diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2019-01-17 07:32:29 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2019-01-17 07:32:29 +0000 |
commit | b00e9be03aa6f95887d0591c88d177f388118534 (patch) | |
tree | ff492ea98b26e8aec3dfef2b01d53f27608732d3 /gcc | |
parent | 33f746e5585fb4da99cded09a44efd49ef2f22c7 (diff) | |
download | gcc-b00e9be03aa6f95887d0591c88d177f388118534.zip gcc-b00e9be03aa6f95887d0591c88d177f388118534.tar.gz gcc-b00e9be03aa6f95887d0591c88d177f388118534.tar.bz2 |
[PR87768] reset location wrapper suppression when reentering top level
Concepts-checking and other kinds of early tsubsting may often take
place while location wrappers are suppressed, e.g. because we've
triggered template instantiation within template parameter lists.
With that, exprs that are usually wrapped by VIEW_CONVERT_EXPRs
location wrappers may end up wrapped by NON_LVALUE_EXPRs that are not
marked as location wrappers. If such NON_LVALUE_EXPRs tsubsted exprs
undergo another round of tsubsting, say for constraint checking, or
even for another round of specialization, they will be rejected by
tsubst_copy_and_build.
This patch arranges for suppress_location_wrappers to be saved and
reset when pushing to the top level, and restored when popping from
it.
for gcc/cp/ChangeLog
PR c++/87768
* cp-tree.h (saved_scope): Add suppress_location_wrappers.
* name-lookup.c (do_push_to_top_level): Save and reset it.
(do_pop_from_top_level): Restore it.
for gcc/testsuite/ChangeLog
PR c++/87768
* g++.dg/concepts/pr87768.C: New.
From-SVN: r268006
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/concepts/pr87768.C | 14 |
5 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 73f1b76..524fbd3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2019-01-17 Alexandre Oliva <aoliva@redhat.com> + PR c++/87768 + * cp-tree.h (saved_scope): Add suppress_location_wrappers. + * name-lookup.c (do_push_to_top_level): Save and reset it. + (do_pop_from_top_level): Restore it. + PR c++/86648 * pt.c (make_template_placeholder): Use auto_identifier. (is_auto): Drop CLASS_PLACEHOLDER_TEMPLATE test. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 1c85b37..5cc8f88 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1626,6 +1626,7 @@ struct GTY(()) saved_scope { int x_processing_template_decl; int x_processing_specialization; + int suppress_location_wrappers; BOOL_BITFIELD x_processing_explicit_instantiation : 1; BOOL_BITFIELD need_pop_function_context : 1; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b65fd5f..d7b9029 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -7133,6 +7133,7 @@ do_push_to_top_level (void) s->function_decl = current_function_decl; s->unevaluated_operand = cp_unevaluated_operand; s->inhibit_evaluation_warnings = c_inhibit_evaluation_warnings; + s->suppress_location_wrappers = suppress_location_wrappers; s->x_stmt_tree.stmts_are_full_exprs_p = true; scope_chain = s; @@ -7143,6 +7144,7 @@ do_push_to_top_level (void) push_class_stack (); cp_unevaluated_operand = 0; c_inhibit_evaluation_warnings = 0; + suppress_location_wrappers = 0; } static void @@ -7175,6 +7177,7 @@ do_pop_from_top_level (void) current_function_decl = s->function_decl; cp_unevaluated_operand = s->unevaluated_operand; c_inhibit_evaluation_warnings = s->inhibit_evaluation_warnings; + suppress_location_wrappers = s->suppress_location_wrappers; /* Make this saved_scope structure available for reuse by push_to_top_level. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ce3da7..15cdb1e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-01-17 Alexandre Oliva <aoliva@redhat.com> + PR c++/87768 + * g++.dg/concepts/pr87768.C: New. + PR c++/86648 * gcc.dg/cpp1z/pr86648.C: New. diff --git a/gcc/testsuite/g++.dg/concepts/pr87768.C b/gcc/testsuite/g++.dg/concepts/pr87768.C new file mode 100644 index 0000000..de436e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr87768.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++17 } } +// { dg-options "-fconcepts" } + +struct a {}; +template <bool> using b = a; + +template <typename> struct c; +template <typename d> + requires requires(d e) { e[0]; } +struct c<d> { + static constexpr bool f = [] { return false; }(); +}; + +struct g : b<c<unsigned[]>::f> {}; |