[TCWG CI] Regression caused by gcc: c++: designators in single-element init lists: commit 885035eacb36b5bf1aa3b0d05f675ab89665d7be Author: Jason Merrill <ja...@redhat.com>
c++: designators in single-element init lists Results regressed to # reset_artifacts: -10 # build_abe binutils: -9 # build_abe stage1: -5 # build_abe qemu: -2 # linux_n_obj: 33 # First few build errors in logs: # 00:00:55 cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory # 00:00:55 cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory # 00:00:55 cc1plus: fatal error: ./include/generated/utsrelease.h: No such file or directory # 00:00:56 make[2]: *** [scripts/gcc-plugins/latent_entropy_plugin.so] Error 1 # 00:00:56 make[2]: *** [scripts/gcc-plugins/stackleak_plugin.so] Error 1 # 00:00:56 make[2]: *** [scripts/gcc-plugins/randomize_layout_plugin.so] Error 1 # 00:00:56 make[1]: *** [scripts/gcc-plugins] Error 2 # 00:00:57 make: *** [scripts] Error 2 from # reset_artifacts: -10 # build_abe binutils: -9 # build_abe stage1: -5 # build_abe qemu: -2 # linux_n_obj: 21071 # linux build successful: all THIS IS THE END OF INTERESTING STUFF. BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT. This commit has regressed these CI configurations: - tcwg_kernel/gnu-release-aarch64-next-allyesconfig First_bad build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/build-885035eacb36b5bf1aa3b0d05f675ab89665d7be/ Last_good build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/build-84fd1b5dff70cd74aee7e8b18f66959d8b8e1ce7/ Baseline build: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/build-baseline/ Even more details: https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/ Reproduce builds: <cut> mkdir investigate-gcc-885035eacb36b5bf1aa3b0d05f675ab89665d7be cd investigate-gcc-885035eacb36b5bf1aa3b0d05f675ab89665d7be # Fetch scripts git clone https://git.linaro.org/toolchain/jenkins-scripts # Fetch manifests and test.sh script mkdir -p artifacts/manifests curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/manifests/build-baseline.sh --fail curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/manifests/build-parameters.sh --fail curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_kernel-gnu-bisect-gnu-release-aarch64-next-allyesconfig/139/artifact/artifacts/test.sh --fail chmod +x artifacts/test.sh # Reproduce the baseline build (build all pre-requisites) ./jenkins-scripts/tcwg_kernel-build.sh @@ artifacts/manifests/build-baseline.sh # Save baseline build state (which is then restored in artifacts/test.sh) mkdir -p ./bisect rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /gcc/ ./ ./bisect/baseline/ cd gcc # Reproduce first_bad build git checkout --detach 885035eacb36b5bf1aa3b0d05f675ab89665d7be ../artifacts/test.sh # Reproduce last_good build git checkout --detach 84fd1b5dff70cd74aee7e8b18f66959d8b8e1ce7 ../artifacts/test.sh cd .. </cut> Full commit (up to 1000 lines): <cut> commit 885035eacb36b5bf1aa3b0d05f675ab89665d7be Author: Jason Merrill <ja...@redhat.com> Date: Wed May 19 21:13:43 2021 -0400 c++: designators in single-element init lists While looking at PR100489, it occurred to me that places that currently use an initializer-list with a single element to initialize an object of the same type shouldn't do that if the element has a designator. gcc/cp/ChangeLog: * call.c (reference_binding): Check for designator. (implicit_conversion_1, build_special_member_call): Likewise. * decl.c (reshape_init_r): Likewise. * pt.c (do_class_deduction): Likewise. * typeck2.c (digest_init_r): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/desig19.C: New test. --- gcc/cp/call.c | 5 ++++- gcc/cp/decl.c | 2 ++ gcc/cp/pt.c | 3 ++- gcc/cp/typeck2.c | 1 + gcc/testsuite/g++.dg/cpp2a/desig19.C | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index fa770f244cb..cfccf273632 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1731,7 +1731,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags, because A[] and A[2] are reference-related. But we don't do it because grok_reference_init has deduced the array size (to 1), and A[1] and A[2] aren't reference-related. */ - if (CONSTRUCTOR_NELTS (expr) == 1) + if (CONSTRUCTOR_NELTS (expr) == 1 + && !CONSTRUCTOR_IS_DESIGNATED_INIT (expr)) { tree elt = CONSTRUCTOR_ELT (expr, 0)->value; if (error_operand_p (elt)) @@ -2095,6 +2096,7 @@ implicit_conversion_1 (tree to, tree from, tree expr, bool c_cast_p, { if (BRACE_ENCLOSED_INITIALIZER_P (expr) && CONSTRUCTOR_NELTS (expr) == 1 + && !CONSTRUCTOR_IS_DESIGNATED_INIT (expr) && !is_list_ctor (cand->fn)) { /* "If C is not an initializer-list constructor and the @@ -10199,6 +10201,7 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args, if (BRACE_ENCLOSED_INITIALIZER_P (arg) && !TYPE_HAS_LIST_CTOR (class_type) + && !CONSTRUCTOR_IS_DESIGNATED_INIT (arg) && CONSTRUCTOR_NELTS (arg) == 1) arg = CONSTRUCTOR_ELT (arg, 0)->value; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6107b553cb4..e7268d5ad18 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6650,6 +6650,8 @@ reshape_init_r (tree type, reshape_iter *d, tree first_initializer_p, initialized from that element." Even if T is an aggregate. */ if (cxx_dialect >= cxx11 && (CLASS_TYPE_P (type) || VECTOR_TYPE_P (type)) && first_initializer_p + /* But not if it's a designated init. */ + && !d->cur->index && d->end - d->cur == 1 && reference_related_p (type, TREE_TYPE (init))) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3d1787b6fc3..99a9ee5ade2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -29326,7 +29326,8 @@ do_class_deduction (tree ptype, tree tmpl, tree init, { list_init_p = true; try_list_ctor = TYPE_HAS_LIST_CTOR (type); - if (try_list_ctor && CONSTRUCTOR_NELTS (init) == 1) + if (try_list_ctor && CONSTRUCTOR_NELTS (init) == 1 + && !CONSTRUCTOR_IS_DESIGNATED_INIT (init)) { /* As an exception, the first phase in 16.3.1.7 (considering the initializer list as a single argument) is omitted if the diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 5a7219dec65..6679e247816 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1183,6 +1183,7 @@ digest_init_r (tree type, tree init, int nested, int flags, the object is initialized from that element." */ if (cxx_dialect >= cxx11 && BRACE_ENCLOSED_INITIALIZER_P (stripped_init) + && !CONSTRUCTOR_IS_DESIGNATED_INIT (stripped_init) && CONSTRUCTOR_NELTS (stripped_init) == 1 && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type)) || VECTOR_TYPE_P (type))) diff --git a/gcc/testsuite/g++.dg/cpp2a/desig19.C b/gcc/testsuite/g++.dg/cpp2a/desig19.C new file mode 100644 index 00000000000..3321da85802 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/desig19.C @@ -0,0 +1,33 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +struct A +{ + int i; + constexpr operator int() { return 42; } +}; + +#define SA(X) static_assert ((X),#X) +constexpr A a1 { A() }; +SA(a1.i == 0); +constexpr A a2 { i: A() }; +SA(a2.i == 42); +#if __cpp_constexpr >= 201304L +constexpr int f3 () { A const &r { A() }; return r.i; } +SA(f3() == 0); +constexpr int f4 () { A const &r { i: A() }; return r.i; } +SA(f4() == 42); +constexpr int f5 () { A ar[1]{{ A() }}; return ar[0].i; } +SA(f5() == 0); +constexpr int f5a () { A ar[1]{{ i: A() }}; return ar[0].i; } +SA(f5a() == 42); +#if __cpp_constexpr >= 201907L +constexpr int f6 () { A* p = new A{A()}; int i = p->i; delete p; return i; } +SA(f6() == 0); +constexpr int f6a () { A* p = new A{i:A()}; int i = p->i; delete p; return i; } +SA(f6a() == 42); +#endif +#endif +constexpr int f7 (A a) { return a.i; } +SA(f7({A()}) == 0); +SA(f7({i:A()}) == 42); </cut> _______________________________________________ linaro-toolchain mailing list -- linaro-toolchain@lists.linaro.org To unsubscribe send an email to linaro-toolchain-le...@lists.linaro.org