// Blocks are difficult because the return type may not be stored in the
// BlockDecl itself. The AST should probably be enhanced, but for now we
// just do what we can.
+ // If the block is declared without an explicit argument list, the
+ // signature-as-written just includes the return type, not the entire
+ // function type.
// FIXME: All blocks should have signatures-as-written, even if the return
- // type is inferred. (That's signified is with a dependent result type.)
+ // type is inferred. (That's signified with a dependent result type.)
if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten()) {
- const FunctionType *FT = TSI->getType()->castAs<FunctionType>();
- if (!FT->getResultType()->isDependentType())
- return FT->getResultType();
+ QualType Ty = TSI->getType();
+ if (const FunctionType *FT = Ty->getAs<FunctionType>())
+ Ty = FT->getResultType();
+ if (!Ty->isDependentType())
+ return Ty;
}
return QualType();
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify -x objective-c++ %s
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from Mac OS X headers:
__attribute__((visibility("default"))) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__nothrow__)) dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr);
typedef long dispatch_once_t;
void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+dispatch_queue_t
+dispatch_queue_create(const char *label, dispatch_queue_attr_t attr);
+
+
typedef signed char BOOL;
typedef unsigned long NSUInteger;
typedef struct _NSZone NSZone;
do {
if (__builtin_expect(*(&pred), ~0l) != ~0l)
dispatch_once(&pred, ^{
- logQueue = dispatch_queue_create("com.mycompany.myproduct.asl", ((void*)0));
- client = asl_open(((void*)0), "com.mycompany.myproduct", 0);
+ logQueue = dispatch_queue_create("com.mycompany.myproduct.asl", 0);
+ client = asl_open(((char*)0), "com.mycompany.myproduct", 0);
});
} while (0);
__builtin_va_start(args, format);
NSString *str = [[NSString alloc] initWithFormat:format arguments:args];
- dispatch_async(logQueue, ^{ asl_log(client, ((void*)0), 4, "%s", [str UTF8String]); });
+ dispatch_async(logQueue, ^{ asl_log(client, ((aslmsg)0), 4, "%s", [str UTF8String]); });
[str release];
__builtin_va_end(args);
});
}
@end
+
+void testReturnVariousSignatures() {
+ (void)^int(){
+ return 42;
+ }();
+
+ (void)^int{
+ return 42;
+ }();
+
+ (void)^(){
+ return 42;
+ }();
+
+ (void)^{
+ return 42;
+ }();
+}