From 6010fae75204ec20492982771e1dd2b6beb8da97 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 3 Jul 2008 00:32:25 -0400 Subject: [PATCH] tree.c (ctor_to_list): Use FOR_EACH_CONSTRUCTOR_ELT. * gcc/tree.c (ctor_to_list): Use FOR_EACH_CONSTRUCTOR_ELT. * gcc/cp/Make-lang.in (cp/typeck2.o): Add dependency. * libstdc++-v3/libsupc++/initializer_list: Uglify and wrap in __GXX_EXPERIMENTAL_CXX0X__. * libstdc++-v3/include/bits/stl_map.h (insert(initializer_list)): Wrap. From-SVN: r137406 --- gcc/ChangeLog | 2 ++ gcc/cp/ChangeLog | 2 ++ gcc/cp/Make-lang.in | 2 +- gcc/tree.c | 8 +++----- libstdc++-v3/ChangeLog | 6 ++++++ libstdc++-v3/include/bits/stl_map.h | 6 ++++-- libstdc++-v3/libsupc++/initializer_list | 23 +++++++++++++---------- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f0b367731d..433157ab870 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -129,6 +129,8 @@ 2008-07-02 Jason Merrill + * tree.c (ctor_to_list): Use FOR_EACH_CONSTRUCTOR_ELT. + * tree.c (ctor_to_list): New fn. * tree.h: Declare it. (CONSTRUCTOR_ELT): New macro. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3bf8c97596d..6475b43fc1b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2008-07-02 Jason Merrill + * Make-lang.in (cp/typeck2.o): Add $(REAL_H) dependency. + Implement WG21 N2672, Initializer List proposed wording * cp-tree.h (enum cp_tree_index): Add CPTI_INIT_LIST_TYPE. (struct lang_type_class): Add has_list_ctor bitfield. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 6fced350ec4..c7877205f25 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -245,7 +245,7 @@ cp/cp-objcp-common.o : cp/cp-objcp-common.c $(CONFIG_H) $(SYSTEM_H) \ langhooks.h $(LANGHOOKS_DEF_H) $(DIAGNOSTIC_H) debug.h \ $(CXX_PRETTY_PRINT_H) cp/cp-objcp-common.h gt-cp-cp-objcp-common.h cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h output.h \ - $(TM_P_H) $(DIAGNOSTIC_H) gt-cp-typeck2.h + $(TM_P_H) $(DIAGNOSTIC_H) gt-cp-typeck2.h $(REAL_H) cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) $(EXPR_H) \ toplev.h $(DIAGNOSTIC_H) convert.h $(C_COMMON_H) $(TARGET_H) cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H) \ diff --git a/gcc/tree.c b/gcc/tree.c index a8f66dbb895..491a7b319ee 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -1835,13 +1835,11 @@ ctor_to_list (tree ctor) tree list = NULL_TREE; tree *p = &list; unsigned ix; - constructor_elt *ce; + tree purpose, val; - for (ix = 0; - VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (ctor), ix, ce); - ++ix) + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), ix, purpose, val) { - *p = build_tree_list (ce->index, ce->value); + *p = build_tree_list (purpose, val); p = &TREE_CHAIN (*p); } diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4c3689e3421..6f0b4152c47 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2008-07-02 Jason Merrill + + * libsupc++/initializer_list: Uglify and wrap in + __GXX_EXPERIMENTAL_CXX0X__. + * include/bits/stl_map.h (insert(initializer_list)): Wrap. + 2008-07-02 Jason Merrill * libsupc++/initializer_list: New file. diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index cf0c16bc42d..cd85b9ab75d 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -469,6 +469,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(const value_type& __x) { return _M_t._M_insert_unique(__x); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ /** * @brief Attempts to insert a list of std::pairs into the %map. * @param list A std::initializer_list of pairs to be @@ -478,8 +479,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * */ void - insert(std::initializer_list list) - { insert (list.begin(), list.end()); } + insert(std::initializer_list __list) + { insert (__list.begin(), __list.end()); } +#endif /** * @brief Attempts to insert a std::pair into the %map. diff --git a/libstdc++-v3/libsupc++/initializer_list b/libstdc++-v3/libsupc++/initializer_list index 1a3cba3dd02..3c81bb69c8b 100644 --- a/libstdc++-v3/libsupc++/initializer_list +++ b/libstdc++-v3/libsupc++/initializer_list @@ -31,34 +31,37 @@ #ifndef __CXX_INITIALIZER_LIST #define __CXX_INITIALIZER_LIST +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + #pragma GCC visibility push(default) #include namespace std { - template + template class initializer_list { - const E* _array; - size_t _len; + const _E* __array; + size_t __len; // The compiler can call a private constructor. - initializer_list(const E* _a, size_t _l) - : _array(_a), _len(_l) { } + initializer_list(const _E* __a, size_t __l) + : __array(__a), __len(__l) { } public: initializer_list() - : _array(NULL), _len(0) {} + : __array(NULL), __len(0) {} size_t size() const // number of elements - { return _len; } - const E* begin() const // first element - { return _array; } - const E* end() const // one past the last element + { return __len; } + const _E* begin() const // first element + { return __array; } + const _E* end() const // one past the last element { return begin() + size(); } }; } #pragma GCC visibility pop +#endif // C++0x #endif // __CXX_INITIALIZER_LIST -- 2.30.2