aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
AgeCommit message (Collapse)AuthorFilesLines
44 hoursdocs: Adjust -Wimplicit-fallthrough= documentation for C23Jakub Jelinek1-1/+1
I've noticed in -Wimplicit-fallthrough= documentation we talk about [[fallthrough]]; for C++17 but don't mention that it is also standard way to suppress the warning for C23. 2025-09-16 Jakub Jelinek <jakub@redhat.com> * doc/invoke.texi (Wimplicit-fallthrough=): Document that also C23 provides a standard way to suppress the warning with [[fallthrough]];.
3 daysAVR: Support AVR32EB14/20/28/32.Georg-Johann Lay1-1/+1
Add support for some recent AVR devices. gcc/ * config/avr/avr-mcus.def: Add avr32eb14, avr32eb20, avr32eb28, avr32eb32. * doc/avr-mmcu.texi: Rebuild.
5 daystarget.def: Properly mark up __cxa_atexit as codeGerald Pfeifer1-3/+4
gcc: * target.def (dtors_from_cxa_atexit): Properly mark up __cxa_atexit as code. * doc/tm.texi: Regenerate.
5 daysdoc: Editorial changes around -fprofile-partial-trainingGerald Pfeifer1-10/+10
gcc: * doc/invoke.texi (Optimize Options): Editorial changes around -fprofile-partial-training.
6 daysmiddle-end: Use addhn for compression instead of inclusive OR when reducing ↵Tamar Christina2-0/+38
comparison values Given a sequence such as int foo () { #pragma GCC unroll 4 for (int i = 0; i < N; i++) if (a[i] == 124) return 1; return 0; } where a[i] is long long, we will unroll the loop and use an OR reduction for early break on Adv. SIMD. Afterwards the sequence is followed by a compression sequence to compress the 128-bit vectors into 64-bits for use by the branch. However if we have support for add halving and narrowing then we can instead of using an OR, use an ADDHN which will do the combining and narrowing. Note that for now I only do the last OR, however if we have more than one level of unrolling we could technically chain them. I will revisit this in another up coming early break series, however an unroll of 2 is fairly common. gcc/ChangeLog: * internal-fn.def (VEC_TRUNC_ADD_HIGH): New. * doc/generic.texi: Document it. * optabs.def (vec_trunc_add_high): New. * doc/md.texi: Document it. * tree-vect-stmts.cc (vectorizable_early_exit): Use addhn if supported. gcc/testsuite/ChangeLog: * gcc.target/aarch64/vect-early-break-addhn_1.c: New test. * gcc.target/aarch64/vect-early-break-addhn_2.c: New test. * gcc.target/aarch64/vect-early-break-addhn_3.c: New test. * gcc.target/aarch64/vect-early-break-addhn_4.c: New test.
6 daysmiddle-end: clear the user unroll flag if the cost model has overriden itTamar Christina1-4/+5
If the user has requested loop unrolling through pragma GCC unroll then at the moment we only set LOOP_VINFO_USER_UNROLL if the vectorizer has not overrode the unroll factor (through backend costing) or if the VF made the requested unroll factor be 1. When we have a loop of say int and a pragma unroll 4 If the vectorizer picks V4SI as the mode, the requested unroll ended up exactly matching the VF. As such the requested unroll is 1 and we don't clear the pragma. So it did honor the requested unroll factor. However since we didn't set the unroll amount back and left it at 4 the rtl unroller won't use the rtl cost model at all and just unroll the vector loop 4 times. But of these events are costing related, and so it stands to reason that we should set LOOP_VINFO_USER_UNROLL to we return the RTL unroller to use the backend costing for any further unrolling. gcc/ChangeLog: * tree-vect-loop.cc (vect_analyze_loop_1): If the unroll pragma was set mark it as handled. * doc/extend.texi (pragma GCC unroll): Update documentation.
7 daysdoc: Correct the return type of float comparisonTrevor Gross1-24/+30
Documentation for `__cmpsf2` and similar functions currently indicate a return type of `int`. This is not correct however; the `libgcc` functions return `CMPtype`, the size of which is determined by the `libgcc_cmp_return` mode. Update documentation to use `CMPtype` and indicate that this is target-dependent, also mentioning the usual modes. Reported-by: beetrees <b@beetr.ee> Fixes: https://github.com/rust-lang/compiler-builtins/issues/919#issuecomment-2905347318 Signed-off-by: Trevor Gross <tmgross@umich.edu> * doc/libgcc.texi (Comparison functions): Document functions as returning CMPtype.
9 daysdoc: Adjust -Wextra description for -Wunterminated-string-initializationJonathan Wakely1-1/+1
Say that -Wunterminated-string-initialization is for C and ObjC only when it appears in the -Wextra documentation. gcc/ChangeLog: * doc/invoke.texi (Warning Options): Note that an option enabled by -Wextra is for C and ObjC only.
10 daysdoc: Document the -folding option for -fdump-tree-* [PR114892]Alex Coplan1-0/+3
I noticed that the -fdump-tree-*-folding flag isn't documented in the Developer options section of invoke.texi; this patch fixes that. gcc/ChangeLog: PR tree-optimization/114892 * doc/invoke.texi (Developer Options): Document -folding option for -fdump-tree-*.
10 daysdoc: Remove references to Binutils 2.7 requirementsGerald Pfeifer1-5/+1
GNU Binutils 2.7 was released in 1996, no realistic need to point it out as a minimal requirement. gcc: * doc/extend.texi (SH Function Attributes): Remove reference to GNU Binutils 2.7 requirement. (H8/300 Variable Attributes): Ditto.
12 daysdoc: drop verify-canonical-types=1 refSam James1-2/+1
--param verify-canonical-types was removed back in r0-81986-g7313518b90b280. The same verification is controlled via our generic checking framework these days. gcc/ChangeLog: * doc/generic.texi (TYPE_CANONICAL): Don't mention long-removed --param verify-canonical-types.
12 daysgcc: introduce the dep_fusion passArtemiy Volkov1-3/+12
Presently, the scheduler code only considers consecutive instructions for macro-op fusion (see sched-deps.cc::sched_macro_fuse_insns () for details). This patch introduces the new dep_fusion pass, which is intended to uncover more fusion opportunities by reordering eligible instructions to form fusible pairs (based solely on the value of the TARGET_SCHED_MACRO_FUSION_PAIR_P hook). This is achieved by using the RTL-SSA framework, and only the single-use instructions are considered for the first instruction of a pair. Aside from reordering instructions, this pass also sets the SCHED_GROUP flag for the second instruction so that following passes can implement special handling of the fused pairs. For instance, RA and regrename should make use of this information to preserve single-output property for some of such pairs. Accordingly, in passes.def, this patch adds two invocations of the new pass: just before IRA and just before regrename. The new pass is enabled at -O2+ and -Os. gcc/ChangeLog: * Makefile.in (OBJS): Add dep-fusion.o. * common.opt (fdep-fusion): Add option. * dep-fusion.cc: New pass. * doc/invoke.texi: Document it. * opts.cc (default_options_table): Enable it at -O2+ and -Os. * passes.def: Insert two instances of dep_fusion. * tree-pass.h (make_pass_dep_fusion): Declare new function.
12 daysdoc: fix -momit-leaf-frame-pointer typoSam James1-1/+1
For x86, the option is -momit-leaf-frame-pointer, not -fomit-leaf-frame-pointer. gcc/ChangeLog: * doc/invoke.texi (x86 Options): Fix '-momit-leaf-frame-pointer' typo.
12 daysinstall: Properly capitalize GNU BinutilsGerald Pfeifer1-12/+12
gcc: PR target/69374 * doc/install.texi (Prerequisites): Properly capitalize GNU Binutils. (Configuration): Ditto. (Building): Ditto. (Specific): Ditto.
12 daysdoc: consistently say 'whole-program' where appropriateSam James1-4/+4
Unchanged instances are deliberate. gcc/ChangeLog: * doc/invoke.texi: Say 'whole-program' consistently where appropriate.
12 daysdoc: consistently spell 'GNU Binutils'Sam James1-2/+2
gcc/ChangeLog: * doc/invoke.texi: Capitalize 'GNU Binutils' consistently.
12 daysdoc: update incremental link vs binutils informationSam James1-7/+6
GNU Binutils now supports linking LTO and non-LTO objects into a single mixed object file as of 2.44. Update the text to reflect this and fix some minor grammar issues while at it. gcc/ChangeLog: PR ipa/116410 * doc/invoke.texi (Link Options): Update -flinker-output= text to reflect GNU Binutils changes. Fix grammar.
14 daysoptab: Add optab for isnanWilco Dijkstra1-0/+6
Add an optab for isnan. This requires changes to the existing folding code to extend the interclass_mathfn infrastructure to support BUILT_IN_ISNAN. It now checks for a valid optab before emitting the generic expansion. There is no change if no optab is defined. Update documentation. gcc: * builtins.cc (interclass_mathfn_icode): Add support for isnan optab. (expand_builtin): Add BUILT_IN_ISNAN to expand isnan optab. (fold_builtin_interclass_mathfn): Expand BUILT_IN_ISNAN only after checking for a valid optab. (fold_builtin_classify): Move generic BUILT_IN_ISNAN expansion to fold_builtin_interclass_mathfn. (fold_builtin_1): For BUILT_IN_ISNAN first try fold_builtin_classify, then fold_builtin_interclass_mathfn. * optabs.def: Add isnan optab. * doc/md.texi: Document isnan.
2025-09-03RISC-V: Add basic XAndes vendor extension support.Kuan-Lin Chen1-0/+24
This patch add basic support for the following XAndes ISA extensions: XANDESPERF XANDESBFHCVT XANDESVBFHCVT XANDESVSINTLOAD XANDESVPACKFPH XANDESVDOT gcc/ChangeLog: * config/riscv/riscv-ext.def: Include riscv-ext-andes.def. * config/riscv/riscv-ext.opt (riscv_xandes_subext): New variable. (XANDESPERF) : New mask. (XANDESBFHCVT): Ditto. (XANDESVBFHCVT): Ditto. (XANDESVSINTLOAD): Ditto. (XANDESVPACKFPH): Ditto. (XANDESVDOT): Ditto. * config/riscv/t-riscv: Add riscv-ext-andes.def. * doc/riscv-ext.texi: Regenerated. * config/riscv/riscv-ext-andes.def: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/xandes/xandes-predef-1.c: New test. * gcc.target/riscv/xandes/xandes-predef-2.c: New test. * gcc.target/riscv/xandes/xandes-predef-3.c: New test. * gcc.target/riscv/xandes/xandes-predef-4.c: New test. * gcc.target/riscv/xandes/xandes-predef-5.c: New test. * gcc.target/riscv/xandes/xandes-predef-6.c: New test. Co-author: Lino Hsing-Yu Peng (linopeng@andestech.com) Co-author: Kai Kai-Yi Weng (kaiweng@andestech.com).
2025-09-02docs: Add NoOffload option flag to the internals manualAndrew Stubbs1-0/+6
The NoOffload flag was introduced recently (commit "Don't pass vector params through to offload targets"). gcc/ChangeLog: * doc/options.texi: Document NoOffload.
2025-09-02doc: Fix sort order for counted_by attributeJonathan Wakely1-79/+79
gcc/ChangeLog: * doc/extend.texi (Common Variable Attributes): Put counted_by in alphabetical order.
2025-09-01install: Fix spelling of "support" and "arithmetic"Jonathan Grant1-7/+7
gcc: * doc/install.texi (Configuration): Fix spelling of "support" and "floating-point arithmetic". Signed-off-by: Jonathan Grant <jg@jguk.org>
2025-09-01doc: Update perfwiki web addressGerald Pfeifer1-1/+1
gcc: * doc/invoke.texi (Optimize Options): Update the perfwiki web address.
2025-09-01install.texi: For amdgcn, update Newlib version recommendationTobias Burnus1-1/+2
Add two Newlib commits to the recommended Newlib version, fixing two other SIMD issues. Cf. PR target/121392 and Newlib Bug 33272. gcc/ChangeLog: PR target/121392 * doc/install.texi (amdgcn): Mention Newlib commit that fixes another SIMD issue.
2025-08-31install: Drop MinGW binaries download linkGerald Pfeifer1-2/+1
This has been unavailable for well over a year. gcc: * doc/install.texi (Binaries): Drop MinGW.
2025-08-30phiopt, math-opts: Adjust spaceship_replacement and optimize_spaceship for ↵Jakub Jelinek1-2/+2
recent libstdc++ changes [PR121698] libstdc++ changed its ABI in <compare> for C++20 recently (under the C++20 is still experimental rule). In addition to the -1, 0, 1 values for less, equal, greater it now uses -128 for unordered instead of former 2 and changes some of the operators, instead of checks like (_M_value & ~1) == _M_value in some cases it now uses _M_reverse() which is negation in unsigned char type + conversion back to the original type. _M_reverse() thus turns the -1, 0, 1, -128 values into 1, 0, -1, -128. Note libc++ uses value -127 instead of 2/-128. Now, the middle-end has some optimizations which rely on the particular implementation and don't optimize if not. One is optimize_spaceship which on some targets (currently x86, aarch64 and s390) attempts to use better comparison instructions (ideally just one floating point comparison to get all 4 possible outcomes plus some flag tests or magic instead of 2 or 3 floating point comparisons). This one can actually handle arbitrary int non-[-1,1] values for unordered but still has a default of 2. The patch changes that default to -128 so that even if something is expanded as branches if it is later during RTL optimizations determined to convert that into partial_ordering we get better code. The other optimization (phiopt one) is about optimizing (x <=> y) < 0 etc. into just x < y. This one actually relies on the exact unordered value (2) and has code to deal with that (_M_value & ~1) == _M_value kind of tests and whatever match.pd lowers it. So, this patch partially rewrites it to look for -128 instead of 2, drop those (_M_value & ~1) == _M_value pattern recognitions and instead introduces pattern recognition of _M_reverse(), i.e. cast to unsigned char, negation in that type and cast back to the original signed type. With all these changes we get back the desired optimizations for all the cases we could optimize previously (note, for HONOR_NANS case we don't try to optimize say (x <=> y) == 0 because the original will raise exception if either x or y is a NaN, while turning it into x == y will not, but (x <=> y) <= 0 is fine (x <= y), because it does raise those exceptions. 2025-08-30 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/121698 * tree-ssa-phiopt.cc (spaceship_replacement): Adjust to handle spaceship unordered value -128 rather than 2 and stmts from the new std::partial_order::_M_reverse() instead of (_M_value & ~1) == _M_value etc. * doc/md.texi (spaceship@var{m}4): Use -128 instead of 2. * tree-ssa-math-opts.cc (optimize_spaceship): Adjust comments that libstdc++ unordered value is -128 rather than 2 and use that as the default unordered value. * config/i386/i386-expand.cc (ix86_expand_fp_spaceship): Use GEN_INT (-128) instead of const2_rtx and adjust comment accordingly. * config/aarch64/aarch64.cc (aarch64_expand_fp_spaceship): Likewise. * config/s390/s390.cc (s390_expand_fp_spaceship): Likewise. * gcc.dg/pr94589-2.c: Adjust for expected unordered value -128 rather than 2 and negations in unsigned char instead of and with ~1 and comparison against original value. * gcc.dg/pr94589-4.c: Likewise. * gcc.dg/pr94589-5.c: Likewise. * gcc.dg/pr94589-6.c: Likewise.
2025-08-30doc: Improve markup for list of vector operatorsGerald Pfeifer1-2/+3
gcc: * doc/extend.texi (Vector Extensions): Improve markup for list of operators.
2025-08-30doc: Update Objective-C language referenceGerald Pfeifer1-3/+2
gcc: * doc/standards.texi (Standards): Update "Object-Oriented Programming and the Objective-C Language" reference.
2025-08-29PR modula2/121709: Failed bootstrap in m2Gaius Mulley1-2/+6
This patch is a followup to PR modula2/121629 which uses the cpp_include_defaults array to configure the default search path entries. In particular it creates default search paths based on LOCAL_INCLUDE_DIR, PREFIX_INCLUDE_DIR, gcc version path and NATIVE_SYSTEM_HEADER_DIR. gcc/m2/ChangeLog: PR modula2/121709 * gm2-lang.cc (concat_component): New function. (find_cpp_entry): Ditto. (lookup_cpp_default): Ditto. (add_default_include_paths): Rewrite. (m2_pathname_root): Remove. gcc/ChangeLog: PR modula2/121709 * doc/gm2.texi (Module Search Path): Reflect the new search order. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-08-29diagnostics: add GCC_DIAGNOSTICS_LOGDavid Malcolm1-0/+10
Whilst experimenting with PR diagnostics/121039 (potentially capturing suppressed diagnostics in SARIF output), I found it very useful to have a text log from the diagnostic subsystem to track what it's doing and the decisions it's making (e.g. exactly when and why a diagnostic is being rejected). This patch adds a simple logging mechanism to the diagnostics subsystem, enabled by setting GCC_DIAGNOSTICS_LOG in the environment, which emits nested text like this to stderr (or a named file): warning (option_id: 668, gmsgid: "%<-Wformat-security%> ignored without %<-Wformat%>") diagnostics::context::diagnostic_impl (option_id: 668, kind: warning, gmsgid: "%<-Wformat-security%> ignored without %<-Wformat%>") diagnostics::context::report_diagnostic rejecting: diagnostic not enabled false <- diagnostics::context::diagnostic_impl false <- warning This logging mechanism doesn't use pretty_printer because it can be helpful to use it to debug pretty_printer itself. gcc/ChangeLog: * Makefile.in (OBJS-libcommon): Add diagnostics/logging.o. * diagnostic-global-context.cc: Include "diagnostics/logging.h". (log_function_params, auto_inc_log_depth): New "using" decls. (verbatim): Add logging. (emit_diagnostic): Likewise. (emit_diagnostic_valist): Likewise. (emit_diagnostic_valist_meta): Likewise. (inform): Likewise. (inform_n): Likewise. (warning): Likewise. (warning_at): Likewise. (warning_meta): Likewise. (warning_n): Likewise. (pedwarn): Likewise. (permerror): Likewise. (permerror_opt): Likewise. * diagnostics/context.cc: Include "diagnostics/logging.h". (context::initialize): Initialize m_logger. Add logging. (context::finish): Add logging. Clean up m_logger. (context::dump): Add indent param. (context::set_sink): Add logging. (context::add_sink): Add logging. (diagnostic_kind_debug_text): New. (get_debug_string_for_kind): New. (context::report_diagnostic): Add logging. (context::diagnostic_impl): Likewise. (context::diagnostic_n_impl): Likewise. (context::end_group): Likewise. * diagnostics/context.h: Include "diagnostics/logging.h". (context::dump): Add indent param. (context::get_logger): New accessor. (context::classify_diagnostics): Add logging. (context::push_diagnostics): Likewise. (context::pop_diagnostics): Likewise. (context::m_logger): New field. * diagnostics/html-sink.cc: Include "diagnostics/logging.h". (html_builder::flush_to_file): Add logging. (html_sink::on_report_diagnostic): Likewise. * diagnostics/kinds.h (get_debug_string_for_kind): New decl. * diagnostics/logging.cc: New file. * diagnostics/logging.h: New file. * diagnostics/output-file.h: Include "label-text.h". * diagnostics/sarif-sink.cc: Include "diagnostics/logging.h". (sarif_builder::flush_to_object): Add logging. (sarif_builder::flush_to_file): Likewise. (sarif_sink::on_report_diagnostic): Likewise. * diagnostics/sink.h (sink::get_logger): New. * diagnostics/text-sink.cc: Include "diagnostics/logging.h". (text_sink::on_report_diagnostic): Add logging. * doc/invoke.texi (Environment Variables): Document GCC_DIAGNOSTICS_LOG. * opts-diagnostic.cc: Include "diagnostics/logging.h". (handle_OPT_fdiagnostics_add_output_): Add loggging. (handle_OPT_fdiagnostics_set_output_): Likewise. gcc/analyzer/ChangeLog: * pending-diagnostic.cc: Include "diagnostics/logging.h". (diagnostic_emission_context::warn): Add logging. (diagnostic_emission_context::inform): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-29invoke.texi: AMD GCN - remove '(experimental)' from some gfx*-genericTobias Burnus1-3/+3
GCC added generic support in r15-7406-gb5a29a93ee29a8 (Feb 2025) with an '(experimental)' marker, also because ROCm only supported it in their git repository and not in a released version. Since ROCm 6.4 (Apr 2025), generic is also supported in released ROCm versions - and has been meanwhile tested by us. For architectures that have a well tested architecture, there is no reason that a binary, compiled for the associated generic architecture, performs any different to the specific version. Hence, this commit removes the marker for gfx-9-generic (gfx900, gfx906, gfx90c are known to work specific architectures), gfx10-3-generic (likewise for gfx1030 and gfx1036), and gfx11-generic (gfx1100 and gfx1103). gcc/ChangeLog: * doc/invoke.texi (AMD GCN Options: -march): Remove '(experimental)' from gfx-{9,10-3,11}-generic.
2025-08-29install.texi: For amdgcn, clarify which llvm-* binaries are requiredTobias Burnus1-3/+7
Also remove future tense for ROCm as 6.4.0 has been released in April 2025 and it supports generic architectures. gcc/ChangeLog: * doc/install.texi (amdgcn): Clarify which binaries must be the LLVM version and which must be installed. Update version data for ROCm for generic architectures.
2025-08-28Document -param=ix86-vect-unroll-limit.liuhongt1-0/+3
gcc/ChangeLog: * doc/invoke.texi: Document -param=ix86-vect-unroll-limit.
2025-08-28PR modula2/121629: adding third party modulesGaius Mulley1-15/+54
This patch makes it easier to add third party modules. cc1gm2 now appends the search directory prefix/include/m2 to the search path for non dialect specific modules. Prior to this it appends the dialect specific subdirectories {m2pim,m2iso,m2log,m2min} with the appropriate dialect pathname. The patch also includes a new option -fm2-pathname-root=prefix which allow additional prefix/m2 directories to be searched before the default. gcc/ChangeLog: PR modula2/121629 * doc/gm2.texi (Module Search Path): New section. (Compiler options): New option -fm2-pathname-root=. New option -fm2-pathname-rootI. gcc/m2/ChangeLog: PR modula2/121629 * gm2-compiler/PathName.mod: Add copyright notice. * gm2-lang.cc (named_path): Add field lib_root. (push_back_Ipath): Set lib_root false. (push_back_lib_root): New function. (get_dir_sep_size): Ditto. (add_path_component): Ditto. (add_one_import_path): Ditto. (add_non_dialect_specific_path): Ditto. (foreach_lib_gen_import_path): Ditto. (get_module_source_dir): Ditto. (add_default_include_paths): Ditto. (assign_flibs): Ditto. (m2_pathname_root): Ditto. (add_m2_import_paths): Remove function. (gm2_langhook_post_options): Call assign_flibs. Check np.lib_root and call foreach_lib_gen_import_path. Replace call to add_m2_import_paths with a call to add_default_include_paths. (gm2_langhook_handle_option): Add case OPT_fm2_pathname_rootI_. * gm2spec.cc (named_path): Add field lib_root. (push_back_Ipath): Set lib_root false. (push_back_lib_root): New function. (add_m2_I_path): Add OPT_fm2_pathname_rootI_ option if np.lib_root. (lang_specific_driver): Add case OPT_fm2_pathname_root_. * lang.opt (fm2-pathname-root=): New option. (fm2-pathname-rootI=): Ditto. gcc/testsuite/ChangeLog: PR modula2/121629 * gm2/switches/pathnameroot/pass/switches-pathnameroot-pass.exp: New test. * gm2/switches/pathnameroot/pass/test.mod: New test. * gm2/switches/pathnameroot/pass/testlib/m2/foo.def: New test. * gm2/switches/pathnameroot/pass/testlib/m2/foo.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-08-28[gcn] gcc/configure.ac + install.texi - changes to detect HAVE_AS_LEB128 ↵Tobias Burnus1-0/+1
[PR119367] The llvm-mc linker by default assemblies to another assembly file and not to an ELF binary; that usually does not matter – but for the LEB128 check, additionally, the resulting binary is checked. Hence, when using llvm-mc as target linker for amdgcn-*-*, we better add the "--filetype=obj -triple=amdgcn--amdhsa" flags. The current patch does so unconditionally, assuming that always llvm-mc is used. Additionally, the resulting ELF file is checked, which requires an ELF reader such as objdump. This commit adds llvm-objdump to the build documentation for amdgcn, albeit also, e.g., Binutil's 'objdump' would do - as long as either amdgcn-amdhsa-objdump or amdgcn-amdhsa/bin/objdump is found during the amdgcn cross build. gcc/ChangeLog: PR debug/119367 * acinclude.m4 (gcc_GAS_FLAGS): For gcn, use "--filetype=obj -triple=amdgcn--amdhsa", if supported. * configure: Regenerate. * doc/install.texi (amdgcn-*-*): Also add llvm-objdump to the list of to-be-copied files.
2025-08-25targhooks: i386: rename TAG_SIZE to TAG_BITSIZEIndu Bhagat2-2/+2
gcc/Changelog: * asan.h (HWASAN_TAG_SIZE): Use targetm.memtag.tag_bitsize. * config/i386/i386.cc (ix86_memtag_tag_size): Rename to ix86_memtag_tag_bitsize. (TARGET_MEMTAG_TAG_SIZE): Renamed to TARGET_MEMTAG_TAG_BITSIZE. * doc/tm.texi (TARGET_MEMTAG_TAG_SIZE): Likewise. * doc/tm.texi.in (TARGET_MEMTAG_TAG_SIZE): Likewise. * target.def (tag_size): Rename to tag_bitsize. * targhooks.cc (default_memtag_tag_size): Rename to default_memtag_tag_bitsize. * targhooks.h (default_memtag_tag_size): Likewise. Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com> Co-authored-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
2025-08-23i386: wire up --with-tls to control -mtls-dialect= defaultSam James1-0/+3
Allow passing --with-tls= at configure-time to control the default value of -mtls-dialect= for i386 and x86_64. The default itself (gnu) is not changed unless --with-tls= is passed. --with-tls= is already wired up for ARM and RISC-V. gcc/ChangeLog: PR target/120933 * config.gcc (supported_defaults): Add tls for i386, x86_64. * config/i386/i386.h (host_detect_local_cpu): Add tls. * doc/install.texi: Document --with-tls= for i386, x86_64.
2025-08-21pru: Add options to disable MUL/FILL/ZERO instructionsDimitar Dimitrov1-1/+9
Older PRU core versions (e.g. in AM1808 SoC) do not support XIN, XOUT, FILL, ZERO instructions. Add GCC command line options to optionally disable generation of those instructions, so that code can be executed on such older PRU cores. gcc/ChangeLog: * common/config/pru/pru-common.cc (TARGET_DEFAULT_TARGET_FLAGS): Keep multiplication, FILL and ZERO instructions enabled by default. * config/pru/pru.md (prumov<mode>): Gate code generation on TARGET_OPT_FILLZERO. (mov<mode>): Ditto. (zero_extendqidi2): Ditto. (zero_extendhidi2): Ditto. (zero_extendsidi2): Ditto. (@pru_ior_fillbytes<mode>): Ditto. (@pru_and_zerobytes<mode>): Ditto. (@<code>di3): Ditto. (mulsi3): Gate code generation on TARGET_OPT_MUL. * config/pru/pru.opt: Add mmul and mfillzero options. * config/pru/pru.opt.urls: Regenerate. * config/rl78/rl78.opt.urls: Regenerate. * doc/invoke.texi: Document new options. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2025-08-20Provide new option -fdiagnostics-show-context=N for -Warray-bounds, ↵Qing Zhao1-1/+18
-Wstringop-* warnings [PR109071,PR85788,PR88771,PR106762,PR108770,PR115274,PR117179] '-fdiagnostics-show-context[=DEPTH]' '-fno-diagnostics-show-context' With this option, the compiler might print the interesting control flow chain that guards the basic block of the statement which has the warning. DEPTH is the maximum depth of the control flow chain. Currently, The list of the impacted warning options includes: '-Warray-bounds', '-Wstringop-overflow', '-Wstringop-overread', '-Wstringop-truncation'. and '-Wrestrict'. More warning options might be added to this list in future releases. The forms '-fdiagnostics-show-context' and '-fno-diagnostics-show-context' are aliases for '-fdiagnostics-show-context=1' and '-fdiagnostics-show-context=0', respectively. For example: $ cat t.c extern void warn(void); static inline void assign(int val, int *regs, int *index) { if (*index >= 4) warn(); *regs = val; } struct nums {int vals[4];}; void sparx5_set (int *ptr, struct nums *sg, int index) { int *val = &sg->vals[index]; assign(0, ptr, &index); assign(*val, ptr, &index); } $ gcc -Wall -O2 -c -o t.o t.c t.c: In function ‘sparx5_set’: t.c:12:23: warning: array subscript 4 is above array bounds of ‘int[4]’ [-Warray-bounds=] 12 | int *val = &sg->vals[index]; | ~~~~~~~~^~~~~~~ t.c:8:18: note: while referencing ‘vals’ 8 | struct nums {int vals[4];}; | ^~~~ In the above, Although the warning is correct in theory, the warning message itself is confusing to the end-user since there is information that cannot be connected to the source code directly. It will be a nice improvement to add more information in the warning message to report where such index value come from. With the new option -fdiagnostics-show-context=1, the warning message for the above testing case is now: $ gcc -Wall -O2 -fdiagnostics-show-context=1 -c -o t.o t.c t.c: In function ‘sparx5_set’: t.c:12:23: warning: array subscript 4 is above array bounds of ‘int[4]’ [-Warray-bounds=] 12 | int *val = &sg->vals[index]; | ~~~~~~~~^~~~~~~ ‘sparx5_set’: events 1-2 4 | if (*index >= 4) | ^ | | | (1) when the condition is evaluated to true ...... 12 | int *val = &sg->vals[index]; | ~~~~~~~~~~~~~~~ | | | (2) warning happens here t.c:8:18: note: while referencing ‘vals’ 8 | struct nums {int vals[4];}; | ^~~~ PR tree-optimization/109071 PR tree-optimization/85788 PR tree-optimization/88771 PR tree-optimization/106762 PR tree-optimization/108770 PR tree-optimization/115274 PR tree-optimization/117179 gcc/ChangeLog: * Makefile.in (OBJS): Add diagnostic-context-rich-location.o. * common.opt (fdiagnostics-show-context): New option. (fdiagnostics-show-context=): New option. * diagnostic-context-rich-location.cc: New file. * diagnostic-context-rich-location.h: New file. * doc/invoke.texi (fdiagnostics-details): Add documentation for the new options. * gimple-array-bounds.cc (check_out_of_bounds_and_warn): Add one new parameter. Use rich location with details for warning_at. (array_bounds_checker::check_array_ref): Use rich location with ditails for warning_at. (array_bounds_checker::check_mem_ref): Add one new parameter. Use rich location with details for warning_at. (array_bounds_checker::check_addr_expr): Use rich location with move_history_diagnostic_path for warning_at. (array_bounds_checker::check_array_bounds): Call check_mem_ref with one more parameter. * gimple-array-bounds.h: Update prototype for check_mem_ref. * gimple-ssa-warn-access.cc (warn_string_no_nul): Use rich location with details for warning_at. (maybe_warn_nonstring_arg): Likewise. (maybe_warn_for_bound): Likewise. (warn_for_access): Likewise. (check_access): Likewise. (pass_waccess::check_strncat): Likewise. (pass_waccess::maybe_check_access_sizes): Likewise. * gimple-ssa-warn-restrict.cc (pass_wrestrict::execute): Calculate dominance info for diagnostics show context. (maybe_diag_overlap): Use rich location with details for warning_at. (maybe_diag_access_bounds): Use rich location with details for warning_at. gcc/testsuite/ChangeLog: * gcc.dg/pr109071.c: New test. * gcc.dg/pr109071_1.c: New test. * gcc.dg/pr109071_10.c: New test. * gcc.dg/pr109071_11.c: New test. * gcc.dg/pr109071_12.c: New test. * gcc.dg/pr109071_2.c: New test. * gcc.dg/pr109071_3.c: New test. * gcc.dg/pr109071_4.c: New test. * gcc.dg/pr109071_5.c: New test. * gcc.dg/pr109071_6.c: New test. * gcc.dg/pr109071_7.c: New test. * gcc.dg/pr109071_8.c: New test. * gcc.dg/pr109071_9.c: New test. * gcc.dg/pr117375.c: New test.
2025-08-18docs: Fix __builtin_object_size example [PR121581]Andrew Pinski1-1/+2
This example used to work (with C) in GCC 14 before the warning for different pointer types without a cast was changed to an error. The fix is to make the q variable `int*` rather than the current `char*`. This also fixes the example for C++ too. Pushed as obvious after doing a `make html`. PR middle-end/121581 gcc/ChangeLog: * doc/extend.texi (__builtin_object_size): Fix example. Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2025-08-18LoongArch: Add -m[no-]scq optionXi Ruoyao1-1/+10
We'll use the sc.q instruction for some 16-byte atomic operations, but it's only added in LoongArch 1.1 evolution so we need to gate it with an option. gcc/ChangeLog: * config/loongarch/genopts/isa-evolution.in (scq): New evolution feature. * config/loongarch/loongarch-evolution.cc: Regenerate. * config/loongarch/loongarch-evolution.h: Regenerate. * config/loongarch/loongarch-str.h: Regenerate. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch.opt.urls: Regenerate. * config/loongarch/loongarch-def.cc: Make -mscq the default for -march=la664 and -march=la64v1.1. * doc/invoke.texi (LoongArch Options): Document -m[no-]scq.
2025-08-16x86: Add target("80387") function attributeH.J. Lu1-0/+5
Add target("80387") attribute to enable and disable x87 instructions in a function. gcc/ PR target/121541 * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Add target("80387") attribute. Set the mask bit in opts_set->x_target_flags if the mask bit in opts->x_target_flags is updated. * doc/extend.texi: Document target("80387") function attribute. gcc/testsuite/ PR target/121541 * gcc.target/i386/pr121541-1a.c: New test. * gcc.target/i386/pr121541-1b.c: Likewise. * gcc.target/i386/pr121541-2.c: Likewise. * gcc.target/i386/pr121541-3.c: Likewise. * gcc.target/i386/pr121541-4.c: Likewise. * gcc.target/i386/pr121541-5a.c: Likewise. * gcc.target/i386/pr121541-5b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-08-15c++: Implement __builtin_structured_binding_size traitJakub Jelinek1-0/+6
clang++ apparently added a SFINAE-friendly __builtin_structured_binding_size trait to return the structured binding size (or error if not in SFINAE contexts if a type doesn't have a structured binding size). The expansion statement patch already anticipated this through adding complain argument to cp_finish_decomp. The following patch implements it. 2025-08-15 Jakub Jelinek <jakub@redhat.com> gcc/ * doc/extend.texi (Type Traits): Document __builtin_structured_binding_size. gcc/cp/ * cp-trait.def (STRUCTURED_BINDING_SIZE): New unary trait. * cp-tree.h (finish_structured_binding_size): Declare. * semantics.cc (trait_expr_value): Handle CPTK_STRUCTURED_BINDING_SIZE. (finish_structured_binding_size): New function. (finish_trait_expr): Handle CPTK_RANK and CPTK_TYPE_ORDER in the switch instead of just doing break; for those and ifs at the end to handle them. Handle CPTK_STRUCTURED_BINDING_SIZE. * pt.cc (tsubst_expr): Likewise. * constraint.cc (diagnose_trait_expr): Likewise. * decl.cc (get_tuple_size): Use mce_true for maybe_const_value. (cp_decomp_size): Diagnose incomplete types not just if processing_template_decl, and use error_at instead of pedwarn. If btype is NULL, just return 0 instead of diagnosing an error. gcc/testsuite/ * g++.dg/cpp26/expansion-stmt15.C: Expect different diagnostics for zero size destructuring expansion statement. * g++.dg/ext/builtin-structured-binding-size1.C: New test. * g++.dg/ext/builtin-structured-binding-size2.C: New test. * g++.dg/ext/builtin-structured-binding-size3.C: New test. * g++.dg/ext/builtin-structured-binding-size4.C: New test.
2025-08-15c++: Implement C++20 P1766R1 - Mitigating minor modules maladies [PR121552]Jakub Jelinek1-1/+23
The following patch attempts to implement the C++20 P1766R1 - Mitigating minor modules maladies paper. clang++ a few years ago introduced for the diagnostics required in the paper -Wnon-c-typedef-for-linkage pedwarn and the following patch does that too. The paper was accepted as a DR, the patch enables the warning also for C++98, dunno whether it might not be better to do it only for C++11 onwards. The paper is also about differences in default arguments of functions in different TUs and in modules, I think within the same TU we diagnose it correctly (maybe I should add some testcase) and perhaps try something with modules as well. But in different TUs it is IFNDR. 2025-08-15 Jakub Jelinek <jakub@redhat.com> PR c++/121552 gcc/ * doc/invoke.texi (-Wno-non-c-typedef-for-linkage): Document. gcc/c-family/ * c.opt (Wnon-c-typedef-for-linkage): New option. * c.opt.urls: Regenerate. gcc/cp/ * decl.cc: Implement C++20 P1766R1 - Mitigating minor modules maladies. (diagnose_non_c_class_typedef_for_linkage, maybe_diagnose_non_c_class_typedef_for_linkage): New functions. (name_unnamed_type): Call maybe_diagnose_non_c_class_typedef_for_linkage. gcc/testsuite/ * g++.dg/cpp2a/typedef1.C: New test. * g++.dg/debug/dwarf2/typedef5.C: Add -Wno-non-c-typedef-for-linkage to dg-options. * g++.dg/inherit/typeinfo1.C: Add -Wno-non-c-typedef-for-linkage to dg-additional-options. * g++.dg/parse/ctor2.C: Likewise. * g++.dg/ext/anon-struct9.C: Add -Wno-non-c-typedef-for-linkage to dg-options. * g++.dg/ext/visibility/anon11.C: Add -Wno-non-c-typedef-for-linkage to dg-additional-options. * g++.dg/lto/pr69137_0.C: Add -Wno-non-c-typedef-for-linkage to dg-lto-options. * g++.dg/other/anon8.C: Add -Wno-non-c-typedef-for-linkage to dg-additional-options. * g++.dg/template/pr84973.C: Likewise. * g++.dg/template/pr84973-2.C: Likewise. * g++.dg/template/pr84973-3.C: Likewise. * g++.dg/abi/anon2.C: Likewise. * g++.dg/abi/anon3.C: Likewise. * g++.old-deja/g++.oliva/linkage1.C: Likewise.
2025-08-15Extend "counted_by" attribute to pointer fields of structures. Convert a ↵Qing Zhao1-5/+36
pointer reference with counted_by attribute to .ACCESS_WITH_SIZE. Fix PR120929. For example: struct PP { size_t count2; char other1; char *array2 __attribute__ ((counted_by (count2))); int other2; } *pp; specifies that the "array2" is an array that is pointed by the pointer field, and its number of elements is given by the field "count2" in the same structure. In order to fix PR120929, we agreed on the following solution: for a pointer field with counted_by attribute: struct S { int n; int *p __attribute__((counted_by(n))); } *f; when generating call to .ACCESS_WITH_SIZE for f->p, instead of generating *.ACCESS_WITH_SIZE (&f->p, &f->n,...) We should generate .ACCESS_WITH_SIZE (f->p, &f->n,...) i.e., the return type and the type of the first argument of the call is the original pointer type in this version. However, this code generation might bring undefined behavior into the applicaiton if the call to .ACCESS_WITH_SIZE is generated for a pointer field reference when this refernece is written to. For example: f->p = malloc (size); ***** the IL for the above is: tmp1 = f->p; tmp2 = &f->n; tmp3 = .ACCESS_WITH_SIZE (tmp1, tmp2, ...); tmp4 = malloc (size); tmp3 = tmp4; In the above, in order to generate a call to .ACCESS_WITH_SIZE for the pointer reference f->p, the new GIMPLE tmp1 = f->p is necessary to pass the value of the pointer f->p to the call to .ACCESS_WITH_SIZE. However, this new GIMPLE is the one that brings UB into the application since the value of f->p is not initialized yet when it is assigned to "tmp1". the above IL will be expanded to the following when .ACCESS_WITH_SIZE is expanded to its first argument: tmp1 = f->p; tmp2 = &f->n; tmp3 = tmp1; tmp4 = malloc (size); tmp3 = tmp4; the final optimized IL will be: tmp3 = f->p; tmp3 = malloc (size);; As a result, the f->p will NOT be set correctly to the pointer returned by malloc (size). Due to this potential issue, We will need to selectively generate the call to .ACCESS_WITH_SIZE for f->p according to whether it's a read or a write. We will only generate call to .ACCESS_WITH_SIZE for f->p when it's a read in C FE. gcc/c-family/ChangeLog: * c-attribs.cc (handle_counted_by_attribute): Accept counted_by attribute for pointer fields. gcc/c/ChangeLog: * c-decl.cc (verify_counted_by_attribute): Change the 2nd argument to a vector of fields with counted_by attribute. Verify all fields in this vector. (finish_struct): Collect all the fields with counted_by attribute to a vector and pass this vector to verify_counted_by_attribute. * c-tree.h (handle_counted_by_for_component_ref): New prototype of handle_counted_by_form_component_ref. * c-parser.cc (c_parser_postfix_expression): Call the new prototype of handle_counted_by_for_component_ref. * c-typeck.cc (default_function_array_read_conversion): Only generate call to .ACCESS_WITH_SIZE for a pointer field when it's a read. (convert_lvalue_to_rvalue): Likewise. (default_conversion): Likewise. (handle_counted_by_p): New routine. (check_counted_by_attribute): New routine. (build_counted_by_ref): Handle pointers with counted_by. (build_access_with_size_for_counted_by): Handle pointers with counted_by. (handle_counted_by_for_component_ref): Add one more argument. (build_component_ref): Call the new prototype of handle_counted_by_for_component_ref. gcc/ChangeLog: * doc/extend.texi: Extend counted_by attribute to pointer fields in structures. Add one more requirement to pointers with counted_by attribute. gcc/testsuite/ChangeLog: * gcc.dg/flex-array-counted-by.c: Update test. * gcc.dg/pointer-counted-by-1.c: New test. * gcc.dg/pointer-counted-by-2.c: New test. * gcc.dg/pointer-counted-by-3.c: New test. * gcc.dg/pointer-counted-by-8.c: New test. * gcc.dg/pointer-counted-by-9.c: New test. * gcc.dg/pointer-counted-by.c: New test.
2025-08-15RISC-V: MIPS prefetch extensions for MIPS RV64 P8700 and can be enabled with ↵Umesh Kalappa1-0/+4
xmipscbop. Addressed the comments and tested "runtest --tool gcc --target_board='riscv-sim/-march=rv64gc_zba_zbb_zbc_zbs/-mabi=lp64/-mcmodel=medlow' riscv.exp" and 32 bit too lint warnings can be ignored for riscv-ext.opt. gcc/ChangeLog: * config/riscv/riscv-ext-mips.def (DEFINE_RISCV_EXT): Added mips prefetch extension. * config/riscv/riscv-ext.opt: Generated file. * config/riscv/riscv.md (prefetch): Added mips prefetch address operand constraint. * config/riscv/constraints.md: Added mips specific constraint. * config/riscv/predicates.md (prefetch_operand): Updated for mips nine bits offset. * config/riscv/riscv.cc (riscv_prefetch_offset_address_p): Legitimate address with offset for prefetch check. * config/riscv/riscv-protos.h: Likewise. * config/riscv/riscv.h: Macros to support for mips cached type. * doc/riscv-ext.texi: Updated for mips prefetch. gcc/testsuite/ChangeLog: * gcc.target/riscv/mipsprefetch.c: Test file for mips.pref.
2025-08-11Don't run tests requiring "B" on designs without "B"Jeff Law1-1/+7
So I resurrected our milkv pioneer over the weekend. While we had the tell-tale signs of PCIE switch issues, it actually appears that the NMVE drive was failing. I had an NVME that was going to be installed in a different system, so I threw it into the Pioneer as a last ditch effort to get it functional again. Voila! It's a happy camper (so far). Naturally I don't like manual testing, so cobbled together a new target for my tester. I forgot to update one field when doing that and as a result it picked up testsuite prior test results from the job that runs on the BPI. So comparing test results from a BPI to the Pioneer wouldn't normally be interesting. We'd expect to see a whole bunch of tests disappear as the Pioneer doesn't have all kinds of extensions that the BPI does (and that does indeed happen). As it turns out we have a handful of tests which need bitmanip to run, but which don't restrict themselves to only run on appropriate hardware. So we might as well fix that. Given the Pioneer/BPI take 6/24 hours to cycle through respectively I just spot checked the testsuite changes. Pushing to the trunk. gcc/ * doc/sourcebuild.texi: Add riscv_b_ok and riscv_v_ok target selectors. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_riscv_b_ok): New. * gcc.target/riscv/pr116085.c: Use new target selector. * gcc.target/riscv/pr117690.c: Use new target selector. * gcc.target/riscv/pr120333.c: Use new target selector. * gcc.target/riscv/zba-shNadd-10.c: Use new target selector.
2025-08-08diagnostics: enable nested diagnostics by default [PR116253]David Malcolm1-9/+47
In GCC 15 I added an experimental nesting view in text sinks for hierarchical diagnostics, such as C++ template problems. This patch enables it for text sinks by default. The old behavior can be restored via -fno-diagnostics-show-nesting, which the patch also adds to -fdiagnostics-plain-output. The patch does not yet enable it for text sinks in sarif-replay. gcc/ChangeLog: PR diagnostics/116253 * common.opt (fdiagnostics-show-nesting): New option. (fdiagnostics-show-nesting-locations): New option. (fdiagnostics-show-nesting-levels): New option. * common.opt.urls: Regenerate. * diagnostics/context.cc (context::set_show_nesting): New. (context::set_show_nesting_locations): New. (context::set_show_nesting_levels): New. * diagnostics/context.h (context::set_show_nesting): New decl. (context::set_show_nesting_locations): New decl. (context::set_show_nesting_levels): New decl. * diagnostics/html-sink.cc: Tweak comment. * diagnostics/output-spec.cc (text_scheme_handler::make_sink): Rename "experimental-nesting" to "show-nesting" and enable by default. Rename "experimental-nesting-show-locations" to "show-nesting-locations". Rename "experimental-nesting-show-levels" to "show-nesting-levels". * diagnostics/sink.h (sink::dyn_cast_text_sink): New. * diagnostics/text-sink.h (text_sink::dyn_cast_text_sink): New. * doc/invoke.texi: Add -fdiagnostics-show-nesting, -fdiagnostics-show-nesting-locations, and -fdiagnostics-show-nesting-levels. Update for changes to output-spec.cc above. * lto-wrapper.cc (merge_and_complain): Ignore OPT_fdiagnostics_show_nesting, OPT_fdiagnostics_show_nesting_locations, and OPT_fdiagnostics_show_nesting_levels. (append_compiler_options): Likewise. (append_diag_options): Likewise. * opts-common.cc (decode_cmdline_options_to_array): Add "-fno-diagnostics-show-nesting" to -fdiagnostics-plain-output. * opts.cc (common_handle_option): Handle the new options. (gen_command_line_string): Ignore the new options. * toplev.cc (general_init): Call set_show_nesting, set_show_nesting_locations, and set_show_nesting_levels on global_dc. gcc/testsuite/ChangeLog: PR diagnostics/116253 * g++.dg/concepts/nested-diagnostics-1-truncated.C: Update for renamed keys to -fdiagnostics-set-output=text * g++.dg/concepts/nested-diagnostics-1.C: Likewise. * g++.dg/concepts/nested-diagnostics-2.C: Likewise. * gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c: New test. * gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c: New test. * gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c: Update for renamed keys to -fdiagnostics-set-output=text. * gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c: Likewise. * gcc.dg/plugin/diagnostic-test-nesting-text-indented.c: Likewise. * gcc.dg/plugin/plugin.exp: Add the new tests. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-08Add subsections for vectorization and OpenMP/OpenACC target hooksRichard Biener2-0/+20
Currently they are grouped under Addressing Modes which is quite misleading. gcc/ * doc/tm.texi.in: Add Vectorization and OpenMP and OpenACC sub-sections to the list of target macros and functions. * doc/tm.texi: Re-generate.
2025-08-07c++, c: Introduce -Wkeyword-macro warning/pedwarn - part of C++26 P2843R3 ↵Jakub Jelinek1-0/+9
[PR120778] The following patch introduces a -Wkeyword-macro warning that clang has since 2014 to implement part of C++26 P2843R3 Preprocessing is never undefined paper. The relevant change in the paper is moving [macro.names]/2 paragraph to https://eel.is/c++draft/cpp.replace.general#9 : "A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table 4, or to the attribute-tokens described in [dcl.attr], except that the names likely and unlikely may be defined as function-like macros." Now, my understanding of the paper is that in [macro.names] and surrounding sections the word shall bears different meaning from [cpp.replace.general], where only the latter location implies ill-formed, diagnostic required. The warning in clang when introduced diagnosed all #define/#undef directives on keywords, but shortly after introduction has been changed not to diagnose #undef at all (with "#undef a keyword is generally harmless but used often in configuration scripts" message) and later on even the #define part tweaked - not warn about say #define inline (or const, extern, static), or #define keyword keyword or #define keyword __keyword or #define keyword __keyword__ Later on the warning has been moved to be only pedantic diagnostic unless requested by users. Clearly some code in the wild does e.g. #define private public and similar games, or e.g. Linux kernel (sure, C) does #define inline __inline__ __attribute__((__always_inline__)) etc. Now, I believe at least with the current C++26 wording such exceptions aren't allowed (unless it is changed to IFNDR). But given that this is just pedantic stuff, the following patch makes the warning off by default for C and C++ before C++26 and even for C++26 it enables it by default only if -pedantic/-pedantic-errors (in that case it pedwarns, otherwise it warns). And it diagnoses both #define and #undef without exceptions. From what I can see, all the current NODE_WARN cases are macros starting with __ with one exception (_Pragma). As the NODE_* flags seem to be a limited resource, I chose to just use NODE_WARN as well and differentiate on the node names (if they don't start with __ or _P, they are considered to be -Wkeyword-macro registered ones, otherwise old NODE_WARN cases, typically builtin macros or __STDC* macros). 2025-08-07 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 gcc/ * doc/invoke.texi (Wkeyword-macro): Document. gcc/c-family/ * c.opt (Wkeyword-macro): New option. * c.opt.urls: Regenerate. * c-common.h (cxx_dialect): Comment formatting fix. * c-opts.cc (c_common_post_options): Default to -Wkeyword-macro for C++26 if pedantic. gcc/c/ * c-decl.cc (c_init_decl_processing): Mark cpp nodes corresponding to keywords as NODE_WARN if warn_keyword_macro. gcc/cp/ * lex.cc (cxx_init): Mark cpp nodes corresponding to keywords, identifiers with special meaning and standard attribute identifiers as NODE_WARN if warn_keyword_macro. gcc/testsuite/ * gcc.dg/Wkeyword-macro-1.c: New test. * gcc.dg/Wkeyword-macro-2.c: New test. * gcc.dg/Wkeyword-macro-3.c: New test. * gcc.dg/Wkeyword-macro-4.c: New test. * gcc.dg/Wkeyword-macro-5.c: New test. * gcc.dg/Wkeyword-macro-6.c: New test. * gcc.dg/Wkeyword-macro-7.c: New test. * gcc.dg/Wkeyword-macro-8.c: New test. * gcc.dg/Wkeyword-macro-9.c: New test. * g++.dg/warn/Wkeyword-macro-1.C: New test. * g++.dg/warn/Wkeyword-macro-2.C: New test. * g++.dg/warn/Wkeyword-macro-3.C: New test. * g++.dg/warn/Wkeyword-macro-4.C: New test. * g++.dg/warn/Wkeyword-macro-5.C: New test. * g++.dg/warn/Wkeyword-macro-6.C: New test. * g++.dg/warn/Wkeyword-macro-7.C: New test. * g++.dg/warn/Wkeyword-macro-8.C: New test. * g++.dg/warn/Wkeyword-macro-9.C: New test. * g++.dg/warn/Wkeyword-macro-10.C: New test. * g++.dg/opt/pr82577.C: Don't #define register to nothing for C++17 and later. Instead define reg macro to nothing for C++17 and later or to register and use it instead of register. * g++.dg/modules/atom-preamble-3.C: Add -Wno-keyword-macro to dg-additional-options. * g++.dg/template/sfinae17.C (static_assert): Rename macro to ... (my_static_assert): ... this. (main): Use my_static_assert instead of static_assert. libcpp/ * include/cpplib.h (struct cpp_options): Add cpp_warn_keyword_macro. (enum cpp_warning_reason): Add CPP_W_KEYWORD_MACRO enumerator. (cpp_keyword_p): New inline function. * directives.cc (do_undef): Support -Wkeyword-macro diagnostics. * macro.cc (warn_of_redefinition): Ignore NODE_WARN flag on nodes registered for -Wkeyword-macro. (_cpp_create_definition): Support -Wkeyword-macro diagnostics. Formatting fixes.