[cfe-commits] r96524 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/enum.c
Douglas Gregor
dgregor at apple.com
Wed Feb 17 14:40:12 PST 2010
Author: dgregor
Date: Wed Feb 17 16:40:11 2010
New Revision: 96524
URL: http://llvm.org/viewvc/llvm-project?rev=96524&view=rev
Log:
When diagnosing enumerator values outside of the range of 'int', be
sure that we get the "too large" vs. "too small" part of the
diagnostic correct.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=96524&r1=96523&r2=96524&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Feb 17 16:40:11 2010
@@ -5732,7 +5732,7 @@
if (!isRepresentableIntegerValue(Context, EnumVal, Context.IntTy))
Diag(IdLoc, diag::ext_enum_value_not_int)
<< EnumVal.toString(10) << Val->getSourceRange()
- << EnumVal.isNonNegative();
+ << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
else if (!Context.hasSameType(Val->getType(), Context.IntTy)) {
// Force the type of the expression to 'int'.
ImpCastExprToType(Val, Context.IntTy, CastExpr::CK_IntegralCast);
Modified: cfe/trunk/test/Sema/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=96524&r1=96523&r2=96524&view=diff
==============================================================================
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Wed Feb 17 16:40:11 2010
@@ -9,7 +9,8 @@
c = -2147483649, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
d = 2147483647 };
enum h { e = -2147483648, // too pos
- f = 2147483648 // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ f = 2147483648, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
+ i = 0xFFFF0000 // expected-warning {{too large}}
};
// minll maxull
More information about the cfe-commits
mailing list