This is the mail archive of the
mailing list for the GCC project.
Re: V4 Lambda templates and implicit function templates.
- From: Adam Butcher <adam at jessamine dot co dot uk>
- To: Jason Merrill <jason at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, Gabriel Dos Reis <gdr at integrable-solutions dot net>, Andrew Sutton <andrew dot n dot sutton at gmail dot com>
- Date: Wed, 11 Sep 2013 19:22:31 +0100
- Subject: Re: V4 Lambda templates and implicit function templates.
- Authentication-results: sourceware.org; auth=none
- References: <1378779587-15362-1-git-send-email-adam at jessamine dot co dot uk> <494a4f7e9b38392bcd602695ed9fbaed at imap dot force9 dot net> <52308151 dot 5060400 at redhat dot com> <52308B7F dot 1020206 at redhat dot com>
On 11.09.2013 16:25, Jason Merrill wrote:
Great, that fixes it. Hadn't noticed it didn't happen a namespace
On 09/11/2013 10:42 AM, Jason Merrill wrote:
Sounds like the problem is that the compiler is trying to
function while cp_unevaluated_operand is set. But that shouldn't be
issue because push_to_top_level clears cp_unevaluated_operand. How
it come to be set when instantiating the local variable?
Ah, I see: it's because instantiate_decl doesn't push_to_top_level
for function-local templates. We still need to save/restore
cp_unevaluated_operand in that case, and let's also do
Okay for the attached to go to trunk with suitable changelog?
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 22087fb..16e57b5 100644
@@ -18947,6 +18947,8 @@ instantiate_decl (tree d, int defer_ok,
location_t saved_loc = input_location;
+ int saved_unevaluated_operand = cp_unevaluated_operand;
+ int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
@@ -19158,8 +19160,13 @@ instantiate_decl (tree d, int defer_ok,
nested = (current_function_decl != NULL_TREE);
- else if (nested)
- push_function_context ();
+ if (nested)
+ push_function_context ();
+ cp_unevaluated_operand = 0;
+ c_inhibit_evaluation_warnings = 0;
/* Mark D as instantiated so that recursive calls to
instantiate_decl do not try to instantiate it again. */
@@ -19283,6 +19290,8 @@ instantiate_decl (tree d, int defer_ok,
input_location = saved_loc;
+ cp_unevaluated_operand = saved_unevaluated_operand;
+ c_inhibit_evaluation_warnings = saved_inhibit_evaluation_warnings;