diff options
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp/truefalse.C | 17 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/dllimport2.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/dllimport3.C | 25 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/pretty1.C | 67 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/pretty2.C | 61 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/typeof5.C | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/using6.C | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/opt/life1.C | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/offsetof3.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/offsetof4.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/access2.C | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/access10.C | 16 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/access11.C | 24 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/instantiate4.C | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/spec10.C | 27 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/spec9.C | 21 |
16 files changed, 366 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp/truefalse.C b/gcc/testsuite/g++.dg/cpp/truefalse.C new file mode 100644 index 00000000000..d852d4e2f21 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/truefalse.C @@ -0,0 +1,17 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ + +/* Source: Neil Booth, 18 Apr 2003. */ + +/* { dg-do preprocess } */ +/* { dg-options "-ansi -pedantic -Wundef" } */ + +/* Check that for C++ we handle true and false correctly, and do not + treat them as undefined identifiers. */ + +#if true /* { dg-bogus "is not defined" } */ +#error foo /* { dg-error "foo" } */ +#endif + +#if false /* { dg-bogus "is not defined" } */ +#error foo /* { dg-bogus "foo" } */ +#endif diff --git a/gcc/testsuite/g++.dg/ext/dllimport2.C b/gcc/testsuite/g++.dg/ext/dllimport2.C new file mode 100644 index 00000000000..9564be4f74c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/dllimport2.C @@ -0,0 +1,15 @@ +// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} } + +// PR 9738 Dllimport attribute is overriden by later definition + +void __attribute__((dllimport)) Bar(void); + + void Foo(void) + { + Bar(); + } + + void Bar(void) + { + } + diff --git a/gcc/testsuite/g++.dg/ext/dllimport3.C b/gcc/testsuite/g++.dg/ext/dllimport3.C new file mode 100644 index 00000000000..d5e7955dbff --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/dllimport3.C @@ -0,0 +1,25 @@ +// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw*} } + +// PR 10148 Dllimport attribute of object is overriden by later +// redefinition without attribute. + +struct Foo + { + int a; + }; + + __attribute__((dllimport)) struct Foo f; + + void Bar(void) + { + void* dummy = &f; + } + + struct Foo f; + +// Dllimport sets DECL_NON_ADDR_CONST_P to 1, so following +// assignment would require static_initialization_and_destruction +// if attribute is retained. + + void* dummy = &f; + diff --git a/gcc/testsuite/g++.dg/ext/pretty1.C b/gcc/testsuite/g++.dg/ext/pretty1.C new file mode 100644 index 00000000000..06608ae30eb --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pretty1.C @@ -0,0 +1,67 @@ +// PR c++/6794 +// Test whether __PRETTY_FUNCTION__ works in templates, functions and +// in initializers at global scope +// { dg-do compile } +// { dg-options "" } + +extern "C" void __assert_fail (const char *, const char *, + unsigned int, const char *) + throw() __attribute__((noreturn)); +extern "C" void abort (void); +extern "C" void exit (int); + +#define str(expr) #expr +#define assert(expr) \ + ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__, \ + __PRETTY_FUNCTION__), 0)) + +int __attribute__((noinline)) +foo (void) +{ + return 1; +} + +template<class T> int +bar (T) +{ + return (assert (foo ()), 1); +} + +template<> int +bar<int> (int) +{ + return (assert (foo ()), 2); +} + +int a = (assert (foo ()), 1); +int b = (assert (foo ()), 2); + +int +main () +{ + double c = 1.0; + unsigned char *d = 0; + int e = (assert (foo ()), 3); + + bar (c); + bar (d); + bar (e); +} + +namespace N +{ + int f = (assert (foo ()), 4); +} + +void __attribute__((noinline)) +__assert_fail (const char *cond, const char *file, unsigned int line, + const char *pretty) throw () +{ + abort (); +} + +// { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } } +// { dg-final { scan-assembler "top level" } } +// { dg-final { scan-assembler "int main\\(\\)" } } +// { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } } +// { dg-final { scan-assembler "int bar\\(T\\).*with T = unsigned char\*" } } diff --git a/gcc/testsuite/g++.dg/ext/pretty2.C b/gcc/testsuite/g++.dg/ext/pretty2.C new file mode 100644 index 00000000000..0c05da9b70d --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pretty2.C @@ -0,0 +1,61 @@ +// PR c++/6794 +// Test whether __PRETTY_FUNCTION__ works in templates, functions and +// in initializers at global scope +// { dg-do run } +// { dg-options "" } + +extern "C" void __assert_fail (const char *, const char *, + unsigned int, const char *) + throw() __attribute__((noreturn)); +extern "C" void abort (void); +extern "C" void exit (int); + +#define str(expr) #expr +#define assert(expr) \ + ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__, \ + __PRETTY_FUNCTION__), 0)) + +int __attribute__((noinline)) +foo (void) +{ + return 1; +} + +template<class T> int +bar (T) +{ + return (assert (foo ()), 1); +} + +template<> int +bar<int> (int) +{ + return (assert (foo ()), 2); +} + +int a = (assert (foo ()), 1); +int b = (assert (foo ()), 2); + +int +main () +{ + double c = 1.0; + unsigned char *d = 0; + int e = (assert (foo ()), 3); + + bar (c); + bar (d); + bar (e); +} + +namespace N +{ + int f = (assert (foo ()), 4); +} + +void __attribute__((noinline)) +__assert_fail (const char *cond, const char *file, unsigned int line, + const char *pretty) throw () +{ + abort (); +} diff --git a/gcc/testsuite/g++.dg/ext/typeof5.C b/gcc/testsuite/g++.dg/ext/typeof5.C new file mode 100644 index 00000000000..d1ee4f718d1 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/typeof5.C @@ -0,0 +1,8 @@ +// { dg-options "" } + +int foo; + +template <class T> struct Base {}; + +template <class T> +struct Derived : public Base<typeof(foo)> {}; diff --git a/gcc/testsuite/g++.dg/lookup/using6.C b/gcc/testsuite/g++.dg/lookup/using6.C new file mode 100644 index 00000000000..416f0b5256c --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using6.C @@ -0,0 +1,11 @@ +// { dg-do compile } + +// Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/9022, nested namespace in using declaration + +namespace gnu { + namespace gcc { + } +} +using gnu::gcc; // { dg-error "namespace" } diff --git a/gcc/testsuite/g++.dg/opt/life1.C b/gcc/testsuite/g++.dg/opt/life1.C new file mode 100644 index 00000000000..ac7a9f26d00 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/life1.C @@ -0,0 +1,16 @@ +// This testcase did not set up the pic register on IA-32 due +// to bug in calculate_global_regs_live EH edge handling. +// { dg-do compile { target i?86-*-linux* } } +// { dg-options "-O2 -fPIC" } + +struct A { }; + +void foo (A (*fn)()) +{ + try { + A a = fn (); + } catch (...) { + } +} + +// { dg-final { scan-assembler "GLOBAL_OFFSET_TABLE" } } diff --git a/gcc/testsuite/g++.dg/other/offsetof3.C b/gcc/testsuite/g++.dg/other/offsetof3.C new file mode 100644 index 00000000000..f600765fd90 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof3.C @@ -0,0 +1,15 @@ +/* Verify that offsetof warns if given a non-POD */ +/* Copyright (C) 2003 Free Software Foundation, Inc. */ +/* Contributed by Matt Austern <austern@apple.com> 15 May 2003 */ +/* { dg-do compile } */ + +struct X +{ + X() : x(3), y(4) { } + int x, y; +}; + +typedef X* pX; + +int yoff = int(&(pX(0)->y)); /* { dg-warning "invalid access" "" } */ +/* { dg-warning "macro was used incorrectly" "" { target *-*-* } 14 } */ diff --git a/gcc/testsuite/g++.dg/other/offsetof4.C b/gcc/testsuite/g++.dg/other/offsetof4.C new file mode 100644 index 00000000000..587231ef88e --- /dev/null +++ b/gcc/testsuite/g++.dg/other/offsetof4.C @@ -0,0 +1,15 @@ +/* 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; + +int yoff = int(&(pX(0)->y)); diff --git a/gcc/testsuite/g++.dg/parse/access2.C b/gcc/testsuite/g++.dg/parse/access2.C new file mode 100644 index 00000000000..ee8cd234e07 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/access2.C @@ -0,0 +1,15 @@ +// Copyright (C) 2003 Free Software Foundation +// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> +// { dg-do compile } + +// Deferred access checking of variable declaration. + +class A { + typedef int X; // { dg-error "private" } + static X a, b, c; +}; + +A::X A::a; +A::X A::b, x; // { dg-error "this context" } +A::X y, A::c; // { dg-error "this context" } +A::X z; // { dg-error "this context" } diff --git a/gcc/testsuite/g++.dg/template/access10.C b/gcc/testsuite/g++.dg/template/access10.C new file mode 100644 index 00000000000..8b4883c254b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access10.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Origin: Giovanni Bajo <giovannibajo@libero.it> + +// PR c++/10849: Incorrect access checking on template specialization. + +class X { + private: + template <typename T> struct Y; +}; + +template <> struct X::Y<int> {}; + +template <typename T> struct X::Y {}; + +template struct X::Y<int>; diff --git a/gcc/testsuite/g++.dg/template/access11.C b/gcc/testsuite/g++.dg/template/access11.C new file mode 100644 index 00000000000..f061f6616eb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/access11.C @@ -0,0 +1,24 @@ +// Copyright (C) 2003 Free Software Foundation +// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> +// { dg-do compile } + +// Access checking during explicit instantiation. + +class A { + typedef int X; // { dg-error "private" } +}; + +class X { + private: + template <typename T> struct Y; +}; + +template <> struct X::Y<int> { + A::X x; // { dg-error "this context" } +}; + +template <typename T> struct X::Y { + typename T::X x; // { dg-error "this context" } +}; + +template struct X::Y<A>; // { dg-error "instantiated" } diff --git a/gcc/testsuite/g++.dg/template/instantiate4.C b/gcc/testsuite/g++.dg/template/instantiate4.C new file mode 100644 index 00000000000..732b8529de2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/instantiate4.C @@ -0,0 +1,13 @@ +// { dg-do compile } + +// Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/10682: Typedef to enum template instantiation logic. + +template <typename T> +struct Foo { + enum E {a,b,c}; + typedef E EE; +}; + +void Baz(Foo<int>::EE x); diff --git a/gcc/testsuite/g++.dg/template/spec10.C b/gcc/testsuite/g++.dg/template/spec10.C new file mode 100644 index 00000000000..f790155dce2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec10.C @@ -0,0 +1,27 @@ +// { dg-do run } + +// Origin: Lynn Akers <lakers@peachtree.com> + +// PR c++/10940: Problem handling parameter list for static member +// that is a specialization of a member template of a template class. + +template<int b> +class o +{ +public: + template<typename T> static void do_add(T* p, T v); +}; + +template<> +template<typename T> +inline void o<32>::do_add(T* p, T v) +{ + *p += v; +} + +int main() +{ + int a = 0x1000; + o<32>().do_add<int>(&a, 0x2000); + return a; +} diff --git a/gcc/testsuite/g++.dg/template/spec9.C b/gcc/testsuite/g++.dg/template/spec9.C new file mode 100644 index 00000000000..013fa0d9920 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec9.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Origin: Lynn Akers <lakers@peachtree.com> +// Wolfgang Bangerth <bangerth@ticam.utexas.edu> + +// PR c++/10956: Incorrect template substitution for member template +// specialization inside template class. + +template <int> struct C { + template<typename T> void pre_add(T); +}; + +template<> +template<typename T> +void C<32>::pre_add(T) { + T pre; +} + +int main() { + C<32>().pre_add<int>(1); +} |