diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/g++.dg/other | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/g++.dg/other')
251 files changed, 5085 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/PR23205.C b/gcc/testsuite/g++.dg/other/PR23205.C new file mode 100644 index 000000000..273535444 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/PR23205.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* *-*-netware* alpha*-*-* hppa*64*-*-* ia64-*-* *-*-vxworks } { "*" } { "" } } */ +/* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types" } */ + +const int foobar = 4; +int foo () +{ + return foobar + 1; +} + +int main() +{ + int i; + i = foo(); + return i; +} + +/* { dg-final { scan-assembler ".stabs.*foobar:(c=i|S)" } } */ diff --git a/gcc/testsuite/g++.dg/other/abstract1.C b/gcc/testsuite/g++.dg/other/abstract1.C new file mode 100644 index 000000000..8406f8a25 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/abstract1.C @@ -0,0 +1,59 @@ +// { dg-do compile } +// Contributed by <giovannibajo at gcc dot gnu dot org>, +// <pavel_vozenilek at hotmail dot com>, +// <bangerth at dealii dot org> +// c++/9256: Make sure that a pointer to an array of abstract elements +// cannot be created, not even during template substitution (DR337). + +struct Abstract { virtual void f() = 0; }; // { dg-message "note" } +struct Complete { void f(); }; + + +/* + * TEST 1 + * Arrays of abstract elements cannot be declared. + */ + +Abstract a0[2]; // { dg-error "" } +Abstract (*a1)[2]; // { dg-error "" } +Abstract (**a2)[2]; // { dg-error "" } +Abstract (***a3)[2]; // { dg-error "" } +Abstract *a4; +Abstract *a5[2]; +Abstract (*a6[2])[2]; // { dg-error "" } +Abstract **a7[2]; +Abstract *(*a8[2])[2]; +Abstract (**a9[2])[2]; // { dg-error "" } + +/* + * TEST 2 + * If a pointer to an array of abstract elements is created during template + * instantiation, an error should occur. + */ + +template <class T> struct K { + T (*a)[2]; // { dg-error "abstract class type" } +}; + +template struct K<Abstract>; // { dg-message "instantiated" } + + + +/* + * TEST 3 + * Deducing an array of abstract elements during type deduction is a silent + * failure (rejects overload). + */ + +template <bool> struct StaticAssert; +template <> struct StaticAssert<true> {}; + +typedef char Yes; +typedef struct { char x[2]; } No; + +template<typename U> No is_abstract(U (*k)[1]); +template<typename U> Yes is_abstract(...); + +StaticAssert<sizeof(is_abstract<Abstract>(0)) == sizeof(Yes)> b1; +StaticAssert<sizeof(is_abstract<Complete>(0)) == sizeof(No)> b2; +StaticAssert<sizeof(is_abstract<int>(0)) == sizeof(No)> b3; diff --git a/gcc/testsuite/g++.dg/other/abstract2.C b/gcc/testsuite/g++.dg/other/abstract2.C new file mode 100644 index 000000000..b79493285 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/abstract2.C @@ -0,0 +1,58 @@ +// { dg-do compile } +// Contributed by Gabriel Dos Reis <gdr at integrable-solutions dot net> +// PR c++/2204: Check for parameters of abstract type in function declarations. + +namespace N1 { + struct X; + + struct Y1 { + void g(X parm1); // { dg-error "abstract" } + void g(X parm2[2]); // { dg-error "abstract" } + void g(X (*parm3)[2]); // { dg-error "abstract" } + }; + + + template <int N> + struct Y2 { + void g(X parm4); // { dg-error "abstract" } + void g(X parm5[2]); // { dg-error "abstract" } + void g(X (*parm6)[2]); // { dg-error "abstract" } + }; + + struct X { // { dg-message "note" } + virtual void xfunc(void) = 0; // { dg-message "note" } + }; +} + +namespace N2 { + struct X1 { // { dg-message "note" } + virtual void xfunc(void) = 0; // { dg-message "note" } + void g(X1 parm7); // { dg-error "abstract" } + void g(X1 parm8[2]); // { dg-error "abstract" } + void g(X1 (*parm9)[2]); // { dg-error "abstract" } + }; + + template <int N> + struct X2 { // { dg-message "note" } + virtual void xfunc(void) = 0; // { dg-message "note" } + void g(X2 parm10); // { dg-error "abstract" } + void g(X2 parm11[2]); // { dg-error "abstract" } + void g(X2 (*parm12)[2]); // { dg-error "abstract" } + }; +} + +namespace N3 { + struct X { // { dg-message "note" "" } + virtual void xfunc(void) = 0; // { dg-message "note" } + }; + void g(X parm13); // { dg-error "abstract" } + void g(X parm14[2]); // { dg-error "abstract" } + void g(X (*parm15)[2]); // { dg-error "abstract" } + + template <int N> + void g(X parm16); // { dg-error "abstract" } + template <int N> + void g(X parm17[2]); // { dg-error "abstract" } + template <int N> + void g(X (*parm18)[2]); // { dg-error "abstract" } +} diff --git a/gcc/testsuite/g++.dg/other/access1.C b/gcc/testsuite/g++.dg/other/access1.C new file mode 100644 index 000000000..ee3239b93 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/access1.C @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Mar 2002 <nathan@codesourcery.com> + +// PR c++/5659. Failed to notice default accessed changed + +class Foo; +struct Foo +{ + static int m; +}; + +class Outer { + private: + class Inner; + Inner *i; + public: + void pub(); +}; + +struct Outer::Inner { + Inner(int i); +}; + +void Outer::pub() { i = new Inner(Foo::m); } diff --git a/gcc/testsuite/g++.dg/other/access2.C b/gcc/testsuite/g++.dg/other/access2.C new file mode 100644 index 000000000..c7dd77a04 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/access2.C @@ -0,0 +1,35 @@ +// { dg-do compile } +// Origin: Dirk Mueller <dmuell@gmx.net> + +// PR c++/2739 +// Access to base class private static member. + +class Base { +private: + static int fooprivate; +protected: + static int fooprotected; +public: + static int foopublic; +}; + +class Derived : public Base { +public: + void test(); +}; + +int Base::fooprivate=42; // { dg-error "private" } +int Base::fooprotected=42; +int Base::foopublic=42; + +void Derived::test() { + if ( fooprivate ); // { dg-error "context" } + if ( fooprotected ); + if ( foopublic ); +} + +int main() +{ + Derived d; + d.test(); +} diff --git a/gcc/testsuite/g++.dg/other/access3.C b/gcc/testsuite/g++.dg/other/access3.C new file mode 100644 index 000000000..2c21c1e5f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/access3.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-fno-access-control" } + +// PR c++/20022 + +// Make sure -fno-access-control doesn't crash, and actually grants at +// least some access. + +class B { + enum A {}; +}; + +B::A r; diff --git a/gcc/testsuite/g++.dg/other/anon-struct.C b/gcc/testsuite/g++.dg/other/anon-struct.C new file mode 100644 index 000000000..a23e8094e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon-struct.C @@ -0,0 +1,9 @@ +// Contributed by Gabriel Dos Reis <gdr@codesourcery.com> +// { dg-do compile } + +namespace N { } + +namespace M +{ + typedef struct { } N; +} diff --git a/gcc/testsuite/g++.dg/other/anon-union.C b/gcc/testsuite/g++.dg/other/anon-union.C new file mode 100644 index 000000000..51598bf3a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon-union.C @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-options -O2 } + +int foo (); +double bar (void) +{ + union + { + char a[8]; + double b; + }; + + a[0] = foo (); + a[1] = foo (); + a[2] = foo (); + a[3] = foo (); + a[4] = foo (); + a[5] = foo (); + a[6] = foo (); + a[7] = foo (); + return b; +} diff --git a/gcc/testsuite/g++.dg/other/anon2.C b/gcc/testsuite/g++.dg/other/anon2.C new file mode 100644 index 000000000..98d8c2065 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon2.C @@ -0,0 +1,22 @@ +// Test that we can have an unnamed struct inside an anonymous union. + +struct A +{ + union + { + struct { int i; } foo; + }; +}; + +static union +{ + struct { int i; } foo; +}; + +int main () +{ + union + { + struct { int i; } bar; + }; +} diff --git a/gcc/testsuite/g++.dg/other/anon3.C b/gcc/testsuite/g++.dg/other/anon3.C new file mode 100644 index 000000000..87116eb89 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon3.C @@ -0,0 +1,7 @@ +// pr c++/15049 +// Origin: Matt Austern <austern@apple.com> +// Test that we can declare a global variable whose type is anonymous. + +// { dg-do compile } + +enum { a = 3 } x; // { dg-warning "anonymous type" } diff --git a/gcc/testsuite/g++.dg/other/anon4.C b/gcc/testsuite/g++.dg/other/anon4.C new file mode 100644 index 000000000..571f4ae65 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon4.C @@ -0,0 +1,8 @@ +// PR c++/27951 +// { dg-do compile } + +void foo() +{ + int i; // { dg-error "previously" } + union { int i; }; // { dg-error "redeclaration" } +} diff --git a/gcc/testsuite/g++.dg/other/anon5.C b/gcc/testsuite/g++.dg/other/anon5.C new file mode 100644 index 000000000..e8ebe0cc2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/anon5.C @@ -0,0 +1,23 @@ +// PR c++/34094 +// { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* alpha*-dec-osf* mips-sgi-irix* } } } } +// { dg-options "-g" } + +namespace { + struct c + { + static const bool t = 0; + }; +} + +const bool &f() +{ + return c::t; // { dg-message "undefined" "undefined" { target *-*-* } 0 } + // Some targets report the error for the previous line, others + // don't give line number inforamtion for it, so use line 0. +} + +int main(void) +{ + return 0; +} + diff --git a/gcc/testsuite/g++.dg/other/arm-neon-1.C b/gcc/testsuite/g++.dg/other/arm-neon-1.C new file mode 100644 index 000000000..33cc04b69 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/arm-neon-1.C @@ -0,0 +1,18 @@ +/* Basic smoke test for arm_neon.h */ + +/* { dg-do assemble } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-add-options arm_neon } */ + +#include "arm_neon.h" + +float a[4]; + +void test(void) +{ + float32x2x2_t v; + float32x2_t res; + v = vld2_f32(a); + res = vadd_f32(v.val[0], v.val[1]); + vst1_f32(a, res); +} diff --git a/gcc/testsuite/g++.dg/other/array1.C b/gcc/testsuite/g++.dg/other/array1.C new file mode 100644 index 000000000..aff960e57 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array1.C @@ -0,0 +1,10 @@ +// Test typeid of multidimensional array with no bounds. +// { dg-do compile } + +#include <typeinfo> + +int main() +{ + const char *s = typeid(double[][]).name(); // { dg-error "bounds|confused" } + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/array2.C b/gcc/testsuite/g++.dg/other/array2.C new file mode 100644 index 000000000..b091d96be --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array2.C @@ -0,0 +1,6 @@ +// PR c++/25263 +// { dg-do compile } + +int x[1/0]; // { dg-warning "division by zero" } + // { dg-error "constant" "constant" { target *-*-* } 4 } + diff --git a/gcc/testsuite/g++.dg/other/array3.C b/gcc/testsuite/g++.dg/other/array3.C new file mode 100644 index 000000000..ce3641e8c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array3.C @@ -0,0 +1,14 @@ +// PR C++/28906: new on an array causes incomplete arrays to +// become complete with the wrong size. + +// the bounds of xvalue_store was being set to include want +// which was incorrect. + +// { dg-do compile } + +extern unsigned char xvalue_store[]; +bool reserve (int want) +{ + new unsigned char[want]; +} +unsigned char xvalue_store[257]; diff --git a/gcc/testsuite/g++.dg/other/array4.C b/gcc/testsuite/g++.dg/other/array4.C new file mode 100644 index 000000000..97ccc986d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array4.C @@ -0,0 +1,19 @@ +// PR C++/28906: new on an array causes incomplete arrays to +// become complete with the wrong size. +// The sizeof machineMain should be 5 and not 100. +// { dg-do run } + + +extern char machineMain[]; +void sort (long len) +{ + new char[100]; +} +char machineMain[] = "main"; +int main(void) +{ + if (sizeof(machineMain)!=sizeof("main")) + __builtin_abort(); +} + + diff --git a/gcc/testsuite/g++.dg/other/array5.C b/gcc/testsuite/g++.dg/other/array5.C new file mode 100644 index 000000000..df551e380 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array5.C @@ -0,0 +1,9 @@ +// Check to make sure changing from an incomplete +// array type to a complete one does not change other +// incomplete array type's bounds. +// { dg-do compile } + +extern unsigned char xvalue_store[]; +extern unsigned char xvalue_store1[]; +unsigned char xvalue_store[7]; +unsigned char xvalue_store1[9]; diff --git a/gcc/testsuite/g++.dg/other/array6.C b/gcc/testsuite/g++.dg/other/array6.C new file mode 100644 index 000000000..cd02401f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/array6.C @@ -0,0 +1,11 @@ +// PR c++/43036 + +typedef char T6[2][8]; +const T6* p1; +typedef char T[8]; +typedef T T2[2]; +typedef T T3[2]; +typedef char T5[2][8]; +const T2* p2; +const T5* p3; +const T3* p4; diff --git a/gcc/testsuite/g++.dg/other/assign1.C b/gcc/testsuite/g++.dg/other/assign1.C new file mode 100644 index 000000000..1983680dd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/assign1.C @@ -0,0 +1,7 @@ +// PR c++/27716 +// { dg-do compile } + +int foo() +{ + return i ""= i; // { dg-error "not declared|string constant" } +} diff --git a/gcc/testsuite/g++.dg/other/big-struct.C b/gcc/testsuite/g++.dg/other/big-struct.C new file mode 100644 index 000000000..dcf230dd6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/big-struct.C @@ -0,0 +1,11 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-require-effective-target ilp32 } + +struct A +{ +}; + +struct B : public A +{ + char b[0x20000000]; +} e; diff --git a/gcc/testsuite/g++.dg/other/bitfield1.C b/gcc/testsuite/g++.dg/other/bitfield1.C new file mode 100644 index 000000000..896490fba --- /dev/null +++ b/gcc/testsuite/g++.dg/other/bitfield1.C @@ -0,0 +1,9 @@ +// { dg-options "-w" } + +union u1 { + char m1 : 16; +} x; + +int main () { + x.m1 = 256; +} diff --git a/gcc/testsuite/g++.dg/other/bitfield2.C b/gcc/testsuite/g++.dg/other/bitfield2.C new file mode 100644 index 000000000..cd9a837dc --- /dev/null +++ b/gcc/testsuite/g++.dg/other/bitfield2.C @@ -0,0 +1,9 @@ +// PR c++/28052 +// { dg-do compile } + +struct A +{ + double d : 2; // { dg-error "non-integral" } + A() {} + ~A() {} +}; diff --git a/gcc/testsuite/g++.dg/other/bitfield3.C b/gcc/testsuite/g++.dg/other/bitfield3.C new file mode 100644 index 000000000..befd7f817 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/bitfield3.C @@ -0,0 +1,19 @@ +// PR c++/33841 +// { dg-do compile } + +template<int> struct A +{ + // multiple errors below: missing semicolon, no anonymous structs, etc. + struct {} : 2; // { dg-error "" } +}; + +template<int> struct B +{ + int a; + // multiple errors below: missing semicolon, no anonymous structs, etc. + struct {} : 2; // { dg-error "" } + int b; +}; + +struct C : A<0> {}; +struct D : B<0> {}; diff --git a/gcc/testsuite/g++.dg/other/bitfield4.C b/gcc/testsuite/g++.dg/other/bitfield4.C new file mode 100644 index 000000000..d140f82cb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/bitfield4.C @@ -0,0 +1,10 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin PR c++/42217 +// { dg-do compile } + +struct A +{ + int : 0; +}; +A a = A(); + diff --git a/gcc/testsuite/g++.dg/other/builtin-unreachable-1.C b/gcc/testsuite/g++.dg/other/builtin-unreachable-1.C new file mode 100644 index 000000000..f6a557703 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/builtin-unreachable-1.C @@ -0,0 +1,11 @@ +// PR c++/40445 +// Check that a function containing only __builtin_unreachable() +// doesn't ICE. + +// { dg-do compile } +// { dg-options "-O0" } +const char * +f (void) +{ + __builtin_unreachable (); +} diff --git a/gcc/testsuite/g++.dg/other/builtin1.C b/gcc/testsuite/g++.dg/other/builtin1.C new file mode 100644 index 000000000..886658199 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/builtin1.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +void foo() +{ + __builtin_isless (foo, 0); /* { dg-error "non-floating-point arguments" } */ +} diff --git a/gcc/testsuite/g++.dg/other/canon-31724.C b/gcc/testsuite/g++.dg/other/canon-31724.C new file mode 100644 index 000000000..1a39f78a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/canon-31724.C @@ -0,0 +1,8 @@ +struct ac {ac();}; +ac spline_rep1(void) +{ + typedef ac at[2]; + ac * b = new ac[2]; + at *a = (at*)b; + return (*a)[0]; +} diff --git a/gcc/testsuite/g++.dg/other/canon-33194.C b/gcc/testsuite/g++.dg/other/canon-33194.C new file mode 100644 index 000000000..496aafe2c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/canon-33194.C @@ -0,0 +1,21 @@ +// PR c++/33194 +void c_translate_location ( + void (*fail) ( + const char *fmt, ...) + __attribute__ ((noreturn, + format (printf, 1, 2))) + ); + + +struct dwflpp +{ + static void loc2c_error (const char *fmt, ...) + { + } + + void + translate_location() + { + return c_translate_location (&loc2c_error); + } +}; diff --git a/gcc/testsuite/g++.dg/other/canon-37342.C b/gcc/testsuite/g++.dg/other/canon-37342.C new file mode 100644 index 000000000..dd96e40eb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/canon-37342.C @@ -0,0 +1,8 @@ +class Asm; +template<typename _CharT> class basic_ostream; +typedef basic_ostream<char> ostream; +class Options { + typedef void (Asm::* emitfunc_t) (ostream &); + emitfunc_t getemit () const { return emitfunc; } + emitfunc_t emitfunc; +}; diff --git a/gcc/testsuite/g++.dg/other/classkey1.C b/gcc/testsuite/g++.dg/other/classkey1.C new file mode 100644 index 000000000..80ab6756c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/classkey1.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Feb 2002 <nathan@codesourcery.com> + +// PR 775. Some mismatches which were broken. + +template <class T> struct A {}; +union A<int> a; // { dg-error "'union' tag" "" } + +template <> union A<float> {}; // { dg-error "'union' tag" "" } + +struct B {}; +union B b; // { dg-error "'union' tag" "" } + +union C {}; +class C c; // { dg-error "'class' tag" "" } diff --git a/gcc/testsuite/g++.dg/other/complex1.C b/gcc/testsuite/g++.dg/other/complex1.C new file mode 100644 index 000000000..5c0351428 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/complex1.C @@ -0,0 +1,28 @@ +// PR middle-end/18882 +// Origin: Petr Mikulik <mikulik@physics.muni.cz> +// Testcase by Wolfgang Bangerth <bangerth@dealii.com> + +// { dg-do run } +// { dg-options "" } + +extern "C" void abort (); + +struct C { + __complex__ long double c; +}; + +void foo() +{ + C x = {2+2i}; + + int n = 1; + C y = (n==1) ? x : (C){3+3i}; + if (__imag__ y.c != 2) + abort (); +} + +int main(void) +{ + foo (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/component1.C b/gcc/testsuite/g++.dg/other/component1.C new file mode 100644 index 000000000..601e019ae --- /dev/null +++ b/gcc/testsuite/g++.dg/other/component1.C @@ -0,0 +1,29 @@ +// { dg-do compile } + +// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 28 Dec 2001 <nathan@codesourcery.com> + +// PR 5123. ICE + +struct C { + template<class T> void f(T); + void g (); + void g (int); +}; + +void Foo () { + C c; + + (c.g) (); + (c.f) (1); + + (c.f<int>) (2); + + c.g; // { dg-error "statement cannot resolve" "" } + c.f; // { dg-error "statement cannot resolve" "" } + c.f<int>; // { dg-error "statement cannot resolve" "" } + + c.g == 1; // { dg-error "invalid" "" } + c.f == 1; // { dg-error "invalid" "" } + c.f<int> == 1; // { dg-error "invalid" "" } +} diff --git a/gcc/testsuite/g++.dg/other/const1.C b/gcc/testsuite/g++.dg/other/const1.C new file mode 100644 index 000000000..f01013837 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/const1.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com> + +// PR 335. Missed diagnostic + +struct Foo +{ + unsigned i; + void Modify(unsigned j) const; +}; + +void Foo::Modify(unsigned j) const +{ + Foo::i = j; // { dg-error "assignment of member" "" } +} diff --git a/gcc/testsuite/g++.dg/other/const2.C b/gcc/testsuite/g++.dg/other/const2.C new file mode 100644 index 000000000..86dde1e45 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/const2.C @@ -0,0 +1,22 @@ +// PR c++/3331: just because 'this' is readonly and bars[0].b is readonly +// doesn't mean that the result of the member reference is readonly. + +struct foo +{ + int a; + + struct bar + { int foo::* b ;}; + + static const bar bars[]; + + void bad () + { + this->*(bars[0].b) = 42; // { dg-bogus "read-only" "" } + } +}; + +const foo::bar foo::bars[] = { { &foo::a } }; + +int main () +{ } diff --git a/gcc/testsuite/g++.dg/other/const3.C b/gcc/testsuite/g++.dg/other/const3.C new file mode 100644 index 000000000..d47133b45 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/const3.C @@ -0,0 +1,23 @@ +// PR middle-end/44101 +// { dg-do compile } + +extern bool equal (int[], int[], const int[]); +extern bool equal (wchar_t[], wchar_t[], const wchar_t[]); + +void foo(void) +{ + const int A1[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; + const int N1 = sizeof(A1) / sizeof(int); + int i1[N1]; + + if (equal(i1, i1 + N1, A1)) + return; + + const wchar_t A3[] = {L'\3', L'\3', L'\3', L'\3', L'\3', + L'\3', L'\3', L'\3', L'\3', L'\3'}; + const int N3 = sizeof(A3) / sizeof(wchar_t); + wchar_t i3[N3]; + + if (equal(i3, i3 + N3, A3)) + return; +} diff --git a/gcc/testsuite/g++.dg/other/constref1.C b/gcc/testsuite/g++.dg/other/constref1.C new file mode 100644 index 000000000..900a07de3 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/constref1.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Matt Austern 12 Sep 2002 <austern@apple.com> + +// Make sure that we can pass a cast-expression as an argument that's +// passed by const reference. + +void bar (const long&) +{ } + +void foo (int x) +{ + bar ((long) x); +} + diff --git a/gcc/testsuite/g++.dg/other/constref2.C b/gcc/testsuite/g++.dg/other/constref2.C new file mode 100644 index 000000000..5c82e2dbb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/constref2.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Matt Austern 12 Sep 2002 <austern@apple.com> + +// Make sure that we can pass a cast-expression as an argument that's +// passed to a function template by const reference. + +template <class T> +void bar (const T&) +{ } + +void foo (int x) +{ + bar ((long) x); +} diff --git a/gcc/testsuite/g++.dg/other/conversion1.C b/gcc/testsuite/g++.dg/other/conversion1.C new file mode 100644 index 000000000..6573ef15b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/conversion1.C @@ -0,0 +1,17 @@ +// PR C++/2213 +// Origin: philippeb@corel.com +// Copyright (C), 2002 Free Software Foundation +// Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> + +// { dg-do compile } + +class QObject +{ +}; + +int main() +{ + long long m; + + (void (QObject::*)()) m; // { dg-error "invalid cast" "" } +} diff --git a/gcc/testsuite/g++.dg/other/copy1.C b/gcc/testsuite/g++.dg/other/copy1.C new file mode 100644 index 000000000..d02b08fce --- /dev/null +++ b/gcc/testsuite/g++.dg/other/copy1.C @@ -0,0 +1,83 @@ +// { dg-do run } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 30 Nov 2001 <nathan@nathan@codesourcery.com> + +// PR 87 + +int assign = 0; +int ctor = 0; +int assignC = 0; + +struct A { + int i; + + template<class T> + void operator=(const T&) const + { + assign = 1; + } + + A () : i (0) {} + + template <typename T> A (const T &) + { + ctor = 1; + } +}; + +struct B : A +{ +}; + +struct C +{ + int i; + + C (int i_) :i (i_) {} + + template <int I> + void operator= (const C &) + { + assignC = 1; + } +}; + + +int main() +{ + const A a; + A b; + B c; + + b = a; + if (assign) + return 5; + + b.i = 100; + c.i = 200; + + a = b; + + if (!assign) + return 1; + if (a.i) + return 2; + + A e (b); + if (ctor) + return 3; + + A d (c); + if (!ctor) + return 4; + + C c0 (0); + C c1 (1); + + c0 = c1; + if (assignC) + return 5; + + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/copy2.C b/gcc/testsuite/g++.dg/other/copy2.C new file mode 100644 index 000000000..335cab8d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/copy2.C @@ -0,0 +1,32 @@ +// { dg-do run } + +// Test that A's copy assignment method is called when B's instance +// member array of A is assigned. + +// Contributed by Brian Gaeke, public domain. +int status = 1; + +class A +{ +public: + int i; + A &operator =(const A &i) + { + status = 0; + } +}; + +class B +{ +public: + A arr[10]; +}; + +int main (int argc, char **argv) +{ + B b; + b.arr[0].i = 15; + B a; + a = b; // trigger copy assignment + return status; +} diff --git a/gcc/testsuite/g++.dg/other/crash-1.C b/gcc/testsuite/g++.dg/other/crash-1.C new file mode 100644 index 000000000..e9a2d79f4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-1.C @@ -0,0 +1,3 @@ + +void f() { return 0; } // { dg-error "return-statement" } + diff --git a/gcc/testsuite/g++.dg/other/crash-10.C b/gcc/testsuite/g++.dg/other/crash-10.C new file mode 100644 index 000000000..6dcd79149 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-10.C @@ -0,0 +1,24 @@ +// Origin: PR c++/43327 +// { dg-do compile } + +template <typename _T> +struct A +{ + template <int _N, int _M> struct B; + + template <int _N> + struct B<_N, _T::m> + { + static void f(); + }; +}; + +struct C +{ + static const int m = 4; +}; + +void m() +{ + A<C>::B<1, 4>::f(); +} diff --git a/gcc/testsuite/g++.dg/other/crash-11.C b/gcc/testsuite/g++.dg/other/crash-11.C new file mode 100644 index 000000000..29ee231be --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-11.C @@ -0,0 +1,27 @@ +// Origin: PR c++/43327 +// { dg-do compile } + +template <typename _T> +struct A +{ + template <int _N, int _M> struct B; + + template <int _N> + struct B<_N, _T::m> + { + static void f(); + }; +}; + +struct C +{ + static int m; +}; + +void m() +{ + A<C>::B<1, 4>::f(); // { dg-error "incomplete type|not a valid" } +} + +int C::m = 4; + diff --git a/gcc/testsuite/g++.dg/other/crash-12.C b/gcc/testsuite/g++.dg/other/crash-12.C new file mode 100644 index 000000000..6612ff216 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-12.C @@ -0,0 +1,25 @@ +// Origin: PR c++/43953 + +template<typename T, + typename U, + typename T::type V> class bad; + +// partial specialization +// for T = U +template<typename T, typename T::type V> +class bad<T, T, V> +{ +public: + static void foo() {} +}; + +struct dummy +{ + typedef int type; +}; + +int main() +{ + bad<dummy, dummy, 0>::foo(); +} + diff --git a/gcc/testsuite/g++.dg/other/crash-2.C b/gcc/testsuite/g++.dg/other/crash-2.C new file mode 100644 index 000000000..961a18a23 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-2.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-finline -finline-functions" } +// Contributed by Hans Buchmann <hans dot buchmann at fhso dot ch> +// PR c++/14033: ICE while inlining a function with incomplete parameter + +struct A; // { dg-error "forward declaration" } +void foo(A a) {} // { dg-error "incomplete" } +struct A {}; + +void bar(void) +{ + foo(A()); +} diff --git a/gcc/testsuite/g++.dg/other/crash-3.C b/gcc/testsuite/g++.dg/other/crash-3.C new file mode 100644 index 000000000..d13821dee --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-3.C @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-g" } +// Contributed by: <schmid at snake dot iap dot physik dot tu-darmstadt dot de> +// and Niall Douglas <s_gccbugzilla at nedprod dot com> +// PR c++/14246: ice in write_template_arg_literal while mangling boolean +// expressions. + +namespace N1 { + + template <typename T> + struct A { + enum { Yes = (sizeof(T) == 1) }; + }; + + template<bool T> + struct B { + void foo(void); + }; + + template struct B< !A<int>::Yes >; + +} + + +namespace N2 { + + template<bool> struct A {}; + A<!false> a; + +} + diff --git a/gcc/testsuite/g++.dg/other/crash-4.C b/gcc/testsuite/g++.dg/other/crash-4.C new file mode 100644 index 000000000..a77fe05d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-4.C @@ -0,0 +1,26 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Jun 2005 <nathan@codesourcery.com> + +// PR 20678: ICE on error message +// Origin: Andrew Pinski pinskia@gcc.gnu.org + +// NOTE: This test assumes packed structure layout differs from unpacked +// structure layout. This isn't true, e.g., with the default +// arm-none-elf options. +// { dg-options "-mstructure-size-boundary=8" { target arm*-*-* } } + +struct a +{ + int m; + a(const a&); +}; +struct b // { dg-error "cannot bind packed field" "" { target { ! default_packed } } } +{ + char c; + a aa __attribute__((packed)); // { dg-warning "attribute ignored" "" { target default_packed } } +}; +struct c +{ + b bb; + c(const b& __a): bb(__a) {} // { dg-message "synthesized" "" { target { ! default_packed } } } +}; diff --git a/gcc/testsuite/g++.dg/other/crash-5.C b/gcc/testsuite/g++.dg/other/crash-5.C new file mode 100644 index 000000000..25a70b7df --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-5.C @@ -0,0 +1,16 @@ +// Origin: PR c++/42758 +// { dg-do compile } + +template<class T> struct less {}; + +template<class T, typename U = less<T> > struct set {}; + +struct int_less_than {}; + +void assert_fail (const char*); + +int f(const set<int, int_less_than>&) +{ + assert_fail (__PRETTY_FUNCTION__); + +} diff --git a/gcc/testsuite/g++.dg/other/crash-6.C b/gcc/testsuite/g++.dg/other/crash-6.C new file mode 100644 index 000000000..2220675dc --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-6.C @@ -0,0 +1,34 @@ +// Origin: PR c++/42634 +// { dg-options "-g -std=c++0x" } +// { dg-do compile } + +template<typename T> T declval(); + +template<typename T, typename... Args> struct is_constructible { + template<typename T1, typename... Args1> static decltype(T1(declval<Args1>()...), char()) test(); + static const bool value = sizeof(test<T, Args...>()) == 1; +}; +template<bool> struct enable_if { + typedef void type; +}; +template<class T1, class T2> struct pair { + template<class U2, + class = typename enable_if<is_constructible<T2,U2&&>::value>::type + > + pair(const T1&, U2&&) { } +}; +struct string { + string() : p(0) {} + char* p; +}; + +struct Foo { + string s; + int i; +}; + +void f() +{ + pair<int, Foo>(1, Foo()); +} + diff --git a/gcc/testsuite/g++.dg/other/crash-7.C b/gcc/testsuite/g++.dg/other/crash-7.C new file mode 100644 index 000000000..d5bc892c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-7.C @@ -0,0 +1,19 @@ +// Origin: PR c++/42336 +// { dg-options "-std=c++0x -O2 -g" } +// { dg-do compile } + +struct X { + void func() {} +}; + +template<typename T, void (X::*P)() = &T::func> +void b(T) {} + +int main() { + b(X()); /* line 9 */ + X().func(); + + return 0; +} + + diff --git a/gcc/testsuite/g++.dg/other/crash-8.C b/gcc/testsuite/g++.dg/other/crash-8.C new file mode 100644 index 000000000..c260431d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-8.C @@ -0,0 +1,109 @@ +// Origin: PR c++/42797 +// { dg-options "-g -O2 -std=c++0x" } + +template<typename _Tp, _Tp __v> struct integral_constant { + static const _Tp value = __v; +}; + +template<typename _Tp> _Tp declval(); + +template<typename _Tp, typename... _Args> +class __is_constructible_helper { +}; + +template<typename _Tp, typename _Arg> +class __is_constructible_helper<_Tp, _Arg> { + + template<typename _Tp1, typename _Arg1> + static decltype(static_cast<_Tp1>(declval<_Arg1>()), char()) __test(int); +public: + static const bool __value = sizeof(__test<_Tp, _Arg>(0)) == 1; +}; + +template<typename _Tp, typename... _Args> +struct is_constructible : public integral_constant<bool,__is_constructible_helper<_Tp, _Args...>::__value> { }; + +template<bool, typename _Tp = void> +struct enable_if { }; + +template<typename _Tp> +struct enable_if<true, _Tp> { + typedef _Tp type; +}; + +template<class _T1, class _T2> struct pair { + _T1 first; + _T2 second; + + template<class _U2, class = typename enable_if<is_constructible<_T2, _U2&&>::value>::type> + pair(const _T1& __x, _U2&& __y) : first(__x), + second(__y) { } +}; + +namespace __gnu_cxx { +template<typename _Tp> +class new_allocator { +public: + new_allocator() throw() { } + new_allocator(const new_allocator&) throw() { } +}; +} + +template<typename _Tp> +class allocator: public __gnu_cxx::new_allocator<_Tp> { +public: + + template<typename _Tp1> + struct rebind { + typedef allocator<_Tp1> other; + }; +}; + + +template<typename _Tp, typename _Alloc> struct _Vector_base { + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + + struct _Vector_impl : public _Tp_alloc_type { + _Vector_impl() + { } + }; +public: + + _Vector_impl _M_impl; +}; + +template<typename _Tp, typename _Alloc = allocator<_Tp> > +class vector : protected _Vector_base<_Tp, _Alloc> { + typedef _Alloc allocator_type; +public: + vector() { } + explicit vector(int, const allocator_type& __a = allocator_type()) + { + } +}; + + +template <typename _Key, typename _Tp> +class map { + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const _Key, _Tp> value_type; +public: + + void insert(const value_type& __x) + { + } + + mapped_type& operator[](const key_type& __k) { + insert(value_type(__k, mapped_type())); + } + +}; + +struct Foo { + Foo() {} template<typename Tp> Foo(Tp *p) {} }; +void foo() { + map <int, vector<Foo>> the_map; + the_map[1] = vector<Foo>(); +} + diff --git a/gcc/testsuite/g++.dg/other/crash-9.C b/gcc/testsuite/g++.dg/other/crash-9.C new file mode 100644 index 000000000..0953fcbc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/crash-9.C @@ -0,0 +1,15 @@ +// Origin: PR c++/42915 +// { dg-do compile } + +template <typename T> +class A +{ + template <typename U> + class B + { + B foo(); + }; +}; +template <typename T> template <typename U> +A<T>::B<U> A<T>::B<U>::foo() {} + diff --git a/gcc/testsuite/g++.dg/other/ctor1.C b/gcc/testsuite/g++.dg/other/ctor1.C new file mode 100644 index 000000000..65449f4c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ctor1.C @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +// PR C++/30303 +// This used to ICE because we did not return NULL +// in grokfndecl when an error happened. + +class A +{ + int i; +}; + +A::A() { A(); } /* { dg-error "definition of implicitly-declared" } */ diff --git a/gcc/testsuite/g++.dg/other/ctor2.C b/gcc/testsuite/g++.dg/other/ctor2.C new file mode 100644 index 000000000..65bd85902 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ctor2.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +// PR C++/30303 +// This used to ICE because we did not return NULL +// in grokfndecl when an error happened. + + +class A +{ + int i; +}; + +void foo() +{ + A(); +} + +A::A() {} /* { dg-error "definition of implicitly-declared" } */ diff --git a/gcc/testsuite/g++.dg/other/cv_func.C b/gcc/testsuite/g++.dg/other/cv_func.C new file mode 100644 index 000000000..941cb8d53 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cv_func.C @@ -0,0 +1,30 @@ +// { dg-do compile } + +typedef int FIC(int) const; +typedef int FI(int); + +FIC f; // { dg-error "qualified" } +struct S { + FIC f; // OK + + const FI g; + + int h(int) const; + +}; +FIC S::*pm = &S::f; +const FI S::*pm2 = &S::f; // { dg-error "cannot convert" } +const FIC S::*pm3 = &S::f; + +int S::f(int) const +{ + return 17; +} + + +int foo(float) const // { dg-error "qualifier" } +{ + return 0; +} + +int bar(float) volatile; // { dg-error "qualifier" } diff --git a/gcc/testsuite/g++.dg/other/cv_func2.C b/gcc/testsuite/g++.dg/other/cv_func2.C new file mode 100644 index 000000000..ffd249fc8 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cv_func2.C @@ -0,0 +1,18 @@ +typedef int ptr1() const; // no error + +void foo () +{ + typedef int ptr2() const; // no error +} + +class C +{ + typedef int ptr3() const; // error + + void bar () + { + typedef int ptr4() const; // no error + } +}; + +void wibble () const { } // { dg-error "non-member function" } diff --git a/gcc/testsuite/g++.dg/other/cxa-atexit1.C b/gcc/testsuite/g++.dg/other/cxa-atexit1.C new file mode 100644 index 000000000..a51f33401 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/cxa-atexit1.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-O2 -fuse-cxa-atexit" } + +# 1 "cxa-atexit1.C" +struct A +{ + struct B + { + B (); + ~B (); + }; +}; +static A::B b; +# 1 "cxa-atexit1.h" 1 +#pragma interface +template <class T> struct C +{ + ~C (void); +}; +struct D : public C<bool> +{ + D (void) : C<bool> () { } +}; +# 55 "cxa-atexit1.C" 2 + +// { dg-final { scan-assembler-not ".gnu.linkonce.t.__tcf_" } } diff --git a/gcc/testsuite/g++.dg/other/darwin-cfstring1.C b/gcc/testsuite/g++.dg/other/darwin-cfstring1.C new file mode 100644 index 000000000..b30ba9bef --- /dev/null +++ b/gcc/testsuite/g++.dg/other/darwin-cfstring1.C @@ -0,0 +1,25 @@ +/* Test whether the __builtin__CFStringMakeConstantString + "function" fails gracefully when handed a non-constant + argument. This will only work on MacOS X 10.1.2 and later. */ +/* Developed by Ziemowit Laski <zlaski@apple.com>. */ + +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-mconstant-cfstrings" } */ + +#include <CoreFoundation/CFString.h> + +#ifdef __CONSTANT_CFSTRINGS__ +#undef CFSTR +#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR)) +#endif + +extern int cond; +extern const char *func(void); + +int main(void) { + CFStringRef s1 = CFSTR("Str1"); + CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "CFString literal expression is not a string constant" } */ + CFStringRef s3 = CFSTR(func()); /* { dg-error "CFString literal expression is not a string constant" } */ + + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/darwin-minversion-1.C b/gcc/testsuite/g++.dg/other/darwin-minversion-1.C new file mode 100644 index 000000000..cbf5ff1d2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/darwin-minversion-1.C @@ -0,0 +1,10 @@ +/* Test for -mmacosx-version-min default on powerpc-darwin. */ +/* { dg-do compile { target powerpc-*-darwin* } } */ + +int main(void) +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1030 + fail me; +#endif + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/datasec1.C b/gcc/testsuite/g++.dg/other/datasec1.C new file mode 100644 index 000000000..c6b2ae981 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/datasec1.C @@ -0,0 +1,11 @@ +// PR target/33168 +// { dg-do compile } +// { dg-require-effective-target named_sections } +// { dg-options "-O2 -fdata-sections" } + +extern const int& foo; +namespace +{ + const int bar = 16; +} +const int &foo = bar; diff --git a/gcc/testsuite/g++.dg/other/default1.C b/gcc/testsuite/g++.dg/other/default1.C new file mode 100644 index 000000000..a6d968185 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default1.C @@ -0,0 +1,22 @@ +// PR c++/24103 +// ICE in simple_cst_equal +// Origin: Alexander Stepanov <astepanov@softminecorp.com> +// { dg-do compile } +// { dg-options "" } + +struct S +{ + int i; +}; + +struct A +{ + A(S = (S){0}); +}; + +struct B +{ + B(S = (S){0}); +}; + +B::B(S) {} diff --git a/gcc/testsuite/g++.dg/other/default2.C b/gcc/testsuite/g++.dg/other/default2.C new file mode 100644 index 000000000..51534b887 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default2.C @@ -0,0 +1,9 @@ +// PR c++/16829 +// { dg-do compile } + +template<typename T> void foo(T, int = 0, int) {} // { dg-error "default" } + +void bar() +{ + foo(0); +} diff --git a/gcc/testsuite/g++.dg/other/default3.C b/gcc/testsuite/g++.dg/other/default3.C new file mode 100644 index 000000000..42c1fe489 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default3.C @@ -0,0 +1,109 @@ +// PR c++/16829 +// { dg-do compile } + +void f1(int = 0, int); // { dg-error "default" } + +void f2(int = 0, int) {} // { dg-error "default" } + +void f3(int, int); +void f3(int = 0, int); // { dg-error "default" } + +void f4(int, int); +void f4(int = 0, int) {} // { dg-error "default" } + +void f5(); +void f5(int = 0, int); // { dg-error "default" } + +void f6(); +void f6(int = 0, int) {} // { dg-error "default" } + +template<typename> void g1(int = 0, int); // { dg-error "default" } + +template<typename> void g2(int = 0, int) {} // { dg-error "default" } + +template<typename> void g3(int, int); +template<typename> void g3(int = 0, int); // { dg-error "default" } + +template<typename> void g4(int, int); +template<typename> void g4(int = 0, int) {} // { dg-error "default" "" { xfail *-*-* } } + +template<typename> void g5(); +template<typename> void g5(int = 0, int); // { dg-error "default" } + +template<typename> void g6(); +template<typename> void g6(int = 0, int) {} // { dg-error "default" } + +template<typename T> void g7(T, T) {} +template<typename T> void g7(T* = 0, T*) {} // { dg-error "default" } + + +struct A +{ + void F1(int = 0, int); // { dg-error "default" } + + void F2(int = 0, int) {} // { dg-error "default" } + + void F3(int, int); + + void F4(); + void F4(int = 0, int); // { dg-error "default" } + + void F5(); + void F5(int = 0, int) {} // { dg-error "default" } + + template<typename> void G1(int = 0, int); // { dg-error "default" } + + template<typename> void G2(int = 0, int) {} // { dg-error "default" } + + template<typename> void G3(int, int); + + template<typename> void G4(); + template<typename> void G4(int = 0, int); // { dg-error "default" } + + template<typename> void G5(); + template<typename> void G5(int = 0, int) {} // { dg-error "default" } + + template<typename T> void G6(T, T) {} + template<typename T> void G6(T* = 0, T*) {} // { dg-error "default" } +}; + +void A::F3(int = 0, int) {} // { dg-error "default" } + +template<typename> void A::G3(int = 0, int) {} // { dg-error "default" } + + +template<typename> struct B +{ + void F1(int = 0, int); // { dg-error "default" } + + void F2(int = 0, int) {} // { dg-error "default" } + + void F3(int, int); + + void F4(); + void F4(int = 0, int); // { dg-error "default" } + + void F5(); + void F5(int = 0, int) {} // { dg-error "default" } + + template<typename> void G1(int = 0, int); // { dg-error "default" } + + template<typename> void G2(int = 0, int) {} // { dg-error "default" } + + template<typename> void G3(int, int); + + template<typename> void G4(); + template<typename> void G4(int = 0, int); // { dg-error "default" } + + template<typename> void G5(); + template<typename> void G5(int = 0, int) {} // { dg-error "default" } + + template<typename T> void G6(T, T) {} + template<typename T> void G6(T* = 0, T*) {} // { dg-error "default" } +}; + +template<typename T> +void B<T>::F3(int = 0, int) {} // { dg-error "default" } + +template<typename T> template<typename> +void B<T>::G3(int = 0, int) {} // { dg-error "default" } diff --git a/gcc/testsuite/g++.dg/other/default4.C b/gcc/testsuite/g++.dg/other/default4.C new file mode 100644 index 000000000..599480984 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default4.C @@ -0,0 +1,29 @@ +// PR c++/15759 +// Origin: Lars Rune Nøstdal <larsnostdal@gmail.com> +// Testcase: Volker Reichelt <reichelt@igpm.rwth-aachen.de> + +// { dg-do run } + +extern "C" void abort(); + +int n = 0; + +int f() { return ++n; } + +int(&foo1)() = f; +int(*foo2)() = &f; +int(*foo3)() = f; + +int bar1(int i = foo1()) { return i; } +int bar2(int i = foo2()) { return i; } +int bar3(int i = foo3()) { return i; } +int bar4(int i = f()) { return i; } + +int main() +{ + if (bar1() != 1) abort(); + if (bar2() != 2) abort(); + if (bar3() != 3) abort(); + if (bar4() != 4) abort(); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/default5.C b/gcc/testsuite/g++.dg/other/default5.C new file mode 100644 index 000000000..d5bae344c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default5.C @@ -0,0 +1,47 @@ +// PR c++/28274 +// { dg-do compile } + +void f1(int, int, int, int, int = 0); +void f1(int, int, int, int = 0, int); +void f1(int, int, int = 0, int, int); +void f1(int = 0, int, int, int, int); // { dg-error "default" } + +void f2(int, int, int, int, int = 0) {} +void f2(int, int, int, int = 0, int); +void f2(int, int, int = 0, int, int); +void f2(int = 0, int, int, int, int); // { dg-error "default" } + +void f3(int, int, int, int, int = 0); +void f3(int, int, int, int = 0, int) {} +void f3(int, int, int = 0, int, int); +void f3(int = 0, int, int, int, int); // { dg-error "default" } + +void f4(int, int, int, int, int = 0); +void f4(int, int, int, int = 0, int); +void f4(int, int, int = 0, int, int) {} +void f4(int = 0, int, int, int, int); // { dg-error "default" } + +void f5(int, int, int, int, int = 0); +void f5(int, int, int, int = 0, int); +void f5(int, int, int = 0, int, int); +void f5(int = 0, int, int, int, int) {} // { dg-error "default" } + + +struct A +{ + void F1(int, int, int = 0); + void F2(int, int, int = 0); +}; + +void A::F1(int, int = 0, int) {} +void A::F2(int = 0, int, int) {} // { dg-error "default" } + + +template<int> struct B +{ + void F1(int, int, int = 0); + void F2(int, int, int = 0); +}; + +template<int N> void B<N>::F1(int, int = 0, int) {} +template<int N> void B<N>::F2(int = 0, int, int) {} // { dg-error "default" } diff --git a/gcc/testsuite/g++.dg/other/default6.C b/gcc/testsuite/g++.dg/other/default6.C new file mode 100644 index 000000000..2641801b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default6.C @@ -0,0 +1,18 @@ +// PR c++/30108 + +class BaseRobot { + typedef void (BaseRobot::*PseudoState)(void); + typedef PseudoState STATE; + STATE initial (); + int ready (); + STATE stpOtherTask (); + STATE commonEventProcessing (STATE pIdleTarget=(STATE)&BaseRobot::ready); +}; +BaseRobot::STATE BaseRobot::initial () +{ + return commonEventProcessing (); +} +BaseRobot::STATE BaseRobot::stpOtherTask () +{ + return commonEventProcessing (); +} diff --git a/gcc/testsuite/g++.dg/other/default7.C b/gcc/testsuite/g++.dg/other/default7.C new file mode 100644 index 000000000..ec523bf89 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/default7.C @@ -0,0 +1,20 @@ +/* { dg-do assemble } */ +/* { dg-options "-O1" }*/ +// This was PR C++/31165 +// We used to copy the whole decl when we just wantted to +// unshare some expressions for the default argument. +class string { + char *ptr; + int len; + int sz; +}; +class cset { } _cset_init; +string an_empty_string; +void f(string& = an_empty_string); +void +h (void ) +{ +f(); +} + + diff --git a/gcc/testsuite/g++.dg/other/do1.C b/gcc/testsuite/g++.dg/other/do1.C new file mode 100644 index 000000000..720358568 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/do1.C @@ -0,0 +1,13 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 16 Sep 2002 <nathan@codesourcery.com> + +// PR 7640. ICE. + +void init () +{ + do { } while (0) + obj = 0; // { dg-error "expected|not declared" "" } + +} diff --git a/gcc/testsuite/g++.dg/other/dtor1.C b/gcc/testsuite/g++.dg/other/dtor1.C new file mode 100644 index 000000000..90ca38007 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/dtor1.C @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +// PR C++/30303 +// This used to ICE because we did not return NULL +// in grokfndecl when an error happened. + +struct Ifoo +{ +virtual ~Ifoo(){} +}; +struct foo : Ifoo +{ + foo(){}; +}; +foo::~foo() // { dg-error "definition of implicitly-declared" } +{ +delete this; +} diff --git a/gcc/testsuite/g++.dg/other/dtor2.C b/gcc/testsuite/g++.dg/other/dtor2.C new file mode 100644 index 000000000..fb673d808 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/dtor2.C @@ -0,0 +1,7 @@ +/* PR c++/35317 */ +/* { dg-do compile } */ + +struct A +{ + void operator delete[] (void*, ...); +}; diff --git a/gcc/testsuite/g++.dg/other/ellipsis1.C b/gcc/testsuite/g++.dg/other/ellipsis1.C new file mode 100644 index 000000000..d2501ca85 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ellipsis1.C @@ -0,0 +1,12 @@ +// PR c++/26291 +// { dg-do compile } + +struct A +{ + A& operator= (A,...); // { dg-error "variable number of arguments" } + A operator+ (...); // { dg-error "variable number of arguments" } + operator int(...); // { dg-error "variable number of arguments" } + int operator() (...); +}; + +A operator- (A,...); // { dg-error "variable number of arguments" } diff --git a/gcc/testsuite/g++.dg/other/enum1.C b/gcc/testsuite/g++.dg/other/enum1.C new file mode 100644 index 000000000..aa5c976ac --- /dev/null +++ b/gcc/testsuite/g++.dg/other/enum1.C @@ -0,0 +1,19 @@ +// PR c++/6037 +// This testcase ICEd because start_enum expected pushtag to insert +// the tag always into current binding level. + +struct A +{ + ~A () { } +}; + +struct B +{ + void foo () + { + switch (0) { default: ; } + A a; + enum C { }; + (void) a; + } +}; diff --git a/gcc/testsuite/g++.dg/other/enum2.C b/gcc/testsuite/g++.dg/other/enum2.C new file mode 100644 index 000000000..3a28f2532 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/enum2.C @@ -0,0 +1,3 @@ +// PR c++/51248 + +enum E { e = sizeof(const E*) }; diff --git a/gcc/testsuite/g++.dg/other/error1.C b/gcc/testsuite/g++.dg/other/error1.C new file mode 100644 index 000000000..927efef8b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error1.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 18 Dec 2001 <nathan@nathan@codesourcery.com> + +// PR 90, stupid error message `(this + 160)' + +class foo { + public: + int fudge[40]; + int bar [40]; + inline int access(int i) { + return bar(i); // { dg-error "cannot be used as a function" "" } + } +}; diff --git a/gcc/testsuite/g++.dg/other/error10.C b/gcc/testsuite/g++.dg/other/error10.C new file mode 100644 index 000000000..26f7ca53f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error10.C @@ -0,0 +1,15 @@ +// PR c++/21930 +// Test case by Volker Reichelt +// { dg-do compile } + +template<int> struct A {}; + +template<int N> +void foo(const A<N> &a) +{ -A<N>(a); } // { dg-error "\\(\\* & a\\)" "" } + +void bar() +{ + foo(A<0>()); // { dg-message "instantiated from here" "" } +} + diff --git a/gcc/testsuite/g++.dg/other/error11.C b/gcc/testsuite/g++.dg/other/error11.C new file mode 100644 index 000000000..d8a641c2b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error11.C @@ -0,0 +1,17 @@ +/* { dg-options "-O1" } */ +struct A +{ + ERROR; /* { dg-error "ERROR" } */ + ~A(); +}; + +struct B +{ + virtual ~B(); +}; + +struct C : B, A {}; + +struct D : C {}; + +D d; diff --git a/gcc/testsuite/g++.dg/other/error12.C b/gcc/testsuite/g++.dg/other/error12.C new file mode 100644 index 000000000..253561e8f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error12.C @@ -0,0 +1,9 @@ +//PR c++/28292 + +extern "Java" +{ + struct A + { + void foo(void; // { dg-error "before|incomplete type|invalid use" } + }; +} diff --git a/gcc/testsuite/g++.dg/other/error13.C b/gcc/testsuite/g++.dg/other/error13.C new file mode 100644 index 000000000..4ee935ad6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error13.C @@ -0,0 +1,12 @@ +//PR c++/28258 + +struct A // { dg-message "note" } +{ + A(void x); // { dg-error "invalid use|incomplete type|candidates" } + // { dg-message "" "match candidate text" { target *-*-* } 5 } +}; + +struct B : A {}; // { dg-error "no matching function for call|deleted" } +// { dg-message "candidate" "candidate note" { target *-*-* } 9 } + +B b; // { dg-message "synthesized method|deleted" } diff --git a/gcc/testsuite/g++.dg/other/error14.C b/gcc/testsuite/g++.dg/other/error14.C new file mode 100644 index 000000000..b3c930188 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error14.C @@ -0,0 +1,7 @@ +//PR c++/26269 + +void foo() +{ + i; // { dg-error "not declared in this scope" } + int i; +} diff --git a/gcc/testsuite/g++.dg/other/error15.C b/gcc/testsuite/g++.dg/other/error15.C new file mode 100644 index 000000000..360185232 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error15.C @@ -0,0 +1,56 @@ +// Test that duplicate function parameters are found in declarations. + +extern void g0 (int a, int b); +extern void g1 (int a, float b); + +extern void f0 (int a, // { dg-error "previous" } + int a); // { dg-error "redefinition" } +extern void f1 (int a, // { dg-error "previous" } + float a); // { dg-error "conflicting" } +extern void f3 (int a, int b, int c, // { dg-error "previous" } + int a); // { dg-error "redefinition" } +extern void f4 (int a, int b, int c, // { dg-error "previous" } + int a, // { dg-error "redefinition" } + int a); // { dg-error "redefinition" } +extern void f5 (int a, int b, int c, int d, int e, int f, int g, int h, // { dg-error "previous" } + int a, // { dg-error "redefinition" } + int i, int j, int k, int l, int m, int n, int o, int p, + int q, int r, int s, int t, int u, int v, int w, int x, int y, + int z); + +extern void f6 (int a, int, int, int, int, int, int, int, int, int, int, // { dg-error "previous" } + int a, // { dg-error "redefinition" } + int, int, int, int, int, int, int, int, int, int, int, + float, float, float, float, float, float, float, float, + int); + +extern void f7 (void (*a)(int), // { dg-error "previous" } + void (*a)(int)); // { dg-error "redefinition" } +extern void f8 (float (*a)(int), // { dg-error "previous" } + int (*a)(float)); // { dg-error "conflicting" } + +extern void f9 (int a, // { dg-error "previous" } + int a, // { dg-error "redefinition" } + int a); // { dg-error "redefinition" } + +extern void f10 (int a, // { dg-error "previous" } + int b, // { dg-error "previous" } + int c, // { dg-error "previous" } + int c, // { dg-error "redefinition" } + int b, // { dg-error "redefinition" } + int a); // { dg-error "redefinition" } + +class C1 { + public: + void C1_g0 (int a, int b); + void C1_f0 (int a, // { dg-error "previous" } + int a); // { dg-error "redefinition" } +}; + +template <class T> +class C2 { + public: + void C2_g0 (T a, T b); + void C2_f0 (T a, // { dg-error "previous" } + T a); // { dg-error "redefinition" } +}; diff --git a/gcc/testsuite/g++.dg/other/error16.C b/gcc/testsuite/g++.dg/other/error16.C new file mode 100644 index 000000000..1e3464714 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error16.C @@ -0,0 +1,14 @@ +// PR c++/17763 + +template <typename U> struct Outer { + struct Inner {}; + Inner foo(); +}; + +typedef int X; +typedef Outer<X> XOuter; + +int main() { + Outer<int> ab; + ab.foo() == 1; // { dg-error "ab.Outer" } +} diff --git a/gcc/testsuite/g++.dg/other/error17.C b/gcc/testsuite/g++.dg/other/error17.C new file mode 100644 index 000000000..18769ef6b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error17.C @@ -0,0 +1,13 @@ +// PR c++/32870 + +struct Foo { + struct Bar; +}; + +namespace N { + struct Foo::Bar { }; // { dg-error "in namespace 'N'" } +} + +struct Baz { + struct Foo::Bar { }; // { dg-error "in 'struct Baz'" } +}; diff --git a/gcc/testsuite/g++.dg/other/error18.C b/gcc/testsuite/g++.dg/other/error18.C new file mode 100644 index 000000000..9e4d21cfd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error18.C @@ -0,0 +1,11 @@ +// PR c++/33208 + +struct A +{ + bool b; +}; + +void f(A a) +{ + a.b--; // { dg-error "Boolean expression" } +} diff --git a/gcc/testsuite/g++.dg/other/error19.C b/gcc/testsuite/g++.dg/other/error19.C new file mode 100644 index 000000000..9389dc170 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error19.C @@ -0,0 +1,7 @@ +// PR c++/33495 + +void foo() +{ + if (({while(true);})) // { dg-error "forbids|<statement>" } + ; +} diff --git a/gcc/testsuite/g++.dg/other/error2.C b/gcc/testsuite/g++.dg/other/error2.C new file mode 100644 index 000000000..36089e4b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error2.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com> + +// PR 196. Misleading diagnostic + +namespace N +{ + class B { friend void operator>>(int, class B); }; + class N { friend void operator>>(int,class N); }; +} +void N::operator>>(int, N::B) // { dg-error "N::N::B|N::operator>>" } +{ } diff --git a/gcc/testsuite/g++.dg/other/error20.C b/gcc/testsuite/g++.dg/other/error20.C new file mode 100644 index 000000000..f3b17aa19 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error20.C @@ -0,0 +1,13 @@ +// PR c++/34275 +// { dg-do compile } + +struct A // { dg-message "operator=|no known conversion" } +{ + virtual A foo (); +}; + +void bar (A& a) +{ + a.foo () = 0; // { dg-error "A::foo\\(\\) = 0" } + // { dg-message "candidate" "candidate note" { target *-*-* } 11 } +} diff --git a/gcc/testsuite/g++.dg/other/error21.C b/gcc/testsuite/g++.dg/other/error21.C new file mode 100644 index 000000000..e4d14eab6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error21.C @@ -0,0 +1,8 @@ +// PR c++/34273 + +struct A {}; + +struct B : A +{ + B() : A()... {} // { dg-error "cannot expand" } +}; diff --git a/gcc/testsuite/g++.dg/other/error22.C b/gcc/testsuite/g++.dg/other/error22.C new file mode 100644 index 000000000..225dcae82 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error22.C @@ -0,0 +1,9 @@ +// PR c++/34394 +// { dg-do compile } + +extern "C" double fabs (double); + +void foo (double x) +{ + fabs (x) (); // { dg-error "__builtin_abs" } +} diff --git a/gcc/testsuite/g++.dg/other/error23.C b/gcc/testsuite/g++.dg/other/error23.C new file mode 100644 index 000000000..959fe4075 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error23.C @@ -0,0 +1,5 @@ +// PR c++/34918 +// { dg-do compile } + +int v __attribute ((vector_size (8))); +bool b = !(v - v); // { dg-error "could not convert .\\(__vector.2. int\\)\\{0, 0\\}. from .__vector.2. int. to .bool.|in argument to unary" } diff --git a/gcc/testsuite/g++.dg/other/error24.C b/gcc/testsuite/g++.dg/other/error24.C new file mode 100644 index 000000000..54343c502 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error24.C @@ -0,0 +1,13 @@ +// PR c++/34965 +// { dg-do compile } +// { dg-options "-O" } + +int foo (int); + +void +bar (int i, int j, double k) +{ + foo (i && j) (); // { dg-error "\\(\\(?i != 0\\)? \\&\\& \\(?j != 0\\)?\\)" } + foo (!i || !j) (); // { dg-error "\\(\\(?i == 0\\)? \\|\\| \\(?j == 0\\)?\\)" } + foo (!i == !j) (); // { dg-error "\\(\\(?i != 0\\)? \\^ \\(?j == 0\\)?\\)" } +} diff --git a/gcc/testsuite/g++.dg/other/error25.C b/gcc/testsuite/g++.dg/other/error25.C new file mode 100644 index 000000000..b5b665a2e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error25.C @@ -0,0 +1,5 @@ +// PR c++/35338 +// { dg-options "" } + +int i = 0r; // { dg-error "not supported" } +bool b = !0r; // { dg-error "not supported" } diff --git a/gcc/testsuite/g++.dg/other/error26.C b/gcc/testsuite/g++.dg/other/error26.C new file mode 100644 index 000000000..fb2c8b727 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error26.C @@ -0,0 +1,6 @@ +// PR c++/35333 + +void foo(__complex__ double x) +{ + __builtin_conj(x)(); // { dg-error "~x" } +} diff --git a/gcc/testsuite/g++.dg/other/error27.C b/gcc/testsuite/g++.dg/other/error27.C new file mode 100644 index 000000000..de9742857 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error27.C @@ -0,0 +1,13 @@ +// PR c++/35332 +// { dg-do compile } +// { dg-options "-fno-finite-math-only" { target sh*-*-* } } + +void foo (double x, double y) +{ + __builtin_isgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_isless(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_isgreaterequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_islessequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_isunordered(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_islessgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } +} diff --git a/gcc/testsuite/g++.dg/other/error28.C b/gcc/testsuite/g++.dg/other/error28.C new file mode 100644 index 000000000..5ac15b7de --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error28.C @@ -0,0 +1,8 @@ +// PR c++/35987 +// { dg-do compile } + +void +foo (char *p) +{ + if (++p = true); // { dg-error "cannot convert" } +} diff --git a/gcc/testsuite/g++.dg/other/error29.C b/gcc/testsuite/g++.dg/other/error29.C new file mode 100644 index 000000000..a46405875 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error29.C @@ -0,0 +1,21 @@ +// PR c++/35334 +// { dg-do compile } +// { dg-bogus "not supported by" "" { target *-*-* } 0 } + +__complex__ unsigned int i; +int j; +char k; +__complex__ double l; +double m; +float n; + +void +foo () +{ + ((__complex__ int)i)(); // { dg-error "cannot be used as a function" } + ((__complex__ int)j)(); // { dg-error "cannot be used as a function" } + ((__complex__ int)k)(); // { dg-error "cannot be used as a function" } + ((__complex__ long double)l)(); // { dg-error "cannot be used as a function" } + ((__complex__ long double)m)(); // { dg-error "cannot be used as a function" } + ((__complex__ long double)n)(); // { dg-error "cannot be used as a function" } +} diff --git a/gcc/testsuite/g++.dg/other/error3.C b/gcc/testsuite/g++.dg/other/error3.C new file mode 100644 index 000000000..bd5d70109 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error3.C @@ -0,0 +1,5 @@ +// Test for proper error message formatting; the throw() should go inside +// the parens, as below. + +void (*g() throw())(); // { dg-error "g\\(\\) throw" "" } +void (*g())(); // { dg-error "" "" } diff --git a/gcc/testsuite/g++.dg/other/error30.C b/gcc/testsuite/g++.dg/other/error30.C new file mode 100644 index 000000000..2df0e6407 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error30.C @@ -0,0 +1,14 @@ +// PR c++/35336 +// { dg-do compile } +// { dg-bogus "not supported by" "" { target *-*-* } 0 } + +struct A +{ + int i : 2; +}; + +void foo (bool b) +{ + A a; + (a.i || b) (); // { dg-error "cannot be used as" } +} diff --git a/gcc/testsuite/g++.dg/other/error31.C b/gcc/testsuite/g++.dg/other/error31.C new file mode 100644 index 000000000..95c9d7374 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error31.C @@ -0,0 +1,14 @@ +// PR c++/35335 +// { dg-do compile } +// { dg-options "" } +// { dg-bogus "not supported by" "" { target *-*-* } 0 } + +struct A {}; // { dg-message "operator=|no known conversion" } + +void +foo () +{ + A a; + a = ({ { 1; } }); // { dg-error "no match for" } + // { dg-message "candidate" "candidate note" { target *-*-* } 12 } +} diff --git a/gcc/testsuite/g++.dg/other/error32.C b/gcc/testsuite/g++.dg/other/error32.C new file mode 100644 index 000000000..56d3b7aec --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error32.C @@ -0,0 +1,8 @@ +// PR c++/33492 +// { dg-options "" } + +void foo() +{ + if (throw 0) // { dg-error "could not convert .\\<throw-expression\\>. from .void. to .bool." } + ; +} diff --git a/gcc/testsuite/g++.dg/other/error33.C b/gcc/testsuite/g++.dg/other/error33.C new file mode 100644 index 000000000..48fca70d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error33.C @@ -0,0 +1,11 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/42218 +// { dg-do compile } + +template<int> struct A +{ + template<int> struct B; +}; + +int i = A<0>::B<0>::X::Y; // { dg-error "'A<0>::B<0>::X' has not been declared" } + diff --git a/gcc/testsuite/g++.dg/other/error34.C b/gcc/testsuite/g++.dg/other/error34.C new file mode 100644 index 000000000..10a782d38 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error34.C @@ -0,0 +1,6 @@ +// PR c++/46538 +// { dg-do compile } +// { dg-options "" } + +S () : str(__PRETTY_FUNCTION__) {} // { dg-error "forbids declaration" } +// { dg-error "only constructors" "" { target *-*-* } 5 } diff --git a/gcc/testsuite/g++.dg/other/error4.C b/gcc/testsuite/g++.dg/other/error4.C new file mode 100644 index 000000000..bd740d92a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error4.C @@ -0,0 +1,15 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 21 Mar 2003 <nathan@codesourcery.com> + +// PR 9898. Confusing error message + +struct Wrapper {}; + +void Foo(int const &); // { dg-error "in passing" "" } + +void Baz () +{ + Foo (Wrapper ()); // { dg-error "Wrapper" "" } +} diff --git a/gcc/testsuite/g++.dg/other/error5.C b/gcc/testsuite/g++.dg/other/error5.C new file mode 100644 index 000000000..c7a142fb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error5.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// Origin: Wolfgang Bangerth <bangerth@ices.utexas.edu> +// PR c++/11106: Error message gives partially mangled operator name + +template <typename T> struct S { + struct I {}; +}; + +template <typename T> struct S2 : S<T> { + using S<T>::operator typename S<T>::I*; // { dg-error "operator S\\<int\\>" "" } +}; + +template struct S2<int>; // { dg-message "instantiated" "" } diff --git a/gcc/testsuite/g++.dg/other/error6.C b/gcc/testsuite/g++.dg/other/error6.C new file mode 100644 index 000000000..21180d765 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error6.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// Make sure we emit a decent error message when trying to mangle an +// expression not supported by the C++ ABI due to a defect. +// Update: Better to make it supported, I think... + +template <int N> +struct A {}; + +struct B +{ + static int foo(void); +}; + +template <class T> +A<sizeof(T::foo())> func(void); + +int main() +{ + func<B>(); +} diff --git a/gcc/testsuite/g++.dg/other/error7.C b/gcc/testsuite/g++.dg/other/error7.C new file mode 100644 index 000000000..9845b4172 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error7.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// Origin: <andrewp at andypo dot net> +// c++/8046: ICE on illegal code involving destructor being treated as bit-not +// expression + +class A; +namespace N {} + +void foo(void) +{ + N::~A(); // { dg-error "not a class-name" } +} diff --git a/gcc/testsuite/g++.dg/other/error8.C b/gcc/testsuite/g++.dg/other/error8.C new file mode 100644 index 000000000..9246c2afa --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error8.C @@ -0,0 +1,22 @@ +// { dg-do compile } +// Contributed by: Michael Elizabeth Chastain +// <mec dot gnu at mindspring dot com> +// PR c++/13927: Wrong error message for redeclartion of type from union + +void foo(void) +{ + union { int alpha; int beta; }; // { dg-error "previous declaration" } + double alpha; // { dg-error "conflicting declaration" } +} + +// This checks both the templated version, and the position of the diagnostic +// (which is currently wrong). +template <int> +void tfoo(void) +{ + union { + int alpha; // { dg-error "" "" { xfail *-*-* } } + int beta; + }; // { dg-bogus "" "misplaced position of the declaration" { xfail *-*-* } } + double alpha; // { dg-error "" "" } +} diff --git a/gcc/testsuite/g++.dg/other/error9.C b/gcc/testsuite/g++.dg/other/error9.C new file mode 100644 index 000000000..65a9c58ce --- /dev/null +++ b/gcc/testsuite/g++.dg/other/error9.C @@ -0,0 +1,20 @@ +// { dg-options -Wall } + +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 27 Sept 2004 <nathan@codesourcery.com> + +// Origin: v.haisman@sh.cvut.cz +// Bug 17681: bad diagnostic text. + +struct A +{ }; + +struct B +{ }; + +struct C : public B, public A +{ + C () // { dg-warning "when initialized" "" } + : A(), B() // { dg-warning "base .\[AB\]." "" } + { } +}; diff --git a/gcc/testsuite/g++.dg/other/field1.C b/gcc/testsuite/g++.dg/other/field1.C new file mode 100644 index 000000000..61a9df695 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/field1.C @@ -0,0 +1,25 @@ +// { dg-do compile } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Jul 2003 <nathan@codesourcery.com> + +// PR c++ 9483. accepted fields with same name as class + +struct test +{ + char test; // { dg-error "with same name as class" "" } + test(); +}; + +template <typename T> struct X +{ + char X; // { dg-error "with same name as class" "" } + X (); +}; + +template <> struct X<int> { + char X; // { dg-error "with same name as class" "" } + X(); +}; + +X<float> i; // { dg-message "instantiated from" "" } diff --git a/gcc/testsuite/g++.dg/other/first-global.C b/gcc/testsuite/g++.dg/other/first-global.C new file mode 100644 index 000000000..d58bc7164 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/first-global.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-add-options bind_pic_locally } */ +/* { dg-final { scan-assembler "_GLOBAL__(I|sub_I)(_|_65535_0_)foobar" } } */ + +struct foo { foo (); }; +foo foobar; diff --git a/gcc/testsuite/g++.dg/other/fold1.C b/gcc/testsuite/g++.dg/other/fold1.C new file mode 100644 index 000000000..23d34546e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/fold1.C @@ -0,0 +1,8 @@ +// PR middle-end/27384 +// { dg-do compile } + +struct A +{ + static const int i = i; // { dg-error "not declared" } + int x[i]; // { dg-error "constant-expression" } +}; diff --git a/gcc/testsuite/g++.dg/other/friend1.C b/gcc/testsuite/g++.dg/other/friend1.C new file mode 100644 index 000000000..3193180ca --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend1.C @@ -0,0 +1,12 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 10 Oct 2001 <nathan@codesourcery.com> + +// Bug 4476. We tangled up inline friends and pure virtuals during +// class definition. + +struct A { + friend void f () { } + void g (A a) { } +}; diff --git a/gcc/testsuite/g++.dg/other/friend2.C b/gcc/testsuite/g++.dg/other/friend2.C new file mode 100644 index 000000000..ce5d2b741 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend2.C @@ -0,0 +1,23 @@ +// { dg-do run } +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> + +// PR c++/12370 +// Wrong code because of the friend declaration + +template <typename T> struct A +{ + T x; + A(T t) : x(t) {} + friend A<int> foo (const A<unsigned>&); +}; + +A<int> foo (const A<unsigned>& a) +{ + A<int> res(a.x); + return res; +} + +int main() +{ + return foo(A<unsigned>(0)).x; +} diff --git a/gcc/testsuite/g++.dg/other/friend3.C b/gcc/testsuite/g++.dg/other/friend3.C new file mode 100644 index 000000000..ce872e555 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend3.C @@ -0,0 +1,13 @@ +// PR c++/22293 +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> +// { dg-do compile } + +struct A +{ + friend ~A(); // { dg-error "qualified name" } +}; + +struct B +{ + friend ~A(); // { dg-error "qualified name" } +}; diff --git a/gcc/testsuite/g++.dg/other/friend4.C b/gcc/testsuite/g++.dg/other/friend4.C new file mode 100644 index 000000000..537643df9 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend4.C @@ -0,0 +1,8 @@ +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> +// Misleading diagnostic + +struct A +{ + friend void A::foo(); // { dg-error "implicitly friends" } + friend A::~A(); // { dg-error "implicitly friends" } +}; diff --git a/gcc/testsuite/g++.dg/other/friend5.C b/gcc/testsuite/g++.dg/other/friend5.C new file mode 100644 index 000000000..b0ec201fb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/friend5.C @@ -0,0 +1,9 @@ +/* PR c++/32111 */ +/* This used to ICE. */ + +/* { dg-do compile } */ + +struct A +{ + friend A::~A() {} /* { dg-error "implicitly friends of their class" } */ +}; diff --git a/gcc/testsuite/g++.dg/other/gc1.C b/gcc/testsuite/g++.dg/other/gc1.C new file mode 100644 index 000000000..3c7a16998 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/gc1.C @@ -0,0 +1,49 @@ +// This test failed with GGC_ALWAYS_COLLECT because not all unparsed +// inline methods were registered with GC. +// { dg-do compile } + +const char *foo () +{ + struct A + { + const char *a1 () + { + return "a1"; + } + const char *a2 () + { + struct B + { + const char *b1 () + { + return "b1"; + } + const char *b2 () + { + struct C + { + const char *c1 () + { + return "c1"; + } + const char *c2 () + { + return "c2"; + } + }; + return "b2"; + } + const char *b3 () + { + return "b3"; + } + }; + return "a2"; + } + const char *a3 () + { + return "a3"; + } + }; + return "foo"; +} diff --git a/gcc/testsuite/g++.dg/other/gc2.C b/gcc/testsuite/g++.dg/other/gc2.C new file mode 100644 index 000000000..142229475 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/gc2.C @@ -0,0 +1,38 @@ +// PR c++/12316 +// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> + +// { dg-do compile } +// { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } + +inline void FOO() {} + +template<typename> struct A +{ + A() {} + ~A() throw() {} +}; + +template<typename> struct B +{ + static void foo(); + static void bar() { foo(); } +}; + +struct C {}; + +template<typename> struct D : C +{ + D() {} + ~D() { B<void>::bar(); } +}; + +template<typename> struct E : D<void> +{ + static void baz() {} + E(A<void>) { baz(); } +}; + +void BAR() +{ + new E<void>(A<void>()); +} diff --git a/gcc/testsuite/g++.dg/other/gc3.C b/gcc/testsuite/g++.dg/other/gc3.C new file mode 100644 index 000000000..500d109e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/gc3.C @@ -0,0 +1,8 @@ +// PR c++/21687 +// { dg-options "--param ggc-min-expand=0 --param ggc-min-heapsize=0" } + +template <class Union> +void perform_test_trivial() { + struct check_union { void perform_test_trivial() {} }; +} + diff --git a/gcc/testsuite/g++.dg/other/gc4.C b/gcc/testsuite/g++.dg/other/gc4.C new file mode 100644 index 000000000..50c16b366 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/gc4.C @@ -0,0 +1,14 @@ +// PR c++/41120 +// { dg-options "--param ggc-min-heapsize=0 --param ggc-min-expand=0" } + +struct A +{ + A(); +}; + +struct B +{ + A a; +}; + +B b; diff --git a/gcc/testsuite/g++.dg/other/i386-1.C b/gcc/testsuite/g++.dg/other/i386-1.C new file mode 100644 index 000000000..ec572ec94 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-1.C @@ -0,0 +1,28 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <xmmintrin.h> + +static void +sse2_test (void) +{ + float a = 1.0f; + float b = 2.0f; + float c = 3.0f; + float r; + + __m128 v = _mm_set_ps(a, b, c, 0); + + v = (__m128)_mm_srli_si128((__m128i)v, 4); + _mm_store_ss(&r, v); + if (r != 3.0f) + abort (); +} + +int +main () +{ + sse2_test (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/i386-2.C b/gcc/testsuite/g++.dg/other/i386-2.C new file mode 100644 index 000000000..1a445f1b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-2.C @@ -0,0 +1,11 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -pedantic-errors -march=k8 -msse4a -m3dnow -mavx -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mbmi -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */ + +/* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h, + xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h, + popcntintrin.h and mm_malloc.h.h are usable with -O -pedantic-errors. */ + +#include <x86intrin.h> + +int dummy; + diff --git a/gcc/testsuite/g++.dg/other/i386-3.C b/gcc/testsuite/g++.dg/other/i386-3.C new file mode 100644 index 000000000..66eec1422 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-3.C @@ -0,0 +1,9 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -fkeep-inline-functions -march=k8 -msse4a -m3dnow -mavx -mfma4 -mxop -maes -mpclmul -mpopcnt -mabm -mbmi -mtbm -mlwp -mfsgsbase -mrdrnd -mf16c" } */ + +/* Test that {,x,e,p,t,s,w,a,b,i}mmintrin.h, mm3dnow.h, fma4intrin.h, + xopintrin.h, abmintrin.h, bmiintrin.h, tbmintrin.h, lwpintrin.h, + popcntintrin.h and mm_malloc.h are usable with + -O -fkeep-inline-functions. */ + +#include <x86intrin.h> diff --git a/gcc/testsuite/g++.dg/other/i386-4.C b/gcc/testsuite/g++.dg/other/i386-4.C new file mode 100644 index 000000000..858a3a74e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-4.C @@ -0,0 +1,30 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O1 -msse2" } */ +/* { dg-require-effective-target sse2 } */ + +#include <xmmintrin.h> + +void ConvertFloatSSE (void *inBuff, void *outBuff, int len) +{ + unsigned char *inByteBuffer = reinterpret_cast < unsigned char *>(inBuff); + float *outFloatBuffer = reinterpret_cast < float *>(outBuff); + + for (int i = 0; i < len / 4; i++) + { + __m128i register1 = + _mm_set_epi8 (*inByteBuffer, *(inByteBuffer + 1), + *(inByteBuffer + 2), 0, + *(inByteBuffer + 3), *(inByteBuffer + 4), + *(inByteBuffer + 5), 0, + *(inByteBuffer + 6), *(inByteBuffer + 7), + *(inByteBuffer + 8), 0, + *(inByteBuffer + 9), *(inByteBuffer + 10), + *(inByteBuffer + 11), 0); + __m128i register2 = _mm_srai_epi32 (register1, 8); + __m128 register3 = _mm_cvtepi32_ps (register2); + + _mm_store_ps (outFloatBuffer, register3); + outFloatBuffer += 4; + inByteBuffer += 12; + } +} diff --git a/gcc/testsuite/g++.dg/other/i386-7.C b/gcc/testsuite/g++.dg/other/i386-7.C new file mode 100644 index 000000000..e2ad51e52 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-7.C @@ -0,0 +1,8 @@ +/* Test that x86intrin.h is usable with -O -pedantic-errors. */ +/* We were using SSE4.2 builtins without the extension available. */ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O -pedantic-errors" } */ + +#include <x86intrin.h> + +int dummy; diff --git a/gcc/testsuite/g++.dg/other/i386-8.C b/gcc/testsuite/g++.dg/other/i386-8.C new file mode 100644 index 000000000..7de75c73c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-8.C @@ -0,0 +1,23 @@ +// PR rtl-optimization/45400 +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-O2 -msse2" } +// { dg-options "-O2 -msse2 -fpic" { target fpic } } +// { dg-require-effective-target sse2 } + +#include <xmmintrin.h> + +static inline unsigned short +bar (unsigned short x) +{ + return ((x << 8) | (x >> 8)); +} + +unsigned int +foo (float *x, short *y) +{ + __m128 a = _mm_set_ps1 (32767.5f); + __m128 b = _mm_mul_ps (_mm_load_ps (x), a); + __m64 c = _mm_cvtps_pi16 (b); + __builtin_memcpy (y, &c, sizeof (short) * 4); + y[0] = bar (y[0]); +} diff --git a/gcc/testsuite/g++.dg/other/i386-9.C b/gcc/testsuite/g++.dg/other/i386-9.C new file mode 100644 index 000000000..796405791 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/i386-9.C @@ -0,0 +1,12 @@ +// PR target/48142 +// Testcase by Zdenek Sojka <zsojka@seznam.cz> + +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-options "-Os -mpreferred-stack-boundary=5 -fstack-check -fno-omit-frame-pointer" } + +int main() +{ + try { throw 0; } + catch (...) {} + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/incomplete1.C b/gcc/testsuite/g++.dg/other/incomplete1.C new file mode 100644 index 000000000..cb7970fad --- /dev/null +++ b/gcc/testsuite/g++.dg/other/incomplete1.C @@ -0,0 +1,7 @@ +// PR c++/23089 +// Origin: Flash Sheridan <flash@pobox.com> +// ICE on incomplete type +// { dg-do compile } +// { dg-options "-O" } + +void foo(struct A) {} // { dg-error "incomplete type|forward declaration" } diff --git a/gcc/testsuite/g++.dg/other/incomplete2.C b/gcc/testsuite/g++.dg/other/incomplete2.C new file mode 100644 index 000000000..127bf588e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/incomplete2.C @@ -0,0 +1,14 @@ +// PR c++/19963 +// { dg-do compile } + +struct A; + +struct B +{ + A a : 1; // { dg-error "incomplete" } +}; + +struct S +{ + S : 1; // { dg-error "incomplete" } +}; diff --git a/gcc/testsuite/g++.dg/other/incomplete3.C b/gcc/testsuite/g++.dg/other/incomplete3.C new file mode 100644 index 000000000..14de98eb6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/incomplete3.C @@ -0,0 +1,9 @@ +//PR c++/28054 + +struct A; + +struct B +{ + friend A : 2; // { dg-error "incomplete type" } +}; + diff --git a/gcc/testsuite/g++.dg/other/increment1.C b/gcc/testsuite/g++.dg/other/increment1.C new file mode 100644 index 000000000..506157ef2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/increment1.C @@ -0,0 +1,19 @@ +// PR c++/37561 +// { dg-do compile } +// { dg-options "-Wno-int-to-pointer-cast" } + +__PTRDIFF_TYPE__ p; +char q; + +void +foo () +{ + ((char *) p)++; // { dg-error "lvalue" } + ((char *) q)++; // { dg-error "lvalue" } + ((char *) p)--; // { dg-error "lvalue" } + ((char *) q)--; // { dg-error "lvalue" } + ++(char *) p; // { dg-error "lvalue" } + ++(char *) q; // { dg-error "lvalue" } + --(char *) p; // { dg-error "lvalue" } + --(char *) q; // { dg-error "lvalue" } +} diff --git a/gcc/testsuite/g++.dg/other/infloop-1.C b/gcc/testsuite/g++.dg/other/infloop-1.C new file mode 100644 index 000000000..6c851c7e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/infloop-1.C @@ -0,0 +1,16 @@ +// PR 18300: This sends old compilers into an infinite loop on x86_64 +// Testcase and patch contributed by Zak Kipling <zak@transversal.com> + +struct base1 { }; +struct base2 { }; +struct base3 { }; + +struct derived : base1, base2, base3 { }; + +void foo(derived); + +int main() +{ + foo(derived()); +} + diff --git a/gcc/testsuite/g++.dg/other/init1.C b/gcc/testsuite/g++.dg/other/init1.C new file mode 100644 index 000000000..7fc7db66a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/init1.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 13 Nov 2001 <nathan@codesourcery.com> + +// Bug 3154 + +class A {}; + +struct B : A +{ + typedef A Parent; + + B () : Parent () {} +}; + +class T +{ + typedef int Foo; + T () : Foo () {} // { dg-error "T::Foo' is not" "" } +}; + +struct S : B +{ + int Parent; + + S () :Parent (1) {} +}; diff --git a/gcc/testsuite/g++.dg/other/init2.C b/gcc/testsuite/g++.dg/other/init2.C new file mode 100644 index 000000000..0b85aa67d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/init2.C @@ -0,0 +1,49 @@ +// { dg-do run } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 20 Dec 2001 <nathan@nathan@codesourcery.com> + +// PR 160. Wrong code emitted for some reference initializers. + +void Foo () +{ +} + +int fail; + +class C +{ + public: + int m; + int &r; + + C () ; +}; + +C::C () + : m (1), r ((Foo (), m)) +{ + m = 10; + + if (r != m) + fail = 1; + else if (&m != &r) + fail = 2; +} +int main () +{ + int m (1); + int &r ((Foo (),m)); + + m = 10; + if (r != m) + fail = 3; + else if (&r != &m) + fail = 4; + + if (!fail) + { + C c; + } + return fail; +} diff --git a/gcc/testsuite/g++.dg/other/java1.C b/gcc/testsuite/g++.dg/other/java1.C new file mode 100644 index 000000000..38b5e0c30 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/java1.C @@ -0,0 +1,22 @@ +// { dg-options "-w -ansi -pedantic" } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 23 Oct 2003 <nathan@codesourcery.com> + +extern "Java" { + class One + { + ~One (); // { dg-error "cannot have a destructor" "" } + One (); + }; + + class Two {}; + + class Three : One {}; // { dg-error "cannot have an implicit" "" } + + class Four : Two {}; + + class Five : Two, Four {}; // { dg-error "cannot have multiple bases" "" } + + class Six : virtual Two {}; // { dg-error "cannot have virtual base" "" } +} diff --git a/gcc/testsuite/g++.dg/other/java2.C b/gcc/testsuite/g++.dg/other/java2.C new file mode 100644 index 000000000..8ba4d5a72 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/java2.C @@ -0,0 +1,11 @@ +// PR c++/??? +// { dg-do compile } + +extern "Java" +{ + struct A {}; +} + +typedef void* jclass; + +A* p = new A; // { dg-error "class\\$" } diff --git a/gcc/testsuite/g++.dg/other/label1.C b/gcc/testsuite/g++.dg/other/label1.C new file mode 100644 index 000000000..74572dc7d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/label1.C @@ -0,0 +1,7 @@ +//PR c++/27820 + +void foo() +{ + L: L: ; // { dg-error "duplicate label" } +} + diff --git a/gcc/testsuite/g++.dg/other/large-size-array.C b/gcc/testsuite/g++.dg/other/large-size-array.C new file mode 100644 index 000000000..9614fb125 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/large-size-array.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +#include <limits.h> + +#ifdef _WIN64 +#define DIM ULLONG_MAX>>1 +#else +#ifdef __LP64__ +#define DIM UINT_MAX>>1 +#else +#define DIM USHRT_MAX>>1 +#endif +#endif + +int +sub (int *a) +{ + return a[0]; +} + +int +main (void) +{ + int a[DIM][DIM]; /* { dg-error "size of array 'a' is too large" } */ + return sub (&a[0][0]); /* { dg-error "declared" } */ +} + + diff --git a/gcc/testsuite/g++.dg/other/linkage1.C b/gcc/testsuite/g++.dg/other/linkage1.C new file mode 100644 index 000000000..c2676bac1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/linkage1.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Dec 2001 <nathan@nathan@codesourcery.com> + +// PR 51 +// This example snippet is from the ISO C++ standard, sect 7.5 para 4: + +extern "C" typedef void FUNC_c(); + +class C { + public: + static FUNC_c* q; +}; diff --git a/gcc/testsuite/g++.dg/other/macro-1.C b/gcc/testsuite/g++.dg/other/macro-1.C new file mode 100644 index 000000000..e1d9d34cd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/macro-1.C @@ -0,0 +1,3 @@ +/* { dg-do compile } */ + +short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__))); diff --git a/gcc/testsuite/g++.dg/other/main1.C b/gcc/testsuite/g++.dg/other/main1.C new file mode 100644 index 000000000..ba945741e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/main1.C @@ -0,0 +1,4 @@ +// PR c++/30021 +// { dg-do compile } + +int main(void,char**); // { dg-error "incomplete type|invalid use" } diff --git a/gcc/testsuite/g++.dg/other/mmintrin.C b/gcc/testsuite/g++.dg/other/mmintrin.C new file mode 100644 index 000000000..8315f93d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/mmintrin.C @@ -0,0 +1,5 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-msse" } +// { dg-require-effective-target sse } + +#include <xmmintrin.h> diff --git a/gcc/testsuite/g++.dg/other/mult-stor1.C b/gcc/testsuite/g++.dg/other/mult-stor1.C new file mode 100644 index 000000000..1eaec4f14 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/mult-stor1.C @@ -0,0 +1,8 @@ +// PR c++/20646 +// Origin: Dan Rosen <dan.rosen@gmail.com> +// { dg-do compile } + +struct A +{ + extern static int i; // { dg-error "conflicting specifiers" } +}; diff --git a/gcc/testsuite/g++.dg/other/nested-extern-1.C b/gcc/testsuite/g++.dg/other/nested-extern-1.C new file mode 100644 index 000000000..6533a2ade --- /dev/null +++ b/gcc/testsuite/g++.dg/other/nested-extern-1.C @@ -0,0 +1,17 @@ +/* { dg-do run } */ +// { dg-additional-sources "nested-extern.cc" } +/* PR 31775 */ +extern "C" void abort(); +extern int *p; +int main() +{ + extern int i; + i = 1; + *p = 2; + if (i == 2) + abort (); + return 0; +} + +static int i; +int *p = &i; diff --git a/gcc/testsuite/g++.dg/other/nested-extern-2.C b/gcc/testsuite/g++.dg/other/nested-extern-2.C new file mode 100644 index 000000000..58f53e083 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/nested-extern-2.C @@ -0,0 +1,18 @@ +/* { dg-do run } */ +// { dg-additional-sources "nested-extern.cc" } +/* PR 31775 */ +extern "C" void abort(); +static int i; +int *p = &i; +int main() +{ + int i; + { + extern int i; + i = 1; + *p = 2; + if (i == 2) + abort (); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/nested-extern.cc b/gcc/testsuite/g++.dg/other/nested-extern.cc new file mode 100644 index 000000000..048f715b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/nested-extern.cc @@ -0,0 +1 @@ +int i; diff --git a/gcc/testsuite/g++.dg/other/new-size-type.C b/gcc/testsuite/g++.dg/other/new-size-type.C new file mode 100644 index 000000000..04933fd4a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/new-size-type.C @@ -0,0 +1,10 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/36741 + +#include <stddef.h> +const char* +foo() +{ + return new char[~static_cast<size_t>(0)];// { dg-bogus "large" } +} + diff --git a/gcc/testsuite/g++.dg/other/new1.C b/gcc/testsuite/g++.dg/other/new1.C new file mode 100644 index 000000000..71383706e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/new1.C @@ -0,0 +1,14 @@ +// PR c++/28267 +// { dg-do compile } + +struct A +{ + A(); + void* operator new(__SIZE_TYPE__, int = X); // { dg-error "not declared" } + void operator delete(void*, int); +}; + +void foo() +{ + new A; // { dg-error "default argument" } +} diff --git a/gcc/testsuite/g++.dg/other/nontype-1.C b/gcc/testsuite/g++.dg/other/nontype-1.C new file mode 100644 index 000000000..11bbfb829 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/nontype-1.C @@ -0,0 +1,7 @@ +template <class Op> +bool asfun(Op f, + Op::first_argument_type a, // { dg-error "not a type" } + Op::second_argument_type b) // { dg-error "not a type" } +{ + return Op(a, b); +} diff --git a/gcc/testsuite/g++.dg/other/ns1.C b/gcc/testsuite/g++.dg/other/ns1.C new file mode 100644 index 000000000..cb77780dc --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ns1.C @@ -0,0 +1,13 @@ +// PR c++/14821 + +namespace A { + namespace B {} +} + +namespace A { + namespace Alias = ::A::B; +} + +namespace A { + namespace Alias = ::A::B; +} diff --git a/gcc/testsuite/g++.dg/other/offsetof1.C b/gcc/testsuite/g++.dg/other/offsetof1.C new file mode 100644 index 000000000..78738892a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof1.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Aug 2002 <nathan@codesourcery.com> + +// PR c++ 7598, offsetof broke +// PR c++ 11072, DR 273's solution is broken + +#include <cstddef> + +struct F +{ + char i; + char j; +}; + +static int ary[offsetof(F, j)]; diff --git a/gcc/testsuite/g++.dg/other/offsetof2.C b/gcc/testsuite/g++.dg/other/offsetof2.C new file mode 100644 index 000000000..3ab63981d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof2.C @@ -0,0 +1,47 @@ +// { dg-do run } +// { dg-options -Wold-style-cast } + +// Copyright (C) 2003 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 22 Apr 2003 <nathan@codesourcery.com> + +// DR273 POD can have an operator&, offsetof is still required to work + +#include <stddef.h> + +struct POD1 +{ + int m; + + void *operator& () const {return 0;} // yes, still a pod! +}; + +struct POD2 +{ + int m; +}; + +void *operator& (POD2 const &) {return 0;} // ouch! + +struct POD3 +{ + int prefix; + + POD1 m; +}; + +struct POD4 +{ + int prefix; + + POD1 m; +}; + +int main () +{ + if (offsetof (POD3, m) != sizeof (int)) + return 1; + if (offsetof (POD4, m) != sizeof (int)) + return 2; + return 0; +} + diff --git a/gcc/testsuite/g++.dg/other/offsetof3.C b/gcc/testsuite/g++.dg/other/offsetof3.C new file mode 100644 index 000000000..5946c812c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof3.C @@ -0,0 +1,17 @@ +/* Verify that offsetof warns if given a non-standard-layout class */ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ +/* Contributed by Matt Austern <austern@apple.com> 15 May 2003 */ +/* { dg-do compile } */ + +struct X +{ + int x, y; +protected: + int z; +}; + +typedef X* pX; +typedef __SIZE_TYPE__ size_t; + +size_t yoff = size_t(&(pX(0)->y)); /* { dg-warning "invalid access" "" } */ +/* { dg-warning "macro was used incorrectly" "macro" { target *-*-* } 16 } */ diff --git a/gcc/testsuite/g++.dg/other/offsetof4.C b/gcc/testsuite/g++.dg/other/offsetof4.C new file mode 100644 index 000000000..ab2282e25 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof4.C @@ -0,0 +1,16 @@ +/* Verify that -Wno-invalid-offsetof disables warning */ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ +/* Contributed by Matt Austern <austern@apple.com> 15 May 2003 */ +/* { dg-do compile } */ +/* { dg-options "-Wno-invalid-offsetof" } */ + +struct X +{ + X() : x(3), y(4) { } + int x, y; +}; + +typedef X* pX; +typedef __SIZE_TYPE__ size_t; + +size_t yoff = size_t(&(pX(0)->y)); diff --git a/gcc/testsuite/g++.dg/other/offsetof5.C b/gcc/testsuite/g++.dg/other/offsetof5.C new file mode 100644 index 000000000..3c4843380 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof5.C @@ -0,0 +1,22 @@ +// PR c++/35741 +// { dg-do compile } + +#include <stddef.h> + +struct A +{ + char c; + int &i; +}; + +int j = offsetof (A, i); // { dg-warning "invalid access|offsetof" } + +template <typename T> +struct S +{ + T h; + T &i; + static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" } +}; + +int k = S<int>::j; // { dg-message "instantiated from here" } diff --git a/gcc/testsuite/g++.dg/other/offsetof6.C b/gcc/testsuite/g++.dg/other/offsetof6.C new file mode 100644 index 000000000..b77d1b99a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof6.C @@ -0,0 +1,26 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin PR c++/38699 +// { dg-do compile } + +template<class T> +struct A +{ + const T *p; +}; + +struct B +{ + A<int> a; +}; + +template class A<char>; + +void +f0 () +{ + __builtin_offsetof(A<char>, p); // OK + __builtin_offsetof(A<char>, p[1]); // { dg-error "non constant address" } + __builtin_offsetof(B, a.p); // OK + __builtin_offsetof(B, a.p[1]); // { dg-error "non constant address" } +} + diff --git a/gcc/testsuite/g++.dg/other/offsetof7.C b/gcc/testsuite/g++.dg/other/offsetof7.C new file mode 100644 index 000000000..0ce2ee02a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof7.C @@ -0,0 +1,17 @@ +// PR c++/50608 +// Testcase by <dberger@oubliette.org> +// { dg-do compile } + +struct A { + int offset; +}; + +struct B: public A { +}; + +struct C { + A a; + B b; +}; + +int fails = __builtin_offsetof (C, b.offset); diff --git a/gcc/testsuite/g++.dg/other/opaque-1.C b/gcc/testsuite/g++.dg/other/opaque-1.C new file mode 100644 index 000000000..5cdaeafe3 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/opaque-1.C @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-mcpu=8540 -mspe -mabi=spe -mfloat-gprs=single" } */ +/* { dg-skip-if "not an SPE target" { ! powerpc_spe_nocache } { "*" } { "" } } */ + +#define __vector __attribute__((vector_size(8))) +typedef float __vector __ev64_fs__; + +__ev64_fs__ f; +__ev64_opaque__ o; + +int here = 0; + +void bar (__ev64_opaque__ x) +{ + here = 0; +} + +void bar (__ev64_fs__ x) +{ + here = 888; +} + +int main () +{ + f = o; + o = f; + bar (f); + if (here != 888) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/opaque-2.C b/gcc/testsuite/g++.dg/other/opaque-2.C new file mode 100644 index 000000000..3bb4af2c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/opaque-2.C @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=8540 -mspe -mabi=spe -mfloat-gprs=single" } */ +/* { dg-skip-if "not an SPE target" { ! powerpc_spe_nocache } { "*" } { "" } } */ + +#define __vector __attribute__((vector_size(8))) +typedef float __vector __ev64_fs__; + +__ev64_fs__ f; +__ev64_opaque__ o; + +extern void bar (__ev64_opaque__); + +int main () +{ + f = o; + o = f; + bar (f); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/opaque-3.C b/gcc/testsuite/g++.dg/other/opaque-3.C new file mode 100644 index 000000000..5ece652c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/opaque-3.C @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=8540 -mspe -mabi=spe -mfloat-gprs=single" } */ +/* { dg-skip-if "not an SPE target" { ! powerpc_spe_nocache } { "*" } { "" } } */ + +__ev64_opaque__ o; +#define v __attribute__((vector_size(8))) +v unsigned int *p; + +void m() +{ + o = __builtin_spe_evldd(p, 5); +} diff --git a/gcc/testsuite/g++.dg/other/operator1.C b/gcc/testsuite/g++.dg/other/operator1.C new file mode 100644 index 000000000..86841c999 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/operator1.C @@ -0,0 +1,9 @@ +// PR c++/27547 +// { dg-do compile } + +int operator=(int); // { dg-error "member function" } + +void foo() +{ + operator=(0); // { dg-error "not defined" } +} diff --git a/gcc/testsuite/g++.dg/other/operator2.C b/gcc/testsuite/g++.dg/other/operator2.C new file mode 100644 index 000000000..4b952bf11 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/operator2.C @@ -0,0 +1,10 @@ +// PR c++/28852 +// { do-do compile } + +struct A +{ + operator int&(int); // { dg-error "void" } +}; + +A a; +int& i = a; // { dg-error "initialization" } diff --git a/gcc/testsuite/g++.dg/other/packed1.C b/gcc/testsuite/g++.dg/other/packed1.C new file mode 100644 index 000000000..ac586c6c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/packed1.C @@ -0,0 +1,29 @@ +// { dg-do run { xfail sh-*-* lm32-*-* } } + +// NMS:2003-04-21 this fails on strict aligned architectures again, +// the patch was reverted because it broke something more important. + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Aug 2002 <nathan@codesourcery.com> + +// WRS SPR 63496, lost packed attribute when accessing a packed +// field. This matters on aligned architectures like sh + +struct thing { int m; }; + +struct pod + { + char a; + thing m __attribute__ ((packed)); // { dg-warning "attribute ignored" "" { target default_packed } } + }; + +int main () +{ + thing t; + pod p; + + p.m = t; /* runtime bus error here */ + + return 0; + +} diff --git a/gcc/testsuite/g++.dg/other/pr20366.C b/gcc/testsuite/g++.dg/other/pr20366.C new file mode 100644 index 000000000..36a689ebf --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr20366.C @@ -0,0 +1,80 @@ +// Test fix for PR20366 +// +// { dg-do compile { target *-*-aix* } } +// { dg-options "-D_LARGE_FILES" } +// +// cstdio includes stdio.h and undefs most of the functions declared +// therein, unfortunately this means that #define fopen fopen64 goes +// away. This tests the fix, and ensures that with -D_LARGE_FILES +// fopen et. al. are indeed aliased to the large file equivalents. +// +// There are many other #define foo foo64 in the AIX headers, but +// these all work out fine as they are not undefined in libstdc++. +// This list is probably incomplete: +// +// Symbol Return type Large file declaration. +// +// aio.h (different for different AIX versions) +// ===== +// aio_read int aio_read64(int, struct aiocb64 *); +// aio_write int aio_write64(int, struct aiocb64 *); +// lio_listio int lio_listio64(int, struct liocb64 *[], int, void *); +// aio_cancel int aio_cancel64(int, struct aiocb64 *); +// aio_suspend int aio_suspend64(int, struct aiocb64 *[]); +// +// stdio.h +// ======= +// fgetpos int fgetpos64(FILE *, fpos64_t *); +// fopen FILE *fopen64(const char *, const char *); +// freopen FILE *freopen64(const char *, const char *, FILE *); +// fseeko int fseeko64(FILE *, off64_t, int); +// fsetpos int fsetpos64(FILE *, const fpos64_t *); +// ftello off64_t ftello64(FILE *); +// +// unistd.h +// ======== +// fclear off64_t fclear64(int, off64_t); +// fsync_range int fsync_range64(int, int, off64_t, off64_t); +// ftruncate int ftruncate64(int, off64_t); +// truncate int truncate64(const char *, off64_t); +// lseek off64_t lseek64(int, off64_t, int); +// pread ssize_t pread64(int, void *, size_t, off64_t); +// pwrite ssize_t pwrite64(int, const void *, size_t, off64_t); +// +// fcntl.h +// ======= +// open int open64(const char *, int, ...); +// creat int creat64(const char *, mode_t); +// +// sys/stat.h +// ========== +// stat int stat64(const char *, struct stat64 *); +// fstat int fstat64(int, struct stat64 *); +// lstat int lstat64(const char *, struct stat64 *); +// +// stdlib.h +// ======== +// mkstemp int mkstemp64(char *); +// +// ftw.h +// ===== +// ftw int ftw64(const char *, int (*)(const char *,const struct stat64 *, int), int); +// nftw int nftw64(const char *, int (*)(const char *, const struct stat64 *, int, struct FTW*), int, int); +// +// It seems unlikely that any of these will be used (and #undef'ed) by +// libstdc++ in the future, if they are then this test and its +// associated patch to fixincludes will have to be revisited. + +#include <cstdio> + +extern "C" { +int fgetpos(FILE *, fpos64_t *); +FILE *fopen(const char *, const char *); +FILE *freopen(const char *, const char *, FILE *); +int fseeko(FILE *, off64_t, int); +int fsetpos(FILE *, const fpos64_t *); +off64_t ftello(FILE *); +} +int main() { + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/pr22003.C b/gcc/testsuite/g++.dg/other/pr22003.C new file mode 100644 index 000000000..222ccac7b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr22003.C @@ -0,0 +1,25 @@ +/* PR rtl-optimization/22003 */ +/* { dg-do compile } */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -fno-exceptions -freorder-blocks-and-partition" } */ + +struct c1 +{ + virtual ~c1(); +}; +class c4; + +struct c2 +{ + virtual c4* func(); +}; + +struct c3 : c1, c2 +{ + c4* func(); +}; + +c4* c3::func() +{ +} + diff --git a/gcc/testsuite/g++.dg/other/pr22358.C b/gcc/testsuite/g++.dg/other/pr22358.C new file mode 100644 index 000000000..dbce0f8a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr22358.C @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +struct a +{ + virtual ~a(); +}; +struct b : virtual a { }; +b a11; diff --git a/gcc/testsuite/g++.dg/other/pr23205-2.C b/gcc/testsuite/g++.dg/other/pr23205-2.C new file mode 100644 index 000000000..608108ad9 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr23205-2.C @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-skip-if "No stabs" { mmix-*-* *-*-aix* *-*-netware* alpha*-*-* hppa*64*-*-* ia64-*-* } { "*" } { "" } } */ +/* { dg-options "-gstabs+ -fno-eliminate-unused-debug-types -ftoplevel-reorder" } */ + +const int foobar = 4; +int foo () +{ + return foobar + 1; +} + +int main() +{ + int i; + i = foo(); + return i; +} + +/* { dg-final { scan-assembler ".stabs.*foobar:c=i" } } */ diff --git a/gcc/testsuite/g++.dg/other/pr24623.C b/gcc/testsuite/g++.dg/other/pr24623.C new file mode 100644 index 000000000..480bb39b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr24623.C @@ -0,0 +1,69 @@ +/* This used to ICE due to a backend problem on s390. */ + +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +class ReferenceCounted +{ +public: + + virtual ~ ReferenceCounted () + { + } + void decrementRefCount () const + { + if (--const_cast < unsigned int &>(_ref_count) == 0) + { + delete this; + } + } + unsigned int _ref_count; +}; + +template < class T > class RefCountPointer +{ +public: + +RefCountPointer (T * p = 0):_p (p) + { + } + RefCountPointer & operator= (const RefCountPointer < T > &o) + { + if (_p != o._p) + { + if (_p != 0) + _p->decrementRefCount (); + } + } + ~RefCountPointer () + { + } + T *_p; +}; +class Item:public ReferenceCounted +{ +public: + + typedef RefCountPointer < const Item > Ptr; +}; +class AnyAtomicType:public Item +{ +}; +class StaticContext +{ +}; +class DynamicContext:public StaticContext +{ +}; +class SortableItem +{ + SortableItem (); + int m_bAscending:1; + DynamicContext *m_context; + AnyAtomicType::Ptr m_item; +}; +SortableItem::SortableItem () +{ + m_context = __null; + m_item = __null; +} diff --git a/gcc/testsuite/g++.dg/other/pr25632.C b/gcc/testsuite/g++.dg/other/pr25632.C new file mode 100644 index 000000000..e66ae3b51 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr25632.C @@ -0,0 +1,19 @@ +/* PR c++/25632 */ + +/* { dg-do compile } */ + +__extension__ typedef __INTPTR_TYPE__ intptr_t; + +struct sockaddr_un { + char sun_path[1]; +}; +const unsigned SI_SUN_HEAD_LEN = (intptr_t)(((struct sockaddr_un *)0)->sun_path); +int SiGetPeerName () +{ + return SI_SUN_HEAD_LEN; +} +int SiAccept () +{ + return SI_SUN_HEAD_LEN; +} + diff --git a/gcc/testsuite/g++.dg/other/pr27495.C b/gcc/testsuite/g++.dg/other/pr27495.C new file mode 100644 index 000000000..990b1ee5e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr27495.C @@ -0,0 +1,8 @@ + +// Test to make sure we do not ICE on this invalid program. + +struct A +{ + template<int> void foo(); + void bar() { this.A::foo<0>(); } // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/other/pr28114.C b/gcc/testsuite/g++.dg/other/pr28114.C new file mode 100644 index 000000000..63ecbf51f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr28114.C @@ -0,0 +1,10 @@ + +// Test to make sure we do not ICE on this invalid program. + +template<int> void foo(struct {}*); // { dg-message "" } + +void bar() +{ + foo<0>(0); // { dg-error "" } + // { dg-message "candidate" "candidate note" { target *-*-* } 8 } +} diff --git a/gcc/testsuite/g++.dg/other/pr28304.C b/gcc/testsuite/g++.dg/other/pr28304.C new file mode 100644 index 000000000..9a0e9cdd7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr28304.C @@ -0,0 +1,11 @@ + +// Test to make sure we do not ICE on this invalid program. + +struct A {}; + +template<typename T> void A::foo(T) {} // { dg-error "" } + +void bar() +{ + A::foo(1); // { dg-error "not a member" } +} diff --git a/gcc/testsuite/g++.dg/other/pr28432.C b/gcc/testsuite/g++.dg/other/pr28432.C new file mode 100644 index 000000000..2b9c76343 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr28432.C @@ -0,0 +1,7 @@ + +// Test to make sure we do not ICE on this invalid program. + +// { dg-options "" } + +struct A {}; +void A::foo(); // { dg-error "member function declared in class|outside of class is not definition" } diff --git a/gcc/testsuite/g++.dg/other/pr29610.C b/gcc/testsuite/g++.dg/other/pr29610.C new file mode 100644 index 000000000..6566fb9a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr29610.C @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops" } */ + +struct __normal_iterator +{ + typedef int*const *_Iterator; + int*const * _M_current; + __normal_iterator(const _Iterator& __i) : _M_current(__i){} + const _Iterator& base() const {} +}; +struct string { ~string(){} }; +struct vector +{ + int** _M_finish; + __normal_iterator end() const { return __normal_iterator (_M_finish); } + int size() const { return end().base() - end().base(); } +}; +class Painter +{ + int redraw_window(void); + typedef int (Painter::* SliceWindowFunc)(void); + int for_each(vector&, SliceWindowFunc); + void tcl_command(void); +}; +inline int Painter::for_each(vector &layout, SliceWindowFunc func) +{ + for (unsigned int window = 0; window < layout.size();++window) + (this->*func)(); +} +int t; +int Painter::redraw_window(void) {t = 1;} +string t2(int); +vector *g(const string&); +void Painter::tcl_command(void) +{ + for_each(*g(t2(2)), &Painter::redraw_window); +} + diff --git a/gcc/testsuite/g++.dg/other/pr31078.C b/gcc/testsuite/g++.dg/other/pr31078.C new file mode 100644 index 000000000..7f6107130 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr31078.C @@ -0,0 +1,31 @@ +typedef int SLONG; +typedef char SCHAR; +typedef short SSHORT; +typedef char TEXT; +typedef long ISC_STATUS; +const SLONG gds_arg_string = 2; +const SLONG gds_sys_request = 335544373L; +enum jrd_blk_t +{ + type_str, type_dcc, type_sbm, type_smb, type_blb, type_irb, type_jrn +}; +struct blk +{ +}; +template < class RPT, SSHORT BLOCK_TYPE = 0 > class pool_alloc_rpt:public blk +{ +}; +class jrn:public pool_alloc_rpt < SCHAR, type_jrn > +{ +public:ISC_STATUS * jrn_status_vector; + TEXT jrn_server[1]; +}; +typedef jrn *JRN; +extern void IBERR_build_status (ISC_STATUS *, ISC_STATUS, ...); +static void +error (ISC_STATUS * status_vector, JRN journal, int status, TEXT * string) +{ + IBERR_build_status (status_vector, gds_sys_request, gds_arg_string, string, + gds_arg_string, (journal) ? journal->jrn_server : "", + 0); +} diff --git a/gcc/testsuite/g++.dg/other/pr33558-2.C b/gcc/testsuite/g++.dg/other/pr33558-2.C new file mode 100644 index 000000000..a8df840b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr33558-2.C @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-fpermissive" } */ + +class X { + mutable int &q; /* { dg-warning "cannot be declared 'mutable'" } */ +}; diff --git a/gcc/testsuite/g++.dg/other/pr33558.C b/gcc/testsuite/g++.dg/other/pr33558.C new file mode 100644 index 000000000..1a340af59 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr33558.C @@ -0,0 +1,5 @@ +/* { dg-do compile } */ + +class X { + mutable int &q; /* { dg-error "cannot be declared 'mutable'" } */ +}; diff --git a/gcc/testsuite/g++.dg/other/pr33601.C b/gcc/testsuite/g++.dg/other/pr33601.C new file mode 100644 index 000000000..0c170092a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr33601.C @@ -0,0 +1,8 @@ +struct A +{ + int membervar; +}; + +typedef const A type; + +int type::* getmemberptr() { return &type::membervar; } diff --git a/gcc/testsuite/g++.dg/other/pr34435.C b/gcc/testsuite/g++.dg/other/pr34435.C new file mode 100644 index 000000000..107ff6a08 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr34435.C @@ -0,0 +1,20 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-msse2 -Wno-abi" } */ +/* { dg-require-effective-target sse2 } */ + +#include <emmintrin.h> + +class Vec { + __m128i vec; +public: + Vec(int mm) { + vec = _mm_set1_epi16(mm); + } + operator __m128i() const { + return vec; + } +}; + +int main() { + _mm_shuffle_epi32(Vec(5), _MM_SHUFFLE(3,3,3,3)); +} diff --git a/gcc/testsuite/g++.dg/other/pr35011.C b/gcc/testsuite/g++.dg/other/pr35011.C new file mode 100644 index 000000000..ca75516d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr35011.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-O3 -fcheck-data-deps" } + +double foo(const double* p0, const double* p1, const double* q0) +{ + double d; + for (; p0 != p1; ++p0, ++q0) + d += *p0 * *q0; + return d; +} + +struct A +{ + double x[3]; + const double* begin() const { return x; } +}; + +struct B +{ + A a0, a1; + double d; + B(const A&); +}; + +B::B(const A& a) : a0(a), a1(a), d(foo(a0.begin(), a0.begin()+3, a1.begin())) +{} diff --git a/gcc/testsuite/g++.dg/other/pr35504.C b/gcc/testsuite/g++.dg/other/pr35504.C new file mode 100644 index 000000000..58422f24a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr35504.C @@ -0,0 +1,159 @@ +// { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } + +#define ATTR0 __attribute__((__regparm__(0))) +#define ATTR1 __attribute__((__regparm__(1))) +#define ATTR2 __attribute__((__regparm__(2))) +#define ATTR3 __attribute__((__regparm__(3))) +#define ATTR4 __attribute__((__fastcall__)) +#define ATTR5 __attribute__((__stdcall__)) +#define ATTR6 __attribute__((__cdecl__)) +#define ATTR7 +#define ATTR8 __attribute__((__thiscall__)) + +extern "C" void abort (void); + +struct long_struct +{ + int a[3]; +}; + +struct long_struct ret; + +class c3 *this3; + +class c1 +{ + int val1; +public: + virtual void foo () { } +}; + +class c2 +{ +public: + virtual ATTR0 struct long_struct method0 () + { + return ret; + } + + virtual ATTR1 struct long_struct method1 () + { + return ret; + } + + virtual ATTR2 struct long_struct method2 () + { + return ret; + } + + virtual ATTR3 struct long_struct method3 () + { + return ret; + } + + virtual ATTR4 struct long_struct method4 () + { + return ret; + } + + virtual ATTR5 struct long_struct method5 () + { + return ret; + } + + virtual ATTR6 struct long_struct method6 () + { + return ret; + } + + virtual ATTR7 struct long_struct method7 () + { + return ret; + } + + virtual ATTR8 struct long_struct method8 () + { + return ret; + } +}; + +class c3:c1, public c2 +{ +public: + c3 () + { + this3 = this; + } + + struct long_struct check_this (int a) + { + if (this3 != this) + abort (); + + return ret; + } + + virtual ATTR0 struct long_struct method0 () + { + return check_this (0); + } + + virtual ATTR1 struct long_struct method1 () + { + return check_this (1); + } + + virtual ATTR2 struct long_struct method2 () + { + return check_this (2); + } + + virtual ATTR3 struct long_struct method3 () + { + return check_this (3); + } + + virtual ATTR4 struct long_struct method4 () + { + return check_this (4); + } + + virtual ATTR5 struct long_struct method5 () + { + return check_this (5); + } + + virtual ATTR6 struct long_struct method6 () + { + return check_this (6); + } + + virtual ATTR7 struct long_struct method7 () + { + return check_this (7); + } + + virtual ATTR8 struct long_struct method8 () + { + return check_this (7); + } +}; + +class c3 c3_instance; +class c2 *c2_ptr = &c3_instance; + +int +main () +{ + c2_ptr->method0 (); + c2_ptr->method1 (); + c2_ptr->method2 (); + c2_ptr->method3 (); + c2_ptr->method4 (); + c2_ptr->method5 (); + c2_ptr->method6 (); + c2_ptr->method7 (); + c2_ptr->method8 (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/pr36944.C b/gcc/testsuite/g++.dg/other/pr36944.C new file mode 100644 index 000000000..b4a1dfa46 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr36944.C @@ -0,0 +1,26 @@ +/* { dg-do compile } */ + +class XObject +{ +public: + int foo; +}; + +class XObjectPtr +{ +public: + explicit + XObjectPtr(XObject* theXObject = 0) : m_xobjectPtr(theXObject) + { + } + +private: + XObject * m_xobjectPtr; +}; + +class SelectionEvent +{ +public: + SelectionEvent(bool selection) : m_selection() {} + const XObjectPtr m_selection; +}; diff --git a/gcc/testsuite/g++.dg/other/pr37394.C b/gcc/testsuite/g++.dg/other/pr37394.C new file mode 100644 index 000000000..7b5772e8e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr37394.C @@ -0,0 +1,12 @@ +// Origin: Martin Michlmayr <tbm@cyrius.com> +// { dg-do compile { target ia64-*-* } } +// { dg-options "-O -fschedule-insns2" } + +struct _Words +{ + void *_M_pword; + _Words (): + _M_pword (0) + { + } +} _M_word_zero; diff --git a/gcc/testsuite/g++.dg/other/pr37789.C b/gcc/testsuite/g++.dg/other/pr37789.C new file mode 100644 index 000000000..728c2fcc6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr37789.C @@ -0,0 +1,7 @@ +// PR c++/37789 +// { dg-do compile } + +void foo(): +{ // { dg-error "initializers|identifier" } + __FUNCTION__; +} diff --git a/gcc/testsuite/g++.dg/other/pr38706.C b/gcc/testsuite/g++.dg/other/pr38706.C new file mode 100644 index 000000000..ec10d90ba --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr38706.C @@ -0,0 +1,19 @@ +// PR target/38706 +// { dg-do compile } +// { dg-options "-O2" } + +class ios_base +{ +public: + virtual ~ios_base (); + +}; + +class istrstream:virtual public ios_base +{ +public: + virtual ~istrstream (); + +}; + +istrstream::~istrstream () {} diff --git a/gcc/testsuite/g++.dg/other/pr39060.C b/gcc/testsuite/g++.dg/other/pr39060.C new file mode 100644 index 000000000..a625aea10 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr39060.C @@ -0,0 +1,19 @@ +// PR c++/39060 +// { dg-do compile } + +struct A +{ + A(void* i=); // { dg-error "with|specification" } + A(void* i=); // { dg-error "overloaded" } + A(void* i=); // { dg-error "overloaded" } + + void operator+ (void* i=); // { dg-error "arguments" } + + virtual void foo1(=); // { dg-error "identifier" } + void foo2(=); // { dg-error "identifier" } + void foo3(=); // { dg-error "identifier" } + void foo4(=); // { dg-error "identifier" } + void foo5(=); // { dg-error "identifier" } +}; // { dg-error "primary-expression" } + +A::A (void* i=) {} // { dg-error "primary-expression|argument" } diff --git a/gcc/testsuite/g++.dg/other/pr39496.C b/gcc/testsuite/g++.dg/other/pr39496.C new file mode 100644 index 000000000..3791434e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr39496.C @@ -0,0 +1,36 @@ +// PR target/39496 +// { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } +// { dg-options "-O0 -fverbose-asm -fno-omit-frame-pointer -mtune=i686 -msse2 -mfpmath=sse" } +// { dg-require-effective-target sse2 } +// Verify that {foo,bar}{,2}param are all passed on the stack, using +// normal calling conventions, when not optimizing. +// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*fooparam," } } +// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*barparam," } } +// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*foo2param," } } +// { dg-final { scan-assembler "\[^0-9-\]8\\(%ebp\\),\[^\n\]*bar2param," } } + +static inline int foo (int fooparam) +{ + return fooparam; +} + +static int bar (int barparam) +{ + return foo (barparam); +} + +static inline double foo2 (double foo2param) +{ + return foo2param; +} + +static double bar2 (double bar2param) +{ + return foo2 (bar2param); +} + +int +main () +{ + return bar (0) + bar2 (0.0); +} diff --git a/gcc/testsuite/g++.dg/other/pr40446.C b/gcc/testsuite/g++.dg/other/pr40446.C new file mode 100644 index 000000000..72cd19606 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr40446.C @@ -0,0 +1,38 @@ +// PR middle-end/40446 +// { dg-do run { target i?86-*-* x86_64-*-* } } +// { dg-options "-O1 -msse2" } +// { dg-require-effective-target sse2_runtime } + +#include <emmintrin.h> + +extern "C" void abort (); + +struct S +{ + S (double r, double i) { __real__ s = r; __imag__ s = i; } + __complex__ double s; +}; + +__m128d +foo () +{ + S c (0, 1); + return _mm_load_pd ((double *) &c); +} + +static void +__attribute__((noinline)) +sse2_test () +{ + union { __m128d vec; double val[2]; } u; + u.vec = foo (); + if (u.val[0] != 0 || u.val[1] != 1) + abort (); +} + +int +main () +{ + sse2_test (); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/pr40561.C b/gcc/testsuite/g++.dg/other/pr40561.C new file mode 100644 index 000000000..c94dfa4bd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr40561.C @@ -0,0 +1,38 @@ +// { dg-do compile } + +#include <set> + +class SyAccess; +class VamsBase +{ + public: + virtual ~VamsBase(void); +}; + +class VamsFnct : public VamsBase +{ + public: + ~VamsFnct(void); + std::set<SyAccess*> getNullDependencies(void) const + { return std::set<SyAccess*>(); + } +}; + +class VamsFnctSystem:public VamsFnct +{ public: + VamsFnctSystem( + const bool _bPassDependencies); +}; + +template< std::set<SyAccess*> (VamsFnct::*__GET_DEP__)(void) const > +class VamsSystemFunction:public VamsFnctSystem +{ public: + VamsSystemFunction() + :VamsFnctSystem( + __GET_DEP__ != &VamsFnct::getNullDependencies + ) + { + } +}; + +VamsSystemFunction<&VamsFnct::getNullDependencies> s; diff --git a/gcc/testsuite/g++.dg/other/pr42645-1.C b/gcc/testsuite/g++.dg/other/pr42645-1.C new file mode 100644 index 000000000..5dc76f9ef --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr42645-1.C @@ -0,0 +1,26 @@ +// PR tree-optimization/42645 +// { dg-do compile } +// { dg-options "-fcompare-debug -O1" } + +extern void foo (); + +struct S +{ + struct T + { + int t1; + char t2[4]; + T *t3; + } t; + int m1 () const { return t.t3[0].t1; } + char *m2 () { foo (); } + void m3 (int x) { char *m = m2 (); if (m1 () > 0 && x > 0); } + void m4 () { if (m1 () > 0) for (int i = 0; i < 4; i++) t.t2[i] = 0; } +}; + +void +f (S *a) +{ + a->m3 (0); + a->m4 (); +} diff --git a/gcc/testsuite/g++.dg/other/pr42645-2.C b/gcc/testsuite/g++.dg/other/pr42645-2.C new file mode 100644 index 000000000..67632e51d --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr42645-2.C @@ -0,0 +1,34 @@ +// PR tree-optimization/42645 +// { dg-do compile } +// { dg-options "-fcompare-debug -O1" } + +struct C +{ + bool b; + C (); +}; + +static inline C *foo () {} + +extern void f4 (); + +static inline int +f3 () +{ + f4 (); +} + +static inline void +f2 (bool b) +{ + int tmp = f3 (); + if (C ().b && b) + C (); +} + +void +f1 () +{ + C *c = foo (); + f2 (c->b); +} diff --git a/gcc/testsuite/g++.dg/other/pr42685.C b/gcc/testsuite/g++.dg/other/pr42685.C new file mode 100644 index 000000000..b8b1ad63b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr42685.C @@ -0,0 +1,10 @@ +// { dg-do compile } +// { dg-options "-O -funroll-loops -fcompare-debug" } + +void Remap(int n, int *src, int *dst, int *map) +{ + do { + int i = *src; + if (i != 0) *dst = map[i]; + } while (--n != 0); +} diff --git a/gcc/testsuite/g++.dg/other/pr42806.C b/gcc/testsuite/g++.dg/other/pr42806.C new file mode 100644 index 000000000..9823238d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr42806.C @@ -0,0 +1,22 @@ +// { dg-do compile } +// { dg-options "-O -fcompare-debug" } + +struct S1 { + ~S1() { } +}; + +struct S2 { + S1 s1; + void m(); + ~S2() { m(); } +}; + +struct S3 { + S3(int, S2); +}; + +void foo() +{ + S3(0, S2()); +} + diff --git a/gcc/testsuite/g++.dg/other/pr43116.C b/gcc/testsuite/g++.dg/other/pr43116.C new file mode 100644 index 000000000..f0d9d01e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr43116.C @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +extern "C" int rpl_open (const char *filename, int flags, ...) __attribute__ +((__nonnull__ (1))); + +namespace gnulib +{ + int (*const open) (const char *filename, int flags, ...) __attribute__ + ((__nonnull__ (1))) = rpl_open; +} diff --git a/gcc/testsuite/g++.dg/other/pr47218-1.C b/gcc/testsuite/g++.dg/other/pr47218-1.C new file mode 100644 index 000000000..aeb070b0c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218-1.C @@ -0,0 +1,10 @@ +#include "pr47218.h" + +Foo2::~Foo2 () +{ + ((FooBaseBase1*)this)->Bar(); +} + +void Foo2::Bar() +{ +} diff --git a/gcc/testsuite/g++.dg/other/pr47218.C b/gcc/testsuite/g++.dg/other/pr47218.C new file mode 100644 index 000000000..f94e15742 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218.C @@ -0,0 +1,21 @@ +/* { dg-do link } */ +/* { dg-options "-save-temps" } */ +/* { dg-additional-sources "pr47218-1.C" } */ + +#include "pr47218.h" + +Foo3::~Foo3 () +{ + ((FooBaseBase1*)this)->Bar(); +} + +void Foo3::Bar() +{ +} + +int main () +{ + return 0; +} + +// { dg-final cleanup-saved-temps } diff --git a/gcc/testsuite/g++.dg/other/pr47218.h b/gcc/testsuite/g++.dg/other/pr47218.h new file mode 100644 index 000000000..1b07da746 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr47218.h @@ -0,0 +1,33 @@ + +class FooBaseBase0 +{ +public: + virtual ~FooBaseBase0 () {} +}; + +class FooBaseBase1 +{ +public: + virtual void Bar() {} +}; + + +class FooBase: public FooBaseBase0, public FooBaseBase1 +{ +public: + virtual void Bar() {} +}; + +class Foo2: public FooBase +{ +public: + ~Foo2 (); + virtual void Bar(); +}; + +class Foo3: public FooBase +{ +public: + ~Foo3 (); + virtual void Bar(); +}; diff --git a/gcc/testsuite/g++.dg/other/pr49133.C b/gcc/testsuite/g++.dg/other/pr49133.C new file mode 100644 index 000000000..a59687f9c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr49133.C @@ -0,0 +1,36 @@ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -msse2" } */ +/* { dg-require-effective-target sse2_runtime } */ + +#include <xmmintrin.h> + +extern "C" void abort (); + +typedef double double_a __attribute__((__may_alias__)); + +struct V +{ + __m128d data; +}; + +int +main() +{ + V a; + __m128d b; + + b = _mm_set_pd (1., 0.); + a.data = _mm_set_pd (1., 0.); + a.data = _mm_add_pd (a.data, + _mm_and_pd (_mm_cmpeq_pd (a.data, _mm_set1_pd (0.)), + _mm_set1_pd (2.))); + reinterpret_cast<double_a *>(&a.data)[1] += 1.; + b = _mm_add_pd (b, _mm_and_pd (_mm_cmpeq_pd (b, _mm_set1_pd (0.)), + _mm_set1_pd (1.))); + b = _mm_add_pd (b, _mm_and_pd (_mm_cmpeq_pd (b, _mm_set1_pd (1.)), + _mm_set1_pd (1.))); + if (_mm_movemask_pd (_mm_cmpeq_pd (a.data, b)) != 0x3) + abort(); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/pr50464.C b/gcc/testsuite/g++.dg/other/pr50464.C new file mode 100644 index 000000000..8c6721373 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr50464.C @@ -0,0 +1,170 @@ +// { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-options "-O3 -mxop" } + +typedef long unsigned int size_t; +typedef unsigned long ulong_t; +typedef signed long slong_t; + + template<typename _Iterator> + struct iterator_traits + { + typedef typename _Iterator::reference reference; + }; + + template<typename _Tp> + struct iterator_traits<_Tp*> + { + typedef _Tp& reference; + }; + + template<typename _Iterator, typename _Container> + class __normal_iterator + { + protected: + _Iterator _M_current; + typedef iterator_traits<_Iterator> __traits_type; + + public: + typedef typename __traits_type::reference reference; + + explicit + __normal_iterator(const _Iterator& __i) : _M_current(__i) { } + + reference + operator*() const + { return *_M_current; } + + __normal_iterator& + operator++() + { + ++_M_current; + return *this; + } + + const _Iterator& + base() const + { return _M_current; } + }; + + template<typename _Iterator, typename _Container> + inline bool + operator!=(const __normal_iterator<_Iterator, _Container>& __lhs, + const __normal_iterator<_Iterator, _Container>& __rhs) + { return __lhs.base() != __rhs.base(); } + + template<typename _Tp> + class allocator + { + public: + typedef _Tp* pointer; + typedef _Tp value_type; + + template<typename _Tp1> + struct rebind + { typedef allocator<_Tp1> other; }; + + pointer allocate(size_t __n, const void* = 0) + { + return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); + } + }; + + template<typename _Tp, typename _Alloc> + struct _Vector_base + { + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + + struct _Vector_impl + : public _Tp_alloc_type + { + typename _Tp_alloc_type::pointer _M_start; + typename _Tp_alloc_type::pointer _M_finish; + typename _Tp_alloc_type::pointer _M_end_of_storage; + + _Vector_impl(_Tp_alloc_type const& __a) { } + }; + + public: + typedef _Alloc allocator_type; + + _Vector_base(size_t __n, const allocator_type& __a) + : _M_impl(__a) + { + this->_M_impl._M_start = this->_M_allocate(__n); + this->_M_impl._M_finish = this->_M_impl._M_start; + this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n; + } + + public: + _Vector_impl _M_impl; + + typename _Tp_alloc_type::pointer + _M_allocate(size_t __n) + { return __n != 0 ? _M_impl.allocate(__n) : 0; } + + }; + + template<typename _Tp, typename _Alloc = allocator<_Tp> > + class vector : protected _Vector_base<_Tp, _Alloc> + { + typedef _Vector_base<_Tp, _Alloc> _Base; + typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; + + public: + typedef _Tp value_type; + typedef typename _Tp_alloc_type::pointer pointer; + typedef __normal_iterator<pointer, vector> iterator; + typedef _Alloc allocator_type; + + protected: + using _Base::_M_allocate; + using _Base::_M_impl; + + public: + + explicit + vector(size_t __n, const value_type& __value = value_type(), + const allocator_type& __a = allocator_type()) + : _Base(__n, __a) + { _M_fill_initialize(__n, __value); } + + iterator begin() + { return iterator(this->_M_impl._M_start); } + + iterator end() + { return iterator(this->_M_impl._M_finish); } + + protected: + void + _M_fill_initialize(size_t __n, const value_type& __value) + { + this->_M_impl._M_finish = this->_M_impl._M_end_of_storage; + } + }; + + template<typename _InputIterator, typename _OutputIterator, typename _Tp> + _OutputIterator + replace_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, + const _Tp& __old_value, const _Tp& __new_value) + { + ; + for (; __first != __last; ++__first, ++__result) + if (*__first == __old_value) + *__result = __new_value; + else + *__result = *__first; + return __result; + } + +extern size_t shape_rank; + +void createDataspaceIdentifier() +{ + vector< ulong_t > dataspaceDims( shape_rank ); + vector< ulong_t > maxDataspaceDims( shape_rank ); + + replace_copy( + dataspaceDims.begin(), dataspaceDims.end(), + maxDataspaceDims.begin(), ulong_t( 0 ), ((ulong_t)(slong_t)(-1)) ); +} diff --git a/gcc/testsuite/g++.dg/other/pragma-ep-1.C b/gcc/testsuite/g++.dg/other/pragma-ep-1.C new file mode 100644 index 000000000..9362943a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pragma-ep-1.C @@ -0,0 +1,27 @@ +/* { dg-do compile { target *-*-osf5* } } */ +/* { dg-final { scan-assembler "xyzzy_one" } } */ +/* { dg-final { scan-assembler "xyzzy_two" } } */ +/* { dg-final { scan-assembler "xyzzz_three" } } */ +/* { dg-final { scan-assembler "four" } } */ +/* { dg-final { scan-assembler-not "_four" } } */ + +#ifndef __PRAGMA_EXTERN_PREFIX +#error +#endif + +#pragma extern_prefix "xyzzy_" + +extern "C" int one(void); +extern "C" int two(void); + +#pragma extern_prefix "xyzzz_" + +extern "C" int three(void); + +#pragma extern_prefix "" + +extern "C" int four(void); + +int (*p[])(void) = { + one, two, three, four +}; diff --git a/gcc/testsuite/g++.dg/other/pragma-re-1.C b/gcc/testsuite/g++.dg/other/pragma-re-1.C new file mode 100644 index 000000000..35ffab1a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pragma-re-1.C @@ -0,0 +1,19 @@ +/* { dg-final { scan-assembler "bar" } } */ +/* { dg-final { scan-assembler-not "foo" } } */ +/* { dg-final { scan-assembler "_Z3bazv" } } */ +/* { dg-final { scan-assembler-not "baq" } } */ + +#ifndef __PRAGMA_REDEFINE_EXTNAME +#error +#endif + +/* This one is expected to work. */ +#pragma redefine_extname foo bar +extern "C" int foo(void); +int (*p)(void) = foo; + +/* This one is expected not to work (redefine_extname + can only be applied to extern "C" names). */ +#pragma redefine_extname baz baq +extern int baz(void); +int (*q)(void) = baz; diff --git a/gcc/testsuite/g++.dg/other/pragma-re-2.C b/gcc/testsuite/g++.dg/other/pragma-re-2.C new file mode 100644 index 000000000..ca71a01a2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pragma-re-2.C @@ -0,0 +1,24 @@ +/* PR c++/14962 */ +/* Originator: <phil@fsel.com> */ + +/* { dg-final { scan-assembler "new_name" } } */ +/* { dg-final { scan-assembler-not "old_name" } } */ + +#ifndef __PRAGMA_REDEFINE_EXTNAME +#error +#endif + +extern "C" { + +struct old_name { int i; }; + +#pragma redefine_extname old_name new_name + +int old_name(void); + +} + +int foo(void) +{ + return old_name(); +} diff --git a/gcc/testsuite/g++.dg/other/profile1.C b/gcc/testsuite/g++.dg/other/profile1.C new file mode 100644 index 000000000..a4bf6b3d0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/profile1.C @@ -0,0 +1,54 @@ +// PR 11767 +// { dg-do run } +// { dg-require-profiling "" } +// { dg-options "-fnon-call-exceptions -fprofile-arcs" } + +#include <string> + +typedef unsigned long ACE_UINT32; +extern "C" void abort(); + +static ACE_UINT32 const msc_maxCurrencyID = 9999; + +class ResourceBalanceType2 +{ + public: + explicit ResourceBalanceType2( + ACE_UINT32 resourceBalanceTypeID, + ACE_UINT32 isoValue, + const std::string& rc_shortName, + const std::string& rc_symbol + ); + public: + const ACE_UINT32 mc_resBalTypeID; + const ACE_UINT32 mc_isoValue; + const std::string mc_shortName; + const std::string mc_symbol; +}; + +void f(){} + +ResourceBalanceType2::ResourceBalanceType2( + ACE_UINT32 resourceBalanceTypeID, + ACE_UINT32 isoValue, + const std::string& rc_shortName, + const std::string& rc_symbol) + : mc_resBalTypeID(resourceBalanceTypeID), + mc_isoValue(isoValue), + mc_shortName(rc_shortName), + mc_symbol(rc_symbol) +{ + bool isGreater = (mc_isoValue > msc_maxCurrencyID); + f(); + bool temp = mc_isoValue > msc_maxCurrencyID; + if (!isGreater) abort(); + if (!temp) abort(); +} + +int main (int argc, char * argv[]) +{ + ACE_UINT32 const mc_isoValue = 10000; + ResourceBalanceType2 rbResourceBalanceType2(3, mc_isoValue, "ATM", "M"); +} + +// { dg-final { cleanup-coverage-files } } diff --git a/gcc/testsuite/g++.dg/other/ptrmem1.C b/gcc/testsuite/g++.dg/other/ptrmem1.C new file mode 100644 index 000000000..fa9115e50 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem1.C @@ -0,0 +1,66 @@ +// { dg-do run } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 31 Dec 2001 <nathan@codesourcery.com> + +// PR 4379. We created pointers to member references and pointers to +// member fields when we shouldn't have. + +int gs; +int gm; + +struct D { + D () :m (gm) {} + + int &m; + static int &s; + + int Foo (); +}; + +int &D::s = gs; + +template<class T> int f1(T x) +{ + return x != &gm; +} +template<class T> int f2(T x) +{ + return x != &gs; +} + +int D::Foo () +{ + int r; + + if (f1( &(D::m))) + return 3; + + if (f2( &D::s)) + return 1; + if (f2( &(D::s))) + return 2; + return 0; +} + +int Foo () +{ + if (f2( &D::s)) + return 4; + if (f2( &(D::s))) + return 5; + return 0; +} + +int main () +{ + D d; + int r = d.Foo (); + if (r) + return r; + r = Foo (); + if (r) + return r; + return 0; + +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem10.C b/gcc/testsuite/g++.dg/other/ptrmem10.C new file mode 100644 index 000000000..bc386ed56 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem10.C @@ -0,0 +1,30 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin PR c++/37093 + +template <class C, void (C::*M) ()> +static +void foo(void *obj) // { dg-message "note" } +{ + C *p = static_cast<C*>(obj); + (p->*M)(); +} + +template <class C> +static void +bar(C *c, void (C::*m) ()) +{ + foo<C,m>((void *)c);// { dg-error "(not a valid template arg|pointer-to-member|no matching fun)" } + // { dg-message "candidate" "candidate note" { target *-*-* } 16 } +} + +struct S +{ + void baz () {} +}; + +int +main () +{ + S a; + bar(&a, &S::baz); +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem11.C b/gcc/testsuite/g++.dg/other/ptrmem11.C new file mode 100644 index 000000000..119cbb078 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem11.C @@ -0,0 +1,22 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin PR c++/37093 + +struct A {}; + +template <int A::* p> +int +foo(A* q) // { dg-message "note" } +{ + return q->*p; +} + +template <typename T> +int +bar(int T::* p) +{ + return foo<p>(0);// { dg-error "(not a valid template arg|no matching func|pointer-to-member)" } + // { dg-message "candidate" "candidate note" { target *-*-* } 17 } +} + +int i = bar<A>(0); + diff --git a/gcc/testsuite/g++.dg/other/ptrmem2.C b/gcc/testsuite/g++.dg/other/ptrmem2.C new file mode 100644 index 000000000..d267df15b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem2.C @@ -0,0 +1,36 @@ +// { dg-do compile } + +// Copyright (C) 2001, 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 31 Dec 2001 <nathan@codesourcery.com> + +// PR 4379. We created pointers to member references and pointers to +// member fields when we shouldn't have. + +struct D { + + int &m; // { dg-error "invalid use of non-static data member" "" } + static int &s; + + int Foo (); +}; + +template<class T> int f1(T x); +template<class T> int f2(T x); + +int D::Foo () +{ + f1( &D::m); // { dg-error "cannot create pointer to ref" "" } + f1( &(D::m)); // ok + f2( &D::s); // ok + f2( &(D::s)); // ok + return 0; +} + +int Foo () +{ + f1( &D::m); // { dg-error "cannot create pointer to ref" "" } + f1( &(D::m)); // { dg-error "from this location" "" } + f2( &D::s); // ok + f2( &(D::s)); // ok + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem3.C b/gcc/testsuite/g++.dg/other/ptrmem3.C new file mode 100644 index 000000000..ed6d87574 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem3.C @@ -0,0 +1,14 @@ +// Bug: The double cast had an TREE_INT_CST_HIGH of 0, while the single +// cast had -1, so the comparison failed. + +// { dg-do run } + +struct A { }; + +typedef int A::* aip; +typedef long A::* alp; + +int main() +{ + return ((aip)(alp)0 != (aip)0); +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem4.C b/gcc/testsuite/g++.dg/other/ptrmem4.C new file mode 100644 index 000000000..4f3f541e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem4.C @@ -0,0 +1,18 @@ +// Bug: This checks that the pointer-to-member-function type is not +// shared between differently-qualified pointer-to-method types. + +// { dg-do compile } +struct A +{ + void f () {} +}; + +void (A::*const cp)() = &A::f; + +int main () +{ + void (A::* p)(); + void (A::** ip)() = &p; + + *ip = &A::f; +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem5.C b/gcc/testsuite/g++.dg/other/ptrmem5.C new file mode 100644 index 000000000..75a78b2f1 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem5.C @@ -0,0 +1,12 @@ +// PR 14123 + +struct a +{ + int x[8]; +}; + +int main() +{ + int a::*n[8]; + n = &a::x; // { dg-error "int \\(a::\\*\\)" } +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem6.C b/gcc/testsuite/g++.dg/other/ptrmem6.C new file mode 100644 index 000000000..5fe796e1c --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem6.C @@ -0,0 +1,10 @@ +// PR c++/19666 +// Origin: Volker Reichelt <reichelt@gcc.gnu.org> +// { dg-do compile } + +struct A { int i; }; + +int foo (A *p) +{ + return &p->i - &(p->*&A::i); +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem7.C b/gcc/testsuite/g++.dg/other/ptrmem7.C new file mode 100644 index 000000000..e7722b8de --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem7.C @@ -0,0 +1,4 @@ +// PR c++/27447 +// { dg-do compile } + +void (A::* p)(); // { dg-error "declared|token" } diff --git a/gcc/testsuite/g++.dg/other/ptrmem8.C b/gcc/testsuite/g++.dg/other/ptrmem8.C new file mode 100644 index 000000000..d0b0ba722 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem8.C @@ -0,0 +1,16 @@ +// PR c++/33844 +// { dg-do compile } + +struct A {}; + +template<int> void foo(void (A::* f)()) +{ + A a; + &(a.*f); // { dg-error "invalid use of\[^\n\]*\\.\\*\[^\n\]*to form|qualified-id is required" } +} + +template<int> void bar(void (A::* f)()) +{ + A *p; + &(p->*f); // { dg-error "invalid use of\[^\n\]*->\\*\[^\n\]*to form|qualified-id is required" } +} diff --git a/gcc/testsuite/g++.dg/other/ptrmem9.C b/gcc/testsuite/g++.dg/other/ptrmem9.C new file mode 100644 index 000000000..c4d3656a0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ptrmem9.C @@ -0,0 +1,5 @@ +// PR c++/33969 +// { dg-do compile } + +struct A; +void (*A::* fp)() const; // { dg-error "invalid in variable declaration" } diff --git a/gcc/testsuite/g++.dg/other/qual1.C b/gcc/testsuite/g++.dg/other/qual1.C new file mode 100644 index 000000000..e4bae2315 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/qual1.C @@ -0,0 +1,11 @@ +// PR c++/28257 +// { dg-do compile } + +struct A +{ + int i; + void foo() + { + int A::i = i; // { dg-error "qualified" } + } +}; diff --git a/gcc/testsuite/g++.dg/other/redecl1.C b/gcc/testsuite/g++.dg/other/redecl1.C new file mode 100644 index 000000000..cfcf66826 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/redecl1.C @@ -0,0 +1,10 @@ +// PR c++/5857 +// This testcase failed because during duplicate_decls the type was promoted +// to int. + +// { dg-do compile } + +typedef char baz; +extern const char foo[]; +const baz foo[] = "xyz"; +const char bar[] = "abc"; diff --git a/gcc/testsuite/g++.dg/other/redecl2.C b/gcc/testsuite/g++.dg/other/redecl2.C new file mode 100644 index 000000000..591c258b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/redecl2.C @@ -0,0 +1,11 @@ +// PR c++/17816 +// We failed to report duplicate definitions of pure virtual ns. + +// { dg-do compile } + +struct S { + virtual int foo() = 0; +}; + +int S::foo() { return 0; } // { dg-error "defined here" } +int S::foo() { return 0; } // { dg-error "redefinition" } diff --git a/gcc/testsuite/g++.dg/other/return1.C b/gcc/testsuite/g++.dg/other/return1.C new file mode 100644 index 000000000..2473b8deb --- /dev/null +++ b/gcc/testsuite/g++.dg/other/return1.C @@ -0,0 +1,15 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Oct 2005 <nathan@codesourcery.com> + +// PR 21117:ICE after error +// Origin: Andrew Pinski <pinskia@gcc.gnu.org> + +struct wxString; +struct wxString* wxGetEmptyString(); + +struct wxString GetHeader() // { dg-error "return type" "" } +{ + return *wxGetEmptyString(); +} + + diff --git a/gcc/testsuite/g++.dg/other/s390-1.C b/gcc/testsuite/g++.dg/other/s390-1.C new file mode 100644 index 000000000..bf37ca449 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/s390-1.C @@ -0,0 +1,32 @@ +// { dg-do compile { target s390x-*-* } } +// { dg-options "-O3 -fPIC" } + +class A +{ +public: + void f (void) { _M_a = 0; } + void g (void) { _M_a = 1; } + void h (void); + +private: + int _M_a; +}; + +class B : virtual public A +{ +}; + +void +test (B& x) +{ + for (int i = 0; i < 17; i++) + { + x.f (); + (x.*&A::g) (); + x.h (); + } +} + +// Check that every call to A::g goes via the PLT. +// { dg-final { scan-assembler-not "brasl\[^@\]*\n" } } + diff --git a/gcc/testsuite/g++.dg/other/scope1.C b/gcc/testsuite/g++.dg/other/scope1.C new file mode 100644 index 000000000..73b141bdf --- /dev/null +++ b/gcc/testsuite/g++.dg/other/scope1.C @@ -0,0 +1,14 @@ +// { dg-do compile } + +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 30 Nov 2001 <nathan@nathan@codesourcery.com> + +// PR 3381 + +namespace N { + template<class T> + class A { }; +} + +template class N::A<unsigned>; // this works (by itself) +template class ::N::A<int>; // but this doesn't diff --git a/gcc/testsuite/g++.dg/other/semicolon.C b/gcc/testsuite/g++.dg/other/semicolon.C new file mode 100644 index 000000000..8797bd32f --- /dev/null +++ b/gcc/testsuite/g++.dg/other/semicolon.C @@ -0,0 +1,10 @@ +// PR c++/18368 +// Origin: Chris Lattner <sabre@nondot.org> +// { dg-do compile } +// { dg-options "-fshow-column" } + +struct A +{ + struct B { int i; } // { dg-error "after struct definition" } + void foo(); +}; diff --git a/gcc/testsuite/g++.dg/other/spu2vmx-1.C b/gcc/testsuite/g++.dg/other/spu2vmx-1.C new file mode 100644 index 000000000..d9c8faf94 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/spu2vmx-1.C @@ -0,0 +1,15 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-require-effective-target powerpc_spu } */ +/* { dg-options "-maltivec" } */ + +#include <altivec.h> +#include <spu2vmx.h> + +vec_uint4 f(vec_uint4 a, vec_uint4 b) +{ + return spu_add(a, b); +} +vec_float4 f(vec_float4 a, vec_float4 b) +{ + return spu_add(a, b); +} diff --git a/gcc/testsuite/g++.dg/other/static1.C b/gcc/testsuite/g++.dg/other/static1.C new file mode 100644 index 000000000..5cf0b9256 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static1.C @@ -0,0 +1,17 @@ +// PR c++/9574 +// Origin: fche@redhat.com and bangerth@dealii.org +// The new parser ICE on this test and then it could +// not find z in bar::bar(). + +// { dg-do compile } + +struct X { + void operator[](const int& __k); +}; +struct foo { + static X x; +}; +struct bar { + int z; + bar () { foo::x[z]; } +}; diff --git a/gcc/testsuite/g++.dg/other/static11.C b/gcc/testsuite/g++.dg/other/static11.C new file mode 100644 index 000000000..e04cbc154 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static11.C @@ -0,0 +1,34 @@ +// This is a copy of g++.old-deja/g++.pt/static11.C which at one +// time got a SEGV for mmix-knuth-mmixware when compiled with +// -da (or either -dj or -df). +// { dg-do compile } +// { dg-options "-da" } + +extern "C" void _exit (int); + +int r = 1; + +struct A +{ + void f(){}; + A(){ ++r; } + ~A(){ r -= 2; _exit (r); } +}; + +template<class T> +struct C +{ + C(){ a.f(); } + static A a; +}; + +template <class T> A C<T>::a; +typedef C<int> B; + +int main() +{ + C<int> c; + return r; +} + +// { dg-final { cleanup-rtl-dump "*" } } diff --git a/gcc/testsuite/g++.dg/other/static2.C b/gcc/testsuite/g++.dg/other/static2.C new file mode 100644 index 000000000..ff1478c2a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/static2.C @@ -0,0 +1,12 @@ +//PR c++/26573 + +void foo() +{ + struct A { static int i; }; // { dg-error "shall not have" } +} + +template<typename T> +void bar() +{ + struct B { static int j; }; // { dg-error "shall not have" } +} diff --git a/gcc/testsuite/g++.dg/other/stdarg1.C b/gcc/testsuite/g++.dg/other/stdarg1.C new file mode 100644 index 000000000..1ac9e8fb2 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/stdarg1.C @@ -0,0 +1,27 @@ +// Test stdarg function with anonymous argument +// { dg-do run } +// { dg-options "-Wno-abi" { target arm_eabi } } + +#include <stdarg.h> + +extern "C" void abort (void); + +void baz (va_list list) +{ + if (va_arg (list, long) != 3) + abort (); +} + +void foo (long p1, long, long p2, ...) +{ + va_list list; + va_start (list, p2); + baz (list); + va_end (list); +} + +int main () +{ + foo (0, 1, 2, (long)3); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/stdarg2.C b/gcc/testsuite/g++.dg/other/stdarg2.C new file mode 100644 index 000000000..99e904013 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/stdarg2.C @@ -0,0 +1,12 @@ +// PR c++/11929 +// Bug: We were complaining about the call to va_start because o is of +// non-POD type. + +struct s { + s(int); +}; + +void test(s o, ...) { + __builtin_va_list varg; + __builtin_va_start(varg, o); +} diff --git a/gcc/testsuite/g++.dg/other/stdarg3.C b/gcc/testsuite/g++.dg/other/stdarg3.C new file mode 100644 index 000000000..0e7abd8dd --- /dev/null +++ b/gcc/testsuite/g++.dg/other/stdarg3.C @@ -0,0 +1,16 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Mar 2005 <nathan@codesourcery.com> + +// PR 20375: ICE +// Origin: Joseph S. Myers <jsm28@gcc.gnu.org> +// { dg-options "-mlp64" { target "ia64-*-hpux*" } } + +union U +{ + void *m[7]; +}; + +struct C; + +void f(struct C *c, float f, union U, ...) +{ } diff --git a/gcc/testsuite/g++.dg/other/struct-va_list.C b/gcc/testsuite/g++.dg/other/struct-va_list.C new file mode 100644 index 000000000..769b909ff --- /dev/null +++ b/gcc/testsuite/g++.dg/other/struct-va_list.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// PR target/13302 + +#include <stdarg.h> + +struct NumArgState{ + va_list ap; +}; diff --git a/gcc/testsuite/g++.dg/other/switch1.C b/gcc/testsuite/g++.dg/other/switch1.C new file mode 100644 index 000000000..a22d2b573 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/switch1.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// Contributed by: Nick Savoiu <savoiu at ics dot uci dot edu> +// PR c++/14250: Incomplete type in switch statement + +template <typename T> +struct A { + operator int(); +}; + +struct C1 { + static A<void> t1; + + void fun() + { + switch(t1) + { + default: break; + } + } +}; diff --git a/gcc/testsuite/g++.dg/other/switch2.C b/gcc/testsuite/g++.dg/other/switch2.C new file mode 100644 index 000000000..6994e2a39 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/switch2.C @@ -0,0 +1,23 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 13 Oct 2005 <nathan@codesourcery.com> + +// PR 22551:ICE +// Origin: Johnny Casey <emailwastefilter-bugzillagccorg@yahoo.com> + +const int B = ~(~0u >> 1); + +#define b(x) (B + x) + + +int Foo (int error) +{ + switch (error) + { + case b (1): return 0; + case b (2): return 0; + case b (3): return 0; + case b (4): return 0; + case b (5): return 0; + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/switch3.C b/gcc/testsuite/g++.dg/other/switch3.C new file mode 100644 index 000000000..4f9b5485e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/switch3.C @@ -0,0 +1,25 @@ +// PR c++/39371 +// { dg-do compile } + +void +foo (bool b) +{ + switch ((unsigned int) b) + { + case 1: + case 2: + break; + } +} + +void +bar (unsigned char b) +{ + switch ((unsigned int) b) + { + case 1: + case 257: + case 513: + break; + } +} diff --git a/gcc/testsuite/g++.dg/other/synth1.C b/gcc/testsuite/g++.dg/other/synth1.C new file mode 100644 index 000000000..5829c6c78 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/synth1.C @@ -0,0 +1,31 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 17 Dec 2004 <nathan@codesourcery.com> + +// PR 18975: Rejects legal +// Origin: Wolfgang Roehrl <wolfgang.roehrl@de.gi-de.com> + +struct PTR +{ + PTR (); + PTR (PTR&); + PTR& operator= (PTR&); + +private: + PTR (const PTR&); + PTR& operator= (const PTR&); +}; + + +struct XYZ +{ + XYZ (PTR& p) : ptr(p) {} + + mutable PTR ptr; +}; + + +XYZ f1 (); + + +XYZ f2 (void) { return f1(); } +void f3 (XYZ& dst, const XYZ& src) { dst = src; } diff --git a/gcc/testsuite/g++.dg/other/typedef1.C b/gcc/testsuite/g++.dg/other/typedef1.C new file mode 100644 index 000000000..ef1684d7a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/typedef1.C @@ -0,0 +1,7 @@ +// PR c++/27572 +// { dg-do compile } + +void f1(typedef) {} // { dg-error "no type|typedef declaration" } +void f2(typedef x) {} // { dg-error "type|typedef declaration" } +void f3(typedef x[]) {} // { dg-error "type|typedef declaration" } +void f4(typedef int x) {} // { dg-error "typedef declaration" } diff --git a/gcc/testsuite/g++.dg/other/typedef2.C b/gcc/testsuite/g++.dg/other/typedef2.C new file mode 100644 index 000000000..902e102d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/typedef2.C @@ -0,0 +1,3 @@ +typedef void fn() const; + +fn* fp; // { dg-error "pointer.*qualified function type" } diff --git a/gcc/testsuite/g++.dg/other/typedef3.C b/gcc/testsuite/g++.dg/other/typedef3.C new file mode 100644 index 000000000..8ead5b845 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/typedef3.C @@ -0,0 +1,12 @@ +// Contributed by Dodji Seketeli <dodji@redhat.com> +// Origin: PR c++/40357 +// { dg-do compile } + +struct XalanCProcessor +{ + typedef enum {eInvalid, eXalanSourceTree, eXercesDOM} ParseOptionType; + ParseOptionType getParseOption(void); +}; +typedef XalanCProcessor::ParseOptionType ParseOptionType; +ParseOptionType XalanCProcessor::getParseOption(void) {} + diff --git a/gcc/testsuite/g++.dg/other/typedef4.C b/gcc/testsuite/g++.dg/other/typedef4.C new file mode 100644 index 000000000..b752f2cae --- /dev/null +++ b/gcc/testsuite/g++.dg/other/typedef4.C @@ -0,0 +1,7 @@ +// { dg-options "-g" } +// { dg-do compile } + +// On some platforms like MIPS, __builtin_va_list is a +// RECORD_TYPE. Make sure we don't wrongly try to generate debug info +// for its TYPE_DECL and crash. +typedef __builtin_va_list foo; diff --git a/gcc/testsuite/g++.dg/other/ucnid-1.C b/gcc/testsuite/g++.dg/other/ucnid-1.C new file mode 100644 index 000000000..9a2728f25 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/ucnid-1.C @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-fextended-identifiers" } */ +/* { dg-xfail-if "" { powerpc-ibm-aix* } { "*" } { "" } } */ +/* { dg-skip-if "" { ! ucn } { "*" } { "" } } */ +#include <cstdlib> + +int \u00C0(void) { return 1; } +int \u00C1(void) { return 2; } +int \U000000C2(void) { return 3; } +int wh\u00ff(void) { return 4; } +int a\u00c4b\u0441\U000003b4e(void) { return 5; } + +int main (void) +{ + + if (\u00C0() != 1) + abort (); + if (\u00c1() != 2) + abort (); + if (\u00C2() != 3) + abort (); + if (wh\u00ff() != 4) + abort (); + if (a\u00c4b\u0441\U000003b4e() != 5) + abort (); + + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/unreachable1.C b/gcc/testsuite/g++.dg/other/unreachable1.C new file mode 100644 index 000000000..da468a099 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/unreachable1.C @@ -0,0 +1,11 @@ +// PR middle-end/17827 +// Origin: Andre Woebbeking <Woebbeking@web.de> +// Testcase by Volker Reichelt <reichelt@gcc.gnu.org> +// { dg-do compile } + +void foo() +{ + if (false) + if (int i=0) + int j=i; +} diff --git a/gcc/testsuite/g++.dg/other/unused1.C b/gcc/testsuite/g++.dg/other/unused1.C new file mode 100644 index 000000000..2a3ca1be7 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/unused1.C @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { { hppa*-*-hpux* *-*-solaris2.[56]* } && { ! hppa*64*-*-* } } { "*" } { "" } } */ + +/* Make sure we didn't eliminate casted types because we thought they were + unused. */ + +void *voidp; + +struct foo { int i; }; +int bar (void) +{ + return ((struct foo *)0x1234)->i; +} + +struct boo { int i; }; +int bar2 (void) +{ + return reinterpret_cast<struct boo *>(0xC0FFEE)->i; +} + +struct cue { int i; }; +int bar3 (void) +{ + return static_cast<struct cue *>(voidp)->i; +} + +class printer { public: int i; }; +const printer *dotmatrix; +int bar4 (void) +{ + return const_cast<printer *>(dotmatrix)->i; +} + +class class1 { public: virtual ~class1(); } *c1; +class class2 : class1 { char j; }; +int bar5 (void) +{ + if (dynamic_cast <class2 *>(c1)) + return 5; + else + return 6; +} +/* { dg-final { scan-assembler "foo" } } */ +/* { dg-final { scan-assembler "boo" } } */ +/* { dg-final { scan-assembler "cue" } } */ +/* The xfail below is for PR33429. */ +/* { dg-final { scan-assembler "(string|ascii?)z?\[\t \]\"class2(\"|\\\\0)" { xfail *-*-* } } } */ +/* { dg-final { scan-assembler "(string|ascii?)z?\[\t \]\"printer(\"|\\\\0)" } } */ diff --git a/gcc/testsuite/g++.dg/other/var_copy-1.C b/gcc/testsuite/g++.dg/other/var_copy-1.C new file mode 100644 index 000000000..2fc6b780e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/var_copy-1.C @@ -0,0 +1,14 @@ +// { dg-options "-std=c++0x" } +// { dg-do compile } + +// Test to allow for va_copy with C++0x standard. + +#include <cstdarg> + +va_list x; +va_list y; + +int main () +{ + va_copy (y, x); +} diff --git a/gcc/testsuite/g++.dg/other/vararg-1.C b/gcc/testsuite/g++.dg/other/vararg-1.C new file mode 100644 index 000000000..f25606e93 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/vararg-1.C @@ -0,0 +1,20 @@ +// C++/15119 +// This ICEd in substitute_placeholder_in_expr because it did not +// implement the 4 element trees. +// Orginal test by: <wanderer@rsu.ru> +// Reduced by: <bangerth@dealii.org> +/* { dg-do compile } */ + +template<typename T> +const T& xmin(const T& a, const T& b); + +void bar (char *, ...); + +char const* descs[4]; + +int main() { + int t = 1; + char buf[100]; + bar( buf, descs[ xmin(t-1,4) ], 0 ); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/vararg-2.C b/gcc/testsuite/g++.dg/other/vararg-2.C new file mode 100644 index 000000000..5b3b9a3bf --- /dev/null +++ b/gcc/testsuite/g++.dg/other/vararg-2.C @@ -0,0 +1,11 @@ +// { dg-do compile } +struct QString {}; +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + QString & sprintf(QString &s,const QString &szFmt,...) + { + va_list list; + __builtin_va_start(list,((const char *)(&(szFmt)))); + __builtin_va_end(list); + return s; + } diff --git a/gcc/testsuite/g++.dg/other/vararg-3.C b/gcc/testsuite/g++.dg/other/vararg-3.C new file mode 100644 index 000000000..4585f3249 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/vararg-3.C @@ -0,0 +1,16 @@ +// PR c++/31488: va_list considered non-POD on alpha +// { dg-do compile } + +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +extern int foo (int a, int b, ...); + +int bar (int a, int b, ...) +{ + va_list args; + __builtin_va_start(args,b); + int result = foo (a, b, args); + __builtin_va_end(args); + return result; +} diff --git a/gcc/testsuite/g++.dg/other/virtual1.C b/gcc/testsuite/g++.dg/other/virtual1.C new file mode 100644 index 000000000..5f44fa78a --- /dev/null +++ b/gcc/testsuite/g++.dg/other/virtual1.C @@ -0,0 +1,7 @@ +// PR c++/26070 +// { dg-do compile } + +struct A +{ + virtual static int i; // { dg-error "virtual" } +}; diff --git a/gcc/testsuite/g++.dg/other/virtual2.C b/gcc/testsuite/g++.dg/other/virtual2.C new file mode 100644 index 000000000..f007403df --- /dev/null +++ b/gcc/testsuite/g++.dg/other/virtual2.C @@ -0,0 +1,7 @@ +// PR c++/26071 +// { dg-do compile } + +struct A +{ + virtual static ~A(); // { dg-error "virtual" } +}; diff --git a/gcc/testsuite/g++.dg/other/void1.C b/gcc/testsuite/g++.dg/other/void1.C new file mode 100644 index 000000000..691e6f782 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/void1.C @@ -0,0 +1,16 @@ +// PR c++/9278 +// { dg-do compile } + +typedef void VOID; + +int foo(void); +int bar(VOID); // { dg-error "type|invalid use" } + +template<int> int foo(void); +template<int> int bar(VOID); // { dg-error "type|invalid use" } + +struct A +{ + int foo(void); + int bar(VOID); // { dg-error "type|invalid use" } +}; diff --git a/gcc/testsuite/g++.dg/other/void2.C b/gcc/testsuite/g++.dg/other/void2.C new file mode 100644 index 000000000..153e0f181 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/void2.C @@ -0,0 +1,5 @@ +// PR c++/27423 +// { dg-do compile } + +void foo(void = 0); // { dg-error "incomplete type|invalid use" } +void bar() { foo(); } diff --git a/gcc/testsuite/g++.dg/other/vrp1.C b/gcc/testsuite/g++.dg/other/vrp1.C new file mode 100644 index 000000000..0a798c995 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/vrp1.C @@ -0,0 +1,12 @@ +// { dg-do compile } +// { dg-options "-O2" } +// This caused a crash in VRP because TREE_OVERFLOW was set for MIN. + +template<long long MIN> +long long mod (long long l, long long r) +{ + if (l == MIN && r == -1) + return 0LL; + return l % r; +} +template long long mod<-0x8000000000000000LL> (long long, long long); diff --git a/gcc/testsuite/g++.dg/other/vthunk1.C b/gcc/testsuite/g++.dg/other/vthunk1.C new file mode 100644 index 000000000..90165628b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/vthunk1.C @@ -0,0 +1,26 @@ +// PR c++/12007 Multiple inheritance float pass by value fails +// { dg-do run } + +extern "C" void abort (void); + +class gvImpl +{ +public: + virtual void PutVal(float value){} +}; + +class foo { public: virtual void Bar(){} }; + +class myGv: public foo, public gvImpl +{ + void PutVal(float value){ if (value != 3.14159f) abort (); } +}; + +myGv x; +gvImpl* object = &x; + +int main() +{ + object->PutVal(3.14159f); + return 0; +} diff --git a/gcc/testsuite/g++.dg/other/warning1.C b/gcc/testsuite/g++.dg/other/warning1.C new file mode 100644 index 000000000..77653a1df --- /dev/null +++ b/gcc/testsuite/g++.dg/other/warning1.C @@ -0,0 +1,19 @@ +// { dg-do compile } + +// PR c++/7804 +// Floating point formatting in error and warning messages + +extern "C" int printf(const char *, ...); + +struct S +{ + static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|float|initialization" } + static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|float|initialization" } +}; + +int main() +{ + // { dg-prune-output "not a member" } + printf("%f\n%f\n", S::inf, S::nan); + return 0; +} |