re PR c++/52688 (static local variable can accessed from local class of function...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sat, 2 Mar 2013 11:17:44 +0000 (11:17 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 2 Mar 2013 11:17:44 +0000 (11:17 +0000)
2013-03-02  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/52688
* g++.dg/template/static33.C: New.
* g++.dg/template/static34.C: Likewise.

PR c++/10291
* g++.dg/template/static35.C: New.

From-SVN: r196405

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/static33.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/static34.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/static35.C [new file with mode: 0644]

index b446a4893e1a009e42fa72fbea301bd2aeb52827..112b6ae37ec817483633b93d7377f0fe9d896f1a 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/52688
+       * g++.dg/template/static33.C: New.
+       * g++.dg/template/static34.C: Likewise.
+
+       PR c++/10291
+       * g++.dg/template/static35.C: New.
+
 2013-03-01  Steve Ellcey  <sellcey@mips.com>
 
        * gcc.dg/pr56396.c: Require pic support.
diff --git a/gcc/testsuite/g++.dg/template/static33.C b/gcc/testsuite/g++.dg/template/static33.C
new file mode 100644 (file)
index 0000000..2d7b97d
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/52688
+// { dg-do link }
+
+template<typename T>
+T f()
+{
+  static const double staticLocalVariable = 100.0;
+  struct local
+  {
+      static double f() { return staticLocalVariable; }
+  };
+  return T(local::f());
+}
+
+int main()
+{
+  f<double>();
+}
diff --git a/gcc/testsuite/g++.dg/template/static34.C b/gcc/testsuite/g++.dg/template/static34.C
new file mode 100644 (file)
index 0000000..122fffa
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/52688
+// { dg-do link }
+
+template<class T>
+struct A {
+  static bool test() {
+    static bool value = false;
+    if (value)
+      return false;
+    struct S {
+      S() { value = true; }
+    };
+    static S s;
+    return true;
+  }
+};
+
+int main()
+{
+  A<int>::test();
+}
diff --git a/gcc/testsuite/g++.dg/template/static35.C b/gcc/testsuite/g++.dg/template/static35.C
new file mode 100644 (file)
index 0000000..d645f24
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/10291
+// { dg-do link }
+
+template <class T>
+int foo ()
+{
+  static int i;
+
+  struct S {
+    int bar () {
+      return i;
+    }
+  } s;
+
+  return s.bar ();
+}
+
+int main ()
+{
+  foo<int>();
+}