From 771ce78ea0c1c51c2fe1579dea950d40a1b8028d Mon Sep 17 00:00:00 2001 From: Simon Baldwin Date: Mon, 4 Aug 2008 15:09:56 +0000 Subject: [PATCH] re PR c++/36999 (Erroneous "declaration 'class ...' does not declare anything" warnings possible) PR c++/36999 * parser.c (cp_parser_elaborated_type_specifier): Warn only when the declaration's id is followed by a semicolon. * g++.dg/warn/pr36999.C: New. From-SVN: r138633 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/pr36999.C | 40 +++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/pr36999.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c865326d0bc..c40b9894e43 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2008-08-04 Simon Baldwin + + PR c++/36999 + * parser.c (cp_parser_elaborated_type_specifier): Warn only when + the declaration's id is followed by a semicolon. + 2008-07-31 Jakub Jelinek PR c++/36405 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 15b66b03b95..76adb633ed7 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11516,7 +11516,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, caught elsewhere in parsing. Those that are pointless arrive here. */ - if (cp_parser_declares_only_class_p (parser) + if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON) && !is_friend && !processing_explicit_instantiation) warning (0, "declaration %qD does not declare anything", decl); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8c0f18eb123..2803cfedfed 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-08-04 Simon Baldwin + + PR c++/36999 + * g++.dg/warn/pr36999.C: New. + 2008-08-04 Arnaud Charlet * gnat.dg/bip_aggregate_bug.adb: New test. diff --git a/gcc/testsuite/g++.dg/warn/pr36999.C b/gcc/testsuite/g++.dg/warn/pr36999.C new file mode 100644 index 00000000000..ce2286efcf4 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr36999.C @@ -0,0 +1,40 @@ +/* PR36999: Erroneous "does not declare anything" warnings. */ +/* { dg-do compile } */ + +class C1 { + public: class C2 { }; +}; + +void cf1 (class C1::C2, void*); // { dg-bogus "does not declare anything" } +void cf2 (void*, class C1::C2); +void cf3 (C1::C2, void*); + +namespace N { + +enum E1 { foo }; +enum E2 { bar }; + +template +class TC1 { }; + +template +class TC2 : public TC1 { }; + +} + +void +tcf1 (N::TC2 *arg1, // { dg-bogus "does not declare anything" } + N::TC2 *arg2, + N::TC2 *arg3) +{ +} + +void * +tcf2 (void *x) +{ + return (void *) + (N::TC2 *) // { dg-bogus "does not declare anything" } + (N::TC2 *) + (N::TC2 *) + x; +} -- 2.11.4.GIT