===================================================================
@@ -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" "" }
===================================================================
@@ -0,0 +1,8 @@
+// PR c++/31489
+
+class foobar; // { dg-error "'class foobar'" }
+
+int main()
+{
+ foobar * o = new foobar; // { dg-error "'class foobar'" }
+}
===================================================================
@@ -13423,7 +13423,13 @@ cp_parser_elaborated_type_specifier (cp_parser* pa
}
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. */