diff options
36 files changed, 942 insertions, 45 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1eb1ada..3a9b1bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,91 @@ +2025-12-05 Vladimir N. Makarov <vmakarov@redhat.com> + + PR rtl-optimization/122215 + * ira-color.cc (improve_allocation): Use register filter for all + loop on hard regs. + +2025-12-05 Richard Earnshaw <rearnsha@arm.com> + + PR target/122999 + * config/arm/arm.cc (arm_canonicalize_comparison): Defer + initializing maxval until we know we are dealing with an + integer mode. + +2025-12-05 Richard Biener <rguenther@suse.de> + + * tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p): + When peeling for gaps we always need an epilog. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/120939 + * tree-vect-loop.cc (vect_need_peeling_or_partial_vectors_p): + Remove eliding an epilogue based on not computed + LOOP_VINFO_COST_MODEL_THRESHOLD and estimated max stmt executions. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/123002 + * tree-vectorizer.h (supportable_widening_operation): Remove + vinfo and stmt_info parameters, add flag to indicate whether + the context would allow OP_{EVEN,ODD}. + * tree-vect-patterns.cc (vect_recog_abd_pattern): Adjust + and pass false. + (vect_recog_widen_op_pattern): Likewise. + (vect_recog_widen_abd_pattern): Likewise. + * tree-vect-stmts.cc (vectorizable_conversion): Move + even/odd validity check here, from supportable_widening_operation. + Adjust it to be conservative. + (supportable_widening_operation): Get flag whether even/odd + is OK to use and remove then unused parameters and code. + +2025-12-05 Richard Biener <rguenther@suse.de> + + * tree-pretty-print.cc (dump_mem_ref): Dump clique : base + specifier for MEM_REF and TARGET_MEM_REF when dumping + GIMPLE format. + +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * gimplify.cc (gimplify_scan_omp_clauses): Handle + OMP_CLAUSE_DYN_GROUPPRIVATE by printing 'sorry, unimplemented'. + * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DYN_GROUPPRIVATE. + (enum omp_clause_fallback_kind): New. + (struct tree_omp_clause): Add fallback_kind union member. + * tree-nested.cc (convert_nonlocal_omp_clauses, + convert_local_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE. + * tree.cc (omp_clause_num_ops, omp_clause_code_name): Add + OMP_CLAUSE_DYN_GROUPPRIVATE. + * tree-pretty-print.cc (dump_omp_clause): Handle + OMP_CLAUSE_DYN_GROUPPRIVATE. + * tree.h (OMP_CLAUSE_DYN_GROUPPRIVATE_EXPR, + OMP_CLAUSE_DYN_GROUPPRIVATE_KIND): New #define. + +2025-12-05 Andrew Pinski <andrew.pinski@oss.qualcomm.com> + + PR middle-end/99782 + * config/i386/i386-expand.cc (ix86_gen_ccmp_next): Move the check + for mode earlier before expand_operands. + * config/aarch64/aarch64.cc (aarch64_gen_ccmp_next): Likewise. + +2025-12-05 Daniel Barboza <dbarboza@ventanamicro.com> + Jeff Law <jlaw@ventanamicro.com> + + * match.pd (`x & c ? (x - c) | (x | c)`): New pattern. + (`x & c ? (x & ~c) | (x | c)`): Likewise. + +2025-12-05 Pan Li <pan2.li@intel.com> + + * config/riscv/autovec-opt.md (*pred_cmp_swapped<mode>_scalar): + Add new pattern to match vec_dup > vec for vmsltu. + * config/riscv/predicates.md (comparison_swappable_operator): + Add new iterator for above pattern + * config/riscv/riscv-protos.h (expand_vx_cmp_vec_dup_vec): Add + new func to emit vmsltu.vx. + * config/riscv/riscv-v.cc (get_swapped_cmp_rtx_code): Add new + func to convert cmp code to swapped, like gtu to ltu. + (expand_vx_cmp_vec_dup_vec): Add new func decl. + 2025-12-04 Jakub Jelinek <jakub@redhat.com> PR target/122991 diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 59fc39b..00fc5a3 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20251205 +20251206 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d918524..f6a0fd3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,119 @@ +2025-12-05 Javier Miranda <miranda@adacore.com> + + * einfo.ads (Has_Unsigned_Base_Range_Aspect): Update documentation. + (Has_Modular_Operations): New synthesized predicate. + (Has_Overflow_Operations): New synthesized predicate. + * einfo-utils.ads (Has_Modular_Operations): New function. + (Has_Overflow_Operations): New function. + * einfo-utils.adb (Is_Modular_Integer_Type): Undo previous patch. + (Is_Signed_Integer_Type): Undo previous patch. + (Has_Modular_Operations): New function. + (Has_Overflow_Operations): New function. + * checks.adb (Determine_Range): Replace selected occurrences of calls to + Is_Modular_Integer_Type by calls to Has_Modular_Operations, and calls to + Is_Signed_Integer_Type by calls to Has Overflow_Operations. + (Enable_Range_Check): Ditto. + (Insert_Valid_Check): Ditto. + * exp_aggr.adb (Others_Check): Ditto. + * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Pred, + Attribute_Succ]): Ditto. + * exp_ch4.adb (Expand_Compare_Minimize_Eliminate_Overflow): Ditto. + (Size_In_Storage_Elements): Ditto. + (Expand_N_Op_Abs): Ditto. + (Expand_N_Op_Expon): Ditto. + (Expand_N_Op_Minus): Ditto. + (Expand_N_Op_Multiply): Ditto. + (Expand_N_Op_Subtract): Ditto. + * freeze.adb (Freeze_Entity): Ditto. + * sem_aggr.adb (Report_Null_Array_Constraint_Error): Ditto plus + report specific error for index with unsigned_base_range aspect. + * sem_attr.adb (Check_Modular_Integer_Type): Ditto. + (Analyze_Attribute [Attribute_Pred, Attribute_Succ, Attribute_ + Range_Length, Attribute_Small, Attribute_Reduce]): Ditto. + * sem_ch12.adb (Instantiate_Type): Ditto. + (Validate_Formal_Type_Default): Ditto. + * sem_ch13.adb (Valid_Empty): Ditto. + * sem_ch2.adb (Analyze_Integer_Literal): Ditto. + * sem_ch3.adb (Unsigned_Base_Range_Type_Declaration): Set attribute + Has_Unsigned_Base_Range_Aspect on the implicit base, and set Etype + of its first subtype E_Modular_Integer_Subtype. + * sem_ch4.adb (Analyze_Call): Ditto. + * sem_eval.adb (Check_Non_Static_Context_For_Overflow): Ditto. + (Eval_Arithmetic_Op): Ditto. + (Eval_Integer_Literal): Ditto. + (Eval_Logical_Op): Ditto. + (Eval_Op_Expon): Ditto. + (Eval_Op_Not): Ditto. + (Eval_Unary_Op): Ditto. + (Fold_Shift): Ditto. + (Test_Expression_Is_Foldable): Ditto. + * sem_intr.adb (Check_Shift): Ditto. + * sem_prag.adb (Analyze_Pragma [Pragma_Unsigned_Base_Range]): Add + assertion. + * sem_res.adb (Resolve_Logical_Op): Ditto. + (Resolve_Unary_Op): Ditto. + (Set_String_Literal_Subtype): Ditto. + * sem_type.adb (Covers): Ditto. + (Specific_Type): Ditto. + (Valid_Boolean_Arg): Ditto. + * sem_util.adb (Wrong_Type): Ditto + * style.adb (Check_Boolean_Operator): Ditto. + +2025-12-05 Ronan Desplanques <desplanques@adacore.com> + + * doc/gnat_rm/representation_clauses_and_pragmas.rst: Improve table. + * gnat_rm.texi: Regenerate. + * gnat_ugn.texi: Regenerate. + +2025-12-05 Viljar Indus <indus@adacore.com> + + * sem_util.adb (Get_Cursor_Type): use the + specific type for classwide container checks. + +2025-12-05 Eric Botcazou <ebotcazou@adacore.com> + + * sem_ch12.adb (Remove_Parent): Only set the Is_Transient component + of the local scope stack entry. + +2025-12-05 Marc Poulhiès <poulhies@adacore.com> + + * doc/gnat_ugn/building_executable_programs_with_gnat.rst + (-gnato??): Remove redundant/confusing doc on floating-point + overflow. + * gnat_ugn.texi: Regenerate. + +2025-12-05 Tonu Naks <naks@adacore.com> + + * adaint.c: use the _tsopen macro when opening RO file + +2025-12-05 Denis Mazzucato <mazzucato@adacore.com> + + * sem_attr.adb + (Analyze_Attribute): Set the type of the attribute expression only when + not ambiguous (it will later be resolved correctly). Emit an error in + case the type is limited. + (Resolve_Attribute): Emit an error if the reducer has no entity. + (Get_Value_Subtype): Try to resolve the Value_Subtype of the aggregate + expression, and if it succeeds, set the candidate reducer subprogram. + (Is_Reducer_Subprogram): Check whether the selected candidate has a + proper reducer profile. + (Make_Array_Type): Return simple array type to resolve the array + aggregate against it. + (Resolve_Attribute): Reimplement the resolution of Reduce attribute, + including its prefix. + * sem_res.adb (Resolve_Declare_Expression): Save and restore variables + that may be hidden by the local declaration. Only setting the new + entities is problematic when dealing with copied trees where the ref is + lost (eg. when resolving array aggregates). + * exp_attr.adb (Expand_N_Attribute_Reference): Remove tricks to resolve + the reducer in case of faulty resolution as not needed anymore. + +2025-12-05 Iain Sandoe <iain@sandoe.co.uk> + + PR ada/115305 + * Makefile.rtl: Use s-oslock__darwin instead of the Posix version. + * libgnat/s-oslock__darwin.ads: New file. + 2025-12-03 Eric Botcazou <ebotcazou@adacore.com> PR ada/122960 diff --git a/gcc/algol68/a68-lang.cc b/gcc/algol68/a68-lang.cc index 8ba0259..f5f316a 100644 --- a/gcc/algol68/a68-lang.cc +++ b/gcc/algol68/a68-lang.cc @@ -336,6 +336,11 @@ a68_type_for_size (unsigned int bits, int unsignedp) } else { + /* Handle TImode as a special case because it is used by some backends + (e.g. ARM) even though it is not available for normal use. */ + if (bits == TYPE_PRECISION (intTI_type_node)) + return intTI_type_node; + if (bits <= TYPE_PRECISION (a68_short_short_int_type)) return a68_short_short_int_type; if (bits <= TYPE_PRECISION (a68_short_int_type)) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 46d0d30..87c06f6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * c-omp.cc (c_omp_split_clauses): Handle + OMP_CLAUSE_DYN_GROUPPRIVATE, sort target clauses + alphabetically. + * c-pragma.h (enum pragma_omp_clause): Add + PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE. + 2025-11-30 Andrew Pinski <andrew.pinski@oss.qualcomm.com> * c.opt.urls: Regenerate. diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 974dd6d..5589389 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,17 @@ +2025-12-05 Richard Biener <rguenther@suse.de> + + * gimple-parser.cc (c_parser_gimple_postfix_expression): + Parse optional clique : base specifier on __MEM. + +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * c-parser.cc (c_parser_omp_clause_dyn_groupprivate): New. + (OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE; + sort clauses alphabetically. + (c_parser_omp_clause_name, c_parser_omp_all_clauses): + Handle 'dyn_groupprivate' clause. + * c-typeck.cc (c_finish_omp_clauses): Likewise. + 2025-11-27 Jakub Jelinek <jakub@redhat.com> PR c/121506 diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 20d3f1f..1f413b6 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -5700,8 +5700,6 @@ arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1, if (mode == VOIDmode) mode = GET_MODE (*op1); - maxval = (HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (mode) - 1)) - 1; - /* For floating-point comparisons, prefer >= and > over <= and < since the former are supported by VSEL on some architectures. Only do this if both operands are registers. */ @@ -5718,6 +5716,13 @@ arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1, return; } + /* Everything below assumes an integer mode. */ + if (GET_MODE_CLASS (mode) != MODE_INT + || GET_MODE_BITSIZE (mode) > HOST_BITS_PER_WIDE_INT) + return; + + maxval = (HOST_WIDE_INT_1U << (GET_MODE_BITSIZE (mode) - 1)) - 1; + /* For DImode, we have GE/LT/GEU/LTU comparisons (with cmp/sbc). In ARM mode we can also use cmp/cmpeq for GTU/LEU. GT/LE must be either reversed or (for constant OP1) adjusted to GE/LT. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5239592..0084a0f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * pt.cc (tsubst_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE. + * semantics.cc (finish_omp_clauses): Likewise. + * parser.cc (cp_parser_omp_clause_dyn_groupprivate): New. + (cp_parser_omp_clause_name, cp_parser_omp_all_clauses): + Handle 'dyn_groupprivate' clause. + (OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE; + sort clauses alphabetically. + 2025-12-03 Jason Merrill <jason@redhat.com> * pt.cc (dependent_implict_conv_p): Rename to... diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c221955..b8a9e3e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,18 @@ +2025-12-05 Harald Anlauf <anlauf@gmx.de> + + PR fortran/122977 + * expr.cc (gfc_is_simply_contiguous): For an associate variable + check whether the associate target is contiguous. + * resolve.cc (resolve_symbol): Skip array type check for an + associate variable when the target has the contiguous attribute. + +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * openmp.cc (resolve_omp_clauses): Permit zero with + DYN_GROUPPRIVATE clause. + * trans-openmp.cc (fallback): Generate TREE code + for DYN_GROUPPRIVATE and remove 'sorry'. + 2025-12-03 Paul Thomas <pault@gcc.gnu.org> PR fortran/103371 diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 00abd9e..054276e 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -6406,6 +6406,14 @@ gfc_is_simply_contiguous (gfc_expr *expr, bool strict, bool permit_element) || (sym->as && sym->as->type == AS_ASSUMED_SHAPE)))) return false; + /* An associate variable may point to a non-contiguous target. */ + if (ar && ar->type == AR_FULL + && sym->attr.associate_var && !sym->attr.contiguous + && sym->assoc + && sym->assoc->target) + return gfc_is_simply_contiguous (sym->assoc->target, strict, + permit_element); + if (!ar || ar->type == AR_FULL) return true; diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index 9f3ce1d..8e076c6 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -18143,6 +18143,7 @@ skip_interfaces: /* F2008, C530. */ if (sym->attr.contiguous + && !sym->attr.associate_var && (!class_attr.dimension || (as->type != AS_ASSUMED_SHAPE && as->type != AS_ASSUMED_RANK && !class_attr.pointer))) diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index 4ee2a65..a051db2 100644 --- a/gcc/ira-color.cc +++ b/gcc/ira-color.cc @@ -3369,6 +3369,9 @@ improve_allocation (void) for (j = 0; j < class_size; j++) { hregno = ira_class_hard_regs[aclass][j]; + if (NUM_REGISTER_FILTERS + && !test_register_filters (ALLOCNO_REGISTER_FILTERS (a), hregno)) + continue; if (check_hard_reg_p (a, hregno, conflicting_regs, profitable_hard_regs) && min_cost > costs[hregno]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a8b45e7..0139ece 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,101 @@ +2025-12-06 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/99782 + * gcc.dg/torture/pr99782-1.c: Fix typo, dg-compile -> dg-do compile. + Use int128 effective target directly on that directive. Move PR + comment first. + +2025-12-05 Andrew Pinski <andrew.pinski@oss.qualcomm.com> + + * gcc.dg/torture/pr99782-1.c: Require intt128 target. + +2025-12-05 Vladimir N. Makarov <vmakarov@redhat.com> + + PR rtl-optimization/122215 + * gcc.target/riscv/pr122215.c: New. + * lib/target-supports.exp (check_effective_target_valgrind): New. + +2025-12-05 Harald Anlauf <anlauf@gmx.de> + + PR fortran/122977 + * gfortran.dg/contiguous_16.f90: New test. + +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * gfortran.dg/gomp/dyn_groupprivate-1.f90: Fix + scan-tree-dump-times regexp to avoid hard-coded 'D.4680'. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/120939 + * gcc.dg/torture/pr113026-1.c: Skip when -ftracer. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/123002 + * gcc.dg/vect/vect-pr123002.c: Make global data non-const + and non-static. + +2025-12-05 Denis Mazzucato <mazzucato@adacore.com> + + * gnat.dg/reduce1.adb: Adjust expected error message. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/123002 + * gcc.dg/vect/vect-pr123002.c: New testcase. + +2025-12-05 Richard Biener <rguenther@suse.de> + + * gcc.dg/gimplefe-58.c: New testcase. + +2025-12-05 Tobias Burnus <tburnus@baylibre.com> + + * gfortran.dg/gomp/dyn_groupprivate-1.f90: Add scan-dump test. + * gfortran.dg/gomp/dyn_groupprivate-2.f90: Extend and update. + * c-c++-common/gomp/dyn_groupprivate-1.c: New test. + * c-c++-common/gomp/dyn_groupprivate-2.c: New test. + +2025-12-05 Richard Biener <rguenther@suse.de> + + PR tree-optimization/122776 + * gcc.dg/vect/vect-simd-clone-24.c: Add -mprefer-vector-width=512. + +2025-12-05 Andrew Pinski <andrew.pinski@oss.qualcomm.com> + + PR middle-end/99782 + * gcc.dg/torture/pr99782-1.c: New test. + +2025-12-05 Daniel Barboza <dbarboza@ventanamicro.com> + Jeff Law <jlaw@ventanamicro.com> + + * gcc.dg/torture/pr122615.c: New test. + * gcc.dg/torture/pr122616.c: Likewise. + +2025-12-05 Pan Li <pan2.li@intel.com> + + * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check + for vmsltu.vx. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test + helper macros. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test + data for run test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vmsltu-run-1-u8.c: New test. + 2025-12-04 Richard Biener <rguenther@suse.de> PR tree-optimization/122776 diff --git a/gcc/testsuite/gcc.dg/torture/pr99782-1.c b/gcc/testsuite/gcc.dg/torture/pr99782-1.c index 76aab18..45fb93e 100644 --- a/gcc/testsuite/gcc.dg/torture/pr99782-1.c +++ b/gcc/testsuite/gcc.dg/torture/pr99782-1.c @@ -1,6 +1,6 @@ -/* { dg-compile } */ -/* { dg-additional-options "-mapxf" { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ /* PR middle-end/99782 */ +/* { dg-do compile { target int128 } } */ +/* { dg-additional-options "-mapxf" { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ int hb; diff --git a/gcc/testsuite/gcc.target/riscv/pr122215.c b/gcc/testsuite/gcc.target/riscv/pr122215.c new file mode 100644 index 0000000..cdc1ed7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr122215.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target valgrind } */ +/* { dg-additional-files "sparseset.supp" } */ +/* { dg-options "-wrapper valgrind,-q,--exit-on-first-error=yes,--error-exitcode=1,--suppressions=${srcdir}/sparseset.supp" } */ + +typedef signed int int32_t; +typedef signed long int int64_t; + +int64_t dual_reg_insn(int64_t x) { + int64_t res; + int64_t zero = 0; + asm ("some_custom_insn %0,%1,%2" : "=R" (res) : "R" (x), "R" (zero)); + return res; +} + +int32_t single_reg_insn(int32_t x) { + int32_t res; + int32_t zero = 0; + asm ("some_custom_insn %0,%1,%2" : "=r" (res) : "r" (x), "r" (zero)); + return res; +} + +int32_t single_reg_insn_explicit_zero(int32_t x) { + int32_t res; + asm ("some_custom_insn %0,%1,%2" : "=r" (res) : "r" (x), "r" (0)); + return res; +} + +int64_t dual_reg_insn2(int64_t x) { + int64_t res; + int64_t zero = 0; + asm ("some_custom_insn %0,%1,%2" : "=R" (res) : "R" (x), "R" (zero)); + return res; + /* This function is IDENTICAL to dual_reg_insn, + * but for some obscure reason (alignment?) + * it decides to use sX registers instead of aX to store zero, + * resulting in a much larger code since it needs to use the stack. + * THIS ONLY HAPPENS SOMETIMES! + */ +} + +int64_t dual_reg_insn_explicit_zero(int64_t x) { + int64_t res; + asm ("some_custom_insn %0,%1,%2" : "=R" (res) : "R" (x), "R" (0LL)); + return res; +} diff --git a/gcc/testsuite/gfortran.dg/contiguous_16.f90 b/gcc/testsuite/gfortran.dg/contiguous_16.f90 new file mode 100644 index 0000000..ae1ba26 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/contiguous_16.f90 @@ -0,0 +1,51 @@ +! { dg-do run } +! { dg-options "-O2 -fdump-tree-original" } +! +! PR fortran/122977 - associate to a contiguous pointer + +program foo + integer, dimension(:), pointer, contiguous :: a + integer, dimension(:), allocatable :: u + allocate (a(4), u(4)) + if (.not. is_contiguous(a)) error stop 1 ! optimized + if (.not. is_contiguous(u)) error stop 2 ! optimized + + associate (b => a) + if (.not. is_contiguous(b)) error stop 3 ! optimized + associate (c => b) + if (.not. is_contiguous(c)) error stop 4 ! optimized + end associate + associate (c => b(1::2)) + if (is_contiguous(c)) stop 11 ! runtime check + end associate + end associate + + associate (v => u) + if (.not. is_contiguous(v)) error stop 5 ! optimized + associate (w => v) + if (.not. is_contiguous(w)) error stop 6 ! optimized + end associate + associate (w => v(1::2)) + if (is_contiguous(w)) stop 12 ! runtime check + end associate + end associate + + associate (b => a(1::2)) + if (is_contiguous(b)) stop 13 ! runtime check + associate (c => b) + if (is_contiguous(c)) stop 14 ! runtime check + end associate + end associate + + associate (v => u(1::2)) + if (is_contiguous(v)) stop 15 ! runtime check + associate (w => v) + if (is_contiguous(w)) stop 16 ! runtime check + end associate + end associate + + deallocate (a, u) +end program foo + +! { dg-final { scan-tree-dump-not "_gfortran_error_stop_numeric" "original" } } +! { dg-final { scan-tree-dump-times "_gfortran_stop_numeric" 6 "original" } } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 1df80d4..6251f4e 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -14762,3 +14762,11 @@ proc check_effective_target_fentry { } { } }] } + +# Check if valgrind executable exists in PATH on host +proc check_effective_target_valgrind { } { + if { [which valgrind] != 0 } { + return 1 + } + return 0 +} diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7ec35de..4215128 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,74 @@ +2025-12-05 Patrick Palka <ppalka@redhat.com> + Tomasz Kamiński <tkaminsk@redhat.com> + + PR libstdc++/120446 + * include/bits/refwrap.h (__detail::__is_ref_wrapper): + Define as per P2655R3 for C++20. + (__detail::__ref_wrap_common_reference_exists_with): Likewise. + (basic_common_reference): Define partial specializations using + the above as per P2655R3 for C++20. + * include/bits/version.def (common_reference_wrapper): New. + * include/bits/version.h: Regenerate. + * include/std/functional (__glibcxx_want_common_reference_wrapper): + Define. + * testsuite/20_util/reference_wrapper/p2655r3.cc: New test. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + PR libstdc++/120446 + * include/bits/version.def (common_reference): New. + * include/bits/version.h: Regenerate. + * include/std/type_traits (__glibcxx_want_common_reference): + Define. + (__common_reference_impl<T1, T2, 1>): Add pointer convertibility + constraints as per P2655R3. + * testsuite/20_util/common_reference/p2655r3.cc: New test. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + PR c++/120446 + * include/std/type_traits (__common_reference_impl): Rewrite + partial specializations to use requires-clause instead of + an additional void_t template parameter. Consolidate the + partial specializations corresponding to bullet 1. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + * testsuite/20_util/function_objects/bind_front/111327.cc: + Add missing space before } ending a dg-error directive. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + PR libstdc++/111550 + * include/std/ranges (views::__adaptor::_Partial::operator()) + [_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this + in C++20 mode when possible. + (views::__adaptor::_Pipe::Operator()) + [_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Likewise. + * testsuite/std/ranges/adaptors/take.cc (test07): New test. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + PR libstdc++/111327 + * include/bits/binders.h (_Binder::operator()) + [_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Also use deducing this in + C++20 mode when possible. + * testsuite/20_util/function_objects/bind_front/111327.cc: + Expect error inside header even in C++20 mode. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + PR libstdc++/111327 + * include/std/functional (_Not_fn::operator()) + [_GLIBCXX_EXPLICIT_THIS_PARAMETER]: Define as a single + overload using deducing this. + * testsuite/20_util/function_objects/not_fn/111327.cc: Extend test. + +2025-12-05 Patrick Palka <ppalka@redhat.com> + + * include/bits/c++config (_GLIBCXX_EXPLICIT_THIS_PARAMETER): + New. + 2025-12-04 François Dumont <frs.dumont@gmail.com> * include/debug/deque diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 6d8c0de..84b8b4c 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -118,7 +118,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __atomic_eq(const _Tp& __a, const _Tp& __b) { // TODO make this do the correct padding bit ignoring comparison - return __builtin_memcmp(&__a, &__b, sizeof(_Tp)) == 0; + return __builtin_memcmp(std::addressof(__a), std::addressof(__b), + sizeof(_Tp)) == 0; } // Storage for up to 64 bits of value, should be considered opaque bits. diff --git a/libstdc++-v3/include/bits/binders.h b/libstdc++-v3/include/bits/binders.h index 6489edd..9724717 100644 --- a/libstdc++-v3/include/bits/binders.h +++ b/libstdc++-v3/include/bits/binders.h @@ -125,7 +125,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_bound_args(__make_bound_args<_BoundArgs...>(std::forward<_Args>(__args)...)) { static_assert(sizeof...(_Args) == sizeof...(_BoundArgs)); } -#if __cpp_explicit_this_parameter +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this template<typename _Self, typename... _CallArgs> constexpr _Result_t<_Self, _CallArgs...> operator()(this _Self&& __self, _CallArgs&&... __call_args) @@ -134,6 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return _S_call(__like_t<_Self, _Binder>(__self), std::forward<_CallArgs>(__call_args)...); } +# pragma GCC diagnostic pop #else template<typename... _CallArgs> requires true diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index eec3a4a..e6d8f18 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -927,6 +927,13 @@ namespace __gnu_cxx # define _GLIBCXX_USE_BUILTIN_TRAIT(BT) 0 #endif +// Whether deducing this is usable either officially, if in C++23 mode, or +// as an extension (Clang doesn't support the latter). +#if __cpp_explicit_this_parameter \ + || (__cplusplus >= 201103L && __GNUC__ >= 14 && !defined(_GLIBCXX_CLANG)) +# define _GLIBCXX_EXPLICIT_THIS_PARAMETER 202110L +#endif + // Mark code that should be ignored by the compiler, but seen by Doxygen. #define _GLIBCXX_DOXYGEN_ONLY(X) diff --git a/libstdc++-v3/include/bits/refwrap.h b/libstdc++-v3/include/bits/refwrap.h index 612715e..5d9f8c8 100644 --- a/libstdc++-v3/include/bits/refwrap.h +++ b/libstdc++-v3/include/bits/refwrap.h @@ -457,6 +457,40 @@ _GLIBCXX_MEM_FN_TRAITS(&& noexcept, false_type, true_type) /// @} +#if __glibcxx_common_reference_wrapper // C++ >= 20 + namespace __detail + { + template<typename _Tp> + constexpr bool __is_ref_wrapper = false; + + template<typename _Tp> + constexpr bool __is_ref_wrapper<reference_wrapper<_Tp>> = true; + + template<typename _Rp, typename _Tp, typename _RQual, typename _TQual> + concept __ref_wrap_common_reference_exists_with = __is_ref_wrapper<_Rp> + && requires { typename common_reference_t<typename _Rp::type&, _TQual>; } + && convertible_to<_RQual, common_reference_t<typename _Rp::type&, _TQual>>; + } // namespace __detail + + template<typename _Rp, typename _Tp, + template<typename> class _RQual, template<typename> class _TQual> + requires __detail::__ref_wrap_common_reference_exists_with<_Rp, _Tp, + _RQual<_Rp>, _TQual<_Tp>> + && (!__detail::__ref_wrap_common_reference_exists_with<_Tp, _Rp, + _TQual<_Tp>, _RQual<_Rp>>) + struct basic_common_reference<_Rp, _Tp, _RQual, _TQual> + { using type = common_reference_t<typename _Rp::type&, _TQual<_Tp>>; }; + + template<typename _Tp, typename _Rp, + template<typename> class _TQual, template<typename> class _RQual> + requires __detail::__ref_wrap_common_reference_exists_with<_Rp, _Tp, + _RQual<_Rp>, _TQual<_Tp>> + && (!__detail::__ref_wrap_common_reference_exists_with<_Tp, _Rp, + _TQual<_Tp>, _RQual<_Rp>>) + struct basic_common_reference<_Tp, _Rp, _TQual, _RQual> + { using type = common_reference_t<typename _Rp::type&, _TQual<_Tp>>; }; +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index d20e085..412b9ce 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -1822,6 +1822,22 @@ ftms = { }; ftms = { + name = common_reference; + values = { + v = 202302; + cxxmin = 20; // We treat P2655R3 as a DR against C++20. + }; +}; + +ftms = { + name = common_reference_wrapper; + values = { + v = 202302; + cxxmin = 20; // We treat P2655R3 as a DR against C++20. + }; +}; + +ftms = { name = formatters; values = { v = 202302; diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index c75368d4..2b96934 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -2030,6 +2030,26 @@ #endif /* !defined(__cpp_lib_flat_set) */ #undef __glibcxx_want_flat_set +#if !defined(__cpp_lib_common_reference) +# if (__cplusplus >= 202002L) +# define __glibcxx_common_reference 202302L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_common_reference) +# define __cpp_lib_common_reference 202302L +# endif +# endif +#endif /* !defined(__cpp_lib_common_reference) && defined(__glibcxx_want_common_reference) */ +#undef __glibcxx_want_common_reference + +#if !defined(__cpp_lib_common_reference_wrapper) +# if (__cplusplus >= 202002L) +# define __glibcxx_common_reference_wrapper 202302L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_common_reference_wrapper) +# define __cpp_lib_common_reference_wrapper 202302L +# endif +# endif +#endif /* !defined(__cpp_lib_common_reference_wrapper) && defined(__glibcxx_want_common_reference_wrapper) */ +#undef __glibcxx_want_common_reference_wrapper + #if !defined(__cpp_lib_formatters) # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED # define __glibcxx_formatters 202302L diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index ccb77fa..0a510d8 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -406,21 +406,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept { - std::__atomic_wait_address_v(&_M_i, __old, - [__m, this] { return this->load(__m); }); + std::__atomic_wait_address_v(std::addressof(_M_i), __old, + [__m, this] { return this->load(__m); }); } // TODO add const volatile overload void notify_one() noexcept - { std::__atomic_notify_address(&_M_i, false); } + { std::__atomic_notify_address(std::addressof(_M_i), false); } void notify_all() noexcept - { std::__atomic_notify_address(&_M_i, true); } + { std::__atomic_notify_address(std::addressof(_M_i), true); } #endif // __cpp_lib_atomic_wait - }; /// Partial specialization for pointer types. diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 1928a27..570e9e9 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -64,6 +64,7 @@ #define __glibcxx_want_not_fn #define __glibcxx_want_ranges #define __glibcxx_want_reference_wrapper +#define __glibcxx_want_common_reference_wrapper #define __glibcxx_want_transparent_operators #include <bits/version.h> @@ -495,6 +496,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_DEPR_BIND #endif +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER + // Return a _Up that has the same cv-quals as _Tp. + template<typename _Tp, typename _Up> // _Up should be cv-unqualified + struct __cv_like + { using type = _Up; }; + + template<typename _Tp, typename _Up> + struct __cv_like<const _Tp, _Up> + { using type = const _Up; }; + + template<typename _Tp, typename _Up> + struct __cv_like<volatile _Tp, _Up> + { using type = volatile _Up; }; + + template<typename _Tp, typename _Up> + struct __cv_like<const volatile _Tp, _Up> + { using type = const volatile _Up; }; + + template<typename _Tp, typename _Up> + using __cv_like_t = typename __cv_like<_Tp, _Up>::type; +#endif + /// Type of the function object returned from bind(). template<typename _Signature> class _Bind; @@ -564,6 +587,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using _Res_type_impl = __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>; +#if !_GLIBCXX_EXPLICIT_THIS_PARAMETER template<typename _CallArgs> using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>; @@ -576,6 +600,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename __cv_quals<__dependent<_CallArgs>>::type, _CallArgs, typename __cv_quals<_Bound_args>::type...>; +#endif public: template<typename... _Args> @@ -593,6 +618,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Bind(const _Bind&) = default; _Bind(_Bind&&) = default; +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr +# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this + template<typename... _Args, + typename _Self, + typename _Self_nonref = typename remove_reference<_Self>::type, + __enable_if_t<!is_volatile<_Self_nonref>::value, int> = 0, + typename _Result + = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>, + tuple<_Args...>, + __cv_like_t<_Self_nonref, _Bound_args>...>> + _GLIBCXX20_CONSTEXPR + _Result + operator()(this _Self&& __self, _Args&&... __args) + { + using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&; + if constexpr (is_const<_Self_nonref>::value) + return _Bind_ref(__self) + .template __call_c<_Result>(std::forward_as_tuple + (std::forward<_Args>(__args)...), + _Bound_indexes()); + else + return _Bind_ref(__self) + .template __call<_Result>(std::forward_as_tuple + (std::forward<_Args>(__args)...), + _Bound_indexes()); + } + +# if defined(_GLIBCXX_VOLATILE_BIND) + template<typename... _Args, + typename _Self, + typename _Self_nonref = typename remove_reference<_Self>::type, + __enable_if_t<is_volatile<_Self_nonref>::value, int> = 0, + typename _Result + = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>, + tuple<_Args...>, + __cv_like_t<_Self_nonref, _Bound_args>...>> + _GLIBCXX_DEPR_BIND + _Result + operator()(this _Self&& __self, _Args&&... __args) + { + using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&; + if constexpr (is_const<_Self_nonref>::value) + return _Bind_ref(__self) + .template __call_c_v<_Result>(std::forward_as_tuple + (std::forward<_Args>(__args)...), + _Bound_indexes()); + else + return _Bind_ref(__self) + .template __call_v<_Result>(std::forward_as_tuple + (std::forward<_Args>(__args)...), + _Bound_indexes()); + } +# endif +# pragma GCC diagnostic pop +#else // Call unqualified template<typename... _Args, typename _Result = _Res_type<tuple<_Args...>>> @@ -642,6 +724,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Bound_indexes()); } #endif // volatile +#endif }; /// Type of the function object returned from bind<R>(). @@ -1056,6 +1139,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Not_fn(_Not_fn&& __fn) = default; ~_Not_fn() = default; +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this + template<typename _Self, typename... _Args> + _GLIBCXX20_CONSTEXPR + decltype(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>()) + operator()(this _Self&& __self, _Args&&... __args) + noexcept(__is_nothrow_invocable<__like_t<_Self, _Fn>, _Args...>::value + && noexcept(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>())) + { + return !std::__invoke(__like_t<_Self, _Not_fn>(__self)._M_fn, + std::forward<_Args>(__args)...); + } +# pragma GCC diagnostic pop +#else // Macro to define operator() with given cv-qualifiers ref-qualifiers, // forwarding _M_fn and the function arguments with the same qualifiers, // and deducing the return type and exception-specification. @@ -1081,6 +1179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_NOT_FN_CALL_OP( && ) _GLIBCXX_NOT_FN_CALL_OP( const && ) #undef _GLIBCXX_NOT_FN_CALL_OP +#endif private: _Fn _M_fn; diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index b3105c5..b81ee78 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -1259,7 +1259,9 @@ namespace views::__adaptor // Invoke _Adaptor with arguments __r, _M_args... according to the // value category of this _Partial object. -#if __cpp_explicit_this_parameter +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this template<typename _Self, typename _Range> requires __adaptor_invocable<_Adaptor, _Range, __like_t<_Self, _Args>...> constexpr auto @@ -1268,6 +1270,7 @@ namespace views::__adaptor return _Binder::_S_call(__like_t<_Self, _Partial>(__self)._M_binder, std::forward<_Range>(__r)); } +# pragma GCC diagnostic pop #else template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, const _Args&...> @@ -1336,7 +1339,9 @@ namespace views::__adaptor // Invoke _M_rhs(_M_lhs(__r)) according to the value category of this // range adaptor closure object. -#if __cpp_explicit_this_parameter +#if _GLIBCXX_EXPLICIT_THIS_PARAMETER +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this template<typename _Self, typename _Range> requires __pipe_invocable<__like_t<_Self, _Lhs>, __like_t<_Self, _Rhs>, _Range> constexpr auto @@ -1346,6 +1351,7 @@ namespace views::__adaptor (__like_t<_Self, _Pipe>(__self)._M_lhs (std::forward<_Range>(__r)))); } +# pragma GCC diagnostic pop #else template<typename _Range> requires __pipe_invocable<const _Lhs&, const _Rhs&, _Range> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 5c09fac..7c157ea 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -41,6 +41,7 @@ #define __glibcxx_want_bool_constant #define __glibcxx_want_bounded_array_traits +#define __glibcxx_want_common_reference #define __glibcxx_want_constant_wrapper #define __glibcxx_want_has_unique_object_representations #define __glibcxx_want_integral_constant_callable @@ -4225,7 +4226,7 @@ template<typename _Ret, typename _Fn, typename... _Args> { using type = _Tp0; }; /// @cond undocumented - template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void> + template<typename _Tp1, typename _Tp2, int _Bullet = 1> struct __common_reference_impl : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> { }; @@ -4238,46 +4239,38 @@ template<typename _Ret, typename _Fn, typename... _Args> // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1&, _Tp2&, 1, - void_t<__common_ref<_Tp1&, _Tp2&>>> - { using type = __common_ref<_Tp1&, _Tp2&>; }; - - template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, - void_t<__common_ref<_Tp1&&, _Tp2&&>>> - { using type = __common_ref<_Tp1&&, _Tp2&&>; }; - - template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1&, _Tp2&&, 1, - void_t<__common_ref<_Tp1&, _Tp2&&>>> - { using type = __common_ref<_Tp1&, _Tp2&&>; }; - - template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1&&, _Tp2&, 1, - void_t<__common_ref<_Tp1&&, _Tp2&>>> - { using type = __common_ref<_Tp1&&, _Tp2&>; }; + requires is_reference_v<_Tp1> && is_reference_v<_Tp2> + && requires { typename __common_ref<_Tp1, _Tp2>; } +#if __cpp_lib_common_reference // C++ >= 20 + && is_convertible_v<add_pointer_t<_Tp1>, + add_pointer_t<__common_ref<_Tp1, _Tp2>>> + && is_convertible_v<add_pointer_t<_Tp2>, + add_pointer_t<__common_ref<_Tp1, _Tp2>>> +#endif + struct __common_reference_impl<_Tp1, _Tp2, 1> + { using type = __common_ref<_Tp1, _Tp2>; }; // Otherwise, if basic_common_reference<...>::type is well-formed, ... template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1, _Tp2, 2, - void_t<__basic_common_ref<_Tp1, _Tp2>>> + requires requires { typename __basic_common_ref<_Tp1, _Tp2>; } + struct __common_reference_impl<_Tp1, _Tp2, 2> { using type = __basic_common_ref<_Tp1, _Tp2>; }; // Otherwise, if COND-RES(T1, T2) is well-formed, ... template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1, _Tp2, 3, - void_t<__cond_res<_Tp1, _Tp2>>> + requires requires { typename __cond_res<_Tp1, _Tp2>; } + struct __common_reference_impl<_Tp1, _Tp2, 3> { using type = __cond_res<_Tp1, _Tp2>; }; // Otherwise, if common_type_t<T1, T2> is well-formed, ... template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1, _Tp2, 4, - void_t<common_type_t<_Tp1, _Tp2>>> + requires requires { typename common_type_t<_Tp1, _Tp2>; } + struct __common_reference_impl<_Tp1, _Tp2, 4> { using type = common_type_t<_Tp1, _Tp2>; }; // Otherwise, there shall be no member type. template<typename _Tp1, typename _Tp2> - struct __common_reference_impl<_Tp1, _Tp2, 5, void> + struct __common_reference_impl<_Tp1, _Tp2, 5> { }; // Otherwise, if sizeof...(T) is greater than two, ... @@ -4296,7 +4289,7 @@ template<typename _Ret, typename _Fn, typename... _Args> { }; /// @endcond -#endif // C++2a +#endif // C++20 #if __cplusplus >= 201103L // Stores a tuple of indices. Used by tuple and pair, and by bind() to diff --git a/libstdc++-v3/testsuite/20_util/bind/80564.cc b/libstdc++-v3/testsuite/20_util/bind/80564.cc new file mode 100644 index 0000000..f6e1a1e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bind/80564.cc @@ -0,0 +1,50 @@ +// PR libstdc++/80564 - bind on SFINAE unfriendly generic lambda +// { dg-do compile { target c++14 } } + +#include <functional> + +struct A +{ + template<typename T> + auto operator()(T&) + { } + + template<typename T> + auto operator()(T&) const + { T::fail; } +}; + +void +test01() +{ + A a; + std::bind(a, 0)(); // doesn't consider the const overload + std::bind<void>(a, 0)(); +} + +void +test02() +{ + auto f = [] (auto& x) { x = 1; }; + int i; + std::bind(f, i)(); // doesn't try const-invoking the lambda + std::bind<void>(f, i)(); +} + +#if __cpp_variadic_using +template<typename... Ts> +struct overloaded : private Ts... +{ + overloaded(Ts... ts) : Ts(ts)... { } + using Ts::operator()...; +}; + +void +test03() +{ + A a; + auto f = std::bind(a, 0); + overloaded<decltype(f)> g(f); + g(); +} +#endif diff --git a/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc index e4c348f..6d37cc4 100644 --- a/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc +++ b/libstdc++-v3/testsuite/20_util/bind/cv_quals_2.cc @@ -44,6 +44,9 @@ void test01() // { dg-error "no match" "" { target c++20 } 43 } } +// Ignore the reasons for deduction/substitution failure in the headers. +// { dg-prune-output "no type named 'type' in 'struct std::enable_if<false" } + int main() { test01(); diff --git a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc index dd47c43..46cc4bb 100644 --- a/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc +++ b/libstdc++-v3/testsuite/20_util/bind/ref_neg.cc @@ -51,6 +51,7 @@ void test02() // Ignore the reasons for deduction/substitution failure in the headers. // Arrange for the match to work on installed trees as well as build trees. // { dg-prune-output "no type named 'type' in 'struct std::__invoke_result" } +// { dg-prune-output "no type named 'type' in 'struct std::enable_if<false" } int main() { diff --git a/libstdc++-v3/testsuite/20_util/common_reference/p2655r3.cc b/libstdc++-v3/testsuite/20_util/common_reference/p2655r3.cc new file mode 100644 index 0000000..4188dd2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_reference/p2655r3.cc @@ -0,0 +1,15 @@ +// P2655R3 - common_reference_t of reference_wrapper Should Be a Reference Type +// Implemented as a DR against C++20 +// { dg-do compile { target c++20 } } + +#include <type_traits> + +#if __cpp_lib_common_reference != 202302L +# error "Feature-test macro __cpp_lib_common_reference has wrong value in <type_traits>" +#endif + +struct A { }; +struct B { operator A&() const; }; + +static_assert( std::is_same_v<std::common_reference_t<A&, const B&>, A&> ); +static_assert( std::is_same_v<std::common_reference_t<const B&, A&>, A&> ); diff --git a/libstdc++-v3/testsuite/20_util/function_objects/bind_front/111327.cc b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/111327.cc index 58832a6..493ef08 100644 --- a/libstdc++-v3/testsuite/20_util/function_objects/bind_front/111327.cc +++ b/libstdc++-v3/testsuite/20_util/function_objects/bind_front/111327.cc @@ -50,4 +50,4 @@ int main() { std::move(std::as_const(g2))(); } -// { dg-error "no type named 'type' in 'std::__conditional_t<false, std::invoke_result<" "" { target c++23 } 0 } +// { dg-error "no type named 'type' in 'std::__conditional_t<false, std::invoke_result<" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/function_objects/not_fn/111327.cc b/libstdc++-v3/testsuite/20_util/function_objects/not_fn/111327.cc index 725a842..be58b0e 100644 --- a/libstdc++-v3/testsuite/20_util/function_objects/not_fn/111327.cc +++ b/libstdc++-v3/testsuite/20_util/function_objects/not_fn/111327.cc @@ -15,15 +15,28 @@ struct G { bool operator()(...) const &&; }; +struct Weird { + void operator()(); + bool operator()() const { return true; } +}; + int main() { auto f = std::not_fn(F{}); - f(); // { dg-error "deleted" } + f(); // { dg-error "no match" } std::move(f)(); std::as_const(f)(); std::move(std::as_const(f))(); auto g = std::not_fn(G{}); - g(); // { dg-error "deleted" } - std::move(g)(); // { dg-error "deleted" } + g(); // { dg-error "no match" } + std::move(g)(); // { dg-error "no match" } std::move(std::as_const(g))(); + + auto h = std::not_fn(Weird{}); + h(); // { dg-error "no match" } } + +// { dg-error "no type named 'type' in 'struct std::__invoke_result<" "" { target *-*-* } 0 } +// { dg-error "no matching function for call to 'std::_Not_fn<Weird>" "" { target *-*-* } 0 } +// { dg-error "could not convert 'std::declval<void>\\(\\)' from 'void' to 'bool'" "" { target *-*-* } 0 } +// { dg-error "in argument to unary !" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/20_util/reference_wrapper/p2655r3.cc b/libstdc++-v3/testsuite/20_util/reference_wrapper/p2655r3.cc new file mode 100644 index 0000000..f2fafec --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/reference_wrapper/p2655r3.cc @@ -0,0 +1,75 @@ +// P2655R3 - common_reference_t of reference_wrapper Should Be a Reference Type +// Implemented as a DR against C++20 +// { dg-do compile { target c++20 } } + +#include <functional> + +#if __cpp_lib_common_reference_wrapper != 202302L +# error "Feature-test macro __cpp_lib_common_reference_wrapper has wrong value in <functional>" +#endif + +using std::is_same_v; +using std::common_reference_t; +using std::reference_wrapper; + +static_assert( is_same_v<common_reference_t<const reference_wrapper<int>&, int&>, int&> ); +static_assert( is_same_v<common_reference_t<int&, const reference_wrapper<int>&>, int&> ); + +static_assert( is_same_v<common_reference_t<reference_wrapper<int>, int&>, + common_reference_t<int&, int&>> ); +static_assert( is_same_v<common_reference_t<reference_wrapper<int>, const int&>, + common_reference_t<int&, const int&>> ); +static_assert( is_same_v<common_reference_t<reference_wrapper<const int>, int&>, + common_reference_t<const int&, int&>> ); + +static_assert( is_same_v<common_reference_t<int&, reference_wrapper<int>>, + common_reference_t<int&, int&>> ); +static_assert( is_same_v<common_reference_t<const int&, reference_wrapper<int>>, + common_reference_t<int&, const int&>> ); +static_assert( is_same_v<common_reference_t<int&, reference_wrapper<const int>>, + common_reference_t<const int&, int&>> ); + +static_assert( is_same_v<common_reference_t<reference_wrapper<int>&, reference_wrapper<int>&>, + reference_wrapper<int>&> ); + +static_assert( is_same_v<common_reference_t<reference_wrapper<char>, + reference_wrapper<int>>, + int> ); +static_assert( is_same_v<common_reference_t<reference_wrapper<reference_wrapper<int>>, + reference_wrapper<int>>, + reference_wrapper<int>> ); +static_assert( is_same_v<common_reference_t<reference_wrapper<int>, + reference_wrapper<reference_wrapper<int>>>, + reference_wrapper<int>> ); + +struct A { }; +struct B { operator A&() const; }; + +template<typename T, typename U> +concept has_common_reference = requires { + typename std::common_reference_t<T, U>; +}; + +static_assert( is_same_v<common_reference_t<reference_wrapper<A>, const B&>, A&> ); +// reference_wrapper<const B> is not convertible to A&, as it would require two user +// defined conversions. +static_assert( !has_common_reference<A, reference_wrapper<const B>> ); +static_assert( !has_common_reference<reference_wrapper<A>, reference_wrapper<const B>> ); + +struct D1 : A {}; +struct D2 : A {}; + +template<template<class> typename Qual1, template<class> typename Qual2> +struct std::basic_common_reference<D1, D2, Qual1, Qual2> + : std::common_reference<Qual1<A>, Qual2<A>> +{ }; + +template<template<class> typename Qual1, template<class> typename Qual2> +struct std::basic_common_reference<D2, D1, Qual1, Qual2> + : std::common_reference<Qual1<A>, Qual2<A>> +{ }; + +static_assert( is_same_v<common_reference_t<D1&, D2&>, A&> ); +static_assert( is_same_v<common_reference_t<reference_wrapper<D1>, D2&>, A&> ); +static_assert( is_same_v<common_reference_t<D1&, reference_wrapper<D2>>, A&> ); +static_assert( !has_common_reference<reference_wrapper<D1>, reference_wrapper<D2>> ); diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc index 1673772..9584c57 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/take.cc @@ -118,6 +118,20 @@ test06() static_assert(!requires { views::all | take; }); } +void +test07() +{ + // PR libstdc++/111550 + struct Five { + operator int() & { return 5; } + operator int() && = delete; + }; + auto take_five = views::take(Five{}); + auto r = take_five(views::iota(0)); + auto take_five_piped = views::take(Five{}) | views::transform(std::identity{}); + auto s = take_five_piped(views::iota(0)); +} + int main() { @@ -127,4 +141,5 @@ main() test04(); test05(); test06(); + test07(); } |
