// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions template struct only { only(T); template only(U) = delete; }; namespace N { auto a = "const char [16]", *p = &a; only testA = a; only testP = p; } void h() { auto b = 42ULL; only testB = b; for (auto c = 0; c < 100; ++c) { only testC = c; } } void p3example() { auto x = 5; const auto *v = &x, u = 6; static auto y = 0.0; only testX = x; only testV = v; only testU = u; only testY = y; } void f() { if (auto a = true) { only testA = a; } switch (auto a = 0) { case 0: only testA = a; } while (auto a = false) { only testA = a; } for (; auto a = "test"; ) { only testA = a; } auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}} int **p; const auto **fail2(p); // expected-error {{variable 'fail2' with type 'const auto **' has incompatible initializer of type 'int **'}} } struct S { void f(); char g(int); float g(double); int m; void test() { auto p1 = &S::f; auto S::*p2 = &S::f; auto (S::*p3)() = &S::f; auto p4 = &S::g; // expected-error {{incompatible initializer of type ''}} auto S::*p5 = &S::g; // expected-error {{incompatible initializer of type ''}} auto (S::*p6)(int) = &S::g; auto p7 = &S::m; auto S::*p8 = &S::m; only test1 = p1; only test2 = p2; only test3 = p3; only test6 = p6; only test7 = p7; only test8 = p8; } }; namespace PR10939 { struct X { int method(int); // expected-note{{possible target for call}} int method(float); // expected-note{{possible target for call}} }; template T g(T); void f(X *x) { auto value = x->method; // expected-error {{reference to non-static member function must be called}} if (value) { } auto funcptr = &g; int (*funcptr2)(int) = funcptr; } } // if the initializer is a braced-init-list, deduce auto as std::initializer_list: // see SemaCXX/cxx0x-initializer-stdinitializerlist.cpp