Commit graph

219634 commits

Author SHA1 Message Date
Thomas Schwinge
27f88cc799 Add 'std::bad_cast' exception, dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-3.C: New.
	* g++.target/nvptx/exceptions-bad_cast-3.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
00cde164ee Add 'std::bad_cast' exception, caught test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-2.C: New.
	* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: New.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C: Likewise.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
0e68f49db9 Add 'std::bad_cast' exception test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading
gcc/testsuite/
	* g++.target/gcn/exceptions-bad_cast-1.C: New.
	* g++.target/nvptx/exceptions-bad_cast-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: New.
	* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
2025-04-14 23:54:53 +02:00
Thomas Schwinge
aa3e72f943 Add test cases for exception handling constructs in dead code for GCN, nvptx target and OpenMP 'target' offloading [PR118794]
PR target/118794
	gcc/testsuite/
	* g++.target/gcn/exceptions-pr118794-1.C: New.
	* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
	Likewise.
	* testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
	Likewise.
2025-04-14 23:54:48 +02:00
Thomas Schwinge
a304c88b6f Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" test cases [PR119692]
... documenting the status quo.

	PR c++/119692
	gcc/testsuite/
	* g++.target/gcn/pr119692-1-1.C: New.
	* g++.target/nvptx/pr119692-1-1.C: Likewise.
	libgomp/
	* testsuite/libgomp.c++/pr119692-1-1.C: New.
	* testsuite/libgomp.c++/pr119692-1-2.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-3.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-4.C: Likewise.
	* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
	* testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.
2025-04-14 23:54:48 +02:00
Thomas Schwinge
785448f046 Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test cases
Like 'gcc.target/gcn/gcn.exp' is modeled after 'gcc.dg/dg.exp', this new
'g++.target/gcn/gcn.exp' is modeled after 'g++.dg/dg.exp'.

	gcc/testsuite/
	* g++.target/gcn/gcn.exp: New.
2025-04-14 23:54:48 +02:00
Thomas Schwinge
8621554d96 Polish 'dg-output-file' test logs
Per commit r15-8260-g563e6d926d9826d76895086d0c40a29dc90d66e5
"testsuite: Add support for dg-output-file directive", this currently produces
test logs as follows:

    PASS: gcc.dg/dg-output-file-1.c (test for excess errors)
    PASS: dg-output-file-1-lp64.txt output file test
    PASS: gcc.dg/dg-output-file-1.c execution test

    PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O0  (test for excess errors)
    PASS: COMP-6_arithmetic.out output file test
    PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O0  execution test
    PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O1  (test for excess errors)
    PASS: COMP-6_arithmetic.out output file test
    PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O1  execution test
    [Etc.]

Notice that the 'PASS: [...] output file test' lines easily produce duplicate
test names, or might even produce PASS plus FAIL for the same test names.

Make the "output file test" use the same "descriptive name" as the other parts,
and get properly sorted with parallel-testing 'contrib/dg-extract-results.sh'
processing:

     PASS: c-c++-common/zero-scratch-regs-leafy-2.c  -Wc++-compat  (test for excess errors)
    -PASS: dg-output-file-1-lp64.txt output file test
     PASS: gcc.dg/20000108-1.c (test for excess errors)
    [...]
     PASS: gcc.dg/devnull-dump.c (test for excess errors)
     PASS: gcc.dg/dg-output-file-1.c (test for excess errors)
     PASS: gcc.dg/dg-output-file-1.c execution test
    +PASS: gcc.dg/dg-output-file-1.c output file test
     PASS: gcc.dg/dg-test-1.c (test for excess errors)

..., and gets de-duplicated test names, for example:

     PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O0  (test for excess errors)
    -PASS: COMP-6_arithmetic.out output file test
    +PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O0   output file test
     PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O0  execution test
     PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O1  (test for excess errors)
    -PASS: COMP-6_arithmetic.out output file test
    +PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O1   output file test
     PASS: cobol.dg/group2/COMP-6_arithmetic.cob   -O1  execution test
    [Etc.]

(Given that only ever a single 'dg-output-file' directive is active, don't
print the output filename.)

	gcc/testsuite/
	* lib/gcc-dg.exp (${tool}_load): Polish 'dg-output-file' test
	logs.
