From 7101fd0e562a21ccb5223ed62b9bc406c2c27517 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 17 Nov 2013 02:50:30 +0000 Subject: [PATCH] Tests for core issues 224-240. llvm-svn: 194946 --- clang/test/CXX/drs/dr2xx.cpp | 188 +++++++++++++++++++++++++++++++++++ clang/www/cxx_dr_status.html | 28 +++--- 2 files changed, 202 insertions(+), 14 deletions(-) diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp index 3e9475600147..139b99f4da05 100644 --- a/clang/test/CXX/drs/dr2xx.cpp +++ b/clang/test/CXX/drs/dr2xx.cpp @@ -217,3 +217,191 @@ namespace dr221 { // dr221: yes // apparently both voted into the WP and acted upon by the editor. // dr223: na + +namespace dr224 { // dr224: no + namespace example1 { + template class A { + typedef int type; + A::type a; + A::type b; + A::type c; // expected-error {{missing 'typename'}} + ::dr224::example1::A::type d; + + class B { + typedef int type; + + A::type a; + A::type b; + A::type c; // expected-error {{missing 'typename'}} + ::dr224::example1::A::type d; + + B::type e; + A::B::type f; + A::B::type g; // expected-error {{missing 'typename'}} + typename A::B::type h; + }; + }; + + template class A { + typedef int type; + A::type a; + A::type b; // expected-error {{missing 'typename'}} + }; + + template struct B { + typedef int type; + B::type b1; + B::type b2; // expected-error {{missing 'typename'}} + + typedef T1 my_T1; + static const int my_I = I; + static const int my_I2 = I+0; + static const int my_I3 = my_I; + B::type b3; // FIXME: expected-error {{missing 'typename'}} + B::type b4; // expected-error {{missing 'typename'}} + B::type b5; // FIXME: expected-error {{missing 'typename'}} + }; + } + + namespace example2 { + template struct X { typedef T type; }; + template class A { + static const int i = 5; + X::type w; // FIXME: expected-error {{missing 'typename'}} + X::type x; // FIXME: expected-error {{missing 'typename'}} + X::i, double>::type y; // FIXME: expected-error {{missing 'typename'}} + X::i, long>::type z; // expected-error {{missing 'typename'}} + int f(); + }; + template int A::f() { + return i; + } + } +} + +// dr225: yes +template void dr225_f(T t) { dr225_g(t); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}} +void dr225_g(int); // expected-note {{should be declared prior to the call site}} +template void dr225_f(int); // expected-note {{in instantiation of}} + +namespace dr226 { // dr226: no + template void f() {} +#if __cplusplus < 201103L + // expected-error@-2 {{extension}} + // FIXME: This appears to be wrong: default arguments for function templates + // are listed as a defect (in c++98) not an extension. EDG accepts them in + // strict c++98 mode. +#endif + template struct S { + template void g(); +#if __cplusplus < 201103L + // expected-error@-2 {{extension}} +#endif + template struct X; + template void h(); + }; + template template void S::g() {} + template template struct S::X {}; // expected-error {{cannot add a default template arg}} + template template void S::h() {} // expected-error {{cannot add a default template arg}} + + template void friend_h(); + struct A { + // FIXME: This is ill-formed. + template struct friend_B; + // FIXME: f, h, and i are ill-formed. + // f is ill-formed because it is not a definition. + // h and i are ill-formed because they are not the only declarations of the + // function in the translation unit. + template void friend_f(); + template void friend_g() {} + template void friend_h() {} + template void friend_i() {} +#if __cplusplus < 201103L + // expected-error@-5 {{extension}} expected-error@-4 {{extension}} + // expected-error@-4 {{extension}} expected-error@-3 {{extension}} +#endif + }; + template void friend_i(); + + template void foo(X) {} + template struct Foo {}; // expected-error {{missing a default argument}} expected-note {{here}} +#if __cplusplus < 201103L + // expected-error@-3 {{extension}} +#endif + + template int foo(X, Y); + template int foo(X, Y); + int x = foo(0, 0); +#if __cplusplus < 201103L + // expected-error@-4 {{extension}} + // expected-error@-4 {{extension}} +#endif +} + +void dr227(bool b) { // dr227: yes + if (b) + int n; + else + int n; +} + +namespace dr228 { // dr228: yes + template struct X { + void f(); + }; + template struct Y { + void g(X x) { x.template X::f(); } + }; +} + +namespace dr229 { // dr229: yes + template void f(); + template void f() {} // expected-error {{function template partial specialization}} + template<> void f() {} +} + +namespace dr231 { // dr231: yes + namespace outer { + namespace inner { + int i; // expected-note {{here}} + } + void f() { using namespace inner; } + int j = i; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}} + } +} + +// dr234: na +// dr235: na + +namespace dr236 { // dr236: yes + void *p = int(); +#if __cplusplus < 201103L + // expected-warning@-2 {{null pointer}} +#else + // expected-error@-4 {{cannot initialize}} +#endif +} + +namespace dr237 { // dr237: dup 470 + template struct A { void f() { T::error; } }; + template struct B : A {}; + template struct B; // ok +} + +namespace dr239 { // dr239: yes + namespace NS { + class T {}; + void f(T); + float &g(T, int); + } + NS::T parm; + int &g(NS::T, float); + int main() { + f(parm); + float &r = g(parm, 1); + extern int &g(NS::T, float); + int &s = g(parm, 1); + } +} + +// dr240: dup 616 diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 258a5f8a8aa8..5fa95f4e9d11 100644 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -110,7 +110,7 @@ 12 dup Default arguments on different declarations for the same function and the Koenig lookup - Superseded by 239 + Superseded by 239 13 @@ -1383,37 +1383,37 @@ accessible? 224 CD1 Definition of dependent names - Unknown + No 225 NAD Koenig lookup and fundamental types - Unknown + Yes 226 CD1 Default template arguments for function templates - Unknown + No 227 TC1 How many scopes in an if statement? - Unknown + Yes 228 CD1 Use of template keyword with non-member templates - Unknown + Yes 229 NAD Partial specialization of function templates - Unknown + Yes 230 @@ -1425,7 +1425,7 @@ accessible? 231 NAD Visibility of names after using-directives - Unknown + Yes 232 @@ -1443,25 +1443,25 @@ accessible? 234 NAD Reuse of base class subobjects - Unknown + N/A 235 TC1 Assignment vs initialization - Unknown + N/A 236 NAD Explicit temporaries and integral constant expressions - Unknown + Yes 237 CD1 Explicit instantiation and base class members - Unknown + Duplicate of 470 238 @@ -1473,13 +1473,13 @@ accessible? 239 CD1 Footnote 116 and Koenig lookup - Unknown + Yes 240 DRWP Uninitialized values and undefined behavior - Unknown + Duplicate of 616 241