Skip to content

Commit cd472fe

Browse files
author
git apple-llvm automerger
committed
Merge commit '45bd85e48152' from llvm.org/main into next
2 parents a5f9b16 + 45bd85e commit cd472fe

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ bool ByteCodeExprGen<Emitter>::VisitCastExpr(const CastExpr *CE) {
212212
if (!this->visit(SubExpr))
213213
return false;
214214

215+
// If SubExpr doesn't result in a pointer, make it one.
216+
if (PrimType FromT = classifyPrim(SubExpr->getType()); FromT != PT_Ptr) {
217+
assert(isPtrType(FromT));
218+
if (!this->emitDecayPtr(FromT, PT_Ptr, CE))
219+
return false;
220+
}
221+
215222
PrimType T = classifyPrim(CE->getType());
216223
if (T == PT_IntAP)
217224
return this->emitCastPointerIntegralAP(Ctx.getBitWidth(CE->getType()),

clang/test/AST/Interp/c.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,10 @@ const int *p = &b;
263263
const __int128 K = (__int128)(int*)0;
264264
const unsigned __int128 KU = (unsigned __int128)(int*)0;
265265
#endif
266+
267+
268+
int test3(void) {
269+
int a[2];
270+
a[0] = test3; // all-error {{incompatible pointer to integer conversion assigning to 'int' from 'int (void)'}}
271+
return 0;
272+
}

0 commit comments

Comments
 (0)