public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/80465, ICE with generic lambda and noexcept
@ 2017-06-17  2:16 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-06-17  2:16 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 187 bytes --]

We need processing_template_decl to be set when we check
TYPE_NOTHROW_P; let's leave it set across a larger section of the
function.

Tested x86_64-pc-linux-gnu, applying to trunk and 7.

[-- Attachment #2: 80465.diff --]
[-- Type: text/plain, Size: 2094 bytes --]

commit 91eb4dc35508aec3ea6d9939e49f691ac6c47231
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 16 14:49:21 2017 -0400

            PR c++/80465 - ICE with generic lambda with noexcept-specifier.
    
            * lambda.c (maybe_add_lambda_conv_op): Keep processing_template_decl
            set longer for a generic lambda.

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index ee8784c..41d4921 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -987,6 +987,8 @@ maybe_add_lambda_conv_op (tree type)
 			    null_pointer_node);
   if (generic_lambda_p)
     {
+      ++processing_template_decl;
+
       /* Prepare the dependent member call for the static member function
 	 '_FUN' and, potentially, prepare another call to be used in a decltype
 	 return expression for a deduced return call op to allow for simple
@@ -1036,9 +1038,7 @@ maybe_add_lambda_conv_op (tree type)
 
 	if (generic_lambda_p)
 	  {
-	    ++processing_template_decl;
 	    tree a = forward_parm (tgt);
-	    --processing_template_decl;
 
 	    CALL_EXPR_ARG (call, ix) = a;
 	    if (decltype_call)
@@ -1062,11 +1062,9 @@ maybe_add_lambda_conv_op (tree type)
     {
       if (decltype_call)
 	{
-	  ++processing_template_decl;
 	  fn_result = finish_decltype_type
 	    (decltype_call, /*id_expression_or_member_access_p=*/false,
 	     tf_warning_or_error);
-	  --processing_template_decl;
 	}
     }
   else
@@ -1084,6 +1082,9 @@ maybe_add_lambda_conv_op (tree type)
       && TYPE_NOTHROW_P (TREE_TYPE (callop)))
     stattype = build_exception_variant (stattype, noexcept_true_spec);
 
+  if (generic_lambda_p)
+    --processing_template_decl;
+
   /* First build up the conversion op.  */
 
   tree rettype = build_pointer_type (stattype);
diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C
new file mode 100644
index 0000000..46aefdd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type17.C
@@ -0,0 +1,7 @@
+// PR c++/80465
+// { dg-options -std=c++1z }
+
+int foo(...);
+int main() {
+  [](auto a) noexcept(noexcept(foo(a))){}(42);
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-17  2:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-17  2:16 C++ PATCH for c++/80465, ICE with generic lambda and noexcept Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).