[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / dependent-auto.cpp
blob6d37f7ab3d1936b53bc62bfd5e83470787e83fd7
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
3 template<typename T>
4 struct only {
5 only(T);
6 template<typename U> only(U) = delete; // expected-note {{here}}
7 };
9 template<typename ...T>
10 void f(T ...t) {
11 auto x(t...); // expected-error {{is empty}} expected-error {{contains multiple expressions}}
12 only<int> check = x;
15 void g() {
16 f(); // expected-note {{here}}
17 f(0);
18 f(0, 1); // expected-note {{here}}
22 template<typename T>
23 bool h(T t) {
24 auto a = t;
25 decltype(a) b;
26 a = a + b;
28 auto p = new auto(t);
30 only<double*> test = p; // expected-error {{conversion function from 'char *' to 'only<double *>'}}
31 return p;
34 bool b = h('x'); // expected-note {{here}}
36 // PR 9276 - Make sure we check auto types deduce the same
37 // in the case of a dependent initializer
38 namespace PR9276 {
39 template<typename T>
40 void f() {
41 auto i = T(), j = 0; // expected-error {{deduced as 'long' in declaration of 'i' and deduced as 'int' in declaration of 'j'}}
44 void g() {
45 f<long>(); // expected-note {{here}}
46 f<int>();
50 namespace NoRepeatedDiagnostic {
51 template<typename T>
52 void f() {
53 auto a = 0, b = 0.0, c = T(); // expected-error {{deduced as 'int' in declaration of 'a' and deduced as 'double' in declaration of 'b'}}
55 // We've already diagnosed an issue. No extra diagnostics is needed for these.
56 template void f<int>();
57 template void f<double>();
58 template void f<char>();