aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Parse/ParseExpr.cpp5
-rw-r--r--test/Sema/block-syntax-error.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 230abf823c..0295f70633 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1239,6 +1239,11 @@ Parser::OwningExprResult Parser::ParseBlockLiteralExpression() {
Actions.ActOnBlockError(CaretLoc, CurScope);
}
}
+ else {
+ // Saw something like: ^expr
+ Diag(Tok, diag::err_expected_expression);
+ return ExprError();
+ }
return move(Result);
}
diff --git a/test/Sema/block-syntax-error.c b/test/Sema/block-syntax-error.c
new file mode 100644
index 0000000000..c98f1fd2aa
--- /dev/null
+++ b/test/Sema/block-syntax-error.c
@@ -0,0 +1,9 @@
+// RUN: clang %s -fsyntax-only -verify -fblocks
+
+void (^noop)(void);
+
+void somefunction() {
+ noop = ^int *{}; // expected-error {{expected expression}}
+
+ noop = ^noop; // expected-error {{expected expression}}
+}