Emit better diagnostics for out of range digits:

diag.c:1:9: error: invalid digit '8' in octal constant
int x = 000080;
        ^
diag.c:2:9: error: invalid digit 'A' in decimal constant
int z = 1000080ABC;
        ^

instead of:

diag.c:1:9: error: invalid suffix '80' on integer constant
int x = 000080;
        ^
diag.c:2:9: error: invalid suffix 'ABC' on integer constant
int z = 1000080ABC;
        ^

llvm-svn: 39605
This commit is contained in:
Chris Lattner 2007-06-08 17:12:06 +00:00
parent c2b867ac4f
commit 328fa5c913
3 changed files with 13 additions and 1 deletions

View File

@ -245,6 +245,10 @@ NumericLiteralParser(const char *begin, const char *end,
DigitsBegin = s;
s = SkipOctalDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
Diag(TokLoc, diag::err_invalid_octal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
s++;
radix = 10;
@ -269,6 +273,10 @@ NumericLiteralParser(const char *begin, const char *end,
radix = 10;
s = SkipDigits(s);
if (s == ThisTokEnd) {
// Done.
} else if (isxdigit(*s)) {
Diag(TokLoc, diag::err_invalid_decimal_digit, std::string(s, s+1));
return;
} else if (*s == '.') {
s++;
saw_period = true;

View File

@ -177,7 +177,7 @@
1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
84916BE40C161E580080778F /* Attr.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Attr.cpp; path = AST/Attr.cpp; sourceTree = "<group>"; };
84916BE60C161E800080778F /* Attr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Attr.h; path = include/clang/AST/Attr.h; sourceTree = "<group>"; };
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };

View File

@ -530,6 +530,10 @@ DIAG(warn_integer_too_large_for_signed, WARNING,
"integer constant is so large that it is unsigned")
DIAG(err_exponent_has_no_digits, ERROR,
"exponent has no digits")
DIAG(err_invalid_octal_digit, ERROR,
"invalid digit '%0' in octal constant")
DIAG(err_invalid_decimal_digit, ERROR,
"invalid digit '%0' in decimal constant")
DIAG(err_hexconstant_requires_exponent, ERROR,
"hexadecimal floating constants require an exponent")
DIAG(err_typecheck_subscript_value, ERROR,