From: Douglas Gregor Date: Sat, 13 Jun 2009 06:59:07 +0000 (+0000) Subject: Move a bunch of tests into temp.param, and write a few tests for paragraphs that... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=247baca66ca998de9c415c19019e199f4895e81c;p=clang Move a bunch of tests into temp.param, and write a few tests for paragraphs that hadn't been touched before git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73288 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/temp/temp.param/p1.cpp b/test/CXX/temp/temp.param/p1.cpp new file mode 100644 index 0000000000..488c3a0742 --- /dev/null +++ b/test/CXX/temp/temp.param/p1.cpp @@ -0,0 +1 @@ +// Paragraph 1 is descriptive, and therefore requires no tests. diff --git a/test/CXX/temp/temp.param/p10.cpp b/test/CXX/temp/temp.param/p10.cpp new file mode 100644 index 0000000000..56e7f3281e --- /dev/null +++ b/test/CXX/temp/temp.param/p10.cpp @@ -0,0 +1,12 @@ +// RUN: clang-cc -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/test/CXX/temp/temp.param/p11.cpp b/test/CXX/temp/temp.param/p11.cpp new file mode 100644 index 0000000000..9e7fd39c0a --- /dev/null +++ b/test/CXX/temp/temp.param/p11.cpp @@ -0,0 +1,15 @@ +// RUN: clang-cc -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/test/CXX/temp/temp.param/p12.cpp b/test/CXX/temp/temp.param/p12.cpp new file mode 100644 index 0000000000..5511224ebe --- /dev/null +++ b/test/CXX/temp/temp.param/p12.cpp @@ -0,0 +1,37 @@ +// RUN: clang-cc -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; diff --git a/test/CXX/temp/temp.param/p13.cpp b/test/CXX/temp/temp.param/p13.cpp new file mode 100644 index 0000000000..559b892d0f --- /dev/null +++ b/test/CXX/temp/temp.param/p13.cpp @@ -0,0 +1,14 @@ +// RUN: clang-cc -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/test/CXX/temp/temp.param/p14.cpp b/test/CXX/temp/temp.param/p14.cpp new file mode 100644 index 0000000000..07e6bfe409 --- /dev/null +++ b/test/CXX/temp/temp.param/p14.cpp @@ -0,0 +1,5 @@ +// RUN: clang-cc -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/test/SemaTemplate/right-angle-brackets-0x.cpp b/test/CXX/temp/temp.param/p15-cxx0x.cpp similarity index 100% rename from test/SemaTemplate/right-angle-brackets-0x.cpp rename to test/CXX/temp/temp.param/p15-cxx0x.cpp diff --git a/test/SemaTemplate/right-angle-brackets-98.cpp b/test/CXX/temp/temp.param/p15.cpp similarity index 100% rename from test/SemaTemplate/right-angle-brackets-98.cpp rename to test/CXX/temp/temp.param/p15.cpp diff --git a/test/CXX/temp/temp.param/p2.cpp b/test/CXX/temp/temp.param/p2.cpp new file mode 100644 index 0000000000..a402cf6f88 --- /dev/null +++ b/test/CXX/temp/temp.param/p2.cpp @@ -0,0 +1,16 @@ +// RUN: clang-cc -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. +// FIXME: template struct Y; + +// A storage class shall not be specified in a template-parameter declaration. +template struct Z; // FIXME: expect an error + +// FIXME: add the example from p2 diff --git a/test/CXX/temp/temp.param/p3.cpp b/test/CXX/temp/temp.param/p3.cpp new file mode 100644 index 0000000000..6a76fe20b8 --- /dev/null +++ b/test/CXX/temp/temp.param/p3.cpp @@ -0,0 +1,28 @@ +// RUN: clang-cc -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 { /* ... */ }; +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{{cannot initialize}} + } +}; diff --git a/test/CXX/temp/temp.param/p4.cpp b/test/CXX/temp/temp.param/p4.cpp new file mode 100644 index 0000000000..3efff12436 --- /dev/null +++ b/test/CXX/temp/temp.param/p4.cpp @@ -0,0 +1,20 @@ +// RUN: clang-cc -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; // expected-error{{a non-type template parameter cannot have type 'void *'}} diff --git a/test/CXX/temp/temp.param/p7.cpp b/test/CXX/temp/temp.param/p7.cpp new file mode 100644 index 0000000000..ccc869ae0f --- /dev/null +++ b/test/CXX/temp/temp.param/p7.cpp @@ -0,0 +1,15 @@ +// RUN: clang-cc -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/test/CXX/temp/temp.param/p8.cpp b/test/CXX/temp/temp.param/p8.cpp new file mode 100644 index 0000000000..dd4af17d79 --- /dev/null +++ b/test/CXX/temp/temp.param/p8.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -fsyntax-only -verify %s +template struct A; +template struct A; +template struct B; +typedef float FLOAT; +template struct B; diff --git a/test/SemaTemplate/temp_param.cpp b/test/SemaTemplate/temp_param.cpp deleted file mode 100644 index c042f0849a..0000000000 --- a/test/SemaTemplate/temp_param.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// RUN: clang-cc -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; // expected-error{{a non-type template parameter cannot have type 'void *'}} - -// C++ [temp.param]p8 -template struct A5; -template struct A7; - -// C++ [temp.param]p11: -template struct Y1; // expected-note{{too few template parameters in template template argument}} -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; - -// Check for bogus template parameter shadow warning. -template class, - template class> - class B1noshadow; - -// C++ [temp.param]p10: -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; - -// 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;