2025-04-14 23:50:18 +02:00
Jakub Jelinek
ebdf92b606 testsuite: Fix up ipa/pr119530.c testcase [PR119318]
I'm seeing
+FAIL: gcc.dg/ipa/pr119530.c execution test
on i686-linux.  The problem is that when long is just 32-bit and
so is unsigned, the testcase then behaves differently and should abort.
Fixed by making the argument long long instead.
While at it, just in case I've changed type of d variable to signed char
as well just in case there is -funsigned-char 8-bit int target or something
similar.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/119318
	* gcc.dg/ipa/pr119530.c (d): Change type from char to signed char.
	(e): Change argument type from long to long long.
2025-04-14 19:35:20 +02:00
Jakub Jelinek
f96a54350a expmed: Always use QImode for init_expmed set_zero_cost [PR119785]
This is a regression on some targets introduced I believe by r6-2055
which added mode argument to set_src_cost.

The problem here is that in the first iteration, mode is always QImode
and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false).
But then we use the mode variable for iterating over int, partial int
and vector int modes, so for the second iteration we call set_src_cost
with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1).

In the x86 case that happens to be V2HFmode and we don't crash (and
compute the same 0 cost as we would for QImode).
But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is
MAX_MACHINE_MODE and that does all kinds of weird things especially
when doing ubsan bootstrap.

Fixed by always using QImode.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/119785
	* expmed.cc (init_expmed): Always pass QImode rather than mode to
	set_src_cost passed to set_zero_cost.
2025-04-14 19:34:22 +02:00
Jakub Jelinek
e0b57c75e6 cobol: Fix -fmax-errors option [PR119776]
There seems to be inconsistency in the -fmax-errors option
naming.  It is a generic option in common.opt (so applies
to all languages) but with the = character in it.
The gcobol.1 man page in one spot documents the generic
option (in the syntax, -fmax-errors=nerror) but in another
spot without the = character.

In common.opt it is
fmax-errors=
Common Joined RejectNegative UInteger Var(flag_max_errors)
-fmax-errors=<number>   Maximum number of errors to report.

I hope the cobol addition is just a mistake, having -fmax-errors variant
without = character when Joined Separate would allow to specify
-fmax-errors 10 with the same meaning as -fmax-errors=10
but also -fmax-errors10 with the same meaning which is just weird.
Also, there is no UInteger and RejectNegative on it, so one can
also specific -fno-max-errors42 or -fmax-errors blah.

So, unless the spelling without = is intentional, here is a patch
to just remove it, the common option already should have arranged
for flag_max_errors to be set to the right number.

Or if it is intentional, I guess we'd need to at least add
RejectNegative UInteger (plus using atoi is generally undesirable
anywhere in the compiler because it does no error checking).
And the man page would need to be updated to specify both forms.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR cobol/119776
	* lang.opt (fmax-errors): Remove.
	* lang.opt.urls: Regenerate.
	* cobol1.cc (cobol_langhook_handle_option) <case OPT_fmax_errors>:
	Remove.
	* gcobol.1: Document -fmax-errors=nerror rather than
	-fmax-errors nerror.
2025-04-14 19:33:11 +02:00
Jakub Jelinek
d0b41f3d6d cobol: Fix up COBOL -include [PR119777]
I was looking through options.cc diff between GCC 14 and 15, looking for
entries with added CL_Cobol where at least one other language is present
and was present before too.  Besides the -fsyntax-only changes this is
the only other one I found, COBOL adds Var(cobol_include) to something
which didn't have a Var at all before and IMHO it is actively harmful.
Because one can specify multiple -include file1 -include file2 options,
both in C/C++ etc. and in COBOL as well (as documented in the man
page).  A Var can track just one entry.  cobol_langhook_handle_option
should use arg instead.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR cobol/119777
	* lang.opt (include): Remove Var(cobol_include).
	* cobol1.cc (cobol_langhook_handle_option) <case OPT_include>: Use
	arg instead of cobol_include.
2025-04-14 19:32:43 +02:00
Jakub Jelinek
e96cb35ceb cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]
The comment is incorrect, fsyntax-only is not documented in c.opt,
but in common.opt:
fsyntax-only
Common Var(flag_syntax_only)
Check for syntax errors, then stop.
and as such it applies to all languages, so adding CL_Cobol to
the CL_COMMON is both unnecessary and because of RejectNegative which
contradicts the generic option very harmful, because it makes
-fno-syntax-only invalid for all languages.

