[cfe-commits] [patch][PR11797] Call ActOnFinishNamespaceDef before consumeClose

Richard Smith richard at metafoo.co.uk
Thu Jan 19 21:40:43 PST 2012


Perhaps it's time to review the handling of #pragma visibility. The existing
mechanism is very flaky -- this is the second subtle bug we've had with it in
recent months (the previous bug, which probably can still be observed in some
cases, is that lookahead / tentative parsing which looks past such a #pragma
applies its effects immediately).

In what positions does gcc permit this pragma to appear? Could we produce a
token for it, and consume that token (and activate the change to the default
visibility) when parsing a declaration?

On Fri, January 20, 2012 02:34, Rafael Ávila de Espíndola wrote:
> The attached patch fixes PR11797. The problem is that
> Tracker.consumeClose will check what is after the '}'. If it is a
> #pragma, it will be handled before ActOnFinishNamespaceDef.
>
>
> This caused Sema to view the testcase in the PR as
>
>
> namespace std __attribute__ ((__visibility__ ("default"))) { #pragma GCC
> visibility push(default) }
> void foo()  { }
> #pragma GCC visibility pop
>
>
> This patch swaps the order of the calls, which unfortunately means that
> we now have to call setRBraceLoc from outside Sema::ActOnFinishNamespaceDef.
>
> Is the patch OK?
>
>
> Cheers,
> Rafael
>
>
>




More information about the cfe-commits mailing list