From 740396437b6584ffcb08857b8fbc8dff17e89c86 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 25 Jan 2013 17:19:07 +0000 Subject: [PATCH] Improve diagnsotic further on integer overflow. llvm-svn: 173461 --- clang/include/clang/Basic/DiagnosticASTKinds.td | 2 +- clang/test/Sema/switch-1.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td index 7074e02ad335..08369a589a1a 100644 --- a/clang/include/clang/Basic/DiagnosticASTKinds.td +++ b/clang/include/clang/Basic/DiagnosticASTKinds.td @@ -107,7 +107,7 @@ def note_constexpr_calls_suppressed : Note< "see all)">; def note_constexpr_call_here : Note<"in call to '%0'">; def warn_integer_constant_overflow : Warning< - "overflow of constant expression results in value %0 of type %1">, + "overflow in expression;result is %0 with type %1">, InGroup>; // inline asm related. diff --git a/clang/test/Sema/switch-1.c b/clang/test/Sema/switch-1.c index 50129c3ee215..4a5ded3b41ab 100644 --- a/clang/test/Sema/switch-1.c +++ b/clang/test/Sema/switch-1.c @@ -4,14 +4,15 @@ int f(int i) { switch (i) { - case 2147483647 + 2: // expected-warning {{overflow of constant expression results in value -2147483647 of type 'int'}} + case 2147483647 + 2: // expected-warning {{overflow in expression;result is -2147483647 with type 'int'}} return 1; - case 9223372036854775807L * 4: // expected-warning {{overflow of constant expression results in value -4 of type 'long'}} + case 9223372036854775807L * 4: // expected-warning {{overflow in expression;result is -4 with type 'long'}} return 2; - case (123456 *789012) + 1: // expected-warning {{overflow of constant expression results in value -1375982336 of type 'int'}} + case (123456 *789012) + 1: // expected-warning {{overflow in expression;result is -1375982336 with type 'int'}} return 3; case 2147483647: return 0; } - return 0; + return (i, 65537) * 65537; // expected-warning {{overflow in expression;result is 131073 with type 'int'}} \ + // expected-warning {{expression result unused}} }