Skip to content
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
5 changes: 4 additions & 1 deletion clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,10 @@ bool CallVirt(InterpState &S, CodePtr OpPC, const Function *Func,

bool CallBI(InterpState &S, CodePtr OpPC, const Function *Func,
const CallExpr *CE, uint32_t BuiltinID) {
if (S.checkingPotentialConstantExpression())
// A little arbitrary, but the current interpreter allows evaluation
// of builtin functions in this mode, with some exceptions.
if (BuiltinID == Builtin::BI__builtin_operator_new &&
S.checkingPotentialConstantExpression())
return false;
auto NewFrame = std::make_unique<InterpFrame>(S, Func, OpPC);

Expand Down
4 changes: 2 additions & 2 deletions clang/test/AST/ByteCode/builtin-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,11 +1198,11 @@ namespace BuiltinMemcpy {
}
static_assert(simpleMove() == 12);

constexpr int memcpyTypeRem() { // ref-error {{never produces a constant expression}}
constexpr int memcpyTypeRem() { // both-error {{never produces a constant expression}}
int a = 12;
int b = 0;
__builtin_memmove(&b, &a, 1); // both-note {{'memmove' not supported: size to copy (1) is not a multiple of size of element type 'int'}} \
// ref-note {{not supported}}
// both-note {{not supported}}
return b;
}
static_assert(memcpyTypeRem() == 12); // both-error {{not an integral constant expression}} \
Expand Down
Loading