summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-01-06 11:31:12 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-01-06 11:31:12 +0000
commitc7dc1a2a3c0c3584596be495f81d75b9d2881993 (patch)
tree9f6929a5bf52f58f703a805ad9f2fed00ecebc4d /clang
parent01dd2f7b44d208ef52e829c2121a5378b5df620a (diff)
downloadbcm5719-llvm-c7dc1a2a3c0c3584596be495f81d75b9d2881993.tar.gz
bcm5719-llvm-c7dc1a2a3c0c3584596be495f81d75b9d2881993.zip
[ObjC] The declarator for a block literal should be a definition
This change avoids the -Wstrict-prototypes warning for block literals with an empty argument list or without argument lists. rdar://15060615 Differential Revision: https://reviews.llvm.org/D28296 llvm-svn: 291231
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp2
-rw-r--r--clang/test/Sema/warn-strict-prototypes.m5
-rw-r--r--clang/test/SemaObjC/block-omitted-return-type.m2
3 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index caf2320f8fc..55b5ff49857 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2751,6 +2751,7 @@ void Parser::ParseBlockId(SourceLocation CaretLoc) {
// Parse the block-declarator.
Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext);
+ DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition);
ParseDeclarator(DeclaratorInfo);
MaybeParseGNUAttributes(DeclaratorInfo);
@@ -2789,6 +2790,7 @@ ExprResult Parser::ParseBlockLiteralExpression() {
// Parse the return type if present.
DeclSpec DS(AttrFactory);
Declarator ParamInfo(DS, Declarator::BlockLiteralContext);
+ ParamInfo.setFunctionDefinitionKind(FDK_Definition);
// FIXME: Since the return type isn't actually parsed, it can't be used to
// fill ParamInfo with an initial valid range, so do it manually.
ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
diff --git a/clang/test/Sema/warn-strict-prototypes.m b/clang/test/Sema/warn-strict-prototypes.m
index cbb01a1f7b2..4567dab0193 100644
--- a/clang/test/Sema/warn-strict-prototypes.m
+++ b/clang/test/Sema/warn-strict-prototypes.m
@@ -14,7 +14,8 @@ void foo() {
void (^block)() = // expected-warning {{this function declaration is not a prototype}}
^void(int arg) { // no warning
};
- void (^block2)(void) = // no warning
- ^void() { // expected-warning {{this function declaration is not a prototype}}
+ void (^block2)(void) = ^void() { // no warning
+ };
+ void (^block3)(void) = ^ { // no warning
};
}
diff --git a/clang/test/SemaObjC/block-omitted-return-type.m b/clang/test/SemaObjC/block-omitted-return-type.m
index 20e32e01865..93d5e05ea28 100644
--- a/clang/test/SemaObjC/block-omitted-return-type.m
+++ b/clang/test/SemaObjC/block-omitted-return-type.m
@@ -24,7 +24,7 @@
return;
};
void (^simpleBlock5)() = ^ const void { //expected-error {{incompatible block pointer types initializing 'void (^)()' with an expression of type 'const void (^)(void)'}}
- return;
+ return; // expected-warning@-1 {{function cannot return qualified void type 'const void'}}
};
void (^simpleBlock6)() = ^ const (void) { //expected-warning {{'const' qualifier on omitted return type '<dependent type>' has no effect}}
return;
OpenPOWER on IntegriCloud