]> granicus.if.org Git - clang/commitdiff
dgregor accidentally killed this assert, but on investigation, it can fire
authorJohn McCall <rjmccall@apple.com>
Tue, 8 Feb 2011 01:59:10 +0000 (01:59 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 8 Feb 2011 01:59:10 +0000 (01:59 +0000)
on invalid code and we don't really care, so kill it harder.

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

lib/Sema/SemaType.cpp
test/Sema/block-args.c

index 9206b1bed6ea11b3ad09eccb67e46417527abb63..b6d28cbe719273dc5e057ba922d830eb6c772798 100644 (file)
@@ -486,27 +486,19 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state,
     return;
   }
 
-  // If there are any type objects, the type as written won't
-  // name a function, regardless of the decl spec type.  This
-  // is because a block signature declarator is always an
-  // abstract-declarator, and abstract-declarators can't just
-  // be parentheses chunks.  Therefore we need to build a function
-  // chunk unless there are no type objects and the decl spec
-  // type is a function.
+  // If there are any type objects, the type as written won't name a
+  // function, regardless of the decl spec type.  This is because a
+  // block signature declarator is always an abstract-declarator, and
+  // abstract-declarators can't just be parentheses chunks.  Therefore
+  // we need to build a function chunk unless there are no type
+  // objects and the decl spec type is a function.
   if (!declarator.getNumTypeObjects() && declSpecType->isFunctionType())
     return;
 
-#ifndef NDEBUG
-  if (declarator.getNumTypeObjects()) {
-    bool isOnlyParens = true;
-    for (unsigned i = 0, e = declarator.getNumTypeObjects(); i != e; ++i) {
-      if (declarator.getTypeObject(i).Kind != DeclaratorChunk::Paren) {
-        isOnlyParens = false;
-        break;
-      }
-    }
-  }
-#endif
+  // Note that there *are* cases with invalid declarators where
+  // declarators consist solely of parentheses.  In general, these
+  // occur only in failed efforts to make function declarators, so
+  // faking up the function chunk is still the right thing to do.
 
   // Otherwise, we need to fake up a function declarator.
   SourceLocation loc = declarator.getSourceRange().getBegin();
index 970c60d51ddb8a43af57d97ade712ea834f4a2b7..e2e2d8e44622eea5a1984c05ba1e83a501474eba 100644 (file)
@@ -34,3 +34,9 @@ void f0() {
   ^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \
                                           // expected-error {{parameter name omitted}}
 }
+
+// rdar://problem/8962770
+void test4() {
+  int (^f)() = ^((x)) { }; // expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-note {{to match this}}
+}
+