]> granicus.if.org Git - clang/commitdiff
Diagnose TypoExprs in a couple of error cases in ParsePostfixExpressionSuffix.
authorKaelyn Takata <rikka@google.com>
Tue, 2 Dec 2014 22:05:35 +0000 (22:05 +0000)
committerKaelyn Takata <rikka@google.com>
Tue, 2 Dec 2014 22:05:35 +0000 (22:05 +0000)
Also have CorrectDelayedTyposInExpr check that the Expr* isn't null
before trying to access its members. Fixes PR21679.

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

lib/Parse/ParseExpr.cpp
lib/Sema/SemaExprCXX.cpp

index 43929c0bcf26ca0406f28798cdbabe591bc2e628..eeea15dec050078f6dc97892cfbb140c509176db 100644 (file)
@@ -1364,8 +1364,10 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
       if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
         LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
                                               Idx.get(), RLoc);
-      } else
+      } else {
+        (void)Actions.CorrectDelayedTyposInExpr(LHS);
         LHS = ExprError();
+      }
 
       // Match the ']'.
       T.consumeClose();
@@ -1536,8 +1538,10 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
                                     /*AllowDestructorName=*/true,
                                     /*AllowConstructorName=*/
                                       getLangOpts().MicrosoftExt, 
-                                    ObjectType, TemplateKWLoc, Name))
+                                    ObjectType, TemplateKWLoc, Name)) {
+        (void)Actions.CorrectDelayedTyposInExpr(LHS);
         LHS = ExprError();
+      }
       
       if (!LHS.isInvalid())
         LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.get(), OpLoc, 
index 0d11e42d55e4de0e229644a851aaba9406625424..e8be716ea099fc084386d7534bd8734bae508186 100644 (file)
@@ -6196,7 +6196,7 @@ ExprResult Sema::CorrectDelayedTyposInExpr(
   // If the current evaluation context indicates there are uncorrected typos
   // and the current expression isn't guaranteed to not have typos, try to
   // resolve any TypoExpr nodes that might be in the expression.
-  if (!ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
+  if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
       (E->isTypeDependent() || E->isValueDependent() ||
        E->isInstantiationDependent())) {
     auto TyposResolved = DelayedTypos.size();