| Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
Follow-up to the Fortran patch r16-5633-g26d41e245dbba3, which (besides
other changes) added parser support for the 'dyn_groupprivate' clause to
the target directive.
This commit adds now the parser support to C/C++ and moves the
not-yet-implemented 'sorry' to the early middle end.
gcc/c-family/ChangeLog:
* c-omp.cc (c_omp_split_clauses): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE, sort target clauses
alphabetically.
* c-pragma.h (enum pragma_omp_clause): Add
PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_clause_dyn_groupprivate): New.
(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE;
sort clauses alphabetically.
(c_parser_omp_clause_name, c_parser_omp_all_clauses):
Handle 'dyn_groupprivate' clause.
* c-typeck.cc (c_finish_omp_clauses): Likewise.
gcc/cp/ChangeLog:
* pt.cc (tsubst_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE.
* semantics.cc (finish_omp_clauses): Likewise.
* parser.cc (cp_parser_omp_clause_dyn_groupprivate): New.
(cp_parser_omp_clause_name, cp_parser_omp_all_clauses):
Handle 'dyn_groupprivate' clause.
(OMP_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_DYN_GROUPPRIVATE;
sort clauses alphabetically.
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Permit zero with
DYN_GROUPPRIVATE clause.
* trans-openmp.cc (fallback): Generate TREE code
for DYN_GROUPPRIVATE and remove 'sorry'.
gcc/ChangeLog:
* gimplify.cc (gimplify_scan_omp_clauses): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE by printing 'sorry, unimplemented'.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DYN_GROUPPRIVATE.
(enum omp_clause_fallback_kind): New.
(struct tree_omp_clause): Add fallback_kind union member.
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree-pretty-print.cc (dump_omp_clause): Handle
OMP_CLAUSE_DYN_GROUPPRIVATE.
* tree.h (OMP_CLAUSE_DYN_GROUPPRIVATE_EXPR,
OMP_CLAUSE_DYN_GROUPPRIVATE_KIND): New #define.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/dyn_groupprivate-1.f90: Add scan-dump test.
* gfortran.dg/gomp/dyn_groupprivate-2.f90: Extend and update.
* c-c++-common/gomp/dyn_groupprivate-1.c: New test.
* c-c++-common/gomp/dyn_groupprivate-2.c: New test.
|
|
|
|
Looks like Jose forgot to one last regenerate of the opt.urls file.
Pushed as obvious after quickly looking to make sure they look decent.
gcc/ada/ChangeLog:
* gcc-interface/lang.opt.urls: Regenerate.
gcc/ChangeLog:
* algol68/lang.opt.urls: Regenerate.
gcc/c-family/ChangeLog:
* c.opt.urls: Regenerate.
gcc/cobol/ChangeLog:
* lang.opt.urls: Regenerate.
gcc/d/ChangeLog:
* lang.opt.urls: Regenerate.
gcc/fortran/ChangeLog:
* lang.opt.urls: Regenerate.
gcc/go/ChangeLog:
* lang.opt.urls: Regenerate.
gcc/m2/ChangeLog:
* lang.opt.urls: Regenerate.
gcc/rust/ChangeLog:
* lang.opt.urls: Regenerate.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
|
|
|
|
Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3628.txt>
These operators have not yet been accepted by the C Committee, so this
is implemented as a GNU extension.
gcc/ChangeLog:
* doc/extend.texi (Syntax Extensions): Document _Maxof & _Minof.
gcc/c-family/ChangeLog:
* c-common.cc (c_common_reswords): Add _Maxof & _Minof keywords.
(c_maxof_type, c_minof_type): New functions.
* c-common.def (MAXOF_EXPR, MINOF_EXPR): New trees.
* c-common.h (enum rid): Add RID_MAXOF & RID_MINOF constants.
(c_maxof_type, c_minof_type): New prototypes.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_maxof_or_minof_expression): New func.
(c_parser_unary_expression): Add RID_MAXOF & RID_MINOF cases.
* c-tree.h (c_expr_maxof_type): New prototype.
(c_expr_minof_type): New prototype.
* c-typeck.cc (c_expr_maxof_type): New function.
(c_expr_minof_type): New function.
gcc/testsuite/ChangeLog:
* gcc.dg/maxof-bitint.c: New test.
* gcc.dg/maxof-bitint575.c: New test.
* gcc.dg/maxof-compile.c: New test.
* gcc.dg/maxof-pedantic-errors.c: New test.
* gcc.dg/maxof-pedantic.c: New test.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
On Mon, Nov 03, 2025 at 01:34:28PM -0500, Marek Polacek via Gcc wrote:
> I would like us to declare that C++20 is no longer experimental and
> change the default dialect to gnu++20. Last time we changed the default
> was over 5 years ago in GCC 11:
> <https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=0801f419440c14f6772b28f763ad7d40f7f7a580>
> and before that in 2015 in GCC 6.1, so this happens roughly every 5 years.
>
> I had been hoping to move to C++20 in GCC 15 (see bug 113920), but at that time
> libstdc++ still had incomplete C++20 support and the compiler had issues to iron
> out (mangling of concepts, modules work, etc.). Are we ready now? Is anyone
> aware of any blockers? Presumably we still wouldn't enable Modules by default.
>
> I'm willing to do the work if we decide that it's time to switch the default
> C++ dialect (that includes updating cxx-status.html and adding a new caveat to
> changes.html).
I haven't seen a patch posted for this, so just that something is posted
during stage1 if we decide to do it, here is a patch.
The patch makes -std=gnu++20 the default C++ dialect and documents that
-fmodules is still not implied by that or -std=c++20 and modules support
is still experimental.
2025-11-26 Jakub Jelinek <jakub@redhat.com>
gcc/
* doc/invoke.texi (gnu++17): Remove comment about the default.
(c++20): Remove note about experimental support, except add a note
that modules are still experimental and need to be enabled separately.
(gnu++20): Likewise. Move here comment about the default.
(fcoroutines): Mention it is enabled by default for C++20 and later.
* doc/standards.texi: Document that the default for C++ is
-std=gnu++20.
gcc/c-family/
* c-opts.cc (c_common_init_options): Call set_std_cxx20 rather than
set_std_cxx17.
* c.opt (std=c++2a): Change description to deprecated option wording.
(std=c++20): Remove experimental support part.
(std=c++2b): Change description to deprecated option wording.
(std=gnu++2a): Likewise.
(std=gnu++20): Remove experimental support part.
(std=gnu++2b): Change description to deprecated option wording.
gcc/testsuite/
* lib/target-supports.exp: Set cxx_default to c++20 rather than
c++17.
* lib/g++-dg.exp (g++-std-flags): Reorder list to put 20 first
and 17 after 26.
* g++.dg/debug/pr80461.C (bar): Use v = v + 1; instead of ++v;.
* g++.dg/debug/pr94459.C: Add -std=gnu++17 to dg-options.
* g++.dg/diagnostic/virtual-constexpr.C: Remove dg-skip-if,
instead use { c++11 && c++17_down } effective target instead of
c++11.
* g++.dg/guality/pr67192.C: Add -std=gnu++17.
* g++.dg/torture/pr84961-1.C: Likewise.
* g++.dg/torture/pr84961-2.C: Likewise.
* g++.dg/torture/pr51482.C (anim_track_bez_wvect::tangent): Cast
key_class to int before multiplying it by float.
* g++.dg/torture/stackalign/unwind-4.C (foo): Use g_a = g_a + 1;
instead of g_a++;.
* g++.dg/tree-prof/partition1.C (bar): Use l = l + 1; return l;
instead of return ++l;.
* obj-c++.dg/exceptions-3.mm: Add -std=gnu++17.
* obj-c++.dg/exceptions-5.mm: Likewise.
libgomp/
* testsuite/libgomp.c++/atomic-12.C (main): Add ()s around array
reference index.
* testsuite/libgomp.c++/atomic-13.C: Likewise.
* testsuite/libgomp.c++/atomic-8.C: Likewise.
* testsuite/libgomp.c++/atomic-9.C: Likewise.
* testsuite/libgomp.c++/loop-6.C: Use count = count + 1;
return count > 0; instead of return ++count > 0;.
* testsuite/libgomp.c++/pr38650.C: Add -std=gnu++17.
* testsuite/libgomp.c++/target-lambda-1.C (merge_data_func):
Use [=,this] instead of just [=] in lambda captures.
* testsuite/libgomp.c-c++-common/target-40.c (f1): Use v += 1;
instead of v++;.
* testsuite/libgomp.c-c++-common/depend-iterator-2.c: Use v = v + 1;
instead of v++.
|
|
|
|
For simple testcases that want to use the std module, it would be useful to
have a reasonably short way to request building the binary module form
before the testcase. So with this patch users can write
g++ -std=c++20 -fmodules --compile-std-module mytest.C
I expect this to be particularly useful on godbolt.org, where currently
building a modules testcase requires messing with cmake. One complication
there is that just adding std.cc to the command line arguments hits the
"cannot specify -o with -S with multiple files" error, so I avoid counting
these added inputs as "multiple files"; in that situation each compile will
output to the same target file, with the user-specified input last so it's
the one that actually ends up in the target after the command completes.
gcc/c-family/ChangeLog:
* c.opt: Add --compile-std-module.
gcc/cp/ChangeLog:
* lang-specs.h: Add @c++-system-module.
* g++spec.cc (lang_specific_driver): Handle --compile-std-module.
gcc/ChangeLog:
* doc/invoke.texi: Document --compile-std-module.
* gcc.cc (struct infile): Add artificial field.
(add_infile): Set it.
(driver::prepare_infiles): Check it.
gcc/testsuite/ChangeLog:
* g++.dg/modules/compile-std1.C: New test.
* g++.dg/modules/modules.exp: Only run it once.
|
|
The following testcase ICEs, because
1) -fsanitize=bounds uses TYPE_MAX_VALUE (TYPE_DOMAIN (type)) with
1 or 2 added as last argument of .UBSAN_BOUNDS call and that
expression at that point is some NOP_EXPR around SAVE_EXPR with
testing for negative sizes
2) during gimplification, gimplify_type_sizes is invoked on the DECL_EXPR
outside of an OpenMP region, and forces TYPE_MAX_VALUE into
a pseudo instead, with the SAVE_EXPR obviously being evaluated
before that
3) the OpenMP gimplification sees an implicit or explicit data sharing
of a VLA and among other things arranges to firstprivatize TYPE_MAX_VALUE
4) when gimplifying the .UBSAN_BOUNDS call inside of the OpenMP region,
it sees a SAVE_EXPR and just gimplifies it to the already initialized
s.1 temporary; but nothing marks s.1 for firstprivatization on the
containing construct(s). The problem is that with SAVE_EXPR we never
know if the first use is within the same statement (typical use) or
somewhere earlier in the same OpenMP construct or in an outer OpenMP
construct or its parent etc., the SAVE_EXPR temporary is a function
local var, not something that is added to the innermost scope where
it is used (and it can't because it perhaps could be used outside of
it); so for OpenMP purposes, SAVE_EXPRs better should be used only
within the same OpenMP region and not across the whole function
The following patch fixes it by deferring the addition of
TYPE_MAX_VALUE in the last argument of .UBSAN_BOUNDS until gimplification
for VLAs, if it sees a VLA, instead of making the first argument
0 with pointer to the corresponding array type, it sets the first
argument to 1 with the same type and only sets the last argument to the
addend (1 or 2). And then gimplification can detect this case and
add the TYPE_MAX_VALUE (which in the meantime should have gone through
gimplify_type_sizes).
2025-11-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/120052
gcc/
* gimplify.cc (gimplify_call_expr): For IFN_UBSAN_BOUNDS
call with integer_onep first argument, change that argument
to 0 and add TYPE_MAX_VALUE (TYPE_DOMAIN (arr_type)) to
3rd argument before gimplification.
gcc/c-family/
* c-ubsan.cc (ubsan_instrument_bounds): For VLAs use
1 instead of 0 as first IFN_UBSAN_BOUNDS argument and only
use the addend without TYPE_MAX_VALUE (TYPE_DOMAIN (type))
in the 3rd argument.
gcc/testsuite/
* c-c++-common/gomp/pr120052.c: New test.
|
|
[PR122624]
The testcase in the PR is miscompiled on aarch64 with
--param=ggc-min-expand=0 --param=ggc-min-heapsize=0 -O2
(not including it in the testsuite because it is too much of
a lottery).
Anyway, the problem is that the testcase only uses unsigned _BitInt(66)
and never uses _BitInt(66), get_alias_set remembers alias set for
ARRAY_TYPE (of its element type in ARRAY_TYPE's TYPE_ALIAS_SET),
c_common_get_alias_set does not remember in TYPE_ALIAS_SET alias of
unsigned types and instead asks for get_alias_set of corresponding
signed type and that creates a new alias set for each new canonical
type.
So, in this case, when being asked about get_alias_set on ARRAY_TYPE
unsigned _BitInt(66) [N], it recurses down to c_common_get_alias_set
which asks for alias set of at that point newly created signed type
_BitInt(66), new alias set is created for it, remembered in that
signed _BitInt(66) TYPE_ALIAS_SET, not remembered in unsigned _BitInt(66)
and remembered in ARRAY_TYPE's TYPE_ALIAS_SET.
Next a GC collection comes, signed _BitInt(66) is not used anywhere in
any reachable from GC roots, so it is removed.
Later on we ask alias oracle whether the above mentioned ARRAY_TYPE
can for TBAA alias pointer dereference with the same unsigned _BitInt(66)
type. For the ARRAY_TYPE, we have the above created alias set remembered
in TYPE_ALIAS_SET, so that is what we use, but for the unsigned _BitInt(66)
we don't, so create a new signed _BitInt(66), create a new alias set for it
and that is what is returned, so we have to distinct alias sets and return
that they can't alias.
Now, for standard INTEGER_TYPEs this isn't a problem, because both the
signed and unsigned variants of those types are always reachable from GTY
roots. For BITINT_TYPE (or build_nonstandard_integer_type built types)
that isn't the case. I'm not convinced we need to fix it for
build_nonstandard_integer_type built INTEGER_TYPEs though, for bit-fields
their address can't be taken in C/C++, but for BITINT_TYPE this clearly
is a problem.
So, the following patch solves it by
1) remembering the alias set we got from get_alias_set on the signed
_BitInt(N) type in the unsigned _BitInt(N) type
2) returning -1 for unsigned _BitInt(1), because there is no corresponding
signed _BitInt type and so we can handle it normally
3) so that the signed _BitInt(N) type isn't later GC collected and later
readded with a new alias set incompatible with the still reachable
unsigned _BitInt(N) type, the patch for signed _BitInt(N) types checks
if corresponding unsigned _BitInt(N) type doesn't already have
TYPE_ALIAS_SET_KNOWN_P, in that case it remembers and returns that;
in order to avoid infinite recursion, it doesn't call get_alias_set
on the unsigned _BitInt(N) type though
4) while type_hash_canon remembers in the type_hash_table both the hash
and the type, so what exactly we use as the hash isn't that important,
I think using type_hash_canon_hash for BITINT_TYPEs is actually better over
hasing TYPE_MAX_VALUE, because especially for larger BITINT_TYPEs
TYPE_MAX_VALUE can have lots of HWIs in the number, for
type_hash_canon_hash hashes for BITINT_TYPEs only
i) TREE_CODE (i.e. BITINT_TYPE)
ii) TYPE_STRUCTURAL_EQUALITY_P flag (likely false)
iii) TYPE_PRECISION
iv) TYPE_UNSIGNED
so 3 ints and one flag, while the old way can hash one HWI up to
1024 HWIs; note it is also more consistent with most other
type_hash_canon calls, except for build_nonstandard_integer_type; for
some reason changing that one to use also type_hash_canon_hash doesn't
work, causes tons of ICEs
This version of the patch handles INTEGER_TYPEs the same as BITINT_TYPE.
2025-11-25 Jakub Jelinek <jakub@redhat.com>
PR middle-end/122624
* tree.cc (build_bitint_type): Use type_hash_canon_hash.
* c-common.cc (c_common_get_alias_set): Fix up handling of BITINT_TYPE
and non-standard INTEGER_TYPEs. For unsigned _BitInt(1) always return
-1. For other unsigned types set TYPE_ALIAS_SET to get_alias_set of
corresponding signed type and return that. For signed types check if
corresponding unsigned type has TYPE_ALIAS_SET_KNOWN_P and if so copy
its TYPE_ALIAS_SET and return that.
|
|
This fixes a permission error that occurs when cross-compiling with
-save-temps and a relocated toolchain, where the original build path
exists but is inaccessible.
The issue occurs when:
- Building the toolchain at /home/scratch/build/
- Installing it to another location like /home/user/rv64-toolchain/
- The /home/scratch directory exists but has insufficient permissions
(e.g. drwx------ for /home/scratch/)
Without this fix, cc1 would report errors like:
cc1: error: /home/scratch/build/install/riscv64-unknown-elf/usr/local/include: Permission denied
This occurred because the GCC driver did not pass GCC_EXEC_PREFIX and
isysroot to cc1/cc1plus in the compile stage when using -save-temps.
This caused cc1/cc1plus to search for headers from the wrong (original
build) path instead of the relocated installation path.
The fix ensures cc1/cc1plus won't try to collect include paths when
-fpreprocessed is specified. This prevents the permission error during
cross-compilation with -save-temps, as the preprocessed file already
contains all necessary headers.
gcc/c-family/ChangeLog:
* c-opts.cc (c_common_post_options): Skip register_include_chains
when cpp_opts->preprocessed is set.
|
|
|
|
This patch implements C++ support for the "begin declare variant"
construct. The OpenMP specification is hazy on interaction of this
feature with C++ language features. Variant functions in classes are
supported but must be defined as members in the class definition,
using an unqualified name for the base function which also must be
present in that class. Similarly variant functions in a namespace can
only be defined in that namespace using an unqualified name for a base
function already declared in that namespace. Variants for template
functions or inside template classes seem to (mostly) work.
gcc/c-family/ChangeLog
* c-omp.cc (c_omp_directives): Uncomment "begin declare variant"
and "end declare variant".
gcc/cp/ChangeLog
* cp-tree.h (struct cp_omp_declare_variant_attr): New.
(struct saved_scope): Add omp_declare_variant_attribute field.
* decl.cc (omp_declare_variant_finalize_one): Add logic to inject
"this" parameter for method calls.
* parser.cc (cp_parser_skip_to_pragma_omp_end_declare_variant): New.
(cp_parser_translation_unit): Handle leftover "begin declare variant"
functions.
(omp_start_variant_function): New.
(omp_finish_variant_function): New.
(omp_maybe_record_variant_base): New.
(cp_parser_init_declarator): Handle variant functions.
(cp_parser_class_specifier): Handle deferred lookup of base functions
when the entire class has been seen.
(cp_parser_member_declaration): Handle variant functions.
(cp_finish_omp_declare_variant): Merge context selectors if in
a "begin declare variant" block.
(cp_parser_omp_begin): Match "omp begin declare variant". Adjust
error messages.
(cp_parser_omp_end): Match "omp end declare variant".
* parser.h (struct omp_begin_declare_variant_map_entry): New.
(struct cp_parser): Add omp_begin_declare_variant_map field.
* semantics.cc (finish_translation_unit): Detect unmatched
"omp begin declare variant".
gcc/testsuite/ChangeLog
* g++.dg/gomp/delim-declare-variant-1.C: New.
* g++.dg/gomp/delim-declare-variant-2.C: New.
* g++.dg/gomp/delim-declare-variant-3.C: New.
* g++.dg/gomp/delim-declare-variant-4.C: New.
* g++.dg/gomp/delim-declare-variant-5.C: New.
* g++.dg/gomp/delim-declare-variant-6.C: New.
* g++.dg/gomp/delim-declare-variant-7.C: New.
* g++.dg/gomp/delim-declare-variant-40.C: New.
* g++.dg/gomp/delim-declare-variant-41.C: New.
* g++.dg/gomp/delim-declare-variant-50.C: New.
* g++.dg/gomp/delim-declare-variant-51.C: New.
* g++.dg/gomp/delim-declare-variant-52.C: New.
* g++.dg/gomp/delim-declare-variant-70.C: New.
* g++.dg/gomp/delim-declare-variant-71.C: New.
libgomp/
* testsuite/libgomp.c++/bdv_module1.C: New.
* testsuite/libgomp.c++/bdv_module1_main.C: New.
* testsuite/libgomp.c++/bdv_module2.C: New.
* testsuite/libgomp.c++/bdv_module2_impl.C: New.
* testsuite/libgomp.c++/bdv_module2_main.C: New.
* testsuite/libgomp.c++/bdv_module3.C: New.
* testsuite/libgomp.c++/bdv_module3_impl.C: New.
* testsuite/libgomp.c++/bdv_module3_main.C: New.
* testsuite/libgomp.c++/delim-declare-variant-1.C: New.
* testsuite/libgomp.c++/delim-declare-variant-2.C: New.
* testsuite/libgomp.c++/delim-declare-variant-7.C: New.
Co-Authored-By: Julian Brown <julian@codesourcery.com>
Co-Authored-By: waffl3x <waffl3x@baylibre.com>
|
|
|
|
No functional change intended.
gcc/c-family/ChangeLog:
* c-warn.cc (warn_parms_array_mismatch): Split out body of
per-pair in parameter lists iteration into...
(warn_parm_array_mismatch): ...this new function.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
No functional change intended.
gcc/c-family/ChangeLog:
* c-warn.cc (warn_parms_array_mismatch): Reduce scope of local
variable.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
gcc/analyzer/ChangeLog
PR other/122243
* analyzer.opt.urls: Regenerated.
gcc/c-family/ChangeLog
PR other/122243
* c.opt.urls: Regenerated.
gcc/cobol/ChangeLog
PR other/122243
* lang.opt.urls: Regenerated.
gcc/ChangeLog
PR other/122243
* common.opt.urls: Regenerated.
* config/dragonfly.opt.urls: Regenerated.
* config/freebsd.opt.urls: Regenerated.
* config/gcn/gcn.opt.urls: Regenerated.
* config/gnu-user.opt.urls: Regenerated.
gcc/fortran/ChangeLog
PR other/122243
* lang.opt.urls: Regenerated.
|
|
PR c/122591
gcc/c-family/ChangeLog:
* c-common.cc (c_countof_type): Convert return value to size_t.
gcc/testsuite/ChangeLog:
* gcc.dg/countof-compile.c (type): Test return type of _Countof.
Reported-by: Sam James <sam@gentoo.org>
Suggested-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
We have a number of command-line options that are undocumented (either
intentionally or because they are obsolete and retained only for
compatibility), that ought to be marked as "Undocumented". I've also
added some comments to the .opt files.
gcc/c-family/ChangeLog
PR other/122243
* c.opt (fmodule-version-ignore): Mark as "Undocumented".
gcc/ChangeLog
PR other/122243
* common.opt (fhelp, fhelp=, ftarget-help, fversion): Mark as
"Undocumented".
(fbounds-check): Update comments.
(flag-graphite, fsel-sched-reschedule-pipelined): Mark as
"Undocumented".
(fstack-limit): Add comment.
|
|
This patch adds the "RejectNegative" property to several options where
it doesn't make sense. These are either options of the form
"name=value" rather than an on/off switch, those that are already in a
"no-" form, or options that form a mutually-exclusive set.
Also, the fhelp, ftarget-help, and fversion options that do not take
arguments ignore the "-no" prefix so that even "-fno-help" (etc)
causes help to be printed instead of suppressing help output. Since that
behavior is not useful, I've added RejectNegative to those options as well.
gcc/analyzer/ChangeLog
PR other/122243
* analyzer.opt (fanalyzer-verbosity=): Add RejectNegative.
gcc/c-family/ChangeLog
PR other/122243
* c.opt: (fdeps-format=): Add RejectNegative.
(fdeps-file=): Likewise.
(fdeps-target=): Likewise.
(Walloc-size-larger-than=): Likewise.
(Wno-alloc-size-larger-than): Likewise.
(Walloca-larger-than=): Likewise.
(Wno-alloca-larger-than): Likewise.
(Woverloaded-virtual=): Likewise.
(Wvla-larger-than=): Likewise.
(Wno-vla-larger-than): Likewise.
(fopenacc-dim=): Likewise.
(femit-struct-debug-baseonly): Likewise.
(femit-struct-debug-reduced): Likewise.
(femit-struct-debug-detailed=): Likewise.
gcc/ChangeLog
PR other/122243
* common.opt (fhelp): Add RejectNegative.
(fhelp=): Likewise.
(ftarget-help): Likewise.
(fversion): Likewise.
(Wno-frame-larger-than): Likewise.
(Wno-larger-than): Likewise.
(Wno-stack-usage): Likewise.
(fdiagnostics-minimum-margin-width=): Likewise.
(flto-incremental=): Likewise.
(foffload=): Likewise.
(foffload-options=): Likewise.
(foffload-abi-host-opts=): Likewise.
(fpatchable-function-entry=): Likewise.
(gno-pubnames): Likewise.
(gpubnames): Likewise.
(ggnu-pubnames): Likewise.
|
|
gcc/c-family/ChangeLog
PR other/122243
* c.opt (Wsynth): Mark as "Ignore".
gcc/ChangeLog
PR other/122243
* common.opt (ftree-lrs): Mark as "Ignore".
|
|
Support a subset of C/C++ operations (bitwise, conditional etc.) on svbool_t.
gcc/c-family/ChangeLog:
* c-common.cc (c_build_vec_convert): Support vector boolean
types for __builtin_convertvector ().
gcc/c/ChangeLog:
* c-typeck.cc (build_binary_op): Support vector boolean types.
gcc/cp/ChangeLog:
* typeck.cc (cp_build_binary_op): Likewise.
* call.cc (build_conditional_expr): Support vector booleans.
* cvt.cc (ocp_convert): Call target hook to resolve conversion
between standard and non-standard booleans.
gcc/ChangeLog:
* config/aarch64/aarch64-sve-builtins.cc (register_builtin_types): Make
SVE vector boolean type equivalent to GNU vectors.
* config/aarch64/aarch64-sve.md (extend<vpred><mode>2,
zero_extend<vpred><mode>2, trunc<mode><vpred>2, vec_cmp<mode><mode>):
New patterns to support additional operations on predicate modes.
* config/aarch64/aarch64.cc (aarch64_valid_vector_boolean_op): New.
(aarch64_invalid_unary_op): Consider vector bool types.
(aarch64_invalid_binary_op): Likewise.
(aarch64_convert_to_type): Define target hook and handle standard to
non-standard bool conversion.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/acle/general/cops_bool.c: New.
|
|
relocation
Trivial relocation was voted out of C++26, the following patch
removes it (note, the libstdc++ part was still waiting for patch review
and so doesn't need to be removed).
This isn't a mere revert of r16-2206; I've kept -Wc++26-compat option,
from earlier patches the non-terminal stays to be class-property-specifier,
and I had to partially revert also various follow-up changes, e.g. for
modules to handle the new flags and test them, for -Wkeyword-macro
etc. to diagnose the conditional keywords or the feature test macro
etc.
2025-11-10 Jakub Jelinek <jakub@redhat.com>
PR c++/119064
gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): Revert 2025-07-11
changes.
gcc/cp/
* cp-tree.h (struct lang_type): Revert 2025-07-11 changes.
(CLASSTYPE_TRIVIALLY_RELOCATABLE_BIT): Remove.
(CLASSTYPE_TRIVIALLY_RELOCATABLE_COMPUTED): Remove.
(CLASSTYPE_REPLACEABLE_BIT): Remove.
(CLASSTYPE_REPLACEABLE_COMPUTED): Remove.
(enum virt_specifier): Revert 2025-07-11 changes.
(trivially_relocatable_type_p): Remove.
(replaceable_type_p): Remove.
* cp-trait.def (IS_NOTHROW_RELOCATABLE): Remove.
(IS_REPLACEABLE): Remove.
(IS_TRIVIALLY_RELOCATABLE): Remove.
* parser.cc (cp_parser_class_specifier, cp_parser_class_head):
Revert 2025-07-11 changes.
* pt.cc (instantiate_class_template): Likewise.
* semantics.cc (trait_expr_value): Likewise.
(finish_trait_expr): Likewise.
* tree.cc (default_movable_type_p): Remove.
(union_with_no_declared_special_member_fns): Remove.
(trivially_relocatable_type_p): Remove.
(replaceable_type_p): Remove.
* constraint.cc (diagnose_trait_expr): Revert 2025-07-11 changes.
* module.cc (trees_out::lang_type_bools): Revert part of
2025-07-26 changes related to trivial relocatability.
(trees_in::lang_type_bools): Likewise.
* lex.cc (cxx_init): Don't call cpp_warn on
trivially_relocatable_if_eligible and replaceable_if_eligible.
gcc/testsuite/
* g++.dg/cpp26/feat-cxx26.C: Revert 2025-07-11 changes.
* g++.dg/DRs/dr2581-1.C (__cpp_trivial_relocatability): Remove test.
* g++.dg/DRs/dr2581-2.C (__cpp_trivial_relocatability): Likewise.
* g++.dg/warn/Wkeyword-macro-1.C: Don't expect any diagnostics on
#define or #undef of trivially_relocatable_if_eligible or
replaceable_if_eligible.
* g++.dg/warn/Wkeyword-macro-2.C: Likewise.
* g++.dg/warn/Wkeyword-macro-4.C: Likewise.
* g++.dg/warn/Wkeyword-macro-5.C: Likewise.
* g++.dg/warn/Wkeyword-macro-7.C: Likewise.
* g++.dg/warn/Wkeyword-macro-8.C: Likewise.
* g++.dg/cpp26/trivially-relocatable1.C: Remove.
* g++.dg/cpp26/trivially-relocatable2.C: Remove.
* g++.dg/cpp26/trivially-relocatable3.C: Remove.
* g++.dg/cpp26/trivially-relocatable4.C: Remove.
* g++.dg/cpp26/trivially-relocatable5.C: Remove.
* g++.dg/cpp26/trivially-relocatable6.C: Remove.
* g++.dg/cpp26/trivially-relocatable7.C: Remove.
* g++.dg/cpp26/trivially-relocatable8.C: Remove.
* g++.dg/cpp26/trivially-relocatable9.C: Remove.
* g++.dg/cpp26/trivially-relocatable10.C: Remove.
* g++.dg/cpp26/trivially-relocatable11.C: Remove.
* g++.dg/modules/class-11_a.H: Remove trivial relocatability
related parts.
* g++.dg/modules/class-11_b.C: Likewise.
|
|
It is permissible to define macros prior to including a PCH, as long as
these definitions are disjoint from or identical to the macros in the
PCH. The PCH loading process replaces all libcpp data structures with those
from the PCH, so it is necessary to remember the extra macros separately and
then restore them after loading the PCH, which all is handled by
cpp_save_state() and cpp_read_state() in libcpp/pch.cc. The restoration
process consists of pushing a buffer containing the macro definition and
then lexing it from there, similar to how a command-line -D option is
processed. The current implementation does not attempt to set up the
line_map for this process, and so the locations assigned to the macros are
often not meaningful. (Similar to what happened in the past with lexing the
tokens out of a _Pragma string, lexing out of a buffer rather than a file
produces "sorta" reasonable locations that are often close enough, but not
reliably correct.)
Fix that up by remembering enough additional information (more or less, an
expanded_location for each macro definition) to produce a reasonable
location for the newly restored macros.
One issue that came up is the treatment of command-line-defined macros. From
the perspective of the generic line_map data structures, the command-line
location is not distinguishable from other locations; it's just an ordinary
location created by the front ends with a fake file name by convention. (At
the moment, it is always the string `<command-line>', subject to
translation.) Since libcpp needs to assign macros to that location, it
needs to know what location to use, so I added a new member
line_maps::cmdline_location for the front ends to set, similar to how
line_maps::builtin_location is handled.
This revealed a small issue, in c-opts.cc we have:
/* All command line defines must have the same location. */
cpp_force_token_locations (parse_in, line_table->highest_line);
But contrary to the comment, all command line defines don't actually end up
with the same location anymore. This is because libcpp/lex.cc has been
expanded (r6-4873) to include range information on the returned
locations. That logic has never been respecting the request of
cpp_force_token_locations. I believe this was not intentional, and so I have
corrected that here. Prior to this patch, the range logic has been leading
to command-line macros all having similar locations in the same line map (or
ad-hoc locations based from there for sufficiently long tokens); with this
change, they all have exactly the same location and that location is
recorded in line_maps::cmdline_location.
With that change, then it works fine for pch.cc to restore macros whether
they came from the command-line or from the main file.
gcc/c-family/ChangeLog:
PR preprocessor/105608
* c-opts.cc (c_finish_options): Set new member
line_table->cmdline_location.
* c-pch.cc (c_common_read_pch): Adapt linemap usage to changes in
libcpp pch.cc; it is now possible that the linemap is in a different
file after returning from cpp_read_state().
libcpp/ChangeLog:
PR preprocessor/105608
* include/line-map.h: Add new member CMDLINE_LOCATION.
* lex.cc (get_location_for_byte_range_in_cur_line): Do not expand
the token location to include range information if token location
override was requested.
(warn_about_normalization): Likewise.
(_cpp_lex_direct): Likewise.
* pch.cc (struct saved_macro): New local struct.
(struct save_macro_data): Change DEFNS vector to hold saved_macro
rather than uchar*.
(save_macros): Adapt to remember the location information for each
saved macro in addition to the definition.
(cpp_prepare_state): Likewise.
(cpp_read_state): Use the saved location information to generate
proper locations for the restored macros.
gcc/testsuite/ChangeLog:
PR preprocessor/105608
* g++.dg/pch/line-map-3.C: Remove xfails.
* g++.dg/pch/line-map-4.C: New test.
* g++.dg/pch/line-map-4.Hs: New test.
|
|
|
|
A frequent issue with migrating to C++20 modules has been dealing with
third-party libraries with internal functions or data. This causes GCC
to currently refuse to build the module if any references to these
internal-linkage declarations escape into the module CMI.
This can seem needlessly hostile, however, especially since we have the
capabilities to support this (to a degree) from header units, albeit
with the inherent ODR issues associated with their use. In aid of this,
this patch demotes the error to a pedwarn in various scenarios, by
treating some declarations as not being TU-local even if they otherwise
would have been.
Effort has been made to not alter semantics of valid programs, and to
continue to diagnose cases that the standard says we must. In
particular, any code in the module purview is still a hard error, due to
the inherent issues with exposing TU-local entities, and the lack of any
migration requirements.
Because this patch is just to assist migration, we only deal with the
simplest (yet most common) cases: namespace scope functions and
variables. Types are hard to handle neatly as we risk getting thousands
of unhelpful warnings as we continue to walk the type body and find new
TU-local entities to complain about. Templates are also tricky because
it's hard to tell if an instantiation that occurred in the module
purview only refers to global module entities or if it's inadvertantly
exposing a purview entity as well. Neither of these are likely to occur
frequently in third-party code; if need be, this can be relaxed later as
well.
Similarly, even in the GMF a constexpr variable with a TU-local value
will not be usable in constant expressions in the importer, and since we
cannot easily warn about this from the importer we continue to make this
an error in the module interface.
PR c++/121574
gcc/c-family/ChangeLog:
* c.opt: New warning '-Wexpose-global-module-tu-local'.
* c.opt.urls: Regenerate.
gcc/ChangeLog:
* doc/invoke.texi: Document '-Wexpose-global-module-tu-local'.
gcc/cp/ChangeLog:
* module.cc (depset::disc_bits): Replace 'DB_REFS_TU_LOCAL_BIT'
and 'DB_EXPOSURE_BIT' with new four flags
'DB_{REF,EXPOSE}_{GLOBAL,PURVIEW}_BIT'.
(depset::is_tu_local): Support checking either for only purview
TU-local entities or any entity described TU-local by standard.
(depset::refs_tu_local): Likewise.
(depset::is_exposure): Likewise.
(depset::hash::make_dependency): A constant initialized to a
TU-local variable is always considered a purview exposure.
(is_exposure_of_member_type): Adjust sanity checks to handle if
we ever relax requirements for TU-local types.
(depset::hash::add_dependency): Differentiate referencing
purview or GMF TU-local entities.
(depset::hash::diagnose_bad_internal_ref): New function.
(depset::hash::diagnose_template_names_tu_local): New function.
(depset::hash::finalize_dependencies): Handle new warnings that
might be needed for GMF TU-local entities.
gcc/testsuite/ChangeLog:
* g++.dg/modules/internal-17_a.C: New test.
* g++.dg/modules/internal-17_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
|
|
gcc/c-family/ChangeLog:
* c-warn.cc (warn_parms_array_mismatch): Fix typos in comment.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
This function acts on entire parameter declaration lists, and iterates
over them. Use plural in the name, to clarify that it acts on
parameters, not just on a single parameter.
gcc/c-family/ChangeLog:
* c-common.h (warn_parm_array_mismatch):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
* c-warn.cc (warn_parm_array_mismatch):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
gcc/c/ChangeLog:
* c-decl.cc (start_function):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
* c-parser.cc (c_parser_declaration_or_fndef):
Rename warn_parm_array_mismatch => warn_parms_array_mismatch.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
|
|
|
|
This extension is requested by linux kernel to ease the adoption of counted_by
attribute into linux kernel.
Please refer to
https://lore.kernel.org/lkml/20251021095447.GL3245006@noisy.programming.kicks-ass.net/
for the initial request for this feature.
The attribute is allowed for a pointer to void, However,
Warnings will be issued for such cases when -Wpointer-arith is
specified. When this attribute is applied on a pointer to void, the
size of each element of this pointer array is treated as 1.
gcc/c-family/ChangeLog:
* c-attribs.cc (handle_counted_by_attribute): Allow counted_by for
void pointer. Issue warnings when -Wpointer-arith is present.
gcc/c/ChangeLog:
* c-typeck.cc (build_access_with_size_for_counted_by): When the element
type is void, assign size one as the element_size.
gcc/ChangeLog:
* doc/extend.texi: Clarification when the counted_by attribute is applied
on a void pointer.
gcc/testsuite/ChangeLog:
* gcc.dg/pointer-counted-by.c: Update for void pointers.
* gcc.dg/pointer-counted-by-10.c: New test.
* gcc.dg/pointer-counted-by-4-void.c: New test.
|
|
|
|
PR122325 reports that -ffast-math no longer enables -fcx-limited-range.
This is due to the weird handling of flag_default_complex_method which
the following simply removes. Frontends that wish to impose a default
evaluation method that is not -fcx-fortran-rules (the current default
of flag_default_complex_method) need to imposed that in ther
init_options_struct langhook which those requesting C std rules already
do and I'm adding that for the fortran frontend, explicitly requesting
fortran rules.
PR middle-end/122325
gcc/
* common.opt (flag_default_complex_method): Remove.
* opts.cc (init_options_struct): Default to fortran rules
for complex evaluations.
(finish_options): Remove (re-)instantiating of the frontend
default of the complex evaluation method.
gcc/c-family/
* c-opts.cc (c_common_init_options_struct): Remove set of
flag_default_complex_method.
gcc/go/
* go-lang.cc (go_langhook_init_options_struct): Remove set of
flag_default_complex_method.
gcc/lto/
* lto-lang.cc (lto_init_options_struct): Remove set of
flag_default_complex_method.
gcc/fortran/
* options.cc (gfc_init_options_struct): Set flag_complex_method
to fortran rules.
gcc/testsuite/
* gcc.dg/complex-8.c: New testcase.
* gcc.dg/complex-9.c: Likewise.
|
|
|
|
The following testcase is miscompiled, because a RAW_DATA_CST tree
node is shared by multiple CONSTRUCTORs and when the braced_list_to_string
function changes one to extend the RAW_DATA_CST over the single preceding
and single succeeding INTEGER_CST, it changes the RAW_DATA_CST in
the other CONSTRUCTOR where the elts around it are still present.
Fixed by tweaking a copy of it instead, like we handle it in other spots.
2025-10-22 Jakub Jelinek <jakub@redhat.com>
PR c++/122302
* c-common.cc (braced_list_to_string): Call copy_node on RAW_DATA_CST
before changing RAW_DATA_POINTER and RAW_DATA_LENGTH on it.
* g++.dg/cpp0x/pr122302.C: New test.
* g++.dg/cpp/embed-27.C: New test.
|
|
|
|
Both Fortran and C/C++ have an array with classifications of directives;
currently, this array is only used to handle the restrictions of the
contains/absent clauses to the assume/assumes directives.
For C/C++, uncommenting 'declare mapper' was missed. Additionally,
'end ...' is a directive but not a directive name; hence, those
are now rejected as 'unknown directive' instead of as 'invalid'
directive.
Additionally, both lists now list newer entries (commented out) for
OpenMP 6.x - and a note (comment) was added for C/C++'s
'begin metadirective' and for Fortran's 'allocate', respectively.
gcc/c-family/ChangeLog:
* c-omp.cc (c_omp_directives): Uncomment 'declare mapper',
add comment to 'begin metadirective', add 6.x unimplemented
directives as comment-out entries.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_assumption_clauses): Switch to
'unknown' not 'invalid' directive name for end directives.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_assumption_clauses): Switch to
'unknown' not 'invalid' directive name for end directives.
gcc/fortran/ChangeLog:
* openmp.cc (gfc_omp_directive): Add comment to 'allocate';
add 6.x unimplemented directives as comment-out entries.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/assumes-2.c: Change for 'invalid'
to 'unknown' change for end directives.
* c-c++-common/gomp/begin-assumes-2.c: Likewise.
* c-c++-common/gomp/assume-2.c: Likewise. Check 'declare
mapper'.
|
|
|
|
This patch enables constant propagation to outlined OpenMP kernels.
It does so using a new function attribute called ' callback' (note the
space).
The attribute ' callback' captures the notion of a function calling one
of its arguments with some of its parameters as arguments. An OpenMP
example of such function is GOMP_parallel.
We implement the attribute with new callgraph edges called callback
edges. They are imaginary edges pointing from the caller of the function
with the attribute (e.g. caller of GOMP_parallel) to the body function
itself (e.g. the outlined OpenMP body). They share their call statement
with the edge from which they are derived (direct edge caller -> GOMP_parallel
in this case). These edges allow passes such as ipa-cp to see the hidden
call site to the body function and optimize the function accordingly.
To illustrate on an example, the body GOMP_parallel looks something
like this:
void GOMP_parallel (void (*fn) (void *), void *data, /* ... */)
{
/* ... */
fn (data);
/* ... */
}
If we extend it with the attribute ' callback(1, 2)', we express that the
function calls its first argument and passes it its second argument.
This is represented in the call graph in this manner:
direct indirect
caller -----------------> GOMP_parallel ---------------> fn
|
----------------------> fn
callback
The direct edge is then the callback-carrying edge, all new edges
are the derived callback edges.
While constant propagation is the main focus of this patch, callback
edges can be useful for different passes (for example, they improve icf
for OpenMP kernels), as they allow for address redirection.
If the outlined body function gets optimized and cloned, from body_fn to
body_fn.optimized, the callback edge allows us to replace the
address in the arguments list:
GOMP_parallel (body_fn, &data_struct, /* ... */);
becomes
GOMP_parallel (body_fn.optimized, &data_struct, /* ... */);
This redirection is possible for any function with the attribute.
This callback attribute implementation is partially compatible with
clang's implementation. Its semantics, arguments and argument indexing style are
the same, but we represent an unknown argument position with 0
(precedent set by attributes such as 'format'), while clang uses -1 or '?'.
We use the index 1 for the 'this' pointer in member functions, clang
uses 0. We also allow for multiple callback attributes on the same function,
while clang only allows one.
The attribute is currently for GCC internal use only, thanks to the
space in its name. Originally, it was supposed to be called
'callback' like its clang counterpart, but we cannot use this name, as
clang uses non-standard indexing style, leading to inconsistencies. The
attribute will be introduced into the public API as 'gnu::callback_only'
in a future patch.
The attribute allows us to propagate constants into body functions of
OpenMP constructs. Currently, GCC won't propagate the value 'c' into the
OpenMP body in the following example:
int a[100];
void test(int c) {
#pragma omp parallel for
for (int i = 0; i < c; i++) {
if (!__builtin_constant_p(c)) {
__builtin_abort();
}
a[i] = i;
}
}
int main() {
test(100);
return a[5] - 5;
}
With this patch, the body function will get cloned and the constant 'c'
will get propagated.
Some functions may utilize the attribute's infrastructure without being
declared with it, for example GOMP_task. These functions are special
cases and use the special case functions found in attr-callback.h. Special
cases use the attribute under certain circumstances, for example
GOMP_task uses it when the copy function is not being used required.
gcc/ChangeLog:
* Makefile.in: Add attr-callback.o to OBJS.
* builtin-attrs.def (ATTR_CALLBACK): Callback attr identifier.
(DEF_CALLBACK_ATTRIBUTE): Macro for callback attr creation.
(GOMP): Attr for libgomp functions.
(ATTR_CALLBACK_GOMP_LIST): ATTR_NOTHROW_LIST with GOMP callback
attr added.
* cgraph.cc (cgraph_add_edge_to_call_site_hash): Always hash the
callback-carrying edge.
(cgraph_node::get_edge): Always return the callback-carrying
edge.
(cgraph_edge::set_call_stmt): Add cascade for callback edges.
(symbol_table::create_edge): Allow callback edges to share call
stmts, initialize new flags.
(cgraph_edge::make_callback): New method, derives a new callback
edge.
(cgraph_edge::get_callback_carrying_edge): New method.
(cgraph_edge::first_callback_edge): Likewise.
(cgraph_edge::next_callback_edge): Likewise.
(cgraph_edge::purge_callback_edges): Likewise.
(cgraph_edge::redirect_callee): When redirecting a callback
edge, redirect its ref as well.
(cgraph_edge::redirect_call_stmt_to_callee): Add callback edge
redirection logic, set update_derived_edges to true hwne
redirecting the carrying edge.
(cgraph_node::remove_callers): Add cascade for callback edges.
(cgraph_edge::dump_edge_flags): Print callback flags.
(cgraph_node::verify_node): Add sanity checks for callback
edges.
* cgraph.h: Add new 1 bit flags and 16 bit callback_id to
cgraph_edge class.
* cgraphclones.cc (cgraph_edge::clone): Copy over callback data.
* cif-code.def (CALLBACK_EDGE): Add CIF_CALLBACK_EDGE code.
* ipa-cp.cc (purge_useless_callback_edges): New function,
deletes callback edges when necessary.
(ipcp_decision_stage): Call purge_useless_callback_edges.
* ipa-fnsummary.cc (ipa_call_summary_t::duplicate): Add
an exception for callback edges.
(analyze_function_body): Copy over summary from carrying to
callback edge.
* ipa-inline-analysis.cc (do_estimate_growth_1): Skip callback
edges when estimating growth.
* ipa-inline-transform.cc (inline_transform): Add redirection
cascade for callback edges.
* ipa-param-manipulation.cc
(drop_decl_attribute_if_params_changed_p): New function.
(ipa_param_adjustments::build_new_function_type): Add
args_modified out param.
(ipa_param_adjustments::adjust_decl): Drop callback attrs when
modifying args.
* ipa-param-manipulation.h: Adjust decl of
build_new_function_type.
* ipa-prop.cc (ipa_duplicate_jump_function): Add decl.
(init_callback_edge_summary): New function.
(ipa_compute_jump_functions_for_edge): Add callback edge
creation logic.
* lto-cgraph.cc (lto_output_edge): Stream out callback data.
(input_edge): Input callback data.
* omp-builtins.def (BUILT_IN_GOMP_PARALLEL_LOOP_STATIC): Use new
attr list.
(BUILT_IN_GOMP_PARALLEL_LOOP_GUIDED): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_DYNAMIC): Likewise.
(BUILT_IN_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME): Likewise.
(BUILT_IN_GOMP_PARALLEL): Likewise.
(BUILT_IN_GOMP_PARALLEL_SECTIONS): Likewise.
(BUILT_IN_GOMP_TEAMS_REG): Likewise.
* tree-core.h (ECF_CB_1_2): New constant for callback(1,2).
* tree-inline.cc (copy_bb): Copy callback edges when copying the
carrying edge.
(redirect_all_calls): Redirect callback edges.
* tree.cc (set_call_expr_flags): Create callback attr according
to the ECF_CB flag.
* attr-callback.cc: New file.
* attr-callback.h: New file.
gcc/c-family/ChangeLog:
* c-attribs.cc: Define callback attr.
gcc/fortran/ChangeLog:
* f95-lang.cc (ATTR_CALLBACK_GOMP_LIST): New attr list
corresponding to the list in builtin-attrs.def.
gcc/testsuite/ChangeLog:
* gcc.dg/ipa/ipcp-cb-spec1.c: New test.
* gcc.dg/ipa/ipcp-cb-spec2.c: New test.
* gcc.dg/ipa/ipcp-cb1.c: New test.
Signed-off-by: Josef Melcr <jmelcr02@gmail.com>
|
|
|
|
On Mon, Oct 13, 2025 at 07:07:01AM +0100, Iain Sandoe wrote:
> * c.opt: Enable Wignored-attributes for Objective-C and
> Objective-C++.
I wrote a more complete version of this patch, here is it rebased
on top of your patch.
I see no reason for any of these options to be C C++ only rather than
C ObjC C++ ObjC++, or in some cases C++ only rather than C++ ObjC++.
The only cases where I think limiting to C only is desirable are
fgimple
C Var(flag_gimple) Init(0)
Enable parsing GIMPLE.
where I think we don't want to support ObjC for GIMPLE FE, and
lang-asm
C Undocumented RejectDriver
For everything else I believe people adding those options just didn't
think of ObjC or ObjC++.
2025-10-14 Jakub Jelinek <jakub@redhat.com>
* c.opt (Wflex-array-member-not-at-end, Wignored-qualifiers,
Wopenacc-parallelism, Wstrict-flex-arrays, Wsync-nand,
fstrict-flex-arrays, fstrict-flex-arrays=): Enable also for ObjC and
ObjC++ next to C and C++.
(Wmisleading-indentation, Wopenmp-simd): Likewise. Also change
LangEnabledBy from just C C++ to C ObjC C++ ObjC++.
(Wplacement-new, Wplacement-new=, fcontract-assumption-mode=,
fcontract-build-level=, fcontract-strict-declarations=,
fcontract-mode=, fcontract-continuation-mode=, fcontract-role=,
fcontract-semantic=, fcoroutines, flang-info-include-translate,
flang-info-include-translate-not, flang-info-include-translate=,
flang-info-module-cmi, flang-info-module-cmi=): Enable also
for ObjC++ next to C++.
|
|
|
|
r16-4373 altered headers so that Wignored-attributes was named in
a diagnostic push. This causes several Objective-C++ tests to fail
since the atomicity.h header is included there.
Since Objective-C/C++ are intended to be supersets of the base
language, there is no specific reason to exclude this warning there.
gcc/c-family/ChangeLog:
* c.opt: Enable Wignored-attributes for Objective-C and
Objective-C++.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
|
|
|
|
Add two new c-family attributes, "btf_type_tag" and "btf_decl_tag"
along with attribute handlers for them. These attributes may be
used to annotate types or declarations respectively with arbitrary
strings, which will be recorded in DWARF and/or BTF information.
Both attributes accept exactly one string argument. Wide strings
are not supported.
gcc/c-family/
* c-attribs.cc (c_common_attribute_table): Add btf_decl_tag and
btf_type_tag attributes.
(handle_btf_decl_tag_attribute): New handler for btf_decl_tag.
(hanlde_btf_type_tag_attribute): New handler for btf_type_tag.
(btf_tag_args_ok): Helper for new attribute handlers.
gcc/testsuite/
* gcc.dg/attr-btf-decl-tag-1.c: New test.
* gcc.dg/attr-btf-decl-tag-2.c: New test.
* gcc.dg/attr-btf-type-tag-1.c: New test.
* gcc.dg/attr-btf-type-tag-2.c: New test.
* gcc.dg/attr-btf-type-tag-3.c: New test.
|
|
The C++26 https://wg21.link/P3348R4 C++26 should refer to C23 not C17
paper among other things changes va_start macro in the similar way
how C23 has changed it. Now, unlike C17 and older, C++ has since forever
allowed int (...) but just one wasn't able to use va_start/va_arg/va_end
in such functions.
With the current C++26 draft wording, we'd have to
#define va_start(V, ...) __builtin_va_start (V, 0)
like we've used for C23 before the PR107980 change.
But Jonathan has kindly filed
https://cplusplus.github.io/LWG/issue4388
which similarly to C23 will if accepted allow to define it as
#define va_start(...) __builtin_c23_va_start(__VA_ARGS__)
and let the compiler diagnose undesirable cases (see stdarg6.C
testcase in the patch for what it can diagnose, basically anything
that isn't either va_start (ap) or va_start (ap, i) where i is the
last argument's identifier). This patch implements what assumes
LWG4388 will pass.
It also defines
#define __STDC_VERSION_STDARG_H__ 202311L
also for C++26.
The hardest part is actually something different.
C23 had to differentiate between C99 void foo (); i.e. unspecified
arguments (but not stdarg) and the new C23 void bar (...); which
is stdarg, but in both cases TYPE_ARG_TYPES (fntype) is NULL.
This has been implemented through the new TYPE_NO_NAMED_ARGS_STDARG_P
flag, fntypes with that flag set are considered stdarg_p and allow
va_start in those, while fntypes with NULL TYPE_ARG_TYPES but the
flag cleared are not stdarg_p, can accept any number of arguments
but can't use va_start.
So, I had to change various places in the C++ FE to pass true
as the third argument to build_function_type for calls which are
meant to be (...) so that one can actually use va_start in those.
Done only for C++26 in order not to disturb older versions too much.
And there is a problem with some of the builtins and #pragma weak
which are using (...) declarations more in the sense of C17
unspecified arguments rather than this call has variable arguments.
So, structural_comptypes now considers the non-C++26 (...) used
for selected builtins and #pragma weak incompatible with C++26 (...)
to avoid ICEs.
2025-10-09 Jakub Jelinek <jakub@redhat.com>
gcc/
* ginclude/stdarg.h (va_start): Use __builtin_c23_va_start
also for C++26.
(__STDC_VERSION_STDARG_H__): Also define for C++26.
gcc/c-family/
* c-common.h (D_CXX26): Define.
* c-common.cc (c_common_resword): Add D_CXX26 to
__builtin_c23_va_start flags, mention D_CXX26 in comment.
gcc/cp/
* cp-tree.h (cp_build_function_type): Declare.
* lex.cc: Implement va_start changes from P3348R4 - C++26 should
refer to C23 not C17 paper.
(init_reswords): Set D_CXX26 in mask for C++23 and older.
* parser.cc (cp_parser_primary_expression): Handle RID_C23_VA_START.
(cp_parser_builtin_c23_va_start): New function.
* cp-objcp-common.cc (names_builtin_p): Likewise.
* decl.cc (grokfndecl, check_function_type): Pass
TYPE_NO_NAMED_ARGS_STDARG_P as last arg to build_function_type.
(grokdeclarator, static_fn_type): Use cp_build_function_type instead
of build_function_type.
* typeck.cc (merge_types): Likewise.
(structural_comptypes): Return false for TYPE_NO_NAMED_ARGS_STDARG_P
differences.
* lambda.cc (maybe_add_lambda_conv_op): Use cp_build_function_type
instead of build_function_type.
* tree.cc (cp_build_function_type): New function.
(strip_typedefs): Pass TYPE_NO_NAMED_ARGS_STDARG_P as last arg to
build_function_type.
* name-lookup.cc (push_local_extern_decl_alias): Likewise.
* module.cc (trees_in::tree_node): Use cp_build_function_type instead
of build_function_type.
* pt.cc (copy_default_args_to_explicit_spec,
rebuild_function_or_method_type, build_deduction_guide): Likewise.
(alias_ctad_tweaks): Pass TYPE_NO_NAMED_ARGS_STDARG_P as last arg to
build_function_type.
* decl2.cc (change_return_type, cp_reconstruct_complex_type):
Likewise.
gcc/testsuite/
* c-c++-common/cpp/has-builtin-4.c: Expect
__has_builtin (__builtin_c23_va_start) == 1 also for C++26.
* c-c++-common/Wvarargs.c (foo3): Don't expect undefined behavior
warning for C++26.
* g++.dg/cpp26/stdarg1.C: New test.
* g++.dg/cpp26/stdarg2.C: New test.
* g++.dg/cpp26/stdarg3.C: New test.
* g++.dg/cpp26/stdarg4.C: New test.
* g++.dg/cpp26/stdarg5.C: New test.
* g++.dg/cpp26/stdarg6.C: New test.
* g++.dg/cpp26/stdarg7.C: New test.
* g++.dg/cpp26/stdarg8.C: New test.
* g++.dg/cpp26/stdarg9.C: New test.
* g++.dg/opt/pr60849.C (foo): Add explicit cast.
|
|
[PR122188]
The patch from yesterday made me think about side-effects in the second
argument of __builtin_c[lt]zg. When we change
__builtin_c[lt]zg (x, y)
when y is not INTEGER_CST into
x ? __builtin_c[lt]zg (x) : y
with evaluating x only once, we omit the side-effects in y unless x is not
0. That looks undesirable, we should evaluate side-effects in y
unconditionally.
2025-10-09 Jakub Jelinek <jakub@redhat.com>
PR c/122188
* c-gimplify.cc (c_gimplify_expr): Also gimplify the second operand
before the COND_EXPR and use in COND_EXPR result of gimplification.
* gcc.dg/torture/pr122188.c: New test.
|
|
This patch provides a way for plugins to add extra information
to a diagnostic sink, potentially capturing more information via
a "finalizer" hook.
gcc/c-family/ChangeLog:
* c-opts.cc: Define INCLUDE_VECTOR.
gcc/cp/ChangeLog:
* error.cc: Define INCLUDE_VECTOR.
gcc/ChangeLog:
* diagnostic-global-context.cc: Define INCLUDE_VECTOR.
* diagnostics/buffering.cc: Likewise.
* diagnostics/context.cc (context::finish): Call
finalize_extensions on each sink.
(sink::dump): Dump any extensions.
(sink::finalize_extensions): New.
* diagnostics/macro-unwinding.cc: Define INCLUDE_VECTOR.
* diagnostics/selftest-context.cc: Likewise.
* diagnostics/sink.h (class sink::extension): New.
(sink::add_extension): New.
(sink::finalize_extensions): New decl.
(sink::m_extensions): New member.
* gcc.cc: Define INCLUDE_VECTOR.
* langhooks.cc: Likewise.
* opts.cc: Likewise.
* tree-diagnostic-client-data-hooks.cc: Likewise.
* tree-diagnostic.cc: Likewise.
gcc/fortran/ChangeLog:
* error.cc: Define INCLUDE_VECTOR.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_group_plugin.cc: Define INCLUDE_VECTOR.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.cc: Likewise.
* gcc.dg/plugin/location_overflow_plugin.cc: Likewise.
libcc1/ChangeLog:
* context.cc: Define INCLUDE_VECTOR.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|