p4.cpp revision 5f31f0893d75203c326ddcd9808099bbfe34aec0
1// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
2// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
3
4template<typename T>
5struct only {
6  only(T);
7  template<typename U> only(U) = delete;
8};
9
10void f() {
11  if (auto a = true) {
12  }
13
14  switch (auto a = 0) {
15  }
16
17  while (auto a = false) {
18  }
19
20  for (; auto a = false; ) {
21  }
22
23  new const auto (0);
24  new (auto) (0.0);
25
26  int arr[] = {1, 2, 3};
27  for (auto i : arr) {
28  }
29}
30
31class X {
32  static const auto n = 'x';
33
34  auto m = 0; // expected-error {{'auto' not allowed in non-static class member}}
35};
36
37struct S {
38  static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}}
39  static const auto b = 0;
40  static const int c;
41};
42const int S::b;
43const auto S::c = 0;
44