1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
2 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
3 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
5 auto a = 0, b = 0, c = 0;
6 auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}}
8 auto v1 = 0, *p1 = &v1;
9 auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}}
12 auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}}
18 auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}}
19 auto &&ra2 = +a, rb2 = b;
23 #if __has_feature(cxx_trailing_return)
25 (*b)() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}}
28 e() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}}
30 auto x() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}}
34 #if __has_feature(cxx_decltype)
35 auto g = 0ull, h = decltype(g)(0);
39 #if __has_feature(cxx_trailing_return)
41 auto p = 0, (*q)() -> auto = F; // expected-error {{declaration with trailing return type must be the only declaration in its group}}
42 #if __cplusplus < 201402L
43 // expected-error@-2 {{'auto' not allowed in function return type}}
47 #if __cplusplus >= 201402L
48 namespace DeducedReturnType {
50 b(), // expected-error {{function with deduced return type must be the only declaration in its group}}
52 auto d(), // expected-error {{function with deduced return type must be the only declaration in its group}}
54 auto f(), // expected-error {{function with deduced return type must be the only declaration in its group}}
59 template<typename T> void h() {
60 auto a = T(), *b = &a;
61 #if __has_feature(cxx_decltype)
62 auto c = T(), d = decltype(c)(0);
65 template void h<int>();
66 template void h<unsigned long>();