re PR c++/26573 (Duplicate message for static member in local class)
authorLee Millward <lee.millward@codesourcery.com>
Sun, 27 Aug 2006 15:22:05 +0000 (15:22 +0000)
committerLee Millward <lmillward@gcc.gnu.org>
Sun, 27 Aug 2006 15:22:05 +0000 (15:22 +0000)
        PR c++/26573
        * class.c (check_field_decls): Don't issue error about
        local classes containing static data members.

        * g++.dg/other/static2.C: New test.

From-SVN: r116490

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

index 5c8b1cb156476a338a113bc80b9d4221a25d5a02..dd1df56fca4c8ef3a26d1ee0e6c2978d5e78893d 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-27  Lee Millward  <lee.millward@codesourcery.com>
+
+        PR c++/26573
+        * class.c (check_field_decls): Don't issue error about
+        local classes containing static data members.
+       
 2006-08-26  Joseph S. Myers  <joseph@codesourcery.com>
 
        PR c++/24009
index 673b07fb3d00ceb869079a17322dd361be92cfe7..18996a043b8ac10cddbcc3bf9d7f291a767b662d 100644 (file)
@@ -2856,10 +2856,6 @@ check_field_decls (tree t, tree *access_decls,
            }
        }
 
-      /* ``A local class cannot have static data members.'' ARM 9.4 */
-      if (current_function_decl && TREE_STATIC (x))
-       error ("field %q+D in local class cannot be static", x);
-
       /* Perform error checking that did not get done in
         grokdeclarator.  */
       if (TREE_CODE (type) == FUNCTION_TYPE)
index c6a3dc352842b36fe0a69409a41c20e62644674f..c6d64573eaeb72f3368f05a1132055caf6d33a58 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-27  Lee Millward  <lee.millward@codesourcery.com>
+
+        PR c++/26573
+        * g++.dg/other/static2.C: New test. 
+       
 2006-08-26  Roger Sayle  <roger@eyesopen.com>
 
        * gcc.dg/Wswitch-enum-2.c: New test case.
diff --git a/gcc/testsuite/g++.dg/other/static2.C b/gcc/testsuite/g++.dg/other/static2.C
new file mode 100644 (file)
index 0000000..ff1478c
--- /dev/null
@@ -0,0 +1,12 @@
+//PR c++/26573
+
+void foo()
+{
+  struct A { static int i; };   // { dg-error "shall not have" }
+}
+
+template<typename T>
+void bar()
+{
+  struct B { static int j; };   // { dg-error "shall not have" }
+}