diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-19 08:04:12 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-19 08:04:12 +0000 |
commit | 17710217faf5b2a347b8d4bbe89a9092e85b8d8e (patch) | |
tree | 33bfca693ef202807ef44347af40a3a852d652c5 /clang | |
parent | c6d4efa1e5e64656acf93439b70c7f9133985eca (diff) | |
download | bcm5719-llvm-17710217faf5b2a347b8d4bbe89a9092e85b8d8e.tar.gz bcm5719-llvm-17710217faf5b2a347b8d4bbe89a9092e85b8d8e.zip |
Tests for DR450-475.
llvm-svn: 204217
Diffstat (limited to 'clang')
-rw-r--r-- | clang/test/CXX/drs/dr4xx.cpp | 230 | ||||
-rw-r--r-- | clang/www/cxx_dr_status.html | 38 |
2 files changed, 249 insertions, 19 deletions
diff --git a/clang/test/CXX/drs/dr4xx.cpp b/clang/test/CXX/drs/dr4xx.cpp index a6cfb89b78b..cdc978bff3e 100644 --- a/clang/test/CXX/drs/dr4xx.cpp +++ b/clang/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<typename> int g(); + }; + + template<typename> struct B : A { + int f(); + template<typename> int g(); + template<typename> int h(); + }; + + int A::f() { + return T; + } + template<typename T> + int A::g() { + return T; // FIXME: this is invalid, it finds the template parameter + } + + template<typename T> + int B<T>::f() { + return T; + } + template<typename T> template<typename U> + int B<T>::g() { + return T; + } + template<typename U> template<typename T> + int B<U>::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<typename> struct A { + template<typename> struct B { + static int C; + }; + }; + int k = dr468::template A<int>::template B<char>::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<typename T> struct X; // expected-note 2{{here}} + template<typename T> struct X<const T> {}; + X<int&> x; // expected-error {{undefined}} + X<int()> y; // expected-error {{undefined}} + + // ... but we do in a function template. GCC and EDG fail deduction of 'f' + // and the second 'h'. + template<typename T> void f(const T *); + template<typename T> void g(T *, const T * = 0); + template<typename T> void h(T *) { T::error; } + template<typename T> void h(const T *); + void i() { + f(&i); + g(&i); + h(&i); + } +} + +namespace dr470 { // dr470: yes + template<typename T> struct A { + struct B {}; + }; + template<typename T> struct C { + }; + + template struct A<int>; // expected-note {{previous}} + template struct A<int>::B; // expected-error {{duplicate explicit instantiation}} + + // ok, instantiating C<char> doesn't instantiate base class members. + template struct A<char>; + template struct C<char>; +} + +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/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 0681e4be420..f871771e11f 100644 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -219,7 +219,7 @@ <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#30">30</a></td> <td>TC1</td> <td>Valid uses of "<TT>::template</TT>"</td> - <td class="none" align="center">Superseded by <a href="#468">468</a> (C++11 onwards)</td> + <td class="full" align="center">Superseded by <a href="#468">468</a> (C++11 onwards)</td> </tr> <tr id="31"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#31">31</a></td> @@ -1462,7 +1462,7 @@ accessible?</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#237">237</a></td> <td>CD1</td> <td>Explicit instantiation and base class members</td> - <td class="none" align="center">Duplicate of <a href="#470">470</a></td> + <td class="full" align="center">Duplicate of <a href="#470">470</a></td> </tr> <tr class="open" id="238"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#238">238</a></td> @@ -2747,13 +2747,13 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#451">451</a></td> <td>CD1</td> <td>Expressions with invalid results and ill-formedness</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="452"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#452">452</a></td> <td>CD1</td> <td>Wording nit on description of <TT>this</TT></td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr class="open" id="453"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#453">453</a></td> @@ -2777,19 +2777,19 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#456">456</a></td> <td>NAD</td> <td>Is initialized const int or const bool variable a null pointer constant?</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="457"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#457">457</a></td> <td>CD1</td> <td>Wording nit on use of const variables in constant expressions</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="458"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#458">458</a></td> <td>C++11</td> <td>Hiding of member template parameters by other members</td> - <td class="none" align="center">Unknown</td> + <td class="none" align="center">No</td> </tr> <tr class="open" id="459"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#459">459</a></td> @@ -2801,13 +2801,13 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#460">460</a></td> <td>CD1</td> <td>Can a <I>using-declaration</I> name a namespace?</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="461"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#461">461</a></td> <td>NAD</td> <td>Make <TT>asm</TT> conditionally-supported</td> - <td class="none" align="center">Unknown</td> + <td class="na" align="center">N/A</td> </tr> <tr id="462"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#462">462</a></td> @@ -2819,55 +2819,55 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#463">463</a></td> <td>CD1</td> <td><TT>reinterpret_cast<T*>(0)</TT></td> - <td class="none" align="center">Unknown</td> + <td class="na" align="center">N/A</td> </tr> <tr id="464"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#464">464</a></td> <td>CD1</td> <td>Wording nit on lifetime of temporaries to which references are bound</td> - <td class="none" align="center">Unknown</td> + <td class="na" align="center">N/A</td> </tr> <tr id="465"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#465">465</a></td> <td>NAD</td> <td>May constructors of global objects call <TT>exit()</TT>?</td> - <td class="none" align="center">Unknown</td> + <td class="na" align="center">N/A</td> </tr> <tr id="466"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#466">466</a></td> <td>CD1</td> <td>cv-qualifiers on pseudo-destructor type</td> - <td class="none" align="center">Unknown</td> + <td class="none" align="center">No</td> </tr> <tr id="467"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#467">467</a></td> <td>NAD</td> <td>Jump past initialization of local static variable</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="468"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#468">468</a></td> <td>CD1</td> <td>Allow <TT>::template</TT> outside of templates</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes (C++11 onwards)</td> </tr> <tr id="469"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#469">469</a></td> <td>NAD</td> <td>Const template specializations and reference arguments</td> - <td class="none" align="center">Unknown</td> + <td class="none" align="center">No</td> </tr> <tr id="470"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#470">470</a></td> <td>CD1</td> <td>Instantiation of members of an explicitly-instantiated class template</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="471"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#471">471</a></td> <td>NAD</td> <td>Conflicting inherited access specifications</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr class="open" id="472"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#472">472</a></td> @@ -2885,7 +2885,7 @@ of class templates</td> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#474">474</a></td> <td>CD1</td> <td>Block-scope <TT>extern</TT> declarations in namespace members</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="475"> <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475">475</a></td> |