re PR c++/36999 (Erroneous "declaration 'class ...' does not declare anything" warnin...
authorSimon Baldwin <simonb@google.com>
Mon, 4 Aug 2008 15:09:56 +0000 (15:09 +0000)
committerSimon Baldwin <simonb@gcc.gnu.org>
Mon, 4 Aug 2008 15:09:56 +0000 (15:09 +0000)
        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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr36999.C [new file with mode: 0644]

index c865326d0bc19e0e418dbf0740b3c5a4aff0b1da..c40b9894e4351b4734c8ee8664081ca0bd3e3cc6 100644 (file)
@@ -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
index 15b66b03b9586a6b45f0fb1863ab5be8ad99e93e..76adb633ed7639cb6bc63e704644bd1be3f99b4e 100644 (file)
@@ -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);
 
index 8c0f18eb1231bc5e8e0c728fb54524b671d32d31..2803cfedfed2adc1bdbd829f33838cb411423ea3 100644 (file)
@@ -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 (file)
index 0000000..ce2286e
--- /dev/null
@@ -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;
+}