aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-12-05 16:33:57 +0000
committerAnders Carlsson <andersca@mac.com>2008-12-05 16:33:57 +0000
commit49184b2916f2f6535ac22f8517dc1e996225d2f1 (patch)
tree46100cafb2641ea4ff31d877ad6d2274b60d8cc8
parentd407a7619904c81d38b41a9ee850de413105084b (diff)
Use VerifyIntegerConstantExpression instead of isIntegerConstantExpr. Fixes PR2963
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60591 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--lib/Sema/SemaDecl.cpp3
-rw-r--r--test/Sema/PR2963-enum-constant.c17
3 files changed, 18 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 2fd6ac5afe..a85e0df324 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -978,8 +978,6 @@ DIAG(err_redefinition_of_enumerator, ERROR,
"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,
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 411307522b..4fd13c3f96 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2899,8 +2899,7 @@ Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl,
// 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 {
diff --git a/test/Sema/PR2963-enum-constant.c b/test/Sema/PR2963-enum-constant.c
new file mode 100644
index 0000000000..28becc3793
--- /dev/null
+++ b/test/Sema/PR2963-enum-constant.c
@@ -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)
+};