]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 months agogccrs: fix bad type inferencing on path's
Philip Herron [Fri, 1 Nov 2024 16:18:28 +0000 (16:18 +0000)] 
gccrs: fix bad type inferencing on path's

This catch to inject inference variables into generic paths was a
catch all 'hack' that we needed before we handled generics correctly
as we do now.

Fixes #3009

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): remove hack

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3009.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agogccrs: Make TyTy::TupleType::get_unit_type cache its return value
Owen Avery [Mon, 28 Oct 2024 23:02:23 +0000 (19:02 -0400)] 
gccrs: Make TyTy::TupleType::get_unit_type cache its return value

This removes a usage of Resolver::get_unit_type_node_id in
rust-hir-type-check-expr.cc (the HIR::TupleExpr overload of
TypeCheckExpr::visit).

gcc/rust/ChangeLog:

* typecheck/rust-tyty.cc
(TupleType::get_unit_type): Remove parameter, cache return
value.
* typecheck/rust-tyty.h
(TupleType::get_unit_type): Remove parameter.
* resolve/rust-late-name-resolver-2.0.cc
(Late::setup_builtin_types): Adjust calls to get_unit_type.
* resolve/rust-name-resolver.cc
(Resolver::generate_builtins): Likewise.
* typecheck/rust-hir-type-check-expr.cc
(TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.cc
(TypeCheckTopLevelExternItem::visit): Likewise.
(TypeCheckImplItem::visit): Likewise.
* typecheck/rust-hir-type-check-item.cc
(TypeCheckItem::visit): Likewise.
* typecheck/rust-hir-type-check-stmt.cc
(TypeCheckStmt::visit): Likewise.
* typecheck/rust-hir-type-check-type.cc
(TypeCheckType::visit): Likewise.
* typecheck/rust-hir-type-check.cc
(TraitItemReference::get_type_from_fn): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: add test case to show method resolution is working
Philip Herron [Fri, 1 Nov 2024 14:07:54 +0000 (14:07 +0000)] 
gccrs: add test case to show method resolution is working

The issue here was that the impl block for Cell<T> defines that T must have
the bound of Copy implemented. But simultaneously if you do an deref
you get direct access to the unsafe cell which also defines a get method
so these are two valid ways of accessing the method in question but
when Copy is implementet the simplest case is prefered so it does resolve
to Cell<T>::get.

Fixes #3033

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr can't handle this
* rust/compile/issue-3033.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agogccrs: Resolve SelfParam in name resolution 2.0
Owen Avery [Fri, 4 Oct 2024 16:56:16 +0000 (12:56 -0400)] 
gccrs: Resolve SelfParam in name resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle SelfParam.
* resolve/rust-late-name-resolver-2.0.h
(Late::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolution 2.0 in TraitResolver
Owen Avery [Sat, 26 Oct 2024 23:43:11 +0000 (19:43 -0400)] 
gccrs: Use name resolution 2.0 in TraitResolver

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc: Add includes.
(TraitResolver::resolve_path_to_trait):
Use name resolution 2.0 resolver when enabled.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agorust: Desugar IfLet* into MatchExpr
Marc Poulhiès [Wed, 12 Jun 2024 19:58:26 +0000 (21:58 +0200)] 
rust: Desugar IfLet* into MatchExpr

Replace the "regular" AST->HIR lowering for IfLet* with a desugaring
into a MatchExpr.

Desugar a simple if let:

   if let Some(y) = some_value {
     bar();
   }

into:

   match some_value {
     Some(y) => {bar();},
     _ => ()
   }

Same applies for IfLetExprConseqElse (if let with an else block).

Desugar:

   if let Some(y) = some_value {
     bar();
   } else {
     baz();
   }

into:

   match some_value {
     Some(y) => {bar();},
     _ => {baz();}
   }

Fixes https://github.com/Rust-GCC/gccrs/issues/1177

gcc/rust/ChangeLog:

* backend/rust-compile-block.h: Adjust after removal of
HIR::IfLetExpr and HIR::IfLetExprConseqElse.
* backend/rust-compile-expr.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc
(ExprStmtBuilder::visit): Likewise.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h:
Likewise.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc
(PrivacyReporter::visit): Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit):
Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit):
Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-block.h (ASTLoweringIfLetBlock::translate):
Change return type.
* hir/rust-ast-lower.cc (ASTLoweringIfLetBlock::desugar_iflet):
New.
(ASTLoweringIfLetBlock::visit(AST::IfLetExpr &)): Adjust and use
desugar_iflet.
* hir/rust-ast-lower.h: Add comment.
* hir/rust-hir-dump.cc (Dump::do_ifletexpr): Remove.
(Dump::visit(IfLetExpr&)): Remove.
(Dump::visit(IfLetExprConseqElse&)): Remove.
* hir/rust-hir-dump.h (Dump::do_ifletexpr): Remove.
(Dump::visit(IfLetExpr&)): Remove.
(Dump::visit(IfLetExprConseqElse&)): Remove.
* hir/tree/rust-hir-expr.h (class IfLetExpr): Remove.
(class IfLetExprConseqElse): Remove.
* hir/tree/rust-hir-full-decls.h (class IfLetExpr): Remove.
(class IfLetExprConseqElse): Remove.
* hir/tree/rust-hir-visitor.h: Adjust after removal of
HIR::IfLetExpr and HIR::IfLetExprConseqElse.
* hir/tree/rust-hir.cc (IfLetExpr::as_string): Remove.
(IfLetExprConseqElse::as_string): Remove.
(IfLetExpr::accept_vis): Remove.
(IfLetExprConseqElse::accept_vis): Remove.
* hir/tree/rust-hir.h: Adjust after removal of HIR::IfLetExpr and
HIR::IfLetExprConseqElse.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* checks/errors/rust-hir-pattern-analysis.cc
(PatternChecker::visit (IfLetExpr &)): Remove.
(PatternChecker::visit (IfLetExprConseqElse &)): Remove.
* checks/errors/rust-hir-pattern-analysis.h (visit(IfLetExpr &)): Remove.
(visit(IfLetExprConseqElse &)): Remove.

gcc/testsuite/ChangeLog:

* rust/compile/if_let_expr.rs: Adjust.
* rust/compile/if_let_expr_simple.rs: New test.
* rust/compile/iflet.rs: New test.
* rust/execute/torture/iflet.rs: New test.
* rust/compile/nr2/exclude: Add iflet.rs and if_let_expr_simple.rs

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
4 months agogccrs: Fix name resolution 2.0 definition lookups in unsafe checker
Owen Avery [Wed, 9 Oct 2024 04:16:27 +0000 (00:16 -0400)] 
gccrs: Fix name resolution 2.0 definition lookups in unsafe checker

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc: Add includes.
(UnsafeChecker::visit): Use 2.0 version of resolver when name
resolution 2.0 is enabled.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Improve path handling while testing name resolution 2.0
Owen Avery [Thu, 17 Oct 2024 00:18:48 +0000 (20:18 -0400)] 
gccrs: Improve path handling while testing name resolution 2.0

gcc/testsuite/ChangeLog:

* rust/compile/nr2/compile.exp: Handle paths using "file join"
and "file split".
* rust/compile/nr2/exclude: Remove debug-diagnostics-on.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolver 2.0 in CompileTraitItem
Owen Avery [Sat, 26 Oct 2024 23:53:42 +0000 (19:53 -0400)] 
gccrs: Use name resolver 2.0 in CompileTraitItem

gcc/rust/ChangeLog:

* backend/rust-compile-implitem.cc
(CompileTraitItem::visit): Use name resolver 2.0 (when enabled)
to obtain canonical paths for instances of TraitItemConst and
TraitItemFunc.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolution 2.0 in TraitItemReference
Owen Avery [Sun, 27 Oct 2024 19:55:48 +0000 (15:55 -0400)] 
gccrs: Use name resolution 2.0 in TraitItemReference

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check.cc: Add includes.
(TraitItemReference::get_type_from_fn): Use
ForeverStack::to_canonical_path when name resolution 2.0 is
enabled.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Rename some PathIdentSegment functions
Owen Avery [Sat, 26 Oct 2024 19:05:43 +0000 (15:05 -0400)] 
gccrs: Rename some PathIdentSegment functions

This makes PathIdentSegment more similar to other classes used to
represent path segments.

gcc/rust/ChangeLog:

* ast/rust-path.h
(PathIdentSegment::is_super_segment): Rename to...
(PathIdentSegment::is_super_path_seg): ...here.
(PathIdentSegment::is_crate_segment): Rename to...
(PathIdentSegment::is_crate_path_seg): ...here.
(PathIdentSegment::is_lower_self): Rename to...
(PathIdentSegment::is_lower_self_seg): ...here.
(PathIdentSegment::is_big_self): Rename to...
(PathIdentSegment::is_big_self_seg): ...here.

