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 3void f() { 4 auto a = 0, b = 0, c = 0; 5 auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}} 6 7 auto v1 = 0, *p1 = &v1; 8 auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}} 9 10 const int k = 0; 11 auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}} 12 13 typedef int I; 14 I x; 15 auto xa = x, xb = 0; 16 17 auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}} 18 auto &&ra2 = +a, rb2 = b; 19} 20 21void g() { 22 auto a = 0, 23#if __has_feature(cxx_trailing_return) 24 (*b)() -> void, 25#endif 26 c = 0; 27 auto d = 0, // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}} 28#if __has_feature(cxx_trailing_return) 29 (*e)() -> void, 30#endif 31 f = 0.0; 32 33#if __has_feature(cxx_decltype) 34 auto g = 0ull, h = decltype(g)(0); 35#endif 36} 37 38template<typename T> void h() { 39 auto a = T(), *b = &a; 40#if __has_feature(cxx_decltype) 41 auto c = T(), d = decltype(c)(0); 42#endif 43} 44template void h<int>(); 45template void h<unsigned long>(); 46