[cfe-commits] r84968 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseExpr.cpp lib/Sema/SemaExprCXX.cpp test/Parser/cxx-parse-member-pointer-op.cpp
Fariborz Jahanian
fjahanian at apple.com
Wed Nov 18 13:56:57 PST 2009
Fixed in TOT: http://llvm.org/viewvc/llvm-project?view=rev&revision=89251
- Fariborz
On Nov 17, 2009, at 11:38 PM, Eli Friedman wrote:
> On Fri, Oct 23, 2009 at 1:01 PM, Fariborz Jahanian <fjahanian at apple.com
> > wrote:
>> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Oct 23 16:01:39 2009
>> @@ -340,7 +340,18 @@
>> // Eat the colon.
>> ColonLoc = ConsumeToken();
>> }
>> -
>> +
>> + if ((OpToken.is(tok::periodstar) || OpToken.is(tok::arrowstar))
>> + && Tok.is(tok::identifier)) {
>> + CXXScopeSpec SS;
>> + if (Actions.getTypeName(*Tok.getIdentifierInfo(),
>> + Tok.getLocation(),
>> CurScope, &SS)) {
>> + const char *Opc = OpToken.is(tok::periodstar) ? "'.*'" :
>> "'->*'";
>> + Diag(OpToken, diag::err_pointer_to_member_type) << Opc;
>> + return ExprError();
>> + }
>> +
>> + }
>
> This check catches a valid construct in Firefox which looks something
> like the following:
> struct C { static int (C::* a); };
> int a(C* x) { return x->*C::a; }
>
> The reason that cxx-parse-member-pointer-op.cpp isn't well-formed has
> nothing to do with the fact that a type follows the ->* operator; the
> issue is that the computed function isn't used in a call, which is
> purely a Sema issue. A construct like "(c->*pmfc())();" is perfectly
> well-formed, but it has undefined behavior.
>
> -Eli
More information about the cfe-commits
mailing list