[cfe-commits] r79040 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/attr-malloc.m

Ted Kremenek kremenek at apple.com
Fri Aug 14 14:52:15 PDT 2009


On Aug 14, 2009, at 2:48 PM, Eli Friedman wrote:

> On Fri, Aug 14, 2009 at 1:49 PM, Ted Kremenek<kremenek at apple.com>  
> wrote:
>> @@ -431,17 +438,18 @@
>>     return;
>>   }
>>
>> -  if (!isFunctionOrMethod(d)) {
>> +  if (!isFunction(d)) {
>>     S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
>>       << Attr.getName() << 0 /*function*/;
>>     return;
>>   }
>>
>> -  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
>> -    if (!FD->getResultType()->isPointerType()) {
>> -      S.Diag(Attr.getLoc(),  
>> diag::warn_attribute_malloc_pointer_only);
>> -      return;
>> -    }
>> +  const FunctionDecl *FD = cast<FunctionDecl>(d);
>> +  QualType RetTy = FD->getResultType();
>> +
>> +  if (!(RetTy->isAnyPointerType() || RetTy->isBlockPointerType())) {
>> +    S.Diag(Attr.getLoc(), diag::warn_attribute_malloc_pointer_only);
>> +    return;
>>   }
>
> I believe we went through this before... isFunction doesn't guarantee
> that d is a FunctionDecl.

Right.  Please see the follow-up patch.



More information about the cfe-commits mailing list