File tree Expand file tree Collapse file tree 4 files changed +27
-12
lines changed Expand file tree Collapse file tree 4 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -9860,11 +9860,15 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
9860
9860
if (Value.isInt()) {
9861
9861
unsigned Size = Info.Ctx.getTypeSize(E->getType());
9862
9862
uint64_t N = Value.getInt().extOrTrunc(Size).getZExtValue();
9863
- Result.Base = (Expr*)nullptr;
9864
- Result.InvalidBase = false;
9865
- Result.Offset = CharUnits::fromQuantity(N);
9866
- Result.Designator.setInvalid();
9867
- Result.IsNullPtr = false;
9863
+ if (N == Info.Ctx.getTargetNullPointerValue(E->getType())) {
9864
+ Result.setNull(Info.Ctx, E->getType());
9865
+ } else {
9866
+ Result.Base = (Expr *)nullptr;
9867
+ Result.InvalidBase = false;
9868
+ Result.Offset = CharUnits::fromQuantity(N);
9869
+ Result.Designator.setInvalid();
9870
+ Result.IsNullPtr = false;
9871
+ }
9868
9872
return true;
9869
9873
} else {
9870
9874
// In rare instances, the value isn't an lvalue.
Original file line number Diff line number Diff line change @@ -622,7 +622,7 @@ namespace FromIntegral {
622
622
int a[(int )DoubleFn((void *)-1 )()]; // both-error {{not allowed at file scope}} \
623
623
// both-warning {{variable length arrays}}
624
624
int b[(int )DoubleFn((void *)(-1 + 1 ))()]; // both-error {{not allowed at file scope}} \
625
- // expected -note {{evaluates to a null function pointer}} \
625
+ // both -note {{evaluates to a null function pointer}} \
626
626
// both-warning {{variable length arrays}}
627
627
#endif
628
628
}
Original file line number Diff line number Diff line change @@ -27,12 +27,14 @@ template void f<B{nullptr}>();
27
27
// CHECK: define weak_odr void @_Z1fIXtl1BLPKi32EEEEvv(
28
28
// MSABI: define {{.*}} @"??$f@$2UB@@PEBH0CA@H0A@@@@YAXXZ"
29
29
template void f<B{fold ((int *)32 )}>();
30
- #ifndef _WIN32
31
- // FIXME: On MS ABI, we mangle this the same as nullptr, despite considering a
32
- // null pointer and zero bitcast to a pointer to be distinct pointer values.
33
- // CHECK: define weak_odr void @_Z1fIXtl1BrcPKiLi0EEEEvv(
34
- template void f<B{fold (reinterpret_cast <int *>(0 ))}>();
35
- #endif
30
+
31
+ // CHECK: define weak_odr void @_Z1fIXtl1BLPKi0ELi2EEEEvv(
32
+ // MSABI: define {{.*}} @"??$f@$2UB@@PEBH0A@H01@@@YAXXZ"(
33
+ template void f<B{fold (reinterpret_cast <int *>(0 )), 2 }>();
34
+
35
+ // CHECK: define weak_odr void @_Z1fIXtl1BLPKi12EEEEvv(
36
+ // MSABI: define {{.*}} @"??$f@$2UB@@PEBH0M@H0A@@@@YAXXZ"(
37
+ template void f<B{fold (reinterpret_cast <int *>(12 ))}>();
36
38
37
39
// Pointers to subobjects.
38
40
struct Nested { union { int k; int arr[2 ]; }; } nested[2 ];
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -triple amdgcn -cl-std=clc++ -verify %s
2
+
3
+ // expected-no-diagnostics
4
+
5
+ #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
6
+ static_assert(nullptr != fold(reinterpret_cast<private int*>(0)));
7
+
8
+ static_assert(nullptr == (private int *)0);
9
+
You can’t perform that action at this time.
0 commit comments