Correct typos in C11 generic-selection expressions.
authorKaelyn Takata <rikka@google.com>
Thu, 19 Mar 2015 20:56:07 +0000 (20:56 +0000)
committerKaelyn Takata <rikka@google.com>
Thu, 19 Mar 2015 20:56:07 +0000 (20:56 +0000)
llvm-svn: 232760

clang/lib/Parse/ParseExpr.cpp
clang/test/Sema/typo-correction.c

index 07af62f..b9127e9 100644 (file)
@@ -2368,7 +2368,8 @@ ExprResult Parser::ParseGenericSelectionExpression() {
     // C11 6.5.1.1p3 "The controlling expression of a generic selection is
     // not evaluated."
     EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
-    ControllingExpr = ParseAssignmentExpression();
+    ControllingExpr =
+        Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
     if (ControllingExpr.isInvalid()) {
       SkipUntil(tok::r_paren, StopAtSemi);
       return ExprError();
@@ -2414,7 +2415,8 @@ ExprResult Parser::ParseGenericSelectionExpression() {
 
     // FIXME: These expressions should be parsed in a potentially potentially
     // evaluated context.
-    ExprResult ER(ParseAssignmentExpression());
+    ExprResult ER(
+        Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
     if (ER.isInvalid()) {
       SkipUntil(tok::r_paren, StopAtSemi);
       return ExprError();
index 8276737..be9a1f3 100644 (file)
@@ -28,3 +28,9 @@ void func(int arg) {
     ;
   }
 }
+
+void banana(void);  // expected-note {{'banana' declared here}}
+int c11Generic(int arg) {
+  _Generic(hello, int : banana)();  // expected-error-re {{use of undeclared identifier 'hello'{{$}}}}
+  _Generic(arg, int : bandana)();  // expected-error {{use of undeclared identifier 'bandana'; did you mean 'banana'?}}
+}