1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2af017e682918f7a1a95ff08d9ab7ae3426436ca3Anders Carlsson
3efeeccfb5efa94b6b4198298a80ad9a699bebcceRichard Smithvoid f();  // expected-note{{possible target for call}}
4efeeccfb5efa94b6b4198298a80ad9a699bebcceRichard Smithvoid f(int);  // expected-note{{possible target for call}}
56dbba4fc128e2e2f5b26be996392bd32c0707f13John McCalldecltype(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')}}
6af017e682918f7a1a95ff08d9ab7ae3426436ca3Anders Carlsson
7af017e682918f7a1a95ff08d9ab7ae3426436ca3Anders Carlssontemplate<typename T> struct S {
8efeeccfb5efa94b6b4198298a80ad9a699bebcceRichard Smith  decltype(T::f) * f; // expected-error {{call to non-static member function without an object argument}}
9af017e682918f7a1a95ff08d9ab7ae3426436ca3Anders Carlsson};
10af017e682918f7a1a95ff08d9ab7ae3426436ca3Anders Carlsson
11db2eae639d3b7ed61ceb56890b73168517ef57f1Douglas Gregorstruct K {
12efeeccfb5efa94b6b4198298a80ad9a699bebcceRichard Smith  void f();
13efeeccfb5efa94b6b4198298a80ad9a699bebcceRichard Smith  void f(int);
14db2eae639d3b7ed61ceb56890b73168517ef57f1Douglas Gregor};
157c2342dd4c9947806842e5aca3d2bb2e542853c9John McCallS<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
16c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith
17c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smithnamespace PR13978 {
18c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> struct S { decltype(1) f(); };
19c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> decltype(1) S<T>::f() { return 1; }
20c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith
21c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  // This case is ill-formed (no diagnostic required) because the decltype
22c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  // expressions are functionally equivalent but not equivalent. It would
23c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  // be acceptable for us to reject this case.
24c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> struct U { struct A {}; decltype(A{}) f(); };
25c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> decltype(typename U<T>::A{}) U<T>::f() {}
26c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith
27c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  // This case is valid.
28c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> struct V { struct A {}; decltype(typename V<T>::A{}) f(); };
29c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith  template<typename T> decltype(typename V<T>::A{}) V<T>::f() {}
30c4a839101e883261d038a1d5ea718dd46abd1d2dRichard Smith}
31