1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11
234b41d939a1328f484511c6002ba2456db879a29Richard Smith
334b41d939a1328f484511c6002ba2456db879a29Richard Smithstruct S {
434b41d939a1328f484511c6002ba2456db879a29Richard Smith  virtual ~S();
534b41d939a1328f484511c6002ba2456db879a29Richard Smith
67a614d8380297fcd2bc23986241905d97222948cRichard Smith  auto a; // expected-error{{'auto' not allowed in non-static struct member}}
77a614d8380297fcd2bc23986241905d97222948cRichard Smith  auto *b; // expected-error{{'auto' not allowed in non-static struct member}}
87a614d8380297fcd2bc23986241905d97222948cRichard Smith  const auto c; // expected-error{{'auto' not allowed in non-static struct member}}
934b41d939a1328f484511c6002ba2456db879a29Richard Smith
1034b41d939a1328f484511c6002ba2456db879a29Richard Smith  void f() throw (auto); // expected-error{{'auto' not allowed here}}
1134b41d939a1328f484511c6002ba2456db879a29Richard Smith
127a614d8380297fcd2bc23986241905d97222948cRichard Smith  friend auto; // expected-error{{'auto' not allowed in non-static struct member}}
1334b41d939a1328f484511c6002ba2456db879a29Richard Smith
1414f78f4a11df4c06667e2cbb87eeb179e4cb46feRichard Smith  operator auto(); // expected-error{{'auto' not allowed in conversion function type}}
1534b41d939a1328f484511c6002ba2456db879a29Richard Smith};
1634b41d939a1328f484511c6002ba2456db879a29Richard Smith
1724d44eddfc98464d10802e71c77d3dc3e45f4aacRichard Smith// PR 9278: auto is not allowed in typedefs, except with a trailing return type.
18ddc83f9255834217f0559b09ff75a1c50b8ce457Richard Smithtypedef auto *AutoPtr; // expected-error{{'auto' not allowed in typedef}}
19e7397c6a1bb2b205c5fe678e26199eb26d22e38eRichard Smithtypedef auto (*PFun)(int a); // expected-error{{'auto' not allowed in typedef}}
20ddc83f9255834217f0559b09ff75a1c50b8ce457Richard Smithtypedef auto Fun(int a) -> decltype(a + a);
21ddc83f9255834217f0559b09ff75a1c50b8ce457Richard Smith
2234b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid g(auto a) { // expected-error{{'auto' not allowed in function prototype}}
2334b41d939a1328f484511c6002ba2456db879a29Richard Smith  try { }
2434b41d939a1328f484511c6002ba2456db879a29Richard Smith  catch (auto &a) { } // expected-error{{'auto' not allowed in exception declaration}}
2534b41d939a1328f484511c6002ba2456db879a29Richard Smith  catch (const auto a) { } // expected-error{{'auto' not allowed in exception declaration}}
2634b41d939a1328f484511c6002ba2456db879a29Richard Smith  try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}}
2734b41d939a1328f484511c6002ba2456db879a29Richard Smith}
2834b41d939a1328f484511c6002ba2456db879a29Richard Smith
2934b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}}
30e2bb224dee15d07bc9843acd4f3ded8eb0f835edAnders Carlsson}
31baf45d31f18e6d5b3d2a33695c2af6e6cbc4ee29Anders Carlsson
3234b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid i(const auto a) { // expected-error{{'auto' not allowed in function prototype}}
3334b41d939a1328f484511c6002ba2456db879a29Richard Smith}
34baf45d31f18e6d5b3d2a33695c2af6e6cbc4ee29Anders Carlsson
3534b41d939a1328f484511c6002ba2456db879a29Richard Smithnamespace std {
3634b41d939a1328f484511c6002ba2456db879a29Richard Smith  class type_info;
3734b41d939a1328f484511c6002ba2456db879a29Richard Smith}
3834b41d939a1328f484511c6002ba2456db879a29Richard Smith
3934b41d939a1328f484511c6002ba2456db879a29Richard Smithtemplate<typename T> struct U {};
4034b41d939a1328f484511c6002ba2456db879a29Richard Smith
4134b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid j() {
4234b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)typeid(auto); // expected-error{{'auto' not allowed here}}
4334b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)sizeof(auto); // expected-error{{'auto' not allowed here}}
4434b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)__alignof(auto); // expected-error{{'auto' not allowed here}}
4534b41d939a1328f484511c6002ba2456db879a29Richard Smith
463b887354b1b667c97d070ddc67b5354353c4c07bDouglas Gregor  U<auto> v; // expected-error{{'auto' not allowed in template argument}}
4734b41d939a1328f484511c6002ba2456db879a29Richard Smith
4834b41d939a1328f484511c6002ba2456db879a29Richard Smith  int n;
4931862ba5ea70b1f2c81d03f8a0100b61cd6f06f6Argyrios Kyrtzidis  (void)dynamic_cast<auto&>(n); // expected-error{{'auto' not allowed here}}
5034b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)static_cast<auto*>(&n); // expected-error{{'auto' not allowed here}}
5134b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)reinterpret_cast<auto*>(&n); // expected-error{{'auto' not allowed here}}
5234b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)const_cast<auto>(n); // expected-error{{'auto' not allowed here}}
5334b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}}
5434b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)auto(n); // expected-error{{expected expression}}
5534b41d939a1328f484511c6002ba2456db879a29Richard Smith  (void)auto{n}; // expected-error{{expected expression}}
56baf45d31f18e6d5b3d2a33695c2af6e6cbc4ee29Anders Carlsson}
57baf45d31f18e6d5b3d2a33695c2af6e6cbc4ee29Anders Carlsson
58baf45d31f18e6d5b3d2a33695c2af6e6cbc4ee29Anders Carlssontemplate <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}}
5934b41d939a1328f484511c6002ba2456db879a29Richard Smithint ints[] = {1, 2, 3};
6034b41d939a1328f484511c6002ba2456db879a29Richard Smithtemplate <const auto (*a)[3] = &ints> class D { }; // expected-error{{'auto' not allowed in template parameter}}
6134b41d939a1328f484511c6002ba2456db879a29Richard Smithenum E : auto {}; // expected-error{{'auto' not allowed here}}
6234b41d939a1328f484511c6002ba2456db879a29Richard Smithstruct F : auto {}; // expected-error{{expected class name}}
63d37b360bf9f954af119c9805fdc79ab9d30e06c6Richard Smithtemplate<typename T = auto> struct G { }; // expected-error{{'auto' not allowed in template argument}}
6434b41d939a1328f484511c6002ba2456db879a29Richard Smith
65162e1c1b487352434552147967c3dd296ebee2f7Richard Smithusing A = auto; // expected-error{{'auto' not allowed in type alias}}
6634b41d939a1328f484511c6002ba2456db879a29Richard Smith
6754655be65585ed6618fdd7a19fa6c70efc321d3aRichard Smithauto k() -> auto; // expected-error{{'auto' not allowed in function return type}}
68