1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2 3// If a template-parameter of a class template or alias template has a default 4// template-argument, each subsequent template-parameter shall either have a 5// default template-argument supplied or be a template parameter pack. 6template<typename> struct vector; 7 8template<typename T = int, typename> struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 9template<typename T = int, typename> using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 10template<int V = 0, int> struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 11template<int V = 0, int> using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 12template<template<class> class M = vector, template<class> class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 13template<template<class> class M = vector, template<class> class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} 14 15template<typename T = int, typename ...Types> struct X2t; 16template<typename T = int, typename ...Types> using A2t = X2t<T, Types...>; 17template<int V = 0, int ...Values> struct X2nt; 18template<int V = 0, int ...Values> using A2nt = X2nt<V, Values...>; 19template<template<class> class M = vector, template<class> class... Metas> 20 struct X2tt; 21template<template<class> class M = vector, template<class> class... Metas> 22 using A2tt = X2tt<M, Metas...>; 23 24// If a template-parameter of a primary class template or alias template is a 25// template parameter pack, it shall be the last template-parameter. 26template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}} 27 int After, int After2> 28struct X0t; 29X0t<int> pr9789(); 30template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}} 31 int After> 32using A0t = int; 33 34template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}} 35 int After> 36struct X0nt; 37template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}} 38 int After> 39using A0nt = int; 40 41template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} 42 int After> 43struct X0tt; 44template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} 45 int After> 46using A0tt = int; 47 48// [ Note: These are not requirements for function templates or class 49// template partial specializations because template arguments can be 50// deduced (14.8.2). -- end note] 51template<typename... Types> struct X1t; 52template<typename ...Types, typename T> struct X1t<T, Types...> { }; 53 54template<int... Values> struct X1nt; 55template<int ...Values, int V> struct X1nt<V, Values...> { }; 56 57template<template<int> class... Meta> struct X1tt; 58template<template<int> class... Meta, template<int> class M> 59 struct X1tt<M, Meta...> { }; 60 61template<typename ...Types, typename T> 62void f1t(X1t<T, Types...>); 63 64template<int ...Values, int V> 65void f1nt(X1nt<V, Values...>); 66 67template<template<int> class... Meta, template<int> class M> 68void f1tt(X1tt<M, Meta...>); 69 70namespace DefaultTemplateArgsInFunction { 71 template<typename T = int, typename U> T &f0(U) { T *x = 0; return *x; } 72 73 void test_f0() { 74 int &ir0 = f0(3.14159); 75 int &ir1 = f0<int>(3.14159); 76 float &fr0 = f0<float>(3.14159); 77 } 78 79 template<> int &f0(int*); 80 template int &f0(double&); 81} 82