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
This commit is contained in:
Jason Merrill 2008-07-03 00:32:25 -04:00 committed by Jason Merrill
parent 5aad979918
commit 6010fae752
7 changed files with 31 additions and 18 deletions

View File

@ -129,6 +129,8 @@
2008-07-02 Jason Merrill <jason@redhat.com>
* 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.

View File

@ -1,5 +1,7 @@
2008-07-02 Jason Merrill <jason@redhat.com>
* 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.

View File

@ -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) \

View File

@ -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);
}

View File

@ -1,3 +1,9 @@
2008-07-02 Jason Merrill <jason@redhat.com>
* libsupc++/initializer_list: Uglify and wrap in
__GXX_EXPERIMENTAL_CXX0X__.
* include/bits/stl_map.h (insert(initializer_list)): Wrap.
2008-07-02 Jason Merrill <jason@redhat.com>
* libsupc++/initializer_list: New file.

View File

@ -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<value_type> of pairs to be
@ -478,8 +479,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
*
*/
void
insert(std::initializer_list<value_type> list)
{ insert (list.begin(), list.end()); }
insert(std::initializer_list<value_type> __list)
{ insert (__list.begin(), __list.end()); }
#endif
/**
* @brief Attempts to insert a std::pair into the %map.

View File

@ -31,34 +31,37 @@
#ifndef __CXX_INITIALIZER_LIST
#define __CXX_INITIALIZER_LIST
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#pragma GCC visibility push(default)
#include <cstddef>
namespace std
{
template<class E>
template<class _E>
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