summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/noexcept22.C21
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic149.C11
-rw-r--r--gcc/testsuite/g++.dg/eh/uncaught1.C2
-rw-r--r--gcc/testsuite/g++.dg/eh/uncaught4.C29
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr59297.C25
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr60640-1.C50
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr60640-2.C15
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr60640-3.C81
-rw-r--r--gcc/testsuite/g++.dg/template/local8.C18
-rw-r--r--gcc/testsuite/g++.dg/template/using27.C33
-rw-r--r--gcc/testsuite/g++.dg/template/using28.C17
-rw-r--r--gcc/testsuite/g++.dg/template/using29.C21
-rw-r--r--gcc/testsuite/g++.dg/torture/pr60609.C252
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-var-21.C31
14 files changed, 605 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept22.C b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C
new file mode 100644
index 00000000000..7aab0f43c4e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C
@@ -0,0 +1,21 @@
+// PR c++/60046
+// { dg-require-effective-target c++11 }
+
+constexpr bool foo () { return noexcept (true); }
+template <typename T>
+struct V
+{
+ void bar (V &) noexcept (foo ()) {}
+};
+template <typename T>
+struct W : public V <int>
+{
+ void bar (W &x) { V <int>::bar (x); }
+};
+
+int
+main ()
+{
+ W <int> a, b;
+ a.bar (b);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic149.C b/gcc/testsuite/g++.dg/cpp0x/variadic149.C
new file mode 100644
index 00000000000..a250e7c296a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic149.C
@@ -0,0 +1,11 @@
+// PR c++/60248
+// { dg-options "-std=c++11 -g -fabi-version=2" }
+
+template<int...> struct A {};
+
+template<> struct A<0>
+{
+ typedef enum { e } B;
+};
+
+A<0> a;
diff --git a/gcc/testsuite/g++.dg/eh/uncaught1.C b/gcc/testsuite/g++.dg/eh/uncaught1.C
index afbf5af4d22..e96af334a8c 100644
--- a/gcc/testsuite/g++.dg/eh/uncaught1.C
+++ b/gcc/testsuite/g++.dg/eh/uncaught1.C
@@ -13,7 +13,7 @@ struct Check {
static Check const data[] = {
{ 0, 0, false }, // construct [0]
- { 1, 0, true }, // [1] = [0]
+ { 1, 0, false }, // [1] = [0]
{ 0, 0, true }, // destruct [0]
{ 2, 1, true }, // [2] = [1]
{ 2, 2, true }, // destruct [2]
diff --git a/gcc/testsuite/g++.dg/eh/uncaught4.C b/gcc/testsuite/g++.dg/eh/uncaught4.C
new file mode 100644
index 00000000000..227d11b330b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/uncaught4.C
@@ -0,0 +1,29 @@
+// PR c++/41174
+// { dg-do run }
+
+#include <exception>
+
+#define assert(E) if (!(E)) __builtin_abort();
+
+struct e {
+ e()
+ {
+ assert( !std::uncaught_exception() );
+ try {
+ throw 1;
+ } catch (int i) {
+ assert( !std::uncaught_exception() );
+ throw;
+ }
+ }
+};
+
+int main()
+{
+ try {
+ throw e();
+ } catch (int i) {
+ assert( !std::uncaught_exception() );
+ }
+ assert( !std::uncaught_exception() );
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr59297.C b/gcc/testsuite/g++.dg/gomp/pr59297.C
new file mode 100644
index 00000000000..330ed2e00b1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr59297.C
@@ -0,0 +1,25 @@
+// PR c++/59297
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+template <typename T>
+struct A
+{
+ ~A ();
+ const T &operator[] (int) const;
+};
+
+struct B
+{
+ int &operator () (A <int>);
+};
+
+void
+foo (B &x, int &z)
+{
+ A<A<int> > y;
+ #pragma omp atomic
+ x (y[0]) += 1;
+ #pragma omp atomic
+ z += x(y[1]);
+}
diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-1.C b/gcc/testsuite/g++.dg/ipa/pr60640-1.C
new file mode 100644
index 00000000000..7a0b91893f8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr60640-1.C
@@ -0,0 +1,50 @@
+// { dg-do compile }
+// { dg-options "-O3" }
+
+class ASN1Object
+{
+public:
+ virtual ~ASN1Object ();
+};
+class A
+{
+ virtual unsigned m_fn1 () const;
+};
+class B
+{
+public:
+ ASN1Object Element;
+ virtual unsigned m_fn1 (bool) const;
+};
+template <class BASE> class C : public BASE
+{
+};
+
+class D : ASN1Object, public B
+{
+};
+class G : public D
+{
+ unsigned m_fn1 (bool) const {}
+};
+class F : A
+{
+public:
+ F (A);
+ unsigned m_fn1 () const
+ {
+ int a;
+ a = m_fn2 ().m_fn1 (0);
+ return a;
+ }
+ const B &m_fn2 () const { return m_groupParameters; }
+ C<G> m_groupParameters;
+};
+template <class D> void BenchMarkKeyAgreement (int *, int *, int)
+{
+ A f;
+ D d (f);
+}
+
+void BenchmarkAll2 () { BenchMarkKeyAgreement<F>(0, 0, 0); }
+
diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-2.C b/gcc/testsuite/g++.dg/ipa/pr60640-2.C
new file mode 100644
index 00000000000..c6e614cc004
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr60640-2.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-O3" }
+
+struct B { virtual unsigned f () const; };
+struct C { virtual void f (); };
+struct F { virtual unsigned f (bool) const; ~F (); };
+struct J : C, F {};
+struct G : J { unsigned f (bool) const { return 0; } };
+struct H : B
+{
+ H (int);
+ unsigned f () const { return ((const F &) h).f (0); }
+ G h;
+};
+H h (0);
diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-3.C b/gcc/testsuite/g++.dg/ipa/pr60640-3.C
new file mode 100644
index 00000000000..21b1f58a040
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr60640-3.C
@@ -0,0 +1,81 @@
+// { dg-do run }
+// { dg-options "-O3" }
+
+struct Distraction
+{
+ char fc[8];
+ virtual Distraction * return_self ()
+ { return this; }
+};
+
+namespace {
+
+struct A;
+static A * __attribute__ ((noinline, noclone)) get_an_A ();
+
+static int go;
+
+struct A
+{
+ int fi;
+
+ A () : fi(777) {}
+ A (int pi) : fi (pi) {}
+ virtual A * foo (int p) = 0;
+};
+
+struct B;
+static B * __attribute__ ((noinline, noclone)) get_a_B ();
+
+struct B : public Distraction, A
+{
+ B () : Distraction(), A() { }
+ B (int pi) : Distraction (), A (pi) {}
+ virtual B * foo (int p)
+ {
+ int o = fi;
+ for (int i = 0; i < p; i++)
+ o += i + i * i;
+ go = o;
+
+ return get_a_B ();
+ }
+};
+
+
+struct B gb1 (1111), gb2 (2);
+static B * __attribute__ ((noinline, noclone))
+get_a_B ()
+{
+ return &gb1;
+}
+
+static A * __attribute__ ((noinline, noclone))
+get_an_A ()
+{
+ return &gb2;
+}
+
+}
+
+static int __attribute__ ((noinline, noclone))
+get_a_number ()
+{
+ return 5;
+}
+
+extern "C" void abort (void);
+
+int main (int argc, char *argv[])
+{
+ for (int i = 0; i < get_a_number (); i++)
+ {
+ struct A *p = get_an_A ();
+ struct A *r = p->foo (4);
+ if (r->fi != 1111)
+ abort ();
+ if (go != 22)
+ abort ();
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/template/local8.C b/gcc/testsuite/g++.dg/template/local8.C
new file mode 100644
index 00000000000..006bd8c40eb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/local8.C
@@ -0,0 +1,18 @@
+// PR c++/56947
+
+struct A
+{
+ A (int);
+};
+
+template < typename >
+void Fn ()
+{
+ const int kCapacity = 0;
+ struct Q:A
+ {
+ Q ():A (kCapacity) { }
+ };
+ Q q;
+}
+template void Fn < int >();
diff --git a/gcc/testsuite/g++.dg/template/using27.C b/gcc/testsuite/g++.dg/template/using27.C
new file mode 100644
index 00000000000..f1835e17161
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/using27.C
@@ -0,0 +1,33 @@
+// PR c++/37140
+
+struct X
+{
+ typedef int nested_type;
+};
+
+template <class T>
+struct A
+{
+ typedef X type;
+};
+
+template <class T>
+struct B : A<T>
+{
+ using typename A<T>::type;
+ typename type::nested_type x;
+};
+
+template <class T>
+struct C : B<T>
+{
+ using typename B<T>::type;
+ typename type::nested_type y;
+};
+
+struct D : C<int>
+{
+ using C<int>::type;
+ type::nested_type z;
+};
+
diff --git a/gcc/testsuite/g++.dg/template/using28.C b/gcc/testsuite/g++.dg/template/using28.C
new file mode 100644
index 00000000000..52f68cfe467
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/using28.C
@@ -0,0 +1,17 @@
+// PR c++/37140
+
+struct C
+{
+ static const int block_size = 1;
+};
+
+template <typename T> struct A {
+ typedef C type;
+};
+
+template <typename T> struct B : public A<T> {
+ using typename A<T>::type;
+ static const int block_size = type::block_size;
+};
+
+template class B<int>;
diff --git a/gcc/testsuite/g++.dg/template/using29.C b/gcc/testsuite/g++.dg/template/using29.C
new file mode 100644
index 00000000000..8726547efdb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/using29.C
@@ -0,0 +1,21 @@
+// PR c++/58047
+
+template <int N>
+struct print_arg { };
+
+struct const_holder {
+ static const int CONSTANT = 42;
+};
+
+template <typename T>
+struct identity {
+ typedef T type;
+};
+
+template <class T>
+struct test_case : public identity<T> {
+ using typename identity<T>::type;
+ print_arg<type::CONSTANT> printer;
+};
+
+template struct test_case<const_holder>;
diff --git a/gcc/testsuite/g++.dg/torture/pr60609.C b/gcc/testsuite/g++.dg/torture/pr60609.C
new file mode 100644
index 00000000000..9ddec0b601d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr60609.C
@@ -0,0 +1,252 @@
+/* { dg-do assemble } */
+
+class exception
+{
+};
+class bad_alloc:exception
+{
+};
+class logic_error:exception
+{
+};
+class domain_error:logic_error
+{
+};
+class invalid_argument:logic_error
+{
+};
+class length_error:logic_error
+{
+};
+class overflow_error:exception
+{
+};
+typedef int mpz_t[];
+template < class > class __gmp_expr;
+template <> class __gmp_expr < mpz_t >
+{
+ ~__gmp_expr ();
+};
+
+class PIP_Solution_Node;
+class internal_exception
+{
+ ~internal_exception ();
+};
+class not_an_integer:internal_exception
+{
+};
+class not_a_variable:internal_exception
+{
+};
+class not_an_optimization_mode:internal_exception
+{
+};
+class not_a_bounded_integer_type_width:internal_exception
+{
+};
+class not_a_bounded_integer_type_representation:internal_exception
+{
+};
+class not_a_bounded_integer_type_overflow:internal_exception
+{
+};
+class not_a_complexity_class:internal_exception
+{
+};
+class not_a_control_parameter_name:internal_exception
+{
+};
+class not_a_control_parameter_value:internal_exception
+{
+};
+class not_a_pip_problem_control_parameter_name:internal_exception
+{
+};
+class not_a_pip_problem_control_parameter_value:internal_exception
+{
+};
+class not_a_relation:internal_exception
+{
+};
+class ppl_handle_mismatch:internal_exception
+{
+};
+class timeout_exception
+{
+ ~timeout_exception ();
+};
+class deterministic_timeout_exception:timeout_exception
+{
+};
+void __assert_fail (const char *, const char *, int, int *)
+__attribute__ ((__noreturn__));
+void PL_get_pointer (void *);
+int Prolog_is_address ();
+inline int
+Prolog_get_address (void **p1)
+{
+ Prolog_is_address ()? static_cast <
+ void >(0) : __assert_fail ("Prolog_is_address", "./swi_cfli.hh", 0, 0);
+ PL_get_pointer (p1);
+ return 0;
+}
+
+class non_linear:internal_exception
+{
+};
+class not_unsigned_integer:internal_exception
+{
+};
+class not_universe_or_empty:internal_exception
+{
+};
+class not_a_nil_terminated_list:internal_exception
+{
+};
+class PPL_integer_out_of_range
+{
+ __gmp_expr < mpz_t > n;
+};
+void handle_exception ();
+template < typename T > T * term_to_handle (int, const char *)
+{
+ if (Prolog_is_address ())
+ {
+ void *p;
+ Prolog_get_address (&p);
+ return static_cast < T * >(0);
+ }
+ throw;
+}
+
+void
+ppl_new_MIP_Problem_from_MIP_Problem ()
+try
+{
+ term_to_handle < int >(0, "ppl_new_MIP_Problem_from_MIP_Problem/2");
+}
+
+catch (exception &)
+{
+}
+
+int
+ppl_PIP_Tree_Node_parametric_values ()
+{
+ try
+ {
+ PIP_Solution_Node *a = term_to_handle < PIP_Solution_Node > (0, 0);
+ (void)a;
+ return 1;
+ }
+ catch (internal_exception &)
+ {
+ }
+ catch (not_unsigned_integer &)
+ {
+ handle_exception ();
+ }
+ catch (non_linear &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_variable &)
+ {
+ handle_exception ();
+ }
+ catch (not_an_integer &)
+ {
+ handle_exception ();
+ }
+ catch (ppl_handle_mismatch &)
+ {
+ handle_exception ();
+ }
+ catch (not_an_optimization_mode &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_complexity_class &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_bounded_integer_type_width &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_bounded_integer_type_representation &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_bounded_integer_type_overflow &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_control_parameter_name &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_control_parameter_value &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_pip_problem_control_parameter_name &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_pip_problem_control_parameter_value &)
+ {
+ handle_exception ();
+ }
+ catch (not_universe_or_empty &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_relation &)
+ {
+ handle_exception ();
+ }
+ catch (not_a_nil_terminated_list &)
+ {
+ handle_exception ();
+ }
+ catch (PPL_integer_out_of_range &)
+ {
+ handle_exception ();
+ }
+ catch (int &)
+ {
+ } catch (timeout_exception &)
+ {
+ handle_exception ();
+ } catch (deterministic_timeout_exception &)
+ {
+ handle_exception ();
+ } catch (overflow_error &)
+ {
+ handle_exception ();
+ } catch (domain_error &)
+ {
+ handle_exception ();
+ } catch (length_error &)
+ {
+ handle_exception ();
+ } catch (invalid_argument &)
+ {
+ handle_exception ();
+ } catch (logic_error &)
+ {
+ handle_exception ();
+ } catch (bad_alloc &)
+ {
+ handle_exception ();
+ } catch (exception &)
+ {
+ handle_exception ();
+ } catch ( ...)
+ {
+ handle_exception ();
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-21.C b/gcc/testsuite/g++.dg/warn/Wunused-var-21.C
new file mode 100644
index 00000000000..d279e598033
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-21.C
@@ -0,0 +1,31 @@
+// PR c++/58325
+// { dg-do compile }
+// { dg-options "-Wunused" }
+
+void
+f1 ()
+{
+ int *volatile a = new int[1];
+ delete[] a;
+}
+
+void
+f2 ()
+{
+ int *b = new int[1];
+ delete[] b;
+}
+
+void
+f3 ()
+{
+ int *volatile c = new int;
+ delete c;
+}
+
+void
+f4 ()
+{
+ int *d = new int;
+ delete d;
+}