new_flags |= LOOKUP_AGGREGATE_PAREN_INIT;
init = digest_init_r (type, init, nested ? 2 : 1, new_flags, complain);
/* When we defer constant folding within a statement, we may want to
- defer this folding as well. Don't call this on CONSTRUCTORs because
- their elements have already been folded, and we must avoid folding
- the result of get_nsdmi. */
- if (TREE_CODE (init) != CONSTRUCTOR)
+ defer this folding as well. Don't call this on CONSTRUCTORs in
+ a template because their elements have already been folded, and
+ we must avoid folding the result of get_nsdmi. */
+ if (!(processing_template_decl && TREE_CODE (init) == CONSTRUCTOR))
{
tree t = fold_non_dependent_init (init, complain);
if (TREE_CONSTANT (t))
--- /dev/null
+// PR c++/118047
+// { dg-do compile { target c++11 } }
+
+typedef decltype(sizeof(char)) size_t;
+
+namespace std {
+template <typename T>
+struct initializer_list {
+ const T *_M_array;
+ size_t _M_len;
+ constexpr size_t size() const { return _M_len; }
+};
+}
+
+enum E {
+ One
+};
+
+struct A {
+ E e = One;
+};
+
+struct B {
+ A as[1] {};
+};
+
+struct V
+{
+ constexpr V(const std::initializer_list<B> &a) : size(a.size()){}
+ int size;
+};
+
+constexpr V a{{}};
+
+static_assert(a.size == 1, "");