[cfe-commits] r121836 - in /cfe/trunk/lib/Sema: SemaExpr.cpp SemaStmt.cpp SemaType.cpp
John McCall
rjmccall at apple.com
Tue Dec 14 20:42:30 PST 2010
Author: rjmccall
Date: Tue Dec 14 22:42:30 2010
New Revision: 121836
URL: http://llvm.org/viewvc/llvm-project?rev=121836&view=rev
Log:
Sundry missing lvalue-to-rvalue conversions. Also leave a TODO for the vital
future task of performing contextual conversion to size_t in a VLA size
expression. :)
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=121836&r1=121835&r2=121836&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 14 22:42:30 2010
@@ -3450,6 +3450,7 @@
// Perform default conversions.
DefaultFunctionArrayConversion(BaseExpr);
+ if (IsArrow) DefaultLvalueConversion(BaseExpr);
QualType BaseType = BaseExpr->getType();
assert(!BaseType->isDependentType());
@@ -3795,8 +3796,9 @@
// Handle 'field access' to vectors, such as 'V.xx'.
if (BaseType->isExtVectorType()) {
+ // FIXME: this expr should store IsArrow.
IdentifierInfo *Member = MemberName.getAsIdentifierInfo();
- ExprValueKind VK = BaseExpr->getValueKind();
+ ExprValueKind VK = (IsArrow ? VK_LValue : BaseExpr->getValueKind());
QualType ret = CheckExtVectorComponent(*this, BaseType, VK, OpLoc,
Member, MemberLoc);
if (ret.isNull())
@@ -3826,12 +3828,12 @@
/// this is an ugly hack around the fact that ObjC @implementations
/// aren't properly put in the context chain
ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base,
- SourceLocation OpLoc,
- tok::TokenKind OpKind,
- CXXScopeSpec &SS,
- UnqualifiedId &Id,
- Decl *ObjCImpDecl,
- bool HasTrailingLParen) {
+ SourceLocation OpLoc,
+ tok::TokenKind OpKind,
+ CXXScopeSpec &SS,
+ UnqualifiedId &Id,
+ Decl *ObjCImpDecl,
+ bool HasTrailingLParen) {
if (SS.isSet() && SS.isInvalid())
return ExprError();
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=121836&r1=121835&r2=121836&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Dec 14 22:42:30 2010
@@ -1597,6 +1597,8 @@
StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc,
Expr *Throw) {
if (Throw) {
+ DefaultLvalueConversion(Throw);
+
QualType ThrowType = Throw->getType();
// Make sure the expression type is an ObjC pointer or "void *".
if (!ThrowType->isDependentType() &&
@@ -1632,6 +1634,8 @@
Stmt *SyncBody) {
getCurFunction()->setHasBranchProtectedScope();
+ DefaultLvalueConversion(SyncExpr);
+
// Make sure the expression type is an ObjC pointer or "void *".
if (!SyncExpr->getType()->isDependentType() &&
!SyncExpr->getType()->isObjCObjectPointerType()) {
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=121836&r1=121835&r2=121836&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Dec 14 22:42:30 2010
@@ -680,7 +680,13 @@
return QualType();
}
+ // Do lvalue-to-rvalue conversions on the array size expression.
+ if (ArraySize && !ArraySize->isRValue())
+ DefaultLvalueConversion(ArraySize);
+
// C99 6.7.5.2p1: The size expression shall have integer type.
+ // TODO: in theory, if we were insane, we could allow contextual
+ // conversions to integer type here.
if (ArraySize && !ArraySize->isTypeDependent() &&
!ArraySize->getType()->isIntegralOrUnscopedEnumerationType()) {
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
More information about the cfe-commits
mailing list