blob: c1d01fc9af952b46efe91d094e9ace13eb5b4a8f [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
Anders Carlssonaf017e62009-06-29 22:58:55 +00002
Richard Smithefeeccf2012-10-21 03:28:35 +00003void f(); // expected-note{{possible target for call}}
4void f(int); // expected-note{{possible target for call}}
John McCall6dbba4f2011-10-11 23:14:30 +00005decltype(f) a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{variable has incomplete type 'decltype(f())' (aka 'void')}}
Anders Carlssonaf017e62009-06-29 22:58:55 +00006
7template<typename T> struct S {
Richard Smithefeeccf2012-10-21 03:28:35 +00008 decltype(T::f) * f; // expected-error {{call to non-static member function without an object argument}}
Anders Carlssonaf017e62009-06-29 22:58:55 +00009};
10
Douglas Gregordb2eae62011-03-16 19:16:25 +000011struct K {
Richard Smithefeeccf2012-10-21 03:28:35 +000012 void f();
13 void f(int);
Douglas Gregordb2eae62011-03-16 19:16:25 +000014};
John McCall7c2342d2010-03-10 11:27:22 +000015S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
Richard Smithc4a83912012-10-01 20:35:07 +000016
17namespace PR13978 {
18 template<typename T> struct S { decltype(1) f(); };
19 template<typename T> decltype(1) S<T>::f() { return 1; }
20
21 // This case is ill-formed (no diagnostic required) because the decltype
22 // expressions are functionally equivalent but not equivalent. It would
23 // be acceptable for us to reject this case.
24 template<typename T> struct U { struct A {}; decltype(A{}) f(); };
25 template<typename T> decltype(typename U<T>::A{}) U<T>::f() {}
26
27 // This case is valid.
28 template<typename T> struct V { struct A {}; decltype(typename V<T>::A{}) f(); };
29 template<typename T> decltype(typename V<T>::A{}) V<T>::f() {}
30}