From bf87e098aefb413abaa78ec5e0d37dc7366c2c86 Mon Sep 17 00:00:00 2001 From: Lee Millward Date: Sun, 27 Aug 2006 15:22:05 +0000 Subject: [PATCH] re PR c++/26573 (Duplicate message for static member in local class) 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 | 6 ++++++ gcc/cp/class.c | 4 ---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/other/static2.C | 12 ++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/static2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5c8b1cb1564..dd1df56fca4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2006-08-27 Lee Millward + + 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 PR c++/24009 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 673b07fb3d0..18996a043b8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6a3dc35284..c6d64573eae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-08-27 Lee Millward + + PR c++/26573 + * g++.dg/other/static2.C: New test. + 2006-08-26 Roger Sayle * 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 index 00000000000..ff1478c2a94 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static2.C @@ -0,0 +1,12 @@ +//PR c++/26573 + +void foo() +{ + struct A { static int i; }; // { dg-error "shall not have" } +} + +template +void bar() +{ + struct B { static int j; }; // { dg-error "shall not have" } +} -- 2.30.2