1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
3 auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}}
4 auto *b = b; // expected-error{{variable 'b' declared with 'auto' type cannot appear in its own initializer}}
5 const auto c = c; // expected-error{{variable 'c' declared with 'auto' type cannot appear in its own initializer}}
6 if (auto d = d) {} // expected-error {{variable 'd' declared with 'auto' type cannot appear in its own initializer}}
7 auto e = ({ auto f = e; 0; }); // expected-error {{variable 'e' declared with 'auto' type cannot appear in its own initializer}}
11 auto a; // expected-error{{declaration of variable 'a' with type 'auto' requires an initializer}}
13 auto *b; // expected-error{{declaration of variable 'b' with type 'auto *' requires an initializer}}
15 if (auto b) {} // expected-error {{expected '='}}
16 for (;auto b;) {} // expected-error {{expected '='}}
17 while (auto b) {} // expected-error {{expected '='}}
18 if (auto b = true) { (void)b; }
21 auto n(1,2,3); // expected-error{{initializer for variable 'n' with type 'auto' contains multiple expressions}}
25 auto a = "const char [16]", *p = &a;
31 for (auto c = 0; c < b; ++c) {
35 template<typename T, typename U> struct same;
36 template<typename T> struct same<T, T> {};
40 const auto *v = &x, u = 6;
42 auto int r; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}}
44 same<decltype(x), int> xHasTypeInt;
45 same<decltype(v), const int*> vHasTypeConstIntPtr;
46 same<decltype(u), const int> uHasTypeConstInt;
47 same<decltype(y), double> yHasTypeDouble;