@@ -83,7 +83,7 @@ bool cpp_typecheck_fargst::match(
8383{
8484 distance=0 ;
8585
86- exprt::operandst ops = operands;
86+ exprt::operandst ops= operands;
8787 const code_typet::parameterst ¶meters=code_type.parameters ();
8888
8989 if (parameters.size ()>ops.size ())
@@ -109,7 +109,8 @@ bool cpp_typecheck_fargst::match(
109109 return false ;
110110 }
111111
112- for (std::size_t i=0 ; i<ops.size (); i++)
112+ exprt::operandst::iterator it=ops.begin ();
113+ for (const auto ¶meter : parameters)
113114 {
114115 // read
115116 // http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/topic/com.ibm.xlcpp8a.doc/language/ref/implicit_conversion_sequences.htm
@@ -119,16 +120,9 @@ bool cpp_typecheck_fargst::match(
119120 // * User-defined conversion sequences
120121 // * Ellipsis conversion sequences
121122
122- if (i>=parameters.size ())
123- {
124- // Ellipsis is the 'worst' of the conversion sequences
125- distance+=1000 ;
126- continue ;
127- }
128-
129- exprt parameter=parameters[i];
130-
131- exprt &operand=ops[i];
123+ assert (it!=ops.end ());
124+ const exprt &operand=*it;
125+ typet type=parameter.type ();
132126
133127 #if 0
134128 // unclear, todo
@@ -140,13 +134,13 @@ bool cpp_typecheck_fargst::match(
140134
141135 // "this" is a special case -- we turn the pointer type
142136 // into a reference type to do the type matching
143- if (i== 0 && parameter.get (ID_C_base_name)==ID_this)
137+ if (it==ops. begin () && parameter.get (ID_C_base_name)==ID_this)
144138 {
145- parameter. type () .set (ID_C_reference, true );
146- parameter. type () .set (" #this" , true );
139+ type.set (ID_C_reference, true );
140+ type.set (" #this" , true );
147141 }
148142
149- unsigned rank = 0 ;
143+ unsigned rank= 0 ;
150144 exprt new_expr;
151145
152146 #if 0
@@ -156,7 +150,7 @@ bool cpp_typecheck_fargst::match(
156150
157151 // can we do the standard conversion sequence?
158152 if (cpp_typecheck.implicit_conversion_sequence (
159- operand, parameter. type () , new_expr, rank))
153+ operand, type, new_expr, rank))
160154 {
161155 // ok
162156 distance+=rank;
@@ -171,7 +165,14 @@ bool cpp_typecheck_fargst::match(
171165 #endif
172166 return false ; // no conversion possible
173167 }
168+
169+ ++it;
174170 }
175171
172+ // we may not have used all operands
173+ for ( ; it!=ops.end (); ++it)
174+ // Ellipsis is the 'worst' of the conversion sequences
175+ distance+=1000 ;
176+
176177 return true ;
177178}
0 commit comments