C++ PATCH to implement initializer lists proposal (n2672)

H.J. Lu hjl.tools@gmail.com
Mon Apr 13 15:09:00 GMT 2009


On Wed, Jul 2, 2008 at 8:37 AM, Jason Merrill <jason@redhat.com> wrote:
> The proposal for the initializer lists extension was accepted at the C++
> standards meeting last month; here is the first implementation.
>
> I decided to handle direct-initialization a la A a{1,2} by wrapping the
> CONSTRUCTOR in a TREE_LIST and setting a flag on it to distinguish it from A
> a({1,2}).  This seemed simpler than changing everywhere in the compiler that
> deals with arguments to be able to handle a CONSTRUCTOR as well as a
> TREE_LIST.
>
> The overload resolution handling was easier than I expected it to be; just a
> few tweaks and the semantics fell out naturally, which makes me feel good
> about the specification.
>
> Allowing {} in mem-initializers complicates the logic in
> cp_parser_save_member_function_body, as now we can't just skip to the end of
> the next {}.  It took me a few iterations, but what I have now will handle
> syntax errors without getting into an infinite loop.
>
> This patch only includes one small piece of N2679, namely
> map::insert(initializer_list) which I wanted to use for testing.  I'll go
> ahead and add the rest in a separate patch.
>
> Tested x86_64-pc-linux-gnu, applied to trunk.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39750

-- 
H.J.



More information about the Gcc-patches mailing list