]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56646 (ICE: in cp_parser_late_return_type_opt, at cp/parser.c:16970)
authorJason Merrill <jason@redhat.com>
Sat, 23 Mar 2013 05:01:12 +0000 (01:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 23 Mar 2013 05:01:12 +0000 (01:01 -0400)
PR c++/56646
* parser.c (cp_parser_late_return_type_opt): Save and restore
current_class_ptr/ref.

From-SVN: r197000

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp0x/trailing9.C [new file with mode: 0644]

index acecb5add443cf0473b8ecbeeec56c892224757a..7cf4e666608818fb17e53b34f5dc820eb182f059 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-20  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56646
+       * parser.c (cp_parser_late_return_type_opt): Save and restore
+       current_class_ptr/ref.
+
 2013-03-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/56614
index cdb524e2f0334fa831572246429330799daf7c64..f875b66ffa4a595f5c0ab1c2bfc60bc464a00577 100644 (file)
@@ -16699,17 +16699,21 @@ cp_parser_late_return_type_opt (cp_parser* parser, cp_cv_quals quals)
   /* Consume the ->.  */
   cp_lexer_consume_token (parser->lexer);
 
+  tree save_ccp = current_class_ptr;
+  tree save_ccr = current_class_ref;
   if (quals >= 0)
     {
       /* DR 1207: 'this' is in scope in the trailing return type.  */
-      gcc_assert (current_class_ptr == NULL_TREE);
       inject_this_parameter (current_class_type, quals);
     }
 
   type = cp_parser_trailing_type_id (parser);
 
   if (quals >= 0)
-    current_class_ptr = current_class_ref = NULL_TREE;
+    {
+      current_class_ptr = save_ccp;
+      current_class_ref = save_ccr;
+    }
 
   return type;
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/trailing9.C b/gcc/testsuite/g++.dg/cpp0x/trailing9.C
new file mode 100644 (file)
index 0000000..d7895b3
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/56646
+// { dg-require-effective-target c++11 }
+
+struct A {
+  void f();
+};
+
+void A::f() {
+  struct B {
+    auto g() -> void { }
+  };
+}