[cfe-commits] r125068 - in /cfe/trunk: lib/Sema/SemaType.cpp test/Sema/block-args.c

John McCall rjmccall at apple.com
Mon Feb 7 17:59:10 PST 2011


Author: rjmccall
Date: Mon Feb  7 19:59:10 2011
New Revision: 125068

URL: http://llvm.org/viewvc/llvm-project?rev=125068&view=rev
Log:
dgregor accidentally killed this assert, but on investigation, it can fire
on invalid code and we don't really care, so kill it harder.


Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Sema/block-args.c

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=125068&r1=125067&r2=125068&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Feb  7 19:59:10 2011
@@ -486,27 +486,19 @@
     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();

Modified: cfe/trunk/test/Sema/block-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-args.c?rev=125068&r1=125067&r2=125068&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-args.c (original)
+++ cfe/trunk/test/Sema/block-args.c Mon Feb  7 19:59:10 2011
@@ -34,3 +34,9 @@
   ^(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}}
+}
+





More information about the cfe-commits mailing list