[cfe-commits] r122056 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Index/load-decls.c
Abramo Bagnara
abramo.bagnara at gmail.com
Fri Dec 17 04:21:11 PST 2010
Author: abramo
Date: Fri Dec 17 06:21:11 2010
New Revision: 122056
URL: http://llvm.org/viewvc/llvm-project?rev=122056&view=rev
Log:
Avoid to emit redundant implicit cast for enum constants init expressions.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Index/load-decls.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=122056&r1=122055&r2=122056&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec 17 06:21:11 2010
@@ -7745,7 +7745,7 @@
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(),
Modified: cfe/trunk/test/Index/load-decls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-decls.c?rev=122056&r1=122055&r2=122056&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-decls.c (original)
+++ cfe/trunk/test/Index/load-decls.c Fri Dec 17 06:21:11 2010
@@ -12,5 +12,4 @@
// 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]
More information about the cfe-commits
mailing list