]> granicus.if.org Git - clang/commitdiff
Stop moving attributes off of a block literal's decl specifiers.
authorDouglas Gregor <dgregor@apple.com>
Fri, 19 Jun 2015 23:18:03 +0000 (23:18 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 19 Jun 2015 23:18:03 +0000 (23:18 +0000)
These usually apply to the return type. At one point this was necessary to
get some of them to apply to the entire block, but it appears that's working
anyway (see block-return.c).

rdar://problem/20468034

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

lib/Parse/ParseExpr.cpp
test/SemaObjC/nullability.m

index cee9079d505d65597d2c1cdf2c02296c06f87e33..da759c76522cc9a8360e2e4b8585390fe9af710f 100644 (file)
@@ -2640,9 +2640,6 @@ void Parser::ParseBlockId(SourceLocation CaretLoc) {
   Declarator DeclaratorInfo(DS, Declarator::BlockLiteralContext);
   ParseDeclarator(DeclaratorInfo);
 
-  // We do this for: ^ __attribute__((noreturn)) {, as DS has the attributes.
-  DeclaratorInfo.takeAttributes(DS.getAttributes(), SourceLocation());
-
   MaybeParseGNUAttributes(DeclaratorInfo);
 
   // Inform sema that we are starting a block.
index 2cbdba1bd33a8e075b817f5eeb89836532895378..ca8c2fcd321e0014de7b0f2eeb9480bb166ffbf3 100644 (file)
@@ -222,3 +222,11 @@ void testMultiProp(MultiProp *foo) {
   ip = foo.d; // expected-warning{{from 'MultiProp * __nullable'}}
   ip = foo.e; // expected-error{{incompatible type 'MultiProp *(^ __nullable)(int)'}}
 }
+
+void testBlockLiterals() {
+  (void)(^id(void) { return 0; });
+  (void)(^id __nullable (void) { return 0; });
+  (void)(^ __nullable id(void) { return 0; });
+
+  int *x = (^ __nullable id(void) { return 0; })(); // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'id __nullable'}}
+}