aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-09-08Merge #1526bors[bot]2-1/+25
1526: backend: correctly formulate the exit condition r=philberty a=liushuyu - backend: correctly formulate the exit condition. Previously the exit condition was treated the same as the loop condition (which is the inverse condition of the exit condition). Now, this is corrected. Should fix #1523 Co-authored-by: liushuyu <liushuyu011@gmail.com>
2022-09-06testsuite: add loop condition execution testliushuyu1-0/+21
2022-09-05backend: correctly formulate the exit condition ...liushuyu1-1/+4
... previously the exit condition was treated the same as the loop condition (which is the inverse condition of the exit condition). Now this is corrected.
2022-09-05Merge #1522bors[bot]3-1/+17
1522: Add testcases to test folding r=philberty a=abbasfaisal The fix is a bit of guess so do have a careful look :) Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
2022-09-04add testcase to test component_ref and constructor codes in ↵Faisal Abbas1-0/+12
eval_constant_expression()
2022-09-04bugfix: initialize slice from array in const contextFaisal Abbas2-1/+5
2022-08-31Merge #1519bors[bot]4-0/+37
1519: Fix generic substitution on unit structs r=philberty a=philberty Fixes #1518 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-31Unit structs are not concrete when they need substitutionsPhilip Herron1-0/+5
Fixes #1518
2022-08-31Add new check for contains_associated_typesPhilip Herron3-0/+20
We don't need to setup associated types when a trait does not contain any associated types.
2022-08-31Add extra debugging for method call expressionsPhilip Herron1-0/+12
2022-08-31Merge #1505bors[bot]2-69/+56
1505: Create canonical process of compiling constant items r=philberty a=philberty In order to compile a block expression constant, the simplest way for us was to reuse what code we have and to generate an artifical function which does not get added to the translation unit. The constant then becomes a CALL_EXPR to this artifical function which we can pass to the constexpr evaluator to resolve the result of this artifical 'CALL_EXPR'. Before this patch we seperated the difference between block expressions and non block expressions in constants. So for non block expressions we simply compiled them as if it was a simple constant but this is not guaranteed to be the case in rust, for example coercion sites can generate temporaries during autoderef which we let the constant evaluator resolve for us. This makes all constants handled in the same way to simplify the logic here. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-31Create canonical process of compiling constant itemsPhilip Herron1-48/+55
In order to compile a block expression constant, the simplest way for us was to reuse what code we have and to generate an artifical function which does not get added to the translation unit. The constant then becomes a CALL_EXPR to this artifical function which we can pass to the constexpr evaluator to resolve the result of this artifical 'CALL_EXPR'. Before this patch we seperated the difference between block expressions and non block expressions in constants. So for non block expressions we simply compiled them as if it was a simple constant but this is not guaranteed to be the case in rust, for example coercion sites can generate temporaries during autoderef which we let the constant evaluator resolve for us. This makes all constants handled in the same way to simplify the logic here.
2022-08-31Remove param_use_canonical_types checks ported from c++ front-endPhilip Herron1-21/+1
We are not fully setting TYPE_CANONICAL yet but we don't need to be as strict as the C++ front-end yet. param_use_canonical_types is a command line option we are not using either.
2022-08-31Merge #1517bors[bot]29-407/+571
1517: Refactor error handling on unify r=philberty a=philberty This is the first pass on a refactor for error handling on unify sites. Eventually we will be able to get rid of our can_eq interface but this is the first pass to abstract unify's to use this interface. Eventually, we will have unify and unify_and_commit. Unify will become our can_eq interface but will require more helpers around inference variables. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-31Refactor unify to hit a unify_sitePhilip Herron28-363/+460
This allows us to enforce better error handling on unify sites
2022-08-31Add missing location info to coercionsPhilip Herron11-44/+109
2022-08-31Add guards against getting data from an empty vectorPhilip Herron1-0/+2
2022-08-31Merge #1408 #1503 #1511bors[bot]25-99/+420
1408: Experiment: add optional error codes to diagnostics r=CohenArthur a=davidmalcolm rustc has error codes to identify specific errors, with URLs documenting each error. In GCC 13 I've extended GCC's diagnostic subsystem so that a diagnostic can be associated with zero or more `diagnostic_metadata::rule` instances, which have a textual description and a URL. I meant this for rules in coding standards and specifications, but it struck me that potentially gccrs could reuse the same error codes as rustc. The following pull request implements an experimental form of this; I picked a single error at random: [E0054](https://doc.rust-lang.org/error-index.html#E0054). With this patch, gccrs emits e.g.: ``` bad_as_bool_char.rs:8:19: error: invalid cast [u8] to [bool] [E0054] 8 | let nb = 0u8 as bool; | ~ ^ ``` where the trailing [E0054] is colorized, and, in a suitably capable terminal is a clickable URL to https://doc.rust-lang.org/error-index.html#E0054. The error code is after the diagnostic message, whereas rustc puts it after the word "error". I could change that in gcc's diagnostic.cc, perhaps. I'm not sure if this is a good idea (e.g. is it OK and maintainable to share error codes with rustc?), but thought it was worth sharing. 1503: Add overflow traps r=CohenArthur a=CohenArthur Opening as a draft since the code is really ugly and some tests still fail. I am looking for feedback on the implementation and my approximative use of functions like `temporary_variable` which I feel I might be using the wrong way. I'll open up an issue of what still needs to be done, namely: - [x] Properly handle sub and mul operations - [ ] Disable the check in `release` mode (`-frust-disable-overflow-checks`) - [ ] Handle specific rust overflow attribute (needs checkup on the name) I'll open up some PRs to clean up some parts of the backend as well. 1511: lint: Do not emit unused warnings for public items r=CohenArthur a=CohenArthur This fixes the overzealous warnings on public items from the unused pass Co-authored-by: David Malcolm <dmalcolm@redhat.com> Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-31Merge #1514bors[bot]4-10/+77
1514: Fix SEGV in transcribe_type when compiling libcore 1.29 r=CohenArthur a=CohenArthur Needs #1513, Skip reviewing the first commit Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-31ast: Add better assertion on AST fragmentsArthur Cohen1-8/+39
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-08-31ast: Only expand expressions and types if the kind is rightArthur Cohen3-5/+25
2022-08-31dump: Add AST debugging using the AST::Dump classArthur Cohen1-0/+16
2022-08-30Merge #1515 #1516bors[bot]3-1/+22
1515: transcriber: Do not infinite loop if the current parsed node is an error r=CohenArthur a=CohenArthur 1516: parser: Parse RangeFullExpr without erroring out r=CohenArthur a=CohenArthur Previously the parser would emit the errors despite later allowing the parsed expression to be null. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-30transcriber: Do not infinite loop if the current parsed node is an errorArthur Cohen1-0/+8
Co-authored-by: philberty <philip.herron@embecosm.com>
2022-08-30Merge #1513bors[bot]3-6/+74
1513: macros: Handle matchers properly in repetitions r=CohenArthur a=CohenArthur This fixes an issue encountered when trying to compile libcore 1.29 Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-30macros: Handle matchers properly in repetitionsArthur Cohen3-6/+74
2022-08-29parser: Parse RangeFullExpr without erroring outArthur Cohen2-1/+14
2022-08-29bors: Fix expected warning listArthur Cohen1-1/+1
2022-08-29fmt: Fix formatting in rust-diagnosticsArthur Cohen1-2/+1
2022-08-29Experiment with adding an error code to an errorDavid Malcolm5-3/+66
2022-08-29diagnostics: add error_metaDavid Malcolm2-0/+18
2022-08-27Merge #1510bors[bot]2-15/+30
1510: rustc_attrs: Allow `rustc_inherit_overflow_checks` as a builtin attribute r=CohenArthur a=CohenArthur We cannot yet handle this attribute, but we should not reject it either. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-26Merge #1512bors[bot]1-1/+2
1512: Add missing language selection for rs6000 r=philberty a=philberty This is an attempt to fix the ppc64le build issues. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-26Add missing language selection for rs6000Philip Herron1-1/+2
2022-08-26lint: Do not emit unused warnings for public itemsArthur Cohen7-13/+18
2022-08-26rustc_attrs: Allow `rustc_inherit_overflow_checks` as a builtinArthur Cohen2-15/+30
attribute We cannot yet handle this attribute, but we should not reject it either
2022-08-26Merge #1509bors[bot]1-1/+1
1509: constexpr: Fix warning in sorry fmt string r=philberty a=CohenArthur Closes #1508 Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-26constexpr: Fix warning in sorry fmt stringArthur Cohen1-1/+1
2022-08-26backend: Add overflow checks to every arithmetic operationArthur Cohen8-38/+223
2022-08-25Merge #1507bors[bot]4-13/+28
1507: Desugar double borrows into two HIR:BorrowExpr's r=philberty a=philberty We simply hit a gcc_unreachable() on double borrows but it seems reasonable to just desugar the AST into a borrow of a borrow to foo. Instead of a borrow expression with a flag to be respected. Fixes #1506 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-25builtins: Add add_overflow builtin and refactor classArthur Cohen1-15/+36
2022-08-25backend: Expose Bvariable class through rust-gcc headerArthur Cohen2-29/+59
2022-08-25Merge #1499bors[bot]8-41/+14261
1499: Constant folding in gccrs: port over rest of the code from CP frontend r=philberty a=abbasfaisal Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com> Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-08-25Desugar double borrows into two HIR:BorrowExpr'sPhilip Herron4-13/+28
We simply hit a gcc_unreachable() on double borrows but it seems reasonable to just desugar the AST into a borrow of a borrow to foo. Instead of a borrow expression with a flag to be respected. Fixes #1506
2022-08-25Merge #1473bors[bot]4-35/+79
1473: Improve AST dump r=CohenArthur a=CohenArthur Let's abuse C++ a little bit to make dumping and the chaining of dumping operations easier. If anyone has input feel free, this is definitely a roundabout way to go about it. This also adds pretty printing of the expanded AST, which can be useful to debug macros or `cfg` invocations Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-08-25Fix warnings on diagnosticsPhilip Herron2-49/+54
2022-08-25Add testcase for const array index expressionsPhilip Herron1-0/+5
2022-08-25Fix up missing jump_target handlingPhilip Herron2-37/+157
This adds in missed ported code for handling VAR_DECLS and jump's within statement lists.
2022-08-25Fix port of NOP_EXPRPhilip Herron1-9/+1
NOP_EXPR should fall through into convert and view_convert_exprs.
2022-08-25rust-constexpr.cc: fixesFaisal Abbas3-9/+3
- error in handling of NOP_EXPR which results in failure in make check-rust - DECL not being marked constant inside finalize_intrinsic_block Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>