Skip to content

Commit 040fc53

Browse files
author
Tim Corringham
committed
Add missing diagnostic argument
Two instances of the err_integer_literal_too_large diagnostic in HLSL specific code within Sema::ActOnNumericConstant() had a missing argument. When these diagnostics were raised this caused an assert in an assert enabled DXC, and random corruption of the diagnostic text in a non-assert enabled DXC. The trivial fix is to supply the required argument. Fixes microsoft#7425
1 parent 1198c30 commit 040fc53

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tools/clang/lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3504,12 +3504,14 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
35043504
Ty = Context.LitIntTy;
35053505
if (Literal.GetIntegerValue(ResultVal)) {
35063506
// If this value didn't fit into 64-bit literal int, report error.
3507-
Diag(Tok.getLocation(), diag::err_integer_literal_too_large);
3507+
Diag(Tok.getLocation(), diag::err_integer_literal_too_large)
3508+
<< /* Unsigned */ 1;
35083509
}
35093510
} else {
35103511

35113512
if (Literal.GetIntegerValue(ResultVal)) {
3512-
Diag(Tok.getLocation(), diag::err_integer_literal_too_large);
3513+
Diag(Tok.getLocation(), diag::err_integer_literal_too_large)
3514+
<< /* Unsigned */ 1;
35133515
}
35143516
if (Literal.isLongLong) {
35153517
if (Literal.isUnsigned)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// RUN: %dxc -T lib_6_6 %s | FileCheck %s
2+
3+
// A diagnostic is generated for an integer literal that is too large to be
4+
// represented by any integer type - an argument indicates whether the text
5+
// contains "signed". That argument was missing in HLSL specific code within
6+
// Sema::ActOnNumericConstant() which resulted in an assert being raised if
7+
// the diagnostic was generated in an assert enabled DXC and a random string
8+
// being inserted in a non-assert enabled DXC.
9+
10+
// CHECK: integer literal is too large to be represented in any integer type
11+
int a = 98765432109876543210;
12+
13+
// CHECK: integer literal is too large to be represented in any integer type
14+
uint b = 98765432109876543210U;

0 commit comments

Comments
 (0)