[gcc r15-3922] c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void
https://gcc.gnu.org/g:de03ef6337b0a368d61c74b790313b4216c7ed6e commit r15-3922-gde03ef6337b0a368d61c74b790313b4216c7ed6e Author: Arsen Arsenović Date: Fri Sep 20 13:13:02 2024 +0200 c++: simplify handling implicit INDIRECT_REF and co_await in convert_to_void convert_to_void has, so far, when converting a co_await expression to void altered the await_resume expression of a co_await so that it is also converted to void. This meant that the type of the await_resume expression, which is also supposed to be the type of the whole co_await expression, was not the same as the type of the CO_AWAIT_EXPR tree. While this has not caused problems so far, it is unexpected, I think. Also, convert_to_void had a special case when an INDIRECT_REF wrapped a CALL_EXPR. In this case, we also diagnosed maybe_warn_nodiscard. This was a duplication of logic related to converting call expressions to void. Instead, we can generalize a bit, and rather discard the expression that was implicitly dereferenced instead. This patch changes the diagnostic of: void f(struct S* x) { static_cast(*x); } ... from: warning: indirection will not access object of incomplete type 'volatile S' in statement ... to: warning: implicit dereference will not access object of type ‘volatile S’ in statement ... but should have no impact in other cases. gcc/cp/ChangeLog: * coroutines.cc (co_await_get_resume_call): Return a tree directly, rather than a tree pointer. * cp-tree.h (co_await_get_resume_call): Adjust signature accordingly. * cvt.cc (convert_to_void): Do not alter CO_AWAIT_EXPRs when discarding them. Simplify handling implicit INDIRECT_REFs. gcc/testsuite/ChangeLog: * g++.dg/coroutines/nodiscard-1.C: New test. Diff: --- gcc/cp/coroutines.cc | 4 +- gcc/cp/cp-tree.h | 2 +- gcc/cp/cvt.cc | 102 +- gcc/testsuite/g++.dg/coroutines/nodiscard-1.C | 77 +++ 4 files changed, 132 insertions(+), 53 deletions(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 50904e0d004e..8e4c55a800e4 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -730,14 +730,14 @@ coro_get_destroy_function (tree decl) /* Given a CO_AWAIT_EXPR AWAIT_EXPR, return its resume call. */ -tree* +tree co_await_get_resume_call (tree await_expr) { gcc_checking_assert (TREE_CODE (await_expr) == CO_AWAIT_EXPR); tree vec = TREE_OPERAND (await_expr, 3); if (!vec) return nullptr; - return &TREE_VEC_ELT (vec, 2); + return TREE_VEC_ELT (vec, 2); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7c438eca16d6..39c065eecf6d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8782,7 +8782,7 @@ extern tree coro_get_actor_function (tree); extern tree coro_get_destroy_function (tree); extern tree coro_get_ramp_function (tree); -extern tree* co_await_get_resume_call (tree await_expr); +extern tree co_await_get_resume_call (tree await_expr); /* contracts.cc */ diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc index df02b8faaf51..526937d36181 100644 --- a/gcc/cp/cvt.cc +++ b/gcc/cp/cvt.cc @@ -1272,88 +1272,96 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) complete_type (type); int is_complete = COMPLETE_TYPE_P (type); - /* Can't load the value if we don't know the type. */ - if (is_volatile && !is_complete) + /* Don't load the value if this is an implicit dereference, or if + the type needs to be handled by ctors/dtors. */ + if (is_reference) { -if (complain & tf_warning) +if (is_volatile && (complain & tf_warning) + /* A co_await expression, in its await_resume expression, also + contains an implicit dereference. As a result, we don't + need to warn about them here. */ + && TREE_CODE (TREE_OPERAND (expr, 0)) != CO_AWAIT_EXPR) switch (implicit) { case ICV_CAST: warning_at (loc, 0, "conversion to void will not access " - "object of incomplete type %qT", type); + "object of type %qT", type); break; case ICV_SECOND_OF_COND: - warning_at (loc, 0, "indirection will not access object of " - "incomplete type %qT in second operand " - "of conditional expression", type); + warning_at (loc, 0, "implicit dereference will not access " +
[gcc r13-9058] s390: Fix TF to FPRX2 conversion [PR115860]
https://gcc.gnu.org/g:f7037fd03ad842dc69e20c03942f29d982ad655e commit r13-9058-gf7037fd03ad842dc69e20c03942f29d982ad655e Author: Stefan Schulze Frielinghaus Date: Fri Sep 27 08:18:47 2024 +0200 s390: Fix TF to FPRX2 conversion [PR115860] Currently subregs originating from *tf_to_fprx2_0 and *tf_to_fprx2_1 survive register allocation. This in turn leads to wrong register renaming. Keeping the current approach would mean we need two insns for *tf_to_fprx2_0 and *tf_to_fprx2_1, respectively. Something along the lines (define_insn "*tf_to_fprx2_0" [(set (subreg:DF (match_operand:FPRX2 0 "nonimmediate_operand" "=f") 0) (unspec:DF [(match_operand:TF 1 "general_operand" "v")] UNSPEC_TF_TO_FPRX2_0))] "TARGET_VXE" "#") (define_insn "*tf_to_fprx2_0" [(set (match_operand:DF 0 "nonimmediate_operand" "=f") (unspec:DF [(match_operand:TF 1 "general_operand" "v")] UNSPEC_TF_TO_FPRX2_0))] "TARGET_VXE" "vpdi\t%v0,%v1,%v0,1 [(set_attr "op_type" "VRR")]) and similar for *tf_to_fprx2_1. Note, pre register allocation operand 0 has mode FPRX2 and afterwards DF once subregs have been eliminated. Since we always copy a whole vector register into a floating-point register pair, another way to fix this is to merge *tf_to_fprx2_0 and *tf_to_fprx2_1 into a single insn which means we don't have to use subregs at all. The downside of this is that the assembler template contains two instructions, now. The upside is that we don't have to come up with some artificial insn before RA which might be more readable/maintainable. That is implemented by this patch. In commit r11-4872-ge627cda5686592, the output operand specifier %V was introduced which is used in tf_to_fprx2 only, now. Instead of coming up with its counterpart %F for floating-point registers, which would also only be used in tf_to_fprx2, I print the operands directly. This renders %V unused which is why it is removed by this patch. gcc/ChangeLog: PR target/115860 * config/s390/s390.cc (print_operand): Remove operand specifier %V. * config/s390/s390.md (UNSPEC_TF_TO_FPRX2): New. * config/s390/vector.md (*tf_to_fprx2_0): Remove. (*tf_to_fprx2_1): Remove. (tf_to_fprx2): New. gcc/testsuite/ChangeLog: * gcc.target/s390/vector/long-double-asm-abi.c: Adapt scan-assembler directive. * gcc.target/s390/vector/long-double-to-i64.c: Adapt scan-assembler directive. * gcc.target/s390/pr115860-1.c: New test. (cherry picked from commit 46c2538435dfc50dd5c67c4e03ce387d1f6ebe9b) Diff: --- gcc/config/s390/s390.cc| 5 +- gcc/config/s390/s390.md| 2 + gcc/config/s390/vector.md | 75 -- gcc/testsuite/gcc.target/s390/pr115860-1.c | 26 .../gcc.target/s390/vector/long-double-asm-abi.c | 2 +- .../gcc.target/s390/vector/long-double-to-i64.c| 2 - 6 files changed, 72 insertions(+), 40 deletions(-) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 26456ba3cc12..a0089e4c0f21 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -8122,7 +8122,6 @@ print_operand_address (FILE *file, rtx addr) CONST_VECTOR: Generate a bitmask for vgbm instruction. 'x': print integer X as if it's an unsigned halfword. 'v': print register number as vector register (v1 instead of f1). -'V': print the second word of a TFmode operand as vector register. */ void @@ -8315,13 +8314,13 @@ print_operand (FILE *file, rtx x, int code) case REG: /* Print FP regs as fx instead of vx when they are accessed through non-vector mode. */ - if ((code == 'v' || code == 'V') + if (code == 'v' || VECTOR_NOFP_REG_P (x) || (FP_REG_P (x) && VECTOR_MODE_P (GET_MODE (x))) || (VECTOR_REG_P (x) && (GET_MODE_SIZE (GET_MODE (x)) / s390_class_max_nregs (FP_REGS, GET_MODE (x))) > 8)) - fprintf (file, "%%v%s", reg_names[REGNO (x) + (code == 'V')] + 2); + fprintf (file, "%%v%s", reg_names[REGNO (x)] + 2); else fprintf (file, "%s", reg_names[REGNO (x)]); break; diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 57bf4a86d32c..2e1229f5f411 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -243,6 +243,8 @@ UNSPEC_VEC_ELTSWAP + UNSPEC_TF_TO_FPRX2 + UNSPEC_NNPA_VCLFNHS_V8HI UNSPEC_NNPA_VCLFNLS_V8HI UNSPEC_NNPA_VCRNFS_V8HI diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index f88e8b655fa8..8cf39e0cd4b6 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s3
[gcc r15-3924] libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809]
https://gcc.gnu.org/g:dd5b823ce238161156e7a4b6267bd30d7dde7c6b commit r15-3924-gdd5b823ce238161156e7a4b6267bd30d7dde7c6b Author: Mark Mentovai Date: Tue Sep 24 16:11:14 2024 -0400 libgcc, Darwin: Don't build legacy libgcc_s.1 on macOS 14 [PR116809] d9cafa0c4f0a stopped building libgcc_s.1 on macOS >= 15, in part because that is required to bootstrap the compiler using the macOS 15 SDK. The macOS 15 SDK ships in Xcode 16, which also runs on macOS 14. libgcc_s.1 can no longer be built on macOS 14 using Xcode 16 by the same logic that the previous change disabled it for macOS 15. PR target/116809 libgcc/ChangeLog: * config.host: Don't build legacy libgcc_s.1 on macOS 14. Signed-off-by: Mark Mentovai Diff: --- libgcc/config.host | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgcc/config.host b/libgcc/config.host index 00bd6384c0f9..fa001c5e900b 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -239,7 +239,7 @@ case ${host} in esac tmake_file="$tmake_file t-slibgcc-darwin" case ${host} in -x86_64-*-darwin2[0-3]*) +x86_64-*-darwin2[0-2]*) tmake_file="t-darwin-min-11 t-darwin-libgccs1 $tmake_file" ;; *-*-darwin2*)
[gcc r15-3929] diagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847]
https://gcc.gnu.org/g:64072e60b1599ae7d347c2cdee46c3b0e37fc338 commit r15-3929-g64072e60b1599ae7d347c2cdee46c3b0e37fc338 Author: Jakub Jelinek Date: Fri Sep 27 16:07:40 2024 +0200 diagnostic: Save/restore diagnostic context history and push/pop state for PCH [PR116847] The following patch on top of the just posted cleanup patch saves/restores the m_classification_history and m_push_list vectors for PCH. Without that as the testcase shows during parsing of the templates we don't report ignored diagnostics, but after loading PCH header when instantiating those templates those warnings can be emitted. This doesn't show up on x86_64-linux build because configure injects there -fcf-protection -mshstk flags during library build (and so also during PCH header creation), but make check doesn't use those flags and so the PCH header is ignored. 2024-09-26 Jakub Jelinek PR libstdc++/116847 gcc/ * diagnostic.h (diagnostic_option_classifier): Add pch_save and pch_restore method declarations. (diagnostic_context): Add pch_save and pch_restore inline method definitions. * diagnostic.cc (diagnostic_option_classifier::pch_save): New method. (diagnostic_option_classifier::pch_restore): Likewise. gcc/c-family/ * c-pch.cc: Include diagnostic.h. (c_common_write_pch): Call global_dc->pch_save. (c_common_read_pch): Call global_dc->pch_restore. gcc/testsuite/ * g++.dg/pch/pr116847.C: New test. * g++.dg/pch/pr116847.Hs: New test. Diff: --- gcc/c-family/c-pch.cc| 8 +++- gcc/diagnostic.cc| 40 gcc/diagnostic.h | 15 ++ gcc/testsuite/g++.dg/pch/pr116847.C | 10 + gcc/testsuite/g++.dg/pch/pr116847.Hs | 8 5 files changed, 80 insertions(+), 1 deletion(-) diff --git a/gcc/c-family/c-pch.cc b/gcc/c-family/c-pch.cc index 9bcfdc804215..f104575d3d08 100644 --- a/gcc/c-family/c-pch.cc +++ b/gcc/c-family/c-pch.cc @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see #include "c-pragma.h" #include "langhooks.h" #include "hosthooks.h" +#include "diagnostic.h" /* This is a list of flag variables that must match exactly, and their names for the error message. The possible values for *flag_var must @@ -178,7 +179,8 @@ c_common_write_pch (void) cpp_write_pch_state (parse_in, pch_outfile); timevar_pop (TV_PCH_CPP_SAVE); - if (fseek (pch_outfile, 0, SEEK_SET) != 0 + if (global_dc->pch_save (pch_outfile) < 0 + || fseek (pch_outfile, 0, SEEK_SET) != 0 || fwrite (get_ident (), IDENT_LENGTH, 1, pch_outfile) != 1) fatal_error (input_location, "cannot write %s: %m", pch_file); @@ -359,6 +361,10 @@ c_common_read_pch (cpp_reader *pfile, const char *name, linemap_line_start (line_table, saved_loc.line, 0); timevar_pop (TV_PCH_CPP_RESTORE); + + if (global_dc->pch_restore (f) < 0) +fatal_error (input_location, "cannot read %s: %m", name); + fclose (f); if (cpp_result != 0) diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index ffe61f73d196..9462fe67a063 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -156,6 +156,46 @@ diagnostic_option_classifier::fini () m_push_list.release (); } +/* Save the diagnostic_option_classifier state to F for PCH + output. Returns 0 on success, -1 on error. */ + +int +diagnostic_option_classifier::pch_save (FILE *f) +{ + unsigned int lengths[2] = { m_classification_history.length (), + m_push_list.length () }; + if (fwrite (lengths, sizeof (lengths), 1, f) != 1 + || fwrite (m_classification_history.address (), +sizeof (diagnostic_classification_change_t), +lengths[0], f) != lengths[0] + || fwrite (m_push_list.address (), sizeof (int), +lengths[1], f) != lengths[1]) +return -1; + return 0; +} + +/* Read the diagnostic_option_classifier state from F for PCH + read. Returns 0 on success, -1 on error. */ + +int +diagnostic_option_classifier::pch_restore (FILE *f) +{ + unsigned int lengths[2]; + if (fread (lengths, sizeof (lengths), 1, f) != 1) +return -1; + gcc_checking_assert (m_classification_history.is_empty ()); + gcc_checking_assert (m_push_list.is_empty ()); + m_classification_history.safe_grow (lengths[0]); + m_push_list.safe_grow (lengths[1]); + if (fread (m_classification_history.address (), +sizeof (diagnostic_classification_change_t), +lengths[0], f) != lengths[0] + || fread (m_push_list.address (), sizeof (int), + lengths[1], f) != lengths[1]) +return -1; + return 0; +} + /* Save all diagnostic classifications in a stack. */ void diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index c3300fc96340..3087b19f9ea9 100644 -
[gcc r15-3921] c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502]
https://gcc.gnu.org/g:05e4f07cad1eacf869c10622cae2a9cdee3b6a7a commit r15-3921-g05e4f07cad1eacf869c10622cae2a9cdee3b6a7a Author: Arsen Arsenović Date: Wed Aug 28 21:59:18 2024 +0200 c++/coro: prevent ICV_STATEMENT diagnostics in temp promotion [PR116502] If such a diagnostic is necessary, it has already been emitted, otherwise, it is not correct and emitting it here is inactionable by the user, and bogus. PR c++/116502 gcc/cp/ChangeLog: * coroutines.cc (maybe_promote_temps): Convert temporary initializers to void without complaining. gcc/testsuite/ChangeLog: * g++.dg/coroutines/maybe-unused-1.C: New test. * g++.dg/coroutines/pr116502.C: New test. Diff: --- gcc/cp/coroutines.cc | 12 ++--- gcc/testsuite/g++.dg/coroutines/maybe-unused-1.C | 33 gcc/testsuite/g++.dg/coroutines/pr116502.C | 33 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 4c7ea1dd3216..50904e0d004e 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -3203,7 +3203,13 @@ maybe_promote_temps (tree *stmt, void *d) to run the initializer. If the initializer is a conditional expression, we need to collect and declare any promoted variables nested within it. DTORs for such -variables must be run conditionally too. */ +variables must be run conditionally too. + +Since here we're synthetically processing code here, we've already +emitted any Wunused-result warnings. Below, however, we call +finish_expr_stmt, which will convert its operand to void, and could +result in such a diagnostic being emitted. To avoid that, convert to +void ahead of time. */ if (t->var) { tree var = t->var; @@ -3213,7 +3219,7 @@ maybe_promote_temps (tree *stmt, void *d) if (TREE_CODE (t->init) == COND_EXPR) process_conditional (t, vlist); else - finish_expr_stmt (t->init); + finish_expr_stmt (convert_to_void (t->init, ICV_STATEMENT, tf_none)); if (tree cleanup = cxx_maybe_build_cleanup (var, tf_warning_or_error)) { tree cl = build_stmt (sloc, CLEANUP_STMT, expr_list, cleanup, var); @@ -3232,7 +3238,7 @@ maybe_promote_temps (tree *stmt, void *d) if (TREE_CODE (t->init) == COND_EXPR) process_conditional (t, vlist); else - finish_expr_stmt (t->init); + finish_expr_stmt (convert_to_void (t->init, ICV_STATEMENT, tf_none)); if (expr_list) { if (TREE_CODE (expr_list) != STATEMENT_LIST) diff --git a/gcc/testsuite/g++.dg/coroutines/maybe-unused-1.C b/gcc/testsuite/g++.dg/coroutines/maybe-unused-1.C new file mode 100644 index ..68d59d83e8eb --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/maybe-unused-1.C @@ -0,0 +1,33 @@ +// https://gcc.gnu.org/PR116502 +#include + +struct SuspendNever { + bool await_ready() noexcept; + void await_suspend(std::coroutine_handle<>) noexcept; + void await_resume() noexcept; +}; + +struct Coroutine; + +struct PromiseType { + Coroutine get_return_object(); + SuspendNever initial_suspend(); + SuspendNever final_suspend() noexcept; + void return_void(); + void unhandled_exception(); +}; + +struct Coroutine { + using promise_type = PromiseType; +}; + +struct Awaiter { + bool await_ready(); + void await_suspend(std::coroutine_handle<>); + [[nodiscard]] int& await_resume(); +}; + +Coroutine foo() +{ + co_await Awaiter {}; // { dg-warning "Wunused-result" } +} diff --git a/gcc/testsuite/g++.dg/coroutines/pr116502.C b/gcc/testsuite/g++.dg/coroutines/pr116502.C new file mode 100644 index ..95cc0bc8a983 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr116502.C @@ -0,0 +1,33 @@ +// https://gcc.gnu.org/PR116502 +#include + +struct SuspendNever { + bool await_ready() noexcept; + void await_suspend(std::coroutine_handle<>) noexcept; + void await_resume() noexcept; +}; + +struct Coroutine; + +struct PromiseType { + Coroutine get_return_object(); + SuspendNever initial_suspend(); + SuspendNever final_suspend() noexcept; + void return_void(); + void unhandled_exception(); +}; + +struct Coroutine { + using promise_type = PromiseType; +}; + +struct Awaiter { + bool await_ready(); + void await_suspend(std::coroutine_handle<>); + [[nodiscard]] int& await_resume(); +}; + +Coroutine foo() +{ + (void)co_await Awaiter {}; +}
[gcc r15-3923] c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793]
https://gcc.gnu.org/g:d888a8a8dcf391197ae82e2bbf99507effc27950 commit r15-3923-gd888a8a8dcf391197ae82e2bbf99507effc27950 Author: Arsen Arsenović Date: Tue Sep 24 18:16:01 2024 +0200 c++/coro: ignore cleanup_point_exprs while expanding awaits [PR116793] If we reach a CLEANUP_POINT_EXPR while trying to walk statements, we actually care about the statement or statement list contained within it. Indeed, such a construction started happening with r15-3513-g964577c31df206, after temporary promotion. In the test case presented in PR116793, the compiler generated:T002_2_3]; int T002 [value-expr: frame_ptr->T002_2_3]; <) >; struct _cleanup_task Aw0 [value-expr: frame_ptr->Aw0_2_3]; <) >; < Aw0 {_cleanup_task::await_ready (&Aw0), _cleanup_task::await_suspend<_task1::promise_type> (&Aw0, TARGET_EXPR ), <<< Unknown tree: aggr_init_expr 4 await_resume D.22443 &Aw0 >>>} 0 >>>) >; <; } D.22467 = 1; int & i [value-expr: frame_ptr->i_1_2]; < (NON_LVALUE_EXPR )) >;>>; ... i.e. a statement list within a cleanup point. In such a case, we don't actually care about the cleanup point, but we do care about the statement inside, so, we can just walk down into the CLEANUP_POINT_EXPR. PR c++/116793 gcc/cp/ChangeLog: * coroutines.cc (await_statement_expander): Just process subtrees if encountering a CLEANUP_POINT_EXPR. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr116793-1.C: New test. Diff: --- gcc/cp/coroutines.cc | 4 +++- gcc/testsuite/g++.dg/coroutines/pr116793-1.C | 26 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 8e4c55a800e4..86a5ac8999ac 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2063,7 +2063,9 @@ await_statement_expander (tree *stmt, int *do_subtree, void *d) tree res = NULL_TREE; /* Process a statement at a time. */ - if (STATEMENT_CLASS_P (*stmt) || TREE_CODE (*stmt) == BIND_EXPR) + if (STATEMENT_CLASS_P (*stmt) + || TREE_CODE (*stmt) == BIND_EXPR + || TREE_CODE (*stmt) == CLEANUP_POINT_EXPR) return NULL_TREE; /* Just process the sub-trees. */ else if (TREE_CODE (*stmt) == STATEMENT_LIST) { diff --git a/gcc/testsuite/g++.dg/coroutines/pr116793-1.C b/gcc/testsuite/g++.dg/coroutines/pr116793-1.C new file mode 100644 index ..ed2bdd26996a --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr116793-1.C @@ -0,0 +1,26 @@ +// https://gcc.gnu.org/PR116793 +#include +#include +struct _cleanup_task { + bool await_ready() const noexcept; + template + bool await_suspend(std::coroutine_handle parent) noexcept; + std::tuple await_resume() noexcept; +}; +struct _task1 { + struct promise_type final { +std::suspend_always initial_suspend() noexcept; +_task1 get_return_object() noexcept; +void unhandled_exception() noexcept; +struct awaiter final { + bool await_ready() noexcept; + void await_resume() noexcept; + void await_suspend(std::coroutine_handle h) noexcept; +}; +awaiter final_suspend() noexcept; + }; +}; +_cleanup_task func(int &&); +_task1 g() { + auto &&[i] = co_await func(3); +}
[gcc r15-3918] RISC-V/libgcc: Save/Restore routines for E goes with ABI.
https://gcc.gnu.org/g:bb01c9d6d280d7ffbaa8f09c36ae57908a4f6883 commit r15-3918-gbb01c9d6d280d7ffbaa8f09c36ae57908a4f6883 Author: Jim Lin Date: Fri Sep 27 14:44:12 2024 +0800 RISC-V/libgcc: Save/Restore routines for E goes with ABI. That Save/Restore routines for E can be used for RVI with ILP32E ABI. libgcc/ChangeLog: * config/riscv/save-restore.S: Check with __riscv_abi_rve rather than __riscv_32e. Diff: --- libgcc/config/riscv/save-restore.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgcc/config/riscv/save-restore.S b/libgcc/config/riscv/save-restore.S index 9bf42d111bc6..8a4391e1a978 100644 --- a/libgcc/config/riscv/save-restore.S +++ b/libgcc/config/riscv/save-restore.S @@ -295,7 +295,7 @@ FUNC_END (__riscv_restore_0) #else -#ifdef __riscv_32e +#ifdef __riscv_abi_rve FUNC_BEGIN(__riscv_save_2) FUNC_BEGIN(__riscv_save_1) FUNC_BEGIN(__riscv_save_0) @@ -529,6 +529,6 @@ FUNC_END (__riscv_restore_2) FUNC_END (__riscv_restore_1) FUNC_END (__riscv_restore_0) -#endif /* __riscv_32e */ +#endif /* __riscv_abi_rve */ #endif /* __riscv_xlen == 64 */
[gcc r15-3926] Widening-Mul: Fix one ICE when iterate on phi node
https://gcc.gnu.org/g:cd430b1fd95dce5868ce6a8063119d253ea2f995 commit r15-3926-gcd430b1fd95dce5868ce6a8063119d253ea2f995 Author: Pan Li Date: Fri Sep 27 11:03:51 2024 +0800 Widening-Mul: Fix one ICE when iterate on phi node We iterate all phi node of bb to try to match the SAT_* pattern for scalar integer. We also remove the phi mode when the relevant pattern matched. Unfortunately the iterator may have no idea the phi node is removed and continue leverage the free data and then ICE similar as below. [0] psi ptr 0x75216340c000 [0] psi ptr 0x75216340c400 [1] psi ptr 0xa5a5a5a5a5a5a5a5 <=== GC freed pointer. during GIMPLE pass: widening_mul tmp.c: In function ‘f’: tmp.c:45:6: internal compiler error: Segmentation fault 45 | void f(int rows, int cols) { | ^ 0x36e2788 internal_error(char const*, ...) ../../gcc/diagnostic-global-context.cc:517 0x18005f0 crash_signal ../../gcc/toplev.cc:321 0x752163c4531f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x103ae0e bool is_a_helper::test(gimple*) ../../gcc/gimple.h:1256 0x103f9a5 bool is_a(gimple*) ../../gcc/is-a.h:232 0x103dc78 gphi* as_a(gimple*) ../../gcc/is-a.h:255 0x104f12e gphi_iterator::phi() const ../../gcc/gimple-iterator.h:47 0x1a57bef after_dom_children ../../gcc/tree-ssa-math-opts.cc:6140 0x3344482 dom_walker::walk(basic_block_def*) ../../gcc/domwalk.cc:354 0x1a58601 execute ../../gcc/tree-ssa-math-opts.cc:6312 This patch would like to fix the iterate on modified collection problem by backup the next phi in advance. The below test suites are passed for this patch. * The rv64gcv fully regression test. * The x86 bootstrap test. * The x86 fully regression test. PR middle-end/116861 gcc/ChangeLog: * tree-ssa-math-opts.cc (math_opts_dom_walker::after_dom_children): Backup the next psi iterator before remove the phi node. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr116861-1.c: New test. Signed-off-by: Pan Li Diff: --- gcc/testsuite/gcc.dg/torture/pr116861-1.c | 76 +++ gcc/tree-ssa-math-opts.cc | 9 +++- 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr116861-1.c b/gcc/testsuite/gcc.dg/torture/pr116861-1.c new file mode 100644 index ..7dcfe664d89d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr116861-1.c @@ -0,0 +1,76 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void pm_message(void); +struct CmdlineInfo { + _Bool wantCrop[4]; + unsigned int margin; +}; +typedef struct { + unsigned int removeSize; +} CropOp; +typedef struct { + CropOp op[4]; +} CropSet; +static void divideAllBackgroundIntoBorders(unsigned int const totalSz, + _Bool const wantCropSideA, + _Bool const wantCropSideB, + unsigned int const wantMargin, + unsigned int *const sideASzP, + unsigned int *const sideBSzP) { + unsigned int sideASz, sideBSz; + if (wantCropSideA && wantCropSideB) + { +sideASz = totalSz / 2; +if (wantMargin) + sideBSz = totalSz - sideASz; + } + else if (wantCropSideB) + { +sideBSz = 0; + } + *sideASzP = sideASz; + *sideBSzP = sideBSz; +} +static CropOp oneSideCrop(_Bool const wantCrop, unsigned int const borderSz, + unsigned int const margin) { + CropOp retval; + if (wantCrop) + { +if (borderSz >= margin) + retval.removeSize = borderSz - margin; +else + retval.removeSize = 0; + } + return retval; +} +struct CmdlineInfo cmdline1; +void f(int rows, int cols) { + struct CmdlineInfo cmdline0 = cmdline1; + CropSet crop; + struct CmdlineInfo cmdline = cmdline0; + CropSet retval; + unsigned int leftBorderSz, rghtBorderSz; + unsigned int topBorderSz, botBorderSz; + divideAllBackgroundIntoBorders(cols, cmdline.wantCrop[0], + cmdline.wantCrop[1], cmdline.margin > 0, + &leftBorderSz, &rghtBorderSz); + divideAllBackgroundIntoBorders(rows, cmdline.wantCrop[2], + cmdline.wantCrop[3], cmdline.margin > 0, + &topBorderSz, &botBorderSz); + retval.op[0] = + oneSideCrop(cmdline.wantCrop[0], leftBorderSz, cmdline.margin); + retval.op[1] = + oneSideCrop(cmdline.wantCrop[1], rghtBorderSz, cmdline.margin); + retval.op[2] = + oneSideCrop(cmdline.wantCrop[2], topBorderSz, cmdline.margin); + retval.op[3] = + oneSideCrop(cmdline.wantCrop[3], botBorderSz, cmdline.mar
[gcc r15-3927] i386: Modernize AMD processor types
https://gcc.gnu.org/g:a72108920805a024b6bbee5acdd32914382c47a1 commit r15-3927-ga72108920805a024b6bbee5acdd32914382c47a1 Author: Uros Bizjak Date: Fri Sep 27 15:58:17 2024 +0200 i386: Modernize AMD processor types Use iterative PTA definitions for members of the same AMD processor family. Also, fix a couple of related M_CPU_TYPE/M_CPU_SUBTYPE inconsistencies. No functional changes intended. gcc/ChangeLog: * config/i386/i386.h: Add PTA_BDVER1, PTA_BDVER2, PTA_BDVER3, PTA_BDVER4, PTA_BTVER1 and PTA_BTVER2. * common/config/i386/i386-common.cc (processor_alias_table) <"bdver1">: Use PTA_BDVER1. <"bdver2">: Use PTA_BDVER2. <"bdver3">: Use PTA_BDVER3. <"bdver4">: Use PTA_BDVER4. <"btver1">: Use PTA_BTVER1. Use M_CPU_TYPE (AMD_BTVER1). <"btver2">: Use PTA_BTVER2. <"shanghai>: Use M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI). <"istanbul>: Use M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL). Diff: --- gcc/common/config/i386/i386-common.cc | 46 +-- gcc/config/i386/i386.h| 32 +++- 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc index fb744319b05e..3f2fc599009a 100644 --- a/gcc/common/config/i386/i386-common.cc +++ b/gcc/common/config/i386/i386-common.cc @@ -2348,34 +2348,16 @@ const pta processor_alias_table[] = | PTA_SSE3 | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_PRFCHW | PTA_FXSR, M_CPU_SUBTYPE (AMDFAM10H_BARCELONA), P_PROC_DYNAMIC}, {"bdver1", PROCESSOR_BDVER1, CPU_BDVER1, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4 - | PTA_XOP | PTA_LWP | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE, -M_CPU_TYPE (AMDFAM15H_BDVER1), P_PROC_XOP}, +PTA_BDVER1, +M_CPU_SUBTYPE (AMDFAM15H_BDVER1), P_PROC_XOP}, {"bdver2", PROCESSOR_BDVER2, CPU_BDVER2, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4 - | PTA_XOP | PTA_LWP | PTA_BMI | PTA_TBM | PTA_F16C - | PTA_FMA | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE, -M_CPU_TYPE (AMDFAM15H_BDVER2), P_PROC_FMA}, +PTA_BDVER2, +M_CPU_SUBTYPE (AMDFAM15H_BDVER2), P_PROC_FMA}, {"bdver3", PROCESSOR_BDVER3, CPU_BDVER3, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_FMA4 - | PTA_XOP | PTA_LWP | PTA_BMI | PTA_TBM | PTA_F16C - | PTA_FMA | PTA_PRFCHW | PTA_FXSR | PTA_XSAVE - | PTA_XSAVEOPT | PTA_FSGSBASE, +PTA_BDVER3, M_CPU_SUBTYPE (AMDFAM15H_BDVER3), P_PROC_FMA}, {"bdver4", PROCESSOR_BDVER4, CPU_BDVER4, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSE4A | PTA_CX16 | PTA_ABM | PTA_SSSE3 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX | PTA_AVX2 - | PTA_FMA4 | PTA_XOP | PTA_LWP | PTA_BMI | PTA_BMI2 - | PTA_TBM | PTA_F16C | PTA_FMA | PTA_PRFCHW | PTA_FXSR - | PTA_XSAVE | PTA_XSAVEOPT | PTA_FSGSBASE | PTA_RDRND - | PTA_MOVBE | PTA_MWAITX, +PTA_BDVER4, M_CPU_SUBTYPE (AMDFAM15H_BDVER4), P_PROC_AVX2}, {"znver1", PROCESSOR_ZNVER1, CPU_ZNVER1, PTA_ZNVER1, @@ -2393,16 +2375,10 @@ const pta processor_alias_table[] = PTA_ZNVER5, M_CPU_SUBTYPE (AMDFAM1AH_ZNVER5), P_PROC_AVX512F}, {"btver1", PROCESSOR_BTVER1, CPU_GENERIC, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_PRFCHW - | PTA_FXSR | PTA_XSAVE, - M_CPU_SUBTYPE (AMDFAM15H_BDVER1), P_PROC_SSE4_A}, +PTA_BTVER1, +M_CPU_TYPE (AMD_BTVER1), P_PROC_SSE4_A}, {"btver2", PROCESSOR_BTVER2, CPU_BTVER2, -PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3 - | PTA_SSSE3 | PTA_SSE4A | PTA_ABM | PTA_CX16 | PTA_SSE4_1 - | PTA_SSE4_2 | PTA_AES | PTA_PCLMUL | PTA_AVX - | PTA_BMI | PTA_F16C | PTA_MOVBE | PTA_PRFCHW - | PTA_FXSR | PTA_XSAVE | PTA_XSAVEOPT, +PTA_BTVER2, M_CPU_TYPE (AMD_BTVER2), P_PROC_BMI}, {"generic", PROCESSOR_GENERIC, CPU_GENERIC, @@ -2421,9 +2397,9 @@ const pta processor_alias_table[] = {"amdfam19h", PROCESSOR_GENERIC, CPU_GENERIC, 0, M_CPU_TYPE (AMDFAM19H), P_NONE}, {"shanghai", PROCESSOR_GENERIC, CPU_GENERIC, 0, -M_CPU_TYPE (AMDFAM10H_SHANGHAI), P_NONE}, +M_CPU_SUBTYPE (AMDFAM10H_SHANGHAI), P_NONE}, {"istanbul", PROCESSOR_GENERIC, CPU_GENERIC, 0, -M_CPU_TYPE (AMDFAM10H_ISTANBUL), P_NONE}, +M_CPU_SUBTYPE (AMDFAM10H_ISTANBUL), P_NONE}, }; /* NB: processor_alias_table stops at the "generic" entry. */ diff --git a/gcc/config/i386/i
[gcc r15-3928] diagnostic: Use vec instead of custom array reallocations for m_classification_history/m_push_list [
https://gcc.gnu.org/g:ddc72ba6c6c2c84a1a95340840bd5fde1f2bde44 commit r15-3928-gddc72ba6c6c2c84a1a95340840bd5fde1f2bde44 Author: Jakub Jelinek Date: Fri Sep 27 16:06:29 2024 +0200 diagnostic: Use vec instead of custom array reallocations for m_classification_history/m_push_list [PR116847] diagnostic.h already relies on vec.h, it uses auto_vec in one spot. The following patch converts m_classification_history and m_push_list hand-managed arrays to vec templates. The main advantage is exponential rather than linear reallocation, e.g. with current libstdc++ headers if one includes all the standard headers there could be ~ 300 reallocations of the m_classification_history array (sure, not all of them will result in actually copying the data, but still). In addition to that it fixes some formatting issues in the code. 2024-09-26 Jakub Jelinek PR libstdc++/116847 * diagnostic.h (diagnostic_option_classifier): Change type of m_classification_history from diagnostic_classification_change_t * to vec. Change type of m_push_list from int * to vec. Remove m_n_classification_history and m_n_push members. * diagnostic.cc (diagnostic_option_classifier::init): Set m_push_list to vNULL rather than nullptr. Don't initialize m_n_push. Initialize m_classification_history to vNULL. (diagnostic_option_classifier::fini): Call release () method on m_push_list instead of free on it. Call release () on m_classification_history. Don't clear m_n_push. (diagnostic_option_classifier::push): Adjust for m_push_list and m_classification_history being vectors rather than custom allocated arrays with counter. (diagnostic_option_classifier::pop): Likewise. (classify_diagnostic): Adjust for m_classification_history being vector rather than custom allocated array with counter. (update_effective_level_from_pragmas): Likewise. Diff: --- gcc/diagnostic.cc | 68 +++ gcc/diagnostic.h | 8 ++- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 152eb9d35a8e..ffe61f73d196 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -143,8 +143,8 @@ diagnostic_option_classifier::init (int n_opts) m_classify_diagnostic = XNEWVEC (diagnostic_t, n_opts); for (int i = 0; i < n_opts; i++) m_classify_diagnostic[i] = DK_UNSPECIFIED; - m_push_list = nullptr; - m_n_push = 0; + m_push_list = vNULL; + m_classification_history = vNULL; } void @@ -152,8 +152,8 @@ diagnostic_option_classifier::fini () { XDELETEVEC (m_classify_diagnostic); m_classify_diagnostic = nullptr; - free (m_push_list); - m_n_push = 0; + m_classification_history.release (); + m_push_list.release (); } /* Save all diagnostic classifications in a stack. */ @@ -161,8 +161,7 @@ diagnostic_option_classifier::fini () void diagnostic_option_classifier::push () { - m_push_list = (int *) xrealloc (m_push_list, (m_n_push + 1) * sizeof (int)); - m_push_list[m_n_push ++] = m_n_classification_history; + m_push_list.safe_push (m_classification_history.length ()); } /* Restore the topmost classification set off the stack. If the stack @@ -173,19 +172,13 @@ diagnostic_option_classifier::pop (location_t where) { int jump_to; - if (m_n_push) -jump_to = m_push_list [-- m_n_push]; + if (!m_push_list.is_empty ()) +jump_to = m_push_list.pop (); else jump_to = 0; - const int i = m_n_classification_history; - m_classification_history = -(diagnostic_classification_change_t *) xrealloc (m_classification_history, (i + 1) -* sizeof (diagnostic_classification_change_t)); - m_classification_history[i].location = where; - m_classification_history[i].option = jump_to; - m_classification_history[i].kind = DK_POP; - m_n_classification_history ++; + diagnostic_classification_change_t v = { where, jump_to, DK_POP }; + m_classification_history.safe_push (v); } /* Initialize the diagnostic message outputting machinery. */ @@ -880,31 +873,27 @@ classify_diagnostic (const diagnostic_context *context, the pragmas were. */ if (where != UNKNOWN_LOCATION) { - int i; + unsigned i; /* Record the command-line status, so we can reset it back on DK_POP. */ if (old_kind == DK_UNSPECIFIED) { - old_kind = !context->option_enabled_p (option_id) - ? DK_IGNORED : DK_ANY; + old_kind = (!context->option_enabled_p (option_id) + ? DK_IGNORED : DK_ANY); m_classify_diagnostic[option_id.m_idx] = old_kind; } - for (i = m_n_classification_history - 1; i >= 0; i --) - if (m_c
[gcc r15-3934] libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite
https://gcc.gnu.org/g:7040c207baa6b5d5f6065a47dd3559f3d3974a1b commit r15-3934-g7040c207baa6b5d5f6065a47dd3559f3d3974a1b Author: Jonathan Wakely Date: Fri Sep 27 15:51:56 2024 +0100 libstdc++: Fix -Wsign-compare warning in std::string::resize_for_overwrite libstdc++-v3/ChangeLog: * include/bits/basic_string.tcc (resize_for_overwrite): Fix -Wsign-compare warning. * include/bits/cow_string.h (resize_for_overwrite): Likewise. Diff: --- libstdc++-v3/include/bits/basic_string.tcc | 2 +- libstdc++-v3/include/bits/cow_string.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 2c17d258bfe4..caeddaf2f5be 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -611,7 +611,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(__gnu_cxx::__is_integer_nonstrict::__value, "resize_and_overwrite operation must return an integer"); #endif - _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n); + _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n); __term._M_r = size_type(__r); if (__term._M_r > __n) __builtin_unreachable(); diff --git a/libstdc++-v3/include/bits/cow_string.h b/libstdc++-v3/include/bits/cow_string.h index b78aa74fbfaf..087ddf81dd86 100644 --- a/libstdc++-v3/include/bits/cow_string.h +++ b/libstdc++-v3/include/bits/cow_string.h @@ -3800,7 +3800,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_assert(__gnu_cxx::__is_integer_nonstrict::__value, "resize_and_overwrite operation must return an integer"); #endif - _GLIBCXX_DEBUG_ASSERT(__r >= 0 && __r <= __n); + _GLIBCXX_DEBUG_ASSERT(__r >= 0 && size_type(__r) <= __n); __term._M_r = size_type(__r); if (__term._M_r > __n) __builtin_unreachable();
[gcc r15-3933] c++: ICE with structured bindings and m-d array [PR102594]
https://gcc.gnu.org/g:96e0370f4daef29b918aafcff68c7f5e4ef397fd commit r15-3933-g96e0370f4daef29b918aafcff68c7f5e4ef397fd Author: Marek Polacek Date: Thu Sep 5 16:45:32 2024 -0400 c++: ICE with structured bindings and m-d array [PR102594] We ICE in decay_conversion with this test: struct S { S() {} }; S arr[1][1]; auto [m](arr3); But not when the last line is: auto [n] = arr3; Therefore the difference is between copy- and direct-init. In particular, in build_vec_init we have: if (direct_init) from = build_tree_list (NULL_TREE, from); and then we call build_vec_init again with init==from. Then decay_conversion gets the TREE_LIST and it crashes. build_aggr_init has: /* Wrap the initializer in a CONSTRUCTOR so that build_vec_init recognizes it as direct-initialization. */ init = build_constructor_single (init_list_type_node, NULL_TREE, init); CONSTRUCTOR_IS_DIRECT_INIT (init) = true; so I propose to do the same in build_vec_init. PR c++/102594 gcc/cp/ChangeLog: * init.cc (build_vec_init): Build up a CONSTRUCTOR to signal direct-initialization rather than a TREE_LIST. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/decomp61.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/cp/init.cc| 8 +++- gcc/testsuite/g++.dg/cpp1z/decomp61.C | 28 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index be7fdb40dd6c..f785015e4774 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4958,7 +4958,13 @@ build_vec_init (tree base, tree maxindex, tree init, if (xvalue) from = move (from); if (direct_init) - from = build_tree_list (NULL_TREE, from); + { + /* Wrap the initializer in a CONSTRUCTOR so that +build_vec_init recognizes it as direct-initialization. */ + from = build_constructor_single (init_list_type_node, + NULL_TREE, from); + CONSTRUCTOR_IS_DIRECT_INIT (from) = true; + } } else from = NULL_TREE; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp61.C b/gcc/testsuite/g++.dg/cpp1z/decomp61.C new file mode 100644 index ..ad0a20c1addd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp61.C @@ -0,0 +1,28 @@ +// PR c++/102594 +// { dg-do compile { target c++17 } } + +struct S { + S() {} +}; +S arr1[2]; +S arr2[2][1]; +S arr3[1][1]; +auto [m](arr3); +auto [n] = arr3; + +struct X { + int i; +}; + +void +g (X x) +{ + auto [a, b](arr2); + auto [c, d] = arr2; + auto [e, f] = (arr2); + auto [i, j](arr1); + auto [k, l] = arr1; + auto [m, n] = (arr1); + auto [z] = x; + auto [y](x); +}
[gcc r15-3915] Fix bogus SLP nvector compute in check_load_store_for_partial_vectors
https://gcc.gnu.org/g:3db9e99165968af8479468cd373990da2f116e3b commit r15-3915-g3db9e99165968af8479468cd373990da2f116e3b Author: Richard Biener Date: Tue Sep 24 10:42:01 2024 +0200 Fix bogus SLP nvector compute in check_load_store_for_partial_vectors We have a new overload for vect_get_num_copies that handles both SLP and non-SLP. Use it and avoid the division by group_size for SLP when not using load-store lanes. * tree-vect-stmts.cc (check_load_store_for_partial_vectors): Use the new vect_get_num_copies overload. Only divide by group_size for SLP for load-store lanes. Diff: --- gcc/tree-vect-stmts.cc | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 1b351c5c66ec..a8031b4f6f5e 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -1507,19 +1507,15 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype, if (memory_access_type == VMAT_INVARIANT) return; - unsigned int nvectors; - if (slp_node) -/* ??? Incorrect for multi-lane lanes. */ -nvectors = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) / group_size; - else -nvectors = vect_get_num_copies (loop_vinfo, vectype); - + unsigned int nvectors = vect_get_num_copies (loop_vinfo, slp_node, vectype); vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo); vec_loop_lens *lens = &LOOP_VINFO_LENS (loop_vinfo); machine_mode vecmode = TYPE_MODE (vectype); bool is_load = (vls_type == VLS_LOAD); if (memory_access_type == VMAT_LOAD_STORE_LANES) { + if (slp_node) + nvectors /= group_size; internal_fn ifn = (is_load ? vect_load_lanes_supported (vectype, group_size, true) : vect_store_lanes_supported (vectype, group_size, true));
[gcc r15-3916] tree-optimization/116818 - try VMAT_GATHER_SCATTER also for SLP
https://gcc.gnu.org/g:b1c7095a1da11d2543222d98243d10f9cc9823ce commit r15-3916-gb1c7095a1da11d2543222d98243d10f9cc9823ce Author: Richard Biener Date: Mon Sep 23 15:24:01 2024 +0200 tree-optimization/116818 - try VMAT_GATHER_SCATTER also for SLP When not doing SLP and we end up with VMAT_ELEMENTWISE we consider using strided loads, aka VMAT_GATHER_SCATTER. The following moves this logic down to also apply to SLP where we now can end up using VMAT_ELEMENTWISE as well. PR tree-optimization/116818 * tree-vect-stmts.cc (get_group_load_store_type): Consider VMAT_GATHER_SCATTER instead of VMAT_ELEMENTWISE also for SLP. (vectorizable_load): For single-lane VMAT_GATHER_SCATTER also ignore permutations. Diff: --- gcc/tree-vect-stmts.cc | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index a8031b4f6f5e..0e75e3b49567 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2260,21 +2260,21 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, } } } +} - /* As a last resort, trying using a gather load or scatter store. + /* As a last resort, trying using a gather load or scatter store. -??? Although the code can handle all group sizes correctly, -it probably isn't a win to use separate strided accesses based -on nearby locations. Or, even if it's a win over scalar code, -it might not be a win over vectorizing at a lower VF, if that -allows us to use contiguous accesses. */ - if (*memory_access_type == VMAT_ELEMENTWISE - && single_element_p - && loop_vinfo - && vect_use_strided_gather_scatters_p (stmt_info, loop_vinfo, -masked_p, gs_info)) - *memory_access_type = VMAT_GATHER_SCATTER; -} + ??? Although the code can handle all group sizes correctly, + it probably isn't a win to use separate strided accesses based + on nearby locations. Or, even if it's a win over scalar code, + it might not be a win over vectorizing at a lower VF, if that + allows us to use contiguous accesses. */ + if (*memory_access_type == VMAT_ELEMENTWISE + && single_element_p + && loop_vinfo + && vect_use_strided_gather_scatters_p (stmt_info, loop_vinfo, +masked_p, gs_info)) +*memory_access_type = VMAT_GATHER_SCATTER; if (*memory_access_type == VMAT_GATHER_SCATTER || *memory_access_type == VMAT_ELEMENTWISE) @@ -10063,7 +10063,8 @@ vectorizable_load (vec_info *vinfo, get_group_load_store_type. */ if (slp && SLP_TREE_LOAD_PERMUTATION (slp_node).exists () - && !(memory_access_type == VMAT_ELEMENTWISE + && !((memory_access_type == VMAT_ELEMENTWISE + || memory_access_type == VMAT_GATHER_SCATTER) && SLP_TREE_LANES (slp_node) == 1)) { slp_perm = true;
[gcc r15-3914] unswitch: Replace manual ondemand maybe_undef with ssa_name_maybe_undef_p/mark_ssa_maybe_undefs [PR1
https://gcc.gnu.org/g:9c04112fdc221b0a337f88572dfef4caaca78349 commit r15-3914-g9c04112fdc221b0a337f88572dfef4caaca78349 Author: Andrew Pinski Date: Thu Sep 26 05:55:58 2024 + unswitch: Replace manual ondemand maybe_undef with ssa_name_maybe_undef_p/mark_ssa_maybe_undefs [PR116848] The ondemand maybe_undef that follows phis was added in r7-6427-g8b670f93ab1136 but then later ssa_name_maybe_undef_p/mark_ssa_maybe_undefs was added in r13-972-gbe2861fe8c527a. This moves the ondemand one to use mark_ssa_maybe_undefs/ssa_name_maybe_undef_p instead. Which itself will be faster since the mark_ssa_maybe_undefs is a walk based on the uses of undefined names (and only once) rather than a walk based on the def of ones which are more likely defined (and on demand). Even though the ondemand maybe_undef had some extra special cases, those won't make a big difference in most code. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/116848 gcc/ChangeLog: * tree-ssa-loop-unswitch.cc (tree_ssa_unswitch_loops): Call mark_ssa_maybe_undefs. (is_maybe_undefined): Call ssa_name_maybe_undef_p instead of ondemand undef. Signed-off-by: Andrew Pinski Diff: --- gcc/tree-ssa-loop-unswitch.cc | 61 ++- 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc index 7601d91e8070..847f7ac739f7 100644 --- a/gcc/tree-ssa-loop-unswitch.cc +++ b/gcc/tree-ssa-loop-unswitch.cc @@ -329,6 +329,7 @@ tree_ssa_unswitch_loops (function *fun) bool changed_unswitch = false; bool changed_hoist = false; auto_edge_flag ignored_edge_flag (fun); + mark_ssa_maybe_undefs (); ranger = enable_ranger (fun); @@ -427,65 +428,7 @@ is_maybe_undefined (const tree name, gimple *stmt, class loop *loop) if (gimple_bb (stmt) == loop->header) return false; - auto_bitmap visited_ssa; - auto_vec worklist; - worklist.safe_push (name); - bitmap_set_bit (visited_ssa, SSA_NAME_VERSION (name)); - while (!worklist.is_empty ()) -{ - tree t = worklist.pop (); - - /* If it's obviously undefined, avoid further computations. */ - if (ssa_undefined_value_p (t, true)) - return true; - - if (ssa_defined_default_def_p (t)) - continue; - - gimple *def = SSA_NAME_DEF_STMT (t); - - /* Check that all the PHI args are fully defined. */ - if (gphi *phi = dyn_cast (def)) - { - for (unsigned i = 0; i < gimple_phi_num_args (phi); ++i) - { - tree t = gimple_phi_arg_def (phi, i); - /* If an SSA has already been seen, it may be a loop, -but we can continue and ignore this use. Otherwise, -add the SSA_NAME to the queue and visit it later. */ - if (TREE_CODE (t) == SSA_NAME - && bitmap_set_bit (visited_ssa, SSA_NAME_VERSION (t))) - worklist.safe_push (t); - } - continue; - } - - /* Uses in stmts always executed when the region header executes -are fine. */ - if (dominated_by_p (CDI_DOMINATORS, loop->header, gimple_bb (def))) - continue; - - /* Handle calls and memory loads conservatively. */ - if (!is_gimple_assign (def) - || (gimple_assign_single_p (def) - && gimple_vuse (def))) - return true; - - /* Check that any SSA names used to define NAME are also fully -defined. */ - use_operand_p use_p; - ssa_op_iter iter; - FOR_EACH_SSA_USE_OPERAND (use_p, def, iter, SSA_OP_USE) - { - tree t = USE_FROM_PTR (use_p); - /* If an SSA has already been seen, it may be a loop, -but we can continue and ignore this use. Otherwise, -add the SSA_NAME to the queue and visit it later. */ - if (bitmap_set_bit (visited_ssa, SSA_NAME_VERSION (t))) - worklist.safe_push (t); - } -} - return false; + return ssa_name_maybe_undef_p (name); } /* Checks whether we can unswitch LOOP on condition at end of BB -- one of its
[gcc r12-10729] s390: Fix TF to FPRX2 conversion [PR115860]
https://gcc.gnu.org/g:7051fa5fa4eaa24785a64072490c1e0c65039915 commit r12-10729-g7051fa5fa4eaa24785a64072490c1e0c65039915 Author: Stefan Schulze Frielinghaus Date: Fri Sep 27 12:45:42 2024 +0200 s390: Fix TF to FPRX2 conversion [PR115860] Currently subregs originating from *tf_to_fprx2_0 and *tf_to_fprx2_1 survive register allocation. This in turn leads to wrong register renaming. Keeping the current approach would mean we need two insns for *tf_to_fprx2_0 and *tf_to_fprx2_1, respectively. Something along the lines (define_insn "*tf_to_fprx2_0" [(set (subreg:DF (match_operand:FPRX2 0 "nonimmediate_operand" "=f") 0) (unspec:DF [(match_operand:TF 1 "general_operand" "v")] UNSPEC_TF_TO_FPRX2_0))] "TARGET_VXE" "#") (define_insn "*tf_to_fprx2_0" [(set (match_operand:DF 0 "nonimmediate_operand" "=f") (unspec:DF [(match_operand:TF 1 "general_operand" "v")] UNSPEC_TF_TO_FPRX2_0))] "TARGET_VXE" "vpdi\t%v0,%v1,%v0,1 [(set_attr "op_type" "VRR")]) and similar for *tf_to_fprx2_1. Note, pre register allocation operand 0 has mode FPRX2 and afterwards DF once subregs have been eliminated. Since we always copy a whole vector register into a floating-point register pair, another way to fix this is to merge *tf_to_fprx2_0 and *tf_to_fprx2_1 into a single insn which means we don't have to use subregs at all. The downside of this is that the assembler template contains two instructions, now. The upside is that we don't have to come up with some artificial insn before RA which might be more readable/maintainable. That is implemented by this patch. In commit r11-4872-ge627cda5686592, the output operand specifier %V was introduced which is used in tf_to_fprx2 only, now. Instead of coming up with its counterpart %F for floating-point registers, which would also only be used in tf_to_fprx2, I print the operands directly. This renders %V unused which is why it is removed by this patch. gcc/ChangeLog: PR target/115860 * config/s390/s390.cc (print_operand): Remove operand specifier %V. * config/s390/s390.md (UNSPEC_TF_TO_FPRX2): New. * config/s390/vector.md (*tf_to_fprx2_0): Remove. (*tf_to_fprx2_1): Remove. (tf_to_fprx2): New. gcc/testsuite/ChangeLog: * gcc.target/s390/vector/long-double-asm-abi.c: Adapt scan-assembler directive. * gcc.target/s390/vector/long-double-to-i64.c: Adapt scan-assembler directive. * gcc.target/s390/pr115860-1.c: New test. (cherry picked from commit 46c2538435dfc50dd5c67c4e03ce387d1f6ebe9b) Diff: --- gcc/config/s390/s390.cc| 5 +- gcc/config/s390/s390.md| 2 + gcc/config/s390/vector.md | 75 -- gcc/testsuite/gcc.target/s390/pr115860-1.c | 26 .../gcc.target/s390/vector/long-double-asm-abi.c | 2 +- .../gcc.target/s390/vector/long-double-to-i64.c| 2 - 6 files changed, 72 insertions(+), 40 deletions(-) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 2be3a873b891..a8f804ffe4f7 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -8028,7 +8028,6 @@ print_operand_address (FILE *file, rtx addr) CONST_VECTOR: Generate a bitmask for vgbm instruction. 'x': print integer X as if it's an unsigned halfword. 'v': print register number as vector register (v1 instead of f1). -'V': print the second word of a TFmode operand as vector register. */ void @@ -8221,13 +8220,13 @@ print_operand (FILE *file, rtx x, int code) case REG: /* Print FP regs as fx instead of vx when they are accessed through non-vector mode. */ - if ((code == 'v' || code == 'V') + if (code == 'v' || VECTOR_NOFP_REG_P (x) || (FP_REG_P (x) && VECTOR_MODE_P (GET_MODE (x))) || (VECTOR_REG_P (x) && (GET_MODE_SIZE (GET_MODE (x)) / s390_class_max_nregs (FP_REGS, GET_MODE (x))) > 8)) - fprintf (file, "%%v%s", reg_names[REGNO (x) + (code == 'V')] + 2); + fprintf (file, "%%v%s", reg_names[REGNO (x)] + 2); else fprintf (file, "%s", reg_names[REGNO (x)]); break; diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 2fc799695377..335aff9884e2 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -244,6 +244,8 @@ UNSPEC_VEC_ELTSWAP + UNSPEC_TF_TO_FPRX2 + UNSPEC_NNPA_VCLFNHS_V8HI UNSPEC_NNPA_VCLFNLS_V8HI UNSPEC_NNPA_VCRNFS_V8HI diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md index 75912280c23d..ac3816a6f5c6 100644 --- a/gcc/config/s390/vector.md +++ b/gcc/config/s
[gcc r12-10728] s390: Fix AQ and AR constraints
https://gcc.gnu.org/g:8d29e1c4ceaea4d3ceec6b51de5b7c31a6bc5f85 commit r12-10728-g8d29e1c4ceaea4d3ceec6b51de5b7c31a6bc5f85 Author: Stefan Schulze Frielinghaus Date: Fri Sep 27 12:45:42 2024 +0200 s390: Fix AQ and AR constraints Ensure for AQ and AR constraints that the resulting displacement after adding any positive offset less than the size of the object being referenced is still valid. gcc/ChangeLog: * config/s390/s390.cc (s390_mem_constraint): Check displacement for AQ and AR constraints. (cherry picked from commit 1a71ff3b89aadc7fa0af0bca269d74bb23c1a957) Diff: --- gcc/config/s390/s390.cc | 12 1 file changed, 12 insertions(+) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index b66fc5be8719..2be3a873b891 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -3405,6 +3405,18 @@ s390_mem_constraint (const char *str, rtx op) if ((reload_completed || reload_in_progress) ? !offsettable_memref_p (op) : !offsettable_nonstrict_memref_p (op)) return 0; + /* offsettable_memref_p ensures only that any positive offset added to +the address forms a valid general address. For AQ and AR constraints +we also have to verify that the resulting displacement after adding +any positive offset less than the size of the object being referenced +is still valid. */ + if (str[1] == 'Q' || str[1] == 'R') + { + int o = GET_MODE_SIZE (GET_MODE (op)) - 1; + rtx tmp = adjust_address (op, QImode, o); + if (!s390_check_qrst_address (str[1], XEXP (tmp, 0), true)) + return 0; + } return s390_check_qrst_address (str[1], XEXP (op, 0), true); case 'B': /* Check for non-literal-pool variants of memory constraints. */
[gcc r15-3920] [MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port
https://gcc.gnu.org/g:037c97e114341143af35f4df3ff49e12afacf105 commit r15-3920-g037c97e114341143af35f4df3ff49e12afacf105 Author: Christophe Lyon Date: Fri Sep 27 10:37:01 2024 +0200 [MAINTAINERS]: Add myself as MVE Reviewer for the AArch32 (arm) port ChangeLog: * MAINTAINERS: Add myself as MVE Reviewer for the AArch32 (arm) port. Diff: --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 47b5915e9f8f..ded5b3d4f643 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -272,6 +272,7 @@ check in changes outside of the parts of the compiler they maintain. Reviewers +arm port (MVE) Christophe Lyon callgraph Martin Jambor C front end Marek Polacek CTF, BTFIndu Bhagat
[gcc r13-9057] s390: Fix AQ and AR constraints
https://gcc.gnu.org/g:14f0fbfb0a4518d507b4038e0757346567024934 commit r13-9057-g14f0fbfb0a4518d507b4038e0757346567024934 Author: Stefan Schulze Frielinghaus Date: Fri Sep 27 08:18:47 2024 +0200 s390: Fix AQ and AR constraints Ensure for AQ and AR constraints that the resulting displacement after adding any positive offset less than the size of the object being referenced is still valid. gcc/ChangeLog: * config/s390/s390.cc (s390_mem_constraint): Check displacement for AQ and AR constraints. (cherry picked from commit 1a71ff3b89aadc7fa0af0bca269d74bb23c1a957) Diff: --- gcc/config/s390/s390.cc | 12 1 file changed, 12 insertions(+) diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 2a451c5ac5d1..26456ba3cc12 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -3453,6 +3453,18 @@ s390_mem_constraint (const char *str, rtx op) if ((reload_completed || reload_in_progress) ? !offsettable_memref_p (op) : !offsettable_nonstrict_memref_p (op)) return 0; + /* offsettable_memref_p ensures only that any positive offset added to +the address forms a valid general address. For AQ and AR constraints +we also have to verify that the resulting displacement after adding +any positive offset less than the size of the object being referenced +is still valid. */ + if (str[1] == 'Q' || str[1] == 'R') + { + int o = GET_MODE_SIZE (GET_MODE (op)) - 1; + rtx tmp = adjust_address (op, QImode, o); + if (!s390_check_qrst_address (str[1], XEXP (tmp, 0), true)) + return 0; + } return s390_check_qrst_address (str[1], XEXP (op, 0), true); case 'B': /* Check for non-literal-pool variants of memory constraints. */
[gcc r15-3917] libgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items
https://gcc.gnu.org/g:6b7eaec20b046eebc771022e460c2206580aef04 commit r15-3917-g6b7eaec20b046eebc771022e460c2206580aef04 Author: Tobias Burnus Date: Fri Sep 27 10:48:09 2024 +0200 libgomp.texi: fix formatting; add post-TR13 OpenMP impl. status items libgomp/ * libgomp.texi (OpenMP Technical Report 13): Change @emph to @code; add two post-TR13 OpenMP 6.0 items. Diff: --- libgomp/libgomp.texi | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 22eff1d7b557..b561cb5f3f48 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -476,6 +476,7 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. specifiers @tab Y @tab @item Support for pure directives in Fortran's @code{do concurrent} @tab N @tab @item All inarguable clauses take now an optional Boolean argument @tab N @tab +@item The @code{adjust_args} clause was extended to specify the argument by position @item For Fortran, @emph{locator list} can be also function reference with data pointer result @tab N @tab @item Concept of @emph{assumed-size arrays} in C and C++ @@ -496,7 +497,7 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. clauses @tab P @tab @code{private} not supported @item For Fortran, rejecting polymorphic types in data-mapping clauses @tab N @tab not diagnosed (and mostly unsupported) -@item New @code{taskgraph} construct including @emph{saved} modifier and +@item New @code{taskgraph} construct including @code{saved} modifier and @code{replayable} clause @tab N @tab @item @code{default} clause on the @code{target} directive @tab N @tab @item Ref-count change for @code{use_device_ptr} and @code{use_device_addr} @@ -509,6 +510,10 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. @item New @code{init_complete} clause to the @code{scan} directive @tab N @tab @item @code{ref} modifier to the @code{map} clause @tab N @tab +@item New @code{storage} map-type modifier; context-dependent @code{alloc} and + @code{release} are aliases. Update to map decay @tab N @tab +@item Update of the map-type decay for mapping and @code{declare_mapper} + @tab N @tab @item Change of the @emph{map-type} property from @emph{ultimate} to @emph{default} @tab N @tab @item @code{self} modifier to @code{map} and @code{self} as @@ -516,7 +521,6 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. @item Mapping of @emph{assumed-size arrays} in C, C++ and Fortran @tab N @tab @item @code{delete} as delete-modifier not as map type @tab N @tab -@item @code{release} map-type modifier in @code{declare_mapper} @tab N @tab @item For Fortran, the @code{automap} modifier to the @code{enter} clause of @code{declare_target} @tab N @tab @item @code{groupprivate} directive @tab N @tab
[gcc r15-3919] libgomp.texi: Remove now duplicate TR13 item
https://gcc.gnu.org/g:cfdc0a384aff5e06f80d3f55f4615abf350b193b commit r15-3919-gcfdc0a384aff5e06f80d3f55f4615abf350b193b Author: Tobias Burnus Date: Fri Sep 27 12:06:17 2024 +0200 libgomp.texi: Remove now duplicate TR13 item Remove an item under "Other new TR 13 features" that since the last commit (r15-3917-g6b7eaec20b046e) to this file is is covered by the added "New @code{storage} map-type modifier; context-dependent @code{alloc} and @code{release} are aliases" "Update of the map-type decay for mapping and @code{declare_mapper}" libgomp/ * libgomp.texi (TR13 status): Update semi-duplicated, semi-obsoleted item; remove left-over half-sentence. Diff: --- libgomp/libgomp.texi | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index b561cb5f3f48..c6464ece32e3 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -511,7 +511,7 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. @tab N @tab @item @code{ref} modifier to the @code{map} clause @tab N @tab @item New @code{storage} map-type modifier; context-dependent @code{alloc} and - @code{release} are aliases. Update to map decay @tab N @tab + @code{release} are aliases @tab N @tab @item Update of the map-type decay for mapping and @code{declare_mapper} @tab N @tab @item Change of the @emph{map-type} property from @emph{ultimate} to @@ -633,8 +633,6 @@ Technical Report (TR) 13 is the third preview for OpenMP 6.0. @item Multi-word directive names are now permitted with underscore @tab N @tab @item In Fortran (fixed + free), space between directive names is mandatory @tab N @tab -@item @code{map(release: ...)} on @code{target} and @code{target_data} (map-type - decay changes) @tab N @tab post-TR13 item @end multitable
[gcc r15-3930] aarch64: fix build failure on aarch64-none-elf
https://gcc.gnu.org/g:0ff49a5c1d39382c57d614a29510559068947376 commit r15-3930-g0ff49a5c1d39382c57d614a29510559068947376 Author: Matthieu Longo Date: Thu Sep 26 18:14:23 2024 +0100 aarch64: fix build failure on aarch64-none-elf A previous patch ([1]) introduced a build regression on aarch64-none-elf target. The changes were primarilly tested on aarch64-unknown-linux-gnu, so the issue was missed during development. The includes are slighly different between the two targets, and due to some include rules ([2]), "aarch64-unwind-def.h" was not found. [1]: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=bdf41d627c13bc5f0dc676991f4513daa9d9ae36 [2]: https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html > include "file" > ... It searches for a file named file first in the directory > containing the current file, ... libgcc/ChangeLog: * config/aarch64/aarch64-unwind.h: Fix header path. Diff: --- libgcc/config/aarch64/aarch64-unwind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgcc/config/aarch64/aarch64-unwind.h b/libgcc/config/aarch64/aarch64-unwind.h index 2b774eb263cf..4d36f0b26f70 100644 --- a/libgcc/config/aarch64/aarch64-unwind.h +++ b/libgcc/config/aarch64/aarch64-unwind.h @@ -25,7 +25,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if !defined (AARCH64_UNWIND_H) && !defined (__ILP32__) #define AARCH64_UNWIND_H -#include "aarch64-unwind-def.h" +#include "config/aarch64/aarch64-unwind-def.h" #include "ansidecl.h" #include
[gcc r15-3931] libstdc++: Fix test FAIL due to -Wpointer-arith
https://gcc.gnu.org/g:500046d178bc78a8f18d529c62f7b45c8ad2c861 commit r15-3931-g500046d178bc78a8f18d529c62f7b45c8ad2c861 Author: Jonathan Wakely Date: Thu Sep 26 23:38:41 2024 +0100 libstdc++: Fix test FAIL due to -Wpointer-arith This fixes a FAIL due to a -Wpointer-arith warning when testing with c++11 or c++14 dialects. As an extension our std::atomic supports pointer arithmetic in C++11 and C++14, but due to the system header changes there is now a warning about it. The warning seems reasonable, so rather than suppress it we should make the test expect it. While looking into this I decided to simplify some of the code related to atomic arithmetic. libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_base::_M_type_size): Replace overloaded functions with static _S_type_size. * include/std/atomic (atomic): Use is_object_v instead of is_object. * testsuite/29_atomics/atomic/operators/pointer_partial_void.cc: Add dg-warning for -Wpointer-arith warning. Diff: --- libstdc++-v3/include/bits/atomic_base.h| 33 ++ libstdc++-v3/include/std/atomic| 32 ++--- .../atomic/operators/pointer_partial_void.cc | 1 + 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 7093d0fc8226..72cc4bae6cf1 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -687,12 +687,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __pointer_type _M_p _GLIBCXX20_INIT(nullptr); - // Factored out to facilitate explicit specialization. - constexpr ptrdiff_t - _M_type_size(ptrdiff_t __d) const { return __d * sizeof(_PTp); } - - constexpr ptrdiff_t - _M_type_size(ptrdiff_t __d) const volatile { return __d * sizeof(_PTp); } + static constexpr ptrdiff_t + _S_type_size(ptrdiff_t __d) + { return __d * sizeof(_PTp); } public: __atomic_base() noexcept = default; @@ -742,42 +739,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __pointer_type operator++() noexcept - { return __atomic_add_fetch(&_M_p, _M_type_size(1), + { return __atomic_add_fetch(&_M_p, _S_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator++() volatile noexcept - { return __atomic_add_fetch(&_M_p, _M_type_size(1), + { return __atomic_add_fetch(&_M_p, _S_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator--() noexcept - { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + { return __atomic_sub_fetch(&_M_p, _S_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator--() volatile noexcept - { return __atomic_sub_fetch(&_M_p, _M_type_size(1), + { return __atomic_sub_fetch(&_M_p, _S_type_size(1), int(memory_order_seq_cst)); } __pointer_type operator+=(ptrdiff_t __d) noexcept - { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + { return __atomic_add_fetch(&_M_p, _S_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator+=(ptrdiff_t __d) volatile noexcept - { return __atomic_add_fetch(&_M_p, _M_type_size(__d), + { return __atomic_add_fetch(&_M_p, _S_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator-=(ptrdiff_t __d) noexcept - { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + { return __atomic_sub_fetch(&_M_p, _S_type_size(__d), int(memory_order_seq_cst)); } __pointer_type operator-=(ptrdiff_t __d) volatile noexcept - { return __atomic_sub_fetch(&_M_p, _M_type_size(__d), + { return __atomic_sub_fetch(&_M_p, _S_type_size(__d), int(memory_order_seq_cst)); } bool @@ -932,22 +929,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_ALWAYS_INLINE __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept - { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + { return __atomic_fetch_add(&_M_p, _S_type_size(__d), int(__m)); } _GLIBCXX_ALWAYS_INLINE __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) volatile noexcept - { return __atomic_fetch_add(&_M_p, _M_type_size(__d), int(__m)); } + { return __atomic_fetch_add(&_M_p, _S_type_size(__d), int(__m)); } _GLIBCXX_ALWAYS_INLINE __pointer_type fetch_sub(ptrdiff_t __d, memory_order __m = memory_order_seq
[gcc r15-3932] libstdc++: Fix test FAILs due to -Wreturn-local-addr
https://gcc.gnu.org/g:c580b8a2b59208efc687e2b706e3a40225167854 commit r15-3932-gc580b8a2b59208efc687e2b706e3a40225167854 Author: Jonathan Wakely Date: Thu Sep 26 23:43:20 2024 +0100 libstdc++: Fix test FAILs due to -Wreturn-local-addr This fixes two FAILs due to -Wpointer-arith warnings when testing with c++11 or c++14 dialects. libstdc++-v3/ChangeLog: * testsuite/20_util/bind/dangling_ref.cc: Add an additional dg-warning for -Wreturn-local-addr warning. * testsuite/30_threads/packaged_task/cons/dangling_ref.cc: Likewise. Diff: --- libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc | 1 + libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc index 70393e4392f8..17e7b21c45cb 100644 --- a/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc +++ b/libstdc++-v3/testsuite/20_util/bind/dangling_ref.cc @@ -5,5 +5,6 @@ int f(); auto b = std::bind(f); int i = b(); // { dg-error "here" "" { target { c++14_down } } } // { dg-error "dangling reference" "" { target { c++14_down } } 0 } +// { dg-error "reference to temporary" "" { target { c++14_down } } 0 } // { dg-error "no matching function" "" { target c++17 } 0 } // { dg-error "enable_if" "" { target c++17 } 0 } diff --git a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc index e9edb5edc8be..225b65fe6a7d 100644 --- a/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc +++ b/libstdc++-v3/testsuite/30_threads/packaged_task/cons/dangling_ref.cc @@ -7,5 +7,6 @@ int f(); std::packaged_task task(f); // { dg-error "dangling reference" "" { target { c++14_down } } 0 } +// { dg-error "reference to temporary" "" { target { c++14_down } } 0 } // { dg-error "no matching function" "" { target c++17 } 0 } // { dg-error "enable_if" "" { target c++17 } 0 }
[gcc r15-3925] Fix sorting in Contributors.html
https://gcc.gnu.org/g:9085cc2a34f1c851e16c497bd9b0e4fd38b08142 commit r15-3925-g9085cc2a34f1c851e16c497bd9b0e4fd38b08142 Author: Richard Biener Date: Fri Sep 27 14:54:07 2024 +0200 Fix sorting in Contributors.html The following moves my entry to where it belongs alphabetically (it wasn't moved when s/Guenther/Biener/). * doc/contrib.texi (Richard Biener): Move entry. Diff: --- gcc/doc/contrib.texi | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/doc/contrib.texi b/gcc/doc/contrib.texi index 7714d52823b1..0e2823f278ae 100644 --- a/gcc/doc/contrib.texi +++ b/gcc/doc/contrib.texi @@ -63,6 +63,10 @@ improved alias analysis, plus migrating GCC to Bugzilla. @item Geoff Berry for his Java object serialization work and various patches. +@item +Richard Biener for his ongoing middle-end contributions and bug fixes +and for release management. + @item David Binderman for testing GCC trunk against Fedora Rawhide and csmith. @@ -364,10 +368,6 @@ Stu Grossman for gdb hacking, allowing GCJ developers to debug Java code. @item Michael K. Gschwind contributed the port to the PDP-11. -@item -Richard Biener for his ongoing middle-end contributions and bug fixes -and for release management. - @item Ron Guilmette implemented the @command{protoize} and @command{unprotoize} tools, the support for DWARF 1 symbolic debugging information, and much of
[gcc r15-3936] libstdc++: Fix more pedwarns in headers for C++98
https://gcc.gnu.org/g:68854071236d3a1064b46a5b22546956d3be32cd commit r15-3936-g68854071236d3a1064b46a5b22546956d3be32cd Author: Jonathan Wakely Date: Fri Sep 27 21:01:46 2024 +0100 libstdc++: Fix more pedwarns in headers for C++98 Some tests e.g. 17_intro/headers/c++1998/all_pedantic_errors.cc FAIL with GLIBCXX_TESTSUITE_STDS=98 due to numerous C++11 extensions still in use in the library headers. The recent changes to not make them system headers means we get warnings now. This change adds more diagnostic pragmas to suppress those warnings. libstdc++-v3/ChangeLog: * include/bits/istream.tcc: Add diagnostic pragmas around uses of long long and extern template. * include/bits/locale_facets.h: Likewise. * include/bits/locale_facets.tcc: Likewise. * include/bits/locale_facets_nonio.tcc: Likewise. * include/bits/ostream.tcc: Likewise. * include/bits/stl_algobase.h: Likewise. * include/c_global/cstdlib: Likewise. * include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp: Likewise. * include/ext/pointer.h: Likewise. * include/ext/stdio_sync_filebuf.h: Likewise. * include/std/istream: Likewise. * include/std/ostream: Likewise. * include/tr1/cmath: Likewise. * include/tr1/type_traits: Likewise. * include/tr1/functional_hash.h: Likewise. Remove semi-colons at namespace scope that aren't needed after macro expansion. * include/tr1/tuple: Remove semi-colon at namespace scope. * include/bits/vector.tcc: Change LL suffix to just L. Diff: --- libstdc++-v3/include/bits/istream.tcc | 10 +++ libstdc++-v3/include/bits/locale_facets.h | 12 libstdc++-v3/include/bits/locale_facets.tcc| 6 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 4 +++ libstdc++-v3/include/bits/ostream.tcc | 6 libstdc++-v3/include/bits/stl_algobase.h | 10 +++ libstdc++-v3/include/bits/vector.tcc | 2 +- libstdc++-v3/include/c_global/cstdlib | 3 ++ .../resize_policy/hash_prime_size_policy_imp.hpp | 3 ++ libstdc++-v3/include/ext/pointer.h | 3 ++ libstdc++-v3/include/ext/stdio_sync_filebuf.h | 3 ++ libstdc++-v3/include/std/istream | 3 ++ libstdc++-v3/include/std/ostream | 3 ++ libstdc++-v3/include/tr1/cmath | 4 +++ libstdc++-v3/include/tr1/functional_hash.h | 32 +- libstdc++-v3/include/tr1/tuple | 2 +- libstdc++-v3/include/tr1/type_traits | 6 17 files changed, 97 insertions(+), 15 deletions(-) diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index e8957fd2c3bf..f96d2d4a3536 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -397,7 +397,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __streambuf_type* __this_sb = this->rdbuf(); int_type __c = __this_sb->sgetc(); char_type __c2 = traits_type::to_char_type(__c); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlong-long" unsigned long long __gcount = 0; +#pragma GCC diagnostic pop while (!traits_type::eq_int_type(__c, __eof) && !traits_type::eq_int_type(__c, __idelim) @@ -1122,6 +1125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. #if _GLIBCXX_EXTERN_TEMPLATE +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++11-extensions" // extern template +#pragma GCC diagnostic ignored "-Wlong-long" extern template class basic_istream; extern template istream& ws(istream&); extern template istream& operator>>(istream&, char&); @@ -1134,8 +1140,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION extern template istream& istream::_M_extract(unsigned long&); extern template istream& istream::_M_extract(bool&); #ifdef _GLIBCXX_USE_LONG_LONG +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wlong-long" extern template istream& istream::_M_extract(long long&); extern template istream& istream::_M_extract(unsigned long long&); +#pragma GCC diagnostic pop #endif extern template istream& istream::_M_extract(float&); extern template istream& istream::_M_extract(double&); @@ -1166,6 +1175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION extern template class basic_iostream; #endif +#pragma GCC diagnostic pop #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index afa239ad96a7..0daffc86de28 100644 --- a/libstdc+
[gcc r15-3935] libstdc++: Refactor experimental::filesystem::path string conversions
https://gcc.gnu.org/g:16491e137c47ad36f9d73f070978841f1e8ca95d commit r15-3935-g16491e137c47ad36f9d73f070978841f1e8ca95d Author: Jonathan Wakely Date: Fri Sep 27 15:53:04 2024 +0100 libstdc++: Refactor experimental::filesystem::path string conversions I noticed a -Wc++17-extensions warning due to use of if-constexpr in std::experimental::filesystem::path, which was not protected by diagnostic pragmas to disable the warning. While adding the pragmas I noticed that other places in the same file use tag dispatching and multiple overloads instead of if-constexpr. Since we're already using it in that file, we might as well just use it everywhere. libstdc++-v3/ChangeLog: * include/experimental/bits/fs_path.h (path::_Cvt): Refactor to use if-constexpr. (path::string(const Allocator&)): Likewise. Diff: --- libstdc++-v3/include/experimental/bits/fs_path.h | 137 +-- 1 file changed, 53 insertions(+), 84 deletions(-) diff --git a/libstdc++-v3/include/experimental/bits/fs_path.h b/libstdc++-v3/include/experimental/bits/fs_path.h index 5008e26af8db..a504aa2492cc 100644 --- a/libstdc++-v3/include/experimental/bits/fs_path.h +++ b/libstdc++-v3/include/experimental/bits/fs_path.h @@ -775,60 +775,38 @@ namespace __detail __codecvt_utf8_to_wchar, __codecvt_utf8_to_utfNN>; -#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS -#ifdef _GLIBCXX_USE_CHAR8_T - static string_type - _S_wconvert(const char8_t* __f, const char8_t* __l, const char8_t*) - { - const char* __f2 = (const char*)__f; - const char* __l2 = (const char*)__l; - std::wstring __wstr; - std::codecvt_utf8_utf16 __wcvt; - if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) - return __wstr; - } -#endif +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr static string_type - _S_wconvert(const char* __f, const char* __l, const char*) - { - std::codecvt_utf8_utf16 __cvt; - std::wstring __wstr; - if (__str_codecvt_in_all(__f, __l, __wstr, __cvt)) - return __wstr; - _GLIBCXX_THROW_OR_ABORT(filesystem_error( - "Cannot convert character sequence", - std::make_error_code(errc::illegal_byte_sequence))); - } - - static string_type - _S_wconvert(const _CharT* __f, const _CharT* __l, const void*) + _S_convert(const _CharT* __f, const _CharT* __l) { - __codecvt_utf8_to_wide __cvt; - std::string __str; - if (__str_codecvt_out_all(__f, __l, __str, __cvt)) +#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS + if constexpr (is_same<_CharT, char>::value) { - const char* __f2 = __str.data(); - const char* __l2 = __f2 + __str.size(); - std::codecvt_utf8_utf16 __wcvt; + std::codecvt_utf8_utf16 __cvt; std::wstring __wstr; - if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) + // Convert char (assumed to be UTF-8) to wchar_t (UTF-16). + if (__str_codecvt_in_all(__f, __l, __wstr, __cvt)) return __wstr; } +#ifdef _GLIBCXX_USE_CHAR8_T + else if constexpr (is_same<_CharT, char8_t>::value) + return _S_convert((const char*)__f, (const char*)__l); +#endif + else + { + // Convert from _CharT to char first: + __codecvt_utf8_to_utfNN __cvt; + std::string __str; + if (__str_codecvt_out_all(__f, __l, __str, __cvt)) + // Then convert char to wchar_t: + return _S_convert(__str.c_str(), __str.c_str() + __str.size()); + } _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); - } - - static string_type - _S_convert(const _CharT* __f, const _CharT* __l) - { - return _S_wconvert(__f, __l, (const _CharT*)nullptr); - } -#else - static string_type - _S_convert(const _CharT* __f, const _CharT* __l) - { +#else // ! WINDOWS #ifdef _GLIBCXX_USE_CHAR8_T if constexpr (is_same<_CharT, char8_t>::value) return string_type(__f, __l); @@ -843,8 +821,9 @@ namespace __detail "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } +#endif // ! WINDOWS } -#endif +#pragma GCC diagnostic pop static string_type _S_convert(_CharT* __f, _CharT* __l) @@ -1038,66 +1017,55 @@ namespace __detail std::swap(_M_type, __rhs._M_type); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr template inline std::basic_string<_CharT, _Traits, _Allocator> path::string(const _Allocator& __a) const { -
[gcc r15-3941] doc: Remove i?86-*-linux* installation note from 2003
https://gcc.gnu.org/g:2531f014fb2364777fb1ce09641db85bda5883b7 commit r15-3941-g2531f014fb2364777fb1ce09641db85bda5883b7 Author: Gerald Pfeifer Date: Sat Sep 28 09:20:31 2024 +0800 doc: Remove i?86-*-linux* installation note from 2003 gcc: PR target/69374 * doc/install.texi (Specific) : Remove note from 2003. Diff: --- gcc/doc/install.texi | 3 --- 1 file changed, 3 deletions(-) diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 08de972c8ec7..517d1cbb2fb2 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -4274,9 +4274,6 @@ libstdc++-v3 documentation. @end html @anchor{ix86-x-linux} @heading i?86-*-linux* -As of GCC 3.3, binutils 2.13.1 or later is required for this platform. -See @uref{https://gcc.gnu.org/PR10877,,bug 10877} for more information. - If you receive Signal 11 errors when building on GNU/Linux, then it is possible you have a hardware problem. Further information on this can be found on @uref{https://www.bitwizard.nl/sig11/,,www.bitwizard.nl}.
[gcc r15-3938] c++: Don't strip USING_DECLs when updating local bindings [PR116748]
https://gcc.gnu.org/g:b9ac51a843f9dc807b00ab7f49f64968807a4ee8 commit r15-3938-gb9ac51a843f9dc807b00ab7f49f64968807a4ee8 Author: Nathaniel Shead Date: Fri Sep 20 00:05:04 2024 +1000 c++: Don't strip USING_DECLs when updating local bindings [PR116748] Currently update_binding strips USING_DECLs too eagerly, leading to ICEs in pop_local_decl as it can't find the decl it's popping in the binding list. Let's rather try to keep the original USING_DECL around. This also means that using59.C can point to the location of the using-decl rather than the underlying object directly; this is in the direction required to fix PR c++/106851 (though more work is needed to emit properly helpful diagnostics here). PR c++/116748 gcc/cp/ChangeLog: * name-lookup.cc (update_binding): Maintain USING_DECLs in the binding slots. gcc/testsuite/ChangeLog: * g++.dg/lookup/using59.C: Update location. * g++.dg/lookup/using69.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/name-lookup.cc | 12 +++- gcc/testsuite/g++.dg/lookup/using59.C | 4 ++-- gcc/testsuite/g++.dg/lookup/using69.C | 10 ++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index eb365b259d92..a2f94e0f363e 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -3005,6 +3005,8 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, if (old == error_mark_node) old = NULL_TREE; + + tree old_bval = old; old = strip_using_decl (old); if (DECL_IMPLICIT_TYPEDEF_P (decl)) @@ -3021,7 +3023,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, gcc_checking_assert (!to_type); hide_type = hiding; to_type = decl; - to_val = old; + to_val = old_bval; } else hide_value = hiding; @@ -3034,7 +3036,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, /* OLD is an implicit typedef. Move it to to_type. */ gcc_checking_assert (!to_type); - to_type = old; + to_type = old_bval; hide_type = hide_value; old = NULL_TREE; hide_value = false; @@ -3093,7 +3095,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, { if (same_type_p (TREE_TYPE (old), TREE_TYPE (decl))) /* Two type decls to the same type. Do nothing. */ - return old; + return old_bval; else goto conflict; } @@ -3106,7 +3108,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, /* The new one must be an alias at this point. */ gcc_assert (DECL_NAMESPACE_ALIAS (decl)); - return old; + return old_bval; } else if (TREE_CODE (old) == VAR_DECL) { @@ -3121,7 +3123,7 @@ update_binding (cp_binding_level *level, cxx_binding *binding, tree *slot, else { conflict: - diagnose_name_conflict (decl, old); + diagnose_name_conflict (decl, old_bval); to_val = NULL_TREE; } } diff --git a/gcc/testsuite/g++.dg/lookup/using59.C b/gcc/testsuite/g++.dg/lookup/using59.C index 3c3a73c28d59..b7ec325d2348 100644 --- a/gcc/testsuite/g++.dg/lookup/using59.C +++ b/gcc/testsuite/g++.dg/lookup/using59.C @@ -1,10 +1,10 @@ namespace Y { - extern int I; // { dg-message "previous declaration" } + extern int I; } -using Y::I; +using Y::I; // { dg-message "previous declaration" } extern int I; // { dg-error "conflicts with a previous" } extern int J; diff --git a/gcc/testsuite/g++.dg/lookup/using69.C b/gcc/testsuite/g++.dg/lookup/using69.C new file mode 100644 index ..7d52b73b9ce0 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/using69.C @@ -0,0 +1,10 @@ +// PR c++/116748 + +namespace ns { + struct empty; +} + +void foo() { + using ns::empty; + int empty; +}
[gcc r15-3939] c++: Implement resolution for DR 36 [PR116160]
https://gcc.gnu.org/g:2196a20b82bdde2aeb099bcfd164fa29a698e837 commit r15-3939-g2196a20b82bdde2aeb099bcfd164fa29a698e837 Author: Nathaniel Shead Date: Fri Sep 20 00:47:12 2024 +1000 c++: Implement resolution for DR 36 [PR116160] This implements part of P1787 to no longer complain about redeclaring an entity via using-decl other than in a class scope. PR c++/116160 gcc/cp/ChangeLog: * name-lookup.cc (supplement_binding): Allow redeclaration via USING_DECL if not in class scope. (do_nonmember_using_decl): Remove function-scope exemption. (push_using_decl_bindings): Remove outdated comment. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/using-enum-3.C: No longer expect an error. * g++.dg/lookup/using53.C: Remove XFAIL. * g++.dg/cpp2a/using-enum-11.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/name-lookup.cc | 12 +++- gcc/testsuite/g++.dg/cpp0x/using-enum-3.C | 2 +- gcc/testsuite/g++.dg/cpp2a/using-enum-11.C | 9 + gcc/testsuite/g++.dg/lookup/using53.C | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index a2f94e0f363e..4754ef5a5229 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -2874,6 +2874,12 @@ supplement_binding (cxx_binding *binding, tree decl) "%<-std=c++2c%> or %<-std=gnu++2c%>"); binding->value = name_lookup::ambiguous (decl, binding->value); } + else if (binding->scope->kind != sk_class + && TREE_CODE (decl) == USING_DECL + && decls_match (target_bval, target_decl)) +/* Since P1787 (DR 36) it is OK to redeclare entities via using-decl, + except in class scopes. */ +ok = false; else { if (!error_operand_p (bval)) @@ -5377,8 +5383,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, else if (value /* Ignore anticipated builtins. */ && !anticipated_builtin_p (value) - && (fn_scope_p - || !decls_match (lookup.value, strip_using_decl (value + && !decls_match (lookup.value, strip_using_decl (value))) { diagnose_name_conflict (lookup.value, value); failed = true; @@ -6651,9 +6656,6 @@ push_using_decl_bindings (name_lookup *lookup, tree name, tree value) type = binding->type; } - /* DR 36 questions why using-decls at function scope may not be - duplicates. Disallow it, as C++11 claimed and PR 20420 - implemented. */ if (lookup) do_nonmember_using_decl (*lookup, true, true, &value, &type); diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C index 34f8bf4fa0bb..4638181c63ce 100644 --- a/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C +++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C @@ -9,7 +9,7 @@ void f () { enum e { a }; - using e::a; // { dg-error "redeclaration" } + using e::a; // { dg-bogus "redeclaration" "P1787" } // { dg-error "enum" "" { target { ! c++2a } } .-1 } } diff --git a/gcc/testsuite/g++.dg/cpp2a/using-enum-11.C b/gcc/testsuite/g++.dg/cpp2a/using-enum-11.C new file mode 100644 index ..ff99ed422d5f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/using-enum-11.C @@ -0,0 +1,9 @@ +// PR c++/116160 +// { dg-do compile { target c++20 } } + +enum class Blah { b }; +void foo() { + using Blah::b; + using Blah::b; + using enum Blah; +} diff --git a/gcc/testsuite/g++.dg/lookup/using53.C b/gcc/testsuite/g++.dg/lookup/using53.C index e91829e939a9..8279c73bfc4f 100644 --- a/gcc/testsuite/g++.dg/lookup/using53.C +++ b/gcc/testsuite/g++.dg/lookup/using53.C @@ -52,5 +52,5 @@ void f () { using N::i; - using N::i; // { dg-bogus "conflicts" "See P1787 (CWG36)" { xfail *-*-* } } + using N::i; // { dg-bogus "conflicts" "See P1787 (CWG36)" } }
[gcc r15-3937] c++/modules: Propagate purview/import for templates in duplicate_decls [PR116803]
https://gcc.gnu.org/g:cf9efe5ec14fea3ad5746fbefb22544bb9424d9d commit r15-3937-gcf9efe5ec14fea3ad5746fbefb22544bb9424d9d Author: Nathaniel Shead Date: Fri Sep 27 18:58:27 2024 +1000 c++/modules: Propagate purview/import for templates in duplicate_decls [PR116803] We need to ensure that for a declaration in the module purview, that the resulting declaration has PURVIEW_P set and IMPORT_P cleared so that we understand it might be something requiring exporting. This is normally handled for a declaration by set_instantiating_module, but when this declaration is a redeclaration duplicate_decls needs to propagate this to olddecl. This patch only changes the logic for template declarations, because in the non-template case the whole contents of olddecl's DECL_LANG_SPECIFIC is replaced with newdecl's (which includes these flags), so there's nothing to do. PR c++/116803 gcc/cp/ChangeLog: * decl.cc (duplicate_decls): Propagate DECL_MODULE_PURVIEW_P and DECL_MODULE_IMPORT_P for template redeclarations. gcc/testsuite/ChangeLog: * g++.dg/modules/merge-18_a.H: New test. * g++.dg/modules/merge-18_b.H: New test. * g++.dg/modules/merge-18_c.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/decl.cc| 10 ++ gcc/testsuite/g++.dg/modules/merge-18_a.H | 8 gcc/testsuite/g++.dg/modules/merge-18_b.H | 13 + gcc/testsuite/g++.dg/modules/merge-18_c.C | 10 ++ 4 files changed, 41 insertions(+) diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index 6a7ba416cf8a..07fb9855cd20 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -2528,6 +2528,16 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) } } + /* Propagate purviewness and importingness as with +set_instantiating_module. */ + if (modules_p ()) + { + if (DECL_MODULE_PURVIEW_P (new_result)) + DECL_MODULE_PURVIEW_P (old_result) = true; + if (!DECL_MODULE_IMPORT_P (new_result)) + DECL_MODULE_IMPORT_P (old_result) = false; + } + /* If the new declaration is a definition, update the file and line information on the declaration, and also make the old declaration the same definition. */ diff --git a/gcc/testsuite/g++.dg/modules/merge-18_a.H b/gcc/testsuite/g++.dg/modules/merge-18_a.H new file mode 100644 index ..8d86ad980ba5 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/merge-18_a.H @@ -0,0 +1,8 @@ +// PR c++/116803 +// { dg-additional-options "-fmodule-header" } +// { dg-module-cmi {} } + +namespace ns { + template void foo(); + template extern const int bar; +} diff --git a/gcc/testsuite/g++.dg/modules/merge-18_b.H b/gcc/testsuite/g++.dg/modules/merge-18_b.H new file mode 100644 index ..2a762e2ac498 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/merge-18_b.H @@ -0,0 +1,13 @@ +// PR c++/116803 +// { dg-additional-options "-fmodule-header -fdump-lang-module" } +// { dg-module-cmi {} } + +import "merge-18_a.H"; + +namespace ns { + template void foo() {} + template const int bar = 123; +} + +// { dg-final { scan-lang-dump {Writing definition '::ns::template foo'} module } } +// { dg-final { scan-lang-dump {Writing definition '::ns::template bar'} module } } diff --git a/gcc/testsuite/g++.dg/modules/merge-18_c.C b/gcc/testsuite/g++.dg/modules/merge-18_c.C new file mode 100644 index ..b90d85f75024 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/merge-18_c.C @@ -0,0 +1,10 @@ +// PR c++/116803 +// { dg-module-do link } +// { dg-additional-options "-fmodules-ts" } + +import "merge-18_b.H"; + +int main() { + ns::foo(); + static_assert(ns::bar == 123); +}