(PathExprSegment::is_super_path_seg): Handle renames.
(PathExprSegment::is_crate_path_seg): Likewise.
(PathExprSegment::is_lower_self_seg): Likewise.
(TypePathSegment::is_crate_path_seg): Likewise.
(TypePathSegment::is_super_path_seg): Likewise.
(TypePathSegment::is_big_self_seg): Likewise.
(TypePathSegment::is_lower_self_seg): Likewise.
* ast/rust-ast-collector.cc
(TokenCollector::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Add a newline to the end of nr2/exclude
Owen Avery [Thu, 24 Oct 2024 18:20:29 +0000 (14:20 -0400)] 
gccrs: Add a newline to the end of nr2/exclude

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Add trailing newline along with
comment.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Fix variable shadowing in late resolution 2.0
Owen Avery [Sun, 27 Oct 2024 17:32:09 +0000 (13:32 -0400)] 
gccrs: Fix variable shadowing in late resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Visit the initialization expressions of let
statements before visiting their patterns.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Insert trait names during toplevel resolution 2.0
Owen Avery [Wed, 16 Oct 2024 04:40:01 +0000 (00:40 -0400)] 
gccrs: Insert trait names during toplevel resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Insert trait names into the type namespace.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Fix bad recursive operator overload call
Philip Herron [Fri, 11 Oct 2024 16:53:50 +0000 (17:53 +0100)] 
gccrs: Fix bad recursive operator overload call

When we are typechecking the impl block for DerefMut for &mut T
the implementation follows the usual operator overload check
but this ended up just resolving directly to the Trait definition
which ends up being recursive which we usually handle. The issue
we had is that a dereference call can be for either the DEREF
or DEREF_MUT lang item here it was looking for a recurisve call
to the DEREF lang item but we were in the DEREF_MUT lang item
so this case was not accounted for.

Fixes #3032

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-reference.h: new get locus helper
* typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::get_locus): implemention
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_operator_overload):
fix overload

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3032-1.rs: New test.
* rust/compile/issue-3032-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agoicf: Punt for musttail call flag differences in ICF [PR119376]
Jakub Jelinek [Fri, 21 Mar 2025 11:18:35 +0000 (12:18 +0100)] 
icf: Punt for musttail call flag differences in ICF [PR119376]

The following testcase shows we were ignoring musttail flags on calls
when deciding if two functions are the same.
That can result in problems in both directions, either we silently
lose musttail attribute because there is a similar function without it
earlier and then we e.g. don't diagnose if it can't be tail called
or don't try harder to do a tail call, or we get it even in functions
which didn't have it before.

The following patch for now just punts if it differs.  Perhaps we could
just merge it and get musttail flag if any of the merged functions had
one in such position, but it feels to me that it is now too late in GCC 15
cycle to play with this.

2025-03-21  Jakub Jelinek  <jakub@redhat.com>

PR ipa/119376
* ipa-icf-gimple.cc (func_checker::compare_gimple_call): Return false
for gimple_call_must_tail_p mismatches.

* c-c++-common/musttail27.c: New test.

4 months agofnsplit: Set musttail call during function splitting if there are musttail calls...
Jakub Jelinek [Fri, 21 Mar 2025 11:17:45 +0000 (12:17 +0100)] 
fnsplit: Set musttail call during function splitting if there are musttail calls [PR119376]

The just posted inliner patch can regress musttail calls if we perform
function splitting and then inline the outlined body back into the original
(or inline both the small function and outlined large body into something
else).
If there are any musttail calls, I think we need to call the outlined
body using a musttail call, so that the inliner will preserve musttail
attributes in the body.

2025-03-21  Jakub Jelinek  <jakub@redhat.com>

PR ipa/119376
* ipa-split.cc (split_function): Call gimple_call_set_must_tail
on the call to outlined partition if has_musttail and
!add_tsan_func_exit.

* g++.dg/opt/musttail1.C: New test.

4 months agoinliner: Silently drop musttail flag on calls during inlining unless the inlined...
Jakub Jelinek [Fri, 21 Mar 2025 11:17:01 +0000 (12:17 +0100)] 
inliner: Silently drop musttail flag on calls during inlining unless the inlined routine was musttail called [PR119376]

As discussed in the PR, some packages fail to build because they use
musttail attribute on calls in functions which we inline, and if they
are inlined into a middle of the function, that results in an error
because we have a musttail call in the middle of a function and so it
can't be tail called there.

Now, guess the primary intent of the musttail attribute is ensuring
we don't get an extra stack frame in the backtrace.  Inlining itself
removes one extra stack frame from the backtrace as well (sure, not
counting virtual backtraces in gdb), so I think erroring out on that
is unnecessary.

Except when we are inlining a musttail call which has musttail calls
in it, in that case we are being asked to remove 2 stack frames from
the backtrace, inlining removes one, so we need to keep musttail
on the calls so that another stack frame is removed through a tail call.

The following patch implements that, keeping previous behavior when
id->call_stmt is NULL (i.e. when versioning/cloning etc.).

2025-03-21  Jakub Jelinek  <jakub@redhat.com>

PR ipa/119376
* tree-inline.cc (remap_gimple_stmt): Silently clear
gimple_call_must_tail_p on inlined call stmts if id->call_stmt
is a call without that flag set.

* c-c++-common/musttail26.c: New test.

4 months agolibstdc++: Fix localized %c formatting for non-UTC times [PR117214]
Jonathan Wakely [Wed, 19 Mar 2025 22:05:28 +0000 (22:05 +0000)] 
libstdc++: Fix localized %c formatting for non-UTC times [PR117214]

The previous commit fixed most cases of %c formatting, but it
incorrectly prints times using the system's local time zone. This only
matters if the locale's %c format includes %Z, but some do.

To print a correct value for %Z we can set tm.tm_zone to either "UTC" or
the abbreviation passed to the formatter in the local-time-format-t
structure.

For local times with no info and for systems that don't support tm_zone
(which is new in POSIX.1-2024) we just set tm_isdst = -1 so that no zone
name is printed.

In theory, a locale's %c format could use %z which should print a +hhmm
offset from UTC. I'm unsure how to control that though. The new
tm_gmtoff field in combination with tm_isdst != -1 seems like it should
work, but using that without also setting tm_zone causes the system zone
to be used for %Z again. That means local_time_format(lt, nullptr, &off)
might work for a locale that uses %z but prints the wrong thing for %Z.
This commit doesn't set tm_gmtoff even if _M_offset_sec is provided for
a local-time-format-t value.

libstdc++-v3/ChangeLog:

PR libstdc++/117214
* configure.ac: Use AC_STRUCT_TIMEZONE.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/chrono_io.h (__formatter_chrono::_M_c): Set
tm_isdst and tm_zone.
* testsuite/std/time/format/pr117214.cc: Check %c formatting of
zoned_time and local time.

4 months agolibstdc++: Fix localized D_T_FMT %c formatting for <chrono> [PR117214]
XU Kailiang [Sat, 1 Mar 2025 05:23:21 +0000 (13:23 +0800)] 
libstdc++: Fix localized D_T_FMT %c formatting for <chrono> [PR117214]

Formatting a time point with %c was implemented by calling
std::vprint_to with format string constructed from locale's D_T_FMT
string, but in some locales this string contains strftime specifiers
which are not valid for chrono-specs, e.g. %l. So just use _M_locale_fmt
to avoid this problem.

libstdc++-v3/ChangeLog:

PR libstdc++/117214
* include/bits/chrono_io.h (__formatter_chrono::_M_c): Use
_M_locale_fmt to format %c time point.
* testsuite/std/time/format/pr117214.cc: New test.

Signed-off-by: XU Kailiang <xu2k3l4@outlook.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
4 months agolibstdc++: Use formatting locale for std::time_put formats
Jonathan Wakely [Wed, 19 Mar 2025 19:38:15 +0000 (19:38 +0000)] 
libstdc++: Use formatting locale for std::time_put formats

When using std::time_put to format a chrono value, we should imbue the
formatting locale into the stream. This ensures that when
std::time_put::do_put uses a ctype or __timepunct facet from the locale,
it gets the correct facets.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__formatter_chrono::_M_locale_fmt):
Imbue locale into ostringstream.
* testsuite/std/time/format/localized.cc: Check that correct
locale is used for call to time_put::put.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Simplify std::vector::vector(from_range_t, const Alloc&)
Jonathan Wakely [Thu, 20 Mar 2025 09:52:35 +0000 (09:52 +0000)] 
libstdc++: Simplify std::vector::vector(from_range_t, const Alloc&)

Tomasz suggested replacing this constructor with just append_range(rg),
after using a delegating constructor so that the destructor will run if
append_range exits via an exception.

This is slightly less simple than his suggestion, because I want to
avoid the overhead of reserve's slow path and the ASan annotations.
Neither of those is needed for this constructor, because we have no
existing storage to reallocate and no unused capacity to tell ASan
about.

