From: Richard Smith Date: Thu, 11 Sep 2014 17:28:14 +0000 (+0000) Subject: Tests for DR573-580. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=33164b60f110f81b3ea7528d8c52e99e71628a3b;p=clang Tests for DR573-580. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217606 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/drs/dr5xx.cpp b/test/CXX/drs/dr5xx.cpp index 8af639f7b5..770e32278f 100644 --- a/test/CXX/drs/dr5xx.cpp +++ b/test/CXX/drs/dr5xx.cpp @@ -726,3 +726,129 @@ namespace dr572 { // dr572: yes enum E { a = 1, b = 2 }; int check[a + b == 3 ? 1 : -1]; } + +namespace dr573 { // dr573: no + void *a; + int *b = reinterpret_cast(a); + void (*c)() = reinterpret_cast(a); + void *d = reinterpret_cast(c); +#if __cplusplus < 201103L + // expected-error@-3 {{extension}} + // expected-error@-3 {{extension}} +#endif + void f() { delete a; } // expected-error {{cannot delete}} + int n = d - a; // expected-error {{arithmetic on pointers to void}} + // FIXME: This is ill-formed. + template struct S; + template struct T; +} + +namespace dr574 { // dr574: yes + struct A { + A &operator=(const A&) const; // expected-note {{does not match because it is const}} + }; + struct B { + B &operator=(const B&) volatile; // expected-note {{nearly matches}} + }; +#if __cplusplus >= 201103L + struct C { + C &operator=(const C&) &; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}} + }; + struct D { + D &operator=(const D&) &&; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}} + }; + void test(C c, D d) { + c = c; + C() = c; // expected-error {{no viable}} + d = d; // expected-error {{no viable}} + D() = d; + } +#endif + struct Test { + friend A &A::operator=(const A&); // expected-error {{does not match}} + friend B &B::operator=(const B&); // expected-error {{does not match}} +#if __cplusplus >= 201103L + // FIXME: We shouldn't produce the 'cannot overload' diagnostics here. + friend C &C::operator=(const C&); // expected-error {{does not match}} expected-error {{cannot overload}} + friend D &D::operator=(const D&); // expected-error {{does not match}} expected-error {{cannot overload}} +#endif + }; +} + +namespace dr575 { // dr575: yes + template void a(T); void a(...); // expected-error 0-1{{extension}} + template void b(T); void b(...); // expected-error 0-1{{extension}} + template void c(T); void c(...); // expected-error 0-1{{extension}} + template void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}} + void x() { + a(0); + b(0); + c(0); + d(0); // expected-note {{in instantiation of default function argument}} + } + + template void f(T* = 0); // expected-error 0-1{{extension}} + template void f(T = 0); // expected-error 0-1{{extension}} + void g() { f<>(); } + + template T &h(T *); + template T *h(T *); + void *p = h((void*)0); +} + +namespace dr576 { // dr576: yes + typedef void f() {} // expected-error {{function definition is not allowed}} + void f(typedef int n); // expected-error {{invalid storage class}} + void f(char c) { typedef int n; } +} + +namespace dr577 { // dr577: yes + typedef void V; + typedef const void CV; + void a(void); + void b(const void); // expected-error {{qualifiers}} + void c(V); + void d(CV); // expected-error {{qualifiers}} + void (*e)(void) = c; + void (*f)(const void); // expected-error {{qualifiers}} + void (*g)(V) = a; + void (*h)(CV); // expected-error {{qualifiers}} + template void i(T); // expected-note 2{{requires 1 arg}} + template void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}} + void k() { + a(); + c(); + i(); // expected-error {{no match}} + i(); // expected-error {{no match}} + j(0); // expected-error {{no match}} + j(0); // expected-error {{no match}} + } +} + +namespace dr580 { // dr580: no + class C; + struct A { static C c; }; + struct B { static C c; }; + class C { + C(); // expected-note {{here}} + ~C(); // expected-note {{here}} + + typedef int I; // expected-note {{here}} + template struct X; + template friend struct Y; + template void f(); + template friend void g(); + friend struct A; + }; + + template struct C::X {}; + template struct Y {}; + template struct Z {}; // FIXME: should reject, accepted because C befriends A! + + template void C::f() {} + template void g() {} + template void h() {} // expected-error {{private}} + + C A::c; + C B::c; // expected-error 2{{private}} +} diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index dd20f5dd4b..90b1420c15 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -147,7 +147,7 @@ 18 NAD f(TYPE) where TYPE is void should be allowed - Superseded by 577 + Superseded by 577 19 @@ -2033,7 +2033,7 @@ of class templates 332 CD3 cv-qualified void parameter types - Duplicate of 577 + Duplicate of 577 333 @@ -3481,31 +3481,31 @@ and POD class 573 C++11 Conversions between function pointers and void* - Unknown + No 574 NAD Definition of “copy assignment operator” - Unknown + Yes 575 C++11 Criteria for deduction failure - Unknown + Yes 576 CD2 Typedefs in function definitions - Unknown + Yes 577 CD3 void in an empty parameter list - Unknown + Yes 578 @@ -3523,7 +3523,7 @@ and POD class 580 C++11 Access in template-parameters of member and friend definitions - Unknown + No 581