summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2014-12-02 22:05:35 +0000
committerKaelyn Takata <rikka@google.com>2014-12-02 22:05:35 +0000
commitc71dda2c38db839bca7262fd3a91a3982c720ddd (patch)
treedebd9c84e59b4bd6cfb6fe989afa37cf941cf9b7 /clang/lib
parentbbdee936388d96bc4c72a3b635ad5d29ff6b6eac (diff)
downloadbcm5719-llvm-c71dda2c38db839bca7262fd3a91a3982c720ddd.tar.gz
bcm5719-llvm-c71dda2c38db839bca7262fd3a91a3982c720ddd.zip
Diagnose TypoExprs in a couple of error cases in ParsePostfixExpressionSuffix.
Also have CorrectDelayedTyposInExpr check that the Expr* isn't null before trying to access its members. Fixes PR21679. llvm-svn: 223162
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp8
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp2
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 43929c0bcf2..eeea15dec05 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -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,
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 0d11e42d55e..e8be716ea09 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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();
OpenPOWER on IntegriCloud