diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
commit | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (patch) | |
tree | a9243275843fbeaa590afc07ee888e006b8d54ea /test/SemaCXX/trailing-return-0x.cpp | |
parent | 69b4eca4a4255ba43baa5c1d9bbdec3ec17f479e (diff) | |
download | FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.zip FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.tar.gz |
Vendor import of clang trunk r126079:
http://llvm.org/svn/llvm-project/cfe/trunk@126079
Diffstat (limited to 'test/SemaCXX/trailing-return-0x.cpp')
-rw-r--r-- | test/SemaCXX/trailing-return-0x.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/SemaCXX/trailing-return-0x.cpp b/test/SemaCXX/trailing-return-0x.cpp new file mode 100644 index 0000000..b52b240 --- /dev/null +++ b/test/SemaCXX/trailing-return-0x.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +template <class T> +struct only +{ + only(T) {} + + template <class U> + only(U) + { + static_assert(sizeof(U) == 0, "expected type failure"); + } +}; + +auto f() -> int +{ + return 0; +} + +auto g(); // expected-error{{return without trailing return type}} + +int h() -> int; // expected-error{{trailing return type must specify return type 'auto', not 'int'}} + +int x; + +template <class T> +auto i(T x) -> decltype(x) +{ + return x; +} + +only<double> p1 = i(1.0); + +template <class T> +struct X +{ + auto f(T x) -> T { return x; } + + template <class U> + auto g(T x, U y) -> decltype(x + y) + { + return x + y; + } + + template<typename U> + struct nested { + template <class V> + auto h(T x, U y, V z) -> decltype(x + y + z) + { + return x + y + z; + } + }; + + template<typename U> + nested<U> get_nested(); +}; + +X<int> xx; +only<int> p2 = xx.f(0L); +only<double> p3 = xx.g(0L, 1.0); +only<double> p4 = xx.get_nested<double>().h(0L, 1.0, 3.14f); |