1// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y 2// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-c++1y-extensions 3// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions 4 5template<typename T> 6struct only { 7 only(T); 8 template<typename U> only(U) = delete; 9}; 10 11void f() { 12 if (auto a = true) { 13 } 14 15 switch (auto a = 0) { 16 } 17 18 while (auto a = false) { 19 } 20 21 for (; auto a = false; ) { 22 } 23 24 new const auto (0); 25 new (auto) (0.0); 26 27 int arr[] = {1, 2, 3}; 28 for (auto i : arr) { 29 } 30} 31 32class X { 33 static const auto n = 'x'; 34 35 auto m = 0; // expected-error {{'auto' not allowed in non-static class member}} 36}; 37 38struct S { 39 static const auto a; // expected-error {{declaration of variable 'a' with type 'const auto' requires an initializer}} 40 static const auto b = 0; 41 static const int c; 42}; 43const int S::b; 44const auto S::c = 0; 45 46namespace std { template<typename T> struct initializer_list { initializer_list(); }; } 47 48// In an initializer of the form ( expression-list ), the expression-list 49// shall be a single assigment-expression. 50auto parens1(1); 51auto parens2(2, 3); // expected-error {{initializer for variable 'parens2' with type 'auto' contains multiple expressions}} 52#if __cplusplus >= 201103L 53auto parens3({4, 5, 6}); // expected-error {{cannot deduce type for variable 'parens3' with type 'auto' from parenthesized initializer list}} 54auto parens4 = [p4(1)] {}; 55auto parens5 = [p5(2, 3)] {}; // expected-error {{initializer for lambda capture 'p5' contains multiple expressions}} 56auto parens6 = [p6({4, 5, 6})] {}; // expected-error {{cannot deduce type for lambda capture 'p6' from parenthesized initializer list}} 57#endif 58 59#if __cplusplus >= 201402L 60namespace std_example { 61 // The other half of this example is in p3.cpp 62 auto f() -> int; 63 auto g() { return 0.0; } 64 auto h(); 65} 66#endif 67