Skip to content

Commit 609c88a

Browse files
authored
[Clang][Sema] Fix __builtin_infer_alloc_token() return type (llvm#168773)
Using the builtin failed on 32-bit architectures: ``` clang/lib/AST/ExprConstant.cpp:14299: [..]: Assertion `I.getBitWidth() == Info.Ctx.getIntWidth(E->getType()) && "Invalid evaluation result."' failed. ``` The return type is meant to be size_t. Fix it.
1 parent 2b16ae0 commit 609c88a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ static bool checkBuiltinInferAllocToken(Sema &S, CallExpr *TheCall) {
15121512
return S.Diag(Arg->getBeginLoc(), diag::err_param_with_void_type);
15131513
}
15141514

1515-
TheCall->setType(S.Context.UnsignedLongLongTy);
1515+
TheCall->setType(S.Context.getSizeType());
15161516
return false;
15171517
}
15181518

clang/test/SemaCXX/alloc-token.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -fexperimental-new-constant-interpreter
44
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -falloc-token-mode=typehash -DMODE_TYPEHASH
55
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2
6+
// RUN: %clang_cc1 -triple arm-linux-androideabi -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2
7+
// RUN: %clang_cc1 -triple arm-linux-androideabi -std=c++23 -fsyntax-only -verify %s -falloc-token-max=2 -DTOKEN_MAX=2 -fexperimental-new-constant-interpreter
68

79
#if !__has_builtin(__builtin_infer_alloc_token)
810
#error "missing __builtin_infer_alloc_token"

0 commit comments

Comments
 (0)