From 34f3bcf7f2907f618f7a10d919bda47e53db60dd Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 26 Jul 2013 00:06:45 +0000 Subject: [PATCH] Partially revert r186903. It turns out that Plum Hall depends on us not emitting an error on integer literals which fit into long long, but fit into unsigned long long. So C99 conformance requires not conforming to C99. :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187172 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticCommonKinds.td | 2 +- lib/Lex/PPExpressions.cpp | 2 +- lib/Sema/SemaExpr.cpp | 2 +- test/Lexer/constants.c | 2 +- test/Misc/warning-flags.c | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index 94f1b4b244..cec938b180 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -101,7 +101,7 @@ def warn_cxx98_compat_longlong : Warning< InGroup, DefaultIgnore; def err_integer_too_large : Error< "integer constant is larger than the largest unsigned integer type">; -def err_integer_too_large_for_signed : Error< +def warn_integer_too_large_for_signed : Warning< "integer constant is larger than the largest signed integer type">; // Sema && AST diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 5cba35b2af..87c0a6ace6 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -259,7 +259,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, if (!Literal.isUnsigned && Result.Val.isNegative()) { // Don't warn for a hex or octal literal: 0x8000..0 shouldn't warn. if (ValueLive && Literal.getRadix() == 10) - PP.Diag(PeekTok, diag::err_integer_too_large_for_signed); + PP.Diag(PeekTok, diag::warn_integer_too_large_for_signed); Result.Val.setIsUnsigned(true); } } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 8b7829d8a5..5b0029a91f 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -3079,7 +3079,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // If we still couldn't decide a type, we probably have something that // does not fit in a signed long long, but has no U suffix. if (Ty.isNull()) { - Diag(Tok.getLocation(), diag::err_integer_too_large_for_signed); + Diag(Tok.getLocation(), diag::warn_integer_too_large_for_signed); Ty = Context.UnsignedLongLongTy; Width = Context.getTargetInfo().getLongLongWidth(); } diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c index c1fb54df42..f0cd4d7cf2 100644 --- a/test/Lexer/constants.c +++ b/test/Lexer/constants.c @@ -15,7 +15,7 @@ float Y = 08.123456; #endif #if -01000000000000000000000 // should not warn. #endif -#if 9223372036854775808 // expected-error {{integer constant is larger than the largest signed integer type}} +#if 9223372036854775808 // expected-warning {{integer constant is larger than the largest signed integer type}} #endif #if 0x10000000000000000 // expected-error {{integer constant is larger than the largest unsigned integer type}} #endif diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index 0a22e640a7..1ddd9e1dac 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -18,7 +18,7 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (135): +CHECK: Warnings without flags (136): CHECK-NEXT: ext_delete_void_ptr_operand CHECK-NEXT: ext_expected_semi_decl_list CHECK-NEXT: ext_explicit_specialization_storage_class @@ -85,6 +85,7 @@ CHECK-NEXT: warn_implements_nscopying CHECK-NEXT: warn_incompatible_qualified_id CHECK-NEXT: warn_initializer_string_for_char_array_too_long CHECK-NEXT: warn_inline_namespace_reopened_noninline +CHECK-NEXT: warn_integer_too_large_for_signed CHECK-NEXT: warn_invalid_asm_cast_lvalue CHECK-NEXT: warn_many_braces_around_scalar_init CHECK-NEXT: warn_maynot_respond -- 2.40.0