libstdc++-v3/ChangeLog:

* include/bits/stl_vector.h (vector(from_range_t, Alloc)): Use
delegating constructor instead of RAII guards. Use append_range
for unsized input range case.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agocobol: Rename COB_{BLOCK,UNSIGNED,SIGNED} to {BLOCK,UNSIGNED,SIGNED}_kw for consistency
Jakub Jelinek [Fri, 21 Mar 2025 09:48:10 +0000 (10:48 +0100)] 
cobol: Rename COB_{BLOCK,UNSIGNED,SIGNED} to {BLOCK,UNSIGNED,SIGNED}_kw for consistency

On Wed, Mar 19, 2025 at 06:03:24PM -0400, James K. Lowden wrote:
> Elsewhere in the parser where there was a conflict like that, I renamed
> the token.  For example, the COBOL word TRUE uses a token named
> TRUE_kw.  I don't mind either way; your solution has less impact on the
> parser.

I think consistency is good and when it is a suffix rather than prefix,
it also sorts alphabetically together with the actual keywords.

2025-03-21  Jakub Jelinek  <jakub@redhat.com>

* parse.y: Rename COB_BLOCK to BLOCK_kw, COB_SIGNED to SIGNED_kw and
COB_UNSIGNED to UNSIGNED_kw.
* scan.l: Likewise.
* token_names.h: Regenerate.

4 months agolibstdc++: Fix std.compat exports of <stdbit.h> and <stdckdint.h>
Jonathan Wakely [Thu, 20 Mar 2025 18:47:33 +0000 (18:47 +0000)] 
libstdc++: Fix std.compat exports of <stdbit.h> and <stdckdint.h>

libstdc++-v3/ChangeLog:

* src/c++23/std.compat.cc.in: Only export <stdbit.h> and
<stdckdint.h> contents for C++26 and later.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Add views::cache_latest and views::to_input to std module
Jonathan Wakely [Thu, 20 Mar 2025 18:48:20 +0000 (18:48 +0000)] 
libstdc++: Add views::cache_latest and views::to_input to std module

Also export the tuple-like helpers from <complex>, and the
std::from_range_t and std::from_range tag.

libstdc++-v3/ChangeLog:

* src/c++23/std.cc.in (tuple_element, tuple_element_t)
(tuple_size, tuple_size_v, get): Export.
(ranges::cache_latest_view, views::cache_latest): Export.
(ranges::to_input_view, views::to_input): Export.
(from_range_t, from_range): Export.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agomove global data to symbol_table_init
Richard Biener [Thu, 20 Mar 2025 09:48:38 +0000 (10:48 +0100)] 
move global data to symbol_table_init

The following avoids early runtime initialization of cbl_field_t
objects which, when using tree to represent the current _Float128
data, segfaults as tree data like float128_type_node is not yet
initialized.  The solution is to move the global data to
symbol_table_init which is the only user and it already has one
such instance locally, the 'constants' array.

* symbols.cc (empty_float, empty_comp5, empty_literal,
empty_conditional, debug_registers, special_registers): Move
global cbl_field_t typed data to ...
(symbol_table_init): ... local scope here.

4 months agos390: Accept only Pmode for registers AP/FP/RA [PR119235]
Stefan Schulze Frielinghaus [Fri, 21 Mar 2025 09:29:19 +0000 (10:29 +0100)] 
s390: Accept only Pmode for registers AP/FP/RA [PR119235]

gcc/ChangeLog:

PR target/119235
* config/s390/s390.cc (s390_hard_regno_mode_ok): Accept only
Pmode for registers AP/FP/RA.

4 months agomake sources coretypes.h and tree.h clean
Richard Biener [Wed, 19 Mar 2025 14:09:03 +0000 (15:09 +0100)] 
make sources coretypes.h and tree.h clean

The following removes HOWEVER_GCC_DEFINES_TREE and the alternate
definition of tree from symbols.h and instead ensures that both
coretypes.h and tree.h are included where required.  This required
putting GCCs own 'NONE' in a scoped enum (see separate patch) and
renaming the cobol use of UNSIGNED, SIGNED and BLOCK which conflict
with enums from tree.h.

There's a few things in conflict with options.h defines, notably
cobol_dialect and cobol_exceptions but also yy_flex_debug (wherever
that comes from).  I've chosen to simply #undef those where
appropriate.  I've refrained from putting the coretypes.h and
tree.h includes in cobol-system.h since not all files require this.

This helps in making use of real.h instead of using _Float128.

PR cobol/119241
gcc/cobol/
* symbols.h: Do not typedef tree.
* cdf.y: Include coretypes.h and tree.h.
* symbols.cc: Likewise.
* symfind.cc: Likewise.
* util.cc: Likewise.
* parse.y: Include coretypes.h and tree.h where appropriate.
Rename BLOCK to COB_BLOCK, SIGNED to COB_SIGNED, UNSIGNED
to COB_UNSIGNED.
* scan.l: Likewise.
* token_names.h: Likewise.
* cobol1.cc: Do not define HOWEVER_GCC_DEFINES_TREE.
* except.cc: Likewise.
* genapi.cc: Likewise.
* gengen.cc: Likewise.
* genmath.cc: Likewise.
* genutil.cc: Likewise.
* structs.cc: Likewise.

4 months agoFortran: Fix double free on polymorphic array dummy argument [PR119349]
Andre Vehreschild [Thu, 20 Mar 2025 12:37:21 +0000 (13:37 +0100)] 
Fortran: Fix double free on polymorphic array dummy argument [PR119349]

Calling elemental routines with polymorphic formals leads to generation
of a temporary polymorphic variable and code for its deallocation.
Sourcing this element from an array constructor the latter now is
prevented from generating a second deallocation.

PR fortran/119349

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): Prevent deallocation
of array temporary for polymorphic temporary argument.

gcc/testsuite/ChangeLog:

* gfortran.dg/class_79.f90: New test.

4 months agoPut early debug generation under TV_SYMOUT
Richard Biener [Thu, 20 Mar 2025 18:48:36 +0000 (19:48 +0100)] 
Put early debug generation under TV_SYMOUT

Like all other debug info generation this should be with TV_SYMOUT,
otherwise it's recorded as TV_CGRAPH.

* cgraphunit.cc (symbol_table::finalize_compilation_unit):
Put early debug generation under TV_SYMOUT.

4 months agoDaily bump.
GCC Administrator [Fri, 21 Mar 2025 00:17:25 +0000 (00:17 +0000)] 
Daily bump.

4 months agocombine: Add REG_DEAD notes to the last instruction after a split [PR118914]
Andrew Pinski [Thu, 20 Feb 2025 00:10:31 +0000 (16:10 -0800)] 
combine: Add REG_DEAD notes to the last instruction after a split [PR118914]

So gcc.target/aarch64/rev16_2.c started to fail after r15-268-g9dbff9c05520a7,
the problem is combine now rejects the instruction combine. This happens because
after a different combine which uses a define_split and that define_split creates
a new pseudo register. That new pseudo register is dead after the last instruction
in the stream BUT combine never creates a REG_DEAD for it. So combine thinks it is
still needed after and now with the i2 not changing, combine rejects the combine.

Now combine should be creating a REG_DEAD for the new pseudo registers for the last
instruction of the split. This fixes rev16_2.c and also improves the situtation in
other cases by removing other dead instructions.

Bootstrapped and tested on aarch64-linux-gnu and x86_64-linux-gnu.

gcc/ChangeLog:

PR rtl-optimization/118914
* combine.cc (recog_for_combine): Add old_nregs and new_nregs
argument (defaulting to 0). Update call to recog_for_combine_1.
(combine_split_insns): Add old_nregs and new_nregs arguments,
store the old and new max registers to them.
(try_combine): Update calls to combine_split_insns and
pass old_nregs and new_nregs for the i3 call to recog_for_combine.
(find_split_point): Update call to combine_split_insns; ignoring
the values there.
(recog_for_combine_1): Add old_nregs and new_nregs arguments,
if the insn was recognized (and not to no-op move), add the
REG_DEAD notes to pnotes argument.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
4 months agod: Fix quoted command-line options to match lang.opt [PR118545]
Iain Buclaw [Thu, 20 Mar 2025 23:28:45 +0000 (00:28 +0100)] 
d: Fix quoted command-line options to match lang.opt [PR118545]

It was noticed that not all D language options get a url in diagnostics.
These have been checked and fixed as necessary.

PR d/118545

gcc/d/ChangeLog:

* d-lang.cc (d_handle_option): Adjust quoted options.

4 months agomodula2: Defend against no ENOTBLK definition
Gaius Mulley [Thu, 20 Mar 2025 22:23:38 +0000 (22:23 +0000)] 
modula2: Defend against no ENOTBLK definition

This patch defends against no ENOTBLK definition.

