diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-21 05:20:21 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-21 05:20:21 +0000 |
commit | aea72cce7e400a42c105d192fdff0a01d9634d43 (patch) | |
tree | 6a2dcbc13ba8e832ec200e3bbf79cdb2c6b68006 /gcc/testsuite/g++.dg | |
parent | 539a0502dc8dfe9e6440ac544f7baa370298a804 (diff) | |
download | gcc-aea72cce7e400a42c105d192fdff0a01d9634d43.tar.gz |
2009-09-21 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 151911
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@151912 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C | 26 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nolinkage1.C | 21 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nolinkage1.h | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/torture/pr40642.C | 26 |
5 files changed, 96 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C new file mode 100644 index 00000000000..e422132afc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-deduce.C @@ -0,0 +1,26 @@ +// Test for deduction of T as std::initializer_list. This isn't currently +// supported by the working draft, but is necessary for perfect forwarding +// of initializer-lists to things that can take a std::initializer_list. + +// { dg-options -std=c++0x } +// { dg-do run } + +#include <initializer_list> + +struct A +{ + A(std::initializer_list<int>) { } +}; + +void f (A a) { } + +template <class T> +auto g (T&& t) -> decltype (f(t)) // { dg-warning "call" } +{ + return f(t); +} + +int main() +{ + g({1}); // { dg-warning "deduc" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C new file mode 100644 index 00000000000..a31394b08ac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.C @@ -0,0 +1,21 @@ +// DR 757 allows using types without linkage in declarations with linkage. +// Test that this doesn't lead to link-time collisions. + +// { dg-additional-sources "nolinkage1a.cc" } +// { dg-do link } + +#include "nolinkage1.h" + +typedef struct { int i; } *AP; + +void f(AP) { } + +A<AP> a; + +static void g() +{ + struct B { }; + A<B> a; +} + +int main() { g(); f(0); } diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h new file mode 100644 index 00000000000..3cb5f63b390 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1.h @@ -0,0 +1,8 @@ +template <class T> +struct A +{ + A(); +}; + +template <class T> +A<T>::A() { } diff --git a/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc b/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc new file mode 100644 index 00000000000..f8528f3e650 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nolinkage1a.cc @@ -0,0 +1,15 @@ +#include "nolinkage1.h" + +typedef struct { double d; } *BP; + +void f(BP) { } + +A<BP> b; + +static void g() +{ + struct B { }; + A<B> a; +} + +int dummy() { g(); f(0); } diff --git a/gcc/testsuite/g++.dg/torture/pr40642.C b/gcc/testsuite/g++.dg/torture/pr40642.C new file mode 100644 index 00000000000..3f545a89037 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr40642.C @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-fprofile-generate" } + +// GCC used to ICE with some EH edge missing. + +inline void* operator new(__SIZE_TYPE__, void* p) throw() { return p; } +inline void operator delete (void*, void*) throw() { } + +template<typename T> void foo(void* p, T t) +{ + new(p) T(t); +} + +void bar(); + +template<typename T> struct A +{ + T* p; + + A() { try { foo(p, T()); } catch(...) {} } + + A(const A&) { try { bar(); } catch(...) { throw; } } +}; + +A<A<int> > a; + |