diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-10-30 22:55:11 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-10-30 22:55:11 +0000 |
commit | c38ba6697fc8b9f5cb577d27c07dc9ff46ae6b17 (patch) | |
tree | 76f9a3482efe52cb597ad84fa7eaf47952c40861 /clang | |
parent | a544c51e94445ad655e512af690cb214aac73321 (diff) | |
download | bcm5719-llvm-c38ba6697fc8b9f5cb577d27c07dc9ff46ae6b17.tar.gz bcm5719-llvm-c38ba6697fc8b9f5cb577d27c07dc9ff46ae6b17.zip |
Typo correct the condition of 'do-while' before exiting its scope
rdar://35172419
llvm-svn: 316966
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaObjCXX/typo-correction.mm | 34 |
2 files changed, 36 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 65c3f21f2d9..e8cf7d5fa45 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1479,6 +1479,9 @@ StmtResult Parser::ParseDoStatement() { DiagnoseAndSkipCXX11Attributes(); ExprResult Cond = ParseExpression(); + // Correct the typos in condition before closing the scope. + if (Cond.isUsable()) + Cond = Actions.CorrectDelayedTyposInExpr(Cond); T.consumeClose(); DoScope.Exit(); diff --git a/clang/test/SemaObjCXX/typo-correction.mm b/clang/test/SemaObjCXX/typo-correction.mm index 8dcda7921fc..3f8a082a84a 100644 --- a/clang/test/SemaObjCXX/typo-correction.mm +++ b/clang/test/SemaObjCXX/typo-correction.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -fsyntax-only +// RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-objc-root-class class ClassA {}; @@ -55,3 +55,35 @@ void invalidNameInIvarAndPropertyBase() { typoCandidate.x = 0; // expected-error {{use of undeclared identifier 'typoCandidate'; did you mean '_typoCandidate'?}} } @end + +// rdar://35172419 +// The scope of 'do-while' ends before typo-correction takes place. + +struct Mat2 { int rows; }; + +@implementation ImplNoInt // expected-warning {{cannot find interface declaration for 'ImplNoInt'}} + +- (void)typoCorrentInDoWhile { + Mat2 tlMat1; // expected-note {{'tlMat1' declared here}} + // Create many scopes to exhaust the cache. + do { + for (int index = 0; index < 2; index++) { + if (true) { + for (int specialTileType = 1; specialTileType < 5; specialTileType++) { + for (int i = 0; i < 10; i++) { + for (double scale = 0.95; scale <= 1.055; scale += 0.05) { + for (int j = 0; j < 10; j++) { + if (1 > 0.9) { + for (int sptile = 1; sptile < 5; sptile++) { + } + } + } + } + } + } + } + } + } while (tlMat.rows); // expected-error {{use of undeclared identifier 'tlMat'; did you mean 'tlMat1'}} +} + +@end |