From eba6cfb6b5694f15f880827805ca7d0b0907c60d Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sat, 21 Aug 2004 01:31:27 +0000 Subject: [PATCH] re PR c++/17121 (Link problem with function-local classes) PR c++/17121 * decl.c (expand_static_init): Use DECL_FUNCTION_SCOPE_P. PR c++/17121 * g++.dg/inherit/local2.C: New test. From-SVN: r86353 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 2 +- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/g++.dg/inherit/local1.C | 10 ++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/inherit/local1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2b794f05ea2..c0f488e94a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-08-20 Mark Mitchell + + PR c++/17121 + * decl.c (expand_static_init): Use DECL_FUNCTION_SCOPE_P. + 2004-08-21 Joseph S. Myers PR c++/17120 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 36e83d9c1a5..d9a74492c1b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5151,7 +5151,7 @@ expand_static_init (tree decl, tree init) && TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) return; - if (! toplevel_bindings_p ()) + if (DECL_FUNCTION_SCOPE_P (decl)) { /* Emit code to perform this initialization but once. */ tree if_stmt; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d096a1b696d..24756293f5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-08-20 Mark Mitchell + + PR c++/17121 + * g++.dg/inherit/local2.C: New test. + 2004-08-21 Joseph S. Myers PR c++/17120 @@ -5,6 +10,9 @@ 2004-08-20 Mark Mitchell + PR c++/17121 + * g++.dg/inherit/local2.C: New test. + * gcc.dg/darwin-longlong.c: Include . * gcc.dg/ppc-ldstruct.c: Likewise. * gcc.dg/ppc64-abi-2.c: Likewise. diff --git a/gcc/testsuite/g++.dg/inherit/local1.C b/gcc/testsuite/g++.dg/inherit/local1.C new file mode 100644 index 00000000000..3cb196c38d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/inherit/local1.C @@ -0,0 +1,10 @@ +// PR c++/17121 + +struct A { + virtual ~A() {} +}; + +void tsk_tsk() +{ + struct B : public A {}; +} -- 2.30.2