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()));


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()));
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to