move to subdirs

From-SVN: r44301
This commit is contained in:
Jason Merrill 2001-07-24 11:08:37 -04:00
parent f8b529aa0a
commit 6f817aaf98
8 changed files with 176 additions and 0 deletions

View File

@ -0,0 +1,19 @@
// Test that we handle mangling of statics in inlines properly.
// { dg-options -fno-weak }
// { dg-do run }
inline int f ()
{
static int nested;
nested = 24;
{
static int nested;
nested = 42;
}
return (nested != 24);
}
int main()
{
return f ();
}

View File

@ -0,0 +1,32 @@
// Test that 'extern template' suppresses instantiations.
// { dg-do link }
// { dg-options "" }
template <class T> void f (T) { }
extern template void f (int);
template <class T> struct A {
void f ();
};
template <class T> void A<T>::f () { }
extern template struct A<int>;
// { dg-error "void f<int>\\(int\\)" "suppressing f<int>" { target *-*-* } "0" }
void test_f_int () { f(42); }
// { dg-error "A<int>::f\\(\\)" "suppressing A<int>" { target *-*-* } "0" }
void test_A_int_f () { A<int> a; a.f (); }
// { dg-bogus "void f<double>\\(double\\)" "f<double>" { target *-*-* } "0" }
void test_f_double () { f (2.0); }
// { dg-bogus "A<double>::f\\(\\)" "A<double>" { target *-*-* } "0" }
void test_A_double_f () { A<double> b; b.f (); }
int main ()
{
test_f_int ();
test_A_int_f ();
test_f_double ();
test_A_double_f ();
}

View File

@ -0,0 +1,10 @@
// Test that we complain about the gcc cast-as-lvalue extension.
int main ()
{
char c;
static_cast<int>(c) = 2; // { dg-error "lvalue" "not an lvalue" }
return c != 2;
}

View File

@ -0,0 +1,28 @@
// Test for the named return value optimization.
// { dg-do run }
// { dg-options -fno-inline }
int c;
int d;
struct A
{
A() { ++c; }
A(const A&) { ++c; };
~A() { ++d; }
};
inline A f ()
{
A a;
return a;
}
int main ()
{
{
A a = f ();
}
return !(c == 1 && c == d);
}

View File

@ -0,0 +1,45 @@
// Submitted by Erik Rozendaal <dlr@acm.org>
// Test case for GNATS bug 787.
// { dg-do run }
#include <stdio.h>
#include <stdlib.h>
static int calls;
int &foo (int &arg)
{
calls++;
arg=0;
return arg;
}
int &identity (int &x)
{
return x;
}
int main()
{
int a;
calls = 0;
int &b = ++foo (a);
if (calls > 1)
abort ();
if (&a != &b)
abort ();
if (a != 1)
abort ();
calls = 0;
int &c = ++identity (++foo (a));
if (calls > 1)
abort ();
if (&a != &c)
abort ();
if (a != 2)
abort ();
exit (0);
}

View File

@ -0,0 +1,42 @@
// Submitted by Jason Merrill <jason_merrill@redhat.com>
// Test for proper handling of local static references.
// { dg-do run }
int r;
int c;
int f ()
{
// Test that we only initialize i once.
if (++c > 1)
++r;
return 42;
}
const int *p;
void g ()
{
static const int &i = f();
// Test that i points to the same place in both calls.
if (p && p != &i)
++r;
// Test that if so, it points to static data.
if (i != 42)
++r;
p = &i;
}
void h ()
{
int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
g ();
}
int main ()
{
g ();
h ();
return r;
}