move to subdirs
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Jul 2001 15:08:37 +0000 (15:08 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Jul 2001 15:08:37 +0000 (15:08 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44301 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/g++.dg/abi/mangle2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/instantiate1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/lvalue1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/nrv1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/init-ref1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/init-ref2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/stdbool-if.C [moved from gcc/testsuite/g++.dg/stdbool-if.C with 100% similarity]
gcc/testsuite/g++.dg/warn/friend.C [moved from gcc/testsuite/g++.dg/friend-warn.C with 100% similarity]

diff --git a/gcc/testsuite/g++.dg/abi/mangle2.C b/gcc/testsuite/g++.dg/abi/mangle2.C
new file mode 100644 (file)
index 0000000..e8b5f40
--- /dev/null
@@ -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 ();
+}
diff --git a/gcc/testsuite/g++.dg/ext/instantiate1.C b/gcc/testsuite/g++.dg/ext/instantiate1.C
new file mode 100644 (file)
index 0000000..90a4af0
--- /dev/null
@@ -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 ();
+}
diff --git a/gcc/testsuite/g++.dg/ext/lvalue1.C b/gcc/testsuite/g++.dg/ext/lvalue1.C
new file mode 100644 (file)
index 0000000..bf883ea
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/g++.dg/opt/nrv1.C b/gcc/testsuite/g++.dg/opt/nrv1.C
new file mode 100644 (file)
index 0000000..cba1625
--- /dev/null
@@ -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);
+}
diff --git a/gcc/testsuite/g++.dg/other/init-ref1.C b/gcc/testsuite/g++.dg/other/init-ref1.C
new file mode 100644 (file)
index 0000000..d0170cd
--- /dev/null
@@ -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);
+}
diff --git a/gcc/testsuite/g++.dg/other/init-ref2.C b/gcc/testsuite/g++.dg/other/init-ref2.C
new file mode 100644 (file)
index 0000000..6d9448a
--- /dev/null
@@ -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;
+}