blob: 6d37f7ab3d1936b53bc62bfd5e83470787e83fd7 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
Richard Smith34b41d92011-02-20 03:19:35 +00002
3template<typename T>
4struct only {
5 only(T);
6 template<typename U> only(U) = delete; // expected-note {{here}}
7};
8
9template<typename ...T>
10void f(T ...t) {
Eli Friedman6aeaa602012-01-05 22:34:08 +000011 auto x(t...); // expected-error {{is empty}} expected-error {{contains multiple expressions}}
Richard Smith34b41d92011-02-20 03:19:35 +000012 only<int> check = x;
13}
14
15void g() {
16 f(); // expected-note {{here}}
17 f(0);
18 f(0, 1); // expected-note {{here}}
19}
20
21
22template<typename T>
23bool h(T t) {
24 auto a = t;
25 decltype(a) b;
26 a = a + b;
27
28 auto p = new auto(t);
29
30 only<double*> test = p; // expected-error {{conversion function from 'char *' to 'only<double *>'}}
31 return p;
32}
33
34bool b = h('x'); // expected-note {{here}}
Richard Smith406c38e2011-02-23 00:37:57 +000035
36// PR 9276 - Make sure we check auto types deduce the same
37// in the case of a dependent initializer
38namespace 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'}}
42 }
43
44 void g() {
45 f<long>(); // expected-note {{here}}
46 f<int>();
47 }
48}
49
50namespace 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'}}
54 }
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>();
59}