1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2 3 // PR5290 4 int const f0(); f0_test()5void f0_test() { 6 decltype(0, f0()) i = 0; 7 i = 0; 8 } 9 AA10struct A { int a[1]; A() { } }; 11 typedef A const AC; 12 int &f1(int*); 13 float &f2(int const*); 14 test_f2()15void test_f2() { 16 float &fr = f2(AC().a); 17 } 18 19 template <class T> 20 struct Future { 21 explicit Future(T v); 22 23 template <class F> callFuture24 auto call(F&& fn) -> decltype(fn(T())) { 25 return fn(T()); 26 } 27 28 template <class B, class F> thenFuture29 auto then(F&& fn) -> decltype(call(fn)) 30 { 31 return fn(T()); 32 } 33 }; 34 rdar16527205()35void rdar16527205() { 36 Future<int> f1(42); 37 f1.call([](int){ return Future<float>(0); }); 38 } 39 40 namespace pr10154 { 41 class A{ 42 A(decltype(nullptr) param); 43 }; 44 } 45 46 template<typename T> struct S {}; f(T t)47template<typename T> auto f(T t) -> decltype(S<int>(t)) { 48 using U = decltype(S<int>(t)); 49 using U = S<int>; 50 return S<int>(t); 51 } 52 53 struct B { 54 B(decltype(undeclared)); // expected-error {{undeclared identifier}} 55 }; 56 struct C { 57 C(decltype(undeclared; // expected-error {{undeclared identifier}} \ 58 // expected-error {{expected ')'}} expected-note {{to match this '('}} 59 }; 60 61 namespace PR16529 { 62 struct U {}; 63 template <typename T> struct S { 64 static decltype(T{}, U{}) &f(); 65 }; 66 U &r = S<int>::f(); 67 } 68 69 namespace PR18876 { 70 struct A { ~A() = delete; }; // expected-note +{{here}} 71 A f(); 72 decltype(f()) *a; // ok, function call 73 decltype(A()) *b; // expected-error {{attempt to use a deleted function}} 74 decltype(0, f()) *c; // ok, function call on RHS of comma 75 decltype(0, A()) *d; // expected-error {{attempt to use a deleted function}} 76 decltype(f(), 0) *e; // expected-error {{attempt to use a deleted function}} 77 } 78 79 template<typename> 80 class conditional { 81 }; 82 83 void foo(conditional<decltype((1),int>) { // expected-note 2 {{to match this '('}} expected-error {{expected ')'}} 84 } // expected-error {{expected function body after function declarator}} expected-error 2 {{expected '>'}} expected-error {{expected ')'}} 85