re PR c++/32870 (Unclear error message when declaring struct in wrong namespace)
authorPaolo Carlini <paolo@gcc.gnu.org>
Fri, 17 Aug 2007 09:35:23 +0000 (09:35 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 17 Aug 2007 09:35:23 +0000 (09:35 +0000)
/cp
2007-08-17  Paolo Carlini  <pcarlini@suse.de>

PR c++/32870
* parser.c (cp_parser_class_head): Improve error message.

/testsuite
2007-08-17  Paolo Carlini  <pcarlini@suse.de>

PR c++/32870
* g++.dg/other/error17.C: Adjust.

From-SVN: r127581

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error17.C [new file with mode: 0644]

index 89172af26d7846518e557410a84b38bceb782f75..15e1819d09e26396cb6dcbab0d91903588176508 100644 (file)
@@ -1,7 +1,12 @@
+2007-08-17  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32870
+       * parser.c (cp_parser_class_head): Improve error message.
+
 2007-08-16  Seongbae Park  <seongbae.park@gmail.com>
 
-        * pt.c (instantiate_decl): Set input_location
-        for the function end.
+       * pt.c (instantiate_decl): Set input_location
+       for the function end.
 
 2007-08-16  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
index b4ffd2fa4bdd7b9fe0c6574361e449cd3349fd9f..70006c9174a8e97fe8b0ce400494ed046257f0a5 100644 (file)
@@ -14417,8 +14417,12 @@ cp_parser_class_head (cp_parser* parser,
         class was originally declared, the program is invalid.  */
       if (scope && !is_ancestor (scope, nested_name_specifier))
        {
-         error ("declaration of %qD in %qD which does not enclose %qD",
-                type, scope, nested_name_specifier);
+         if (at_namespace_scope_p ())
+           error ("declaration of %qD in namespace %qD which does not "
+                  "enclose %qD", type, scope, nested_name_specifier);
+         else
+           error ("declaration of %qD in %qD which does not enclose %qD",
+                  type, scope, nested_name_specifier);
          type = NULL_TREE;
          goto done;
        }
index b8f5839bfae33b23c4cf193ca734d447f5ec48f2..ee7d70a794e59412d39691df1198c73ed0c6ad30 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-17  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32870
+       * g++.dg/other/error17.C: Adjust.
+       
 2007-08-17  Ben Elliston  <bje@au.ibm.com>
 
        PR middle-end/32970
diff --git a/gcc/testsuite/g++.dg/other/error17.C b/gcc/testsuite/g++.dg/other/error17.C
new file mode 100644 (file)
index 0000000..18769ef
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/32870
+
+struct Foo {
+  struct Bar;
+};
+
+namespace N {
+  struct Foo::Bar { }; // { dg-error "in namespace 'N'" }
+}
+
+struct Baz {
+  struct Foo::Bar { }; // { dg-error "in 'struct Baz'" }
+};