re PR c++/52688 (static local variable can accessed from local class of function template)
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
This commit is contained in:
parent
9eb2474821
commit
2609a39863
|
@ -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.
|
||||
|
|
|
@ -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>();
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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>();
|
||||
}
|
Loading…
Reference in New Issue