aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2022-02-18path-id: Add location info on path identifierArthur Cohen3-18/+22
2022-02-18closure-arg: Add location info on arg nameArthur Cohen2-7/+10
2022-02-18struct-base: Add location info on `..` tokenArthur Cohen2-5/+7
2022-02-18array-copy-init: Add location infoArthur Cohen2-5/+4
2022-02-18array-values: Add location infoArthur Cohen2-7/+6
2022-02-18fn-arg: Add location on parameter nameArthur Cohen2-6/+6
2022-02-17Semicolon based macro invocationPhilip Herron15-156/+430
This allows for macro invocation at the toplevel or as statements. This patched required us to propogate the delimited token tree fix to include the delimiter tokens. The rest of the fix was straight forward to call the apropriate visitors in names resolution and hir lowering. Some thought will be needed to handle hir lowering for repeating items.
2022-02-17Support block expressions within macrosPhilip Herron4-45/+19
When we parse DelimTokenTree's the delimiter's are synthesised when we ask for the token stream which results in tokens lacking location info. This removes the hack by adding the actual tokens from the lexer into the stream.
2022-02-17When we expand a macro we must visit it to ensure any cfg expansions or ↵Philip Herron1-2/+11
recursive macro expansion is required
2022-02-17Add initial support for macro expansionPhilip Herron15-255/+1017
This is the first pass at implementing macros more testcases are needed. This does not support repetition matchers but it supports simple declarative macros and transcribes them. The approach taken here is that we reuse our existing parser to call the apropriate functions as specified as part of the MacroFragmentType enum if the parser does not have errors parsing that item then it must be a match. Then once we match a rule we have a map of the token begin/end offsets for each fragment match, this is then used to adjust and create a new token stream for the macro rule definition so that when we feed it to the parser the tokens are already substituted. The resulting expression or item is then attached to the respective macro invocation and this is then name resolved and used for hir lowering. Fixes #17 #22 Addresses #573
2022-02-17Add name-resolution helpers for looking up macrosPhilip Herron2-0/+49
2022-02-17Add mappings helpers for looking up macros definitionsPhilip Herron2-0/+27
2022-02-17Add missing copyright header to lexer headerPhilip Herron1-0/+19
2022-02-17Merge #935bors[bot]7-77/+147
935: frust-cfg: Only allow double quoted values r=philberty a=CohenArthur Closes #910 This PR separates the `handle_cfg_option()` function in two, separating the parsing logic from the session logic. The parsing logic is able to be unit tested, and now only allows quoted values. What remains to be done is to only allow `key` and `value` to be proper rust identifiers. We need to figure out if we'd like to spawn a parser here and parse identifiers, or simply sanitize both strings to make sure they do not contain invalid characters. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-17frust-cfg: Only allow double quoted valuesArthur Cohen7-77/+147
This commit separates the `handle_cfg_option()` function in two, separating the parsing logic from the session logic. The parsing logic is able to be unit tested, and now only allows quoted values.
2022-02-17macrorule: Add location informationArthur Cohen2-11/+16
2022-02-17macrotranscriber: Add location infoArthur Cohen2-6/+9
2022-02-16Merge #934 #937bors[bot]3-25/+42
934: macromatch: Add location to abstract MacroMatch class r=philberty a=CohenArthur Closes #928 This adds location to the all child classes of the `MacroMatch` abstract class. The current locations are as follow, which I believe is what is expected but might be wrong. ```rust test.rs:2:6: error: macro match fragment 2 | ($a:expr, $b:expr) => { $a + $b }; | ^ test.rs:2:15: error: macro match fragment 2 | ($a:expr, $b:expr) => { $a + $b }; | ^ test.rs:2:5: error: macro matcher 2 | ($a:expr, $b:expr) => { $a + $b }; | ^ test.rs:3:8: error: macro match fragment 3 | ($($i:ident)*) => { $($i)* } | ^ test.rs:3:17: error: macro match repetition! 3 | ($($i:ident)*) => { $($i)* } | ^ test.rs:3:5: error: macro matcher 3 | ($($i:ident)*) => { $($i)* } | ^ ``` I think this should be rebased on #932 so that I can remove the FIXME 937: dockerfile: Install cargo-gccrs alongside gccrs r=philberty a=CohenArthur Closes #826 Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2022-02-16macromatch: Add location to abstract MacroMatch classArthur Cohen3-25/+42
2022-02-16rust-cfg: Quote option name when erroring outArthur Cohen1-1/+1
2022-02-16macros: Add base for execution tests for macrosArthur Cohen3-0/+107
2022-02-16macros: Add multiple macro syntax testsArthur Cohen5-0/+15
2022-02-13Support inline never and always optionsPhilip Herron5-14/+82
This maps over to DECL_UNINLINEABLE and to use the GCC attribute always_inline. Fixes #921
2022-02-11Support deref_mut lang item during method resolutionPhilip Herron10-322/+605
When we have method resolution we need to look at any deref lang items for the receiver. The precise rules need to be tested rigorously to ensure this is right. Fixes #890
2022-02-11refactor named_constant_expression out of the backend classPhilip Herron4-32/+24
2022-02-11Fix warnings when including rust-target.h informationPhilip Herron2-21/+8
2022-02-11Cleanup header usage and remove void_type wrapperPhilip Herron4-22/+13
2022-02-11Remove error_mark_node wrappers from backend proxy class.Philip Herron10-156/+83
2022-02-10Refactor code to reuse a canonical way to compile functions and constantsPhilip Herron15-1023/+648
This is a big cleanup so all paths that compile functions and constants end up in the same path so we avoid any duplication in how we actually compile a function.
2022-02-10Remove tree addressable flags from back-end local and fnparm decl creationPhilip Herron4-30/+15
2022-02-10Remove unsued functions in the GCC wrapperPhilip Herron2-334/+0
2022-02-10Remove AddressTakenContextPhilip Herron13-293/+109
We can reuse more C front-end code c_mark_addressable can be used instead of trying to track TREE_ADDRESSABLE as part of type-checking. This also pulls the GCC::Backend::address_expression to be part of the HIRCompileBase class during code-generation.
2022-02-09Support inline attribute by marking as DECL_DECLARED_INLINE_PPhilip Herron12-164/+214
This does a refactor by removing more flags for the fndecl construction from the rust-gcc wrapper code in favour of using the tree api directly. The ABI option attributes have also been refactored from the backend interface in favour of their own package. The gccgo wrapper tried to mark inline fns as extern inline but this refactor allows us to control the inline options specificly for the rust semantics. Fixes #857
2022-02-08Merge #912bors[bot]7-23/+219
912: Handle generic substitution on path expressions r=philberty a=philberty In this bug the path expression failed to take Foo::<i32> and apply this bound generic argument into the impl block. The fn type for this function test is: fn <T,Y>test(a:T, b:Y); But the impl block has a Self of Foo<T> so we need to inherit the T argument from the previous Foo::<i32> which was missing. Fixes #893 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-08Handle generic substitution on path expressionsPhilip Herron7-23/+219
In this bug the path expression failed to take Foo::<i32> and apply this bound generic argument into the impl block. The fn type for this function test is: fn <T,Y>test(a:T, b:Y); But the impl block has a Self of Foo<T> so we need to inherit the T argument from the previous Foo::<i32> which was missing. Fixes #893
2022-02-07Refactor to_string from header to impl filePhilip Herron2-78/+78
2022-02-06Merge #909bors[bot]2-4/+96
909: Add support for key = value pairs on -frust-cfg= r=philberty a=philberty This adds in a basic parser to parse out key value pairs for the config option it needs to be tested poperly once the self-test framework is merged in. Fixes #889 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-06Merge #888bors[bot]5-219/+22
888: Added location data to Match Arm and removed unused code r=philberty a=mvvsmk Fixes #863 - Added location data to Match arm in gcc/rust/ast/rust-expr.h and gcc/rust/hir/tree/rust-hir-expr.h - Updated the respective constructors and copy constructors - Updated location info for match arm in code generation in gcc/rust/backend/eust-compile-expr.cc - Removed unused code in the above rust-expr.h and rust-gir-expr.h files as mentioned in the issue by `@philberty.` - Comment removed form rust-expr.h - Changed partameterized constructor and static function in rust-hir-expr.h - Changed line 697 to pass expr.get_locus() in rust-ast-lower - Changed parameterised constructor in rust-expr.h - Changed line 8563 in rust-parse-impl.h to pass location data. Note : - I also added a public member funtion for the class MatchArm `Location get_locus ( ) const { return locus; }` Do me know if I missed anything or could improve on something. Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> Co-authored-by: @mvvsmk <mvvsmanojkumar@gmail.com>
2022-02-06Merge #908bors[bot]2-2/+2
908: Fix '-Wformat-diag' issue in 'TypeCheckPattern::visit (HIR::TupleStructPattern &pattern)' r=philberty a=tschwinge It's alread now diagnosed, non-fatal warning: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc: In member function ‘virtual void Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::TupleStructPattern&)’: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc:61:69: warning: unquoted operator ‘::’ in format [-Wformat-diag] 61 | "expected tuple struct or tuple variant, found %s variant %s::%s", | ^~ A later merge from GCC upstream will bring in commit 34ba4275dcf5162efb9b634e4665734766faf4e3 "Enable -Werror=format-diag during bootstrap", which then causes: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc: In member function ‘virtual void Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::TupleStructPattern&)’: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc:61:69: error: unquoted operator ‘::’ in format [-Werror=format-diag] 61 | "expected tuple struct or tuple variant, found %s variant %s::%s", | ^~ cc1plus: all warnings being treated as errors make[3]: *** [rust/rust-hir-type-check-pattern.o] Error 1 Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-02-05selftest: Move C specific tests in c_family_test()CohenArthur6-5/+6
2022-02-05selftest: Enable unit testing for the rust frontendCohenArthur2-3/+34
2022-02-04Add support for key = value pairs on -frust-cfg=Philip Herron2-4/+96
This adds in a basic parser to parse out key value pairs for the config option it needs to be tested poperly once the self-test framework is merged in. Fixes #889
2022-02-04Fix '-Wformat-diag' issue in 'TypeCheckPattern::visit ↵Thomas Schwinge2-2/+2
(HIR::TupleStructPattern &pattern)' It's alread now diagnosed, non-fatal warning: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc: In member function ‘virtual void Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::TupleStructPattern&)’: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc:61:69: warning: unquoted operator ‘::’ in format [-Wformat-diag] 61 | "expected tuple struct or tuple variant, found %s variant %s::%s", | ^~ A later merge from GCC upstream will bring in commit 34ba4275dcf5162efb9b634e4665734766faf4e3 "Enable -Werror=format-diag during bootstrap", which then causes: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc: In member function ‘virtual void Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::TupleStructPattern&)’: [...]/source-gcc/gcc/rust/typecheck/rust-hir-type-check-pattern.cc:61:69: error: unquoted operator ‘::’ in format [-Werror=format-diag] 61 | "expected tuple struct or tuple variant, found %s variant %s::%s", | ^~ cc1plus: all warnings being treated as errors make[3]: *** [rust/rust-hir-type-check-pattern.o] Error 1
2022-02-04Merge #907bors[bot]7-61/+124
907: Support cfg expansions predicates r=philberty a=philberty Config expansion can be not, any, or all predicate to enforce the config expansion logic. This patch refactors the MacroParser to be named AttributeParser as it is only used to parse attributes into MetaItems that we can work with and do expansion logic upon. This handles the case of parsing the inner-meta-item of not(A) to parse it into MetaListNameValueStr and tidies up some of the code in the area. Fixes #901 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
2022-02-04Upated parameterised constuctor of MatchArm to take location data@mvvsmk4-12/+12
Addresses issue #863 1)comment removed form rust-expr.h 2)changed partameterized constructor and static function in rust-hir-expr.h 3)changed line 697 to pass expr.get_locus() in rust-ast-lower 4)changed parameterised constructor in rust-expr.h 5)changed line 8563 in rust-parse-impl.h to pass location data. Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
2022-02-03Merge commit 'ff7aeceb6b3a476c3bac66a7f39a5ef4240206fc' [#247, #906]Thomas Schwinge1649-1620528/+1623976
2022-02-03Revert code formatting changes of "Added MSP430 target hook (or at least ↵Thomas Schwinge1-276/+288
provisional one)" To reduce the differences with GCC upstream, this reverts code formatting changes of GCC/Rust commit ea5e2aff4e3fc149125bf5b7da627ffb352ced45, keeping just the 'TARGET_RUST_CPU_INFO' definition.
2022-02-03Merge #906bors[bot]80-55/+55
906: GCC/Rust pieces of GCC upstream "Mass rename of C++ .c files to .cc suffix" r=tschwinge a=tschwinge ... in preparation of merge of the latter. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-02-03Support cfg expansions predicatesPhilip Herron7-61/+124
Config expansion can be not, any, or all predicate to enforce the config expansion logic. This patch refactors the MacroParser to be named AttributeParser as it is only used to parse attributes into MetaItems that we can work with and do expansion logic upon. This handles the case of parsing the inner-meta-item of not(A) to parse it into MetaListNameValueStr and tidies up some of the code in the area. Fixes #901
2022-02-03Merge #903bors[bot]18-241/+580
903: Add new RustIdent struct to track canonical-path and location info r=philberty a=philberty This refactors our TyTy type abstractions to contain their repspective canonical-path and location info. This cleans up alot of location tracking for example when we have generic structures we create implicit hirids which may or may not have location info this now tracks the location info of the declaration of the type avoiding any confustion. Co-authored-by: Philip Herron <philip.herron@embecosm.com>