Skip to content

[clang] Add CodeGen tests for CWG 6xx issues #87876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions clang/test/CXX/drs/dr605.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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
// 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
// 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
// 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
// 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
// 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

namespace dr605 { // dr605: 2.7

template <class T>
static T f(T t) {}

template <>
int f(int t) {}

void g(int a) {
f(a);
}

} // namespace dr605

// CHECK: define internal {{.*}} i32 @int dr605::f<int>(int)
40 changes: 40 additions & 0 deletions clang/test/CXX/drs/dr650.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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
// 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
// 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
// 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
// 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
// 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

#if __cplusplus == 199711L
#define NOTHROW throw()
#else
#define NOTHROW noexcept(true)
#endif

namespace dr650 { // dr650: 2.8

struct Q {
~Q() NOTHROW;
};

struct R {
~R() NOTHROW;
};

struct S {
~S() NOTHROW;
};

const S& f() {
Q q;
return (R(), S());
}

} // namespace dr650

// CHECK-LABEL: define {{.*}} @dr650::f()()
// CHECK: call void @dr650::S::~S()
// CHECK: call void @dr650::R::~R()
// CHECK: call void @dr650::Q::~Q()
// CHECK-LABEL: }
25 changes: 25 additions & 0 deletions clang/test/CXX/drs/dr653.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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
// 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
// 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
// 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
// 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
// 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

namespace dr653 { // dr653: 2.7

union U {
int a;
float b;
};

void f(U u) {
U v;
v = u;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also test that unions without trivial copy are rejected? It seems to me that the 'we copy as if via memcpy''s fallout is that we can't copy things that aren't trivial to copy.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM on this.

}

} // namespace dr653

// CHECK-LABEL: define {{.*}} void @dr653::f(dr653::U)
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} %v, ptr {{.*}} %u, {{.*}})
// CHECK-LABEL: }
25 changes: 25 additions & 0 deletions clang/test/CXX/drs/dr658.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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
// 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
// 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
// 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
// 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
// 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

namespace dr658 { // dr658: 2.7

void f(int* p1) {
char* p2 = reinterpret_cast<char*>(p1);
}

} // namespace dr658

// We're checking that p1 is stored into p2 without changes.

// CHECK-LABEL: define {{.*}} void @dr658::f(int*)(ptr noundef %p1)
// CHECK: [[P1_ADDR:%.+]] = alloca ptr, align 8
// CHECK-NEXT: [[P2:%.+]] = alloca ptr, align 8
// CHECK: store ptr %p1, ptr [[P1_ADDR]]
// CHECK-NEXT: [[TEMP:%.+]] = load ptr, ptr [[P1_ADDR]]
// CHECK-NEXT: store ptr [[TEMP]], ptr [[P2]]
// CHECK-LABEL: }
29 changes: 29 additions & 0 deletions clang/test/CXX/drs/dr661.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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
// 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
// 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
// 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
// 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
// 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

namespace dr661 {

void f(int a, int b) { // dr661: 2.7
a == b;
a != b;
a < b;
a <= b;
a > b;
a >= b;
}

} // namespace dr661

// CHECK-LABEL: define {{.*}} void @dr661::f(int, int)
// CHECK: icmp eq
// CHECK: icmp ne
// CHECK: icmp slt
// CHECK: icmp sle
// CHECK: icmp sgt
// CHECK: icmp sge
// CHECK-LABEL: }
32 changes: 32 additions & 0 deletions clang/test/CXX/drs/dr672.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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
// 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
// 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
// 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
// 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
// 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

#if __cplusplus == 199711L
#define NOTHROW throw()
#else
#define NOTHROW noexcept(true)
#endif

namespace dr672 { // dr672: 2.7

struct A {
A() NOTHROW;
};

void f() {
A *a = new A;
}

} // namespace dr672

// CHECK-LABEL: define {{.*}} void @dr672::f()()
// CHECK: [[A:%.+]] = alloca ptr
// CHECK: [[CALL:%.+]] = call {{.*}} ptr @operator new(unsigned long)
// CHECK: call void @dr672::A::A()
// CHECK: store ptr [[CALL]], ptr [[A]]
// CHECK-LABEL: }
16 changes: 8 additions & 8 deletions clang/test/CXX/drs/dr6xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace dr603 { // dr603: yes
}

