From 70366e8358b7ad49ae722a9d7e7296264ebd44af Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 27 Sep 2011 21:52:19 +0000 Subject: [PATCH] /cp 2011-09-27 Paolo Carlini PR c++/31489 * parser.c (cp_parser_elaborated_type_specifier): For RECORD_TYPE, set CLASSTYPE_DECLARED_CLASS. /testsuite 2011-09-27 Paolo Carlini PR c++/31489 * g++.dg/parse/error40.C: New. * g++.dg/warn/incomplete1.C: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179293 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 8 +++++++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/parse/error40.C | 10 ++++++++++ gcc/testsuite/g++.dg/warn/incomplete1.C | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/error40.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 24068c8..596d4a9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-09-27 Paolo Carlini + + PR c++/31489 + * parser.c (cp_parser_elaborated_type_specifier): For RECORD_TYPE, + set CLASSTYPE_DECLARED_CLASS. + 2011-09-27 Jakub Jelinek * decl.c (duplicate_decls): If compatible stpcpy prototype diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 9600aa9..83d7b71 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1f47b45..01eed5c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-09-27 Paolo Carlini + + PR c++/31489 + * g++.dg/parse/error40.C: New. + * g++.dg/warn/incomplete1.C: Adjust. + 2011-09-27 Jan Hubicka 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 index 0000000..9ab7552 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error40.C @@ -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'" } +} diff --git a/gcc/testsuite/g++.dg/warn/incomplete1.C b/gcc/testsuite/g++.dg/warn/incomplete1.C index 26cfe2e..9dc645d 100644 --- a/gcc/testsuite/g++.dg/warn/incomplete1.C +++ b/gcc/testsuite/g++.dg/warn/incomplete1.C @@ -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" "" } -- 2.7.4