Fixed by just dropping it.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR cobol/119777
	* lang.opt (fsyntax-only): Remove.
	* lang.opt.urls: Regenerate.
2025-04-14 19:32:06 +02:00
Jakub Jelinek
2e3c91786a pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up maybe_complain_about_tail_call [PR119718]
Andrew P. mentioned earlier he'd like to see in the dump files a note
whether it was a failed must tail call or not.
We already print that on the tailc/musttail pass side, because
print_gimple_stmt prints [must tail call] after the musttail calls.
The first hunk below does it for GENERIC CALL_EXPRs too (which is needed
for the expand diagnostics).  That isn't enough though, because the
error on it was done first and then CALL_EXPR_MUST_TAIL_CALL flag was
cleared, so the dump didn't have it anymore.  I've reordered the
dump printing with error, so that it works properly.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/119718
	* tree-pretty-print.cc (dump_generic_node) <case CALL_EXPR>: Dump
	also CALL_EXPR_MUST_TAIL_CALL flag.
	* calls.cc (maybe_complain_about_tail_call): Emit error about
	CALL_EXPR_MUST_TAIL_CALL only after emitting dump message, not before
	it.
2025-04-14 19:31:23 +02:00
Arthur Cohen
901d94e8b4 gccrs: lang-items: Add ManuallyDrop<T>
gcc/rust/ChangeLog:

	* util/rust-lang-item.h: Add new manually_drop lang item.
	* util/rust-lang-item.cc: Likewise.
2025-04-14 18:23:56 +02:00
Arthur Cohen
73d72498f9 gccrs: attributes: Handle external tool annotations like rustfmt::
gcc/rust/ChangeLog:

	* util/rust-attribute-values.h: Add RUSTFMT value.
	* util/rust-attributes.cc: Define the attribute.
	* util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant.
	* expand/rust-macro-builtins.cc: Fix formatting.
2025-04-14 18:23:56 +02:00
Arthur Cohen
9ed95c0697 gccrs: nr2.0: Only insert derive macros if they exist
This causes an assertion failure when compiling core with nr2.0, but should
probably be improved. I'm not sure how this code enables built-in derive
macros to be resolved so this is a temporary fix.

gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Remove assertion.
2025-04-14 18:23:56 +02:00
Arthur Cohen
34c516efbb gccrs: attributes: Add missing attributes used in core
gcc/rust/ChangeLog:

	* util/rust-attribute-values.h: Add missing attributes.
	* util/rust-attributes.cc: Likewise.
	* util/rust-attributes.h (enum CompilerPass): Mention adding something for const
	functions.
2025-04-14 18:23:56 +02:00
beamandala
e84f76dc58 gccrs: Add #[track_caller] as known attribute
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers):
	Add entry for track_caller.
	* util/rust-attribute-values.h: add `TRACK_CALLER` attribute.
	* util/rust-attributes.cc: add `track_caller` attribute definition.

gcc/testsuite/ChangeLog:

	* rust/compile/track_caller.rs: New test.

Signed-off-by: Bhavesh Mandalapu <mandalapubhavesh@gmail.com>
2025-04-14 18:23:55 +02:00
Arthur Cohen
497ed6099b gccrs: install.texi: Mention Rust requirement for building gccrs
Addresses PR#117869

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869

gcc/ChangeLog:

	* doc/install.texi: Add requirements for building gccrs.
2025-04-14 18:23:55 +02:00
Owen Avery
85a57bf470 gccrs: Fix const checking of enum discriminants
gcc/rust/ChangeLog:

	* checks/errors/rust-const-checker.cc
	(ConstChecker::visit): Visit the enum items of enums.
	* resolve/rust-ast-resolve-item.cc
	(ResolveItem::visit): Resolve enum discriminants during nr1.0.

gcc/testsuite/ChangeLog:

	* rust/compile/enum_discriminant2.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-04-14 18:23:55 +02:00
Arthur Cohen
5074a85e03 gccrs: format_args: Allow extraneous commas, improve safety
gcc/rust/ChangeLog:

	* expand/rust-macro-builtins-format-args.cc (format_args_parse_arguments): Improve safety,
	allow extra commas after end of argument list.

gcc/testsuite/ChangeLog:

	* rust/compile/format_args_extra_comma.rs: New test.
