Author: rikka
Date: Tue Dec 16 17:07:00 2014
New Revision: 224386

URL: http://llvm.org/viewvc/llvm-project?rev=224386&view=rev
Log:
Try typo correction on all initialization arguments and be less
pessimistic about when to do so.

This also fixes PR21905 as the initialization argument was no longer
viewed as being type dependent due to the TypoExpr being type-cast.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=224386&r1=224385&r2=224386&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 16 17:07:00 2014
@@ -8806,12 +8806,10 @@ void Sema::AddInitializerToDecl(Decl *Re
       Args = MultiExprArg(CXXDirectInit->getExprs(),
                           CXXDirectInit->getNumExprs());
 
-    // Try to correct any TypoExprs if there might be some in the 
initialization
-    // arguments (TypoExprs are marked as type-dependent).
-    // TODO: Handle typo correction when there's more than one argument?
-    if (Args.size() == 1 && Expr::hasAnyTypeDependentArguments(Args)) {
+    // Try to correct any TypoExprs in the initialization arguments.
+    for (size_t Idx = 0; Idx < Args.size(); ++Idx) {
       ExprResult Res =
-          CorrectDelayedTyposInExpr(Args[0], [this, Entity, Kind](Expr *E) {
+          CorrectDelayedTyposInExpr(Args[Idx], [this, Entity, Kind](Expr *E) {
             InitializationSequence Init(*this, Entity, Kind, MultiExprArg(E));
             return Init.Failed() ? ExprError() : E;
           });
@@ -8819,8 +8817,8 @@ void Sema::AddInitializerToDecl(Decl *Re
         VDecl->setInvalidDecl();
         return;
       }
-      if (Res.get() != Args[0])
-        Args[0] = Res.get();
+      if (Res.get() != Args[Idx])
+        Args[Idx] = Res.get();
     }
 
     InitializationSequence InitSeq(*this, Entity, Kind, Args);

Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=224386&r1=224385&r2=224386&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Tue Dec 16 17:07:00 2014
@@ -143,3 +143,7 @@ void test() {
   int x = variableX.getX();
 }
 }
+
+namespace PR21905 {
+int (*a) () = (void)Z;  // expected-error-re {{use of undeclared identifier 
'Z'{{$}}}}
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to