[cfe-commits] r80988 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/SemaCXX/libstdcxx_is_pod_hack.cpp

Eli Friedman eli.friedman at gmail.com
Fri Sep 4 01:14:06 PDT 2009


On Thu, Sep 3, 2009 at 10:53 PM, Douglas Gregor<dgregor at apple.com> wrote:
> Author: dgregor
> Date: Fri Sep  4 00:53:02 2009
> New Revision: 80988
>
> URL: http://llvm.org/viewvc/llvm-project?rev=80988&view=rev
> Log:
> Introduce an egregious hack to fix PR4828.
>
> The problem this change addresses is that we treat __is_pod and
> __is_empty as keywords in C++, because they are built-in type traits
> in GCC >= 4.3. However, GNU libstdc++ 4.2 (and possibly earlier
> versions) define implementation-detail struct templates named __is_pod
> and __is_empty.
>
> This commit solves the problem by recognizing
>
>  struct __is_pod
>
> and
>
>  struct __is_empty
>
> as special token sequences. When one of these token sequences is
> encountered, the keyword (__is_pod or __is_empty) is implicitly
> downgraded to an identifier so that parsing can continue. This is an
> egregious hack, but it has the virtue of "just working" whether
> someone is using libstdc++ 4.2 or not, without the need for special
> flags.

Wow, that's evilly clever.

-Eli




More information about the cfe-commits mailing list