// dr604: na
// dr605 needs IRGen test
// dr605 is in dr605.cpp

namespace dr606 { // dr606: 3.0
#if __cplusplus >= 201103L
Expand Down Expand Up @@ -253,7 +253,7 @@ namespace dr621 { // dr621: yes
// dr623: na
// FIXME: Add documentation saying we allow invalid pointer values.

// dr624 needs an IRGen check.
// dr624 needs a libc++abi test.

namespace dr625 { // dr625: yes
template<typename T> struct A {};
Expand Down Expand Up @@ -650,7 +650,7 @@ struct Y {
}
#endif

// dr650 FIXME: add codegen test
// dr650 is in dr650.cpp

#if __cplusplus >= 201103L
namespace dr651 { // dr651: yes
Expand All @@ -672,7 +672,7 @@ namespace dr652 { // dr652: yes
}
#endif

// dr653 FIXME: add codegen test
// dr653 is in dr653.cpp

#if __cplusplus >= 201103L
namespace dr654 { // dr654: sup 1423
Expand Down Expand Up @@ -798,7 +798,7 @@ namespace dr657 { // dr657: partial
Cnvt2<Abs>::type err;
}

// dr658 FIXME: add codegen test
// dr658 is in dr658.cpp

#if __cplusplus >= 201103L
namespace dr659 { // dr659: 3.0
Expand Down Expand Up @@ -829,7 +829,7 @@ namespace dr660 { // dr660: 3.0
}
#endif

// dr661 FIXME: add codegen test
// dr661 is in dr661.cpp

namespace dr662 { // dr662: yes
template <typename T> void f(T t) {
Expand Down Expand Up @@ -931,7 +931,7 @@ namespace dr667 { // dr667: 8
}
#endif

// dr668 FIXME: add codegen test
// dr668 needs an libc++abi test

#if __cplusplus >= 201103L
namespace dr669 { // dr669: yes
Expand Down Expand Up @@ -971,7 +971,7 @@ namespace dr671 { // dr671: 2.9
int m = static_cast<int>(e);
}

// dr672 FIXME: add codegen test
// dr672 is in dr672.cpp

namespace dr673 { // dr673: yes
template<typename> struct X { static const int n = 0; };
Expand Down
12 changes: 6 additions & 6 deletions clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -3672,7 +3672,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/605.html">605</a></td>
<td>C++11</td>
<td>Linkage of explicit specializations</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="606">
<td><a href="https://cplusplus.github.io/CWG/issues/606.html">606</a></td>
Expand Down Expand Up @@ -3942,7 +3942,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/650.html">650</a></td>
<td>CD2</td>
<td>Order of destruction for temporaries bound to the returned value of a function</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.8</td>
</tr>
<tr id="651">
<td><a href="https://cplusplus.github.io/CWG/issues/651.html">651</a></td>
Expand All @@ -3960,7 +3960,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/653.html">653</a></td>
<td>CD2</td>
<td>Copy assignment of unions</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="654">
<td><a href="https://cplusplus.github.io/CWG/issues/654.html">654</a></td>
Expand Down Expand Up @@ -3990,7 +3990,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/658.html">658</a></td>
<td>CD2</td>
<td>Defining <TT>reinterpret_cast</TT> for pointer types</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="659">
<td><a href="https://cplusplus.github.io/CWG/issues/659.html">659</a></td>
Expand All @@ -4008,7 +4008,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/661.html">661</a></td>
<td>CD1</td>
<td>Semantics of arithmetic comparisons</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="662">
<td><a href="https://cplusplus.github.io/CWG/issues/662.html">662</a></td>
Expand Down Expand Up @@ -4074,7 +4074,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/672.html">672</a></td>
<td>CD2</td>
<td>Sequencing of initialization in <I>new-expression</I>s</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="673">
<td><a href="https://cplusplus.github.io/CWG/issues/673.html">673</a></td>
Expand Down