libgm2/ChangeLog:

* libm2iso/ErrnoCategory.cc (IsErrnoHard): Defend against
lack of ENOTBLK.
(UnAvailable): Ditto.
(GetOpenResults): Ditto.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 months agoPR modula2/118600 Assigning to a record causes alignment exception
Gaius Mulley [Thu, 20 Mar 2025 20:10:31 +0000 (20:10 +0000)] 
PR modula2/118600 Assigning to a record causes alignment exception

This patch recursively tests every assignment (of a constructor
to a designator) to ensure the types are GCC equivalent.  If they
are equivalent then it uses gimple assignment and if not then it
copies a structure by field and uses __builtin_strncpy to copy a
string cst into an array.  Unions are copied by __builtin_memcpy.

gcc/m2/ChangeLog:

PR modula2/118600
* gm2-compiler/M2GenGCC.mod (PerformCodeBecomes): New procedure.
(CodeBecomes): Refactor and call PerformCodeBecomes.
* gm2-gcc/m2builtins.cc (gm2_strncpy_node): New global variable.
(DoBuiltinStrNCopy): New function.
(m2builtins_BuiltinStrNCopy): New function.
(m2builtins_init): Initialize gm2_strncpy_node.
* gm2-gcc/m2builtins.def (BuiltinStrNCopy): New procedure
function.
* gm2-gcc/m2builtins.h (m2builtins_BuiltinStrNCopy): New
function.
* gm2-gcc/m2statement.cc (copy_record_fields): New function.
(copy_array): Ditto.
(copy_strncpy): Ditto.
(copy_memcpy): Ditto.
(CopyByField_Lower): Ditto.
(m2statement_CopyByField): Ditto.
* gm2-gcc/m2statement.def (CopyByField): New procedure function.
* gm2-gcc/m2statement.h (m2statement_CopyByField): New function.
* gm2-gcc/m2type.cc (check_record_fields): Ditto.
(check_array_types): Ditto.
(m2type_IsGccStrictTypeEquivalent): Ditto.
* gm2-gcc/m2type.def (IsGccStrictTypeEquivalent): New procedure
function.
* gm2-gcc/m2type.h (m2type_IsAddress): Replace return type int
with bool.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 months agocobol: Do not overload int64_t, overload long and long long.
Iain Sandoe [Sun, 16 Mar 2025 00:18:01 +0000 (00:18 +0000)] 
cobol: Do not overload int64_t, overload long and long long.

Since the type that is ued for int64_t varies between platforms trying
to overload it creates ambiguous or conflicting overloads.

gcc/cobol/ChangeLog:

* cdfval.h (struct cdfval_t): Overload long instead of int64_t.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agolibgcobol: Add configure checks for iconv.
Iain Sandoe [Sun, 16 Mar 2025 08:58:09 +0000 (08:58 +0000)] 
libgcobol: Add configure checks for iconv.

Some targets might need to add libraries to get iconv support.

libgcobol/ChangeLog:

* Makefile.am: Use LIBICONV.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for iconv support.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
4 months agoUpdate gcc hr.po
Joseph Myers [Thu, 20 Mar 2025 19:34:30 +0000 (19:34 +0000)] 
Update gcc hr.po

* hr.po: Update.

4 months agotree-optimization/119389 - limit edge processing in dominated_by_p_w_unex
Richard Biener [Thu, 20 Mar 2025 14:08:33 +0000 (15:08 +0100)] 
tree-optimization/119389 - limit edge processing in dominated_by_p_w_unex

The following removes quadraticness when visiting each predecessor
of a large CFG merge with dominated_by_p_w_unex.

PR tree-optimization/119389
* tree-ssa-sccvn.cc (dominated_by_p_w_unex): Limit the number
of predecessors of a CFG merge we try to skip.

4 months agoUpdate cpplib de.po
Joseph Myers [Thu, 20 Mar 2025 17:30:54 +0000 (17:30 +0000)] 
Update cpplib de.po

* de.po: Update.

4 months agoRevert "s390: Deprecate ESA/390 support"
Stefan Schulze Frielinghaus [Thu, 20 Mar 2025 15:48:24 +0000 (16:48 +0100)] 
Revert "s390: Deprecate ESA/390 support"

The intention of -m31 -mesa and -m31 -mzarch was that they are (ABI)
compatible which is almost true except as it turns out they are not for
attribute mode(word).

After doing some archaeology and digging out an over 18 year old thread
[1,2] which is about this very attribute, I come to the conclusion to
revert this patch.  The intention by deprecating and eventually removing
ESA/390 support was to prepare for a future removal of -m31; though in
smaller steps.  Thus, instead of introducing some potential hick ups
along the route, I will revert this patch and will revisit this topic
when time for -m31 in its entirety has come---independent of
-mesa/-mzarch.

[1] https://gcc.gnu.org/pipermail/gcc-patches/2006-September/200465.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2006-October/201154.html

This reverts commit 3b1bd1fdcd241dd1e5b706b6937400d74ca43146.

4 months agogimple: sccopy: Don't increment i after vec::unordered_remove()
Filip Kastl [Thu, 20 Mar 2025 10:54:59 +0000 (11:54 +0100)] 
gimple: sccopy: Don't increment i after vec::unordered_remove()

I increment the index variable in a loop even when I do
vec::unordered_remove() which causes the vector traversal to miss some
elements.  Mikael notified me of this mistake I made in my last patch.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (scc_copy_prop::propagate): Don't
increment after vec::unordered_remove().

Reported-by: Mikael Morin <mikael@gcc.gnu.org>
Signed-off-by: Filip Kastl <fkastl@suse.cz>
4 months agolibstdc++: Add from_range_t constructors to debug unordered containers
Tomasz Kamiński [Thu, 20 Mar 2025 11:08:00 +0000 (12:08 +0100)] 
libstdc++: Add from_range_t constructors to debug unordered containers

libstdc++-v3/ChangeLog:

* include/debug/unordered_map (unordered_map): Add from_range
constructors and deduction guides.
(unordered_multimap): Likewise.
* include/debug/unordered_set (unordered_set): Add from_range
constructors and deduction guides.
(unordered_multiset): Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Add from_range_t constructors to debug ordered containers
Jonathan Wakely [Wed, 19 Mar 2025 22:22:56 +0000 (22:22 +0000)] 
libstdc++: Add from_range_t constructors to debug ordered containers

libstdc++-v3/ChangeLog:

* include/debug/map.h (map): Add from_range constructors and
deduction guides.
* include/debug/multimap.h (multimap): Likewise.
* include/debug/multiset.h (multiset): Likewise.
* include/debug/set.h (set): Likewise.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 months agolibstdc++: Fix comment typo
Jakub Jelinek [Thu, 20 Mar 2025 09:36:29 +0000 (10:36 +0100)] 
libstdc++: Fix comment typo

Another IEE typo.

2025-03-20  Jakub Jelinek  <jakub@redhat.com>

* testsuite/18_support/numeric_limits/traps.cc (main): Fix comment
typo.

4 months agoMake function_decl_type a scoped enum
Richard Biener [Wed, 19 Mar 2025 14:02:23 +0000 (15:02 +0100)] 
Make function_decl_type a scoped enum

The enum currently has a member named NONE which pollutes the global
namespace unnecessarily.  Use a scoped enum instead.

gcc/
* tree-core.h (function_decl_type): Make a scoped enum.
* tree.h (set_function_decl_type): Adjust.
(DECL_IS_OPERATOR_NEW_P): Likewise.
(DECL_SET_IS_OPERATOR_NEW): Likewise.
(DECL_IS_OPERATOR_DELETE_P): Likewise.
(DECL_SET_IS_OPERATOR_DELETE): Likewise.
(DECL_LAMBDA_FUNCTION_P): Likewise.
(DECL_SET_LAMBDA_FUNCTION): Likewise.
* lto-streamer-out.cc (hash_tree): Hash all of
FUNCTION_DECL_DECL_TYPE.
* tree-streamer-out.cc (pack_ts_function_decl_value_fields):
Adjust.
* config/aarch64/aarch64-simd-pragma-builtins.def (vcombine_mf8):
Use literal zero instead of NONE.

gcc/cp/
* module.cc (trees_out::core_bools): Convert scoped enum
explicitly.

4 months agoi386: Fix AVX10.2 SAT CVT testcases.
Hu, Lin1 [Thu, 20 Mar 2025 03:55:49 +0000 (11:55 +0800)] 
i386: Fix AVX10.2 SAT CVT testcases.

Init res_ref2 for rounding control intrinsics.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-vcvtph2ibs-2.c: Fix testcase.
* gcc.target/i386/avx10_2-512-vcvtph2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2dqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2qqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2udqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2uqqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttph2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2dqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2qqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2udqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2uqqs-2.c: Ditto.

