diff options
Diffstat (limited to 'gcc/testsuite/g++.dg')
59 files changed, 1252 insertions, 25 deletions
diff --git a/gcc/testsuite/g++.dg/abi/mangle62.C b/gcc/testsuite/g++.dg/abi/mangle62.C new file mode 100644 index 00000000000..6dbfd7865cf --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle62.C @@ -0,0 +1,11 @@ +// Before v8, we mistakenly treated an unqualified function type +// as a substitution candidate for a function type with function-cv-quals. +// Test for the conformant behavior. + +// { dg-options -fabi-version=0 } + +template <class T, class U> struct A { }; +// { dg-final { scan-assembler "_Z1fP1AIKFvvEFvvEE" } } +void f (A<void()const, void()> *){} +// { dg-final { scan-assembler "_Z1gP1AIFvvEKFvvEE" } } +void g (A<void(), void()const> *){} diff --git a/gcc/testsuite/g++.dg/abi/mangle62a.C b/gcc/testsuite/g++.dg/abi/mangle62a.C new file mode 100644 index 00000000000..fca1cb6c436 --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle62a.C @@ -0,0 +1,11 @@ +// Before v8, we mistakenly treated an unqualified function type +// as a substitution candidate for a function type with function-cv-quals. +// Test for that for backward compatibility. + +// { dg-options -fabi-version=7 } + +template <class T, class U> struct A { }; +// { dg-final { scan-assembler "_Z1fP1AIKFvvES0_E" } } +void f (A<void()const, void()> *){} +// { dg-final { scan-assembler "_Z1gP1AIFvvEKS0_E" } } +void g (A<void(), void()const> *){} diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/cilkplus_AN_cpp_errors.exp b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/cilkplus_AN_cpp_errors.exp new file mode 100644 index 00000000000..7a2360c5a28 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/cilkplus_AN_cpp_errors.exp @@ -0,0 +1,25 @@ +# Copyright (C) 2012-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Written by Balaji V. Iyer <balaji.v.iyer@intel.com> + + +load_lib gcc-dg.exp + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] " -fcilkplus" " " +dg-finish + diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/fp_triplet_values.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/fp_triplet_values.cc index d664c03e439..31dbaf83c04 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/fp_triplet_values.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/fp_triplet_values.cc @@ -1,5 +1,5 @@ -/* {dg-do compile } */ -/* {dg-options } */ +/* { dg-do compile } */ +/* { dg-options } */ #include <cstdlib> float q; #if 1 diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/parser_errors.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/parser_errors.cc index d3fc2a6e5ab..760565e42b3 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/parser_errors.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/parser_errors.cc @@ -1,5 +1,5 @@ -/* {dg-do compile } */ -/* {dg-options } */ +/* { dg-do compile } */ +/* { dg-options } */ int main (int argc, char **argv) { diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit.cc index 70d38f0e6af..b2a1d7b4a27 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit.cc @@ -1,5 +1,5 @@ -/* {dg-do compile } */ -/* {dg-options } */ +/* { dg-do compile } */ +/* { dg-options } */ int main (int argc, char **argv) { diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit2.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit2.cc index f37aa4e27ca..db08c994ffb 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit2.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_implicit2.cc @@ -1,5 +1,5 @@ -/* {dg-do compile } */ -/* {dg-options } */ +/* { dg-do compile } */ +/* { dg-options } */ int main (int argc, char **argv) { diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec.cc new file mode 100644 index 00000000000..ebad022df97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec.cc @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +int main () +{ + int a; + a = __sec_reduce_add(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_mul(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_max(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_min(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_any_zero(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_any_nonzero(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_all_zero(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_all_nonzero(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_max_ind(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce_min_ind(__sec_reduce_add(1)); /* { dg-error "parameter with zero rank" } */ + a = __sec_reduce(0, __sec_reduce_add(1), __sec_reduce_add); /* { dg-error "parameter with zero rank" } */ + __sec_reduce_mutating (&a, __sec_reduce_add(1), __sec_reduce_add); /* { dg-error "parameter with zero rank" } */ + return 0; +} + + diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec2.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec2.cc new file mode 100644 index 00000000000..05e00ef2188 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_inside_sec2.cc @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ +int A[256]; + +int add( int x, int y) +{ + return x+y; +} + +void +check () { + int a; + a = __sec_reduce_min_ind (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_max_ind (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_any_zero (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_any_nonzero (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_all_nonzero (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_max (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_min (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_mul (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce_add (__sec_reduce_min_ind (A[:])); /* { dg-error "cannot have array notation parameter with zero" } */ + a = __sec_reduce (0, __sec_reduce_min_ind (A[:]), add); /* { dg-error "cannot have array notation parameter with zero" } */ + __sec_reduce_mutating (&a, __sec_reduce_min_ind (A[:]), add); /* { dg-error "cannot have array notation parameter with zero" } */ +} + diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_reduce_max_min_ind.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_reduce_max_min_ind.cc index fb41ba3f669..d4a5b773719 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_reduce_max_min_ind.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/sec_reduce_max_min_ind.cc @@ -1,5 +1,5 @@ -/* {dg-do compile } */ -/* {dg-options } */ +/* { dg-do compile } */ +/* { dg-options } */ int main (int argc, char **argv) { diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/tst_lngth.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/tst_lngth.cc new file mode 100644 index 00000000000..68ac452e6f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/errors/tst_lngth.cc @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +#if HAVE_IO +#include <stdio.h> +#endif + +#define N 256 + +template <class T> +int +main2 (int argc, char **argv) +{ + T A[N], B[N]; + T A2[N][N], B2[N][N]; + T A3[N][N][N], B3[N][N][N]; + T A4[N][N][N][N], B4[N][N][N][N]; + A[0:(N / 4)] = A[4]+ B[0:(N / 2):2]; /* { dg-error "length mismatch between" } */ + A[0:(N / 4)] = B[0:(N / 2):2] + N; /* { dg-error "length mismatch between" } */ + A[0:(N / 4)] = B[0:(N / 2):2] + A[4]; /* { dg-error "length mismatch between" } */ + A[0:10:1] = B[0:10:1] + A[0:5:1]; /* { dg-error "length mismatch in " } */ + A[0:10:1] = B[0:5:1] + A[0:10:1]; /* { dg-error "length mismatch in " } */ + A2[:][:] = B2[:][0:5] + B2[:][0:10]; /* { dg-error "length mismatch in " } */ + A2[5][:] = B2[5][0:5] + B2[3][0:10]; /* { dg-error "length mismatch in " } */ + A3[:][5][:] = B3[:][5][0:5] + B3[:][3][0:10]; /* { dg-error "length mismatch in " } */ + A3[:][5][:] = B3[5][:][0:5] + B3[:][3][0:10]; /* { dg-error "length mismatch in " } */ + A4[:][:][:][:] = B4[:][:][0:5][:] + B4[:][:][:][0:5:1]; /* { dg-error "length mismatch in " } */ + return 0; +} + +int main (int argc, char **argv) +{ + main2 <char> (argc, argv); + main2 <short> (argc, argv); + main2 <int> (argc, argv); + main2 <long> (argc, argv); + main2 <long long> (argc, argv); + return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/multiple_insert_check.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/multiple_insert_check.cc new file mode 100644 index 00000000000..edd3a93052e --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/multiple_insert_check.cc @@ -0,0 +1,17 @@ +int A[256]; +int func (int x) { + return x; +} + +/* There was an error that some call exprs were inserted twice. This will + check that issue. */ +int main (int argc, char **argv) +{ + int x = 0; + A[:] = 4; + x = func (__sec_reduce_add(A[0:5:2])) + x; + if (x != 20) + return 1; + else + return 0; +} diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/sec_red_zero_test.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/sec_red_zero_test.cc new file mode 100644 index 00000000000..0b264fecace --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/sec_red_zero_test.cc @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#if HAVE_IO +#include <iostream> +#endif +int A[16]; + +int main () { + A[:] = 5; +#if HAVE_IO + std::cout << __sec_reduce_any_zero(A[:]) << "\n"; +#else + if (__sec_reduce_any_zero (A[:])) + return 1; +#endif + A[:] = 0; +#if HAVE_IO + std::cout << __sec_reduce_any_nonzero(A[:]) << "\n"; +#else + if (__sec_reduce_any_nonzero (A[:])) + return 1; +#endif + return 0; +} + diff --git a/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/test_sec_limits.cc b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/test_sec_limits.cc new file mode 100644 index 00000000000..f8dd4e49413 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/array_notation_tests/execute/test_sec_limits.cc @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-fcilkplus" } */ + +#if HAVE_IO +#include <iostream> +#endif +#include <limits.h> +int A[16]; +int a = 0; + +int main () { + if (__sec_reduce_max(A[0:0:2]) != INT_MIN) { +#if HAVE_IO + std::cout << __sec_reduce_max(A[0:0:2]) << std::endl; +#endif + a++; + } + if (__sec_reduce_min(A[0:0:2]) != INT_MAX) { +#if HAVE_IO + std::cout << __sec_reduce_min(A[0:0:2]) << std::endl; +#endif + a++; + } + + return a; +} + + diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk_keywords_test/compile/c++-cilk-for.cc b/gcc/testsuite/g++.dg/cilk-plus/cilk_keywords_test/compile/c++-cilk-for.cc index 5e9cd23994c..73fbe9fe147 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/cilk_keywords_test/compile/c++-cilk-for.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/cilk_keywords_test/compile/c++-cilk-for.cc @@ -1,5 +1,7 @@ +#if HAVE_IO #include <iostream> #include <cstdio> +#endif #include <cstring> #include <cilk/cilk.h> @@ -32,11 +34,13 @@ CClass::CClass(int a, int b) #if 1 CClass::~CClass() { - cilk_for (int ii = 0; ii < NUMBER; ii++) { +#if 1 + _Cilk_for (int ii = 0; ii < NUMBER; ii++) { x[ii]=0; y[ii]=0; r[ii]=0; } +#endif } int CClass::SomeCalc() @@ -52,7 +56,9 @@ void CClass::PrintValues() { for(int ii = 0; ii < NUMBER; ii++) { +#if HAVE_IO printf("X[%2d]=%2d Y[%2d]=%2d r[%2d]=%3d\n",ii,x[ii],ii,y[ii],ii,r[ii]); +#endif } return; } @@ -61,13 +67,17 @@ int main(void) { CClass vars(5,9); +#if HAVE_IO cout << "Array values BEFORE The Calculation: " << endl; +#endif vars.PrintValues(); vars.SomeCalc(); +#if HAVE_IO cout << "Array values AFTER The Calculation: " << endl; +#endif vars.PrintValues(); return 5; } diff --git a/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/cilkplus_PS_cpp_compile.exp b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/cilkplus_PS_cpp_compile.exp new file mode 100644 index 00000000000..c956054d45b --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/cilkplus_PS_cpp_compile.exp @@ -0,0 +1,24 @@ +# Copyright (C) 2012-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Written by Balaji V. Iyer <balaji.v.iyer@intel.com> + + +load_lib gcc-dg.exp + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] " -O3 -ftree-vectorize -fcilkplus" " " +dg-finish diff --git a/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/tst1.cc b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/tst1.cc new file mode 100644 index 00000000000..b726af792da --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/compile/tst1.cc @@ -0,0 +1,52 @@ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus -O3 -w" } */ + +#define VLEN 4 + +/* The clauses really doesn't make sense in this, the main thing this code + is checking is to see if it can catch the for-loop correctly after + the clauses, and compile successfully. */ +int main (void) +{ + int array[1000]; + int i, nphi = 100, w; + + +#pragma simd vectorlength(VLEN) reduction(+:w) +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} + +#pragma simd reduction(+:w) vectorlength (VLEN) +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} + +#pragma simd vectorlength (VLEN) private(array) +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} + +#pragma simd reduction(+:w) noassert +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} + +#pragma simd vectorlength(VLEN) linear(nphi:1) +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} + +#pragma simd linear(nphi) vectorlength(VLEN) linear(nphi:1) +for (i = 0; i < nphi; i++) +{ + w += array[i]; +} +return w; +} + diff --git a/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/cilkplus_PS_cpp_errors.exp b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/cilkplus_PS_cpp_errors.exp new file mode 100644 index 00000000000..578c3672606 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/cilkplus_PS_cpp_errors.exp @@ -0,0 +1,24 @@ +# Copyright (C) 2012-2013 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Written by Balaji V. Iyer <balaji.v.iyer@intel.com> + + +load_lib gcc-dg.exp + +dg-init +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cc]] " " " " +dg-finish diff --git a/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/for_body_errors.cc b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/for_body_errors.cc index fd60ff26ec5..0165327dc23 100644 --- a/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/for_body_errors.cc +++ b/gcc/testsuite/g++.dg/cilk-plus/pragma_simd_tests/errors/for_body_errors.cc @@ -8,18 +8,18 @@ int main(void) #pragma simd for (ii = 0; ii < 1000; ii++) - break; /* { dg-error "break statments are not allowed" } */ + break; /* { dg-error "break statements are not allowed" } */ #pragma simd linear (ii) for (ii = 0; ii < 1000; ii++) if (ii) - continue; /* { dg-error "continue statments are not allowed" } */ + continue; /* { dg-error "continue statements are not allowed" } */ #pragma simd for (ii = 0; ii < 1000; ii++) { L5: - goto L5; /* { dg-error "goto statments are not allowed" } */ + goto L5; /* { dg-error "goto statements are not allowed" } */ } #pragma simd diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C new file mode 100644 index 00000000000..8003ed9e133 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-specialization.C @@ -0,0 +1,12 @@ +// PR c++/56871 +// { dg-options "-std=c++11" } + +template<typename T> constexpr int foo(T); +template<> int foo(int); +template<> int foo(int); // { dg-error "previous" } +template<> constexpr int foo(int); // { dg-error "redeclaration" } + +template<typename T> int bar(T); +template<> constexpr int bar(int); +template<> constexpr int bar(int); // { dg-error "previous" } +template<> int bar(int); // { dg-error "redeclaration" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C b/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C new file mode 100644 index 00000000000..27797a2fa31 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-call3.C @@ -0,0 +1,132 @@ +// Testcase for N3276 and operator overloading +// { dg-require-effective-target c++11 } + +struct A; +struct B { + A operator()(int); + A operator[](int); + A operator=(int); + A operator+=(int); + A operator-=(int); + A operator*=(int); + A operator/=(int); + A operator^=(int); + A operator&=(int); + A operator|=(int); + A operator<<=(int); + A operator>>=(int); +}; + +A operator-(B); +A operator+(B); +A operator*(B); +A operator&(B); +A operator!(B); +A operator~(B); +A operator++(B); +A operator--(B); + +A operator+(B,B); +A operator-(B,B); +A operator*(B,B); +A operator/(B,B); +A operator%(B,B); +A operator^(B,B); +A operator&(B,B); +A operator|(B,B); +A operator<(B,B); +A operator>(B,B); +A operator,(B,B); +A operator<<(B,B); +A operator>>(B,B); +A operator==(B,B); +A operator->*(B,B); + +#define TRY(E) static_cast<decltype(E)*>(0) + +template <class B> +void f() +{ + B b; + TRY(b(0)); + TRY(b[0]); + TRY(b=0); + TRY(b+=0); + TRY(b-=0); + TRY(b*=0); + TRY(b/=0); + TRY(b^=0); + TRY(b&=0); + TRY(b|=0); + TRY(b<<=0); + TRY(b>>=0); + + TRY(-b); + TRY(+b); + TRY(*b); + TRY(&b); + TRY(!b); + TRY(~b); + TRY(++b); + TRY(--b); + + TRY(b+b); + TRY(b-b); + TRY(b*b); + TRY(b/b); + TRY(b%b); + TRY(b^b); + TRY(b&b); + TRY(b|b); + TRY(b>b); + TRY(b<b); + TRY((b,b)); + TRY(b<<b); + TRY(b>>b); + TRY(b==b); + TRY(b->*b); +} + +int main() +{ + B b; + TRY(b(0)); + TRY(b[0]); + TRY(b=0); + TRY(b+=0); + TRY(b-=0); + TRY(b*=0); + TRY(b/=0); + TRY(b^=0); + TRY(b&=0); + TRY(b|=0); + TRY(b<<=0); + TRY(b>>=0); + + TRY(-b); + TRY(+b); + TRY(*b); + TRY(&b); + TRY(!b); + TRY(~b); + TRY(++b); + TRY(--b); + + TRY(b+b); + TRY(b-b); + TRY(b*b); + TRY(b/b); + TRY(b%b); + TRY(b^b); + TRY(b&b); + TRY(b|b); + TRY(b>b); + TRY(b<b); + TRY((b,b)); + TRY(b<<b); + TRY(b>>b); + TRY(b==b); + TRY(b->*b); + + f<B>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum25.C b/gcc/testsuite/g++.dg/cpp0x/enum25.C new file mode 100644 index 00000000000..cb2cf8f5363 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum25.C @@ -0,0 +1,18 @@ +// PR c++/56793 +// { dg-require-effective-target c++11 } + +struct A +{ + enum struct B {X, Y} b; +} a; + +enum struct D {X,Y}; +struct C { } c; + +int main () +{ + if (a.b == a.B::Y) + a.b = A::B::X; + + c.D::Y; // { dg-error "not a member" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/enum26.C b/gcc/testsuite/g++.dg/cpp0x/enum26.C new file mode 100644 index 00000000000..a21067edb87 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/enum26.C @@ -0,0 +1,8 @@ +// PR c++/54216 +// { dg-options "-std=c++11 -pedantic" } + +enum {}; // { dg-warning "empty anonymous" } + +enum class {}; // { dg-error "anonymous" } + +enum class { x }; // { dg-error "anonymous" } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C index bad33d6e822..dff46b4af76 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-4.C @@ -3,17 +3,17 @@ // Test for syntax support of various attribute permutations. int -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } one [[gnu::unused]] (void); -int one_third [[gnu::noreturn]] [[gnu::unused]] (void); +int one_third [[noreturn]] [[gnu::unused]] (void); int [[gnu::unused]] one_half(); // { dg-warning "ignored" } static -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } void two [[gnu::unused]] (void) {} @@ -21,10 +21,10 @@ void two [[gnu::unused]] (void) {} [[gnu::unused]] int five(void) -[[gnu::noreturn]] // { dg-warning "ignored" } +[[noreturn]] // { dg-warning "ignored" } {} -[[gnu::noreturn]] +[[noreturn]] void six (void) ; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist68.C b/gcc/testsuite/g++.dg/cpp0x/initlist68.C new file mode 100644 index 00000000000..7cfe1a34bee --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist68.C @@ -0,0 +1,20 @@ +// PR c++/56772 +// { dg-require-effective-target c++11 } + +typedef __SIZE_TYPE__ size_t; +void* operator new[](size_t, void *p) { return p; } +template <typename T = size_t> +void f () +{ + size_t coord [2][2]; + new (&coord) size_t [2][2] + { + {0,0}, + {0,0}, + }; +} + +int main () +{ + f<>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto2.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto2.C new file mode 100644 index 00000000000..05fadf5d047 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-auto2.C @@ -0,0 +1,16 @@ +// PR c++/56901 +// { dg-require-effective-target c++11 } + +template <typename> +void foo_impl() +{ + int data; + auto L = [&](){ return data; }; + [&](){ L(); }(); + [&L](){ L(); }(); +} + +void foo() +{ + foo_impl<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C new file mode 100644 index 00000000000..10dc6e36d2b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh3.C @@ -0,0 +1,14 @@ +// PR c++/56388 +// { dg-require-effective-target c++11 } + +int main() +{ + bool /*const*/ condition = false; + + [&]{ + try{} + catch(...){ + if(condition){} + } + }(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for24.C b/gcc/testsuite/g++.dg/cpp0x/range-for24.C new file mode 100644 index 00000000000..b4a5b185bd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for24.C @@ -0,0 +1,15 @@ +// PR c++/56794 +// { dg-require-effective-target c++11 } + +template<int... values> +static void Colors() +{ + static const int colors[] = { values... }; + + for(auto c: colors) { } +} + +int main() +{ + Colors<0,1,2> (); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual-mangle1.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual-mangle1.C new file mode 100644 index 00000000000..c6ef0792b50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual-mangle1.C @@ -0,0 +1,37 @@ +// PR c++/56821 +// { dg-require-effective-target c++11 } + +struct A { + // { dg-final { scan-assembler "_ZNR1A1fEv" } } + void f() & {} + // { dg-final { scan-assembler "_ZNO1A1gEv" } } + void g() && {} + // { dg-final { scan-assembler "_ZNKR1A1hEv" } } + void h() const & {} +}; + +// { dg-final { scan-assembler "_Z1jM1AFvvRE" } } +void j(void (A::*)() &) { } +// { dg-final { scan-assembler "_Z1kM1AFvvOE" } } +void k(void (A::*)() &&) { } +// { dg-final { scan-assembler "_Z1lM1AKFvvRE" } } +void l(void (A::*)() const &) { } + +// { dg-final { scan-assembler "_Z1mIFvvOEEvM1AT_" } } +// { dg-final { scan-assembler "_Z1mIFvvREEvM1AT_" } } +// { dg-final { scan-assembler "_Z1mIKFvvREEvM1AT_" } } +template <typename T> +void m(T A::*) {} + +// { dg-final { scan-assembler "_Z1nIM1AFvvOEEvT_" } } +// { dg-final { scan-assembler "_Z1nIM1AFvvREEvT_" } } +// { dg-final { scan-assembler "_Z1nIM1AKFvvREEvT_" } } +template <typename T> +void n(T) {} + +int main() +{ + j(&A::f); k(&A::g); l(&A::h); + m(&A::f); m(&A::g); m(&A::h); + n(&A::f); n(&A::g); n(&A::h); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C new file mode 100644 index 00000000000..5be89423f03 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual-multi-neg.C @@ -0,0 +1,7 @@ +// { dg-require-effective-target c++11 } + +class Foo +{ +public: + void bar() const && & { } // { dg-error "multiple ref-qualifiers" } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual1.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual1.C new file mode 100644 index 00000000000..7fa826c3db4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual1.C @@ -0,0 +1,30 @@ +// { dg-require-effective-target c++11 } + +template <class,class> struct ST; +template <class T> struct ST<T,T> {}; + +struct A +{ + int f() &; + char f() &&; +}; + +template <class T> struct B +{ + int f() &; + char f() &&; +}; + +int main() +{ + A a; + a.f(); + A().f(); + ST<decltype(a.f()), int>(); + ST<decltype(A().f()), char>(); + B<int> b; + b.f(); + B<int>().f(); + ST<decltype(b.f()), int>(); + ST<decltype(B<int>().f()), char>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual2.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual2.C new file mode 100644 index 00000000000..fa09ab48a15 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual2.C @@ -0,0 +1,75 @@ +// In a .* expression whose object expression is an rvalue, the program is +// ill-formed if the second operand is a pointer to member function with +// ref-qualifier &. In a .* expression whose object expression is an +// lvalue, the program is ill-formed if the second operand is a pointer to +// member function with ref-qualifier &&. + +// { dg-require-effective-target c++11 } + +struct A { + void f() &; + void g() &&; + void h(); +}; + +void one() +{ + A a; + + void (A::*p)() & = &A::f; + (a.*p)(); + (A().*p)(); // { dg-error "" } + + p = &A::g; // { dg-error "" } + p = &A::h; // { dg-error "" } + + void (A::*p2)() && = &A::g; + (A().*p2)(); + (a.*p2)(); // { dg-error "" } + p2 = &A::f; // { dg-error "" } + p2 = &A::h; // { dg-error "" } + + void (A::*p3)() = &A::h; + (a.*p3)(); + (A().*p3)(); + p3 = &A::f; // { dg-error "" } + p3 = &A::g; // { dg-error "" } +} + +template <class T> +struct B { + void f() &; + void g() &&; + void h(); +}; + +template <class T> +void two() +{ + B<T> a; + + void (B<T>::*p)() & = &B<T>::f; + (a.*p)(); + (B<T>().*p)(); // { dg-error "" } + + p = &B<T>::g; // { dg-error "" } + p = &B<T>::h; // { dg-error "" } + + void (B<T>::*p2)() && = &B<T>::g; + (B<T>().*p2)(); + (a.*p2)(); // { dg-error "" } + p2 = &B<T>::f; // { dg-error "" } + p2 = &B<T>::h; // { dg-error "" } + + void (B<T>::*p3)() = &B<T>::h; + (a.*p3)(); + (B<T>().*p3)(); + p3 = &B<T>::f; // { dg-error "" } + p3 = &B<T>::g; // { dg-error "" } +} + +int main() +{ + one(); + two<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual3.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual3.C new file mode 100644 index 00000000000..1b21196321a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual3.C @@ -0,0 +1,29 @@ +// An explicitly defaulted function can have a ref-qualifier. + +// { dg-require-effective-target c++11 } + +struct A { + A& operator=(const A&) & = default; +}; + +template<class T> +struct B { + B& operator=(const B&) & = default; +}; + +template<class T> +void f() +{ + B<T> b; + b = B<T>(); + B<T>() = b; // { dg-error "" } +} + +int main() +{ + A a; + a = A(); + A() = a; // { dg-error "" } + + f<int>(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual4.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual4.C new file mode 100644 index 00000000000..5a0ee162fe5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual4.C @@ -0,0 +1,14 @@ +// 12.1: A constructor shall not be declared with a ref-qualifier. +// 12.4: A destructor shall not be declared with a ref-qualifier. + +// { dg-require-effective-target c++11 } + +struct A { + A() & = default; // { dg-error "constructor" } + ~A() & = default; // { dg-error "destructor" } +}; + +int main() +{ + A a; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual5.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual5.C new file mode 100644 index 00000000000..e3d26e5a78f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual5.C @@ -0,0 +1,13 @@ +// 13.1: ...cannot be overloaded if any of them, but not all, have a +// ref-qualifier. + +// { dg-require-effective-target c++11 } + +class Y { + void h() &; + void h() const &; // OK + void h() &&; // OK, all declarations have a ref-qualifier + void i() &; // { dg-message "" } + void i() const; // { dg-error "" } prior declaration of i + // has a ref-qualifier +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual6.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual6.C new file mode 100644 index 00000000000..02e3f6e683e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual6.C @@ -0,0 +1,15 @@ +// Binding an rvalue to && beats binding it to const& (13.3.3.2). + +// { dg-require-effective-target c++11 } + +struct A +{ + int operator+(int) &&; +}; + +void operator+ (const A&, int); + +int main() +{ + return A() + 42; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual7.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual7.C new file mode 100644 index 00000000000..2430665db34 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual7.C @@ -0,0 +1,19 @@ +// typedef test +// { dg-require-effective-target c++11 } + +typedef void F() &; + +F f; // { dg-error "" } +F* p; // { dg-error "" } +extern F& r; // { dg-error "" } + +struct A { + F f; +}; + +int main() +{ + A a; + a.f(); + A().f(); // { dg-error "" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual8.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual8.C new file mode 100644 index 00000000000..b4c972b3c3b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual8.C @@ -0,0 +1,13 @@ +// { dg-require-effective-target c++11 } + +struct A +{ + virtual void f() & = 0; +}; + +struct B: A +{ + void f(); // doesn't override +}; + +B b; // { dg-error "abstract" } diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae44.C b/gcc/testsuite/g++.dg/cpp0x/sfinae44.C new file mode 100644 index 00000000000..bbcae622630 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae44.C @@ -0,0 +1,26 @@ +// PR c++/56913 +// { dg-do compile { target c++11 } } + +template<typename T> +T &&declval(); + +template<typename T, typename U, + typename = decltype((declval<T>().*declval<U>())())> +constexpr bool test(int) +{ + return true; +} + +template<typename T, typename U> +constexpr bool test(...) +{ + return false; +} + +struct S +{}; + +static_assert(!test<S, void (S::*)() &>(0), ""); +static_assert(test<S, void (S::*)() &&>(0), ""); +static_assert(test<S &, void (S::*)() &>(0), ""); +static_assert(!test<S &, void (S::*)() &&>(0), ""); diff --git a/gcc/testsuite/g++.dg/debug/pr56294.C b/gcc/testsuite/g++.dg/debug/pr56294.C index 204c78eadc6..a9ee807631f 100644 --- a/gcc/testsuite/g++.dg/debug/pr56294.C +++ b/gcc/testsuite/g++.dg/debug/pr56294.C @@ -1,5 +1,6 @@ // { dg-do compile } // { dg-options "-fno-ipa-sra -fcompare-debug" } +// { dg-xfail-if "" { powerpc-ibm-aix* } { "*" } { "" } } struct comp_cost { int cost; unsigned complexity; }; struct cost_pair { struct iv_cand *cand; }; diff --git a/gcc/testsuite/g++.dg/debug/pr56819.C b/gcc/testsuite/g++.dg/debug/pr56819.C new file mode 100644 index 00000000000..62926be2fb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr56819.C @@ -0,0 +1,27 @@ +// PR debug/56819 +// { dg-do compile } +// { dg-options "-fcompare-debug" } + +template <typename> +struct A +{ + template <typename> + struct B; +}; + +template <typename> +struct C +{ + typedef int I; +}; + +template <typename T> +class D +{ + typedef A <void> E; + typedef typename T::template B <E> F; + typedef typename C <F>::I I; + A <I> foo () { return A<I> (); } +}; + +template class D <A <void> >; diff --git a/gcc/testsuite/g++.dg/ext/pr56790-1.C b/gcc/testsuite/g++.dg/ext/pr56790-1.C new file mode 100644 index 00000000000..84feca19c7d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr56790-1.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ccp1" } */ + +typedef long vec __attribute__ ((vector_size (2 * sizeof (long)))); + +vec f (void) +{ + vec a = { 5, 7 }; + vec b = { 11, 13 }; + vec m = { -1, 0 }; + return m ? a : b; +} + +/* { dg-final { scan-tree-dump "{ 5, 13 }" "ccp1" } } */ +/* { dg-final { scan-tree-dump-not "VEC_COND_EXPR" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C index 966ad96306d..7da74a780ac 100644 --- a/gcc/testsuite/g++.dg/gomp/for-19.C +++ b/gcc/testsuite/g++.dg/gomp/for-19.C @@ -9,7 +9,7 @@ void f1 (void) { #pragma omp for - for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } + for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-warning "forbids incrementing a pointer of type" } ; } @@ -27,7 +27,7 @@ void f3 (void) { #pragma omp for - for (T q = T (p); q < T (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } + for (T q = T (p); q < T (p + 4); q++) // { dg-warning "forbids incrementing a pointer of type" } ; } diff --git a/gcc/testsuite/g++.dg/opt/vt2.C b/gcc/testsuite/g++.dg/opt/vt2.C new file mode 100644 index 00000000000..a77db38755a --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/vt2.C @@ -0,0 +1,24 @@ +// PR c++/34949 +// { dg-options "-O3" } +// { dg-final { scan-assembler-not "mov\[^\n\]*_ZTV" { target i?86-*-* x86_64-*-* } } } + +class Foo +{ +public: + virtual ~Foo(); +}; + +Foo::~Foo() +{ +} + + +class Bar : public Foo +{ +public: + virtual ~Bar(); +}; + +Bar::~Bar() +{ +} diff --git a/gcc/testsuite/g++.dg/opt/vt3.C b/gcc/testsuite/g++.dg/opt/vt3.C new file mode 100644 index 00000000000..0cef67206e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/vt3.C @@ -0,0 +1,43 @@ +// PR c++/34949 +// { dg-do compile } +// { dg-options "-O3" } + +struct E {}; +struct A +{ + virtual void a (void *) = 0; +}; +struct B +{ + virtual ~B () {}; + unsigned int b1; + E **b2; + A *b3; +}; +struct C : public B +{ + ~C (); +}; +C::~C () +{ + for (unsigned int i = 0; i < b1; i++) + b3->a (b2); +} +struct D +{ + ~D () {} + C d; +}; +struct F { virtual ~F () {}; }; +struct G { void g (); }; +struct H : public F +{ + virtual ~H (); + D *h1; + G *h2; +}; +H::~H () +{ + h2->g (); + delete h1; +} diff --git a/gcc/testsuite/g++.dg/opt/vt4.C b/gcc/testsuite/g++.dg/opt/vt4.C new file mode 100644 index 00000000000..c8d04cffc16 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/vt4.C @@ -0,0 +1,31 @@ +// PR c++/50243 +// { dg-do compile } +// { dg-options "-O" } +// { dg-final { scan-assembler-not "_ZTV.A" } } + +void foo (); + +struct A +{ + ~A () { } + virtual void a () = 0; + virtual void b () = 0; + virtual void c () = 0; +}; + +struct B : public A +{ + ~B () { foo (); } + void a () { foo (); } + void b () { foo (); } + void c () { delete this; } +}; + +void +test () +{ + A *y = new B (); + y->a (); + y->b (); + y->c (); +} diff --git a/gcc/testsuite/g++.dg/rtti/typeid10.C b/gcc/testsuite/g++.dg/rtti/typeid10.C new file mode 100644 index 00000000000..47b45b1056d --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/typeid10.C @@ -0,0 +1,36 @@ +// PR c++/25466 +// { dg-do run } + +#include <typeinfo> + +const std::type_info *a; + +template <class T> +bool is_polymorphic() { + bool result(false); + const std::type_info &a1 = typeid( (result=true), *(T*)0); + a = &a1; + return result; +} + +struct non_polymorphic {}; +struct polymorphic { virtual ~polymorphic() {} }; + + +int main() { + if (is_polymorphic<int>()) __builtin_abort(); + if (is_polymorphic<non_polymorphic>()) __builtin_abort(); + try + { + is_polymorphic<polymorphic>(); + __builtin_abort(); // should have thrown bad_typeid + } + catch (std::bad_typeid&) + { + // OK + } + catch (...) + { + __builtin_abort(); + } +} diff --git a/gcc/testsuite/g++.dg/template/abstract-dr337.C b/gcc/testsuite/g++.dg/template/abstract-dr337.C index 6905262d6cb..4f66c1c1188 100644 --- a/gcc/testsuite/g++.dg/template/abstract-dr337.C +++ b/gcc/testsuite/g++.dg/template/abstract-dr337.C @@ -6,8 +6,8 @@ class A { }; template<typename T> -void g(T (*a)[1]) {} // { dg-error "abstract" "" } +void g(T (*a)[1]) {} // { dg-error "abstract" "" { xfail *-*-* } } int main() { - g<A<int> >(0); // { dg-error "no matching function" } + g<A<int> >(0); // { dg-error "no matching function" "" { xfail *-*-* } } } diff --git a/gcc/testsuite/g++.dg/template/arrow3.C b/gcc/testsuite/g++.dg/template/arrow3.C new file mode 100644 index 00000000000..b2029ba4894 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/arrow3.C @@ -0,0 +1,38 @@ +// PR c++/56895 +// { dg-do compile } + +extern struct A { bool foo (); A bar (); } *a; + +template <int> +int +baz1 () +{ + return 2 << (a->bar().foo() ? 1 : 0); +} + +template <int> +int +baz2 () +{ + return 2 >> (a->bar().foo() ? 1 : 0); +} + +template <int> +int +baz3 () +{ + return 10 / (a->bar().foo() ? 1 : 2); +} + +template <int> +int +baz4 () +{ + return 10 % (a->bar().foo() ? 1 : 0); +} + +int +test () +{ + return baz1<0> () + baz2<0> () + baz3<0> () + baz4<0> (); +} diff --git a/gcc/testsuite/g++.dg/template/arrow4.C b/gcc/testsuite/g++.dg/template/arrow4.C new file mode 100644 index 00000000000..89e78221958 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/arrow4.C @@ -0,0 +1,19 @@ +// PR c++/56895 +// { dg-do compile } + +void fn (int *); +void fn (int); +extern struct A { bool foo (); A bar (); } *a; + +template <int> +void +baz () +{ + fn (a->bar().foo() ? 1 : 0); +} + +void +test () +{ + baz<0> (); +} diff --git a/gcc/testsuite/g++.dg/template/non-deducible1.C b/gcc/testsuite/g++.dg/template/non-deducible1.C new file mode 100644 index 00000000000..42135248904 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/non-deducible1.C @@ -0,0 +1,8 @@ +// PR c++/23055 + +template <class> struct S { typedef int type; }; + +template <class T> +int foo(T, typename S<T>::type * ret); + +int j = foo(1, 0); diff --git a/gcc/testsuite/g++.dg/template/nontype25.C b/gcc/testsuite/g++.dg/template/nontype25.C index bcdcce5ea9b..f3994083ebe 100644 --- a/gcc/testsuite/g++.dg/template/nontype25.C +++ b/gcc/testsuite/g++.dg/template/nontype25.C @@ -7,7 +7,7 @@ template<const A* a> class C {}; template<const B* b> class D {}; template<B* b> class E {}; -template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {} // { dg-error "" "" { target c++98 } } +template<const B* b> void f(D<b> &, C<static_cast<const A*>(b)> &) {} // { dg-error "" "" } template<const B* b> void g(D<b> &, E<const_cast<B*>(b)> &) {} // { dg-error "" "" { target c++98 } } B b; diff --git a/gcc/testsuite/g++.dg/torture/pr56768.C b/gcc/testsuite/g++.dg/torture/pr56768.C new file mode 100644 index 00000000000..db504c500e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr56768.C @@ -0,0 +1,41 @@ +// { dg-do compile } +// { dg-options "-std=c++0x" } + +struct Iter +{ + int& operator* (); + void operator++ (); +}; + +bool operator!= (Iter &, Iter &) { } + +struct Container +{ + Iter begin () const; + Iter end () const; +}; + +struct J +{ + virtual J *mutable_child (); +}; + +struct M +{ + M (const Container &); + J ns_; +}; +namespace +{ + J MakeNamespace (const Container &src) + { + J a; + J *b = 0; + for (const int &c: src) + b = b ? b->mutable_child () : &a; + return a; + } +} +M::M (const Container &ns):ns_ (MakeNamespace (ns)) +{ +} diff --git a/gcc/testsuite/g++.dg/torture/pr56817.C b/gcc/testsuite/g++.dg/torture/pr56817.C new file mode 100644 index 00000000000..35fc6f74ff2 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr56817.C @@ -0,0 +1,38 @@ +// { dg-do compile } +// { dg-options "--param max-unroll-times=32" } + +struct A {}; +A **q; +struct B +{ + A **j; + B () { j = q; } + A *& operator[] (unsigned long x) { return j[x]; } +}; +struct C +{ + C (int r) : v (), s (r) {} + A *& operator () (int i, int j) { return v[i * s + j]; } + B v; + int s; +}; +struct D +{ + D () + { + unsigned h = 2; + for (int i = 0; i < 1; ++i, h *= 2) + { + C w (h); + for (unsigned j = 0; j < h; ++j) + for (unsigned k = 0; k < h; ++k) + w (j, k) = new A; + } + } +}; +void +foo () +{ + for (int i = 0; i < 3; i++) + A (), A (), D (); +} diff --git a/gcc/testsuite/g++.dg/torture/pr56837.C b/gcc/testsuite/g++.dg/torture/pr56837.C new file mode 100644 index 00000000000..d0071228047 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr56837.C @@ -0,0 +1,20 @@ +// { dg-do run } +// { dg-options "-ftree-loop-distribute-patterns" } + +extern "C" void abort (void); +extern "C" int memcmp (const void *, const void *, __SIZE_TYPE__); + +bool b1[8]; +bool b2[8] = { true, true, true, true, true, true, true, true }; + +int main() +{ + unsigned int i; + for(i=0 ; i < 8; i++) + b1[i] = true; + + if (memcmp (b1, b2, 8) != 0) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/torture/pr56854.C b/gcc/testsuite/g++.dg/torture/pr56854.C new file mode 100644 index 00000000000..fc7e30299f6 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr56854.C @@ -0,0 +1,24 @@ +// PR tree-optimization/56854 +// { dg-do compile } + +inline void * +operator new (__SIZE_TYPE__, void *p) throw () +{ + return p; +} + +struct A +{ + int a; + A () : a (0) {} + ~A () {} + A &operator= (const A &v) { this->~A (); new (this) A (v); return *this; } +}; +A b[4], c[4]; + +void +foo () +{ + for (int i = 0; i < 4; ++i) + c[i] = b[i]; +} diff --git a/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C b/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C index 0a29ce9cb4f..b0faa93e3c5 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C +++ b/gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C @@ -26,6 +26,6 @@ t (void) // { dg-final { scan-tree-dump-times "Empty EH handler" 2 "ehcleanup1" } } // // And as a result also contained control flow. -// { dg-final { scan-tree-dump-times "Removing unreachable" 4 "ehcleanup1" } } +// { dg-final { scan-tree-dump-times "Removing unreachable" 6 "ehcleanup1" } } // // { dg-final { cleanup-tree-dump "ehcleanup1" } } diff --git a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc new file mode 100644 index 00000000000..9b2fcc683c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc @@ -0,0 +1,21 @@ +/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+/* { dg-require-effective-target vect_hw_misalign } */
+/* { dg-additional-options "-O3 -funroll-loops -fvect-cost-model" } */
+
+class mydata {
+public:
+ mydata() {Set(-1.0);}
+ void Set (float);
+ static int upper() {return 8;}
+ float data[8];
+};
+
+void mydata::Set (float x)
+{
+ for (int i=0; i<upper(); i++)
+ data[i] = x;
+}
+
+/* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 1 "slp" } } */
+/* { dg-final { cleanup-tree-dump "slp" } } */
diff --git a/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C b/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C new file mode 100644 index 00000000000..a4aa6960897 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C @@ -0,0 +1,13 @@ +// PR c++/56815 +// { dg-options "-Wpointer-arith" } + +int main() +{ + void *pv = 0; + pv++; // { dg-warning "forbids incrementing a pointer" } + + typedef void (*pft) (); + + pft pf = 0; + pf++; // { dg-warning "forbids incrementing a pointer" } +} |