]> granicus.if.org Git - clang/commitdiff
Correct all typos in the initialization arguments, even if one could not
authorKaelyn Takata <rikka@google.com>
Wed, 21 Jan 2015 00:04:19 +0000 (00:04 +0000)
committerKaelyn Takata <rikka@google.com>
Wed, 21 Jan 2015 00:04:19 +0000 (00:04 +0000)
be corrected.

This fixes PR22250, which exposed the bug where if there's more than one
TypoExpr in the arguments, once one failed to be corrected none of the
TypoExprs after it would be handled at all thanks to an early return.

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

lib/Sema/SemaDecl.cpp
test/SemaCXX/typo-correction-delayed.cpp

index 8fbe82fd88124ecbc26e02fef8b34e5efc45df99..cd6ff6ce5820994e28ceac2fc83af8a1543bf37e 100644 (file)
@@ -8841,11 +8841,12 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
           });
       if (Res.isInvalid()) {
         VDecl->setInvalidDecl();
-        return;
-      }
-      if (Res.get() != Args[Idx])
+      } else if (Res.get() != Args[Idx]) {
         Args[Idx] = Res.get();
+      }
     }
+    if (VDecl->isInvalidDecl())
+      return;
 
     InitializationSequence InitSeq(*this, Entity, Kind, Args);
     ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Args, &DclT);
index 454a8b365c3bc87bfe60c85ef8395a50502e5aff..f09dd330dbb178fa9bf6a9b08c4fade0b32940f1 100644 (file)
@@ -167,3 +167,11 @@ void MovePointer(Pointer &Click, int x, int y) {  // expected-note 2 {{'Click' d
   click.set_xpos(x);  // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
   click.set_ypos(x);  // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
 }
+
+namespace PR22250 {
+// expected-error@+4 {{use of undeclared identifier 'size_t'; did you mean 'sizeof'?}}
+// expected-error-re@+3 {{use of undeclared identifier 'y'{{$}}}}
+// expected-error-re@+2 {{use of undeclared identifier 'z'{{$}}}}
+// expected-error@+1 {{expected ';' after top level declarator}}
+int getenv_s(size_t *y, char(&z)) {}
+}