diff options
author | no-author <no-author@gcc.gnu.org> | 2004-02-12 20:15:57 +0000 |
---|---|---|
committer | no-author <no-author@gcc.gnu.org> | 2004-02-12 20:15:57 +0000 |
commit | 5ce35163972a168c33c34b1ed753d16747f73ef3 (patch) | |
tree | 03bdff41b9946151953d965b51d3352fd8baf64d /gcc/testsuite/g++.dg | |
parent | e8461705deb66941c2b0ae4ae0ed44637b44c345 (diff) |
This commit was manufactured by cvs2svn to create branch
'tree-ssa-20020619-branch'.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@77725 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg')
23 files changed, 364 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/conversion/op2.C b/gcc/testsuite/g++.dg/conversion/op2.C new file mode 100644 index 00000000000..b400988108d --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/op2.C @@ -0,0 +1,16 @@ +// PR c++/13907 + +struct A { + operator int & (); + operator const int & () const; +}; + + +void f(int &); +void f(const int &); + + +int main() { + const A x = A(); + f(x); +} diff --git a/gcc/testsuite/g++.dg/ext/attrib13.C b/gcc/testsuite/g++.dg/ext/attrib13.C new file mode 100644 index 00000000000..22ea97ae706 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib13.C @@ -0,0 +1,4 @@ +// PR c++/13854 + +extern char *rindex (__const char *__s, int __c) throw () __attribute__ ((__pure__)); +extern char *rindex (__const char *__s, int __c) throw () __attribute__ ((__pure__)); diff --git a/gcc/testsuite/g++.dg/ext/case-range1.C b/gcc/testsuite/g++.dg/ext/case-range1.C new file mode 100644 index 00000000000..0e313d6b602 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/case-range1.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// Tests if case ranges (a GNU extension) are accepted +// { dg-options "" } +const int low = -2; +const int high = 15; + +template <typename T> +T f2 (T i) +{ + switch (i) + { + case low ... high : return i + 1; + default : return 0; + } +} + +int f (int i) +{ + switch (i) { + case 1 ... 10: return i + 1; + default: return f2 (i); + } +} diff --git a/gcc/testsuite/g++.dg/ext/case-range2.C b/gcc/testsuite/g++.dg/ext/case-range2.C new file mode 100644 index 00000000000..33befbd588a --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/case-range2.C @@ -0,0 +1,27 @@ +// { dg-do compile } +// Tests if case ranges (a GNU extension) correctly emit messages +// about overlapping ranges. +// { dg-options "" } + +const int low = -2; +const int high = 15; + +template <typename T> +T f2 (T i) +{ + switch (i) + { + case low ... high : return i + 1; // { dg-error "" } + case 5 : return i + 2; // { dg-error "duplicate" } + default : return 0; + } +} + +int f (int i) +{ + switch (i) { + case 1 ... 10: return i + 1; // { dg-error "" } + case 3 ... 5 : return i + 3; // { dg-error "duplicate" } + default: return f2 (i); // { dg-error "" } + } +} diff --git a/gcc/testsuite/g++.dg/ext/case-range3.C b/gcc/testsuite/g++.dg/ext/case-range3.C new file mode 100644 index 00000000000..569ce627455 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/case-range3.C @@ -0,0 +1,23 @@ +// { dg-do compile } +// Tests if case ranges (a GNU extension) emit errors in ISO mode +// { dg-options "-pedantic" } +const int low = -2; +const int high = 15; + +template <typename T> +T f2 (T i) +{ + switch (i) + { + case low ... high : return i + 1; // { dg-error "non-standard" } + default : return 0; + } +} + +int f (int i) +{ + switch (i) { + case 1 ... 10: return i + 1; // { dg-error "non-standard" } + default: return f2 (i); // { dg-error "" } + } +} diff --git a/gcc/testsuite/g++.dg/opt/fold1.C b/gcc/testsuite/g++.dg/opt/fold1.C new file mode 100644 index 00000000000..98f1b519115 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/fold1.C @@ -0,0 +1,17 @@ +// PR middle-end/13696 +// { dg-do compile } +// { dg-options "-O2" } + +extern void x(unsigned long*); + +enum e { red, blue, green }; + +struct s { + unsigned long l; +}; +struct s map[1][256]; + +void +f(int i,e j) { + x(&(map[i][j].l)); +} 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 00000000000..3a19f3ba8ab --- /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/parse/angle-bracket2.C b/gcc/testsuite/g++.dg/parse/angle-bracket2.C new file mode 100644 index 00000000000..fb758e33f76 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/angle-bracket2.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// Contributed by MattyT <mattyt-bugzilla at tpg dot com dot au> +// PR c++/14028: Parser accepts invalid unbalanced bracket. + +template <int> struct A {}; +template <typename TP> class B : public A<4 {}; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/parse/error13.C b/gcc/testsuite/g++.dg/parse/error13.C new file mode 100644 index 00000000000..15642e39ed7 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error13.C @@ -0,0 +1,13 @@ +// PR c++/13975 + +public: // { dg-error "" } + +int i; + +protected: // { dg-error "" } + +int j; + +private: // { dg-error "" } + +int k; diff --git a/gcc/testsuite/g++.dg/parse/error14.C b/gcc/testsuite/g++.dg/parse/error14.C new file mode 100644 index 00000000000..4b230453867 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error14.C @@ -0,0 +1,22 @@ +// PR c++/13970 + +struct X +{ + template< typename Z > Z Zunc() + { + return Z(); + } + + template< typename Z > void Zinc() + { + } + + void tst() + { + Zunc<int>(); + + Zinc<int>( //); + // } + +}; // { dg-error "" } + diff --git a/gcc/testsuite/g++.dg/parse/error15.C b/gcc/testsuite/g++.dg/parse/error15.C new file mode 100644 index 00000000000..fd703824718 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/error15.C @@ -0,0 +1,39 @@ +// { dg-do compile } +// Contributed by Volker Reichelt <reichelt at gcc dot gnu dot org> +// PR c++/14008: Improve diagnostic on invalid types in declarators. + +namespace N +{ + template<int> struct A {}; + struct C {}; + int K; +} + +N::A f2; // { dg-error "without an argument list" } +N::INVALID f3; // { dg-error "in namespace `N' does not name a type" } +N::C::INVALID f4; // { dg-error "in class `N::C' does not name a type" } +N::K f6; // { dg-error "in namespace `N' does not name a type" } +typename N::A f7; // { dg-error "without an argument list|outside of template" } + +struct B +{ + N::A f2; // { dg-error "without an argument list" } + N::INVALID f3; // { dg-error "in namespace `N' does not name a type" } + N::C::INVALID f4; // { dg-error "in class `N::C' does not name a type" } + N::K f6; // { dg-error "in namespace `N' does not name a type" } + typename N::A f7; // { dg-error "without an argument list|outside of template" } +}; + +template <int> +struct C +{ + N::A f2; // { dg-error "without an argument list" } + N::INVALID f3; // { dg-error "in namespace `N' does not name a type" } + N::C::INVALID f4; // { dg-error "in class `N::C' does not name a type" } + N::K f6; // { dg-error "in namespace `N' does not name a type" } + typename N::A f7; // { dg-error "without an argument list" } +}; + +// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 16 } +// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 24 } +// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 34 } diff --git a/gcc/testsuite/g++.dg/parse/template13.C b/gcc/testsuite/g++.dg/parse/template13.C new file mode 100644 index 00000000000..b1c03690be5 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template13.C @@ -0,0 +1,10 @@ +// PR c++/14002 + +template <typename T> void foo (T x) { x; } + +void bar() { foo(0); } + +struct A +{ + friend void foo<int> (int); +}; diff --git a/gcc/testsuite/g++.dg/template/crash17.C b/gcc/testsuite/g++.dg/template/crash17.C new file mode 100644 index 00000000000..9fa826b999d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/crash17.C @@ -0,0 +1,19 @@ +template <int I> +struct A { +}; + +template <typename T> +struct B { + typedef typename T::type type; + static const type j = T::j; + + A<j> b; +}; + +struct C { + typedef int type; + static const int j = 3; +}; + +int i = B<C>::j; + diff --git a/gcc/testsuite/g++.dg/template/koenig4.C b/gcc/testsuite/g++.dg/template/koenig4.C new file mode 100644 index 00000000000..31e41fcf97f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/koenig4.C @@ -0,0 +1,12 @@ +// PR c++/13978 + +namespace ns { + template <class TP> void func1(TP* t); + struct A {}; +} + +template < class TP > +void func2() { + func1( new ns::A() ); +} + diff --git a/gcc/testsuite/g++.dg/template/lookup4.C b/gcc/testsuite/g++.dg/template/lookup4.C new file mode 100644 index 00000000000..d64006133c3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/lookup4.C @@ -0,0 +1,6 @@ +// PR c++/13950 + +template <class T> struct Base {}; +template <class T> struct Derived: public Base<T> { + typename Derived::template Base<double>* p1; // { dg-error "" } +}; diff --git a/gcc/testsuite/g++.dg/template/lookup5.C b/gcc/testsuite/g++.dg/template/lookup5.C new file mode 100644 index 00000000000..022202a7158 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/lookup5.C @@ -0,0 +1,17 @@ +// PR c++/13925 + +namespace N { + template <class T> void f(T); + + namespace M { + class A { + friend void f<int>(int); + }; + } + + template <class T> void f(T) {} + template <> void f<int>(int ) + { + f<long>(0); + } +} diff --git a/gcc/testsuite/g++.dg/template/member4.C b/gcc/testsuite/g++.dg/template/member4.C new file mode 100644 index 00000000000..290fbb566c2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/member4.C @@ -0,0 +1,20 @@ +// { dg-do compile } +// Contributed by Matty T. <mattyt-bugzilla at tpg dot com dot au> +// PR c++/13813 [DR206]: Check semantic constraints of members of +// non-dependent type at instantiation time. + + +// DR206 explains that this is ill-formed, no diagnostic required. We emit +// a diagnostic instead. +class E; +template < class A > class Z { + A a; + E e; // { dg-error "incomplete type" } +}; + + +// Nested classes are always dependent names. +template < class A > class Y { + class F; + F e; // { dg-bogus "" "nested classes are always dependent, see DR108 and DR224" } +}; diff --git a/gcc/testsuite/g++.dg/template/nontype6.C b/gcc/testsuite/g++.dg/template/nontype6.C new file mode 100644 index 00000000000..43470ccdb1d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/nontype6.C @@ -0,0 +1,19 @@ +// { dg-do compile } +// Origin: <v dot haisman at sh dot cvut dot cz> +// PR c++/13957: Improved error message for type in template (when non-type +// is expected). + +template <class T> +struct A +{ + typedef int type; +}; + +template <class T> +void func(void) +{ + (void)A<T>::type(); // { dg-error "if a type is meant" } +// { dg-error "parsed as a non-type" "" { target *-*-* } 15 } +} + +template void func<float>(void); // { dg-error "instantiated from here" } diff --git a/gcc/testsuite/g++.dg/template/partial3.C b/gcc/testsuite/g++.dg/template/partial3.C new file mode 100644 index 00000000000..9862675148e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial3.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// Origin: John Maddock <john at johnmaddock dot co dot uk> +// PR c++/13997: Error while matching partial specialization of array type + +template <typename T> +struct is_array; + +template <typename T, unsigned int N> +struct is_array<T[N]>; + +template <typename T, unsigned int N> +struct is_array<const T[N]> {}; + +template struct is_array<int const[2]>; diff --git a/gcc/testsuite/g++.dg/template/sizeof6.C b/gcc/testsuite/g++.dg/template/sizeof6.C new file mode 100644 index 00000000000..3ef3794b5b7 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof6.C @@ -0,0 +1,13 @@ +// { dg-do compile } +// Contributed by Giovanni Bajo <giovannibajo at gcc dot gnu dot org> +// PR c++/13683: bogus warning about passing non-PODs through ellipsis + +struct B {}; +struct NonPOD : B {}; + +struct A +{ + static int check(...); + static NonPOD GetNonPOD(void); + enum { value = sizeof(A::check(A::GetNonPOD())) }; +}; diff --git a/gcc/testsuite/g++.dg/template/sizeof7.C b/gcc/testsuite/g++.dg/template/sizeof7.C new file mode 100644 index 00000000000..4964bfd25d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sizeof7.C @@ -0,0 +1,14 @@ +// { dg-do compile } +// Testcase by: bangerth@dealii.org +// PR c++/10858: failure with calling a method inside sizeof in a template + + template <int> struct P {}; + + void bar (); + + template <class T> struct X { + static int foo(void (*)()); + P<sizeof(foo(&bar))> p; + }; + + template class X<int>; diff --git a/gcc/testsuite/g++.dg/template/static6.C b/gcc/testsuite/g++.dg/template/static6.C new file mode 100644 index 00000000000..30ecae94067 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static6.C @@ -0,0 +1,14 @@ +// PR c++/13969 + +struct B { + static const int N=10; +}; + +template <int> struct X {}; + +template <typename> struct S { + static const int N = B::N; + X<N> x; +}; + +template class S<float>; diff --git a/gcc/testsuite/g++.dg/warn/conv2.C b/gcc/testsuite/g++.dg/warn/conv2.C new file mode 100644 index 00000000000..e3466002218 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/conv2.C @@ -0,0 +1,3 @@ +// PR c++/13932 + +int i = 1.; // { dg-warning "converting" } |