[cfe-dev] Preliminary reinterpret_cast Sema patch

Doug Gregor doug.gregor at gmail.com
Thu Oct 23 07:12:37 PDT 2008


On Thu, Oct 23, 2008 at 4:59 AM, Sebastian Redl
<sebastian.redl at getdesigned.at> wrote:
> Doug Gregor wrote:
>>
>> On Tue, Oct 21, 2008 at 9:44 AM, Sebastian Redl
>> <sebastian.redl at getdesigned.at> wrote:
>> Hmm... in the case of an error when type-checking the casts, we should
>> not actually build a CXXCastExpr node. Rather, Sema::ActOnCXXCasts
>> should return "true" so that the parser knows that there was an error.
>>
>> I suggest that both CheckConstCast and CheckReinterpretCast return a
>> bool that is true when there is an error and false otherwise (this is
>> the scheme used elsewhere in Clang). Then, ActOnCXXCasts will never
>> build an ill-formed node in the AST (which is a good thing).
>>
>
> I had it that way originally, but Argiris told me to return the node
> regardless of the result of the check.

Ah, interesting. Well, in that case, leave it as is and we can have a
separate discussion about this issue.

>>> +  // As for members, we don't have them yet.
>>> +
>>> +  if (SrcType->isObjectType() || SrcType->isVoidType()) {
>>> +    if (DestType->isObjectType() || DestType->isVoidType()) {
>>> +      // C++ 5.2.10p7: A pointer to an object can be explicitly
>>> converted
>>> to
>>> +      //   a pointer to an object of different type.
>>> +      // Void pointers are not specified, but supported by G++.
>>> +      return;
>>> +    }
>>>
>>
>> EDG supports void pointers, too, and it seems obvious that they should
>> be allowed, but there is nothing in the standard or in the issues list
>> to imply that conversion to/from void pointers is okay.
>>
>
> So, do we support this or not?

Yes, and I'm going to ask for clarification or file an issue.

>> Thanks again for the patch! We're getting close... actually, the
>> const_cast bits could probably go in with a tiny amount of tweaking.
>> If you'd like to separate out those bits and submit/commit, please go
>> ahead; I'd like to look over a second round of the reinterpret_cast
>> stuff before it goes in, though.
>>
>
> I'll just post another full version of the patch. With SVN, separating
> different parts is always a bit of a hassle.

Yes, it is. Looking forward to your next revision!

  - Doug



More information about the cfe-dev mailing list