Skip to content

Commit 50dbd2c

Browse files
committed
[clang][Sema] Tests for GH41441
I've borrowed size-calculation test from PR89036 and added another test, which PR89036 fails on.
1 parent 096b999 commit 50dbd2c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

clang/test/SemaCXX/GH41441.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 %s -fsyntax-only -verify
3+
4+
namespace std {
5+
using size_t = decltype(sizeof(int));
6+
};
7+
void* operator new[](std::size_t, void*) noexcept;
8+
9+
// CHECK: call void @llvm.memset.p0.i64(ptr align 1 %x, i8 0, i64 8, i1 false)
10+
// CHECK: call void @llvm.memset.p0.i64(ptr align 16 %x, i8 0, i64 32, i1 false)
11+
template <typename TYPE>
12+
void f()
13+
{
14+
typedef TYPE TArray[8];
15+
16+
TArray x;
17+
new(&x) TArray();
18+
}
19+
20+
template <typename T>
21+
void f1() {
22+
int (*x)[1] = new int[1][1];
23+
}
24+
template void f1<char>();
25+
void f2() {
26+
int (*x)[1] = new int[1][1];
27+
}
28+
29+
int main()
30+
{
31+
f<char>();
32+
f<int>();
33+
}
34+
35+
// expected-no-diagnostics
36+
template <typename T> struct unique_ptr {unique_ptr(T* p){}};
37+
38+
template <typename T>
39+
unique_ptr<T> make_unique(unsigned long long n) {
40+
return unique_ptr<T>(new T[n]());
41+
}
42+
43+
auto boro(int n){
44+
typedef double HistoryBuffer[4];
45+
return make_unique<HistoryBuffer>(n);
46+
}

0 commit comments

Comments
 (0)