[cfe-commits] r60591 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDecl.cpp test/Sema/PR2963-enum-constant.c
Anders Carlsson
andersca at mac.com
Fri Dec 5 08:34:10 PST 2008
Author: andersca
Date: Fri Dec 5 10:33:57 2008
New Revision: 60591
URL: http://llvm.org/viewvc/llvm-project?rev=60591&view=rev
Log:
Use VerifyIntegerConstantExpression instead of isIntegerConstantExpr. Fixes PR2963
Added:
cfe/trunk/test/Sema/PR2963-enum-constant.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=60591&r1=60590&r2=60591&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Dec 5 10:33:57 2008
@@ -978,8 +978,6 @@
"redefinition of enumerator %0")
DIAG(err_duplicate_member, ERROR,
"duplicate member %0")
-DIAG(err_enum_value_not_integer_constant_expr, ERROR,
- "enumerator value for %0 is not an integer constant")
DIAG(ext_enum_value_not_int, EXTENSION,
"ISO C restricts enumerator values to range of 'int' (%0 is too large)")
DIAG(warn_enum_too_large, WARNING,
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=60591&r1=60590&r2=60591&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 5 10:33:57 2008
@@ -2899,8 +2899,7 @@
// C99 6.7.2.2p2: Make sure we have an integer constant expression.
SourceLocation ExpLoc;
- if (!Val->isIntegerConstantExpr(EnumVal, Context, &ExpLoc)) {
- Diag(ExpLoc, diag::err_enum_value_not_integer_constant_expr) << Id;
+ if (VerifyIntegerConstantExpression(Val, &EnumVal)) {
delete Val;
Val = 0; // Just forget about it.
} else {
Added: cfe/trunk/test/Sema/PR2963-enum-constant.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2963-enum-constant.c?rev=60591&view=auto
==============================================================================
--- cfe/trunk/test/Sema/PR2963-enum-constant.c (added)
+++ cfe/trunk/test/Sema/PR2963-enum-constant.c Fri Dec 5 10:33:57 2008
@@ -0,0 +1,17 @@
+// RUN: clang %s -verify -pedantic -fsyntax-only
+
+typedef short short_fixed;
+
+enum
+{
+ // 8.8 short_fixed
+ SHORT_FIXED_FRACTIONAL_BITS= 8,
+ SHORT_FIXED_ONE= 1<<SHORT_FIXED_FRACTIONAL_BITS
+};
+
+#define FLOAT_TO_SHORT_FIXED(f) ((short_fixed)((f)*SHORT_FIXED_ONE))
+
+enum
+{
+ SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1)
+};
More information about the cfe-commits
mailing list