4 months agoopenmp: Fix up cloning of dynamic C++ initializers for OpenMP target [PR119370]
Jakub Jelinek [Thu, 20 Mar 2025 08:06:17 +0000 (09:06 +0100)] 
openmp: Fix up cloning of dynamic C++ initializers for OpenMP target [PR119370]

The following testcase ICEs, because we emit the dynamic initialization twice,
once for host and once for target initialization, and although we use
copy_tree_body_r to unshare it, e.g. for the array initializers it can contain
TARGET_EXPRs with local temporaries (or local temporaries alone).
Now, these temporaries were created when current_function_decl was NULL,
they are outside of any particular function, so they have DECL_CONTEXT NULL.
That is normally fine, gimple_add_tmp_var will set DECL_CONTEXT for them
later on to the host __static_init* function into which they are gimplified.
The problem is that the copy_tree_body_r cloning happens before that (and has
to, gimplification is destructive and so we couldn't gimplify the same tree
again in __omp_static_init* function) and uses auto_var_in_fn_p to see what
needs to be remapped.  But that means it doesn't remap temporaries with
NULL DECL_CONTEXT and having the same temporaries in two different functions
results in ICEs (sure, one can e.g. use parent function's temporaries in a
nested function).

The following patch just arranges to set DECL_CONTEXT on the temporaries
to the host dynamic initialization function, so that they get remapped.
If gimplification cared whether DECL_CONTEXT is NULL or not, we could
remember those that we've changed in a vector and undo it afterwards,
but seems it doesn't really care.

2025-03-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/119370
* decl2.cc (set_context_for_auto_vars_r): New function.
(emit_partial_init_fini_fn): Call walk_tree with that function
on &init before walk_tree with copy_tree_body_r.

* g++.dg/gomp/pr119370.C: New test.

4 months agoUse ix86_fp_comparison_operator in cbranchbf4 to avoid ICE.
liuhongt [Tue, 18 Mar 2025 05:47:11 +0000 (22:47 -0700)] 
Use ix86_fp_comparison_operator in cbranchbf4 to avoid ICE.

*jcc only supports ix86_fp_comparison_operator for CCFP, when
comparison code is LT, there's an ICE. W/o AVX10.2, it's ok since
do_compare_rtx_and_jump will transform LT to GT, but w/ AVX10.2 it
goes directly into ix86_expand_branch which doesn't handle it.

Use ix86_fp_comparison_operator in cbranchbf4.

gcc/ChangeLog:

PR target/117452
* config/i386/i386.md (cbranchbf4): Use
ix86_fp_comparison_operator instead of comparison_operator.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr117452.c: New test.

4 months agoi386: Add "s_" as Saturation for AVX10.2 SAT CVT Intrinsics.
Hu, Lin1 [Tue, 18 Mar 2025 08:50:24 +0000 (16:50 +0800)] 
i386: Add "s_" as Saturation for AVX10.2 SAT CVT Intrinsics.

This patch aims to add "s_" before intrinsic core name represent
saturation.

gcc/ChangeLog:

* config/i386/avx10_2-512satcvtintrin.h: Add "s_" before
intrinsics' core name.
* config/i386/avx10_2satcvtintrin.h: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-satcvt-1.c: Modify intrinsic name.
* gcc.target/i386/avx10_2-512-vcvtbf162ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtbf162iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtph2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtph2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttbf162ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttbf162iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2dqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2qqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2udqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttpd2uqqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttph2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttph2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2dqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2qqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2udqs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2uqqs-2.c: Ditto.
* gcc.target/i386/avx10_2-satcvt-1.c: Ditto.
* gcc.target/i386/avx10_2-vcvttsd2sis-2.c: Ditto.
* gcc.target/i386/avx10_2-vcvttsd2usis-2.c: Ditto.
* gcc.target/i386/avx10_2-vcvttss2sis-2.c: Ditto.
* gcc.target/i386/avx10_2-vcvttss2usis-2.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.

4 months agoi386: Fix AVX10.2 SAT CVT testcases.
Hu, Lin1 [Fri, 14 Mar 2025 03:16:14 +0000 (11:16 +0800)] 
i386: Fix AVX10.2 SAT CVT testcases.

Add missing testcases.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-satcvt-1.c: Add testcase.
* gcc.target/i386/avx10_2-512-vcvtph2ibs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvtph2iubs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvtps2ibs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvtps2iubs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttpd2dqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttpd2qqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttpd2udqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttpd2uqqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttph2ibs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttph2iubs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2dqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2ibs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2iubs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2qqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2udqs-2.c: Ditto
* gcc.target/i386/avx10_2-512-vcvttps2uqqs-2.c: Ditto
* gcc.target/i386/avx10_2-satcvt-1.c: Ditto
* gcc.target/i386/avx10_2-vcvttsd2sis-2.c: Ditto
* gcc.target/i386/avx10_2-vcvttsd2usis-2.c: Ditto
* gcc.target/i386/avx10_2-vcvttss2sis-2.c: Ditto
* gcc.target/i386/avx10_2-vcvttss2usis-2.c: Ditto

4 months agoi386: Add AVX10.2 SAT CVT Intrinsics without Rounding Control
Hu, Lin1 [Thu, 13 Mar 2025 08:36:15 +0000 (16:36 +0800)] 
i386: Add AVX10.2 SAT CVT Intrinsics without Rounding Control

gcc/ChangeLog:

* config/i386/avx10_2-512satcvtintrin.h: Add new intrinsics.
* config/i386/avx10_2satcvtintrin.h: Ditto.
* config/i386/i386-builtin-types.def:
Add DEF_FUNCTION_TYPE (V32HI, V32HF, V32HI, USI),
(V16SI, V16SF, V16SI, UHI), (V8DI, V8SF, V8DI, UQI),
(V8DI, V8DF, V8DI, UQI), (V8SI, V8DF, V8SI, UQI).
* config/i386/i386-builtin.def: Add new builtins.
* config/i386/i386-expand.cc: Handle V16SI_FTYPE_V16SF_V16SI_UHI,
V32HI_FTYPE_V32HF_V32HI_USI, V8DI_FTYPE_V8SF_V8DI_UQI,
V8DI_FTYPE_V8DF_V8DI_UQI, V8SI_FTYPE_V8DF_V8SI_UQI.

4 months agoi386: Update Suffix for AVX10.2 SAT CVT Intrinsics
Hu, Lin1 [Tue, 18 Mar 2025 02:03:22 +0000 (10:03 +0800)] 
i386: Update Suffix for AVX10.2 SAT CVT Intrinsics

The intrinsic names for *[i|u]bs instructions in AVX10.2 are missing the
required _ep[i|u]8 suffix.

This patch aims to fix the issue.

gcc/ChangeLog:

* config/i386/avx10_2-512satcvtintrin.h: Change *i[u]bs's type suffix
of intrin name.
* config/i386/avx10_2satcvtintrin.h: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx10_2-512-satcvt-1.c: Modify intrin name.
* gcc.target/i386/avx10_2-512-vcvtbf162ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtbf162iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtph2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtph2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvtps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttbf162ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttbf162iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttph2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttph2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2ibs-2.c: Ditto.
* gcc.target/i386/avx10_2-512-vcvttps2iubs-2.c: Ditto.
* gcc.target/i386/avx10_2-satcvt-1.c: Ditto.
* gcc.target/i386/sse-14.c: Ditto.
* gcc.target/i386/sse-22.c: Ditto.

4 months agoDaily bump.
GCC Administrator [Thu, 20 Mar 2025 00:20:10 +0000 (00:20 +0000)] 
Daily bump.

4 months agolibstdc++: Correct statement about default -std option
Jonathan Wakely [Wed, 19 Mar 2025 23:27:24 +0000 (23:27 +0000)] 
libstdc++: Correct statement about default -std option

The default is -std=gnu++17 now, not -std=gnu++14.

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Fix default for -std option.
* doc/html/manual/test.html: Regenerate.

4 months agolibstdc++: Fix "IEE" typo in comment in std::time_put::do_put
Jonathan Wakely [Wed, 19 Mar 2025 23:26:10 +0000 (23:26 +0000)] 
libstdc++: Fix "IEE" typo in comment in std::time_put::do_put

libstdc++-v3/ChangeLog:

* include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix
typo in comment.

4 months agoFortran: fix bogus bounds check for reallocation on assignment [PR116706]
Harald Anlauf [Wed, 19 Mar 2025 21:56:03 +0000 (22:56 +0100)] 
Fortran: fix bogus bounds check for reallocation on assignment [PR116706]

PR fortran/116706

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_is_reallocatable_lhs): Fix check on
allocatable components of derived type or class objects.

gcc/testsuite/ChangeLog:

* gfortran.dg/bounds_check_27.f90: New test.

4 months agoc++: mangling of array new [PR119316]
Jason Merrill [Wed, 19 Mar 2025 09:15:00 +0000 (05:15 -0400)] 
c++: mangling of array new [PR119316]