2025-04-14 18:23:55 +02:00
Arthur Cohen
9710cf3e34 gccrs: expansion: Desugar doc comments into attributes before expansion
gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Call into
	TokenTreeDesugar.
	* expand/rust-token-tree-desugar.cc: New file.
	* expand/rust-token-tree-desugar.h: New file.
	* Make-lang.in: Compile them.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro-issue3709-1.rs: New test.
	* rust/compile/macros/mbe/macro-issue3709-2.rs: New test.
2025-04-14 18:23:54 +02:00
Arthur Cohen
cb23182fa2 gccrs: expansion: Only add fragments if the matcher succeeded
gcc/rust/ChangeLog:

	* expand/rust-macro-expand.cc (MacroExpander::match_n_matches): Do not
	insert fragments and substack fragments if the matcher failed.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro-issue3708.rs: New test.
2025-04-14 18:23:54 +02:00
Arthur Cohen
76477f9655 gccrs: session: Desugar question mark operator after expansion instead.
gcc/rust/ChangeLog:

	* rust-session-manager.cc (Session::compile_crate): Call the visitor later in the pipeline.
2025-04-14 18:23:54 +02:00
Arthur Cohen
4aa6cae27b gccrs: ast: Add get_locus() to DelimTokenTree
gcc/rust/ChangeLog:

	* ast/rust-ast.h (DelimTokenTree::get_locus): New function.
2025-04-14 18:23:54 +02:00
Arthur Cohen
09c4a7a58b gccrs: ast: Support outer attributes for AST::RangeExpr
gcc/rust/ChangeLog:

	* ast/rust-expr.h (class RangeExpr): Add empty outer attributes and allow getting them
	and setting them.
2025-04-14 18:23:53 +02:00
Arthur Cohen
6dcbbcd27c gccrs: nr2.0: Do not resolve modules this run if they are unloaded
Instead, mark the visitor as dirty and wait for the next round of the fixed point to take care of
them. This avoids issues with module items being loaded while not being stripped yet.

gcc/rust/ChangeLog:

	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Return if module
	is unloaded.
2025-04-14 18:23:53 +02:00
Arthur Cohen
eb5eee065b gccrs: typecheck: Properly select methods when dealing with specialization
gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (is_default_fn): New.
	(emit_ambiguous_resolution_error): New.
	(handle_multiple_candidates): Properly handle multiple candidates in
	the case of specialization.
	(TypeCheckExpr::visit): Call `handle_multiple_candidates`.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/min_specialization2.rs: New test.
	* rust/execute/torture/min_specialization3.rs: New test.
2025-04-14 18:23:53 +02:00
Andrew Pinski
9e367223ce rust: Add comment inside block [PR119342]
Inside a BLOCK node, all of the variables of the scope/block
are chained together and that connects them to the block.
This just adds a comment to that effect as reading the code
it is not so obvious why they need to be chained together.

gcc/rust/ChangeLog:

	PR rust/119342
	* rust-gcc.cc (block): Add comment on why chaining
	the variables of the scope toether.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14 18:23:52 +02:00
Andrew Pinski
ec2edeffed rust: use range for inside rust-gcc.cc [PR119341]
There are some places inside rust-gcc.cc which are candidates
to use range for instead of iterators directly. This changes
the locations I saw and makes the code slightly more readable.

gcc/rust/ChangeLog:

	PR rust/119341
	* rust-gcc.cc (function_type): Use range fors.
	(function_type_variadic): Likewise.
	(fill_in_fields): Likewise.
	(statement_list): Likewise.
	(block): Likewise.
	(block_add_statements): Likewise.
	(function_set_parameters): Likewise.
	(write_global_definitions): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14 18:23:52 +02:00
Andrew Pinski
a2db03fdf3 rust: Use error_operand_p in rust-gcc.cc
Just a simple cleanupof the code to use error_operand_p
instead of directly comparing against error_mark_node.

This also moves some cdoe around when dealing with error_operand_p
just to be faster and/or slightly tighten up the code slightly.

