From: Richard Smith Date: Wed, 19 Mar 2014 08:04:12 +0000 (+0000) Subject: Tests for DR450-475. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=be1b9f52abb9ad244ccacab1f87e0ec1bed4c53e;p=clang Tests for DR450-475. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204217 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp index a6cfb89b78..cdc978bff3 100644 --- a/test/CXX/drs/dr4xx.cpp +++ b/test/CXX/drs/dr4xx.cpp @@ -603,6 +603,236 @@ namespace dr450 { // dr450: yes #endif } +namespace dr451 { // dr451: yes + const int a = 1 / 0; // expected-warning {{undefined}} + const int b = 1 / 0; // expected-warning {{undefined}} + int arr[b]; // expected-error +{{variable length arr}} +} + +namespace dr452 { // dr452: yes + struct A { + int a, b, c; + A *p; + int f(); + A() : a(f()), b(this->f() + a), c(this->a), p(this) {} + }; +} + +// dr454 FIXME write a codegen test + +namespace dr456 { // dr456: yes + // sup 903 c++11 + const int null = 0; + void *p = null; +#if __cplusplus >= 201103L + // expected-error@-2 {{cannot initialize}} +#else + // expected-warning@-4 {{null}} +#endif + + const bool f = false; + void *q = f; +#if __cplusplus >= 201103L + // expected-error@-2 {{cannot initialize}} +#else + // expected-warning@-4 {{null}} +#endif +} + +namespace dr457 { // dr457: yes + const int a = 1; + const volatile int b = 1; + int ax[a]; + int bx[b]; // expected-error +{{variable length array}} + + enum E { + ea = a, + eb = b // expected-error {{not an integral constant}} expected-note {{read of volatile-qualified}} + }; +} + +namespace dr458 { // dr458: no + struct A { + int T; + int f(); + template int g(); + }; + + template struct B : A { + int f(); + template int g(); + template int h(); + }; + + int A::f() { + return T; + } + template + int A::g() { + return T; // FIXME: this is invalid, it finds the template parameter + } + + template + int B::f() { + return T; + } + template template + int B::g() { + return T; + } + template template + int B::h() { + return T; // FIXME: this is invalid, it finds the template parameter + } +} + +namespace dr460 { // dr460: yes + namespace X { namespace Q { int n; } } + namespace Y { + using X; // expected-error {{requires a qualified name}} + using dr460::X; // expected-error {{cannot refer to namespace}} + using X::Q; // expected-error {{cannot refer to namespace}} + } +} + +// dr461: na +// dr462 FIXME write a codegen test +// dr463: na +// dr464: na +// dr465: na + +namespace dr466 { // dr466: no + typedef int I; + typedef const int CI; + typedef volatile int VI; + void f(int *a, CI *b, VI *c) { + a->~I(); + a->~CI(); + a->~VI(); + a->I::~I(); + a->CI::~CI(); + a->VI::~VI(); + + a->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type. + + b->~I(); + b->~CI(); + b->~VI(); + b->I::~I(); + b->CI::~CI(); + b->VI::~VI(); + + c->~I(); + c->~CI(); + c->~VI(); + c->I::~I(); + c->CI::~CI(); + c->VI::~VI(); + } +} + +namespace dr467 { // dr467: yes + int stuff(); + + int f() { + static bool done; + if (done) + goto later; + static int k = stuff(); + done = true; + later: + return k; + } + int g() { + goto later; // expected-error {{protected scope}} + int k = stuff(); // expected-note {{bypasses variable initialization}} + later: + return k; + } +} + +namespace dr468 { // dr468: yes c++11 + // FIXME: Should we allow this in C++98 too? + template struct A { + template struct B { + static int C; + }; + }; + int k = dr468::template A::template B::C; +#if __cplusplus < 201103L + // expected-error@-2 2{{'template' keyword outside of a template}} +#endif +} + +namespace dr469 { // dr469: no + // FIXME: The core issue here didn't really answer the question. We don't + // deduce 'const T' from a function or reference type in a class template... + template struct X; // expected-note 2{{here}} + template struct X {}; + X x; // expected-error {{undefined}} + X y; // expected-error {{undefined}} + + // ... but we do in a function template. GCC and EDG fail deduction of 'f' + // and the second 'h'. + template void f(const T *); + template void g(T *, const T * = 0); + template void h(T *) { T::error; } + template void h(const T *); + void i() { + f(&i); + g(&i); + h(&i); + } +} + +namespace dr470 { // dr470: yes + template struct A { + struct B {}; + }; + template struct C { + }; + + template struct A; // expected-note {{previous}} + template struct A::B; // expected-error {{duplicate explicit instantiation}} + + // ok, instantiating C doesn't instantiate base class members. + template struct A; + template struct C; +} + +namespace dr471 { // dr471: yes + struct A { int n; }; + struct B : private virtual A {}; + struct C : protected virtual A {}; + struct D : B, C { int f() { return n; } }; + struct E : private virtual A { + using A::n; + }; + struct F : E, B { int f() { return n; } }; + struct G : virtual A { + private: + using A::n; // expected-note {{here}} + }; + struct H : B, G { int f() { return n; } }; // expected-error {{private}} +} + +namespace dr474 { // dr474: yes + namespace N { + struct S { + void f(); + }; + } + void N::S::f() { + void g(); // expected-note {{previous}} + } + int g(); + namespace N { + int g(); // expected-error {{cannot be overloaded}} + } +} + +// dr475 FIXME write a codegen test + namespace dr482 { // dr482: 3.5 extern int a; void f(); diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index 0681e4be42..f871771e11 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -219,7 +219,7 @@ 30 TC1 Valid uses of "::template" - Superseded by 468 (C++11 onwards) + Superseded by 468 (C++11 onwards) 31 @@ -1462,7 +1462,7 @@ accessible? 237 CD1 Explicit instantiation and base class members - Duplicate of 470 + Duplicate of 470 238 @@ -2747,13 +2747,13 @@ of class templates 451 CD1 Expressions with invalid results and ill-formedness - Unknown + Yes 452 CD1 Wording nit on description of this - Unknown + Yes 453 @@ -2777,19 +2777,19 @@ of class templates 456 NAD Is initialized const int or const bool variable a null pointer constant? - Unknown + Yes 457 CD1 Wording nit on use of const variables in constant expressions - Unknown + Yes 458 C++11 Hiding of member template parameters by other members - Unknown + No 459 @@ -2801,13 +2801,13 @@ of class templates 460 CD1 Can a using-declaration name a namespace? - Unknown + Yes 461 NAD Make asm conditionally-supported - Unknown + N/A 462 @@ -2819,55 +2819,55 @@ of class templates 463 CD1 reinterpret_cast<T*>(0) - Unknown + N/A 464 CD1 Wording nit on lifetime of temporaries to which references are bound - Unknown + N/A 465 NAD May constructors of global objects call exit()? - Unknown + N/A 466 CD1 cv-qualifiers on pseudo-destructor type - Unknown + No 467 NAD Jump past initialization of local static variable - Unknown + Yes 468 CD1 Allow ::template outside of templates - Unknown + Yes (C++11 onwards) 469 NAD Const template specializations and reference arguments - Unknown + No 470 CD1 Instantiation of members of an explicitly-instantiated class template - Unknown + Yes 471 NAD Conflicting inherited access specifications - Unknown + Yes 472 @@ -2885,7 +2885,7 @@ of class templates 474 CD1 Block-scope extern declarations in namespace members - Unknown + Yes 475