Because we build an array type to represent an array new, we hit a VLA
error in compute_array_index_type for a variable length array new.  To avoid
this, let's build the MINUS_EXPR and index type directly.

I also noticed that the non-constant case in write_array_type was assuming
MINUS_EXPR without verifying it, so I added a checking_assert.

I also noticed that Clang doesn't mangle the length of an array new at all,
so I opened https://github.com/itanium-cxx-abi/cxx-abi/issues/199 to clarify
this.

PR c++/119316

gcc/cp/ChangeLog:

* mangle.cc (write_expression) [NEW_EXPR]: Avoid using
compute_array_index_type.
(write_array_type): Add checking_assert.

gcc/testsuite/ChangeLog:

* g++.dg/abi/mangle-new1.C: New test.

4 months agolibstdc++: Activate a __cpp_lib_ranges_to_container dependent test
François Dumont [Wed, 19 Mar 2025 18:10:48 +0000 (19:10 +0100)] 
libstdc++: Activate a __cpp_lib_ranges_to_container dependent test

Now that std::set has support for __cpp_lib_ranges_to_container we can
activate a test using it in a fancy allocator pointer context.

libstdc++-v3/ChangeLog

* testsuite/23_containers/set/requirements/explicit_instantiation/alloc_ptr.cc:
Activate the template member tests involving __cpp_lib_ranges_to_container
support.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
4 months agolibstdc++: Make <stdbit.h> test use <climits> instead of <limits.h>
Jonathan Wakely [Mon, 17 Mar 2025 15:02:12 +0000 (15:02 +0000)] 
libstdc++: Make <stdbit.h> test use <climits> instead of <limits.h>

Our <climits> ensures that LLONG_MIN, LLONG_MAX, and ULLONG_MAX are
defined even if the C library's <limits.h> doesn't define them. Our
<limits.h> then includes <climits>, which should mean that <limits.h>
and <climits> always define the same macros. However, we only install
our own version of <limits.h> for --enable-cheaders=c and not for the
default --enable-cheaders=c_global setting that everybody uses.

This means that if the C library's <limits.h> is not C++-aware, or if
the C library doesn't provide it and GCC's own gcc/glimits.h is used
instead, then <climits> defines the macros for long long types but
<limits.h> does not.

This causes the new 20_util/stdbit/1.cc test to fail for arm-non-eabi
because it uses gcc/glimits.h which is not C++-aware, only checking
__STDC_VERSION__ when deciding whether to declare the long long macros.
If gcc/glimits.h also checked __cplusplus it would be OK, and we would
not need our own <limits.h> to be installed.

This commit just changes the new test to use <climits> instead of
<limits.h>, but we should ensure that gcc/glimits.h is made to work
(i.e.  define the long long macros) for C++, and/or install our own
<limits.h> for the --enable-cheaders=c_global configuration.

libstdc++-v3/ChangeLog:

* testsuite/20_util/stdbit/1.cc: Include <climits> instead of
<limits.h>.

4 months ago[PR119270][IRA]: Ignore equiv init insns for cost calculation for invariants only
Vladimir N. Makarov [Wed, 19 Mar 2025 20:06:41 +0000 (16:06 -0400)] 
[PR119270][IRA]: Ignore equiv init insns for cost calculation for invariants only

My previous patch for PR114991 contains code ignoring equiv init insns
for increasing cost of usage the equivalence.  Although common sense says
it is right thing to do, this results in more aggressive usage of
memory equivalence and significant performance degradation of SPEC2017
cactuBSSM.  Given patch restores previous cost calculation for all
equivalences except for invariant ones.

gcc/ChangeLog:

PR target/119270
* ira-costs.cc (calculate_equiv_gains): Ignore equiv init insns
only for invariants.

4 months agoUpdate gcc fr.po
Joseph Myers [Wed, 19 Mar 2025 19:41:43 +0000 (19:41 +0000)] 
Update gcc fr.po

* fr.po: Update.

4 months agodiagnostics: fix crash in urlifier with -Wfatal-errors [PR119366]
David Malcolm [Wed, 19 Mar 2025 19:03:42 +0000 (15:03 -0400)] 
diagnostics: fix crash in urlifier with -Wfatal-errors [PR119366]

diagnostic_context's dtor assumed that it owned the m_urlifier pointer
and would delete it.

As of r15-5988-g5a022062d22e0b this isn't always the case -
auto_urlify_attributes is used in various places in the C/C++ frontends
and in the middle-end to temporarily override the urlifier with an
on-stack instance, which would lead to delete-of-on-stack-buffer crashes
with -Wfatal-errors as the global_dc was cleaned up.

Fix by explicitly tracking the stack of urlifiers within
diagnostic_context, tracking for each node whether the pointer is
owned or borrowed.

gcc/ChangeLog:
PR c/119366
* diagnostic-format-sarif.cc (test_message_with_embedded_link):
Convert diagnostic_context from one urlifier to a stack of
urlifiers, where each node in the stack tracks whether the
urlifier is owned or borrowed.
* diagnostic.cc (diagnostic_context::initialize): Likewise.
(diagnostic_context::finish): Likewise.
(diagnostic_context::set_urlifier): Delete.
(diagnostic_context::push_owned_urlifier): New.
(diagnostic_context::push_borrowed_urlifier): New.
(diagnostic_context::pop_urlifier): New.
(diagnostic_context::get_urlifier): Reimplement in terms of stack.
(diagnostic_context::override_urlifier): Delete.
* diagnostic.h (diagnostic_context::set_urlifier): Delete decl.
(diagnostic_context::override_urlifier): Delete decl.
(diagnostic_context::push_owned_urlifier): New decl.
(diagnostic_context::push_borrowed_urlifier): New decl.
(diagnostic_context::pop_urlifier): New decl.
(diagnostic_context::get_urlifier): Make return value const; hide
implementation.
(diagnostic_context::m_urlifier): Replace with...
(diagnostic_context::urlifier_stack_node): ... this and...
(diagnostic_context::m_urlifier_stack): ...this.
* gcc-urlifier.cc
(auto_override_urlifier::auto_override_urlifier): Reimplement.
(auto_override_urlifier::~auto_override_urlifier): Reimplement.
* gcc-urlifier.h (class auto_override_urlifier): Reimplement.
(auto_urlify_attributes::auto_urlify_attributes): Update for
pass-by-reference.
* gcc.cc (driver::global_initializations): Update for
reimplementation of urlifiers in terms of a stack.
* toplev.cc (general_init): Likewise.

gcc/testsuite/ChangeLog:
PR c/119366
* gcc.dg/Wfatal-bad-attr-pr119366.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 months agoc: pedwarn on flexible array member initialization with {} for C23+ [PR119350]
Jakub Jelinek [Wed, 19 Mar 2025 18:21:38 +0000 (19:21 +0100)] 
c: pedwarn on flexible array member initialization with {} for C23+ [PR119350]

Even in C23/C2Y any initialization of flexible array member is still
invalid, so we should emit a pedwarn on it.  But we no longer do for
initialization with {}.  The reason is that for C17 and earlier,
we already emitted a pedwarn on the {} initializer and so emitting
another pedwarn on the flexible array member initialization would
be diagnosing the same thing multiple times.

In C23 we no longer pedwarn on {}, it is standard.
The following patch arranges a pedwarning for that for C23+, so that
at least one pedwarning is emitted.

So that we don't "regress" from C17 to C23 on nested flexible array
member initialization with no -pedantic/-pedantic-errors/-Wpedantic,
the patch emits even the
initialization of flexible array member in a nested context
diagnostic as pedwarn in the {} case, after all, it doesn't cause
much trouble, we just ignore it like before, it wouldn't initialize
anything.

2025-03-19  Jakub Jelinek  <jakub@redhat.com>

PR c/119350
* c-typeck.cc (pop_init_level): Don't ignore empty brackets for
flag_isoc23, still set constructor_type to NULL in that case but
emit a pedwarn_init in that case.

* gcc.dg/pr119350-1.c: New test.
* gcc.dg/pr119350-2.c: New test.
* gcc.dg/pr119350-3.c: New test.

4 months agotestsuite/113634 - fixup declarations of calloc/realloc
Richard Biener [Wed, 19 Mar 2025 17:48:09 +0000 (18:48 +0100)] 
testsuite/113634 - fixup declarations of calloc/realloc

Then we can also remove the added -std=gnu17

PR testsuite/113634
* gcc.dg/Wfree-nonheap-object-7.c: Adjust calloc and realloc
declarations, remove -std=gnu17.

4 months agoFix formatting of version message for gnat driver
Eric Botcazou [Wed, 19 Mar 2025 17:15:29 +0000 (18:15 +0100)] 
Fix formatting of version message for gnat driver

