diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-01-21 14:04:55 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-01-21 14:04:55 -0500 |
commit | f645da0e4ab9438dfd0c047c710c7ec6a7d6d8f3 (patch) | |
tree | 74874eda6f57c92625bff229fec34338a408c563 /gcc/cp/semantics.c | |
parent | 7944753fad501194eb8a828d6b74270e79d14a4d (diff) | |
download | gcc-f645da0e4ab9438dfd0c047c710c7ec6a7d6d8f3.zip gcc-f645da0e4ab9438dfd0c047c710c7ec6a7d6d8f3.tar.gz gcc-f645da0e4ab9438dfd0c047c710c7ec6a7d6d8f3.tar.bz2 |
c++: Fix excessive instantiation inside decltype [PR71879]
Here after resolving the address of a template-id inside decltype, we
end up instantiating the chosen specialization (from the call to
mark_used in resolve_nondeduced_context), even though only its type is
needed.
This patch sets cp_unevaluated_operand throughout finish_decltype_type,
so that in particular it's set during the call to
resolve_nondeduced_context within.
gcc/cp/ChangeLog:
PR c++/71879
* semantics.c (finish_decltype_type): Set up a cp_unevaluated
sentinel at the start of the function. Remove a now-redundant
manual adjustment of cp_unevaluated_operand.
gcc/testsuite/ChangeLog:
PR c++/71879
* g++.dg/cpp0x/decltype-71879.C: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 244fc70..0670952 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10080,6 +10080,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, return error_mark_node; } + /* decltype is an unevaluated context. */ + cp_unevaluated u; + /* Depending on the resolution of DR 1172, we may later need to distinguish instantiation-dependent but not type-dependent expressions so that, say, A<decltype(sizeof(T))>::U doesn't require 'typename'. */ @@ -10095,9 +10098,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, } else if (processing_template_decl) { - ++cp_unevaluated_operand; expr = instantiate_non_dependent_expr_sfinae (expr, complain); - --cp_unevaluated_operand; if (expr == error_mark_node) return error_mark_node; } |