p5.cpp revision e7397c6a1bb2b205c5fe678e26199eb26d22e38e
1// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s -std=c++0x 2 3struct S { 4 virtual ~S(); 5 6 auto a; // expected-error{{'auto' not allowed in struct member}} 7 auto *b; // expected-error{{'auto' not allowed in struct member}} 8 const auto c; // expected-error{{'auto' not allowed in struct member}} 9 10 void f() throw (auto); // expected-error{{'auto' not allowed here}} 11 12 friend auto; // expected-error{{'auto' not allowed in 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. 18typedef auto *AutoPtr; // expected-error{{'auto' not allowed in typedef}} 19typedef auto (*PFun)(int a); // expected-error{{'auto' not allowed in typedef}} 20typedef auto Fun(int a) -> decltype(a + a); 21 22void 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 29void h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}} 30} 31 32void i(const auto a) { // expected-error{{'auto' not allowed in function prototype}} 33} 34 35namespace std { 36 class type_info; 37} 38 39template<typename T> struct U {}; 40 41void 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 // FIXME: don't issue the second diagnostic for this error. 47 U<auto> v; // expected-error{{'auto' not allowed in template argument}} unexpected-error{{C++ requires a type specifier}} 48 49 int n; 50 (void)dynamic_cast<auto&>(S()); // expected-error{{'auto' not allowed here}} 51 (void)static_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} 52 (void)reinterpret_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} 53 (void)const_cast<auto>(n); // expected-error{{'auto' not allowed here}} 54 (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}} 55 (void)auto(n); // expected-error{{expected expression}} 56 (void)auto{n}; // expected-error{{expected expression}} 57} 58 59template <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}} 60int ints[] = {1, 2, 3}; 61template <const auto (*a)[3] = &ints> class D { }; // expected-error{{'auto' not allowed in template parameter}} 62enum E : auto {}; // expected-error{{'auto' not allowed here}} 63struct F : auto {}; // expected-error{{expected class name}} 64template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed here}} 65 66using A = auto; // expected-error{{expected ';'}} expected-error{{requires a qualified name}} 67 68// FIXME: don't issue the second diagnostic for this error. 69auto k() -> auto; // expected-error{{'auto' not allowed here}} unexpected-error{{without trailing return type}} 70