Like the main driver (as well as gccgo, gccrs, gcov, etc) the gnat driver
prints the standard version message in response to the --version switch,
but it is not properly formatted.

gcc/ada
* gnatvsn.adb (Gnat_Free_Software): Fix message formatting.

4 months agos390: testsuite: Fix autovec-double-signaling-eq-z13.c
Stefan Schulze Frielinghaus [Wed, 19 Mar 2025 15:35:12 +0000 (16:35 +0100)] 
s390: testsuite: Fix autovec-double-signaling-eq-z13.c

Since r15-3992-g698e0ec89bc096 we optimize x<=y && x>=y to x==y.
Honour signaling NaNs by using option -fsignaling-nans in order to
prevent this.

gcc/testsuite/ChangeLog:

* gcc.target/s390/zvector/autovec-double-signaling-eq-z13.c:
Honour sNaNs.

4 months agos390: testsuite: Fix vcond-shift.c
Stefan Schulze Frielinghaus [Wed, 19 Mar 2025 15:35:12 +0000 (16:35 +0100)] 
s390: testsuite: Fix vcond-shift.c

Previously we optimized expressions of the form a < 0 ? -1 : 0 to
(signed)a >> 31 during vcond expanding.  Since r15-1638-gaac00d09859cc5
this is done in match.pd.  The implementation in the back end as well as
in match.pd are basically the same but still distinct.  For the tests in
vcond-shift.c the back end emitted

  (xx - (xx >> 31)) >> 1

whereas now via match.pd

  ((int) ((unsigned int) xx >> 31) + xx) >> 1

which is basically the same.  We just have to adapt the scan-assembler
directives w.r.t. signed/unsigned shifts which is done by this patch.

gcc/testsuite/ChangeLog:

* gcc.target/s390/vector/vcond-shift.c: Adapt to new match.pd
rule and change scan-assembler-times for shifts.

4 months agogccrs: Handle external static items in toplevel resolver 2.0
Owen Avery [Wed, 16 Oct 2024 03:42:41 +0000 (23:42 -0400)] 
gccrs: Handle external static items in toplevel resolver 2.0

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Handle ExternalStaticItem.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolver 2.0 in pattern checker
Owen Avery [Tue, 15 Oct 2024 19:34:06 +0000 (15:34 -0400)] 
gccrs: Use name resolver 2.0 in pattern checker

gcc/rust/ChangeLog:

* checks/errors/rust-hir-pattern-analysis.cc: Add includes.
(PatternChecker::visit): Use name resolver 2.0 when enabled.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolver 2.0 for compiling break/continue
Owen Avery [Tue, 15 Oct 2024 18:56:04 +0000 (14:56 -0400)] 
gccrs: Use name resolver 2.0 for compiling break/continue

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc
(CompileExpr::visit): Use name resolver 2.0 to lookup label
definitions for break and continue statements when name
resolution 2.0 is enabled.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolver 2.0 in const checker
Owen Avery [Tue, 15 Oct 2024 19:33:46 +0000 (15:33 -0400)] 
gccrs: Use name resolver 2.0 in const checker

gcc/rust/ChangeLog:

* checks/errors/rust-const-checker.cc: Add includes.
(ConstChecker::visit): Use name resolver 2.0 to lookup
function definitions when name resolution 2.0 is enabled.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Load unloaded modules during toplevel resolution 2.0
Owen Avery [Wed, 16 Oct 2024 02:24:29 +0000 (22:24 -0400)] 
gccrs: Load unloaded modules during toplevel resolution 2.0

This may load conditionally compiled modules too eagerly.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Load unloaded modules before attempting to
visit their items.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove issue-1089.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Make const references to ForeverStack more useful
Owen Avery [Mon, 21 Oct 2024 22:35:30 +0000 (18:35 -0400)] 
gccrs: Make const references to ForeverStack more useful

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h
(ForeverStack::to_canonical_path): Make const.
(ForeverStack::to_rib): Add const overload.
(ForeverStack::reverse_iter): Add const overloads.
(ForeverStack::ConstDfsResult): Add.
(ForeverStack::dfs): Add const overload.
(ForeverStack::dfs_rib): Likewise.
* resolve/rust-forever-stack.hxx
(ForeverStack::reverse_iter): Add const overloads.
(ForeverStack::dfs): Add const overload.
(ForeverStack::to_canonical_path): Make const.
(ForeverStack::dfs_rib): Likewise.
(ForeverStack::to_rib): Add const overload.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Use name resolver 2.0 in MarkLive
Owen Avery [Tue, 15 Oct 2024 19:34:28 +0000 (15:34 -0400)] 
gccrs: Use name resolver 2.0 in MarkLive

gcc/rust/ChangeLog:

* checks/lints/rust-lint-marklive.cc
(MarkLive::visit_path_segment): Use name resolver 2.0 when
enabled.
(MarkLive::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Handle const generic parameters during resolution 2.0
Owen Avery [Wed, 16 Oct 2024 02:10:35 +0000 (22:10 -0400)] 
gccrs: Handle const generic parameters during resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Handle ConstGenericParam.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Disambiguate generic args during name resolution 2.0
Owen Avery [Wed, 16 Oct 2024 03:16:23 +0000 (23:16 -0400)] 
gccrs: Disambiguate generic args during name resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Visit GenericArgs and GenericArg, the former
because the latter involves a non-virtual member function call.
* resolve/rust-late-name-resolver-2.0.h
(Late::visit): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Fix compiler error on ast wrong implicit construct push_back
badumbatish [Thu, 17 Oct 2024 05:41:47 +0000 (22:41 -0700)] 
gccrs: Fix compiler error on ast wrong implicit construct push_back

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Fix
compiler error on ast wrong implicit construct push_back

4 months agogccrs: Provide input operand for gccrs
badumbatish [Thu, 5 Sep 2024 06:59:36 +0000 (23:59 -0700)] 
gccrs: Provide input operand for gccrs

gcc/rust/ChangeLog:

* backend/rust-compile-asm.cc (CompileAsm::asm_construct_inputs):
Provide input operand for gccrs
* expand/rust-macro-builtins-asm.cc (parse_reg_operand_in):
Move expr to In
(expand_inline_asm_strings):
Add comments to debug strings

gcc/testsuite/ChangeLog:

* rust/compile/inline_asm_parse_operand.rs:
Remove inout, functionality not supported. Remove redundant {}
* rust/execute/torture/inline_asm_mov_x_5_ARM.rs: Add operand in
* rust/execute/torture/inline_asm_mov_x_5_x86_64.rs: Likewise

4 months agogccrs: Use name resolver 2.0 during pattern typechecking
Owen Avery [Tue, 15 Oct 2024 19:35:21 +0000 (15:35 -0400)] 
gccrs: Use name resolver 2.0 during pattern typechecking

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc: Add includes.
(TypeCheckPattern::visit): Use name resolver 2.0 if enabled.

* resolve/rust-name-resolution-context.cc
(NameResolutionContext::lookup): Make const qualified.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::lookup): Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Allow identifiers and paths to reference types during nr2.0
Owen Avery [Tue, 15 Oct 2024 02:07:54 +0000 (22:07 -0400)] 
gccrs: Allow identifiers and paths to reference types during nr2.0

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Allow IdentifierExpr and PathInExpression to
reference types as well as values, remove ability for
IdentifierExpr to reference labels.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Improve handling of InlineAsm in DefaultASTVisitor
Owen Avery [Thu, 10 Oct 2024 01:47:02 +0000 (21:47 -0400)] 
gccrs: Improve handling of InlineAsm in DefaultASTVisitor

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Visit fields of InlineAsm.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove
inline_asm_parse_output_operand.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Insert static items into the value namespace
Owen Avery [Fri, 11 Oct 2024 05:24:14 +0000 (01:24 -0400)] 
gccrs: Insert static items into the value namespace

gcc/rust/ChangeLog:

* backend/rust-compile-item.cc
(CompileItem::visit): Check canonical path of StaticItem
properly when name resolution 2.0 is enabled.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Insert static items into the value namespace.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Rework InlineAsmOperand
Owen Avery [Fri, 11 Oct 2024 01:24:50 +0000 (21:24 -0400)] 
gccrs: Rework InlineAsmOperand

Not thrilled with some of this boilerplate, but it does seem like an
improvement.

gcc/rust/ChangeLog:

