[cfe-dev] clang ignoring global function declaration depending on include/declaration order

Francois Pichet pichet2000 at gmail.com
Mon Jun 13 08:08:01 PDT 2011


On Mon, Jun 13, 2011 at 1:26 AM, David Blaikie <dblaikie at gmail.com> wrote:
>> Cédric Venet <cedric.venet at laposte.net>
>> writes:
>> > // this only work on gcc (and most compiler other than clang):
>> > template<class T> int bar2(T a) { return a+foo2(); }
>> > int foo2();
>>
>> This actually _doesn't_ work with any version of g++ I have (4.1 - 4.7):
>
> Indeed - I expect the only thing, if anything, that accepts this is
> Microsoft's C++ compiler (it's missing the whole two-phase lookup thing
> entirely).
> _______________________________________________

clang supports a -fdelayed-template-parsing mode to be able to parse such code.
Using -fdelayed-template-parsing, the parsing of the body of templated
functions is postponed to the end of the translation unit to make sure
all the names are available.




More information about the cfe-dev mailing list