gcc/rust/ChangeLog:

	* rust-gcc.cc (Bvariable::get_tree): Use error_operand_p.
	(pointer_type): Likewise.
	(reference_type): Likewise.
	(immutable_type): Likewise.
	(function_type): Likewise.
	(function_type_variadic): Likewise.
	Cleanup the check for receiver.type first.
	(function_ptr_type): Use error_operand_p.
	(fill_in_fields): Likewise.
	(fill_in_array): Likewise.
	(named_type): Likewise.
	(type_size): Likewise.
	(type_alignment): Likewise.
	(type_field_alignment): Likewise.
	(type_field_offset): Likewise.
	(zero_expression): Likewise.
	(float_constant_expression): Likewise.
	(convert_expression): Likewise.
	(struct_field_expression): Likewise.
	(compound_expression): Likewise.
	(conditional_expression): Likewise.
	(negation_expression): Likewise.
	(arithmetic_or_logical_expression): Likewise.
	(arithmetic_or_logical_expression_checked): Likewise.
	(comparison_expression): Likewise.
	(lazy_boolean_expression): Likewise.
	(constructor_expression): Likewise.
	(array_constructor_expression): Likewise.
	(array_index_expression): Likewise.
	(call_expression): Likewise.
	(init_statement): Likewise.
	(assignment_statement): Likewise.
	(return_statement): Likewise.
	(exception_handler_statement): Likewise.
	(if_statement): Likewise.
	(compound_statement): Likewise.
	Tighten up the code, removing t variable.
	(statement_list): Use error_operand_p.
	(block): Likewise.
	(block_add_statements): Likewise.
	(convert_tree): Likewise.
	(global_variable): Likewise.
	(global_variable_set_init): Likewise.
	(local_variable): Likewise.
	(parameter_variable): Likewise.
	(static_chain_variable): Likewise.
	(temporary_variable): Likewise.
	(function): Likewise. Tighten up the code.
	(function_defer_statement): Use error_operand_p.
	(function_set_parameters): Use error_operand_p.
	(write_global_definitions): Use error_operand_p.
	Tighten up the code around the loop.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14 18:23:52 +02:00
Andrew Pinski
3eb76b8c62 rust: Use FLOAT_TYPE_P instead of manual checking
This moves is_floating_point over to using FLOAT_TYPE_P instead
of manually checking. Note before it would return true for all
COMPLEX_TYPE but complex types' inner type could be integral.

Also fixes up the comment to be in more of the GNU style.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/rust/ChangeLog:

	* rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P
	instead of manually checking the type.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14 18:23:51 +02:00
Andrew Pinski
d45a6502d1 testcase: Add testcase for already fixed PR [PR118476]
This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

	PR tree-optimization/118476

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr118476-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-14 09:08:22 -07:00
Patrick Palka
00966a7fdb c++: wrong targs in satisfaction diagnostic context line [PR99214]
In the three-parameter version of satisfy_declaration_constraints, when
't' isn't the most general template, then 't' won't correspond with
'args' after we augment the latter via add_outermost_template_args, and
so the instantiation context that we push via push_tinst_level isn't
quite correct: 'args' is a complete set of template arguments, but 't'
is not necessarily the most general template.  This manifests as
misleading diagnostic context lines when issuing a satisfaction failure
error, e.g.  the below testcase without this patch we emit:
  In substitution of '... void A<int>::f<U>() ... [with U = int]'
and with this patch we emit:
  In substitution of '... void A<int>::f<U>() ... [with U = char]'.

This patch fixes this by passing the original 'args' to push_tinst_level,
which ought to properly correspond to 't'.

	PR c++/99214

gcc/cp/ChangeLog:

	* constraint.cc (satisfy_declaration_constraints): Pass the
	original ARGS to push_tinst_level.

gcc/testsuite/ChangeLog:

	* g++.dg/concepts/diagnostic20.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2025-04-14 11:20:13 -04:00
Andreas Schwab
6518799b2d libgcobol: Add missing float128 suffix
* libgcobol.cc (__gg__float64_from_128): Mark literal as float128
	literal.
2025-04-14 15:09:08 +02:00
H.J. Lu
0a074b8c7e APX: Don't use red-zone with 32 GPRs and no caller-saved registers
Don't use red-zone when there are no caller-saved registers with 32 GPRs
since 128-byte red-zone is too small for 31 GPRs.

gcc/

	PR target/119784
	* config/i386/i386.cc (ix86_using_red_zone): Don't use red-zone
	with 32 GPRs and no caller-saved registers.

gcc/testsuite/

	PR target/119784
	* gcc.target/i386/pr119784a.c: New test.
	* gcc.target/i386/pr119784b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-14 05:56:04 -07:00
