summaryrefslogtreecommitdiffstats
path: root/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp
blob: 4f230cfb8d40b0e9d37ea0d5a4732f792a008d6c (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
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
void f() {
  auto a = 0, b = 0, c = 0;
  auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}}

  auto v1 = 0, *p1 = &v1;
  auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}}

  const int k = 0;
  auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}}

  typedef int I;
  I x;
  auto xa = x, xb = 0;

  auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}}
  auto &&ra2 = +a, rb2 = b;
}

void g() {
  auto a = 0,
#if __has_feature(cxx_trailing_return)
       (*b)() -> void,
#endif
       c = 0;
  auto d = 0, // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}}
#if __has_feature(cxx_trailing_return)
       (*e)() -> void,
#endif
       f = 0.0;
}