From 401219a6c93d1ba14cee07ed0ab7935f04072358 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 21 Sep 2000 18:05:48 -0400 Subject: [PATCH] * decl2.c (get_guard): Check DECL_FUNCTION_SCOPE_P. From-SVN: r36567 --- gcc/testsuite/g++.old-deja/g++.pt/static11.C | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/static11.C diff --git a/gcc/testsuite/g++.old-deja/g++.pt/static11.C b/gcc/testsuite/g++.old-deja/g++.pt/static11.C new file mode 100644 index 00000000000..07e6fd71d0b --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/static11.C @@ -0,0 +1,29 @@ +// Bug: g++ was failing to destroy C::a because it was using two +// different sentry variables for construction and destruction. + +extern "C" void _exit (int); + +int r = 1; + +struct A +{ + void f(){}; + A(){ ++r; } + ~A(){ r -= 2; _exit (r); } +}; + +template +struct C +{ + C(){ a.f(); } + static A a; +}; + +template A C::a; +typedef C B; + +int main() +{ + C c; + return r; +}