re PR c++/17121 (Link problem with function-local classes)
authorMark Mitchell <mark@codesourcery.com>
Sat, 21 Aug 2004 01:31:27 +0000 (01:31 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 21 Aug 2004 01:31:27 +0000 (01:31 +0000)
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
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/local1.C [new file with mode: 0644]

index 2b794f05ea2f1cce4c89b6c1d73117810ab6ed82..c0f488e94a229e81aedee84e0fdb02184c496e09 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-20  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/17121
+       * decl.c (expand_static_init): Use DECL_FUNCTION_SCOPE_P.
+
 2004-08-21  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c++/17120
index 36e83d9c1a52ac08b6d3bdb4838a0a6d55865780..d9a74492c1bd647782d621a6427de4a0f7372a0a 100644 (file)
@@ -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;
index d096a1b696dfbc6531979701f08384ce5883c745..24756293f5f725a76fba838ed00276e478513fe4 100644 (file)
@@ -1,3 +1,8 @@
+2004-08-20  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/17121
+       * g++.dg/inherit/local2.C: New test.
+
 2004-08-21  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c++/17120
@@ -5,6 +10,9 @@
 
 2004-08-20  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/17121
+       * g++.dg/inherit/local2.C: New test.
+
        * gcc.dg/darwin-longlong.c: Include <stdlib.h>.
        * 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 (file)
index 0000000..3cb196c
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/17121
+
+struct A {
+  virtual ~A() {}
+};
+
+void tsk_tsk()
+{
+  struct B : public A {};
+}