aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSimon Baldwin <simonb@google.com>2008-08-04 15:09:56 +0000
committerSimon Baldwin <simonb@gcc.gnu.org>2008-08-04 15:09:56 +0000
commit771ce78ea0c1c51c2fe1579dea950d40a1b8028d (patch)
tree8cb01afe7fc8381db4660b4397422f3d4d566d0a /gcc
parent6fc3c2b2c42c5d5a177867aa5390f054d7d8a8a8 (diff)
downloadgcc-771ce78ea0c1c51c2fe1579dea950d40a1b8028d.zip
gcc-771ce78ea0c1c51c2fe1579dea950d40a1b8028d.tar.gz
gcc-771ce78ea0c1c51c2fe1579dea950d40a1b8028d.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/warn/pr36999.C40
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c865326..c40b989 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-04 Simon Baldwin <simonb@google.com>
+
+ 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 <jakub@redhat.com>
PR c++/36405
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 15b66b0..76adb63 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 8c0f18e..2803cfe 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-04 Simon Baldwin <simonb@google.com>
+
+ PR c++/36999
+ * g++.dg/warn/pr36999.C: New.
+
2008-08-04 Arnaud Charlet <charlet@adacore.com>
* 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 0000000..ce2286e
--- /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 X>
+class TC1 { };
+
+template <class T, class U>
+class TC2 : public TC1<T> { };
+
+}
+
+void
+tcf1 (N::TC2<enum N::E1, void*> *arg1, // { dg-bogus "does not declare anything" }
+ N::TC2<void*, enum N::E1> *arg2,
+ N::TC2<N::E1, void*> *arg3)
+{
+}
+
+void *
+tcf2 (void *x)
+{
+ return (void *)
+ (N::TC2<enum N::E1, void*> *) // { dg-bogus "does not declare anything" }
+ (N::TC2<void*, enum N::E1> *)
+ (N::TC2<N::E1, void*> *)
+ x;
+}