[cfe-commits] r55039 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaExpr.cpp test/CodeGen/2008-08-19-cast-of-typedef.c

Daniel Dunbar daniel at zuster.org
Tue Aug 19 20:55:42 PDT 2008


Author: ddunbar
Date: Tue Aug 19 22:55:42 2008
New Revision: 55039

URL: http://llvm.org/viewvc/llvm-project?rev=55039&view=rev
Log:
Fix subtle bug introduced in r54852.
 - UsualUnaryConversions takes an Expr *& and may modify its argument,
   this broke when it was refactored into Sema::CheckCastTypes. This
   meant that we were missing implicit casts in some places.
 - Seems pretty sad that this got through our tests.

Added:
    cfe/trunk/test/CodeGen/2008-08-19-cast-of-typedef.c
Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=55039&r1=55038&r2=55039&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 19 22:55:42 2008
@@ -871,7 +871,7 @@
   bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
 
   /// CheckCastTypes - Check type constraints for casting between types.
-  bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *CastExpr);
+  bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr);
   
   // CheckVectorCast - check type constraints for vectors. 
   // Since vectors are an extension, there are no C standard reference for this.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=55039&r1=55038&r2=55039&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 19 22:55:42 2008
@@ -1089,7 +1089,7 @@
 }
 
 /// CheckCastTypes - Check type constraints for casting between types.
-bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *castExpr) {
+bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) {
   UsualUnaryConversions(castExpr);
 
   // C99 6.5.4p2: the cast type needs to be void or scalar and the expression

Added: cfe/trunk/test/CodeGen/2008-08-19-cast-of-typedef.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2008-08-19-cast-of-typedef.c?rev=55039&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/2008-08-19-cast-of-typedef.c (added)
+++ cfe/trunk/test/CodeGen/2008-08-19-cast-of-typedef.c Tue Aug 19 22:55:42 2008
@@ -0,0 +1,10 @@
+// RUN: clang --emit-llvm -o %t %s
+
+typedef short T[4];
+struct s {
+  T f0;
+};
+
+void foo(struct s *x) {
+  bar((long) x->f0);
+}





More information about the cfe-commits mailing list