* ast/rust-expr.h
(InlineAsmOperand): Replace multiple mutually-exclusive tl::optional
fields with a std::unique_ptr and modify nested classes to allow
this. Also, make getters return references where possible.
* expand/rust-macro-builtins-asm.cc
(parse_reg_operand_out): Pass location when constructing
InlineAsmOperand.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Handle TypeAlias during toplevel resolution 2.0
Owen Avery [Thu, 10 Oct 2024 04:46:01 +0000 (00:46 -0400)] 
gccrs: Handle TypeAlias during toplevel resolution 2.0

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Handle TypeAlias.
* resolve/rust-toplevel-name-resolver-2.0.h
(TopLevel::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove type-alias1.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Fix some issues with canonical path fetching in name resolution 2.0
Owen Avery [Wed, 9 Oct 2024 03:29:27 +0000 (23:29 -0400)] 
gccrs: Fix some issues with canonical path fetching in name resolution 2.0

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-enumitem.cc: Add includes.
(TypeCheckEnumItem::visit): Fetch canonical paths properly when
name resolution 2.0 is enabled.
* typecheck/rust-hir-type-check-implitem.cc: Add includes.
(TypeCheckImplItem::visit): Fetch canonical paths properly when
name resolution 2.0 is enabled.
* typecheck/rust-hir-type-check-item.cc: Add include.
(TypeCheckItem::visit): Fetch canonical paths properly when name
resolution 2.0 is enabled.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Improve Rib::Definition shadowing
Owen Avery [Fri, 4 Oct 2024 21:33:42 +0000 (17:33 -0400)] 
gccrs: Improve Rib::Definition shadowing

gcc/rust/ChangeLog:

* resolve/rust-finalize-imports-2.0.cc
(GlobbingVisitor::visit): Replace calls to insert_shadowable with
insert_globbed.
* resolve/rust-forever-stack.h
(ForeverStack::insert_globbed): Add.
* resolve/rust-forever-stack.hxx
(ForeverStack::insert_globbed): Add.
(ForeverStack::dfs): Handle modifications to Rib::Definition
fields.
* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Make IdentifierPattern-based declarations
shadowable.
* resolve/rust-name-resolution-context.cc
(NameResolutionContext::insert_globbed): Add.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::insert_globbed): Add.
* resolve/rust-rib.cc
(Rib::Definition::Definition): Use Rib::Definition::Mode to
indicate shadowing mode instead of boolean, handle modifications
to Rib::Definition fields.
(Rib::Definition::is_ambiguous): Handle modifications to
Rib::Definition fields.
(Rib::Definition::to_string): Likewise.
(Rib::Definition::Shadowable): Handle changed constructor
signature.
(Rib::Definition::NonShadowable): Likewise.
(Rib::Definition::Globbed): Add.
(Rib::insert): Handle changes to Rib::Definition fields.
* resolve/rust-rib.h
(Rib::Definition::Globbed): Add.
(Rib::Definition::ids): Remove.
(Rib::Definition::ids_shadowable): Add.
(Rib::Definition::ids_non_shadowable): Add.
(Rib::Definition::ids_globbed): Add.
(Rib::Definition::get_node_id): Handle modifications to
Rib::Definition fields.
(Rib::Definition::Mode): Add.
(Rib::Definition::Definition): Use Rib::Definition::Mode to
indicate shadowing mode instead of boolean.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove shadow1.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agogccrs: Fix ICE when typechecking non-trait item when we expect one
Philip Herron [Wed, 2 Oct 2024 14:47:33 +0000 (15:47 +0100)] 
gccrs: Fix ICE when typechecking non-trait item when we expect one

We just had an assertion here for this case where we expect a trait.
This changes the assertion into error handling producing the correct
error code with fixit suggestion like rustc.

Fixes #2499

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait):
use error handling instead of assertion
* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): reuse trait reference
* typecheck/rust-hir-type-check-item.h: update prototype

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-2499.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agogccrs: Add test case to show ICE is fixed
Philip Herron [Wed, 2 Oct 2024 13:23:26 +0000 (14:23 +0100)] 
gccrs: Add test case to show ICE is fixed

This was resolved in: 18422c9c386 which was missing the name
resolution step for unit-types.

Fixes #2203

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude:
* rust/compile/issue-2203.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agogccrs: add test case to show impl block on ! works
Philip Herron [Thu, 26 Sep 2024 14:25:21 +0000 (15:25 +0100)] 
gccrs: add test case to show impl block on ! works

The resolution with ! was fixed in: 09cfe530f9c this adds a
test case to show the other issue is also fixed.

Fixes #2951

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 is crashing here
* rust/compile/issue-2951.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agorust: fix ICE during name resolution for impls on unit-types
Philip Herron [Fri, 20 Sep 2024 16:38:14 +0000 (17:38 +0100)] 
rust: fix ICE during name resolution for impls on unit-types

The canonical paths need to support unit-types which are technically a
TupleType with no fields. This handles this case and adds an unreachable.

Fixes #3036

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveTypeToCanonicalPath::visit): add unit-type catch
* resolve/rust-ast-resolve-type.h: likewise

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 cant handle this
* rust/compile/issue-3036.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
4 months agorust: Add support for Clone and Copy derive on generic types
Philip Herron [Thu, 19 Sep 2024 15:45:54 +0000 (16:45 +0100)] 
rust: Add support for Clone and Copy derive on generic types

When we generate derivations for Copy and Clone we need to make sure
the associated impl block sets up the generic parameters and arguments
correctly. This patch introduces the framework to copy chunks of the AST
because we need to make sure these new AST nodes have their own associated
id, calling clone on the nodes will just confuse name-resolution and
subsequent mappings.

Fixes #3139

gcc/rust/ChangeLog:

* Make-lang.in: new objects
* ast/rust-ast-builder.cc (Builder::generic_type_path_segment): new helper
(Builder::single_generic_type_path): likewise
(Builder::new_type): likewise
(Builder::new_lifetime_param): likewise
(Builder::new_type_param): likewise
(Builder::new_lifetime): likewise
(Builder::new_generic_args): likewise
* ast/rust-ast-builder.h: new helper decls
* ast/rust-ast.h: new const getters
* ast/rust-path.h: likewise
* ast/rust-type.h: likewise
* expand/rust-derive-clone.cc (DeriveClone::clone_impl): take the types generics
(DeriveClone::visit_tuple): likewise
(DeriveClone::visit_struct): likewise
(DeriveClone::visit_union): likewise
* expand/rust-derive-clone.h: update header
* expand/rust-derive-copy.cc (DeriveCopy::copy_impl): similarly take type generics
(DeriveCopy::visit_struct): likewise
(DeriveCopy::visit_tuple): likewise
(DeriveCopy::visit_enum): likewise
(DeriveCopy::visit_union): likewise
* expand/rust-derive-copy.h: likewse
* ast/rust-ast-builder-type.cc: New file.
* ast/rust-ast-builder-type.h: New file.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3139-1.rs: New test.
* rust/compile/issue-3139-2.rs: New test.
* rust/compile/issue-3139-3.rs: New test.
* rust/compile/nr2/exclude: these all break nr2

4 months agogccrs: Remove some passing test from nr2 passing list
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 21:37:35 +0000 (23:37 +0200)] 
gccrs: Remove some passing test from nr2 passing list

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove cast_generics.rs, issue-1131.rs,
issue-1383.rs and unsafe10.rs

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Postpone break on error after name resolution
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 21:17:59 +0000 (23:17 +0200)] 
gccrs: Postpone break on error after name resolution

We need the top level to run at least once before breaking because it
will be required by the other name resolution steps.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::expansion): Break on error after
top level name resolution.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Resolve TypeParam with name resolution 2.0
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 21:16:21 +0000 (23:16 +0200)] 
gccrs: Resolve TypeParam with name resolution 2.0

Resolve TypeParam unless it is Self.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Resolve
TypeParam.
* resolve/rust-toplevel-name-resolver-2.0.h: Add visit function
prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Add box definition to avoid error
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 20:59:48 +0000 (22:59 +0200)] 
gccrs: Add box definition to avoid error

Box definition is part of the standard library and cannot be found during
name resolution. This simple definition prevent any error from being
emitted.

gcc/testsuite/ChangeLog:

* rust/compile/box_syntax_feature_gate.rs: Add box land item
definition.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: This test requires the standard library
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 20:51:17 +0000 (22:51 +0200)] 
gccrs: This test requires the standard library

It requires the standard library and Copy to work correctly which we
cannot provide. Stopping the compiler before the name resolution allow us
to prevent an error whilst resolving Copy and keep the test's goal.

gcc/testsuite/ChangeLog:

* rust/compile/functions_without_body.rs: Add compile step argument.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Make node id getter const.
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 20:46:16 +0000 (22:46 +0200)] 
gccrs: Make node id getter const.

gcc/rust/ChangeLog:

* ast/rust-ast.h: Node id getter could be const.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Change resolved type segment
Pierre-Emmanuel Patry [Thu, 26 Sep 2024 20:43:18 +0000 (22:43 +0200)] 
gccrs: Change resolved type segment

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.h: Add visit function prototype.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change resolved
type segment.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
4 months agogccrs: Update exclude list with working tests
Pierre-Emmanuel Patry [Tue, 17 Sep 2024 13:25:41 +0000 (15:25 +0200)] 
gccrs: Update exclude list with working tests

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove working tests from nr2 exclude list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>