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 8c0bfd9..6997180 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 5804267..155e350 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 3186805..c06d63a 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" }
+  };
+};