dr3xx.cpp 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  2. // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  3. // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  4. // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
  5. namespace dr300 { // dr300: yes
  6. template<typename R, typename A> void f(R (&)(A)) {}
  7. int g(int);
  8. void h() { f(g); }
  9. }
  10. namespace dr301 { // dr301: yes
  11. // see also dr38
  12. struct S;
  13. template<typename T> void operator+(T, T);
  14. void operator-(S, S);
  15. void f() {
  16. bool a = (void(*)(S, S))operator+<S> <
  17. (void(*)(S, S))operator+<S>;
  18. bool b = (void(*)(S, S))operator- <
  19. (void(*)(S, S))operator-;
  20. bool c = (void(*)(S, S))operator+ <
  21. (void(*)(S, S))operator-; // expected-error {{expected '>'}}
  22. }
  23. template<typename T> void f() {
  24. typename T::template operator+<int> a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}}
  25. // FIXME: This shouldn't say (null).
  26. class T::template operator+<int> b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}}
  27. enum T::template operator+<int> c; // expected-error {{expected identifier}} expected-error {{does not declare anything}}
  28. enum T::template operator+<int>::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}}
  29. enum T::template X<int>::E e;
  30. T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}}
  31. T::template operator+<int>(0); // ok
  32. }
  33. template<typename T> class operator&<T*> {}; // expected-error +{{}}
  34. template<typename T> class T::operator& {}; // expected-error +{{}}
  35. template<typename T> class S::operator&<T*> {}; // expected-error +{{}}
  36. }
  37. namespace dr302 { // dr302: yes
  38. struct A { A(); ~A(); };
  39. #if __cplusplus < 201103L
  40. struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}}
  41. const int n; // expected-note {{declared here}}
  42. A a;
  43. } b = B(); // expected-note {{first required here}}
  44. // Trivial default constructor C::C() is not called here.
  45. struct C {
  46. const int n;
  47. } c = C();
  48. #else
  49. struct B {
  50. const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
  51. A a;
  52. } b = B(); // expected-error {{call to implicitly-deleted default constructor}}
  53. // C::C() is called here, because even though it's trivial, it's deleted.
  54. struct C {
  55. const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
  56. } c = C(); // expected-error {{call to implicitly-deleted default constructor}}
  57. struct D {
  58. const int n = 0;
  59. } d = D();
  60. #endif
  61. }
  62. // dr303: na
  63. namespace dr304 { // dr304: yes
  64. typedef int &a;
  65. int n = a(); // expected-error {{requires an initializer}}
  66. struct S { int &b; };
  67. int m = S().b;
  68. #if __cplusplus < 201103L
  69. // expected-error@-3 {{requires an initializer}}
  70. // expected-note@-3 {{in value-initialization}}
  71. #else
  72. // expected-error@-5 {{deleted}}
  73. // expected-note@-7 {{reference}}
  74. #endif
  75. }
  76. namespace dr305 { // dr305: no
  77. struct A {
  78. typedef A C;
  79. };
  80. void f(A *a) {
  81. struct A {};
  82. a->~A();
  83. a->~C();
  84. }
  85. typedef A B;
  86. void g(B *b) {
  87. b->~B();
  88. b->~C();
  89. }
  90. void h(B *b) {
  91. struct B {}; // expected-note {{declared here}}
  92. b->~B(); // expected-error {{does not match}}
  93. }
  94. template<typename T> struct X {};
  95. void i(X<int>* x) {
  96. struct X {};
  97. x->~X<int>();
  98. x->~X();
  99. x->~X<char>(); // expected-error {{no member named}}
  100. }
  101. #if __cplusplus >= 201103L
  102. struct Y {
  103. template<typename T> using T1 = Y;
  104. };
  105. template<typename T> using T2 = Y;
  106. void j(Y *y) {
  107. y->~T1<int>();
  108. y->~T2<int>();
  109. }
  110. struct Z {
  111. template<typename T> using T2 = T;
  112. };
  113. void k(Z *z) {
  114. // FIXME: This diagnostic is terrible.
  115. z->~T1<int>(); // expected-error {{'T1' following the 'template' keyword does not refer to a template}} expected-error +{{}}
  116. z->~T2<int>(); // expected-error {{no member named '~int'}}
  117. z->~T2<Z>();
  118. }
  119. // FIXME: This is valid.
  120. namespace Q {
  121. template<typename A> struct R {};
  122. }
  123. template<typename A> using R = Q::R<int>;
  124. void qr(Q::R<int> x) { x.~R<char>(); } // expected-error {{no member named}}
  125. #endif
  126. }
  127. namespace dr306 { // dr306: no
  128. // FIXME: dup 39
  129. // FIXME: This should be accepted.
  130. struct A { struct B {}; }; // expected-note 2{{member}}
  131. struct C { typedef A::B B; }; // expected-note {{member}}
  132. struct D : A, A::B, C {};
  133. D::B b; // expected-error {{found in multiple base classes of different types}}
  134. }
  135. // dr307: na
  136. namespace dr308 { // dr308: yes
  137. // This is mostly an ABI library issue.
  138. struct A {};
  139. struct B : A {};
  140. struct C : A {};
  141. struct D : B, C {};
  142. void f() {
  143. try {
  144. throw D();
  145. } catch (const A&) { // expected-note {{for type 'const dr308::A &'}}
  146. // unreachable
  147. } catch (const B&) { // expected-warning {{exception of type 'const dr308::B &' will be caught by earlier handler}}
  148. // get here instead
  149. }
  150. }
  151. }
  152. // dr309: dup 485
  153. namespace dr311 { // dr311: yes
  154. namespace X { namespace Y {} }
  155. namespace X::Y {}
  156. #if __cplusplus <= 201402L
  157. // expected-error@-2 {{define each namespace separately}}
  158. #endif
  159. namespace X {
  160. namespace X::Y {}
  161. #if __cplusplus <= 201402L
  162. // expected-error@-2 {{define each namespace separately}}
  163. #endif
  164. }
  165. // FIXME: The diagnostics here are not very good.
  166. namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}}
  167. }
  168. // dr312: dup 616
  169. namespace dr313 { // dr313: dup 299 c++11
  170. struct A { operator int() const; };
  171. int *p = new int[A()];
  172. #if __cplusplus < 201103L
  173. // FIXME: should this be available in c++98 mode? expected-error@-2 {{extension}}
  174. #endif
  175. }
  176. namespace dr314 { // FIXME 314: dup 1710
  177. template<typename T> struct A {
  178. template<typename U> struct B {};
  179. };
  180. template<typename T> struct C : public A<T>::template B<T> {
  181. C() : A<T>::template B<T>() {}
  182. };
  183. }
  184. // dr315: na
  185. // dr316: sup 1004
  186. namespace dr317 { // dr317: 3.5
  187. void f() {} // expected-note {{previous}}
  188. inline void f(); // expected-error {{inline declaration of 'f' follows non-inline definition}}
  189. int g();
  190. int n = g();
  191. inline int g() { return 0; }
  192. int h();
  193. int m = h();
  194. int h() { return 0; } // expected-note {{previous}}
  195. inline int h(); // expected-error {{inline declaration of 'h' follows non-inline definition}}
  196. }
  197. namespace dr318 { // dr318: sup 1310
  198. struct A {};
  199. struct A::A a;
  200. }
  201. namespace dr319 { // dr319: no
  202. // FIXME: dup dr389
  203. // FIXME: We don't have a diagnostic for a name with linkage
  204. // having a type without linkage.
  205. typedef struct {
  206. int i;
  207. } *ps;
  208. extern "C" void f(ps);
  209. void g(ps); // FIXME: ill-formed, type 'ps' has no linkage
  210. static enum { e } a1;
  211. enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage
  212. enum { n1 = 1u };
  213. typedef int (*pa)[n1];
  214. pa parr; // ok, type has linkage despite using 'n1'
  215. template<typename> struct X {};
  216. void f() {
  217. struct A { int n; };
  218. extern A a; // FIXME: ill-formed
  219. X<A> xa;
  220. typedef A B;
  221. extern B b; // FIXME: ill-formed
  222. X<B> xb;
  223. const int n = 1;
  224. typedef int (*C)[n];
  225. extern C c; // ok
  226. X<C> xc;
  227. }
  228. #if __cplusplus < 201103L
  229. // expected-error@-12 {{uses local type 'A'}}
  230. // expected-error@-9 {{uses local type 'A'}}
  231. #endif
  232. }
  233. namespace dr320 { // dr320: yes
  234. #if __cplusplus >= 201103L
  235. struct X {
  236. constexpr X() {}
  237. constexpr X(const X &x) : copies(x.copies + 1) {}
  238. unsigned copies = 0;
  239. };
  240. constexpr X f(X x) { return x; }
  241. constexpr unsigned g(X x) { return x.copies; }
  242. static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value");
  243. #endif
  244. }
  245. namespace dr321 { // dr321: dup 557
  246. namespace N {
  247. template<int> struct A {
  248. template<int> struct B;
  249. };
  250. template<> template<> struct A<0>::B<0>;
  251. void f(A<0>::B<0>);
  252. }
  253. template<> template<> struct N::A<0>::B<0> {};
  254. template<typename T> void g(T t) { f(t); }
  255. template void g(N::A<0>::B<0>);
  256. namespace N {
  257. template<typename> struct I { friend bool operator==(const I&, const I&); };
  258. }
  259. N::I<int> i, j;
  260. bool x = i == j;
  261. }
  262. namespace dr322 { // dr322: yes
  263. struct A {
  264. template<typename T> operator T&();
  265. } a;
  266. int &r = static_cast<int&>(a);
  267. int &s = a;
  268. }
  269. // dr323: no
  270. namespace dr324 { // dr324: yes
  271. struct S { int n : 1; } s; // expected-note 3{{bit-field is declared here}}
  272. int &a = s.n; // expected-error {{non-const reference cannot bind to bit-field}}
  273. int *b = &s.n; // expected-error {{address of bit-field}}
  274. int &c = (s.n = 0); // expected-error {{non-const reference cannot bind to bit-field}}
  275. int *d = &(s.n = 0); // expected-error {{address of bit-field}}
  276. int &e = true ? s.n : s.n; // expected-error {{non-const reference cannot bind to bit-field}}
  277. int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}}
  278. int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}}
  279. int *h = &(void(), s.n); // expected-error {{address of bit-field}}
  280. int *i = &++s.n; // expected-error {{address of bit-field}}
  281. }
  282. namespace dr326 { // dr326: yes
  283. struct S {};
  284. int test[__is_trivially_constructible(S, const S&) ? 1 : -1];
  285. }
  286. namespace dr327 { // dr327: dup 538
  287. struct A;
  288. class A {};
  289. class B;
  290. struct B {};
  291. }
  292. namespace dr328 { // dr328: yes
  293. struct A; // expected-note 3{{forward declaration}}
  294. struct B { A a; }; // expected-error {{incomplete}}
  295. template<typename> struct C { A a; }; // expected-error {{incomplete}}
  296. A *p = new A[0]; // expected-error {{incomplete}}
  297. }
  298. namespace dr329 { // dr329: 3.5
  299. struct B {};
  300. template<typename T> struct A : B {
  301. friend void f(A a) { g(a); }
  302. friend void h(A a) { g(a); } // expected-error {{undeclared}}
  303. friend void i(B b) {} // expected-error {{redefinition}} expected-note {{previous}}
  304. };
  305. A<int> a;
  306. A<char> b; // expected-note {{instantiation}}
  307. void test() {
  308. h(a); // expected-note {{instantiation}}
  309. }
  310. }
  311. namespace dr331 { // dr331: yes
  312. struct A {
  313. A(volatile A&); // expected-note {{candidate}}
  314. } const a, b(a); // expected-error {{no matching constructor}}
  315. }
  316. namespace dr332 { // dr332: dup 577
  317. void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}}
  318. void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}}
  319. void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}}
  320. }
  321. namespace dr333 { // dr333: yes
  322. int n = 0;
  323. int f(int(n));
  324. int g((int(n)));
  325. int h = f(g);
  326. }
  327. namespace dr334 { // dr334: yes
  328. template<typename T> void f() {
  329. T x;
  330. f((x, 123));
  331. }
  332. struct S {
  333. friend S operator,(S, int);
  334. friend void f(S);
  335. };
  336. template void f<S>();
  337. }
  338. // dr335: no
  339. namespace dr336 { // dr336: yes
  340. namespace Pre {
  341. template<class T1> class A {
  342. template<class T2> class B {
  343. template<class T3> void mf1(T3);
  344. void mf2();
  345. };
  346. };
  347. template<> template<class X> class A<int>::B {};
  348. template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} // expected-error {{does not match}}
  349. template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}}
  350. }
  351. namespace Post {
  352. template<class T1> class A {
  353. template<class T2> class B {
  354. template<class T3> void mf1(T3);
  355. void mf2();
  356. };
  357. };
  358. template<> template<class X> class A<int>::B {
  359. template<class T> void mf1(T);
  360. };
  361. template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {}
  362. // FIXME: This diagnostic isn't very good.
  363. template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}}
  364. }
  365. }
  366. namespace dr337 { // dr337: yes
  367. template<typename T> void f(T (*)[1]);
  368. template<typename T> int &f(...);
  369. struct A { virtual ~A() = 0; };
  370. int &r = f<A>(0);
  371. // FIXME: The language rules here are completely broken. We cannot determine
  372. // whether an incomplete type is abstract. See DR1640, which will probably
  373. // supersede this one and remove this rule.
  374. struct B;
  375. int &s = f<B>(0); // expected-error {{of type 'void'}}
  376. struct B { virtual ~B() = 0; };
  377. }
  378. namespace dr339 { // dr339: yes
  379. template <int I> struct A { static const int value = I; };
  380. char xxx(int);
  381. char (&xxx(float))[2];
  382. template<class T> A<sizeof(xxx((T)0))> f(T) {} // expected-note {{candidate}}
  383. void test() {
  384. A<1> a = f(0);
  385. A<2> b = f(0.0f);
  386. A<3> c = f("foo"); // expected-error {{no matching function}}
  387. }
  388. char f(int);
  389. int f(...);
  390. template <class T> struct conv_int {
  391. static const bool value = sizeof(f(T())) == 1;
  392. };
  393. template <class T> bool conv_int2(A<sizeof(f(T()))> p);
  394. template<typename T> A<sizeof(f(T()))> make_A();
  395. int a[conv_int<char>::value ? 1 : -1];
  396. bool b = conv_int2<char>(A<1>());
  397. A<1> c = make_A<char>();
  398. }
  399. namespace dr340 { // dr340: yes
  400. struct A { A(int); };
  401. struct B { B(A, A, int); };
  402. int x, y;
  403. B b(A(x), A(y), 3);
  404. }
  405. namespace dr341 { // dr341: sup 1708
  406. namespace A {
  407. int n;
  408. extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}}
  409. }
  410. namespace B {
  411. extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}}
  412. }
  413. extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}}
  414. }
  415. int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}}
  416. int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}}
  417. int dr341_c; // expected-note {{declared in global scope here}}
  418. int dr341_d; // expected-note {{declared in global scope here}}
  419. namespace dr341 {
  420. extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}}
  421. extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}}
  422. namespace A { extern "C" int dr341_e; } // expected-note {{previous}}
  423. namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}}
  424. }
  425. // dr342: na
  426. namespace dr343 { // FIXME 343: no
  427. // FIXME: dup 1710
  428. template<typename T> struct A {
  429. template<typename U> struct B {};
  430. };
  431. // FIXME: In these contexts, the 'template' keyword is optional.
  432. template<typename T> struct C : public A<T>::B<T> { // expected-error {{use 'template'}}
  433. C() : A<T>::B<T>() {} // expected-error {{use 'template'}}
  434. };
  435. }
  436. namespace dr344 { // dr344: dup 1435
  437. struct A { inline virtual ~A(); };
  438. struct B { friend A::~A(); };
  439. }
  440. namespace dr345 { // dr345: yes
  441. struct A {
  442. struct X {};
  443. int X; // expected-note {{here}}
  444. };
  445. struct B {
  446. struct X {};
  447. };
  448. template <class T> void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}}
  449. void f(A a, B b) {
  450. f(b);
  451. f(a); // expected-note {{instantiation}}
  452. }
  453. }
  454. // dr346: na
  455. namespace dr347 { // dr347: yes
  456. struct base {
  457. struct nested;
  458. static int n;
  459. static void f();
  460. void g();
  461. };
  462. struct derived : base {};
  463. struct derived::nested {}; // expected-error {{no struct named 'nested'}}
  464. int derived::n; // expected-error {{no member named 'n'}}
  465. void derived::f() {} // expected-error {{does not match any}}
  466. void derived::g() {} // expected-error {{does not match any}}
  467. }
  468. // dr348: na
  469. namespace dr349 { // dr349: no
  470. struct A {
  471. template <class T> operator T ***() {
  472. int ***p = 0;
  473. return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}}
  474. }
  475. };
  476. // FIXME: This is valid.
  477. A a;
  478. const int *const *const *p1 = a; // expected-note {{in instantiation of}}
  479. struct B {
  480. template <class T> operator T ***() {
  481. const int ***p = 0;
  482. return p;
  483. }
  484. };
  485. // FIXME: This is invalid.
  486. B b;
  487. const int *const *const *p2 = b;
  488. }
  489. // dr351: na
  490. namespace dr352 { // dr352: yes
  491. namespace example1 {
  492. namespace A {
  493. enum E {};
  494. template<typename R, typename A> void foo(E, R (*)(A)); // expected-note 2{{couldn't infer template argument 'R'}}
  495. }
  496. template<typename T> void arg(T);
  497. template<typename T> int arg(T) = delete; // expected-note {{here}} expected-error 0-1{{extension}}
  498. void f(A::E e) {
  499. foo(e, &arg); // expected-error {{no matching function}}
  500. using A::foo;
  501. foo<int, int>(e, &arg); // expected-error {{deleted}}
  502. }
  503. int arg(int);
  504. void g(A::E e) {
  505. foo(e, &arg); // expected-error {{no matching function}}
  506. using A::foo;
  507. foo<int, int>(e, &arg); // ok, uses non-template
  508. }
  509. }
  510. namespace contexts {
  511. template<int I> void f1(int (&)[I]);
  512. template<int I> void f2(int (&)[I+1]); // expected-note {{couldn't infer}}
  513. template<int I> void f3(int (&)[I+1], int (&)[I]);
  514. void f() {
  515. int a[4];
  516. int b[3];
  517. f1(a);
  518. f2(a); // expected-error {{no matching function}}
  519. f3(a, b);
  520. }
  521. template<int I> struct S {};
  522. template<int I> void g1(S<I>);
  523. template<int I> void g2(S<I+1>); // expected-note {{couldn't infer}}
  524. template<int I> void g3(S<I+1>, S<I>);
  525. void g() {
  526. S<4> a;
  527. S<3> b;
  528. g1(a);
  529. g2(a); // expected-error {{no matching function}}
  530. g3(a, b);
  531. }
  532. template<typename T> void h1(T = 0); // expected-note {{couldn't infer}}
  533. template<typename T> void h2(T, T = 0);
  534. void h() {
  535. h1(); // expected-error {{no matching function}}
  536. h1(0);
  537. h1<int>();
  538. h2(0);
  539. }
  540. template<typename T> int tmpl(T);
  541. template<typename R, typename A> void i1(R (*)(A)); // expected-note 3{{couldn't infer}}
  542. template<typename R, typename A> void i2(R, A, R (*)(A)); // expected-note {{not viable}}
  543. void i() {
  544. extern int single(int);
  545. i1(single);
  546. i2(0, 0, single);
  547. extern int ambig(float), ambig(int);
  548. i1(ambig); // expected-error {{no matching function}}
  549. i2(0, 0, ambig);
  550. extern void no_match(float), no_match(int);
  551. i1(no_match); // expected-error {{no matching function}}
  552. i2(0, 0, no_match); // expected-error {{no matching function}}
  553. i1(tmpl); // expected-error {{no matching function}}
  554. i2(0, 0, tmpl);
  555. }
  556. }
  557. template<typename T> struct is_int;
  558. template<> struct is_int<int> {};
  559. namespace example2 {
  560. template<typename T> int f(T (*p)(T)) { is_int<T>(); }
  561. int g(int);
  562. int g(char);
  563. int i = f(g);
  564. }
  565. namespace example3 {
  566. template<typename T> int f(T, T (*p)(T)) { is_int<T>(); }
  567. int g(int);
  568. char g(char);
  569. int i = f(1, g);
  570. }
  571. namespace example4 {
  572. template <class T> int f(T, T (*p)(T)) { is_int<T>(); }
  573. char g(char);
  574. template <class T> T g(T);
  575. int i = f(1, g);
  576. }
  577. namespace example5 {
  578. template<int I> class A {};
  579. template<int I> void g(A<I+1>); // expected-note {{couldn't infer}}
  580. template<int I> void f(A<I>, A<I+1>);
  581. void h(A<1> a1, A<2> a2) {
  582. g(a1); // expected-error {{no matching function}}
  583. g<0>(a1);
  584. f(a1, a2);
  585. }
  586. }
  587. }
  588. // dr353 needs an IRGen test.
  589. namespace dr354 { // dr354: yes c++11
  590. // FIXME: Should we allow this in C++98 too?
  591. struct S {};
  592. template<int*> struct ptr {}; // expected-note 0-4{{here}}
  593. ptr<0> p0;
  594. ptr<(int*)0> p1;
  595. ptr<(float*)0> p2;
  596. ptr<(int S::*)0> p3;
  597. #if __cplusplus < 201103L
  598. // expected-error@-5 {{does not refer to any decl}}
  599. // expected-error@-5 {{does not refer to any decl}}
  600. // expected-error@-5 {{does not refer to any decl}}
  601. // expected-error@-5 {{does not refer to any decl}}
  602. #elif __cplusplus <= 201402L
  603. // expected-error@-10 {{must be cast}}
  604. // ok
  605. // expected-error@-10 {{does not match}}
  606. // expected-error@-10 {{does not match}}
  607. #else
  608. // expected-error@-15 {{conversion from 'int' to 'int *' is not allowed}}
  609. // ok
  610. // expected-error@-15 {{'float *' is not implicitly convertible to 'int *'}}
  611. // expected-error@-15 {{'int dr354::S::*' is not implicitly convertible to 'int *'}}
  612. #endif
  613. template<int*> int both();
  614. template<int> int both();
  615. int b0 = both<0>();
  616. int b1 = both<(int*)0>();
  617. #if __cplusplus < 201103L
  618. // expected-error@-2 {{no matching function}}
  619. // expected-note@-6 {{candidate}}
  620. // expected-note@-6 {{candidate}}
  621. #endif
  622. template<int S::*> struct ptr_mem {}; // expected-note 0-4{{here}}
  623. ptr_mem<0> m0;
  624. ptr_mem<(int S::*)0> m1;
  625. ptr_mem<(float S::*)0> m2;
  626. ptr_mem<(int *)0> m3;
  627. #if __cplusplus < 201103L
  628. // expected-error@-5 {{cannot be converted}}
  629. // expected-error@-5 {{is not a pointer to member constant}}
  630. // expected-error@-5 {{cannot be converted}}
  631. // expected-error@-5 {{cannot be converted}}
  632. #elif __cplusplus <= 201402L
  633. // expected-error@-10 {{must be cast}}
  634. // ok
  635. // expected-error@-10 {{does not match}}
  636. // expected-error@-10 {{does not match}}
  637. #else
  638. // expected-error@-15 {{conversion from 'int' to 'int dr354::S::*' is not allowed}}
  639. // ok
  640. // expected-error@-15 {{'float dr354::S::*' is not implicitly convertible to 'int dr354::S::*'}}
  641. // expected-error@-15 {{'int *' is not implicitly convertible to 'int dr354::S::*'}}
  642. #endif
  643. }
  644. struct dr355_S; // dr355: yes
  645. struct ::dr355_S {}; // expected-warning {{extra qualification}}
  646. namespace dr355 { struct ::dr355_S s; }
  647. // dr356: na
  648. namespace dr357 { // dr357: yes
  649. template<typename T> struct A {
  650. void f() const; // expected-note {{const qualified}}
  651. };
  652. template<typename T> void A<T>::f() {} // expected-error {{does not match}}
  653. struct B {
  654. template<typename T> void f();
  655. };
  656. template<typename T> void B::f() const {} // expected-error {{does not match}}
  657. }
  658. namespace dr358 { // dr358: yes
  659. extern "C" void dr358_f();
  660. namespace N {
  661. int var;
  662. extern "C" void dr358_f() { var = 10; }
  663. }
  664. }
  665. namespace dr359 { // dr359: yes
  666. // Note, the example in the DR is wrong; it doesn't contain an anonymous
  667. // union.
  668. struct E {
  669. union {
  670. struct {
  671. int x;
  672. } s;
  673. } v;
  674. union {
  675. struct { // expected-error {{extension}}
  676. int x;
  677. } s;
  678. struct S { // expected-error {{types cannot be declared in an anonymous union}}
  679. int x;
  680. } t;
  681. union { // expected-error {{extension}}
  682. int u;
  683. };
  684. };
  685. };
  686. }
  687. // dr362: na
  688. // dr363: na
  689. namespace dr364 { // dr364: yes
  690. struct S {
  691. static void f(int);
  692. void f(char);
  693. };
  694. void g() {
  695. S::f('a'); // expected-error {{call to non-static}}
  696. S::f(0);
  697. }
  698. }
  699. #if "foo" // expected-error {{invalid token}} dr366: yes
  700. #endif
  701. namespace dr367 { // dr367: yes
  702. // FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global
  703. // array as being a VLA!
  704. int a[true ? throw 0 : 4]; // expected-error 2{{variable length array}}
  705. int b[true ? 4 : throw 0];
  706. int c[true ? *new int : 4]; // expected-error 2{{variable length array}}
  707. int d[true ? 4 : *new int];
  708. #if __cplusplus < 201103L
  709. // expected-error@-4 {{variable length array}} expected-error@-4 {{constant expression}}
  710. // expected-error@-3 {{variable length array}} expected-error@-3 {{constant expression}}
  711. #endif
  712. }
  713. namespace dr368 { // dr368: yes
  714. template<typename T, T> struct S {}; // expected-note {{here}}
  715. template<typename T> int f(S<T, T()> *); // expected-error {{function type}}
  716. //template<typename T> int g(S<T, (T())> *); // FIXME: crashes clang
  717. template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{cannot have type 'dr368::X'}}
  718. struct X {};
  719. int n = g<X>(0); // expected-error {{no matching}}
  720. }
  721. // dr370: na
  722. namespace dr372 { // dr372: no
  723. namespace example1 {
  724. template<typename T> struct X {
  725. protected:
  726. typedef T Type; // expected-note 2{{protected}}
  727. };
  728. template<typename T> struct Y {};
  729. // FIXME: These two are valid; deriving from T1<T> gives Z1 access to
  730. // the protected member T1<T>::Type.
  731. template<typename T,
  732. template<typename> class T1,
  733. template<typename> class T2> struct Z1 :
  734. T1<T>,
  735. T2<typename T1<T>::Type> {}; // expected-error {{protected}}
  736. template<typename T,
  737. template<typename> class T1,
  738. template<typename> class T2> struct Z2 :
  739. T2<typename T1<T>::Type>, // expected-error {{protected}}
  740. T1<T> {};
  741. Z1<int, X, Y> z1; // expected-note {{instantiation of}}
  742. Z2<int, X, Y> z2; // expected-note {{instantiation of}}
  743. }
  744. namespace example2 {
  745. struct X {
  746. private:
  747. typedef int Type; // expected-note {{private}}
  748. };
  749. template<typename T> struct A {
  750. typename T::Type t; // expected-error {{private}}
  751. };
  752. A<X> ax; // expected-note {{instantiation of}}
  753. }
  754. namespace example3 {
  755. struct A {
  756. protected:
  757. typedef int N; // expected-note 2{{protected}}
  758. };
  759. template<typename T> struct B {};
  760. template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}}
  761. template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}}
  762. C<A> x; // expected-note {{instantiation of}}
  763. D<A> y; // expected-note {{instantiation of}}
  764. }
  765. namespace example4 {
  766. class A {
  767. class B {};
  768. friend class X;
  769. };
  770. struct X : A::B {
  771. A::B mx;
  772. class Y {
  773. A::B my;
  774. };
  775. };
  776. }
  777. }
  778. namespace dr373 { // dr373: no
  779. // FIXME: This is valid.
  780. namespace X { int dr373; } // expected-note 2{{here}}
  781. struct dr373 { // expected-note {{here}}
  782. void f() {
  783. using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
  784. int k = dr373; // expected-error {{does not refer to a value}}
  785. namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
  786. k = Y::dr373;
  787. }
  788. };
  789. }
  790. namespace dr374 { // dr374: yes c++11
  791. namespace N {
  792. template<typename T> void f();
  793. template<typename T> struct A { void f(); };
  794. }
  795. template<> void N::f<char>() {}
  796. template<> void N::A<char>::f() {}
  797. template<> struct N::A<int> {};
  798. #if __cplusplus < 201103L
  799. // expected-error@-4 {{extension}} expected-note@-7 {{here}}
  800. // expected-error@-4 {{extension}} expected-note@-7 {{here}}
  801. // expected-error@-4 {{extension}} expected-note@-8 {{here}}
  802. #endif
  803. }
  804. // dr375: dup 345
  805. // dr376: na
  806. namespace dr377 { // dr377: yes
  807. enum E { // expected-error {{enumeration values exceed range of largest integer}}
  808. a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}}
  809. b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}}
  810. };
  811. }
  812. // dr378: dup 276
  813. // dr379: na
  814. namespace dr381 { // dr381: yes
  815. struct A {
  816. int a;
  817. };
  818. struct B : virtual A {};
  819. struct C : B {};
  820. struct D : B {};
  821. struct E : public C, public D {};
  822. struct F : public A {};
  823. void f() {
  824. E e;
  825. e.B::a = 0; // expected-error {{ambiguous conversion}}
  826. F f;
  827. f.A::a = 1;
  828. }
  829. }
  830. namespace dr382 { // dr382: yes c++11
  831. // FIXME: Should we allow this in C++98 mode?
  832. struct A { typedef int T; };
  833. typename A::T t;
  834. typename dr382::A a;
  835. #if __cplusplus < 201103L
  836. // expected-error@-3 {{occurs outside of a template}}
  837. // expected-error@-3 {{occurs outside of a template}}
  838. #endif
  839. typename A b; // expected-error {{expected a qualified name}}
  840. }
  841. namespace dr383 { // dr383: yes
  842. struct A { A &operator=(const A&); };
  843. struct B { ~B(); };
  844. union C { C &operator=(const C&); };
  845. union D { ~D(); };
  846. int check[(__is_pod(A) || __is_pod(B) || __is_pod(C) || __is_pod(D)) ? -1 : 1];
  847. }
  848. namespace dr384 { // dr384: yes
  849. namespace N1 {
  850. template<typename T> struct Base {};
  851. template<typename T> struct X {
  852. struct Y : public Base<T> {
  853. Y operator+(int) const;
  854. };
  855. Y f(unsigned i) { return Y() + i; }
  856. };
  857. }
  858. namespace N2 {
  859. struct Z {};
  860. template<typename T> int *operator+(T, unsigned);
  861. }
  862. int main() {
  863. N1::X<N2::Z> v;
  864. v.f(0);
  865. }
  866. }
  867. namespace dr385 { // dr385: yes
  868. struct A { protected: void f(); };
  869. struct B : A { using A::f; };
  870. struct C : A { void g(B b) { b.f(); } };
  871. void h(B b) { b.f(); }
  872. struct D { int n; }; // expected-note {{member}}
  873. struct E : protected D {}; // expected-note 2{{protected}}
  874. struct F : E { friend int i(E); };
  875. int i(E e) { return e.n; } // expected-error {{protected base}} expected-error {{protected member}}
  876. }
  877. namespace dr387 { // dr387: yes
  878. namespace old {
  879. template<typename T> class number {
  880. number(int); // expected-note 2{{here}}
  881. friend number gcd(number &x, number &y) {}
  882. };
  883. void g() {
  884. number<double> a(3), b(4); // expected-error 2{{private}}
  885. a = gcd(a, b);
  886. b = gcd(3, 4); // expected-error {{undeclared}}
  887. }
  888. }
  889. namespace newer {
  890. template <typename T> class number {
  891. public:
  892. number(int);
  893. friend number gcd(number x, number y) { return 0; }
  894. };
  895. void g() {
  896. number<double> a(3), b(4);
  897. a = gcd(a, b);
  898. b = gcd(3, 4); // expected-error {{undeclared}}
  899. }
  900. }
  901. }
  902. // FIXME: dr388 needs codegen test
  903. namespace dr389 { // dr389: no
  904. struct S {
  905. typedef struct {} A;
  906. typedef enum {} B;
  907. typedef struct {} const C; // expected-note 0-2{{here}}
  908. typedef enum {} const D; // expected-note 0-1{{here}}
  909. };
  910. template<typename> struct T {};
  911. struct WithLinkage1 {};
  912. enum WithLinkage2 {};
  913. typedef struct {} *WithLinkage3a, WithLinkage3b;
  914. typedef enum {} WithLinkage4a, *WithLinkage4b;
  915. typedef S::A WithLinkage5;
  916. typedef const S::B WithLinkage6;
  917. typedef int WithLinkage7;
  918. typedef void (*WithLinkage8)(WithLinkage2 WithLinkage1::*, WithLinkage5 *);
  919. typedef T<WithLinkage5> WithLinkage9;
  920. typedef struct {} *WithoutLinkage1; // expected-note 0-1{{here}}
  921. typedef enum {} const WithoutLinkage2; // expected-note 0-1{{here}}
  922. // These two types don't have linkage even though they are externally visible
  923. // and the ODR requires them to be merged across TUs.
  924. typedef S::C WithoutLinkage3;
  925. typedef S::D WithoutLinkage4;
  926. typedef void (*WithoutLinkage5)(int (WithoutLinkage3::*)(char));
  927. #if __cplusplus >= 201103L
  928. // This has linkage even though its template argument does not.
  929. // FIXME: This is probably a defect.
  930. typedef T<WithoutLinkage1> WithLinkage10;
  931. #else
  932. typedef int WithLinkage10; // dummy
  933. typedef T<WithLinkage1> GoodArg1;
  934. typedef T<WithLinkage2> GoodArg2;
  935. typedef T<WithLinkage3a> GoodArg3a;
  936. typedef T<WithLinkage3b> GoodArg3b;
  937. typedef T<WithLinkage4a> GoodArg4a;
  938. typedef T<WithLinkage4b> GoodArg4b;
  939. typedef T<WithLinkage5> GoodArg5;
  940. typedef T<WithLinkage6> GoodArg6;
  941. typedef T<WithLinkage7> GoodArg7;
  942. typedef T<WithLinkage8> GoodArg8;
  943. typedef T<WithLinkage9> GoodArg9;
  944. typedef T<WithoutLinkage1> BadArg1; // expected-error{{template argument uses}}
  945. typedef T<WithoutLinkage2> BadArg2; // expected-error{{template argument uses}}
  946. typedef T<WithoutLinkage3> BadArg3; // expected-error{{template argument uses}}
  947. typedef T<WithoutLinkage4> BadArg4; // expected-error{{template argument uses}}
  948. typedef T<WithoutLinkage5> BadArg5; // expected-error{{template argument uses}}
  949. #endif
  950. extern WithLinkage1 withLinkage1;
  951. extern WithLinkage2 withLinkage2;
  952. extern WithLinkage3a withLinkage3a;
  953. extern WithLinkage3b withLinkage3b;
  954. extern WithLinkage4a withLinkage4a;
  955. extern WithLinkage4b withLinkage4b;
  956. extern WithLinkage5 withLinkage5;
  957. extern WithLinkage6 withLinkage6;
  958. extern WithLinkage7 withLinkage7;
  959. extern WithLinkage8 withLinkage8;
  960. extern WithLinkage9 withLinkage9;
  961. extern WithLinkage10 withLinkage10;
  962. // FIXME: These are all ill-formed.
  963. extern WithoutLinkage1 withoutLinkage1;
  964. extern WithoutLinkage2 withoutLinkage2;
  965. extern WithoutLinkage3 withoutLinkage3;
  966. extern WithoutLinkage4 withoutLinkage4;
  967. extern WithoutLinkage5 withoutLinkage5;
  968. // OK, extern "C".
  969. extern "C" {
  970. extern WithoutLinkage1 dr389_withoutLinkage1;
  971. extern WithoutLinkage2 dr389_withoutLinkage2;
  972. extern WithoutLinkage3 dr389_withoutLinkage3;
  973. extern WithoutLinkage4 dr389_withoutLinkage4;
  974. extern WithoutLinkage5 dr389_withoutLinkage5;
  975. }
  976. // OK, defined.
  977. WithoutLinkage1 withoutLinkageDef1;
  978. WithoutLinkage2 withoutLinkageDef2 = WithoutLinkage2();
  979. WithoutLinkage3 withoutLinkageDef3 = {};
  980. WithoutLinkage4 withoutLinkageDef4 = WithoutLinkage4();
  981. WithoutLinkage5 withoutLinkageDef5;
  982. void use(const void *);
  983. void use_all() {
  984. use(&withLinkage1); use(&withLinkage2); use(&withLinkage3a); use(&withLinkage3b);
  985. use(&withLinkage4a); use(&withLinkage4b); use(&withLinkage5); use(&withLinkage6);
  986. use(&withLinkage7); use(&withLinkage8); use(&withLinkage9); use(&withLinkage10);
  987. use(&withoutLinkage1); use(&withoutLinkage2); use(&withoutLinkage3);
  988. use(&withoutLinkage4); use(&withoutLinkage5);
  989. use(&dr389_withoutLinkage1); use(&dr389_withoutLinkage2);
  990. use(&dr389_withoutLinkage3); use(&dr389_withoutLinkage4);
  991. use(&dr389_withoutLinkage5);
  992. use(&withoutLinkageDef1); use(&withoutLinkageDef2); use(&withoutLinkageDef3);
  993. use(&withoutLinkageDef4); use(&withoutLinkageDef5);
  994. }
  995. void local() {
  996. // FIXME: This is ill-formed.
  997. extern WithoutLinkage1 withoutLinkageLocal;
  998. }
  999. }
  1000. namespace dr390 { // dr390: yes
  1001. template<typename T>
  1002. struct A {
  1003. A() { f(); } // expected-warning {{call to pure virt}}
  1004. virtual void f() = 0; // expected-note {{here}}
  1005. virtual ~A() = 0;
  1006. };
  1007. template<typename T> A<T>::~A() { T::error; } // expected-error {{cannot be used prior to}}
  1008. template<typename T> void A<T>::f() { T::error; } // ok, not odr-used
  1009. struct B : A<int> { // expected-note 2{{in instantiation of}}
  1010. void f() {}
  1011. } b;
  1012. }
  1013. namespace dr391 { // dr391: yes c++11
  1014. // FIXME: Should this apply to C++98 too?
  1015. class A { A(const A&); }; // expected-note 0-1{{here}}
  1016. A fa();
  1017. const A &a = fa();
  1018. #if __cplusplus < 201103L
  1019. // expected-error@-2 {{C++98 requires an accessible copy constructor}}
  1020. #endif
  1021. struct B { B(const B&) = delete; }; // expected-error 0-1{{extension}} expected-note 0-1{{here}}
  1022. B fb();
  1023. const B &b = fb();
  1024. #if __cplusplus < 201103L
  1025. // expected-error@-2 {{deleted}}
  1026. #endif
  1027. template<typename T>
  1028. struct C {
  1029. C(const C&) { T::error; }
  1030. };
  1031. C<int> fc();
  1032. const C<int> &c = fc();
  1033. }
  1034. // dr392 FIXME write codegen test
  1035. // dr394: na
  1036. namespace dr395 { // dr395: yes
  1037. struct S {
  1038. template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}}
  1039. template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}}
  1040. template <typename T> operator T *() const { return 0; }
  1041. template <typename T, typename U> operator T U::*() const { return 0; }
  1042. template <typename T, typename U> operator T (U::*)()() const { return 0; } // expected-error +{{}}
  1043. };
  1044. struct null1_t {
  1045. template <class T, class U> struct ptr_mem_fun_t {
  1046. typedef T (U::*type)();
  1047. };
  1048. template <class T, class U>
  1049. operator typename ptr_mem_fun_t<T, U>::type() const { // expected-note {{couldn't infer}}
  1050. return 0;
  1051. }
  1052. } null1;
  1053. int (S::*p)() = null1; // expected-error {{no viable conversion}}
  1054. template <typename T> using id = T; // expected-error 0-1{{extension}}
  1055. struct T {
  1056. template <typename T, int N> operator id<T[N]> &();
  1057. template <typename T, typename U> operator id<T (U::*)()>() const;
  1058. };
  1059. struct null2_t {
  1060. template<class T, class U> using ptr_mem_fun_t = T (U::*)(); // expected-error 0-1{{extension}}
  1061. template<class T, class U> operator ptr_mem_fun_t<T, U>() const { return 0; };
  1062. } null2;
  1063. int (S::*q)() = null2;
  1064. }
  1065. namespace dr396 { // dr396: yes
  1066. void f() {
  1067. auto int a(); // expected-error {{storage class on function}}
  1068. int (i); // expected-note {{previous}}
  1069. auto int (i); // expected-error {{redefinition}}
  1070. #if __cplusplus >= 201103L
  1071. // expected-error@-4 {{'auto' storage class}} expected-error@-2 {{'auto' storage class}}
  1072. #endif
  1073. }
  1074. }
  1075. // dr397: sup 1823
  1076. namespace dr398 { // dr398: yes
  1077. namespace example1 {
  1078. struct S {
  1079. static int const I = 42;
  1080. };
  1081. template <int N> struct X {};
  1082. template <typename T> void f(X<T::I> *) {}
  1083. template <typename T> void f(X<T::J> *) {}
  1084. void foo() { f<S>(0); }
  1085. }
  1086. namespace example2 {
  1087. template <int I> struct X {};
  1088. template <template <class T> class> struct Z {};
  1089. template <class T> void f(typename T::Y *) {} // expected-note 2{{substitution failure}}
  1090. template <class T> void g(X<T::N> *) {} // expected-note {{substitution failure}}
  1091. template <class T> void h(Z<T::template TT> *) {} // expected-note {{substitution failure}}
  1092. struct A {};
  1093. struct B {
  1094. int Y;
  1095. };
  1096. struct C {
  1097. typedef int N;
  1098. };
  1099. struct D {
  1100. typedef int TT;
  1101. };
  1102. void test() {
  1103. f<A>(0); // expected-error {{no matching function}}
  1104. f<B>(0); // expected-error {{no matching function}}
  1105. g<C>(0); // expected-error {{no matching function}}
  1106. h<D>(0); // expected-error {{no matching function}}
  1107. }
  1108. }
  1109. }