summaryrefslogtreecommitdiffstats
path: root/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
blob: d5d0952aa858b5fd15efde5f7d7f38b164a428a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions

template<typename T>
struct only {
  only(T);
  template<typename U> only(U) = delete;
};

void f() {
  if (auto a = true) {
  }

  switch (auto a = 0) {
  }

  while (auto a = false) {
  }

  for (; auto a = false; ) {
  }

  new const auto (0);
  new (auto) (0.0);

  int arr[] = {1, 2, 3};
  for (auto i : arr) {
  }
}

class X {
  static const auto n = 'x';

  auto m = 0; // expected-error {{'auto' not allowed in non-static class member}}
};

struct S {
  static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}}
  static const auto b = 0;
  static const int c;
};
const int S::b;
const auto S::c = 0;