From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/CXX/temp/temp.param/p1.cpp | 12 +++++ clang/test/CXX/temp/temp.param/p10-0x.cpp | 13 +++++ clang/test/CXX/temp/temp.param/p10.cpp | 12 +++++ clang/test/CXX/temp/temp.param/p11-0x.cpp | 81 ++++++++++++++++++++++++++++ clang/test/CXX/temp/temp.param/p11.cpp | 15 ++++++ clang/test/CXX/temp/temp.param/p12.cpp | 39 ++++++++++++++ clang/test/CXX/temp/temp.param/p13.cpp | 14 +++++ clang/test/CXX/temp/temp.param/p14.cpp | 5 ++ clang/test/CXX/temp/temp.param/p15-cxx0x.cpp | 24 +++++++++ clang/test/CXX/temp/temp.param/p15.cpp | 12 +++++ clang/test/CXX/temp/temp.param/p2.cpp | 22 ++++++++ clang/test/CXX/temp/temp.param/p3.cpp | 40 ++++++++++++++ clang/test/CXX/temp/temp.param/p4.cpp | 21 ++++++++ clang/test/CXX/temp/temp.param/p5.cpp | 13 +++++ clang/test/CXX/temp/temp.param/p7.cpp | 15 ++++++ clang/test/CXX/temp/temp.param/p8.cpp | 6 +++ clang/test/CXX/temp/temp.param/p9-0x.cpp | 61 +++++++++++++++++++++ clang/test/CXX/temp/temp.param/p9.cpp | 23 ++++++++ 18 files changed, 428 insertions(+) create mode 100644 clang/test/CXX/temp/temp.param/p1.cpp create mode 100644 clang/test/CXX/temp/temp.param/p10-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p10.cpp create mode 100644 clang/test/CXX/temp/temp.param/p11-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p11.cpp create mode 100644 clang/test/CXX/temp/temp.param/p12.cpp create mode 100644 clang/test/CXX/temp/temp.param/p13.cpp create mode 100644 clang/test/CXX/temp/temp.param/p14.cpp create mode 100644 clang/test/CXX/temp/temp.param/p15-cxx0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p15.cpp create mode 100644 clang/test/CXX/temp/temp.param/p2.cpp create mode 100644 clang/test/CXX/temp/temp.param/p3.cpp create mode 100644 clang/test/CXX/temp/temp.param/p4.cpp create mode 100644 clang/test/CXX/temp/temp.param/p5.cpp create mode 100644 clang/test/CXX/temp/temp.param/p7.cpp create mode 100644 clang/test/CXX/temp/temp.param/p8.cpp create mode 100644 clang/test/CXX/temp/temp.param/p9-0x.cpp create mode 100644 clang/test/CXX/temp/temp.param/p9.cpp (limited to 'clang/test/CXX/temp/temp.param') diff --git a/clang/test/CXX/temp/temp.param/p1.cpp b/clang/test/CXX/temp/temp.param/p1.cpp new file mode 100644 index 0000000..e9a9789 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p1.cpp @@ -0,0 +1,12 @@ +// Suppress 'no run line' failure. +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template class C> class D; // expected-error{{template template parameter must have its own template parameters}} + + +struct A {}; +template // expected-error{{template parameter missing a default argument}} +class X0 {}; // expected-note{{template is declared here}} +X0 x0; // expected-error{{too few template arguments for class template 'X0'}} diff --git a/clang/test/CXX/temp/temp.param/p10-0x.cpp b/clang/test/CXX/temp/temp.param/p10-0x.cpp new file mode 100644 index 0000000..37bb284 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p10-0x.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + +template struct Y1; +template struct Y2; + +template using B2 = T1; +template using B2 = T1; + +template class F, template class G = Y1> using B2t = F>; +template class F = Y2, template class G> using B2t = F>; + +template using B2n = Y2; +template using B2n = Y2; diff --git a/clang/test/CXX/temp/temp.param/p10.cpp b/clang/test/CXX/temp/temp.param/p10.cpp new file mode 100644 index 0000000..b9dac75 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p10.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template struct Y1; +template struct Y2; + +template class B2; +template class B2; + +template class, template class = Y1> class B2t; +template class = Y2, template class> class B2t; + +template class B2n; +template class B2n; diff --git a/clang/test/CXX/temp/temp.param/p11-0x.cpp b/clang/test/CXX/temp/temp.param/p11-0x.cpp new file mode 100644 index 0000000..d2276a3 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p11-0x.cpp @@ -0,0 +1,81 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// If a template-parameter of a class template or alias template has a default +// template-argument, each subsequent template-parameter shall either have a +// default template-argument supplied or be a template parameter pack. +template struct vector; + +template struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template class M = vector, template class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template class M = vector, template class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} + +template struct X2t; +template using A2t = X2t; +template struct X2nt; +template using A2nt = X2nt; +template class M = vector, template class... Metas> + struct X2tt; +template class M = vector, template class... Metas> + using A2tt = X2tt; + +// If a template-parameter of a primary class template or alias template is a +// template parameter pack, it shall be the last template-parameter. +template +struct X0t; +X0t pr9789(); +template +using A0t = int; + +template +struct X0nt; +template +using A0nt = int; + +template class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} + int After> +struct X0tt; +template class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} + int After> +using A0tt = int; + +// [ Note: These are not requirements for function templates or class +// template partial specializations because template arguments can be +// deduced (14.8.2). -- end note] +template struct X1t; +template struct X1t { }; + +template struct X1nt; +template struct X1nt { }; + +template class... Meta> struct X1tt; +template class... Meta, template class M> + struct X1tt { }; + +template +void f1t(X1t); + +template +void f1nt(X1nt); + +template class... Meta, template class M> +void f1tt(X1tt); + +namespace DefaultTemplateArgsInFunction { + template T &f0(U) { T *x = 0; return *x; } + + void test_f0() { + int &ir0 = f0(3.14159); + int &ir1 = f0(3.14159); + float &fr0 = f0(3.14159); + } + + template<> int &f0(int*); + template int &f0(double&); +} diff --git a/clang/test/CXX/temp/temp.param/p11.cpp b/clang/test/CXX/temp/temp.param/p11.cpp new file mode 100644 index 0000000..5af0c4e --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p11.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template struct Y1; +template struct Y2; + +template // expected-error{{template parameter missing a default argument}} + class B1; + +template class = Y1, // expected-note{{previous default template argument defined here}} + template class> // expected-error{{template parameter missing a default argument}} + class B1t; + +template // expected-error{{template parameter missing a default argument}} + class B1n; diff --git a/clang/test/CXX/temp/temp.param/p12.cpp b/clang/test/CXX/temp/temp.param/p12.cpp new file mode 100644 index 0000000..7be3879 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p12.cpp @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template struct Y1; // expected-note{{too few template parameters in template template argument}} +template struct Y2; + +// C++ [temp.param]p12: +template // expected-note{{previous default template argument defined here}} + class B3; +template class B3; +template // expected-error{{template parameter redefines default argument}} + class B3; + +template class, + template class = Y1> // expected-note{{previous default template argument defined here}} + class B3t; + +template class, template class> class B3t; + +template class, + template class = Y1> // expected-error{{template parameter redefines default argument}} + class B3t; + +template // expected-note{{previous default template argument defined here}} + class B3n; + +template class B3n; + +template // expected-error{{template parameter redefines default argument}} + class B3n; + +// Check validity of default arguments +template class // expected-note{{previous template template parameter is here}} + = Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} + class C1 {}; + +C1<> c1; // expected-note{{while checking a default template argument}} diff --git a/clang/test/CXX/temp/temp.param/p13.cpp b/clang/test/CXX/temp/temp.param/p13.cpp new file mode 100644 index 0000000..7e7dbe5 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p13.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// The scope of atemplate-parameterextends from its point of +// declaration until the end of its template. In particular, a +// template-parameter can be used in the declaration of subsequent +// template-parameters and their default arguments. + +template class X { /* ... */ }; +// FIXME: template void f(T* p = new T); + +// Check for bogus template parameter shadow warning. +template class, + template class> + class B1noshadow; diff --git a/clang/test/CXX/temp/temp.param/p14.cpp b/clang/test/CXX/temp/temp.param/p14.cpp new file mode 100644 index 0000000..a6c53c1 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p14.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// XFAIL: * + +// A template-parameter shall not be used in its own default argument. +template struct X; // expected-error{{default}} diff --git a/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp b/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp new file mode 100644 index 0000000..5fc57a4 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p15-cxx0x.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s +template struct X; +template struct Y; + +X> *x1; + +Y<(1 >> 2)> *y1; +Y<1 >> 2> *y2; // FIXME: expected-error{{expected unqualified-id}} + +X>>>> *x2; + +template<> struct X { }; +typedef X X_int; +struct Z : X_int { }; + +void f(const X x) { + (void)reinterpret_cast>(x); // expected-error{{reinterpret_cast from}} + (void)reinterpret_cast>>>(x); // expected-error{{reinterpret_cast from}} + + X> *x1; +} + +template struct X1 { }; +X1> x1a; diff --git a/clang/test/CXX/temp/temp.param/p15.cpp b/clang/test/CXX/temp/temp.param/p15.cpp new file mode 100644 index 0000000..ee572e9 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p15.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s +template struct X; +template struct Y; + +X > *x1; +X> *x2; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} + +X> // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} + >> *x3; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} + +Y<(1 >> 2)> *y1; +Y<1 >> 2> *y2; // expected-warning{{use of right-shift operator ('>>') in template argument will require parentheses in C++11}} diff --git a/clang/test/CXX/temp/temp.param/p2.cpp b/clang/test/CXX/temp/temp.param/p2.cpp new file mode 100644 index 0000000..fed6e9c --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p2.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// There is no semantic difference between class and typename in a +// template-parameter. typename followed by an unqualified-id names a +// template type parameter. +template struct X; +template struct X; + +// typename followed by aqualified-id denotes the type in a non-type +// parameter-declaration. +template struct Y0; +template::type Value> struct Y1; + +// A storage class shall not be specified in a template-parameter declaration. +template struct Z; // FIXME: expect an error + +// Make sure that we properly disambiguate non-type template parameters that +// start with 'class'. +class X1 { }; +template struct Y2 { }; + +// FIXME: add the example from p2 diff --git a/clang/test/CXX/temp/temp.param/p3.cpp b/clang/test/CXX/temp/temp.param/p3.cpp new file mode 100644 index 0000000..dc40c4b --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p3.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// A type-parameter defines its identifier to be a type-name (if +// declared with class or typename) or template-name (if declared with +// template) in the scope of the template declaration. +template struct X0 { + T* value; +}; + +template class Y> struct X1 { + Y value; +}; + +// [Note: because of the name lookup rules, a template-parameter that +// could be interpreted as either a non-type template-parameter or a +// type-parameter (because its identifier is the name of an already +// existing class) is taken as a type-parameter. For example, +class T { /* ... */ }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} +int i; + +template struct X2 { + void f(T t) + { + T t1 = i; //template-parameters T and i + ::T t2 = ::i; // global namespace members T and i \ + // expected-error{{no viable conversion}} + } +}; + +namespace PR6831 { + namespace NA { struct S; } + namespace NB { struct S; } + + using namespace NA; + using namespace NB; + + template void foo(); + template void bar(); + template class S> void baz(); +} diff --git a/clang/test/CXX/temp/temp.param/p4.cpp b/clang/test/CXX/temp/temp.param/p4.cpp new file mode 100644 index 0000000..809fb20 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p4.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +class X; + +// C++ [temp.param]p4 +typedef int INT; +enum E { enum1, enum2 }; +template struct A1; +template struct A2; +template struct A3; +template struct A4; +template struct A5; +template struct A6; +template struct A7; +template struct A8; +template struct A9; +template struct A10; + +template struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} + +template struct A12; +template struct A13; diff --git a/clang/test/CXX/temp/temp.param/p5.cpp b/clang/test/CXX/temp/temp.param/p5.cpp new file mode 100644 index 0000000..3cbb3b7 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p5.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -verify %s -std=c++11 + +template struct S { + decltype(I) n; + int &&r = I; +}; +S<5> s; + +template struct U { + decltype(v) n; + int &&r = v; +}; +U u; diff --git a/clang/test/CXX/temp/temp.param/p7.cpp b/clang/test/CXX/temp/temp.param/p7.cpp new file mode 100644 index 0000000..13f0367 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p7.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// A non-type template-parameter shall not be declared to have +// floating point, class, or void type. +struct A; + +template class X; // expected-error{{cannot have type}} +template class Y; //OK +template class Z; //OK + +template class X0; // expected-error{{cannot have type}} + +typedef void VOID; +template class X01; // expected-error{{cannot have type}} + diff --git a/clang/test/CXX/temp/temp.param/p8.cpp b/clang/test/CXX/temp/temp.param/p8.cpp new file mode 100644 index 0000000..fed048c --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p8.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template struct A; +template struct A; +template struct B; +typedef float FLOAT; +template struct B; diff --git a/clang/test/CXX/temp/temp.param/p9-0x.cpp b/clang/test/CXX/temp/temp.param/p9-0x.cpp new file mode 100644 index 0000000..29a7549 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p9-0x.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +// A default template-argument may be specified for any kind of +// template-parameter that is not a template parameter pack. +template // expected-error{{template parameter pack cannot have a default argument}} +struct X0; + +template // expected-error{{template parameter pack cannot have a default argument}} +struct X1; + +template struct vector; + +template class ...Templates = vector> // expected-error{{template parameter pack cannot have a default argument}} +struct X2; + +struct X3 { + template // expected-error{{default template argument not permitted on a friend template}} + friend void f0(X3); + + template + friend void f1(X3) { + } +}; + +namespace PR8748 { + // Testcase 1 + struct A0 { template struct B; }; + template struct A0::B { }; + + // Testcase 2 + template struct A1 { template struct B; }; + template template struct A1::B { }; // expected-error{{cannot add a default template argument to the definition of a member of a class template}} + + // Testcase 3 + template + struct X2 { + void f0(); + template void f1(); + }; + + template void X2::f0() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}} + template template void X2::f1() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}} + + namespace Inner { + template struct X3; + template void f2(); + } + + // Okay; not class members. + template struct Inner::X3 { }; + template void Inner::f2() {} +} + +namespace PR10069 { + template + T f(T x); + + void g() { + f(0); + } +} diff --git a/clang/test/CXX/temp/temp.param/p9.cpp b/clang/test/CXX/temp/temp.param/p9.cpp new file mode 100644 index 0000000..b2318c2 --- /dev/null +++ b/clang/test/CXX/temp/temp.param/p9.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s + +// A default template-argument shall not be specified in a function +// template declaration or a function template definition +template // expected-warning{{default template arguments for a function template are a C++11 extension}} + void foo0(T); +template // expected-warning{{default template arguments for a function template are a C++11 extension}} + void foo1(T) { } + +// [...] nor in the template-parameter-list of the definition of a +// member of a class template. +template +struct X0 { + void f(); +}; + +template // expected-error{{cannot add a default template argument}} +void X0::f() { } + +class X1 { + template class TT = X0> // expected-error{{not permitted on a friend template}} + friend void f2(); +}; -- cgit v1.2.3