From 4d23e264150a6513712d8d3649fa398769234182 Mon Sep 17 00:00:00 2001 From: lmillward Date: Sun, 27 Aug 2006 15:22:05 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116490 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 5c8b1cb..dd1df56 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 673b07f..18996a0 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 c6a3dc3..c6d6457 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 0000000..ff1478c --- /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.7.4