[cfe-commits] r78862 - /cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Chris Lattner clattner at apple.com
Thu Aug 13 12:54:17 PDT 2009


On Aug 12, 2009, at 6:17 PM, Ryan Flynn wrote:

> On Wed, Aug 12, 2009 at 7:56 PM, Eli  
> Friedman<eli.friedman at gmail.com> wrote:
>> On Wed, Aug 12, 2009 at 4:53 PM, Ryan Flynn<parseerror at gmail.com>  
>> wrote:
>>> On Wed, Aug 12, 2009 at 7:49 PM, Eli  
>>> Friedman<eli.friedman at gmail.com> wrote:
>>>> On Wed, Aug 12, 2009 at 4:36 PM, Ryan Flynn<pizza at parseerror.com>  
>>>> wrote:
>>>>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
>>>>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Aug 12 18:36:28 2009
>>>>> @@ -437,7 +437,7 @@
>>>>>     return;
>>>>>   }
>>>>>
>>>>> -  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
>>>>> +  if (FunctionDecl *FD = cast<FunctionDecl>(d)) {
>>>>>     if (!FD->getResultType()->isPointerType()) {
>>>>>       S.Diag(Attr.getLoc(),  
>>>>> diag::warn_attribute_malloc_pointer_only);
>>>>>       return;
>>>>
>>>> Is there actually any guarantee the decl in question is a  
>>>> function decl?
>>>>
>>>> -Eli
>>>>
>>>
>>> Eli,
>>>
>>> The block above it returns if (!isFunctionOrMethod(d)).
>>>
>>> Ryan
>>
>> But that doesn't guarantee it's a FunctionDecl, no?
>>
>> -Eli
>>
>
> Eli,
>
> Nope.

Ok, so getting back to cast vs dyncast, we need to do the "must be a  
pointer return type" check for the othe case as well :)

-Chris




More information about the cfe-commits mailing list