Martin Jambor
6b6611f814
ipa-cp: Use the collected pass-through types to propgate constants (PR118097)
This patch revisits the fix for PR 118097 and instead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.

It is bigger than the ones for propagating value ranges and known bits
because we track constants both in parameters themselves and also in
memory they point to or within aggregates, we clone functions for them
and we do fancy things for some types of recursive calls.

In the case of constants in aggregates or passed by reference, the
situation should not change because the code creating jump functions
for them does not allow type-casts, unlike for the plain ones.
However, this patch changes how we handle them for the sake of
consistency and also so that we can try and eliminate this limitation
in the next stage 1.

gcc/ChangeLog:

2025-03-20  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118097
	* ipa-cp.cc (ipa_get_jf_arith_result): Require res_operand for
	anything except NOP_EXPR or ADDR_EXPR, document it and remove the code
	trying to deduce it.
	(ipa_value_from_jfunc): Use the stored and streamed type of arithmetic
	pass-through functions.
	(ipa_agg_value_from_jfunc): Use the stored and streamed type of
	arithmetic pass-through functions, convert to the type used to store
	the value if necessary.
	(get_val_across_arith_op): New parameter op_type, pass it to
	ipa_get_jf_arith_result.
	(propagate_vals_across_arith_jfunc): New parameter op_type, pass it to
	get_val_across_arith_op.
	(propagate_vals_across_pass_through): Use the stored and streamed type
	of arithmetic pass-through functions.
	(propagate_aggregate_lattice): Likewise.
	(push_agg_values_for_index_from_edge): Use the stored and streamed
	type of arithmetic pass-through functions, convert to the type used to
	store the value if necessary.
2025-04-14 14:39:47 +02:00
Martin Jambor
4f19487f26
ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)
This patch revisits the fix for PR 118785 and intead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.  The main advantage is that we do not rely on
expr_type_first_operand_type_p enumarating all operations.

gcc/ChangeLog:

2025-03-20  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118785
	* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Use the stored
	and streamed type of arithmetic pass-through functions.
2025-04-14 14:39:39 +02:00
Martin Jambor
044d0d1ee1
ipa-cp: Make dumping of widest_ints even more sane
This patch just introduces a form of dumping of widest ints that only
have zeros in the lowest 128 bits so that instead of printing
thousands of f's the output looks like:

       Bits: value = 0xffff, mask = all ones folled by 0xffffffffffffffffffffffffffff0000

and then makes sure we use the function not only to print bits but
also to print masks where values like these can also occur.

gcc/ChangeLog:

2025-03-21  Martin Jambor  <mjambor@suse.cz>

	* ipa-cp.cc (ipcp_print_widest_int): Also add a truncated form of
	dumping of widest ints which only have zeros in the lowest 128 bits.
	Update the comment.
	(ipcp_bits_lattice::print): Also dump the mask using
	ipcp_print_widest_int.
	(ipcp_store_vr_results): Likewise.
2025-04-14 14:39:28 +02:00
Martin Jambor
de1c734a8a
ipa-cp: Make propagation of bits in IPA-CP aware of type conversions (PR119318)
After the propagation of constants and value ranges, it turns out
that the propagation of known bits also needs to be made aware of any
intermediate types in which any arithmetic operations are made and
must limit its precision there.  This implements just that, using the
newly collected and streamed types of the operations involved.

This version removed the extra check that the type of a formal
parameter is known pointed out in Honza in his review because I agree
it is currently always known.  I have also added the testcase of PR
119530 which is a duplicate of this bug.

gcc/ChangeLog:

2025-04-11  Martin Jambor  <mjambor@suse.cz>

	PR ipa/119318
	* ipa-cp.cc (ipcp_bits_lattice::meet_with_1): Set all mask bits
	not covered by precision to one.
	(ipcp_bits_lattice::meet_with): Likewise.
	(propagate_bits_across_jump_function): Use the stored operation
	type to perform meet with other lattices.

gcc/testsuite/ChangeLog:

2025-04-11  Martin Jambor  <mjambor@suse.cz>

	PR ipa/119318
	* gcc.dg/ipa/pr119318.c: New test.
	* gcc.dg/ipa/pr119530.c: Likwise.
