]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/31489 (error says struct when it should say class)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 27 Sep 2011 21:52:19 +0000 (21:52 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 27 Sep 2011 21:52:19 +0000 (21:52 +0000)
/cp
2011-09-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/31489
* parser.c (cp_parser_elaborated_type_specifier): For RECORD_TYPE,
set CLASSTYPE_DECLARED_CLASS.

/testsuite
2011-09-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/31489
* g++.dg/parse/error40.C: New.
* g++.dg/warn/incomplete1.C: Adjust.

From-SVN: r179293

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

index 24068c8168b86575c562242c6bac9e92b82d483c..596d4a97f7070544a55d7ffd90e7d8c84470491f 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/31489
+       * parser.c (cp_parser_elaborated_type_specifier): For RECORD_TYPE,
+       set CLASSTYPE_DECLARED_CLASS.
+
 2011-09-27  Jakub Jelinek  <jakub@redhat.com>
 
        * decl.c (duplicate_decls): If compatible stpcpy prototype
index 9600aa954384747379859fe12501cd5818b51528..83d7b71c8c4c22ee6068eca2f74f868d38d56543 100644 (file)
@@ -13423,7 +13423,13 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
     }
 
   if (tag_type != enum_type)
-    cp_parser_check_class_key (tag_type, type);
+    {
+      /* Indicate whether this class was declared as a `class' or as a
+        `struct'.  */
+      if (TREE_CODE (type) == RECORD_TYPE)
+       CLASSTYPE_DECLARED_CLASS (type) = (tag_type == class_type);
+      cp_parser_check_class_key (tag_type, type);
+    }
 
   /* A "<" cannot follow an elaborated type specifier.  If that
      happens, the user was probably trying to form a template-id.  */
index 1f47b452c1b466a9915221828f1f4adb53296ffd..01eed5cca7ef506767711332860d8a7df5213956 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/31489
+       * g++.dg/parse/error40.C: New.
+       * g++.dg/warn/incomplete1.C: Adjust.
+
 2011-09-27  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/49463
diff --git a/gcc/testsuite/g++.dg/parse/error40.C b/gcc/testsuite/g++.dg/parse/error40.C
new file mode 100644 (file)
index 0000000..9ab7552
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/31489
+
+class foo;   // { dg-error "'class foo'" }
+struct bar;  // { dg-error "'struct bar'" }
+
+int main()
+{
+  foo* f = new foo; // { dg-error "'class foo'" }
+  bar* b = new bar; // { dg-error "'struct bar'" }
+}
index 26cfe2eae4bdec0e578e679ed0b45088c76eaa51..9dc645d82f9d132c063a13dce15b70bef5c3564b 100644 (file)
@@ -9,7 +9,7 @@
 // (But the deletion does not constitute an ill-formed program. So the
 // program should nevertheless compile, but it should give a warning.)
 
-class A;       // { dg-warning "forward declaration of 'struct A'" "" }
+class A;       // { dg-warning "forward declaration of 'class A'" "" }
 
 A *a;          // { dg-warning "'a' has incomplete type" "" }