[cfe-commits] r134785 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Francois Pichet pichet2000 at gmail.com
Fri Jul 8 23:20:52 PDT 2011


On Sat, Jul 9, 2011 at 1:50 AM, John McCall <rjmccall at apple.com> wrote:
>
> On Jul 8, 2011, at 10:47 PM, Francois Pichet wrote:
>
>> On Fri, Jul 8, 2011 at 10:30 PM, John McCall <rjmccall at apple.com> wrote:
>>> Author: rjmccall
>>> Date: Fri Jul  8 21:30:03 2011
>>> New Revision: 134785
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=134785&view=rev
>>> Log:
>>> GCC 4.2 compatibility hack.
>>>
>>>
>>> Modified:
>>>    cfe/trunk/lib/CodeGen/CGDecl.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=134785&r1=134784&r2=134785&view=diff
>>> ==============================================================================
>>> --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jul  8 21:30:03 2011
>>> @@ -1099,11 +1099,12 @@
>>>
>>>  CodeGenFunction::Destroyer &
>>>  CodeGenFunction::getDestroyer(QualType::DestructionKind kind) {
>>> +  // GCC 4.2 requires the *& on these function references.
>>>   switch (kind) {
>>>   case QualType::DK_none: llvm_unreachable("no destroyer for trivial dtor");
>>> -  case QualType::DK_cxx_destructor: return destroyCXXObject;
>>> -  case QualType::DK_objc_strong_lifetime: return destroyARCStrongPrecise;
>>> -  case QualType::DK_objc_weak_lifetime: return destroyARCWeak;
>>> +  case QualType::DK_cxx_destructor: return *&destroyCXXObject;
>>> +  case QualType::DK_objc_strong_lifetime: return *&destroyARCStrongPrecise;
>>> +  case QualType::DK_objc_weak_lifetime: return *&destroyARCWeak;
>>>   }
>>
>> MSVC doesn't like this hack:
>>
>> 38>CGDecl.cpp(1105): error C2276: '*' : illegal operation on bound
>> member function expression
>> 38>CGDecl.cpp(1106): error C2276: '*' : illegal operation on bound
>> member function expression
>> 38>CGDecl.cpp(1107): error C2276: '*' : illegal operation on bound
>> member function expression
>
> What?  MSVC is crazy, these are static functions.
>
> Would you mind playing with this and figuring out what MSVC will accept?
>
> John.
>

What about this:
  Destroyer* D = 0;
  switch (kind) {
  case QualType::DK_none: llvm_unreachable("no destroyer for trivial dtor");
  case QualType::DK_cxx_destructor: D = &destroyCXXObject; break;
  case QualType::DK_objc_strong_lifetime: D = &destroyARCStrongPrecise; break;
  case QualType::DK_objc_weak_lifetime: D = &destroyARCWeak; break;
  }
  return *D;




More information about the cfe-commits mailing list