p4.cpp revision 8f4fb190852d3f86787c7e2c3dfc1b96143197ae
1// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x 2// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions 3 4template<typename T> 5struct only { 6 only(T); 7 template<typename U> only(U) = delete; 8}; 9 10void f() { 11 if (auto a = true) { 12 } 13 14 switch (auto a = 0) { 15 } 16 17 while (auto a = false) { 18 } 19 20 for (; auto a = false; ) { 21 } 22 23 // FIXME: support 'auto' error recovery here in pre-C++0x mode. 24#if __has_feature(cxx_auto_type) 25 new const auto (0); 26#endif 27 new (auto) (0.0); 28 29 int arr[] = {1, 2, 3}; 30 for (auto i : arr) { 31 } 32} 33 34class X { 35 static const auto n = 'x'; 36 37 auto m = 0; // expected-error {{'auto' not allowed in non-static class member}} 38}; 39 40struct S { 41 static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}} 42 static const auto b = 0; 43 static const int c; 44}; 45const int S::b; 46const auto S::c = 0; 47