]> granicus.if.org Git - clang/commitdiff
Sema: correct typo recovery with blocks
authorSaleem Abdulrasool <compnerd@compnerd.org>
Sat, 31 Oct 2015 00:39:15 +0000 (00:39 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Sat, 31 Oct 2015 00:39:15 +0000 (00:39 +0000)
Handle blocks in the tree transform for the typo correction as otherwise, the
capture may miss.  This would trigger an assertion.  Thanks to Doug Gregor for
the help with this!

Fixes PR25001.

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

lib/Sema/SemaExprCXX.cpp
test/SemaCXX/typo-correction-blocks.c [new file with mode: 0644]

index 348f29638e02849d431c4f0d7b6a3a3735b0bde1..dfaa4503ff28605d33c4aaa6fd6ce18b7c87d0dd 100644 (file)
@@ -6545,6 +6545,8 @@ public:
 
   ExprResult TransformLambdaExpr(LambdaExpr *E) { return Owned(E); }
 
+  ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
+
   ExprResult Transform(Expr *E) {
     ExprResult Res;
     while (true) {
diff --git a/test/SemaCXX/typo-correction-blocks.c b/test/SemaCXX/typo-correction-blocks.c
new file mode 100644 (file)
index 0000000..300a5be
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx -fblocks -fsyntax-only -verify %s
+
+extern int h(int *);
+extern void g(int, void (^)(void));
+extern int fuzzys;                  // expected-note {{'fuzzys' declared here}}
+
+static void f(void *v) {
+  g(fuzzy, ^{                       // expected-error {{did you mean 'fuzzys'}}
+    int i = h(v);
+  });
+}
+