diff --git a/clang/test/CXX/drs/dr11xx.cpp b/clang/test/CXX/drs/dr11xx.cpp index 86e726ae8c741..a71a105c7eb20 100644 --- a/clang/test/CXX/drs/dr11xx.cpp +++ b/clang/test/CXX/drs/dr11xx.cpp @@ -70,3 +70,5 @@ namespace dr1113 { // dr1113: partial } void g() { f(); } } + +// dr1150: na diff --git a/clang/test/CXX/drs/dr14xx.cpp b/clang/test/CXX/drs/dr14xx.cpp index d262f6f9dcab7..58a2b3a0d0275 100644 --- a/clang/test/CXX/drs/dr14xx.cpp +++ b/clang/test/CXX/drs/dr14xx.cpp @@ -614,6 +614,30 @@ enum E2 : S::I { e }; #endif } // namespace dr1482 +namespace dr1487 { // dr1487: 3.3 +#if __cplusplus >= 201103L +struct A { // #dr1482-A + struct B { + using A::A; + // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'B'}} + }; + + struct C : A { + // since-cxx11-error@-1 {{base class has incomplete type}} + // since-cxx11-note@#dr1482-A {{definition of 'dr1487::A' is not complete until the closing '}'}} + using A::A; + // since-cxx11-error@-1 {{using declaration refers into 'A::', which is not a base class of 'C'}} + }; + + struct D; +}; + +struct D : A { + using A::A; +}; +#endif +} // namespace dr1487 + namespace dr1490 { // dr1490: 3.7 c++11 #if __cplusplus >= 201103L // List-initialization from a string literal diff --git a/clang/test/CXX/drs/dr15xx.cpp b/clang/test/CXX/drs/dr15xx.cpp index 3d4050a5713f9..ac503db625ba0 100644 --- a/clang/test/CXX/drs/dr15xx.cpp +++ b/clang/test/CXX/drs/dr15xx.cpp @@ -360,6 +360,45 @@ namespace dr1563 { // dr1563: yes #endif } +namespace dr1567 { // dr1567: 3.3 +#if __cplusplus >= 201103L +struct B; +struct A { + A(const A&); + A(const B&) = delete; + A(A&&); + A(B&&) = delete; + A(int); // #dr1567-A-int +}; + +struct B: A { // #dr1567-B + using A::A; // #dr1567-using-A + B(double); // #dr1567-B-double +}; + +A a{0}; +B b{1.0}; +// Good, deleted converting ctors are not inherited as copy/move ctors +B b2{b}; +B b3{B{1.0}}; +// Good, copy/move ctors are not inherited +B b4{a}; +// since-cxx11-error@-1 {{no matching constructor for initialization of 'B'}} +// since-cxx11-note@#dr1567-A-int {{candidate inherited constructor not viable: no known conversion from 'A' to 'int' for 1st argument}} +// since-cxx11-note@#dr1567-using-A {{constructor from base class 'A' inherited here}} +// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A' to 'const B' for 1st argument}} +// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A' to 'B' for 1st argument}} +// since-cxx11-note@#dr1567-B-double {{candidate constructor not viable: no known conversion from 'A' to 'double' for 1st argument}} +B b5{A{0}}; +// since-cxx11-error@-1 {{no matching constructor for initialization of 'B'}} +// since-cxx11-note@#dr1567-A-int {{candidate inherited constructor not viable: no known conversion from 'A' to 'int' for 1st argument}} +// since-cxx11-note@#dr1567-using-A {{constructor from base class 'A' inherited here}} +// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A' to 'const B' for 1st argument}} +// since-cxx11-note@#dr1567-B {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'A' to 'B' for 1st argument}} +// since-cxx11-note@#dr1567-B-double {{candidate constructor not viable: no known conversion from 'A' to 'double' for 1st argument}} +#endif +} + namespace dr1573 { // dr1573: 3.9 #if __cplusplus >= 201103L // ellipsis is inherited (p0136r1 supersedes this part). diff --git a/clang/test/CXX/drs/dr17xx.cpp b/clang/test/CXX/drs/dr17xx.cpp index 885ed00ace0f5..2f7e62da7bb60 100644 --- a/clang/test/CXX/drs/dr17xx.cpp +++ b/clang/test/CXX/drs/dr17xx.cpp @@ -89,6 +89,23 @@ S s(q); // #dr1736-s #endif } +namespace dr1738 { // dr1738: sup P0136R1 +#if __cplusplus >= 201103L +struct A { + template + A(int, T) {} +}; + +struct B : A { + using A::A; +}; + +// FIXME: this is well-formed since P0136R1 +template B::B(int, double); +// since-cxx11-error@-1 {{explicit instantiation of 'B' does not refer to a function template, variable template, member function, member class, or static data member}} +#endif +} + // dr1748 is in dr1748.cpp namespace dr1753 { // dr1753: 11 diff --git a/clang/test/CXX/drs/dr22xx.cpp b/clang/test/CXX/drs/dr22xx.cpp index 19518247b5289..3a13cb0471a75 100644 --- a/clang/test/CXX/drs/dr22xx.cpp +++ b/clang/test/CXX/drs/dr22xx.cpp @@ -154,6 +154,47 @@ const D &d3(c); // FIXME ill-formed #endif } +namespace dr2273 { // dr2273: 3.3 +#if __cplusplus >= 201103L +struct A { + A(int = 0) = delete; // #dr2273-A +}; + +struct B : A { // #dr2273-B + using A::A; +}; + +B b; +// since-cxx11-error@-1 {{call to implicitly-deleted default constructor of 'B'}} +// since-cxx11-note@#dr2273-B {{default constructor of 'B' is implicitly deleted because base class 'A' has a deleted default constructor}} +// since-cxx11-note@#dr2273-A {{'A' has been explicitly marked deleted here}} +#endif +} + +namespace dr2277 { // dr2277: partial +#if __cplusplus >= 201103L +struct A { + A(int, int = 0); + void f(int, int = 0); // #dr2277-A-f +}; +struct B : A { + B(int); + using A::A; + + void f(int); // #dr2277-B-f + using A::f; +}; + +void g() { + B b{0}; + b.f(0); // FIXME: this is well-formed for the same reason as initialization of 'b' above + // since-cxx11-error@-1 {{call to member function 'f' is ambiguous}} + // since-cxx11-note@#dr2277-A-f {{candidate function}} + // since-cxx11-note@#dr2277-B-f {{candidate function}} +} +#endif +} + namespace dr2292 { // dr2292: 9 #if __cplusplus >= 201103L template using id = T; diff --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp index 3f8c476427eba..c0463730b6a23 100644 --- a/clang/test/CXX/drs/dr23xx.cpp +++ b/clang/test/CXX/drs/dr23xx.cpp @@ -147,6 +147,31 @@ enum struct alignas(64) B {}; #endif } // namespace dr2354 +namespace dr2356 { // dr2356: 4 +#if __cplusplus >= 201103L +struct A { + A(); + A(A &&); // #1 + template A(T &&); // #2 +}; +struct B : A { + using A::A; + B(const B &); // #3 + B(B &&) = default; // #4, implicitly deleted + // since-cxx11-warning@-1 {{explicitly defaulted move constructor is implicitly deleted}} + // since-cxx11-note@#dr2356-X {{move constructor of 'B' is implicitly deleted because field 'x' has a deleted move constructor}} + // since-cxx11-note@#dr2356-X {{'X' has been explicitly marked deleted here}} + // since-cxx11-note@-4 {{replace 'default' with 'delete'}} + + struct X { X(X &&) = delete; } x; // #dr2356-X +}; +extern B b1; +B b2 = static_cast(b1); // calls #3: #1, #2, and #4 are not viable +struct C { operator B&&(); }; +B b3 = C(); // calls #3 +#endif +} + #if __cplusplus >= 201402L namespace dr2358 { // dr2358: 16 void f2() { diff --git a/clang/test/CXX/drs/dr2504.cpp b/clang/test/CXX/drs/dr2504.cpp new file mode 100644 index 0000000000000..686ea73cd6a0e --- /dev/null +++ b/clang/test/CXX/drs/dr2504.cpp @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK +// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 +// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 +// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 +// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 +// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 +// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11 + +namespace dr2504 { // dr2504: no +#if __cplusplus >= 201103L +struct V { V() = default; V(int); }; +struct Q { Q(); }; +struct A : virtual V, Q { + using V::V; + A() = delete; +}; +int bar() { return 42; } +struct B : A { + B() : A(bar()) {} // ok +}; +struct C : B {}; +void foo() { C c; } // bar is not invoked, because the V subobject is not initialized as part of B +#endif +} + +// FIXME: As specified in the comment above (which comes from an example in the Standard), +// we are not supposed to unconditionally call `bar()` and call a constructor +// inherited from `V`. + +// SINCE-CXX11-LABEL: define linkonce_odr void @dr2504::B::B() +// SINCE-CXX11-NOT: br +// SINCE-CXX11: call noundef i32 @dr2504::bar() +// SINCE-CXX11-NOT: br +// SINCE-CXX11: call void @dr2504::A::A(int) +// SINCE-CXX11-LABEL: } + +// CHECK: {{.*}} diff --git a/clang/test/CXX/drs/dr25xx.cpp b/clang/test/CXX/drs/dr25xx.cpp index 502f03271d9af..b1e54804fc895 100644 --- a/clang/test/CXX/drs/dr25xx.cpp +++ b/clang/test/CXX/drs/dr25xx.cpp @@ -10,6 +10,8 @@ // expected-no-diagnostics #endif +// dr2504 is in dr2504.cpp + namespace dr2516 { // dr2516: 3.0 // NB: reusing 1482 test #if __cplusplus >= 201103L diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 3e13a4d89ef98..4ce5c430a47c9 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -6708,7 +6708,7 @@

C++ defect report implementation status

1150 NAD Inheriting constructors have not been implemented - Unknown + N/A 1151 @@ -8730,7 +8730,7 @@

C++ defect report implementation status

1487 CD3 When are inheriting constructors declared? - Unknown + Clang 3.3 1488 @@ -9210,7 +9210,7 @@

C++ defect report implementation status

1567 C++14 Inheriting constructors and copy/move constructors - Unknown + Clang 3.3 1568 @@ -10236,7 +10236,7 @@

C++ defect report implementation status

1738 C++14 Explicit instantiation/specialization of inheriting constructor templates - Unknown + Superseded by P0136R1 1739 @@ -13446,7 +13446,7 @@

C++ defect report implementation status

2273 CD5 Inheriting constructors vs implicit default constructor - Unknown + Clang 3.3 2274 @@ -13470,7 +13470,7 @@

C++ defect report implementation status

2277 CD5 Ambiguity inheriting constructors with default arguments - Unknown + Partial 2278 @@ -13944,7 +13944,7 @@

C++ defect report implementation status

2356 CD5 Base class copy and move constructors should not be inherited - Unknown + Clang 4 2357 @@ -14832,7 +14832,7 @@

C++ defect report implementation status

2504 DR Inheriting constructors from virtual base classes - Unknown + No 2505