From: Richard Smith Date: Tue, 2 Sep 2014 21:29:16 +0000 (+0000) Subject: Tests for DR550-572. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aeb411378752e79d70fb1246e9eba2f886d80b61;p=clang Tests for DR550-572. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216953 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp index 87a7bdf7b3..b5f6dd7bfc 100644 --- a/test/CXX/drs/dr3xx.cpp +++ b/test/CXX/drs/dr3xx.cpp @@ -366,7 +366,7 @@ namespace dr331 { // dr331: yes } const a, b(a); // expected-error {{no matching constructor}} } -namespace dr332 { // dr332: dup 557 +namespace dr332 { // dr332: dup 577 void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}} void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}} void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}} diff --git a/test/CXX/drs/dr5xx.cpp b/test/CXX/drs/dr5xx.cpp index a349006b95..ac6c9df808 100644 --- a/test/CXX/drs/dr5xx.cpp +++ b/test/CXX/drs/dr5xx.cpp @@ -2,6 +2,11 @@ // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++1y %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// FIXME: This is included to avoid a diagnostic with no source location +// pointing at the implicit operator new. We can't match such a diagnostic +// with -verify. +void *operator new(__SIZE_TYPE__); // expected-warning 0-1{{missing exception spec}} expected-note{{candidate}} + namespace dr500 { // dr500: dup 372 class D; class A { @@ -528,3 +533,186 @@ namespace dr548 { // dr548: dup 482 template struct dr548::S; template void dr548::f(); } + +namespace dr551 { // dr551: yes c++11 + // FIXME: This obviously should apply in C++98 mode too. + template void f() {} + template inline void f(); +#if __cplusplus >= 201103L + // expected-error@-2 {{cannot be 'inline'}} +#endif + + template inline void g() {} + template inline void g(); +#if __cplusplus >= 201103L + // expected-error@-2 {{cannot be 'inline'}} +#endif + + template struct X { + void f() {} + }; + template inline void X::f(); +#if __cplusplus >= 201103L + // expected-error@-2 {{cannot be 'inline'}} +#endif +} + +namespace dr552 { // dr552: yes + template struct X {}; + struct Y { typedef int U; }; + X x; +} + +struct dr553_class { + friend void *operator new(__SIZE_TYPE__, dr553_class); +}; +namespace dr553 { + dr553_class c; + // Contrary to the apparent intention of the DR, operator new is not actually + // looked up with a lookup mechanism that performs ADL; the standard says it + // "is looked up in global scope", where it is not visible. + void *p = new (c) int; // expected-error {{no matching function}} + + struct namespace_scope { + friend void *operator new(__SIZE_TYPE__, namespace_scope); // expected-error {{cannot be declared inside a namespace}} + }; +} + +// dr556: na + +namespace dr557 { // dr557: yes + template struct S { + friend void f(S *); + friend void g(S > *); + }; + void x(S *p, S > *q) { + f(p); + g(q); + } +} + +namespace dr558 { // dr558: yes + wchar_t a = L'\uD7FF'; + wchar_t b = L'\xD7FF'; + wchar_t c = L'\uD800'; // expected-error {{invalid universal character}} + wchar_t d = L'\xD800'; + wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}} + wchar_t f = L'\xDFFF'; + wchar_t g = L'\uE000'; + wchar_t h = L'\xE000'; +} + +template struct dr559 { typedef int T; dr559::T u; }; // dr559: yes + +namespace dr561 { // dr561: yes + template void f(int); + template void g(T t) { + f(t); + } + namespace { + struct S {}; + template static void f(S); + } + void h(S s) { + g(s); + } +} + +namespace dr564 { // dr564: yes + extern "C++" void f(int); + void f(int); // ok + extern "C++" { extern int n; } + int n; // ok +} + +namespace dr565 { // dr565: yes + namespace N { + template int f(T); // expected-note {{target}} + } + using N::f; // expected-note {{using}} + template int f(T*); + template void f(T); + template int f(T); // expected-error 0-1{{extension}} + template int f(T, int = 0); + template int f(T); // expected-error {{conflicts with}} +} + +namespace dr566 { // dr566: yes +#if __cplusplus >= 201103L + int check[int(-3.99) == -3 ? 1 : -1]; +#endif +} + +// dr567: na + +namespace dr568 { // dr568: yes c++11 + // FIXME: This is a DR issue against C++98, so should probably apply there + // too. + struct x { int y; }; + class trivial : x { + x y; + public: + int n; + }; + int check_trivial[__is_trivial(trivial) ? 1 : -1]; + + struct std_layout { + std_layout(); + std_layout(const std_layout &); + ~std_layout(); + private: + int n; + }; + int check_std_layout[__is_standard_layout(std_layout) ? 1 : -1]; + + struct aggregate { + int x; + int y; + trivial t; + std_layout sl; + }; + aggregate aggr = {}; + + void f(...); + void g(trivial t) { f(t); } +#if __cplusplus < 201103L + // expected-error@-2 {{non-POD}} +#endif + + void jump() { + goto x; +#if __cplusplus < 201103L + // expected-error@-2 {{protected scope}} + // expected-note@+2 {{non-POD}} +#endif + trivial t; + x: ; + } +} + +namespace dr569 { // dr569: yes c++11 + // FIXME: This is a DR issue against C++98, so should probably apply there + // too. + ;;;;; +#if __cplusplus < 201103L + // expected-error@-2 {{C++11 extension}} +#endif +} + +namespace dr570 { // dr570: dup 633 + int n; + int &r = n; // expected-note {{previous}} + int &r = n; // expected-error {{redefinition}} +} + +namespace dr571 { // dr571 unknown + // FIXME: Add a codegen test. + typedef int &ir; + int n; + const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage. +} + +namespace dr572 { // dr572: yes + enum E { a = 1, b = 2 }; + int check[a + b == 3 ? 1 : -1]; +} diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index dba3275df9..14ce95ac32 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -1967,7 +1967,7 @@ of class templates 321 dup Associated classes and namespaces for argument-dependent lookup - Duplicate of 557 + Duplicate of 557 322 @@ -2033,7 +2033,7 @@ of class templates 332 CD3 cv-qualified void parameter types - Duplicate of 557 + Duplicate of 577 333 @@ -3349,13 +3349,13 @@ and POD class 551 CD1 When is inline permitted in an explicit instantiation? - Unknown + Yes (C++11 onwards) 552 NAD Use of typename in the type in a non-type parameter-declaration - Unknown + Yes 553 @@ -3379,25 +3379,25 @@ and POD class 556 CD2 Conflicting requirements for acceptable aliasing - Unknown + N/A 557 CD1 Does argument-dependent lookup cause template instantiation? - Unknown + Yes 558 CD1 Excluded characters in universal character names - Unknown + Yes 559 CD1 Editing error in issue 382 resolution - Unknown + Yes 560 @@ -3409,7 +3409,7 @@ and POD class 561 CD2 Internal linkage functions in dependent name lookup - Unknown + Yes 562 @@ -3427,43 +3427,43 @@ and POD class 564 CD2 Agreement of language linkage or linkage-specifications? - Unknown + Yes 565 CD3 Conflict rules for using-declarations naming function templates - Unknown + Yes 566 NAD Conversion of negative floating point values to integer type - Unknown + Yes 567 NAD Can size_t and ptrdiff_t be larger than long? - Unknown + N/A 568 CD1 Definition of POD is too strict - Unknown + Yes (C++11 onwards) 569 CD2 Spurious semicolons at namespace scope should be allowed - Unknown + Yes (C++11 onwards) 570 CD2 Are references subject to the ODR? - Unknown + Duplicate of 633 571 @@ -3475,7 +3475,7 @@ and POD class 572 C++11 Standard conversions for non-built-in types - Unknown + Yes 573