[cfe-commits] r148920 - /cfe/trunk/lib/Sema/SemaExprCXX.cpp

Eli Friedman eli.friedman at gmail.com
Tue Jan 24 20:29:24 PST 2012


Author: efriedma
Date: Tue Jan 24 22:29:24 2012
New Revision: 148920

URL: http://llvm.org/viewvc/llvm-project?rev=148920&view=rev
Log:
Add missing check for placeholders.


Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=148920&r1=148919&r2=148920&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jan 24 22:29:24 2012
@@ -4360,12 +4360,21 @@
                        /*RPLoc*/ ExpectedLParenLoc);
 }
 
-static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *Base, 
+static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *&Base, 
                    tok::TokenKind& OpKind, SourceLocation OpLoc) {
+  if (Base->hasPlaceholderType()) {
+    ExprResult result = S.CheckPlaceholderExpr(Base);
+    if (result.isInvalid()) return true;
+    Base = result.take();
+  }
+  ObjectType = Base->getType();
+
   // C++ [expr.pseudo]p2:
   //   The left-hand side of the dot operator shall be of scalar type. The
   //   left-hand side of the arrow operator shall be of pointer to scalar type.
   //   This scalar type is the object type.
+  // Note that this is rather different from the normal handling for the
+  // arrow operator.
   if (OpKind == tok::arrow) {
     if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) {
       ObjectType = Ptr->getPointeeType();
@@ -4395,7 +4404,6 @@
                                            bool HasTrailingLParen) {
   TypeSourceInfo *DestructedTypeInfo = Destructed.getTypeSourceInfo();
 
-  QualType ObjectType = Base->getType();
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 
@@ -4500,7 +4508,6 @@
           SecondTypeName.getKind() == UnqualifiedId::IK_Identifier) &&
          "Invalid second type name in pseudo-destructor");
 
-  QualType ObjectType = Base->getType();
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 
@@ -4629,7 +4636,6 @@
                                            const DeclSpec& DS,
                                            bool HasTrailingLParen) {
   
-  QualType ObjectType = Base->getType();
   if (CheckArrow(*this, ObjectType, Base, OpKind, OpLoc))
     return ExprError();
 





More information about the cfe-commits mailing list