Skip to content

Commit bd5c2b1

Browse files
author
nathan
committed
PR c++/80891 (#3)
* cp-tree.h (build_min_nt_call_vec): Declare. * decl.c (build_offset_ref_call_from_tree): Call it. * parser.c (cp_parser_postfix_expression): Likewise. * pt.c (tsubst_copy_and_build): Likewise. * semantics.c (finish_call_expr): Likewise. * tree.c (build_min_nt_loc): Keep unresolved lookups. (build_min): Likewise. (build_min_non_dep): Likewise. (build_min_non_dep_call_vec): Likewise. (build_min_nt_call_vec): New. PR c++/80891 (#3) * g++.dg/lookup/pr80891-3.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248571 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 5fde115 commit bd5c2b1

File tree

9 files changed

+82
-10
lines changed

9 files changed

+82
-10
lines changed

gcc/cp/ChangeLog

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
2017-05-26 Nathan Sidwell <[email protected]>
1+
2017-05-29 Nathan Sidwell <[email protected]>
2+
3+
PR c++/80891 (#3)
4+
* cp-tree.h (build_min_nt_call_vec): Declare.
5+
* decl.c (build_offset_ref_call_from_tree): Call it.
6+
* parser.c (cp_parser_postfix_expression): Likewise.
7+
* pt.c (tsubst_copy_and_build): Likewise.
8+
* semantics.c (finish_call_expr): Likewise.
9+
* tree.c (build_min_nt_loc): Keep unresolved lookups.
10+
(build_min): Likewise.
11+
(build_min_non_dep): Likewise.
12+
(build_min_non_dep_call_vec): Likewise.
13+
(build_min_nt_call_vec): New.
214

315
PR c++/80891 (#2)
416
* tree.c (ovl_copy): Adjust assert, copy OVL_LOOKUP.
517
(ovl_used): New.
618
(lookup_keep): Call it.
719

20+
2017-05-26 Nathan Sidwell <[email protected]>
21+
822
Implement DR2061
923
* name-lookup.c (push_inline_namespaces): New.
1024
(push_namespace): Look inside inline namespaces.

gcc/cp/cp-tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6891,6 +6891,7 @@ extern tree build_min_nt_loc (location_t, enum tree_code,
68916891
...);
68926892
extern tree build_min_non_dep (enum tree_code, tree, ...);
68936893
extern tree build_min_non_dep_op_overload (enum tree_code, tree, tree, ...);
6894+
extern tree build_min_nt_call_vec (tree, vec<tree, va_gc> *);
68946895
extern tree build_min_non_dep_call_vec (tree, tree, vec<tree, va_gc> *);
68956896
extern vec<tree, va_gc>* vec_copy_and_insert (vec<tree, va_gc>*, tree, unsigned);
68966897
extern tree build_cplus_new (tree, tree, tsubst_flags_t);

gcc/cp/decl2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4891,7 +4891,7 @@ build_offset_ref_call_from_tree (tree fn, vec<tree, va_gc> **args,
48914891
|| TREE_CODE (fn) == MEMBER_REF);
48924892
if (type_dependent_expression_p (fn)
48934893
|| any_type_dependent_arguments_p (*args))
4894-
return build_nt_call_vec (fn, *args);
4894+
return build_min_nt_call_vec (fn, *args);
48954895

48964896
orig_args = make_tree_vector_copy (*args);
48974897

gcc/cp/parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6952,7 +6952,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
69526952
{
69536953
maybe_generic_this_capture (instance, fn);
69546954
postfix_expression
6955-
= build_nt_call_vec (postfix_expression, args);
6955+
= build_min_nt_call_vec (postfix_expression, args);
69566956
release_tree_vector (args);
69576957
break;
69586958
}

gcc/cp/pt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17389,7 +17389,7 @@ tsubst_copy_and_build (tree t,
1738917389
&& TREE_CODE (fn) != FIELD_DECL)
1739017390
|| type_dependent_expression_p (fn)
1739117391
|| any_type_dependent_arguments_p (call_args)))
17392-
ret = build_nt_call_vec (function, call_args);
17392+
ret = build_min_nt_call_vec (function, call_args);
1739317393
else if (!BASELINK_P (fn))
1739417394
ret = finish_call_expr (function, &call_args,
1739517395
/*disallow_virtual=*/false,

gcc/cp/semantics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
23222322
if (type_dependent_expression_p (fn)
23232323
|| any_type_dependent_arguments_p (*args))
23242324
{
2325-
result = build_nt_call_vec (fn, *args);
2325+
result = build_min_nt_call_vec (fn, *args);
23262326
SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location));
23272327
KOENIG_LOOKUP_P (result) = koenig_p;
23282328
if (is_overloaded_fn (fn))

gcc/cp/tree.c

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

32283229
tree
@@ -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

32993327
tree
33003328
build_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);

gcc/testsuite/ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
2017-05-29 Nathan Sidwell <[email protected]>
22

3+
PR c++/80891 (#3)
4+
* g++.dg/lookup/pr80891-3.C: New.
5+
36
PR c++/80891 (#2)
47
* g++.dg/lookup/pr80891-2.C: New.
58

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// PR c++/80891 part 3
2+
// We were failing to mark OVERLOADS held in template definitions as
3+
// immutable in non-call contexts.
4+
5+
namespace std {
6+
int endl();
7+
}
8+
9+
using std::endl;
10+
11+
template <class RealType> void test_spots(RealType)
12+
{
13+
using namespace std;
14+
RealType a;
15+
a << endl;
16+
}
17+
18+
template <typename T>
19+
void operator<< (T, int (&)());
20+
21+
struct Q {};
22+
void test_maintest_method()
23+
{
24+
Q q;
25+
test_spots(q);
26+
}

0 commit comments

Comments
 (0)