re PR c++/84605 (internal compiler error: in xref_basetypes, at cp/decl.c:13818)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 4 Mar 2019 23:49:23 +0000 (23:49 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 4 Mar 2019 23:49:23 +0000 (23:49 +0000)
/cp
2019-03-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84605
* parser.c (cp_parser_class_head): Reject TYPE_BEING_DEFINED too.

/testsuite
2019-03-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/84605
* g++.dg/parse/crash69.C: New.

From-SVN: r269378

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

index 8c0bfd994ebe7fb4e5847ee3cc0256619c8efafc..699718000999a02d78af9e8bf0d80b36aeb3f301 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84605
+       * parser.c (cp_parser_class_head): Reject TYPE_BEING_DEFINED too.
+
 2019-03-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/71446
index 580426780ea67bada91e9fbb6c464151266e79a8..155e350d01d607e4d1d10b5f56af1de136306348 100644 (file)
@@ -24021,8 +24021,11 @@ cp_parser_class_head (cp_parser* parser,
   cp_parser_check_class_key (class_key, type);
 
   /* If this type was already complete, and we see another definition,
-     that's an error.  */
-  if (type != error_mark_node && COMPLETE_TYPE_P (type))
+     that's an error.  Likewise if the type is already being defined:
+     this can happen, eg, when it's defined from within an expression 
+     (c++/84605).  */
+  if (type != error_mark_node
+      && (COMPLETE_TYPE_P (type) || TYPE_BEING_DEFINED (type)))
     {
       error_at (type_start_token->location, "redefinition of %q#T",
                type);
index 3186805c9cb2afbc079dbf02a9485038981d4e12..c06d63a17a6bedd69225830a4c8bb50245240fe3 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/84605
+       * g++.dg/parse/crash69.C: New.
+
 2019-03-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/71446
diff --git a/gcc/testsuite/g++.dg/parse/crash69.C b/gcc/testsuite/g++.dg/parse/crash69.C
new file mode 100644 (file)
index 0000000..a85bbee
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/84605
+
+struct b {
+  int x(((struct b {})));  // { dg-error "expected|redefinition" }
+};
+
+struct c {
+  struct d {
+    int x(((struct c {})));  // { dg-error "expected|redefinition" }
+  };
+};