Home | History | Annotate | Download | only in temp.param
      1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
      2 
      3 // A default template-argument may be specified for any kind of
      4 // template-parameter that is not a template parameter pack.
      5 template<typename ...Types = int> // expected-error{{template parameter pack cannot have a default argument}}
      6 struct X0;
      7 
      8 template<int ...Values = 0> // expected-error{{template parameter pack cannot have a default argument}}
      9 struct X1;
     10 
     11 template<typename T> struct vector;
     12 
     13 template<template<class> class ...Templates = vector> // expected-error{{template parameter pack cannot have a default argument}}
     14 struct X2;
     15 
     16 struct X3 {
     17   template<typename T = int> // expected-error{{default template argument not permitted on a friend template}}
     18   friend void f0(X3);
     19 
     20   template<typename T = int>
     21   friend void f1(X3) {
     22   }
     23 };
     24 
     25 namespace PR8748 {
     26   // Testcase 1
     27   struct A0 { template<typename U> struct B; };
     28   template<typename U = int> struct A0::B { };
     29 
     30   // Testcase 2
     31   template<typename T> struct A1 { template<typename U> struct B; };
     32   template<typename T> template<typename U = int> struct A1<T>::B { }; // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
     33 
     34   // Testcase 3
     35   template<typename T>
     36   struct X2 {
     37     void f0();
     38     template<typename U> void f1();
     39   };
     40 
     41   template<typename T = int> void X2<T>::f0() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
     42   template<typename T> template<typename U = int> void X2<T>::f1() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}}
     43 
     44   namespace Inner {
     45     template<typename T> struct X3;
     46     template<typename T> void f2();
     47   }
     48 
     49   // Okay; not class members.
     50   template<typename T = int> struct Inner::X3 { };
     51   template<typename T = int> void Inner::f2() {}
     52 }
     53 
     54 namespace PR10069 {
     55   template<typename T, T a, T b=0, T c=1>
     56   T f(T x);
     57 
     58   void g() {
     59     f<unsigned int, 0>(0);
     60   }
     61 }
     62