aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-03-20Make function_decl_type a scoped enumRichard Biener6-13/+19
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.
2025-03-20i386: Fix AVX10.2 SAT CVT testcases.Hu, Lin115-90/+165
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.
2025-03-20openmp: Fix up cloning of dynamic C++ initializers for OpenMP target [PR119370]Jakub Jelinek2-0/+28
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.
2025-03-19Use ix86_fp_comparison_operator in cbranchbf4 to avoid ICE.liuhongt2-1/+13
*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.
2025-03-20i386: Add "s_" as Saturation for AVX10.2 SAT CVT Intrinsics.Hu, Lin130-760/+760
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.
2025-03-20i386: Fix AVX10.2 SAT CVT testcases.Hu, Lin123-97/+565
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
2025-03-20i386: Add AVX10.2 SAT CVT Intrinsics without Rounding ControlHu, Lin15-0/+1098
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.
2025-03-20i386: Update Suffix for AVX10.2 SAT CVT IntrinsicsHu, Lin118-458/+458
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.
2025-03-20Daily bump.GCC Administrator10-1/+2029
2025-03-19libstdc++: Correct statement about default -std optionJonathan Wakely2-4/+4
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.
2025-03-19libstdc++: Fix "IEE" typo in comment in std::time_put::do_putJonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * include/bits/locale_facets_nonio.tcc (time_put::do_put): Fix typo in comment.
2025-03-19Fortran: fix bogus bounds check for reallocation on assignment [PR116706]Harald Anlauf2-3/+46
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.
2025-03-19c++: mangling of array new [PR119316]Jason Merrill2-3/+20
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.
2025-03-19libstdc++: Activate a __cpp_lib_ranges_to_container dependent testFrançois Dumont1-3/+1
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>
2025-03-19libstdc++: Make <stdbit.h> test use <climits> instead of <limits.h>Jonathan Wakely1-1/+1
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>.
2025-03-19[PR119270][IRA]: Ignore equiv init insns for cost calculation for invariants ↵Vladimir N. Makarov1-6/+9
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.
2025-03-19Update gcc fr.poJoseph Myers1-741/+537
* fr.po: Update.
2025-03-19diagnostics: fix crash in urlifier with -Wfatal-errors [PR119366]David Malcolm8-34/+74
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>
2025-03-19c: pedwarn on flexible array member initialization with {} for C23+ [PR119350]Jakub Jelinek4-6/+53
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.
2025-03-19testsuite/113634 - fixup declarations of calloc/reallocRichard Biener1-3/+3
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.
2025-03-19Fix formatting of version message for gnat driverEric Botcazou1-3/+4
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.
2025-03-19s390: testsuite: Fix autovec-double-signaling-eq-z13.cStefan Schulze Frielinghaus1-1/+1
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.
2025-03-19s390: testsuite: Fix vcond-shift.cStefan Schulze Frielinghaus1-6/+6
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.
2025-03-19gccrs: Handle external static items in toplevel resolver 2.0Owen Avery2-0/+8
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>
2025-03-19gccrs: Use name resolver 2.0 in pattern checkerOwen Avery1-1/+15
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>
2025-03-19gccrs: Use name resolver 2.0 for compiling break/continueOwen Avery1-4/+37
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>
2025-03-19gccrs: Use name resolver 2.0 in const checkerOwen Avery2-4/+15
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>
2025-03-19gccrs: Load unloaded modules during toplevel resolution 2.0Owen Avery2-1/+11
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>
2025-03-19gccrs: Make const references to ForeverStack more usefulOwen Avery2-4/+102
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>
2025-03-19gccrs: Use name resolver 2.0 in MarkLiveOwen Avery1-4/+27
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>
2025-03-19gccrs: Handle const generic parameters during resolution 2.0Owen Avery2-0/+9
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>
2025-03-19gccrs: Disambiguate generic args during name resolution 2.0Owen Avery2-0/+34
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>
2025-03-19gccrs: Fix compiler error on ast wrong implicit construct push_backbadumbatish1-1/+2
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Fix compiler error on ast wrong implicit construct push_back
2025-03-19gccrs: Provide input operand for gccrsbadumbatish5-14/+56
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
2025-03-19gccrs: Use name resolver 2.0 during pattern typecheckingOwen Avery3-8/+26
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>
2025-03-19gccrs: Allow identifiers and paths to reference types during nr2.0Owen Avery2-15/+24
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>
2025-03-19gccrs: Improve handling of InlineAsm in DefaultASTVisitorOwen Avery2-2/+40
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>
2025-03-19gccrs: Insert static items into the value namespaceOwen Avery3-4/+20
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>
2025-03-19gccrs: Rework InlineAsmOperandOwen Avery2-36/+150
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>
2025-03-19gccrs: Handle TypeAlias during toplevel resolution 2.0Owen Avery3-1/+10
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>
2025-03-19gccrs: Fix some issues with canonical path fetching in name resolution 2.0Owen Avery4-22/+132
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>
2025-03-19gccrs: Improve Rib::Definition shadowingOwen Avery9-56/+187
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>
2025-03-19gccrs: Fix ICE when typechecking non-trait item when we expect onePhilip Herron5-17/+46
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>
2025-03-19gccrs: Add test case to show ICE is fixedPhilip Herron2-0/+4
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>
2025-03-19gccrs: add test case to show impl block on ! worksPhilip Herron2-0/+14
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>
2025-03-19rust: fix ICE during name resolution for impls on unit-typesPhilip Herron4-0/+26
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>
2025-03-19rust: Add support for Clone and Copy derive on generic typesPhilip Herron16-22/+783
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
2025-03-19gccrs: Remove some passing test from nr2 passing listPierre-Emmanuel Patry1-4/+0
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>
2025-03-19gccrs: Postpone break on error after name resolutionPierre-Emmanuel Patry1-3/+3
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>
2025-03-19gccrs: Resolve TypeParam with name resolution 2.0Pierre-Emmanuel Patry2-0/+20
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>