S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0;
return;
}
-
- const FunctionDecl *FD = dyn_cast<FunctionDecl>(d);
-
- if (!FD) {
+
+ const FunctionType *FT = getFunctionType(d, false);
+
+ if (!FT) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << 0 /*function*/;
return;
}
- QualType RetTy = FD->getResultType();
+ QualType RetTy = FT->getResultType();
if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning pointer type}}
int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning pointer type}}
-int * returns_intptr(void) __attribute((malloc));
+int * returns_intptr(void) __attribute((malloc)); // no-warning
typedef int * iptr;
-iptr returns_iptr (void) __attribute((malloc));
+iptr returns_iptr (void) __attribute((malloc)); // no-warning
+
+__attribute((malloc)) void *(*f)(); // no-warning
__attribute((malloc))
-void * xalloc(unsigned n) { return malloc(n); }
+void * xalloc(unsigned n) { return malloc(n); } // no-warning
// RUN: grep 'define noalias .* @xalloc(' %t &&
#define malloc_like __attribute((__malloc__))