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
10 changes: 8 additions & 2 deletions clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2042,10 +2042,16 @@ static bool interp__builtin_memchr(InterpState &S, CodePtr OpPC,
}

if (ID == Builtin::BIstrchr || ID == Builtin::BI__builtin_strchr) {
int64_t DesiredTrunc;
if (S.getASTContext().CharTy->isSignedIntegerType())
DesiredTrunc =
Desired.trunc(S.getASTContext().getCharWidth()).getSExtValue();
else
DesiredTrunc =
Desired.trunc(S.getASTContext().getCharWidth()).getZExtValue();
// strchr compares directly to the passed integer, and therefore
// always fails if given an int that is not a char.
if (Desired !=
Desired.trunc(S.getASTContext().getCharWidth()).getSExtValue()) {
if (Desired != DesiredTrunc) {
S.Stk.push<Pointer>();
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions clang/test/SemaCXX/constexpr-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-signed-char
// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-wchar -DNO_PREDEFINED_WCHAR_T

// RUN: %clang_cc1 %s -triple armebv7-unknown-linux -std=c++2a -fsyntax-only -verify -pedantic -Wno-vla-extension -fno-signed-char -fexperimental-new-constant-interpreter

# 9 "/usr/include/string.h" 1 3 4 // expected-warning {{this style of line directive is a GNU extension}}
extern "C" {
typedef decltype(sizeof(int)) size_t;
Expand Down