diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-02-17 22:40:11 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-02-17 22:40:11 +0000 |
| commit | c0b8c81a0777cf3c7cfbe7c0a8cc5c86d1093a34 (patch) | |
| tree | 00b107ab1ff1ca473e17bfc6e86ec61b2d1c8f9a | |
| parent | 1d793a5e0e4c9511c1f2ac7efe90fd7bad93ff86 (diff) | |
| download | bcm5719-llvm-c0b8c81a0777cf3c7cfbe7c0a8cc5c86d1093a34.tar.gz bcm5719-llvm-c0b8c81a0777cf3c7cfbe7c0a8cc5c86d1093a34.zip | |
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.
llvm-svn: 96524
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Sema/enum.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 38211134393..e7217dc2200 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5732,7 +5732,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, 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); diff --git a/clang/test/Sema/enum.c b/clang/test/Sema/enum.c index 9b4650091e1..6177edff91c 100644 --- a/clang/test/Sema/enum.c +++ b/clang/test/Sema/enum.c @@ -9,7 +9,8 @@ enum g { // too negative 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 |

