aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2022-09-18Add testcase for const-eval issue from rust-blogPhilip Herron1-0/+12
see: https://blog.rust-lang.org/2022/09/15/const-eval-safety-rule-revision.html
2022-09-17remove bad assertionPhilip Herron1-3/+4
2022-09-17Statics are a coercion sitePhilip Herron1-5/+5
Statics can be assigned to a block expression meaning they need to behave similarly to constant items.
2022-09-17Static Items must be const evaluatedPhilip Herron1-1/+6
Statics like constants need to have a singular value they are not functions to be lazy evaluated. So to evaluate a block expr we can just reuse our const code to resolve this to a singular value.
2022-09-08Merge #1528bors[bot]1-0/+40
1528: add testcase with struct to test component_ref and constructor codes in eval_constant_expression() r=philberty a=abbasfaisal Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
2022-09-06testsuite: add loop condition execution testliushuyu1-0/+21
2022-09-06add testcase with struct to test component_ref and constructor codes inFaisal Abbas1-0/+40
eval_constant_expression()
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-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-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-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]24-98/+419
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-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-30macros: Handle matchers properly in repetitionsArthur Cohen3-6/+74
2022-08-29parser: Parse RangeFullExpr without erroring outArthur Cohen2-1/+14
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-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-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-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>
2022-08-25rust-constexpr.cc: fix warnings for unused variables for unsupported bitsFaisal Abbas3-156/+143
Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>
2022-08-25rust-constexpr.cc: fix build errorFaisal Abbas1-3/+2
2022-08-25rust-tree.cc: comment some important code instead of removing it.Faisal Abbas1-0/+7
2022-08-25rust-constexpr.cc: port over cxx_eval_array_reference andFaisal Abbas3-26/+388
cxx_eval_component_reference. Some important parts are commented out and marked such. These will need revisiting.