From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaCXX/trailing-return-0x.cpp | 71 +++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 clang/test/SemaCXX/trailing-return-0x.cpp (limited to 'clang/test/SemaCXX/trailing-return-0x.cpp') diff --git a/clang/test/SemaCXX/trailing-return-0x.cpp b/clang/test/SemaCXX/trailing-return-0x.cpp new file mode 100644 index 0000000..c219b77 --- /dev/null +++ b/clang/test/SemaCXX/trailing-return-0x.cpp @@ -0,0 +1,71 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +template +struct only +{ + only(T) {} + + template + 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 i(); +auto i() -> int; +int i() {} + +using T = auto (int) -> auto (*)(char) -> void; // expected-note {{previous}} +using T = void; // expected-error {{type alias redefinition with different types ('void' vs 'auto (int) -> auto (*)(char) -> void')}} + +using U = auto (int) -> auto (*)(char) -> void; +using U = void (*(int))(char); // ok + +int x; + +template +auto i(T x) -> decltype(x) +{ + return x; +} + +only p1 = i(1.0); + +template +struct X +{ + auto f(T x) -> T { return x; } + + template + auto g(T x, U y) -> decltype(x + y) + { + return x + y; + } + + template + struct nested { + template + auto h(T x, U y, V z) -> decltype(x + y + z) + { + return x + y + z; + } + }; + + template + nested get_nested(); +}; + +X xx; +only p2 = xx.f(0L); +only p3 = xx.g(0L, 1.0); +only p4 = xx.get_nested().h(0L, 1.0, 3.14f); -- cgit v1.2.3