Skip to content

Commit 5febef5

Browse files
committed
Treat signed size_t literals to be of type ptrdiff_t
1 parent ec69d58 commit 5febef5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16716,7 +16716,7 @@ static bool CheckOperatorNewDeclaration(Sema &SemaRef, FunctionDecl *FnDecl) {
1671616716
return true;
1671716717

1671816718
CanQualType SizeTy =
16719-
SemaRef.Context.getCanonicalType(SemaRef.Context.getSizeType());
16719+
SemaRef.Context.getCanonicalType(SemaRef.Context.getSizeType());
1672016720

1672116721
// C++ [basic.stc.dynamic.allocation]p1:
1672216722
// The return type shall be void*. The first parameter shall have type

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4025,8 +4025,9 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
40254025

40264026
// Does it fit in size_t?
40274027
if (ResultVal.isIntN(SizeTSize)) {
4028-
// Does it fit in ptrdiff_t?
4028+
// Does it fit in signed size_t?
40294029
if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
4030+
// treat it as ptrdiff_t to distinguish it from long/long long
40304031
Ty = Context.getPointerDiffType();
40314032
else if (AllowUnsigned)
40324033
Ty = Context.getSizeType();

0 commit comments

Comments
 (0)