aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-03-18libstdc++: Add P1206R7 from_range members to ordered maps [PR111055]Tomasz Kamiński7-0/+638
This is another piece of P1206R7, adding new members to std::map and std::multimap. PR libstdc++/111055 libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (__detail::__range_to_alloc_type): Define. * include/bits/stl_multimap.h: (inser_range) (multimap(from_range_t, _Rg&&, const _Compare&, const _Alloc&)) (multimap(from_range_t, _Rg&&, const _Alloc&)): Define. * include/bits/stl_map.h: (map(from_range_t, _Rg&&, const _Alloc&)) i (map(from_range_t, _Rg&&, const _Compare&, const _Alloc&), insert_range): Define. * testsuite/23_containers/multimap/cons/from_range.cc: New test. * testsuite/23_containers/multimap/modifiers/insert/insert_range.cc: New test. * testsuite/23_containers/map/cons/from_range.cc: New test. * testsuite/23_containers/map/modifiers/insert/insert_range.cc: New test.
2025-03-18cobol: use ldirname in cdf-copy.ccJose E. Marchesi1-8/+16
This patch changes gcc/cobol/cdf-copy.cc to use the new ldirname from libibertay rather than the host's dirname. This removes an include for libgen.h. Regtested in x86_64-linux-gnu by running make check-cobol. gcc/cobol/ChangeLog * cdf-copy.cc (copybook_elem_t::open_file): Use ldirname rather than dirname.
2025-03-18libiberty: add ldirname functionJose E. Marchesi5-3/+121
This patch adds a function ldirname to libiberty. It is implemented in terms of lbasename. Basically, given a given pathname, the dirname part is what is not the basename minus the last directory separator separating the dirname with the basename. include/ChangeLog * libiberty.h (ldirname): New function declaration. (dos_ldirname): Likewise. (unix_ldirname): Likewise. libiberty/ChangeLog * ldirname.c: New file. * Makefile.in (CFILES): Add ldirname.c. (REQUIRED_OFILES): Add ldirname.$(objext). (./ldirname.$(objext)): New rule. * makefile.vms (OBJS): Add ldirname.obj. * configure.com (FILES): Add ldirname.
2025-03-18cobol: Do not include C++ headers after system.h.Iain Sandoe1-6/+0
The headers mentioned in parse.y are already unconditionally included by system.h (via cobol-system.h). gcc/cobol/ChangeLog: * parse.y: Remove c++ header includes appearing after system.h. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-18debug/101533 - ICE with variant typedef DIE generationRichard Biener2-4/+13
There's a sanity check in gen_type_die_with_usage that trips unnecessarily for a case where the relevant DIE has already been generated successfully in other ways. The following keys the existing TREE_ASM_WRITTEN check on the correct object, honoring this and does nothing instead of ICEing for the testcase at hand. PR debug/101533 * dwarf2out.cc (gen_type_die_with_usage): When we have output the typedef already do nothing for a typedef variant. Do not set TREE_ASM_WRITTEN on the type. * g++.dg/debug/pr101533.C: New testcase.
2025-03-18i386: Remove XFAIL for pr103750 testcasesHaochen Jiang4-8/+4
After commit r15-4510, the following testcases also do not need XFAIL. gcc/testsuite/ChangeLog: * gcc.target/i386/avx512f-pr103750-1.c: Remove XFAIL. * gcc.target/i386/avx512f-pr103750-2.c: Ditto. * gcc.target/i386/avx512fp16-pr103750-1.c: Ditto. * gcc.target/i386/avx512fp16-pr103750-2.c: Ditto.
2025-03-17[RISC-V] Fix another unreported code quality regressionJeff Law2-1/+36
So here's the other case I was just looking at. This is a slightly modified version of some code from 500.perlbench which shows another nop logical operation: > void frob (void); > typedef struct av AV; > typedef unsigned int U32; > struct av > { > void *dummy; > U32 sv_refcnt; > U32 sv_flags; > }; > void > Perl_save_ary (AV *const oav) > { > AV *av; > unsigned int x1 = oav->sv_flags; > unsigned int x2 = x1 & 3221225472; > if (x2 == 2147483648) > frob (); > } https://godbolt.org/z/941vqfGE6 It's not as obvious, but this is probably a regression as well. I would expect the gcc-14 code to execute in 1c faster than the current trunk code on a superscalar design: gcc-14: trunk: lw a5,12(a0) lw a5,12(a0) li a3,-1073741824 li a3,-2 li a4,-2147483648 and a5,a5,a3 srai a4,a5,30 beq a5,a4,.L4 andi a4,a4,-1 beq a4,a3,.L4 Essentially the "li" instrutions can execute in parallel with the lw. But the rest of the sequence has data dependencies forcing the instructions to execute serially. Thus that extra andi extends the critical path by 1c. Removing the useless andi should make the two sequences perform the same and reduces the codesize. Much like the prior case we walk backwards using -fdump-rtl-all -dp to find the andi: andi a4,a4,-1 # 26 [c=4 l=4] *anddi3/1 The UID is 26. And just like the prior case it first shows up in the .split2 dump: grep insn\ 26 j.c.* j.c.326r.split2:(insn 26 25 27 2 (set (reg:DI 14 a4 [144]) j.c.327r.ree:(insn 26 25 27 2 (set (reg:DI 14 a4 [144]) j.c.329r.pro_and_epilogue:(insn 26 25 27 2 (set (reg:DI 14 a4 [144]) j.c.330r.dse2:(insn 26 25 27 2 (set (reg:DI 14 a4 [144]) In the .split2 dump: Splitting with gen_split_77 (riscv.md:3184) scanning new insn with uid = 25. scanning new insn with uid = 26. scanning new insn with uid = 27. scanning new insn with uid = 28. deleting insn with uid = 12. deleting insn with uid = 12. So insn 12 is where we want to look. > (jump_insn 12 6 13 2 (parallel [ > (set (pc) > (if_then_else (ne (and:DI (reg:DI 15 a5 [orig:138 oav_3(D)->sv_flags ] [138]) > (const_int -1073741824 [0xffffffffc0000000])) > (const_int -2147483648 [0xffffffff80000000])) > (label_ref:DI 18) > (pc))) > (clobber (reg:DI 14 a4 [144])) > (clobber (reg:DI 13 a3 [145])) > ]) "j.c":16:6 361 {*branchdi_shiftedarith_ne_shifted} > (int_list:REG_BR_PROB 856416484 (nil)) > -> 18) So that's a conditional branch with the condition (a5 & 0xffffffffc0000000) != 0xffffffff80000000 Note how those instructions have many low bits as zeros and that the constants likely require some kind of constant synthesis. We can conceptually do an arithmetic right shift of a5 and both constants and get the same result, likely making the constants easier to synthesize. And that's precisely what this pattern is designed to do: > (define_insn_and_split "*branch<ANYI:mode>_shiftedarith_<optab>_shifted" > [(set (pc) > (if_then_else (any_eq > (and:ANYI (match_operand:ANYI 1 "register_operand" "r") > (match_operand 2 "shifted_const_arith_operand" "i")) > (match_operand 3 "shifted_const_arith_operand" "i")) > (label_ref (match_operand 0 "" "")) > (pc))) > (clobber (match_scratch:X 4 "=&r")) > (clobber (match_scratch:X 5 "=&r"))] > "!SMALL_OPERAND (INTVAL (operands[2])) > && !SMALL_OPERAND (INTVAL (operands[3])) > && SMALL_AFTER_COMMON_TRAILING_SHIFT (INTVAL (operands[2]), > INTVAL (operands[3]))" > "#" > "&& reload_completed" > [(set (match_dup 4) (ashiftrt:X (match_dup 1) (match_dup 7))) > (set (match_dup 4) (and:X (match_dup 4) (match_dup 8))) > (set (match_dup 5) (match_dup 9)) > (set (pc) (if_then_else (any_eq (match_dup 4) (match_dup 5)) > (label_ref (match_dup 0)) (pc)))] > { > HOST_WIDE_INT mask1 = INTVAL (operands[2]); > HOST_WIDE_INT mask2 = INTVAL (operands[3]); > int trailing_shift = COMMON_TRAILING_ZEROS (mask1, mask2); > > operands[7] = GEN_INT (trailing_shift); > operands[8] = GEN_INT (mask1 >> trailing_shift); > operands[9] = GEN_INT (mask2 >> trailing_shift); > } It finds the number of low bits in both that must be zero. In this case it's 30 bits. So it shifts the register right by 30 bits. Then constructs the two new constants, one of which is -1 after shifting. And we emit (set (match_dup 4) (and (match_dup 4) (const_int -1)) And since this splits after register allocation nothing eliminates the useless and dest,src,-1 and boom we have a regression. The fix this time is a bit different. I really don't want to open code the new RTL. So instead I create a new operand for the source of the AND statement. If the constant is going to be -1 then that operand has the same value as the destination operand (ie, a nop move). Otherwise it is the appropriate AND expression. The nop-move will get eliminated thus resolving the regression. I suspect some of the other patterns in riscv.md are subject to similar issues, though I haven't seem them trigger, so I'm leaving them alone for now. This has been tested in my tester and it'll obviously go through the upstream CI flow before I push it to the trunk. gcc/ * config/riscv/riscv.md (equality shifted-arith splitter): Do not create op AND -1 as it won't be cleaned up post-reload. gcc/testsuite * gcc.target/riscv/redundant-andi-2.c: New test.
2025-03-17Fix r15-8073 (Pass -macos_version_min to the linker)Andrew Pinski2-9/+9
With r15-8073-g952e17223d3a98, gcc_cv_ld64_macosx_version_min is being used for the replacement and being set in a few locations but gcc_cv_ld64_macos_version_min is set in others. Since the auto-host.h variable is named LD64_HAS_MACOS_VERSION_MIN, I changed over to remove the x from the name. Committed as obvious after a quick test to make sure LD64_HAS_MACOS_VERSION_MIN was not set to empty. gcc/ChangeLog: * configure: Regenerate. * configure.ac: s/gcc_cv_ld64_macosx_version_min/gcc_cv_ld64_macos_version_min/. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-03-18Daily bump.GCC Administrator13-1/+1923
2025-03-17Update .po filesJoseph Myers43-104322/+118389
gcc/po/ * be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po, ja.po, ka.po, nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update. libcpp/po/ * be.po, ca.po, da.po, de.po, el.po, eo.po, es.po, fi.po, fr.po, id.po, ja.po, ka.po, nl.po, pt_BR.po, ro.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po, zh_TW.po: Update.
2025-03-17[RISC-V] Fix unreported code quality regression with single bit manipulationsJeff Law3-10/+69
I was reviewing some code recently and spotted an oddity. In a few places we were emitting andi dst,src,-1 and in others [x]ori dst,src,0. Those are obviously nops and we should get rid of them. Most of these are coming from a split part of a couple define_insn_and_split patterns added back in late 2022, so this is an unreported 13, 14 & 15 code quality regression (verified on godbolt, https://godbolt.org/z/EPszox5Kd). Essentially the split part is matching over-aggressively and splitting what should be a trivial bitmanip insn such as bset, bclr or binv into a nop logical with a bit twiddle. Since the split portions trigger post-reload nothing comes along to remove the nop logical operations. The fix is trivial. Just refine the condition. I considered refining the operand predicates too. Both are valid approaches. I noticed the formatting was goofy, so fixed that while I was in there. I'm aware of one other similar case, but I haven't concluded if it's a regression or not. Tested in my tester. Waiting for pre-commit CI to do its thing. Jeff gcc/ * config/riscv/bitmanip.md (*<or_optab>i<mode>_extrabit): Reject cases where we only need to twiddle one bit. Fix formatting. (*andi<mode>extrabit): Likewise. gcc/testsuite/ * gcc.target/riscv/redundant-andi.c: New test. * gcc.target/riscv/redundant-ori.c: Likewise
2025-03-17gcc.dg/pr90838-2.c: Replace long with long longH.J. Lu1-2/+2
Since gcc.dg/pr90838-2.c is only for 64-bit integer, replace long with long long for ILP32 targets. * gcc.dg/pr90838-2.c (ctz4): Replace long with long long. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-03-17cobol: Eliminate CPPFLAGS assignment from Make-lang.in [PR119213].Bob Dubner15-80/+82
A number of gcc/cobol files had to be modified to '#include "../../libgcobol/xxx.h" instead of "xxx.h" gcc/cobol PR cobol/119213 * Make-lang.in: Eliminate CPPFLAGS= assignment. * cdf.y: Modify #includes that reference libgcobol. * cobol1.cc: Modify #includes that reference libgcobol. * except.cc: Modify #includes that reference libgcobol. * gcobolspec.cc: Modify #includes that reference libgcobol. * genapi.cc: Modify #includes that reference libgcobol. * gengen.cc: Modify #includes that reference libgcobol. * genmath.cc: Modify #includes that reference libgcobol. * genutil.cc: Modify #includes that reference libgcobol. * parse.y: Modify #includes that reference libgcobol. * scan.l: Modify #includes that reference libgcobol. * structs.cc: Modify #includes that reference libgcobol. * symbols.cc: Modify #includes that reference libgcobol. * symfind.cc: Modify #includes that reference libgcobol. * util.cc: Modify #includes that reference libgcobol.
2025-03-17libgcobol: Remove unused headers from shared sources.Bob Dubner3-23/+0
This reduces the number of headers included in sources that are shared with the Front End. libgcobol/ChangeLog: * charmaps.cc: Remove unused headers * libgcobol.h: Likewise. * valconv.cc: Likewise. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-17[PR119285][IRA]: Use an additional way of reg equiv invariant substitution ↵Vladimir N. Makarov1-13/+12
correctness Patch for PR114991 resulted in 5% decrease of SPEC2017 lbm performance on Zen2 and Zen4. For one RTL insn of lbm, LRA with PR114991 patch can not confirm that the equivalence insertion will create a valid RTL insn. This resulted in that the pseudo equiv was assumed costly and pseudo was assigned to hard reg (caller saved as the pseudo lives through calls) and some other pseudos did not get hard regs as it was before PR114991 patch. The insn in question is `pseudo1 = pseduo2 + pseudo3` where pseudo2 has equiv `hard_reg + const`. The old code recognized the insn after equiv substitution as LEA. The new code failed. The patch here makes to use two ways for equiv subsbtitution correctness, the old one and new one (mostly for memory addresses where the old code fails to find the substitution correctness). So given patch fixes lbm performance degradation and actually makes GCC to generate the same code as it was before PR114991 patch. gcc/ChangeLog: PR rtl-optimization/119285 * ira-costs.cc (equiv_can_be_consumed_p): Use 2 ways for recognizing a valid insn after equiv insertion.
2025-03-17rs6000: Add -msplit-patch-nops (PR112980)Michael Matz5-12/+57
as the bug report details some uses of -fpatchable-function-entry aren't happy with the "before" NOPs being inserted between global and local entry point on powerpc. We want the before NOPs be in front of the global entry point. That means that the patching NOPs aren't consecutive for dual entry point functions, but for these usecases that's not the problem. But let us support both under the control of a new target option: -msplit-patch-nops. gcc/ PR target/112980 * config/rs6000/rs6000.opt (msplit-patch-nops): New option. * doc/invoke.texi (RS/6000 and PowerPC Options): Document it. * config/rs6000/rs6000.h (machine_function.stop_patch_area_print): New member. * config/rs6000/rs6000.cc (rs6000_print_patchable_function_entry): Emit split nops under control of that one. * config/rs6000/rs6000-logue.cc (rs6000_output_function_prologue): Add handling of split patch nops.
2025-03-17doc: Regenerate common.opt.urlsMichal Jires1-0/+6
Regenerating common.opt.urls, which I missed until autobuilder noticed. gcc/ChangeLog: * common.opt.urls: Regenerate.
2025-03-17gccrs: [E0576] Associated `item` not found in given `type`Muhammad Mahad2-1/+21
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): Add rich error message and error code similiar to rustc with associaed type and trait name gcc/testsuite/ChangeLog: * rust/compile/unknown-associated-item.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
2025-03-17gccrs: [gccrs#2987] Patch ICE when deriving Clone and CopyLiam Naddell2-8/+26
gcc/rust/ChangeLog: * expand/rust-expand-visitor.cc: Fix ICE caused by unique_ptr UB and buggy iterator use gcc/testsuite/ChangeLog: * rust/compile/issue-2987.rs: Add test for deriving Clone and Copy at the same time Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2025-03-17gccrs: Fix ffi and enum conventionsbadumbatish4-25/+27
gcc/rust/ChangeLog: * ast/rust-fmt.h (enum ParseMode): Drop typedef in Cpp libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Remove repr(C) * libformat_parser/src/bin.rs: Use ffi * libformat_parser/src/lib.rs: pub ffi, create ParseMode and match rustc's parse mode
2025-03-17gccrs: Added options for ParseModebadumbatish6-9/+25
gcc/rust/ChangeLog: * ast/rust-fmt.cc (Pieces::collect): Added options for ParseMode * ast/rust-fmt.h (collect_pieces): Likewise. (struct Pieces): Likewise. * expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise. libgrust/ChangeLog: * libformat_parser/generic_format_parser/src/lib.rs: Likewise. * libformat_parser/src/bin.rs: Likewise. * libformat_parser/src/lib.rs: Likewise.
2025-03-17gccrs: Change assertion of constructorbadumbatish1-11/+14
Change the assert of (expr != nullptr) to (this->expr != nullptr) because we assigned (std::move(expr)) to this->expr, no need to assert expr gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): Change assertion of constructor (struct InlineAsmOperand): Change assertion of constructor
2025-03-17gccrs: [gccrs#3046] ICE on failing to find enum variantLiam Naddell2-1/+31
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc: Fix ICE caused by not finding enum variant by adding new error message gcc/testsuite/ChangeLog: * rust/compile/issue-3046.rs: Add test for new error message Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2025-03-17gccrs: Update pattern with \r* for dg-output testsbadumbatish2-3/+2
First scan with "rg -v '\\r' gcc/testsuite/rust | rg 'dg-output'" gcc/testsuite/ChangeLog: * rust/execute/torture/issue-2187.rs: Update pattern with \r* for dg-output tests * rust/execute/xfail/macro1.rs: Likewise
2025-03-17gccrs: Improve error messages for operator expressionsAntonio Gomes4-6/+25
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: Add new get_operator_str method in ArithmeticOrLogicalExpr and CompoundAssignmentExpr * hir/tree/rust-hir.cc: Likewise * typecheck/rust-hir-type-check-expr.cc: Improve error message for operator expressions to display the correct operator symbol gcc/testsuite/ChangeLog: * rust/compile/shadow1.rs: Fix test for new error message Signed-off-by: Antonio Gomes <antoniospg100@gmail.com>
2025-03-17gccrs: Introduce new class to handle borrow errorsKushal Pal4-17/+142
gcc/rust/ChangeLog: * Make-lang.in: Compile new file. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Use new class to report errors. * checks/errors/borrowck/rust-borrow-checker-diagnostics.cc: New file. * checks/errors/borrowck/rust-borrow-checker-diagnostics.h: New file, adds new class. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2025-03-17gccrs: Fix nightly rustc warningsKushal Pal3-31/+1
libgrust/ChangeLog: * libformat_parser/Cargo.toml: Used crate-type instead of depricated crate_type. * libformat_parser/generic_format_parser/src/lib.rs: Remove dead code. * libformat_parser/src/lib.rs: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2025-03-17gccrs: Added FFIVector to get Polonius output on C++ sideKushal Pal8-13/+258
gcc/rust/ChangeLog: * Make-lang.in: Compile new file, rust-polonius.cc * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Opaque type to represent FFIVector from C++. * checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: Change types of fields in Output. * checks/errors/borrowck/ffi-polonius/src/lib.rs: Added helper functions to contruct Polonius output on C++ side, used helpers to contruct Polonius output on C++ side. * checks/errors/borrowck/polonius/rust-polonius-ffi.h (make_vector): FFIVector is a wrapper around std::vector for transfering data from Rust to C++. (struct Output): Use pointers to FFIVector instead of bool to store Polonius output data. * checks/errors/borrowck/polonius/rust-polonius.h (FFIVector__new): Helper function. (FFIVector__new_vec_pair): Likewise. (FFIVector__new_vec_triple): Likewise. (FFIVector__push): Likewise. (FFIVector__push_vec_pair): Likewise. (FFIVector__push_vec_triple): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Convert FFIVector to std::vector representation for easier navigation. * checks/errors/borrowck/polonius/rust-polonius.cc: New file, implementation of helper functions. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
2025-03-17rust: fix HIR dump for MatchExprMarc Poulhiès2-7/+38
The visitor was still using the as_string() method. gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_matcharm): New. (Dump::do_matchcase): New. (Dump::visit(MatchExpr)): Adjust, don't use as_string. * hir/rust-hir-dump.h (Dump::do_matcharm, Dump::do_matchcase): New. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2025-03-17gccrs: [gccrs#3051] Remove unnecessary #include from rust-expr.hLiam Naddell1-2/+0
gcc/rust/ChangeLog: * ast/rust-expr.h: Remove unnecessary include. Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
2025-03-17gccrs: Safe-guard InlineAsm structsbadumbatish2-66/+53
gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): Safe-guard InlineAsm structs (struct InlineAsmOperand): Likewise. * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_inout): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Store parse result of parse_format_string(s)badumbatish2-3/+21
gcc/rust/ChangeLog: * ast/rust-expr.h (struct TupleTemplateStr): Store parse result of parse_format_string(s) * expand/rust-macro-builtins-asm.cc (parse_format_strings): Likewise Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Clean up monadic operations on expected<>jjasmine1-5/+3
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_asm): Clean up monadic operations on expected<> Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Addresses warning, put warn unused in right placejjasmine2-11/+34
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Addresses warning, put warn unused in right place (parse_reg_operand_inout): Likewise. (parse_asm_arg): Likewise. * expand/rust-macro-builtins-asm.h (enum WARN_UNUSED_RESULT): Likewise. (enum InlineAsmParseError): Likewise. (validate): Likewise. (parse_asm_arg): Likewise. (parse_format_strings): Likewise. (parse_clobber_abi): Likewise. (parse_reg_operand): Likewise. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_lateout): Likewise. (parse_reg_operand_inout): Likewise. (parse_reg_operand_inlateout): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_sym): Likewise. (parse_reg_operand_unexpected): Likewise. (parse_asm): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_format_string): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Add WARN_UNUSED_RESULT parse errorjjasmine1-1/+2
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.h (enum InlineAsmParseError): Add WARN_UNUSED_RESULT parse error (enum WARN_UNUSED_RESULT): Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Added a test that is expected to failjjasmine4-31/+60
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): added comments (parse_options): Likewise (parse_asm_arg): Likewise (parse_asm): Likewise * expand/rust-macro-builtins-asm.h: Likewise gcc/testsuite/ChangeLog: * rust/compile/inline_asm_illegal_options.rs: new test * rust/compile/inline_asm_illegal_operands.rs: New test. This is expected to fail but we couldn't resolve parse_expr()'s general functionality yet Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Added tl::expected to parse_operandjjasmine3-16/+82
Added tl::expected to parse_operand by implementing the validation inside the parse_reg_operand function. gcc/rust/ChangeLog: * ast/rust-expr.h: Added tl::expected to parse_operand * expand/rust-macro-builtins-asm.cc (parse_reg): Likewise. (parse_reg_operand): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_inout): Likewise. (parse_asm_arg): Likewise. * expand/rust-macro-builtins-asm.h: Likewise. Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Scaffold expected on parse_options and asm_argjjasmine2-16/+28
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (check_and_set): Scaffold expected on parse_options and asm_arg (parse_options): Likewise (parse_asm_arg): Likewise * expand/rust-macro-builtins-asm.h (check_and_set): Likewise (parse_label): Likewise Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Finish expected parse_reg_operandjjasmine2-36/+35
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Finish expected parse_reg_operand (parse_reg_operand_unexpected): Likewise * expand/rust-macro-builtins-asm.h (parse_reg_operand_unexpected): Likewise Signed-off-by: badumbatish <tanghocle456@gmail.com>
2025-03-17gccrs: Finish incorporating expected of parse_reg_operandjjasmine2-97/+180
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Finish incorporating expected of parse_reg_operand (parse_reg): Likewise. (parse_reg_operand): Likewise. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_lateout): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_inout): Likewise. (parse_reg_operand_sym): Likewise. (MacroBuiltin::asm_handler): Likewise. (parse_asm_arg): Likewise. (parse_asm): Likewise. (parse_format_strings): Likewise. (validate): Likewise. * expand/rust-macro-builtins-asm.h (class InlineAsmParseError): Likewise. (enum InlineAsmParseError): Likewise. (validate): Likewise. (parse_format_strings): Likewise. (parse_reg_operand_in): Likewise. (parse_reg_operand_out): Likewise. (parse_reg_operand_lateout): Likewise. (parse_reg_operand_inout): Likewise. (parse_reg_operand_inlateout): Likewise. (parse_reg_operand_const): Likewise. (parse_reg_operand_sym): Likewise.
2025-03-17gccrs: Add RAW_STRING_LITERALansh8-1/+45
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Handle case for RAW_STRING_LITERAL. * ast/rust-ast.cc (AttributeParser::parse_meta_item_inner): Likewise. (AttributeParser::parse_literal): Likewise. * ast/rust-ast.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_literal): Likewise. * lex/rust-lex.cc (Lexer::parse_raw_string): Likewise. * lex/rust-token.cc (Token::as_string): Likewise. * lex/rust-token.h (enum PrimitiveCoreType): Likewise. * parse/rust-parse-impl.h (Parser::parse_attr_input): Likewise. (Parser::parse_literal_expr): Likewise. (Parser::parse_pattern_no_alt): Likewise. Signed-off-by: ansh <anshmalik2002@gmail.com>
2025-03-17gccrs: Added ExprType::InlineAsmjjasmine2-2/+2
gcc/rust/ChangeLog: * hir/tree/rust-hir-expr.h: Added ExprType::InlineAsm * hir/tree/rust-hir.h: Added ExprType::InlineAsm
2025-03-17gccrs: Add test case for using asm! outside of unsafe {}jjasmine1-0/+11
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_outside_unsafe.rs: New test.
2025-03-17gccrs: expand: Switch semicolon boolean to an enum instead.Arthur Cohen14-73/+105
gcc/rust/ChangeLog: * ast/rust-ast-fragment.h (enum class): Add InvocKind and AsmKind enums. * ast/rust-macro.h: Switch semicolon boolean to InvocKind enum. * expand/rust-expand-visitor.cc (ExpandVisitor::visit): Likewise. * expand/rust-macro-builtins-asm.cc (MacroBuiltin::asm_handler): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (parse_asm): Likewise. * expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise. * expand/rust-macro-builtins-include.cc (MacroBuiltin::include_bytes_handler): Likewise. (MacroBuiltin::include_str_handler): Likewise. (MacroBuiltin::include_handler): Likewise. * expand/rust-macro-builtins-location.cc (MacroBuiltin::file_handler): Likewise. (MacroBuiltin::column_handler): Likewise. (MacroBuiltin::line_handler): Likewise. * expand/rust-macro-builtins-log-debug.cc (MacroBuiltin::assert_handler): Likewise. * expand/rust-macro-builtins-utility.cc (MacroBuiltin::compile_error_handler): Likewise. (MacroBuiltin::concat_handler): Likewise. (MacroBuiltin::env_handler): Likewise. (MacroBuiltin::cfg_handler): Likewise. (MacroBuiltin::stringify_handler): Likewise. * expand/rust-macro-builtins.cc (format_args_maker): Likewise. (enum class): Likewise. (inline_asm_maker): Likewise. (MacroBuiltin::sorry): Likewise. (MacroBuiltin::proc_macro_builtin): Likewise. * expand/rust-macro-builtins.h: Likewise. * expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise. (MacroExpander::expand_eager_invocations): Likewise. (MacroExpander::expand_invoc): Likewise. * expand/rust-macro-expand.h (struct MacroExpander): Likewise.
2025-03-17gccrs: expand: Keep track of semicoloned builtin macrosArthur Cohen15-64/+94
This is quite a rough fix (like a lot of the macro expansion code...) but it allows built-in macros to be treated as statements. I *think* asm!() might be the only one where it really matters, but also doing something like { line!(); } will now work, whereas before the macro invocation would not get expanded properly and would be ignored. gcc/rust/ChangeLog: * ast/rust-ast-fragment.h: Pass `is_semicolon` information to builtin macro transcribers. * ast/rust-macro.h: Pass semicolon information to transcriber.. * expand/rust-macro-builtins-asm.cc (MacroBuiltin::asm_handler): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (parse_asm): Likewise. * expand/rust-macro-builtins-format-args.cc (MacroBuiltin::format_args_handler): Likewise. * expand/rust-macro-builtins-include.cc (MacroBuiltin::include_bytes_handler): Likewise. (MacroBuiltin::include_str_handler): Likewise. (MacroBuiltin::include_handler): Likewise. * expand/rust-macro-builtins-location.cc (MacroBuiltin::file_handler): Likewise. (MacroBuiltin::column_handler): Likewise. (MacroBuiltin::line_handler): Likewise. * expand/rust-macro-builtins-log-debug.cc (MacroBuiltin::assert_handler): Likewise. * expand/rust-macro-builtins-utility.cc (MacroBuiltin::compile_error_handler): Likewise. (MacroBuiltin::concat_handler): Likewise. (MacroBuiltin::env_handler): Likewise. (MacroBuiltin::cfg_handler): Likewise. (MacroBuiltin::stringify_handler): Likewise. * expand/rust-macro-builtins.cc (format_args_maker): Likewise. (inline_asm_maker): Likewise. (MacroBuiltin::sorry): Likewise. (MacroBuiltin::proc_macro_builtin): Likewise. * expand/rust-macro-builtins.h: Likewise. * expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): Likewise. (MacroExpander::expand_invoc): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Remove rust_unreachable. * ast/rust-ast.cc (InlineAsm::accept_vis): Likewise. * hir/tree/rust-hir.cc (InlineAsm::accept_vis): Likewise.
2025-03-17gccrs: Fix optional trait parsingdave2-0/+21
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Check for ?Trait in visitor gcc/testsuite/ChangeLog: * rust/compile/issue-2725.rs: New test. Signed-off-by: Dave Evans <dave@dmetwo.org>
2025-03-17gccrs: Partial second layer of expected in parsing asmjjasmine2-69/+37
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parseDirSpec): Partial second layer of expected in parsing asm (parse_clobber_abi): Likewise (parse_operand): Likewise (parse_reg_operand): Likewise (parse_asm_arg): Likewise * expand/rust-macro-builtins-asm.h (parse_clobber_abi): Likewise (parse_reg_operand): Likewise (parse_operand): Likewise
2025-03-17gccrs: Expected first layer donejjasmine2-36/+61
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg): Expected first layer done (parse_reg_operand): Likewise. (parse_asm_arg): Likewise. (parse_format_strings): Likewise. (parse_asm): Likewise. (validate): Likewise. * expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise. (validate): Likewise. (parse_format_strings): Likewise.
2025-03-17gccrs: Move parser and last_token_id to InlineAsmCtxjjasmine2-69/+70
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Move parser and last_token_id to InlineAsmCtx to prepapre for tl::expected. (parse_reg): Likewise. (parse_operand): Likewise. (parse_reg_operand): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_format_string): Likewise. (parse_asm_arg): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (class InlineAsmParseError): Likewise. (parse_asm_arg): Likewise. (check_and_set): Likewise. (parse_operand): Likewise. (parse_reg_operand): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_clobber_abi): Likewise. (parse_format_string): Likewise.
2025-03-17gccrs: Update parser to parse strings in the first stagejjasmine1-49/+13
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Update parser to parse strings in the first stage (parse_label): not needed right now