[cfe-dev] Storage class as written in the source.

Enea Zaffanella zaffanella at cs.unipr.it
Fri Apr 16 23:48:19 PDT 2010


Douglas Gregor wrote:
> Hi Enea,
>
> On Apr 16, 2010, at 12:27 PM, Enea Zaffanella wrote:
>> Some time ago, Paolo Bolzoni sent to the mailing list a patch meant to enhance VarDecl and FunctionDecl nodes so that they can record the storage class "as written" in the source code (in contrast with the semantic storage class, which could be inherited).
>>
>> This was the message:
>> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-February/007982.html
>>
>> The patch was not applied and now is out-of-date.
>>
>> I have just refreshed it to be a patch against a recent version (r101446, see attached file). It passes all of the clang tests.
>>
>> It would be nice if someone could have a look on and possibly commit it.
> 
> Looks very good. I have a few comments that I'd like to see addressed before I commit.

Thank you for the very quick reply.

[...]

> Constructors, destructors, and conversions don't have storage classes in well-formed code, so we shouldn't make the storage-class specifier part of the constructors for the corresponding AST nodes. Just pass FunctionDecl::None down to the CXXMethodDecl constructor in the appropriate place.

Paolo in his message observed that out-of-line definitions of 
constructors, destructors and conversions can have "extern" as a storage 
class. The following compiles cleanly on g++:

struct S {
   S();
   ~S();
   operator bool();
};

extern S::S() {}
extern S::~S() {}
extern S::operator bool() { return true; }


Hence, will it be OK if we leave the extra argument in the constructors 
of the AST nodes above?

(The other comments are finding their way in the revised patch.)

Cheers,
Enea.




More information about the cfe-dev mailing list