aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-03-16 10:35:47 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-03-16 10:35:47 -0400
commita81495699e206fef07824accd73d183294a1d0b0 (patch)
treeb870e3297bcf07ffe3ad6a62ae155040fc12c1a1 /gcc
parent570f86f94eca76fbfab919dcbfe639a5ba69f20e (diff)
downloadgcc-a81495699e206fef07824accd73d183294a1d0b0.zip
gcc-a81495699e206fef07824accd73d183294a1d0b0.tar.gz
gcc-a81495699e206fef07824accd73d183294a1d0b0.tar.bz2
PR c++/83937 - wrong C++17 handling of init-list ctor argument.
* call.c (build_special_member_call): Don't convert an init-list argument directly to the class type. From-SVN: r258594
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/call.c7
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-ctor2.C15
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0ea8371..7428c4b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-16 Jason Merrill <jason@redhat.com>
+
+ PR c++/83937 - wrong C++17 handling of init-list ctor argument.
+ * call.c (build_special_member_call): Don't convert an init-list
+ argument directly to the class type.
+
2018-03-16 Jakub Jelinek <jakub@redhat.com>
PR c++/79937
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 5cee63f..a32f419 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8827,7 +8827,12 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args,
/* If we're using this to initialize a non-temporary object, don't
require the destructor to be accessible. */
sub_complain |= tf_no_cleanup;
- if (!reference_related_p (class_type, TREE_TYPE (arg)))
+ if (BRACE_ENCLOSED_INITIALIZER_P (arg)
+ && !CONSTRUCTOR_IS_DIRECT_INIT (arg))
+ /* An init-list arg needs to convert to the parm type (83937), so fall
+ through to normal processing. */
+ arg = error_mark_node;
+ else if (!reference_related_p (class_type, TREE_TYPE (arg)))
arg = perform_implicit_conversion_flags (class_type, arg,
sub_complain,
flags);
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-ctor2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-ctor2.C
new file mode 100644
index 0000000..ebacec0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-ctor2.C
@@ -0,0 +1,15 @@
+// PR c++/83937
+// { dg-do run { target c++11 } }
+
+struct S
+{
+ S(int v = 42) {
+ if (v != int{})
+ __builtin_abort();
+ }
+};
+
+int main()
+{
+ S( {} );
+}