Just need to pass the flags down.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 6aee56eb70ff04c9c1fbcbef388144d4a0338154
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Nov 18 10:04:49 2016 -0500

            PR c++/67631 - list-init and explicit conversions
    
            * semantics.c (finish_compound_literal): Call digest_init_flags.
            * typeck2.c (digest_init_flags): Add complain parm.
            (store_init_value): Pass it.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e5f9113..5674886 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6839,7 +6839,7 @@ extern tree store_init_value                      (tree, 
tree, vec<tree, va_gc>**, int);
 extern tree split_nonconstant_init             (tree, tree);
 extern bool check_narrowing                    (tree, tree, tsubst_flags_t);
 extern tree digest_init                                (tree, tree, 
tsubst_flags_t);
-extern tree digest_init_flags                  (tree, tree, int);
+extern tree digest_init_flags                  (tree, tree, int, 
tsubst_flags_t);
 extern tree digest_nsdmi_init                  (tree, tree);
 extern tree build_scoped_ref                   (tree, tree, tree *);
 extern tree build_x_arrow                      (location_t, tree,
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 96c67a5..389e7f1 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2713,7 +2713,8 @@ finish_compound_literal (tree type, tree compound_literal,
       if (type == error_mark_node)
        return error_mark_node;
     }
-  compound_literal = digest_init (type, compound_literal, complain);
+  compound_literal = digest_init_flags (type, compound_literal, LOOKUP_NORMAL,
+                                       complain);
   if (TREE_CODE (compound_literal) == CONSTRUCTOR)
     TREE_HAS_CONSTRUCTOR (compound_literal) = true;
 
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 2ca4bf2..b214c99 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -794,7 +794,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** 
cleanups, int flags)
     value = init;
   else
     /* Digest the specified initializer into an expression.  */
-    value = digest_init_flags (type, init, flags);
+    value = digest_init_flags (type, init, flags, tf_warning_or_error);
 
   value = extend_ref_init_temps (decl, value, cleanups);
 
@@ -1165,9 +1165,9 @@ digest_init (tree type, tree init, tsubst_flags_t 
complain)
 }
 
 tree
-digest_init_flags (tree type, tree init, int flags)
+digest_init_flags (tree type, tree init, int flags, tsubst_flags_t complain)
 {
-  return digest_init_r (type, init, false, flags, tf_warning_or_error);
+  return digest_init_r (type, init, false, flags, complain);
 }
 
 /* Process the initializer INIT for an NSDMI DECL (a FIELD_DECL).  */
@@ -1183,7 +1183,7 @@ digest_nsdmi_init (tree decl, tree init)
   if (BRACE_ENCLOSED_INITIALIZER_P (init)
       && CP_AGGREGATE_TYPE_P (type))
     init = reshape_init (type, init, tf_warning_or_error);
-  init = digest_init_flags (type, init, flags);
+  init = digest_init_flags (type, init, flags, tf_warning_or_error);
   if (TREE_CODE (init) == TARGET_EXPR)
     /* This represents the whole initialization.  */
     TARGET_EXPR_DIRECT_INIT_P (init) = true;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-explicit1.C 
b/gcc/testsuite/g++.dg/cpp0x/initlist-explicit1.C
new file mode 100644
index 0000000..5e00b2d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-explicit1.C
@@ -0,0 +1,11 @@
+// PR c++/67631
+// { dg-do compile { target c++11 } }
+
+struct X
+{
+  explicit operator unsigned ();
+};
+unsigned foo ()
+{
+  return unsigned{ X () };
+}

Reply via email to