1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 234b41d939a1328f484511c6002ba2456db879a29Richard Smith 334b41d939a1328f484511c6002ba2456db879a29Richard Smithtemplate<typename T> 434b41d939a1328f484511c6002ba2456db879a29Richard Smithstruct only { 534b41d939a1328f484511c6002ba2456db879a29Richard Smith only(T); 634b41d939a1328f484511c6002ba2456db879a29Richard Smith template<typename U> only(U) = delete; // expected-note {{here}} 734b41d939a1328f484511c6002ba2456db879a29Richard Smith}; 834b41d939a1328f484511c6002ba2456db879a29Richard Smith 934b41d939a1328f484511c6002ba2456db879a29Richard Smithtemplate<typename ...T> 1034b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid f(T ...t) { 116aeaa60217e1ed11a621409acf1b53df0d14b591Eli Friedman auto x(t...); // expected-error {{is empty}} expected-error {{contains multiple expressions}} 1234b41d939a1328f484511c6002ba2456db879a29Richard Smith only<int> check = x; 1334b41d939a1328f484511c6002ba2456db879a29Richard Smith} 1434b41d939a1328f484511c6002ba2456db879a29Richard Smith 1534b41d939a1328f484511c6002ba2456db879a29Richard Smithvoid g() { 1634b41d939a1328f484511c6002ba2456db879a29Richard Smith f(); // expected-note {{here}} 1734b41d939a1328f484511c6002ba2456db879a29Richard Smith f(0); 1834b41d939a1328f484511c6002ba2456db879a29Richard Smith f(0, 1); // expected-note {{here}} 1934b41d939a1328f484511c6002ba2456db879a29Richard Smith} 2034b41d939a1328f484511c6002ba2456db879a29Richard Smith 2134b41d939a1328f484511c6002ba2456db879a29Richard Smith 2234b41d939a1328f484511c6002ba2456db879a29Richard Smithtemplate<typename T> 2334b41d939a1328f484511c6002ba2456db879a29Richard Smithbool h(T t) { 2434b41d939a1328f484511c6002ba2456db879a29Richard Smith auto a = t; 2534b41d939a1328f484511c6002ba2456db879a29Richard Smith decltype(a) b; 2634b41d939a1328f484511c6002ba2456db879a29Richard Smith a = a + b; 2734b41d939a1328f484511c6002ba2456db879a29Richard Smith 2834b41d939a1328f484511c6002ba2456db879a29Richard Smith auto p = new auto(t); 2934b41d939a1328f484511c6002ba2456db879a29Richard Smith 3034b41d939a1328f484511c6002ba2456db879a29Richard Smith only<double*> test = p; // expected-error {{conversion function from 'char *' to 'only<double *>'}} 3134b41d939a1328f484511c6002ba2456db879a29Richard Smith return p; 3234b41d939a1328f484511c6002ba2456db879a29Richard Smith} 3334b41d939a1328f484511c6002ba2456db879a29Richard Smith 3434b41d939a1328f484511c6002ba2456db879a29Richard Smithbool b = h('x'); // expected-note {{here}} 35406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith 36406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith// PR 9276 - Make sure we check auto types deduce the same 37406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith// in the case of a dependent initializer 38406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smithnamespace PR9276 { 39406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith template<typename T> 40406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith void f() { 41406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith auto i = T(), j = 0; // expected-error {{deduced as 'long' in declaration of 'i' and deduced as 'int' in declaration of 'j'}} 42406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith } 43406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith 44406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith void g() { 45406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith f<long>(); // expected-note {{here}} 46406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith f<int>(); 47406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith } 48406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith} 49406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith 50406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smithnamespace NoRepeatedDiagnostic { 51406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith template<typename T> 52406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith void f() { 53406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith 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'}} 54406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith } 55406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith // We've already diagnosed an issue. No extra diagnostics is needed for these. 56406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith template void f<int>(); 57406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith template void f<double>(); 58406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith template void f<char>(); 59406c38e8c1f105acfd438f94dfbc17af817aa4a5Richard Smith} 60