[cfe-dev] WIP patch for qualified-ids in class member access
Douglas Gregor
dgregor at apple.com
Fri Jul 10 08:53:48 PDT 2009
On Jul 8, 2009, at 7:53 PM, Douglas Gregor wrote:
> Hi James,
>
> On Jul 6, 2009, at 9:27 PM, James Porter wrote:
>> Index: lib/Parse/ParseExpr.cpp
>> ===================================================================
>> --- lib/Parse/ParseExpr.cpp (revision 74890)
>> +++ lib/Parse/ParseExpr.cpp (working copy)
>> @@ -915,6 +915,14 @@
>> tok::TokenKind OpKind = Tok.getKind();
>> SourceLocation OpLoc = ConsumeToken(); // Eat the "." or "-
>> >" token.
>>
>> + CXXScopeSpec SS;
>> + if (getLang().CPlusPlus) {
>> + if( !Actions.ActOnCXXEnterMemberScope(CurScope,LHS) )
>> + return ExprError();
>> + ParseOptionalCXXScopeSpecifier(SS);
>> + Actions.ActOnCXXExitMemberScope(CurScope,LHS,SS);
>> + }
>> +
>
> Oh, this is interesting. I completely expected to have something like:
>
>
>> + CXXScopeSpec SS;
>> + if (getLang().CPlusPlus) {
>> + if( !Actions.ActOnCXXEnterMemberScope(CurScope,LHS) )
>> + return ExprError();
>> + ParseOptionalCXXScopeSpecifier(SS);
>
> followed by a call to ActOnMemberReferenceExpr, then
>
> if (getLang().CPlusPlus)
> Actions.ActOnCXXExitMemberScope(CurScope,LHS,SS);
>
> In other words, I expected that we would enter the member scope,
> process the member-reference expression within that scope (so that
> name lookup would be based on that scope), then exit the member
> scope at the end. \
Thinking about this further, I think you had the right idea after all.
At least, I can see both ways working, and they need to produce the
same results. The really, really tricky case is with a conversion
function, e.g., x.operator T(). C++ [basic.lookup.classref]p7 says
this:
If the id-expression is a conversion-function-id, its conversion-type-
id shall denote the same type in both the context in which the entire
postfix-expression occurs and in the context of the class of the
object expression (or the class pointed to by the pointer expression).
Since the conversion-function-id is the only place where I could
imagine your approach and my suggestion to differ, and in theory we
have to do *both*, let's go with your approach: it requires fewer
changes, and we can think about diagnosing paragraph 7 later.
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090710/265587d3/attachment.html>
More information about the cfe-dev
mailing list