2025-04-14 14:39:06 +02:00
Martin Jambor
f33d2e6b53
ipa: Record and stream result types of arithemetic jump functions
In order to replace the use of somewhat unweildy
expr_type_first_operand_type_p we need to record and stream the types
of results of operations recorded in arithmetic jump functions.  This
is necessary so that we can then simulate them at the IPA stage with
the corresponding precision and signedness.  This patch does the
recorsing and streaming, the following one adds the use of the date.

Per Honza's request this version also checks that we do not put VLA
types into the global LTO stream, even though I was not able to
actually craft a test-case that would do that without them.

gcc/ChangeLog:

2025-04-11  Martin Jambor  <mjambor@suse.cz>

	PR ipa/118097
	PR ipa/118785
	PR ipa/119318
	* lto-streamer.h (lto_variably_modified_type_p): Declare.
	* ipa-prop.h (ipa_pass_through_data): New field op_type.
	(ipa_get_jf_pass_through_op_type): New function.
	* ipa-prop.cc: Include lto-streamer.h.
	(ipa_dump_jump_function): Dump also pass-through
	operation types, if any.  Dump pass-through operands only if not NULL.
	(ipa_set_jf_simple_pass_through): Set op_type accordingly.
	(compute_complex_assign_jump_func): Set op_type of arithmetic
	pass-through jump_functions.
	(analyze_agg_content_value): Update lhs when walking assighment
	copies.  Set op_type of aggregate arithmetic pass-through
	jump_functions.
	(update_jump_functions_after_inlining): Also transfer the operation
	type from the source arithmentic pass-through jump function to the
	destination jump function.
	(ipa_write_jump_function): Stream also the op_type when necessary.
	(ipa_read_jump_function): Likewise.
	(ipa_agg_pass_through_jf_equivalent_p): Also compare operation types.
	* lto-streamer-out.cc (lto_variably_modified_type_p): Make public.
2025-04-14 14:33:37 +02:00
Jonathan Wakely
dd35f66287
libstdc++: Document thread-safety for COW std::string [PR21334]
The gcc4-compatible copy-on-write std::string does not conform to the
C++11 requirements on data race avoidance in standard containers.
Specifically, calling non-const member functions such as begin() and
data() needs to do the "copy on write" operation and so is most
definitely a modification of the object. As such, those non-const
members must not be called concurrently with any other uses of the
string object.

