@@ -3216,13 +3216,14 @@ build_min_nt_loc (location_t loc, enum tree_code code, ...)
32163216 {
32173217 tree x = va_arg (p , tree );
32183218 TREE_OPERAND (t , i ) = x ;
3219+ if (x && TREE_CODE (x ) == OVERLOAD )
3220+ lookup_keep (x , true);
32193221 }
32203222
32213223 va_end (p );
32223224 return t ;
32233225}
32243226
3225-
32263227/* Similar to `build', but for template definitions. */
32273228
32283229tree
@@ -3245,8 +3246,13 @@ build_min (enum tree_code code, tree tt, ...)
32453246 {
32463247 tree x = va_arg (p , tree );
32473248 TREE_OPERAND (t , i ) = x ;
3248- if (x && !TYPE_P (x ) && TREE_SIDE_EFFECTS (x ))
3249- TREE_SIDE_EFFECTS (t ) = 1 ;
3249+ if (x )
3250+ {
3251+ if (!TYPE_P (x ) && TREE_SIDE_EFFECTS (x ))
3252+ TREE_SIDE_EFFECTS (t ) = 1 ;
3253+ if (TREE_CODE (x ) == OVERLOAD )
3254+ lookup_keep (x , true);
3255+ }
32503256 }
32513257
32523258 va_end (p );
@@ -3281,6 +3287,8 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...)
32813287 {
32823288 tree x = va_arg (p , tree );
32833289 TREE_OPERAND (t , i ) = x ;
3290+ if (x && TREE_CODE (x ) == OVERLOAD )
3291+ lookup_keep (x , true);
32843292 }
32853293
32863294 if (code == COMPOUND_EXPR && TREE_CODE (non_dep ) != COMPOUND_EXPR )
@@ -3292,14 +3300,34 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...)
32923300 return convert_from_reference (t );
32933301}
32943302
3295- /* Similar to `build_nt_call_vec', but for template definitions of
3303+ /* Similar to build_min_nt, but call expressions */
3304+
3305+ tree
3306+ build_min_nt_call_vec (tree fn , vec < tree , va_gc > * args )
3307+ {
3308+ tree ret , t ;
3309+ unsigned int ix ;
3310+
3311+ ret = build_vl_exp (CALL_EXPR , vec_safe_length (args ) + 3 );
3312+ CALL_EXPR_FN (ret ) = fn ;
3313+ CALL_EXPR_STATIC_CHAIN (ret ) = NULL_TREE ;
3314+ FOR_EACH_VEC_SAFE_ELT (args , ix , t )
3315+ {
3316+ CALL_EXPR_ARG (ret , ix ) = t ;
3317+ if (TREE_CODE (t ) == OVERLOAD )
3318+ lookup_keep (t , true);
3319+ }
3320+ return ret ;
3321+ }
3322+
3323+ /* Similar to `build_min_nt_call_vec', but for template definitions of
32963324 non-dependent expressions. NON_DEP is the non-dependent expression
32973325 that has been built. */
32983326
32993327tree
33003328build_min_non_dep_call_vec (tree non_dep , tree fn , vec < tree , va_gc > * argvec )
33013329{
3302- tree t = build_nt_call_vec (fn , argvec );
3330+ tree t = build_min_nt_call_vec (fn , argvec );
33033331 if (REFERENCE_REF_P (non_dep ))
33043332 non_dep = TREE_OPERAND (non_dep , 0 );
33053333 TREE_TYPE (t ) = TREE_TYPE (non_dep );
0 commit comments