aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2010-12-17 12:21:11 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2010-12-17 12:21:11 +0000
commitbbca85d14c227641cb482ef497e1e567fe6f9c95 (patch)
tree87ec378fb3353c5aae8f57ff09c720e0355753c6
parent28d5b724198b8b7449066dd2feb3b0276192f563 (diff)
Avoid to emit redundant implicit cast for enum constants init expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122056 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp2
-rw-r--r--test/Index/load-decls.c1
2 files changed, 1 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 3f94bdc669..5fb5cbaa45 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7745,7 +7745,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
ECD->setInitVal(InitVal);
// Adjust the Expr initializer and type.
- if (ECD->getInitExpr())
+ if (ECD->getInitExpr() && NewTy != ECD->getInitExpr()->getType())
ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy,
CK_IntegralCast,
ECD->getInitExpr(),
diff --git a/test/Index/load-decls.c b/test/Index/load-decls.c
index cf88f4285c..e0617c07df 100644
--- a/test/Index/load-decls.c
+++ b/test/Index/load-decls.c
@@ -12,5 +12,4 @@ enum Color {
// CHECK: load-decls.c:3:3: EnumConstantDecl=Green:3:3 (Definition) Extent=[3:3 - 3:8]
// CHECK: load-decls.c:4:3: EnumConstantDecl=Blue:4:3 (Definition) Extent=[4:3 - 4:7]
// CHECK: load-decls.c:6:3: EnumConstantDecl=Rouge:6:3 (Definition) Extent=[6:3 - 6:14]
-// CHECK: load-decls.c:6:11: UnexposedExpr=Red:2:3 Extent=[6:11 - 6:14]
// CHECK: load-decls.c:6:11: DeclRefExpr=Red:2:3 Extent=[6:11 - 6:14]