libstdc++-v3/ChangeLog:

	PR libstdc++/21334
	* doc/xml/manual/using.xml: Document that container data race
	avoidance rules do not apply to COW std::string.
	* doc/html/*: Regenerate.
2025-04-14 13:13:11 +01:00
Richard Biener
2f334a10bc tree-optimization/119757 - reject mixed mask/non-mask ldst SLP
The following makes sure to not mix masked/non-masked stmts when
forming a SLP node.

	PR tree-optimization/119757
	* tree-vect-slp.cc (vect_build_slp_tree_1): Record and compare
	whether a stmt uses a maks.

	* gcc.dg/vect/pr119757.c: New testcase.
2025-04-14 13:53:17 +02:00
Tomasz Kamiński
c2f1dda34d libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]
This changes the `dg-options` line so UTF-32 with byte order native to the
machine is used as wide encoding.

We still do not handle mismatch in the byte order of the Unicode encodings
(UTF32-BE on little-endian machines). This would require larger changes,
as for example `unicode-data.h` tables are encoded with native byte order.

	PR libstdc++/119725

libstdc++-v3/ChangeLog:

	* testsuite/std/format/debug.cc: Updated dg-options.
	* testsuite/std/format/debug_nonunicode.cc: Updated dg-options.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-04-14 13:19:15 +02:00
Richard Biener
a48f934211 tree-optimization/119778 - properly mark abnormal edge sources during inlining
When inlining a call that abnormally transfers control-flow we make
all inlined calls that can possibly transfer abnormal control-flow
do so as well.  But we failed to mark the calls as altering
control-flow.  This results in inconsistent behavior later and
possibly wrong-code (we'd eventually prune those edges).

	PR tree-optimization/119778
	* tree-inline.cc (copy_edges_for_bb): Mark calls that are
	source of abnormal edges as altering control-flow.

	* g++.dg/torture/pr119778.C: New testcase.
2025-04-14 13:00:40 +02:00
Gaius Mulley
9e0a98a47c PR modula2/119779 ASM examples no longer work
This patch introduces four dejagnu tests matching four
documentation examples.  Both asm examples are added and only built if
the x86_64 target is available.  The other two are hello world using
libc and StrIO.  The doc/gm2.texi asm examples are changed to
use eax rather than rax.

gcc/ChangeLog:

	PR modula2/119779
	* doc/gm2.texi (Interface to assembly language): Use eax
	rather than rax in both examples.

gcc/testsuite/ChangeLog:

	PR modula2/119779
	* gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test.
	* gm2.dg/doc/examples/pass/exampleadd.mod: New test.
	* gm2.dg/doc/examples/pass/exampleadd2.mod: New test.
	* gm2.dg/doc/examples/pass/hello.mod: New test.
	* gm2.dg/doc/examples/pass/hellopim.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-04-14 10:13:40 +01:00
Jakub Jelinek
5a32e85810 driver: On linux hosts disable ASLR during -freport-bug [PR119727]
Andi had a useful comment that even with the PR119727 workaround to
ignore differences in libbacktrace printed addresses, it is still better
to turn off ASLR when easily possible, e.g. in case some address leaks
in somewhere in the ICE message elsewhere, or to verify the ICE doesn't
depend on a particular library/binary load addresses.

The following patch adds a configure check and uses personality syscall
to turn off randomization for further -freport-bug subprocesses.

2025-04-14  Jakub Jelinek  <jakub@redhat.com>

	PR driver/119727
	* configure.ac (HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE): New check.
	* gcc.cc: Include sys/personality.h if
	HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
	(try_generate_repro): Call
	personality (personality (0xffffffffU) | ADDR_NO_RANDOMIZE)
	if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
	* config.in: Regenerate.
	* configure: Regenerate.
2025-04-14 10:18:13 +02:00
Eric Botcazou
5c82694319 Fix implementation of Win32 thread model for C++ modules
This applies the same magic to config/i386/gthr-win32.h that was applied
to gthr-posix.h (https://gcc.gnu.org/cgit/gcc/commit/?id=6a4d1c374eed17)
for the sake of C++ modules.

libgcc/
	PR target/119673
	* config/i386/gthr-win32.h (__GTHREAD_ALWAYS_INLINE): New macro.
	(__GTHREAD_INLINE): Likewise.
	(__GTHR_W32_InterlockedCompareExchange): Delete.
	(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
	static inline.
	(__gthread_create): Likewise.
	(__gthread_join): Likewise.
	(__gthread_self): Likewise.
	(__gthread_detach): Likewise.
	(__gthread_equal): Likewise.
	(__gthread_yield): Likewise.
	(__gthread_once): Likewise.
	(__gthread_key_create): Likewise.
	(__gthread_key_delete): Likewise.
	(__gthread_getspecific): Likewise.
	(__gthread_setspecific): Likewise.
	(__gthread_mutex_init_function): Likewise.
	(__gthread_mutex_destroy): Likewise.
	(__gthread_mutex_lock): Likewise.
	(__gthread_mutex_trylock): Likewise.
	(__gthread_mutex_timedlock): Likewise.
	(__gthread_mutex_unlock): Likewise.
	(__gthread_recursive_mutex_trylock): Likewise.
	(__gthread_cond_init_function): Likewise.
	(__gthread_cond_broadcast): Likewise.
	(__gthread_cond_signal): Likewise.
	(__gthread_cond_wait): Likewise.
	(__gthread_cond_timedwait): Likewise.
	(__GTHREAD_WIN32_INLINE): Likewise.
	(__GTHREAD_WIN32_COND_INLINE): Likewise.
	(__gthread_recursive_mutex_init_function): Likewise.
	(__gthread_recursive_mutex_destroy): Likewise.
	(__gthread_recursive_mutex_lock): Likewise.
	(__gthread_recursive_mutex_unlock): Likewise.
	(__gthread_cond_destroy): Likewise.
	(__gthread_cond_wait_recursive): Likewise.
2025-04-14 09:37:51 +02:00
Eric Botcazou
ec4bf5b6c2 Add testcase for PR lto/119792
It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
	PR lto/119792
	* gnat.dg/lto29.adb: New test.
	* gnat.dg/lto29_pkg.ads: New helper.
2025-04-14 09:26:52 +02:00
GCC Administrator
d72b4e9f78 Daily bump. 2025-04-14 00:16:58 +00:00