[PATCH] D28296: [ObjC] The declarator for a block literal should be a definition

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 4 09:02:13 PST 2017


arphaman created this revision.
arphaman added reviewers: bruno, ahatanak.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This avoids the -Wstrict-prototypes warning for block literals with an empty or without argument lists.


Repository:
  rL LLVM

https://reviews.llvm.org/D28296

Files:
  lib/Parse/ParseExpr.cpp
  test/Sema/warn-strict-prototypes.m


Index: test/Sema/warn-strict-prototypes.m
===================================================================
--- test/Sema/warn-strict-prototypes.m
+++ test/Sema/warn-strict-prototypes.m
@@ -14,7 +14,8 @@
   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
   };
 }
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -2751,6 +2751,7 @@
 
   // Parse the block-declarator.
   Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext);
+  DeclaratorInfo.setFunctionDefinitionKind(FDK_Definition);
   ParseDeclarator(DeclaratorInfo);
 
   MaybeParseGNUAttributes(DeclaratorInfo);
@@ -2789,6 +2790,7 @@
   // 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()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28296.83061.patch
Type: text/x-patch
Size: 1467 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170104/490528eb/attachment.bin>


More information about the cfe-commits mailing list