1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11 2 3 struct S { 4 virtual ~S(); 5 6 auto a; // expected-error{{'auto' not allowed in non-static struct member}} 7 auto *b; // expected-error{{'auto' not allowed in non-static struct member}} 8 const auto c; // expected-error{{'auto' not allowed in non-static struct member}} 9 10 void f() throw (auto); // expected-error{{'auto' not allowed here}} 11 12 friend auto; // expected-error{{'auto' not allowed in non-static struct member}} 13 14 operator auto(); // expected-error{{'auto' not allowed here}} 15 }; 16 17 // PR 9278: auto is not allowed in typedefs, except with a trailing return type. 18 typedef auto *AutoPtr; // expected-error{{'auto' not allowed in typedef}} 19 typedef auto (*PFun)(int a); // expected-error{{'auto' not allowed in typedef}} 20 typedef auto Fun(int a) -> decltype(a + a); 21 22 void g(auto a) { // expected-error{{'auto' not allowed in function prototype}} 23 try { } 24 catch (auto &a) { } // expected-error{{'auto' not allowed in exception declaration}} 25 catch (const auto a) { } // expected-error{{'auto' not allowed in exception declaration}} 26 try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}} 27 } 28 29 void h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}} 30 } 31 32 void i(const auto a) { // expected-error{{'auto' not allowed in function prototype}} 33 } 34 35 namespace std { 36 class type_info; 37 } 38 39 template<typename T> struct U {}; 40 41 void j() { 42 (void)typeid(auto); // expected-error{{'auto' not allowed here}} 43 (void)sizeof(auto); // expected-error{{'auto' not allowed here}} 44 (void)__alignof(auto); // expected-error{{'auto' not allowed here}} 45 46 U<auto> v; // expected-error{{'auto' not allowed in template argument}} 47 48 int n; 49 (void)dynamic_cast<auto&>(n); // expected-error{{'auto' not allowed here}} 50 (void)static_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} 51 (void)reinterpret_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} 52 (void)const_cast<auto>(n); // expected-error{{'auto' not allowed here}} 53 (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}} 54 (void)auto(n); // expected-error{{expected expression}} 55 (void)auto{n}; // expected-error{{expected expression}} 56 } 57 58 template <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}} 59 int ints[] = {1, 2, 3}; 60 template <const auto (*a)[3] = &ints> class D { }; // expected-error{{'auto' not allowed in template parameter}} 61 enum E : auto {}; // expected-error{{'auto' not allowed here}} 62 struct F : auto {}; // expected-error{{expected class name}} 63 template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed here}} 64 65 using A = auto; // expected-error{{'auto' not allowed in type alias}} 66 67 // FIXME: don't issue the second diagnostic for this error. 68 auto k() -> auto; // expected-error{{'auto' not allowed here}} unexpected-error{{without trailing return type}} 69