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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2008-08-20 03:55:42 +00:00
Родитель 77ee5ed0ac
Коммит 58d5ebbe72
3 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -871,7 +871,7 @@ private:
bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT); bool CheckStringLiteralInit(StringLiteral *strLiteral, QualType &DeclT);
/// CheckCastTypes - Check type constraints for casting between types. /// 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. // CheckVectorCast - check type constraints for vectors.
// Since vectors are an extension, there are no C standard reference for this. // Since vectors are an extension, there are no C standard reference for this.

Просмотреть файл

@ -1089,7 +1089,7 @@ ActOnInitList(SourceLocation LBraceLoc, ExprTy **initlist, unsigned NumInit,
} }
/// CheckCastTypes - Check type constraints for casting between types. /// 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); UsualUnaryConversions(castExpr);
// C99 6.5.4p2: the cast type needs to be void or scalar and the expression // C99 6.5.4p2: the cast type needs to be void or scalar and the expression

Просмотреть файл

@ -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);
}