]> granicus.if.org Git - clang/commitdiff
Sundry missing lvalue-to-rvalue conversions. Also leave a TODO for the vital
authorJohn McCall <rjmccall@apple.com>
Wed, 15 Dec 2010 04:42:30 +0000 (04:42 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 15 Dec 2010 04:42:30 +0000 (04:42 +0000)
future task of performing contextual conversion to size_t in a VLA size
expression. :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121836 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaType.cpp

index baa7bf867077c2c2ff4e64aca8246a3d5f53807c..ea4f6bc85592f5e8cb9c2569a133abd7e063b46c 100644 (file)
@@ -3450,6 +3450,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
 
   // Perform default conversions.
   DefaultFunctionArrayConversion(BaseExpr);
+  if (IsArrow) DefaultLvalueConversion(BaseExpr);
 
   QualType BaseType = BaseExpr->getType();
   assert(!BaseType->isDependentType());
@@ -3795,8 +3796,9 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
 
   // 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 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
 ///   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();
 
index 2c7ff5bd47b706a6627115c0bb7fa31a09f7e74b..6ddbe13b271a2254faa62e1872e11ae6ee299c2e 100644 (file)
@@ -1597,6 +1597,8 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
 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 @@ Sema::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SyncExpr,
                                   Stmt *SyncBody) {
   getCurFunction()->setHasBranchProtectedScope();
 
+  DefaultLvalueConversion(SyncExpr);
+
   // Make sure the expression type is an ObjC pointer or "void *".
   if (!SyncExpr->getType()->isDependentType() &&
       !SyncExpr->getType()->isObjCObjectPointerType()) {
index 04440ef9a5de13843b2efd30e388ce545554c291..2eb2c0b7cfe5dc03fed244394ca00da4be603332 100644 (file)
@@ -680,7 +680,13 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
     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)