On Fri, Oct 23, 2009 at 1:01 PM, Fariborz Jahanian <[email protected]> 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

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to