-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Add tests for DRs about inheriting constructors (#79981)
Covers CWG issues [1150](https://cplusplus.github.io/CWG/issues/1150.html), [1487](https://cplusplus.github.io/CWG/issues/1487.html), [1567](https://cplusplus.github.io/CWG/issues/1567.html), [1738](https://cplusplus.github.io/CWG/issues/1738.html), [2273](https://cplusplus.github.io/CWG/issues/2273.html), [2277](https://cplusplus.github.io/CWG/issues/2277.html), [2356](https://cplusplus.github.io/CWG/issues/2356.html), [2504](https://cplusplus.github.io/CWG/issues/2504.html). On top of the wording in proposed resolutions, [P0136R1](https://wg21.link/p0136r1) "Rewording inheriting constructors (core issue 1941 et al)" is a very relevant paper. Note that status for 1738 `sup P0136R1` is not officially recognized by CWG, but saying `yes` or `no` seems even more confusing to me. Official resolution is to reject certain code, but Clang is the only implementation that still rejects it to this day: https://godbolt.org/z/b1W8jc1o5. GCC rejected it until 9, now it's accepted: https://godbolt.org/z/of6oh4sdT
- Loading branch information
Showing
9 changed files
with
195 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,5 @@ namespace dr1113 { // dr1113: partial | |
} | ||
void g() { f(); } | ||
} | ||
|
||
// dr1150: na |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: {{.*}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters