From: Richard Smith Date: Mon, 3 Feb 2014 06:34:23 +0000 (+0000) Subject: Tests for DR331-350. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6bab958d4166278ff1591d9e1d5f20942f5ae9c6;p=clang Tests for DR331-350. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200678 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp index c2b5cb1e00..2791c1f311 100644 --- a/test/CXX/drs/dr3xx.cpp +++ b/test/CXX/drs/dr3xx.cpp @@ -330,3 +330,200 @@ namespace dr329 { // dr329: 3.5 h(a); // expected-note {{instantiation}} } } + +namespace dr331 { // dr331: yes + struct A { + A(volatile A&); // expected-note {{candidate}} + } const a, b(a); // expected-error {{no matching constructor}} +} + +namespace dr332 { // dr332: dup 557 + 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}} +} + +namespace dr333 { // dr333: yes + int n = 0; + int f(int(n)); + int g((int(n))); + int h = f(g); +} + +namespace dr334 { // dr334: yes + template void f() { + T x; + f((x, 123)); + } + struct S { + friend S operator,(S, int); + friend void f(S); + }; + template void f(); +} + +// dr335: no + +namespace dr336 { // dr336: yes + namespace Pre { + template class A { + template class B { + template void mf1(T3); + void mf2(); + }; + }; + template<> template class A::B {}; + template<> template<> template void A::B::mf1(T t) {} // expected-error {{does not match}} + template template<> void A::B::mf2() {} // expected-error {{does not refer into a class}} + } + namespace Post { + template class A { + template class B { + template void mf1(T3); + void mf2(); + }; + }; + template<> template class A::B { + template void mf1(T); + }; + template<> template<> template void A::B::mf1(T t) {} + // FIXME: This diagnostic isn't very good. + template template<> void A::B::mf2() {} // expected-error {{does not refer into a class}} + } +} + +namespace dr337 { // dr337: yes + template void f(T (*)[1]); + template int &f(...); + + struct A { virtual ~A() = 0; }; + int &r = f(0); + + // FIXME: The language rules here are completely broken. We cannot determine + // whether an incomplete type is abstract. See DR1640, which will probably + // supersede this one and remove this rule. + struct B; + int &s = f(0); // expected-error {{of type 'void'}} + struct B { virtual ~B() = 0; }; +} + +namespace dr339 { // dr339: yes + template struct A { static const int value = I; }; + + char xxx(int); + char (&xxx(float))[2]; + + template A f(T) {} // expected-note {{candidate}} + + void test() { + A<1> a = f(0); + A<2> b = f(0.0f); + A<3> c = f("foo"); // expected-error {{no matching function}} + } + + + char f(int); + int f(...); + + template struct conv_int { + static const bool value = sizeof(f(T())) == 1; + }; + + template bool conv_int2(A p); + + template A make_A(); + + int a[conv_int::value ? 1 : -1]; + bool b = conv_int2(A<1>()); + A<1> c = make_A(); +} + +namespace dr340 { // dr340: yes + struct A { A(int); }; + struct B { B(A, A, int); }; + int x, y; + B b(A(x), A(y), 3); +} + +namespace dr341 { // dr341: sup 1708 + namespace A { + int n; + extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}} + } + namespace B { + extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}} + } + extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}} +} +int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}} +int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}} +int dr341_c; // expected-note {{declared in global scope here}} +int dr341_d; // expected-note {{declared in global scope here}} +namespace dr341 { + extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}} + extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}} + + namespace A { extern "C" int dr341_e; } // expected-note {{previous}} + namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}} +} + +// dr342: na + +namespace dr345 { // dr345: yes + struct A { + struct X {}; + int X; // expected-note {{here}} + }; + struct B { + struct X {}; + }; + template void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}} + void f(A a, B b) { + f(b); + f(a); // expected-note {{instantiation}} + } +} + +// dr346: na + +namespace dr347 { // dr347: yes + struct base { + struct nested; + static int n; + static void f(); + void g(); + }; + + struct derived : base {}; + + struct derived::nested {}; // expected-error {{no struct named 'nested'}} + int derived::n; // expected-error {{no member named 'n'}} + void derived::f() {} // expected-error {{does not match any}} + void derived::g() {} // expected-error {{does not match any}} +} + +// dr348: na + +namespace dr349 { // dr349: no + struct A { + template operator T ***() { + int ***p = 0; + return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}} + } + }; + + // FIXME: This is valid. + A a; + const int *const *const *p1 = a; // expected-note {{in instantiation of}} + + struct B { + template operator T ***() { + const int ***p = 0; + return p; + } + }; + + // FIXME: This is invalid. + B b; + const int *const *const *p2 = b; +} diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html index 33c8ba4113..3600c7335c 100644 --- a/www/cxx_dr_status.html +++ b/www/cxx_dr_status.html @@ -2027,43 +2027,43 @@ of class templates 331 CD1 Allowed copy constructor signatures - Unknown + Yes 332 DRWP cv-qualified void parameter types - Unknown + Duplicate of 557 333 NAD Ambiguous use of "declaration" in disambiguation section - Unknown + Yes 334 NAD Is a comma-expression dependent if its first operand is? - Unknown + Yes 335 CD1 Allowing export on template members of nontemplate classes - Unknown + No 336 CD1 Explicit specialization examples are still incorrect - Unknown + Yes 337 CD1 Attempt to create array of abtract type should cause deduction to fail - Unknown + Yes 338 @@ -2075,25 +2075,25 @@ of class templates 339 CD1 Overload resolution in operand of sizeof in constant expression - Unknown + Yes 340 NAD Unclear wording in disambiguation section - Unknown + Yes 341 FDIS extern "C" namespace member function versus global variable - Unknown + Superseded by 1708 342 DRWP Terminology: "indirection" versus "dereference" - Unknown + N/A 343 @@ -2111,31 +2111,31 @@ of class templates 345 CD1 Misleading comment on example in templates chapter - Unknown + Yes 346 NAD Typo in 15.4 - Unknown + N/A 347 NAD Use of derived class name in defining base class nested class - Unknown + Yes 348 CD1 delete and user-written deallocation functions - Unknown + N/A 349 CD1 Template argument deduction for conversion functions and qualification conversions - Unknown + No 350