aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-04-04Regenerate gcc.potJoseph Myers1-6960/+7235
* gcc.pot: Regenerate.
2025-04-04cobol: New testcases.Bob Dubner157-0/+4336
Derived from cobolworx UAT run_functions.at. gcc/testsuite * cobol.dg/group2/call_subprogram_using_pointer__passing_pointer.cob: New testcase. * cobol.dg/group2/FUNCTION_ABS.cob: Likewise. * cobol.dg/group2/FUNCTION_ACOS.cob: Likewise. * cobol.dg/group2/FUNCTION_ALL_INTRINSIC_simple_test.cob: Likewise. * cobol.dg/group2/FUNCTION_ANNUITY.cob: Likewise. * cobol.dg/group2/FUNCTION_as_CALL_parameter_BY_CONTENT.cob: Likewise. * cobol.dg/group2/FUNCTION_ASIN.cob: Likewise. * cobol.dg/group2/FUNCTION_ATAN.cob: Likewise. * cobol.dg/group2/FUNCTION_BIGGER-POINTER__2_.cob: Likewise. * cobol.dg/group2/FUNCTION_BIGGER-POINTER.cob: Likewise. * cobol.dg/group2/FUNCTION_BYTE-LENGTH.cob: Likewise. * cobol.dg/group2/FUNCTION_CHAR.cob: Likewise. * cobol.dg/group2/FUNCTION_COMBINED-DATETIME.cob: Likewise. * cobol.dg/group2/FUNCTION_CONCAT___CONCATENATE.cob: Likewise. * cobol.dg/group2/FUNCTION_CONCAT_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_COS.cob: Likewise. * cobol.dg/group2/FUNCTION_CURRENT-DATE.cob: Likewise. * cobol.dg/group2/FUNCTION_DATE-OF-INTEGER.cob: Likewise. * cobol.dg/group2/FUNCTION_DATE___TIME_OMNIBUS.cob: Likewise. * cobol.dg/group2/FUNCTION_DATE-TO-YYYYMMDD.cob: Likewise. * cobol.dg/group2/FUNCTION_DAY-OF-INTEGER.cob: Likewise. * cobol.dg/group2/FUNCTION_DAY-TO-YYYYDDD.cob: Likewise. * cobol.dg/group2/FUNCTION_E.cob: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-FILE.cob: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-STATEMENT.cob: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-STATUS.cob: Likewise. * cobol.dg/group2/FUNCTION_EXP10.cob: Likewise. * cobol.dg/group2/FUNCTION_EXP.cob: Likewise. * cobol.dg/group2/FUNCTION_FACTORIAL.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATE.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATETIME.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATE_TIME_DATETIME.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATETIME_with_ref_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATE_with_ref_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-TIME_DP.COMMA.cob: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-TIME_with_ref_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_FRACTION-PART.cob: Likewise. * cobol.dg/group2/FUNCTION_HEX-OF.cob: Likewise. * cobol.dg/group2/FUNCTION_HIGHEST-ALGEBRAIC.cob: Likewise. * cobol.dg/group2/FUNCTION_INTEGER.cob: Likewise. * cobol.dg/group2/FUNCTION_INTEGER-OF-DATE.cob: Likewise. * cobol.dg/group2/FUNCTION_INTEGER-OF-DAY.cob: Likewise. * cobol.dg/group2/FUNCTION_INTEGER-OF-FORMATTED-DATE.cob: Likewise. * cobol.dg/group2/FUNCTION_INTEGER-PART.cob: Likewise. * cobol.dg/group2/FUNCTION_LENGTH__1_.cob: Likewise. * cobol.dg/group2/FUNCTION_LENGTH__2_.cob: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-COMPARE.cob: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-DATE.cob: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-TIME.cob: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-TIME-FROM-SECONDS.cob: Likewise. * cobol.dg/group2/FUNCTION_LOG10.cob: Likewise. * cobol.dg/group2/FUNCTION_LOG.cob: Likewise. * cobol.dg/group2/FUNCTION_LOWER-CASE.cob: Likewise. * cobol.dg/group2/FUNCTION_LOWER-CASE_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_LOWEST-ALGEBRAIC.cob: Likewise. * cobol.dg/group2/FUNCTION_MAX.cob: Likewise. * cobol.dg/group2/FUNCTION_MEAN.cob: Likewise. * cobol.dg/group2/FUNCTION_MEDIAN.cob: Likewise. * cobol.dg/group2/FUNCTION_MIDRANGE.cob: Likewise. * cobol.dg/group2/FUNCTION_MIN.cob: Likewise. * cobol.dg/group2/FUNCTION_MOD__invalid_.cob: Likewise. * cobol.dg/group2/FUNCTION_MODULE-NAME.cob: Likewise. * cobol.dg/group2/FUNCTION_MOD__valid_.cob: Likewise. * cobol.dg/group2/FUNCTION_NUMVAL-C.cob: Likewise. * cobol.dg/group2/FUNCTION_NUMVAL-C_DP.COMMA.cob: Likewise. * cobol.dg/group2/FUNCTION_NUMVAL.cob: Likewise. * cobol.dg/group2/FUNCTION_NUMVAL-F.cob: Likewise. * cobol.dg/group2/FUNCTION_ORD.cob: Likewise. * cobol.dg/group2/FUNCTION_ORD-MAX.cob: Likewise. * cobol.dg/group2/FUNCTION_ORD-MIN.cob: Likewise. * cobol.dg/group2/FUNCTION_PI.cob: Likewise. * cobol.dg/group2/FUNCTION_PRESENT-VALUE.cob: Likewise. * cobol.dg/group2/FUNCTION_RANDOM.cob: Likewise. * cobol.dg/group2/FUNCTION_RANGE.cob: Likewise. * cobol.dg/group2/FUNCTION_REM__invalid_.cob: Likewise. * cobol.dg/group2/FUNCTION_REM__valid_.cob: Likewise. * cobol.dg/group2/FUNCTION_REVERSE.cob: Likewise. * cobol.dg/group2/FUNCTION_REVERSE_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_SECONDS-FROM-FORMATTED-TIME.cob: Likewise. * cobol.dg/group2/FUNCTION_SECONDS-PAST-MIDNIGHT.cob: Likewise. * cobol.dg/group2/FUNCTION_SIGN.cob: Likewise. * cobol.dg/group2/FUNCTION_SIN.cob: Likewise. * cobol.dg/group2/FUNCTION_SQRT.cob: Likewise. * cobol.dg/group2/FUNCTION_STANDARD-DEVIATION.cob: Likewise. * cobol.dg/group2/FUNCTION_SUBSTITUTE-CASE.cob: Likewise. * cobol.dg/group2/FUNCTION_SUBSTITUTE-CASE_with_reference_mod.cob: Likewise. * cobol.dg/group2/FUNCTION_SUBSTITUTE.cob: Likewise. * cobol.dg/group2/FUNCTION_SUBSTITUTE_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_SUM.cob: Likewise. * cobol.dg/group2/FUNCTION_TAN.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-DATE-YYYYMMDD.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-DAY-YYYYDDD__1_.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-DAY-YYYYDDD__2_.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-FORMATTED-DATETIME_additional.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-FORMATTED-DATETIME_DP.COMMA.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-FORMATTED-DATETIME_with_dates.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-FORMATTED-DATETIME_with_datetimes.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-FORMATTED-DATETIME_with_times.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-NUMVAL-C.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-NUMVAL.cob: Likewise. * cobol.dg/group2/FUNCTION_TEST-NUMVAL-F.cob: Likewise. * cobol.dg/group2/FUNCTION_TRIM.cob: Likewise. * cobol.dg/group2/FUNCTION_TRIM_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_TRIM_zero_length.cob: Likewise. * cobol.dg/group2/FUNCTION_UPPER-CASE.cob: Likewise. * cobol.dg/group2/FUNCTION_UPPER-CASE_with_reference_modding.cob: Likewise. * cobol.dg/group2/FUNCTION_VARIANCE.cob: Likewise. * cobol.dg/group2/FUNCTION_WHEN-COMPILED.cob: Likewise. * cobol.dg/group2/FUNCTION_YEAR-TO-YYYY.cob: Likewise. * cobol.dg/group2/Intrinsics_without_FUNCTION_keyword__2_.cob: Likewise. * cobol.dg/group2/Program-to-program_parameters_and_retvals.cob: Likewise. * cobol.dg/group2/Recursive_FUNCTION_with_local-storage.cob: Likewise. * cobol.dg/group2/Repository_functions_clause.cob: Likewise. * cobol.dg/group2/UDF_fibonacci_recursion.cob: Likewise. * cobol.dg/group2/UDF_in_COMPUTE.cob: Likewise. * cobol.dg/group2/UDF_RETURNING_group_and_PIC_9_5_.cob: Likewise. * cobol.dg/group2/UDF_with_recursion.cob: Likewise. * cobol.dg/group2/call_subprogram_using_pointer__passing_pointer.out: New known-good file. * cobol.dg/group2/FUNCTION_ABS.out: Likewise. * cobol.dg/group2/FUNCTION_ALL_INTRINSIC_simple_test.out: Likewise. * cobol.dg/group2/FUNCTION_as_CALL_parameter_BY_CONTENT.out: Likewise. * cobol.dg/group2/FUNCTION_BIGGER-POINTER__2_.out: Likewise. * cobol.dg/group2/FUNCTION_BIGGER-POINTER.out: Likewise. * cobol.dg/group2/FUNCTION_BYTE-LENGTH.out: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-FILE.out: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-STATEMENT.out: Likewise. * cobol.dg/group2/FUNCTION_EXCEPTION-STATUS.out: Likewise. * cobol.dg/group2/FUNCTION_FORMATTED-DATE_TIME_DATETIME.out: Likewise. * cobol.dg/group2/FUNCTION_HEX-OF.out: Likewise. * cobol.dg/group2/FUNCTION_LENGTH__2_.out: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-DATE.out: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-TIME-FROM-SECONDS.out: Likewise. * cobol.dg/group2/FUNCTION_LOCALE-TIME.out: Likewise. * cobol.dg/group2/FUNCTION_MAX.out: Likewise. * cobol.dg/group2/FUNCTION_MEAN.out: Likewise. * cobol.dg/group2/FUNCTION_MEDIAN.out: Likewise. * cobol.dg/group2/FUNCTION_MIDRANGE.out: Likewise. * cobol.dg/group2/FUNCTION_MIN.out: Likewise. * cobol.dg/group2/FUNCTION_MODULE-NAME.out: Likewise. * cobol.dg/group2/FUNCTION_NUMVAL-F.out: Likewise. * cobol.dg/group2/FUNCTION_ORD-MAX.out: Likewise. * cobol.dg/group2/FUNCTION_ORD-MIN.out: Likewise. * cobol.dg/group2/FUNCTION_ORD.out: Likewise. * cobol.dg/group2/FUNCTION_PRESENT-VALUE.out: Likewise. * cobol.dg/group2/FUNCTION_SUBSTITUTE.out: Likewise. * cobol.dg/group2/FUNCTION_TEST-DATE-YYYYMMDD.out: Likewise. * cobol.dg/group2/FUNCTION_TEST-DAY-YYYYDDD__1_.out: Likewise. * cobol.dg/group2/FUNCTION_TRIM.out: Likewise. * cobol.dg/group2/FUNCTION_TRIM_with_reference_modding.out: Likewise. * cobol.dg/group2/FUNCTION_TRIM_zero_length.out: Likewise. * cobol.dg/group2/Program-to-program_parameters_and_retvals.out: Likewise. * cobol.dg/group2/Recursive_FUNCTION_with_local-storage.out: Likewise. * cobol.dg/group2/Repository_functions_clause.out: Likewise. * cobol.dg/group2/UDF_fibonacci_recursion.out: Likewise. * cobol.dg/group2/UDF_in_COMPUTE.out: Likewise. * cobol.dg/group2/UDF_RETURNING_group_and_PIC_9_5_.out: Likewise. * cobol.dg/group2/UDF_with_recursion.out: Likewise.
2025-04-04c++: lambda in requires outside template [PR99546]Jason Merrill6-12/+61
Since r10-7441 we set processing_template_decl in a requires-expression so that we can use tsubst_expr to evaluate the requirements, but that confuses lambdas terribly; begin_lambda_type silently returns error_mark_node and we continue into other failures. This patch clears processing_template_decl again while we're defining the closure and op() function, so it only remains set while parsing the introducer (i.e. any init-captures) and building the resulting object. This properly avoids trying to create another lambda in tsubst_lambda_expr. PR c++/99546 PR c++/113925 PR c++/106976 PR c++/109961 PR c++/117336 gcc/cp/ChangeLog: * lambda.cc (build_lambda_object): Handle fake requires-expr processing_template_decl. * parser.cc (cp_parser_lambda_expression): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-requires2.C: New test. * g++.dg/cpp2a/lambda-requires3.C: New test. * g++.dg/cpp2a/lambda-requires4.C: New test. * g++.dg/cpp2a/lambda-requires5.C: New test.
2025-04-04libstdc++: Avoid redundant value_type object in flat_set::emplace [PR119620]Patrick Palka3-4/+58
flat_set::emplace (and flat_multiset's) currently unconditionally constructs an object outside of the container, but if we're passed a value_type object we can and should avoid that. PR libstdc++/119620 libstdc++-v3/ChangeLog: * include/std/flat_set (_Flat_set_impl::_M_try_emplace): Split out into two overloads, one taking at least one argument and one taking zero arguments. Turn __k into an auto&& reference bound to __arg if it's already a value_type and otherwise bound to a lifetime-extended value_type temporary. * testsuite/23_containers/flat_multiset/1.cc (test08): New test. * testsuite/23_containers/flat_set/1.cc (test08): New test. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-04-04lto: lto-opts fixes [PR119625]Jakub Jelinek1-21/+22
I can reproduce a really weird error in our distro i686 trunk gcc (but haven't managed to reproduce it with vanilla trunk yet). echo 'void foo (void) {}' > a.c; gcc -O2 -flto=auto -m32 -march=i686 -ffat-lto-objects -fhardened -o a.o -c a.c; gcc -O2 -flto=auto -m32 -march=i686 -r -o a.lo a.o lto1: fatal error: open failed: No such file or directory compilation terminated. lto-wrapper: fatal error: gcc returned 1 exit status The error is because cat ./a.lo.lto.o-args.0 "" a.o My suspicion is that this "" in there is caused by weird .gnu.lto_.opts section content during gcc -O2 -flto=auto -m32 -march=i686 -ffat-lto-objects -fhardened -S -o a.s -c a.c compilation (and I can reproduce that one with vanilla trunk). The above results in .section .gnu.lto_.opts,"e",@progbits .string "'-fno-openmp' '-fno-openacc' '-fPIC' '' '-m32' '-march=i686' '-O2' '-flto=auto' '-ffat-lto-objects'" There are two weird things, one (IMHO the cause of the "" later on) is the '' part, I think it comes from lto_write_options doing append_to_collect_gcc_options (&temporary_obstack, &first_p, ""); IMHO it shouldn't call append_to_collect_gcc_options at all for that case. The -fhardened option causes global_options.x_flag_cf_protection to be set to CF_FULL and later on the backend option processing sets it to CF_FULL | CF_SET (i.e. 7, a value not handled in lto_write_options). The following patch fixes it by not emitting anything there if flag_cf_protection is one of the unhandled values. Perhaps it could incrementally use switch (global_options.x_flag_cf_protection & ~CF_SET) instead, dunno. And the other problem is that the -fPIC in there is really weird. Our distro compiler or vanilla configured trunk certainly doesn't default to -fPIC and -fhardened uses -fPIE when -fPIC/-fpic/-fno-pie/-fno-pic is not specified, so I was expecting -fPIE in there. The thing is that the -fpie option causes setting of both global_options.x_flag_pi{c,e} to 1, -fPIE both to 2: /* If -fPIE or -fpie is used, turn on PIC. */ if (opts->x_flag_pie) opts->x_flag_pic = opts->x_flag_pie; else if (opts->x_flag_pic == -1) opts->x_flag_pic = 0; if (opts->x_flag_pic && !opts->x_flag_pie) opts->x_flag_shlib = 1; so checking first for flag_pic == 2 and then flag_pic == 1 and only afterwards for flag_pie means we never print -fPIE/-fpie. Or do you want something further (like switch (global_options.x_flag_cf_protection & ~CF_SET) )? 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR lto/119625 * lto-opts.cc (lto_write_options): If neither flag_pic nor flag_pie are set, check first for flag_pie and only later for flag_pic rather than the other way around, use a temporary variable. If flag_cf_protection is not set, don't append anything if flag_cf_protection is none of CF_{NONE,FULL,BRANCH,RETURN} and use a temporary variable.
2025-04-04profile: Another musttail fix [PR119618]Jakub Jelinek2-2/+24
As the following testcase shows, sometimes we can have debug stmts after a musttail call and profile.cc in that case would incorrectly allow the edge from that, causing musttail error and -fcompare-debug failure (because if there are no debug stmts after it, then musttail is found there and the edge is ignored). The following patch uses gsi_last_nondebug_bb instead of gsi_last_bb to find the musttail call. And so that we don't uselessly skip over debug stmts at the end of many bbs, the patch limits it to cfun->has_musttail functions. 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/119618 * profile.cc (branch_prob): Only check for musttail calls if cfun->has_musttail. Use gsi_last_nondebug_bb instead of gsi_last_bb. * c-c++-common/pr119618.c: New test.
2025-04-04tailc: Don't reject all tail calls if param has addr taken [PR119616]Jakub Jelinek2-14/+46
Before my PR119376 r15-9145 changes, suitable_for_tail_call_opt_p would return the same value in the same caller, regardless of the calls in it. If it fails, the caller clears opt_tailcalls which is a reference and therefore shared by all calls in the caller and we only do tail recursion, all non-recursive or tail recursion non-optimizable calls are not tail call optimized. For musttail calls we want to allow address taken parameters, but the r15-9145 change effectively resulted in the behavior where if there are just musttail calls considered, they will be tail call optimized, and if there are also other tail call candidates (without musttail), we clear opt_tailcall and then error out on all the musttail calls. The following patch fixes that by moving the address taken parameter discovery from suitable_for_tail_call_opt_p to its single caller. If there are addressable parameters, if !cfun->has_musttail it will work as before, disable all tail calls in the caller but possibly allow tail recursions. If cfun->has_musttail, it will set a new bool automatic flag and reject non-tail recursions. This way musttail calls can be still accepted and normal tail call candidates rejected (and tail recursions accepted). 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/119616 * tree-tailcall.cc (suitable_for_tail_call_opt_p): Move checking for addressable parameters from here ... (find_tail_calls): ... here. If cfun->has_musttail, don't clear opt_tailcalls for it, instead set a local flag and punt if we can't tail recurse optimize it. * c-c++-common/pr119616.c: New test.
2025-04-04cfgrtl: Remove REG_EH_REGION notes from tail calls [PR119613]Jakub Jelinek2-0/+32
In PR119491 r15-9154 I've allowed some useless EH regions for musttail calls (if there are no non-debug/clobber stmts before resx which resumes external throwing). Now, for -O1+ (but not -O0/-Og) there is a cleanup_eh pass after it which should optimize that way. The following testcase ICEs at -O0 though, the cleanup_eh in that case is before the musttail pass and dunno why it didn't actually optimize it away. The following patch catches that during expansion and just removes the note, which causes EH cleanups to do the rest. A tail call, even when it throws, will not throw while the musttail caller's frame is still on the stack, will throw after that and so REG_EH_REGION for it is irrelevant (like it would be never set before the r15-9154 changes). 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR middle-end/119613 * cfgrtl.cc (purge_dead_edges): Remove REG_EH_REGION notes from tail calls. * g++.dg/opt/pr119613.C: New test.
2025-04-04libgcobol: Check if the target needs libm.Iain Sandoe4-4/+148
Use the libtool config check and $(LIBM). libgcobol/ChangeLog: * Makefile.am: Use $(LIBM) to add the math lib when it is needed. * Makefile.in: Regenerate. * configure: Regenerate. * configure.ac: Check if the target wants libm. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-04-04cobol: Eliminate cobolworx UAT errors when compiling with -OsBob Dubner5-10/+52
Testcases compiled with -Os were failing because static functions and static variables were being optimized away, because of improper data type casts, and because strict aliasing (whatever that is) was resulting in some loss of data. These changes eliminate those known problems. gcc/cobol * cobol1.cc: (cobol_langhook_post_options): Implemented in order to set flag_strict_aliasing to zero. * genapi.cc: (set_user_status): Add comment. (parser_intrinsic_subst): Expand SHOW_PARSE information. (psa_global): Change names of return-code and upsi globals, (psa_FldLiteralA): Set DECL_PRESERVE_P for FldLiteralA. * gengen.cc: (show_type): Add POINTER type. (gg_define_function_with_no_parameters): Set DECL_PRESERVE_P for COBOL- style nested programs. (gg_array_of_bytes): Fix bad cast. libgcobol * charmaps.h: Change __gg__data_return_code to 'short' type. * constants.cc: Likewise.
2025-04-04rtlanal, i386: Adjust pattern_cost and x86 constant cost [PR115910]Jakub Jelinek3-2/+26
Below is an attempt to fix up RTX costing P1 caused by r15-775 https://gcc.gnu.org/pipermail/gcc-patches/2024-May/thread.html#652446 @@ -21562,7 +21562,8 @@ ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, if (x86_64_immediate_operand (x, VOIDmode)) *total = 0; else - *total = 1; + /* movabsq is slightly more expensive than a simple instruction. */ + *total = COSTS_N_INSNS (1) + 1; return true; case CONST_DOUBLE: change. In my understanding this was partially trying to workaround weird code in pattern_cost, which uses return cost > 0 ? cost : COSTS_N_INSNS (1); That doesn't make sense to me. All costs smaller than COSTS_N_INSNS (1) mean we need to have at least one instruction there which has the COSTS_N_INSNS (1) minimal cost. So special casing just cost 0 for the really cheap immediates which can be used pretty much everywhere but not ones which have just tiny bit larger cost than that (1, 2 or 3) is just weird. So, the following patch changes that to MAX (COSTS_N_INSNS (1), cost) which doesn't have this weird behavior where set_src_cost 0 is considered more expensive than set_src_cost 1. Note, pattern_cost isn't the only spot where costs are computed and normally we often sum the subcosts of different parts of a pattern or just query rtx costs of different parts of subexpressions, so the jump from 1 to 5 is quite significant. Additionally, x86_64 doesn't have just 2 kinds of constants with different costs, it has 3, signed 32-bit ones are the ones which can appear in almost all instructions and so using cost of 0 for those looks best, then unsigned 32-bit ones which can be done with still cheap movl instruction (and I think some others too) and finally full 64-bit ones which can be done only with a single movabsq instruction and are quite costly both in instruction size and even more expensive to execute. The following patch attempts to restore the behavior of GCC 14 with the pattern_cost hunk fixed for the unsigned 32-bit ones and only keeps the bigger cost for the 64-bit ones. 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR target/115910 * rtlanal.cc (pattern_cost): Return at least COSTS_N_INSNS (1) rather than just COSTS_N_INTNS (1) for cost <= 0. * config/i386/i386.cc (ix86_rtx_costs): Set *total to 1 for TARGET_64BIT x86_64_zext_immediate_operand constants. * gcc.target/i386/pr115910.c: New test.
2025-04-04c++: constraint variable used in evaluated context [PR117849]Patrick Palka2-0/+26
Here we wrongly reject the type-requirement at parse time due to its use of the constraint variable 't' within a template argument (an evaluated context). Fix this simply by refining the "use of parameter outside function body" error path to exclude constraint variables. PR c++/104255 tracks the same issue for function parameters, but fixing that would be more involved, requiring changes to the PARM_DECL case of tsubst_expr. PR c++/117849 gcc/cp/ChangeLog: * semantics.cc (finish_id_expression_1): Allow use of constraint variable outside an unevaluated context. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires41.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-04-04always turn return into __builtin_unreachable for noreturn fuctions [PR119599]Andrew Pinski3-9/+61
r8-3988-g356fcc67fba52b added code to turn return statements into __builtin_unreachable calls inside noreturn functions but only while optimizing. Since -funreachable-traps was added (r13-1204-gd68d3664253696), it is a good idea to move over to using __builtin_unreachable (and the trap version with this option which defaults at -O0 and -0g) instead of just a follow through even at -O0. This also fixes a regression when inlining a noreturn function that returns at -O0 (due to always_inline) as we would get an empty bb which has no successor edge instead of one with a call to __builtin_unreachable. I also noticed there was no testcase testing the warning about __builtin_return inside a noreturn function so I added a testcase there. Bootstrapped and tested on x86_64-linux-gnu. PR ipa/119599 gcc/ChangeLog: * tree-cfg.cc (pass_warn_function_return::execute): Turn return statements always into __builtin_unreachable calls. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr119599-1.c: New test. * gcc.dg/builtin-apply5.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-04c++, libcpp: Allow some left shifts in the preprocessor [PR119391]Jakub Jelinek2-5/+38
The libcpp left shift handling implements (partially) the C99-C23 wording where shifts are UB if shift count is negative, or too large, or shifting left a negative value or shifting left non-negative value results in something not representable in the result type (in the preprocessor case that is intmax_t). libcpp actually implements left shift by negative count as right shifts by negation of the count and similarly right shifts by negative count as left shifts by negation (not ok), sets overflow for too large shift count (ok), doesn't check for negative values on left shift (not ok) and checks correctly for the non-representable ones otherwise (ok). Now, C++11 to C++17 has different behavior, whereas in C99-C23 1 << 63 in preprocessor is invalid, in C++11-17 it is valid, but 3 << 63 is not. The wording is that left shift of negative value is UB (like in C) and signed non-negative left shift is UB if the result isn't representable in corresponding unsigned type (so uintmax_t for libcpp). And then C++20 and newer says all left shifts are well defined with the exception of bad shift counts. In -fsanitize=undefined we handle these by /* For signed x << y, in C99 and later, the following: (unsigned) x >> (uprecm1 - y) if non-zero, is undefined. */ and /* For signed x << y, in C++11 to C++17, the following: x < 0 || ((unsigned) x >> (uprecm1 - y)) if > 1, is undefined. */ Now, we are late in GCC 15 development, so I think making the preprocessor more strict than it is now is undesirable, so will defer setting overflow flag for the shifts by negative count, or shifts by negative value left. The following patch just makes some previously incorrectly rejected or warned cases valid for C++11-17 and even more for C++20 and later. 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/119391 * expr.cc (num_lshift): Add pfile argument. Don't set num.overflow for !num.unsignedp in C++20 or later unless n >= precision. For C++11 to C++17 set it if orig >> (precision - 1 - n) as logical shift results in value > 1. (num_binary_op): Pass pfile to num_lshift. (num_div_op): Likewise. * g++.dg/cpp/pr119391.C: New test.
2025-04-04arm: testsuite: restore dg-do-what-default in mve.expRichard Earnshaw1-0/+3
On Arm, running make check-gcc RUNTESTFLAGS="dwarf2.exp=pr43190.c" with a target list of "arm-qemu{,-mthumb}" results in no errors. But running it with make check-gcc RUNTESTFLAGS="{mve,dwarf2}.exp=pr43190.c" results in unresolved tests while running the thumb variant. The problem is that mve.exp is changing dg-do-what-default to "assemble", but failing to restore the original value once its tests are complete. The result is that all subsequent tests run with an incorrect underlying default value. The fix is easy - save dg-do-what-default and restore it after the tests are complete. gcc/testsuite/ChangeLog: * gcc.target/arm/mve/mve.exp: Save dg-do-what-default before changing it. Restore it once done.
2025-04-04libstdc++: Replace use of __mindist in ranges::uninitialized_xxx algos ↵Jonathan Wakely3-34/+71
[PR101587] In r15-8980-gf4b6acfc36fb1f I introduced a new function object for finding the smaller of two distances. In bugzilla Hewill Kang pointed out that we still need to explicitly convert the result back to the right difference type, because the result might be an integer-like class type that doesn't convert to an integral type explicitly. Rather than doing that conversion in the __mindist function object, I think it's simpler to remove it again and just do a comparison and assignment. We always want the result to have a specific type, so we can just check if the value of the other type is smaller, and then convert that to the other type if so. libstdc++-v3/ChangeLog: PR libstdc++/101587 * include/bits/ranges_uninitialized.h (__detail::__mindist): Remove. (ranges::uninitialized_copy, ranges::uninitialized_copy_n) (ranges::uninitialized_move, ranges::uninitialized_move_n): Use comparison and assignment instead of __mindist. * testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc: Check with ranges that use integer-like class type for difference type. * testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc: Likewise. Reviewed-by: Tomasz Kaminski <tkaminsk@redhat.com> Reviewed-by: Hewill Kang <hewillk@gmail.com>
2025-04-04libstdc++: Provide formatter for vector<bool>::reference [PR109162]Tomasz Kamiński8-21/+192
This patch implement formatter for vector<bool>::reference which is part of P2286R8. To indicate partial support we define __glibcxx_format_ranges macro value 1, without defining __cpp_lib_format_ranges. To avoid including the whole content of the <format> header, we introduce new bits/formatfwd.h forward declares classes required for newly introduce formatter. The signatures of the user-facing parse and format method of the provided formatters deviate from the standard by constraining types of params: * _Bit_reference instead T satisfying is-vector-bool-reference<T> * _CharT is constrained __formatter::__char * basic_format_parse_context<_CharT> for parse argument * basic_format_context<_Out, _CharT> for format second argument The standard specifies last three of above as unconstrained types, which leads to formattable<vector<bool>::reference, char32_t> (and any other type as char) being true. PR libstdc++/109162 libstdc++-v3/ChangeLog: * include/Makefile.am: Add bits/formatfwd.h. * include/Makefile.in: Add bits/formatfwd.h. * include/bits/version.def: Define __glibcxx_format_ranges without corresponding std name. * include/bits/version.h: Regenerate. * include/std/format (basic_format_context, __format::__char): Move declartions to bits/formatfwd.h. (formatter<_Tp, _CharT>): Remove default argument for _CharT parameter, now specified in forward declaration in bits/formatfwd.h. * include/std/vector (formatter<_Bit_reference, _CharT>): Define. * include/bits/formatfwd.h: New file with forward declarations for bits of std/format. * testsuite/23_containers/vector/bool/format.cc: New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-04Ada: Fix thinko in Eigensystem for complex Hermitian matricesEric Botcazou2-61/+66
The implementation solves the eigensystem for a NxN complex Hermitian matrix by first solving it for a 2Nx2N real symmetric matrix and then interpreting the 2Nx1 real vectors as Nx1 complex ones, but the last step does not work. The patch fixes the last step and also performs a small cleanup throughout the implementation, mostly in the commentary and without functional changes. gcc/ada/ * libgnat/a-ngcoar.adb (Eigensystem): Adjust notation and fix the layout of the real symmetric matrix in the main comment. Adjust the layout of the associated code accordingly and correctly turn the 2Nx1 real vectors into Nx1 complex ones. (Eigenvalues): Minor similar tweaks. * libgnat/a-ngrear.adb (Jacobi): Minor tweaks in the main comment. Adjust notation and corresponding parameter names of functions. Fix call to Unit_Matrix routine. Adjust the comment describing the various kinds of iterations to match the implementation.
2025-04-04libstdc++: Check feature test macro for std::string_view in <string>Jonathan Wakely2-34/+35
We can use the __glibcxx_string_view macro to guard the uses of std::string_view in <string>, instead of just checking the value of __cplusplus. It makes no practical difference because __glibcxx_string_view is defined for C++17 and up, but it makes it clear to readers that the lines guarded by that macro are features that depend on string_view. We could be more precise and check __glibcxx_string_view >= 201606L which is the value for the P0254R2 paper that integrated std::string_view with std::string, but I think just checking for the macro being defined is clear enough. We can also check __glibcxx_variant for the _Never_valueless_alt partial specialization. libstdc++-v3/ChangeLog: * include/bits/basic_string.h: Check __glibcxx_string_view and __glibcxx_variant instead of __cplusplus >= 2017L. * include/bits/cow_string.h: Likewise. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-04libstdc++: Fix whitespace in std::basic_string::_M_construct<bool>Jonathan Wakely1-2/+2
libstdc++-v3/ChangeLog: * include/bits/basic_string.tcc: Fix whitespace.
2025-04-04libstdc++: allow defining version FTMs without standard-named macrosArsen Arsenović2-3/+7
This is useful to provide libstdc++-internal-only macros. libstdc++-v3/ChangeLog: * include/bits/version.tpl: Implement no_stdname. * include/bits/version.def: Document no_stdname.
2025-04-04tailc: Use the IPA-VRP tail call hack even for pointers [PR119614]Jakub Jelinek4-1/+87
As the first two testcases show, even with pointers IPA-VRP can optimize return values from functions if they have singleton ranges into just the exact value, so we need to virtually undo that for tail calls similarly to integers and floats. The third test just adds check that it works even with floats (which it does). 2025-04-04 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/119614 * tree-tailcall.cc (find_tail_calls): Handle also pointer types in the IPA-VRP workaround. * c-c++-common/pr119614-1.c: New test. * c-c++-common/pr119614-2.c: New test. * c-c++-common/pr119614-3.c: New test.
2025-04-04Daily bump.GCC Administrator8-1/+239
2025-04-03libstdc++, nvptx: Remove machinery to inject per-file flagsThomas Schwinge2-6/+0
Not used anymore. libstdc++-v3/ * config/cpu/nvptx/t-nvptx: Remove. * configure.host [nvptx]: Adjust.
2025-04-03nvptx: Don't use PTX '.const', constant state space [PR119573]Thomas Schwinge4-15/+6
This avoids cases where a "File uses too much global constant data" (final executable, or single object file), and avoids cases of wrong code generation: "error : State space incorrect for instruction 'st'" ('st.const'), or another case where an "illegal instruction was encountered", or a lot of cases where for two compilation units (such as a library linked with user code) we ran into "error : Memory space doesn't match" due to differences in '.const' usage between definition and use of a variable. We progress: ptxas error : File uses too much global constant data (0x1f01a bytes, 0x10000 max) nvptx-run: cuLinkAddData failed: a PTX JIT compilation failed (CUDA_ERROR_INVALID_PTX, 218) ... into: PASS: 20_util/to_chars/103955.cc -std=gnu++17 (test for excess errors) [-FAIL:-]{+PASS:+} 20_util/to_chars/103955.cc -std=gnu++17 execution test We progress: ptxas error : File uses too much global constant data (0x36c65 bytes, 0x10000 max) nvptx-as: ptxas returned 255 exit status ... into: [-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c -O0 {+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c -O1 {+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c -O2 {+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c -O3 -g {+(test for excess errors)+} [-UNSUPPORTED:-]{+PASS:+} gcc.c-torture/compile/pr46534.c -Os {+(test for excess errors)+} [-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C -O0 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C -O1 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C -O2 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C -O3 -g (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/torture/pr31863.C -Os (test for excess errors) [-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-1.f90 -O0 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-1.f90 -O0 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-4.f90 -O0 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-4.f90 -O0 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} gfortran.dg/bind-c-contiguous-5.f90 -O0 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} gfortran.dg/bind-c-contiguous-5.f90 -O0 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} 20_util/to_chars/double.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} 20_util/to_chars/double.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} 20_util/to_chars/float.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} 20_util/to_chars/float.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} special_functions/13_ellint_3/check_value.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} special_functions/13_ellint_3/check_value.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} tr1/5_numerical_facilities/special_functions/14_ellint_3/check_value.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} tr1/5_numerical_facilities/special_functions/14_ellint_3/check_value.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} ..., and progress likewise, but fail later with an unrelated error: [-FAIL:-]{+PASS:+} ext/special_functions/hyperg/check_value.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+FAIL:+} ext/special_functions/hyperg/check_value.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [...]/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_value.cc:12317: void test(const testcase_hyperg<Ret> (&)[Num], Ret) [with Ret = double; unsigned int Num = 19]: Assertion 'max_abs_frac < toler' failed. ..., and: [-FAIL:-]{+PASS:+} tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc -std=gnu++17 (test for excess errors) [-UNRESOLVED:-]{+FAIL:+} tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc -std=gnu++17 [-compilation failed to produce executable-]{+execution test+} [...]/libstdc++-v3/testsuite/tr1/5_numerical_facilities/special_functions/17_hyperg/check_value.cc:12316: void test(const testcase_hyperg<Ret> (&)[Num], Ret) [with Ret = double; unsigned int Num = 19]: Assertion 'max_abs_frac < toler' failed. We progress: nvptx-run: error getting kernel result: an illegal instruction was encountered (CUDA_ERROR_ILLEGAL_INSTRUCTION, 715) ... into: PASS: g++.dg/cpp1z/inline-var1.C -std=gnu++17 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/cpp1z/inline-var1.C -std=gnu++17 execution test PASS: g++.dg/cpp1z/inline-var1.C -std=gnu++20 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/cpp1z/inline-var1.C -std=gnu++20 execution test PASS: g++.dg/cpp1z/inline-var1.C -std=gnu++26 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/cpp1z/inline-var1.C -std=gnu++26 execution test (A lot of '.const' -> '.global' etc. Haven't researched what the actual problem was.) We progress: ptxas /tmp/cc5TSZZp.o, line 142; error : State space incorrect for instruction 'st' ptxas /tmp/cc5TSZZp.o, line 174; error : State space incorrect for instruction 'st' ptxas fatal : Ptx assembly aborted due to errors nvptx-as: ptxas returned 255 exit status ... into: [-FAIL:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O0 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O0 [-compilation failed to produce executable-]{+execution test+} PASS: g++.dg/torture/builtin-clear-padding-1.C -O1 (test for excess errors) PASS: g++.dg/torture/builtin-clear-padding-1.C -O1 execution test [-FAIL:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O2 (test for excess errors) [-UNRESOLVED:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O2 [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O3 -g (test for excess errors) [-UNRESOLVED:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -O3 -g [-compilation failed to produce executable-]{+execution test+} [-FAIL:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -Os (test for excess errors) [-UNRESOLVED:-]{+PASS:+} g++.dg/torture/builtin-clear-padding-1.C -Os [-compilation failed to produce executable-]{+execution test+} This indeed tried to write ('st.const') into 's2', which was '.const' (also: 's1' was '.const') -- even though, no explicit 'const' in 'g++.dg/torture/builtin-clear-padding-1.C'; "interesting". We progress: error : Memory space doesn't match for '_ZNSt3tr18__detail12__prime_listE' in 'input file 3 at offset 53085', first specified in 'input file 1 at offset 1924' nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300) ... into execution test PASS for a few dozens of libstdc++ test cases. We progress: error : Memory space doesn't match for '_ZNSt6locale17_S_twinned_facetsE' in 'input file 11 at offset 479903', first specified in 'input file 9 at offset 59300' nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300) ... into: PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++17 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++17 execution test PASS: g++.dg/tree-ssa/pr20458.C -std=gnu++26 (test for excess errors) [-FAIL:-]{+PASS:+} g++.dg/tree-ssa/pr20458.C -std=gnu++26 execution test ..., and likewise for a few hundreds of libstdc++ test cases. We progress: error : Memory space doesn't match for '_ZNSt6locale5_Impl19_S_facet_categoriesE' in 'input file 11 at offset 821962', first specified in 'input file 10 at offset 676317' nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300) ... into execution test PASS for a hundred of libstdc++ test cases. We progress: error : Memory space doesn't match for '_ctype_' in 'input file 22 at offset 1698331', first specified in 'input file 9 at offset 57095' nvptx-run: cuLinkAddData failed: device kernel image is invalid (CUDA_ERROR_INVALID_SOURCE, 300) ... into execution test PASS for another few libstdc++ test cases. PR target/119573 gcc/ * config/nvptx/nvptx.cc (nvptx_encode_section_info): Don't set 'DATA_AREA_CONST' for 'TREE_CONSTANT', or 'TREE_READONLY'. (nvptx_asm_declare_constant_name): Use '.global' instead of '.const'. gcc/testsuite/ * gcc.c-torture/compile/pr46534.c: Don't 'dg-skip-if' nvptx. * gcc.target/nvptx/decl.c: Adjust. libstdc++-v3/ * config/cpu/nvptx/t-nvptx (AM_MAKEFLAGS): Don't amend.
2025-04-03c++: P2280R4 and speculative constexpr folding [PR119387]Patrick Palka1-3/+19
Compiling the testcase in this PR uses 2.5x more memory and 6x more time ever since r14-5979 which implements P2280R4. This is because our speculative constexpr folding now does a lot more work trying to fold ultimately non-constant calls to constexpr functions, and in turn produces a lot of garbage. We do sometimes successfully fold more thanks to P2280R4, but it seems to be trivial stuff like calls to std::array::size or std::addressof. The benefit of P2280 therefore doesn't seem worth the cost during speculative constexpr folding, so this patch restricts the paper to only manifestly-constant evaluation. PR c++/119387 gcc/cp/ChangeLog: * constexpr.cc (p2280_active_p): New. (cxx_eval_constant_expression) <case VAR_DECL>: Use it to restrict P2280 relaxations. <case PARM_DECL>: Likewise. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-04-03rs6000: Add Cobol support to traceback table [PR119308]Peter Bergner1-0/+2
The AIX traceback table documentation states the tbtab "lang" field for Cobol should be set to 7. Use it. 2025-04-03 Peter Bergner <bergner@linux.ibm.com> gcc/ PR target/119308 * config/rs6000/rs6000-logue.cc (rs6000_output_function_epilogue): Handle GCC COBOL for the tbtab lang field.
2025-04-03c++/modules: inline loaded at eofJason Merrill1-0/+13
std/format/string.cc and a few other libstdc++ tests were failing with module std with undefined references to __failed_to_parse_format_spec. This turned out to be because since r15-8012 we don't end up calling note_vague_linkage_fn for functions loaded after at_eof is set. But once import_export_decl decides on COMDAT linkage, we should be able to just clear DECL_EXTERNAL and let cgraph take it from there. I initially made this change in import_export_decl, but decided that for GCC 15 it would be safer to limit the change to modules. For GCC 16 I'd like to do away with DECL_NOT_REALLY_EXTERN entirely, it's been obsolete since cgraphunit in 2003. gcc/cp/ChangeLog: * module.cc (module_state::read_cluster) (post_load_processing): Clear DECL_EXTERNAL if DECL_COMDAT.
2025-04-03c++: operator!= rewriting and arg-dep lookupJason Merrill2-3/+57
When considering an op== as a rewrite target, we need to disqualify it if there is a matching op!= in the same scope. But add_candidates was assuming that we could use the same set of op!= for all op==, which is wrong if arg-dep lookup finds op== in multiple namespaces. This broke 20_util/optional/relops/constrained.cc if the order of the ADL set changed. gcc/cp/ChangeLog: * call.cc (add_candidates): Re-lookup ne_fns if we move into another namespace. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/spaceship-rewrite6.C: New test.
2025-04-03Doc: Clean up musttail attribute docs some moreSandra Loosemore1-23/+23
Looking over the recently-committed change to the musttail attribute documentation, it appears the comment in the last example was a paste-o, as it does not agree with either what the similar example in the -Wmaybe-musttail-local-addr documentation says, or the actual behavior observed when running the code. In addition, the entire section on musttail was in need of copy-editing to put it in the present tense, avoid reference to "the user", etc. I've attempted to clean it up here. gcc/ChangeLog * doc/extend.texi (Statement Attributes): Copy-edit the musttail attribute documentation and correct the comment in the last example.
2025-04-03vect: Relax scan-tree-dump strict pattern matching [PR118597]Victor Do Nascimento1-5/+3
Using specific SSA names in pattern matching in `dg-final' makes tests "unstable", in that changes in passes prior to the pass whose dump is analyzed in the particular test may change the numbering of the SSA variables, causing the test to start failing spuriously. We thus switch from specific SSA names to the use of a multi-line regular expression making use of capture groups for matching particular variables across different statements, ensuring the test will pass more consistently across different versions of GCC. PR testsuite/118597 gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-fncall-mask.c: Update test directives.
2025-04-03libgcobol: Provide fallbacks for C32 strfromf32/64 functions.Iain Sandoe4-2/+44
strfrom{f,d,l,fN) are all C23 and might not be available in general. This uses snprintf() to provide fall-backs where the libc does not yet have support. libgcobol/ChangeLog: * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Check for availability of strfromf32 and strfromf64. * libgcobol.cc (strfromf32, strfromf64): New. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-04-03libgcobol: Only use random_r if it is available [PR119295]Iain Sandoe4-7/+70
We do not have a replacement at the moment, so fall back to using regular random and friends. PR cobol/119295 libgcobol/ChangeLog: * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Configure random_r and friends * intrinsic.cc (__gg__random): Use random_r when available. (__gg__random_next): Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-04-03libgcobol: Ensure that config.h is included where needed.Iain Sandoe4-0/+9
This includes config.h before any other project-related headers or sources so that they properly make use of the values determined by configure. libgcobol/ChangeLog: * gfileio.cc: Include config.h. * gmath.cc: Likewise. * io.cc: Likewise. * libgcobol.cc: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-04-03cobol: New testcases for INSPECT statement.Bob Dubner41-0/+1475
gcc/testsuite * cobol.dg/group2/INSPECT_BACKWARD_REPLACING_LEADING.cob: New testcase. * cobol.dg/group2/INSPECT_BACKWARD_REPLACING_TRAILING.cob: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_CONVERTING.cob: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_REPLACING.cob: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_TALLYING.cob: Likewise. * cobol.dg/group2/INSPECT_CONVERTING_NULL.cob: Likewise. * cobol.dg/group2/INSPECT_CONVERTING_TO_figurative_constant.cob: Likewise. * cobol.dg/group2/INSPECT_CONVERTING_TO_figurative_constants.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_1.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_2.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_3.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_4.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5-f.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5-r.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_6.cob: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_7.cob: Likewise. * cobol.dg/group2/INSPECT_No_repeat_conversion_check.cob: Likewise. * cobol.dg/group2/INSPECT_REPLACING_figurative_constant.cob: Likewise. * cobol.dg/group2/INSPECT_REPLACING_LEADING_ZEROS_BY_SPACES.cob: Likewise. * cobol.dg/group2/INSPECT_TALLYING_AFTER.cob: Likewise. * cobol.dg/group2/INSPECT_TALLYING_BEFORE.cob: Likewise. * cobol.dg/group2/INSPECT_TALLYING_REPLACING_ISO_Example.cob: Likewise. * cobol.dg/group2/INSPECT_TRAILING.cob: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_REPLACING_LEADING.out: New known-good result. * cobol.dg/group2/INSPECT_BACKWARD_REPLACING_TRAILING.out: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_CONVERTING.out: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_REPLACING.out: Likewise. * cobol.dg/group2/INSPECT_BACKWARD_simple_TALLYING.out: Likewise. * cobol.dg/group2/INSPECT_CONVERTING_TO_figurative_constants.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_1.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_2.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_3.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_4.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5-f.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_5-r.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_6.out: Likewise. * cobol.dg/group2/INSPECT_ISO_Example_7.out: Likewise. * cobol.dg/group2/INSPECT_TALLYING_REPLACING_ISO_Example.out: Likewise. * cobol.dg/group2/INSPECT_TRAILING.out: Likewise.
2025-04-03libstdc++: Restored accidentally removed test case.Tomasz Kamiński1-0/+1
It was removed by accident r15-9178-g5c7f6272f43f42. libstdc++-v3/ChangeLog: * testsuite/std/format/functions/format.cc: Restored line.
2025-04-03libstdc++: Fix handling of field width for wide strings and characters ↵Tomasz Kamiński3-3/+23
[PR119593] This patch corrects handling of UTF-32LE and UTF32-BE in __unicode::__literal_encoding_is_unicode<_CharT>, so they are recognized as unicode and functions produces correct result for wchar_t. Use `__unicode::__field_width` to compute the estimated witdh of the charcter for unicode wide encoding. PR libstdc++/119593 libstdc++-v3/ChangeLog: * include/bits/unicode.h (__unicode::__literal_encoding_is_unicode<_CharT>): Corrected handing for UTF-16 and UTF-32 with "LE" or "BE" suffix. * include/std/format (__formatter_str::_S_character_width): Define. (__formatter_str::_S_character_width): Updated passed char length. * testsuite/std/format/functions/format.cc: Test for wchar_t. Reviewed-by: Jonathan Wakely <jwakely@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-03c++: Fix typo in RAW_DATA_CST build_list_conv subsubconv hanling [PR119563]Jakub Jelinek3-1/+143
The following testcase ICEs (the embed one actually doesn't but dereferences random uninitialized pointer far after allocated memory) because of a typo. In the RAW_DATA_CST handling of list conversion where there are conversions to something other than initializer_list<{{,un}signed ,}char>, the code now calls implicit_conversion for all the RAW_DATA_CST elements and stores them into subsubconvs array. The next loop (done in a separate loop because subsubconvs[0] is handled differently) attempts to do the for (i = 0; i < len; ++i) { conversion *sub = subconvs[i]; if (sub->rank > t->rank) t->rank = sub->rank; if (sub->user_conv_p) t->user_conv_p = true; if (sub->bad_p) t->bad_p = true; } rank/user_conv_p/bad_p merging, but I mistyped the index, the loop iterates with j iterator and i is subconvs index, so the loop effectively doesn't do anything interesting except for merging from one of the subsubconvs element, if lucky within the subsubconvs array, if unlucky not even from inside of the array. The following patch fixes that. 2025-04-03 Andrew Pinski <quic_apinski@quicinc.com> Jakub Jelinek <jakub@redhat.com> PR c++/119563 * call.cc (build_list_conv): Fix a typo in loop gathering summary information from subsubconvs. * g++.dg/cpp0x/pr119563.C: New test. * g++.dg/cpp/embed-26.C: New test.
2025-04-03Fix costs of x86 move instructions at -OsJan Hubicka1-26/+31
This patch fixes problem with size costs declaring all moves to have equal size (which was caught by the sanity check I tried in prologue move cost hook). Costs are relative to reg-reg move which is two. Coincidentally it is also size of the encoding, so the costs should represent typical size of move instruction. The patch reduces cc1plus text size 26391115->26205707 (0.7%) and similar changes also happens to other binaries build during bootstrap. Bootsrapped/regtested x86_64-linux, plan to commit it tomorrow if there are no complains There are other targets that define some load/store costs to be 2 that probably should be fixed too, but they are mostly very old ones and I don't have way of benchmarking them. * config/i386/x86-tune-costs.h (ix86_size_cost): Fix sizes of move instructions
2025-04-03testsuite: Remove guality xfails for aarch64*-*-*Christophe Lyon2-3/+3
Since r15-7878-ge1c49f413c8, these tests appear as XPASS on aarch64, so we can remove the xfails introduced by r12-102-gf31ddad8ac8f11. gcc/testsuite/ChangeLog: * gcc.dg/guality/pr90074.c: Remove xfail for aarch64. * gcc.dg/guality/pr90716.c: Likewise.
2025-04-03testsuite: i386: Fix gcc.target/i386/pr82142?.c etc. on Solaris/x86Rainer Orth3-3/+3
Three tests FAIL on Solaris/x86 in similar ways: FAIL: gcc.target/i386/pr111673.c check-function-bodies advance FAIL: gcc.target/i386/pr82142a.c check-function-bodies assignzero FAIL: gcc.target/i386/pr82142b.c check-function-bodies assignzero All tests FAIL as is because they lack either or both of the .LFB0 label and the .cfi_startproc directive: * The 32-bit pr82142b.c test lacks both, whether as or gas is in use: as lacks full support for the cfi directives and the .LFB0 label is only emitted with -fasynchronous-unwind-tables. * The 64-bit tests pr111673.c and pr82142a.c already work with gas, but with as the cfi directives are again missing. In addition, the 32-bit test (pr82142b.c) still FAILs because 32-bit Solaris/x86 defaults to -mstackrealign. To fix all this, this patch adds -fasynchronous-unwind-tables -fdwarf2-cfi-asm to all tests to force the generation of both the .LFB0 label and .cfi_startproc (which is ok since they are compile tests). In addition, pr82142b.c is compiled with -mno-stackrealign to avoid platform differences. Tested on i386-pc-solaris2.11 and x86_64-pc-linux-gnu. 2025-03-25 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> gcc/testsuite: * gcc.target/i386/pr111673.c (dg-options): Add -fasynchronous-unwind-tables -fdwarf2-cfi-asm. * gcc.target/i386/pr82142a.c: Likewise. * gcc.target/i386/pr82142b.c (dg-options): Add -mno-stackrealign -fasynchronous-unwind-tables -fdwarf2-cfi-asm.
2025-04-03c-family: Regenerate c.opt.urlsJakub Jelinek1-1/+1
On Sun, Mar 30, 2025 at 02:48:43PM +0200, Martin Uecker wrote: > The warning -Wzero-as-null-pointer-constant is now not only supported > in C++ but also in C. Change the documentation accordingly. This change didn't include make regenerate-opt-urls changes, because moving option documentation to different section can affect the *.urls files. 2025-04-03 Jakub Jelinek <jakub@redhat.com> * c.opt.urls: Regenerate.
2025-04-03fold-const, cobol: Add native_encode_wide_int and use it in COBOL FE [PR119242]Jakub Jelinek3-17/+26
As has been mentioned earlier, various parts of the COBOL FE and the library aren't endian clean. In the library that means that for now we have to live with no support for big endian targets, but in the FE that means that as well as not being able to build cross-compilers from big endian or pdp endian hosts to little endian targets which are otherwise supported. The following patch attempts to fix one such spot, where it wants to encode in target byte ordering wide_int constants into 1, 2, 4, 8 or 16 bytes. We could wide_int_to_tree and then native_encode_expr, but so that we don't need to build the constants, the following patch exports from fold-const.cc a helper for native_encode_int which takes type and const wide_int_ref reference rather than an expression. 2025-04-03 Jakub Jelinek <jakub@redhat.com> PR cobol/119242 gcc/ * fold-const.h (native_encode_wide_int): Declare. * fold-const.cc (native_encode_wide_int): New function. (native_encode_int): Use it. gcc/cobol/ * genapi.cc (binary_initial_from_float128): Use native_encode_wide_int.
2025-04-03[testsuite] [riscv] limit vwaddsub-1.c to rv64Alexandre Oliva1-1/+1
The desired vw{add,sub}.wx instructions don't come up on rv32 for the first two functions, we get v{add,sub}.vx instead. I suppose this is an oversight, and something about the test is meant for rv64 only, but the fact that the instruction is spelled out in the intrinsic name and a different instruction is generated suggests something may be wrong after all. for gcc/testsuite/ChangeLog * gcc.target/riscv/rvv/base/vwaddsub-1.c: Require rv64.
2025-04-03[testsuite] [riscv] limit mcpu-xiangshan-nanhu.c to rv64Alexandre Oliva1-2/+2
The testcase makes the -march option conditional on rv64, and #errors out if the desired CPU properties are not active. This makes the test fail on rv32. Arrange to skip the test on rv32 instead, moving the rv64 conditional. for gcc/testsuite/ChangeLog * gcc.target/riscv/mcpu-xiangshan-nanhu.c: Skip on non-rv64.
2025-04-03[testsuite] [riscv] xfail some [PR113281] testsAlexandre Oliva3-3/+3
Some of the tests regressed with a fix for the vectorization of shifts. The riscv cost models need to be adjusted to avoid the unprofitable optimization. The failure of these tests has been known since 2024-03-13, without a forthcoming fix, so I suggest we consider it expected by now. Adjust the tests to reflect that expectation. for gcc/testsuite/ChangeLog PR tree-optimization/113281 * gcc.dg/vect/costmodel/riscv/rvv/pr113281-1.c: XFAIL. * gcc.dg/vect/costmodel/riscv/rvv/pr113281-2.c: Likewise. * gcc.dg/vect/costmodel/riscv/rvv/pr113281-5.c: Likewise.
2025-04-03[testsuite] [riscv] xfail ssa-dom-cse-2 on riscv64Alexandre Oliva1-1/+1
For the same reasons that affect alpha and other targets, gcc.dg/tree-ssa/ssa-dom-cse-2.c fails to be optimized to the expected return statement: the array initializer is vectorized into pairs, and DOM cannot see through that. Add riscv*-*-* to the list of affected lp64 platforms. riscv32 is not affected. for gcc/testsuite/ChangeLog * gcc.dg/tree-ssa/ssa-dom-cse-2.c: XFAIL on riscv lp64.
2025-04-03LoongArch: Make gen-evolution.awk compatible with FreeBSD awkXi Ruoyao1-3/+5
Avoid using gensub that FreeBSD awk lacks, use gsub and split those each of gawk, mawk, and FreeBSD awk provides. Reported-by: mpysw@vip.163.com Link: https://man.freebsd.org/cgi/man.cgi?query=awk gcc/ChangeLog: * config/loongarch/genopts/gen-evolution.awk: Avoid using gensub that FreeBSD awk lacks.
2025-04-03APX: Emit nf variant for rotl splitter with mask [PR 119539]Hongyu Wang2-3/+25
For spiltter after *<rotate_insn><mode>3_mask it now splits the pattern to *<rotate_insn><mode>3_mask with flag reg clobber, and it doesn't generate nf variant of rotate. Directly emit nf pattern when TARGET_APX_NF enabled in these define_insn_and_split. gcc/ChangeLog: PR target/119539 * config/i386/i386.md (*<insn><mode>3_mask): Emit NF variant of rotate when APX_NF enabled, and use force_lowpart_subreg. (*<insn><mode>3_mask_1): Likewise. gcc/testsuite/ChangeLog: PR target/119539 * gcc.target/i386/apx-nf-pr119539.c: New test.
2025-04-03Doc: Clarify use of access attribute [PR101440]Sandra Loosemore1-19/+22
This issue was specifically about a confusing mention of the "second and third arguments to the memcpy function" when only the second one is a pointer affected by the attribute, but reading through the entire discussion I found other things confusing as well; e.g. in some cases it wasn't clear whether the "arguments" were the arguments to the attribute or the function, or exactly what a "positional argument" was. I've tried to rewrite that part to straighten it out, as well as some light copy-editing throughout. gcc/ChangeLog PR c/101440 * doc/extend.texi (Common Function Attributes): Clean up some confusing language in the description of the "access" attribute.