]> gcc.gnu.org Git - gcc.git/log
gcc.git
4 months agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Mon, 11 Mar 2024 22:44:18 +0000 (23:44 +0100)]
Adjust '.github/bors_log_expected_warnings'

4 months agocse: Workaround GCC < 5 bug in cse_insn [PR111852]
Jakub Jelinek [Wed, 18 Oct 2023 15:01:26 +0000 (17:01 +0200)]
cse: Workaround GCC < 5 bug in cse_insn [PR111852]

Before the r5-3834 commit for PR63362, GCC 4.8-4.9 refuses to compile
cse.cc which contains a variable with rtx_def type, because rtx_def
contains a union with poly_uint16 element.  poly_int template has
defaulted default constructor and a variadic template constructor which
could have empty parameter pack. GCC < 5 treated it as non-trivially
constructible class and deleted rtunion and rtx_def default constructors.

For the cse_insn purposes, all we need is a variable with size and alignment
of rtx_def, not necessarily rtx_def itself, which we then memset to 0 and
fill in like rtx is normally allocated from heap, so this patch for
GCC_VERSION < 5000 uses an unsigned char array of the right size/alignment.

2023-10-18  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/111852
* cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of
using rtx_def type for memory_extend_buf, use unsigned char
arrayy with size of rtx_def and its alignment.

(cherry picked from commit bc4bd69faf986326f6b0fd0400cdd6871577afd1)

4 months agoMerge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:51:28 +0000 (22:51 +0100)]
Merge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD

4 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:43:19 +0000 (22:43 +0100)]
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD

4 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:38:33 +0000 (22:38 +0100)]
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD

4 months agoMerge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]
Thomas Schwinge [Mon, 11 Mar 2024 00:05:15 +0000 (01:05 +0100)]
Merge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]

4 months agoMerge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:59:26 +0000 (00:59 +0100)]
Merge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD

4 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:58:39 +0000 (00:58 +0100)]
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD

4 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:57:51 +0000 (00:57 +0100)]
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD

4 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:56:06 +0000 (00:56 +0100)]
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD

4 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:47:49 +0000 (00:47 +0100)]
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD

4 months agoMerge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:45:13 +0000 (00:45 +0100)]
Merge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]

4 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:34:47 +0000 (00:34 +0100)]
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]

4 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:34:22 +0000 (00:34 +0100)]
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD

4 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]
Thomas Schwinge [Sun, 10 Mar 2024 23:33:08 +0000 (00:33 +0100)]
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]

4 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:26:50 +0000 (00:26 +0100)]
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD

4 months agoMerge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:25:25 +0000 (00:25 +0100)]
Merge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1' into HEAD

4 months agoMerge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:25:10 +0000 (00:25 +0100)]
Merge commit 'dc17ceb3055f56aa3a59c6ef3ae32043d58502d1^' into HEAD

4 months agoMerge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:24:32 +0000 (00:24 +0100)]
Merge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d' into HEAD

4 months agoMerge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:24:01 +0000 (00:24 +0100)]
Merge commit '9fc0ae6033f3e41c9b4605531a6a8543414b0d2d^' into HEAD

4 months agoMerge commit 'ead5103cc6f526bcc5a30c8c7185e9dd5de73d55' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:21:19 +0000 (00:21 +0100)]
Merge commit 'ead5103cc6f526bcc5a30c8c7185e9dd5de73d55' into HEAD

4 months agoMerge commit 'f330710912229678b65def1f6f52765baa3d0f7a' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:20:06 +0000 (00:20 +0100)]
Merge commit 'f330710912229678b65def1f6f52765baa3d0f7a' into HEAD

4 months agoMerge commit 'ab422974567ae73926c2308c3400b5974d6e09f1' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:18:11 +0000 (00:18 +0100)]
Merge commit 'ab422974567ae73926c2308c3400b5974d6e09f1' into HEAD

4 months agoMerge commit 'ab422974567ae73926c2308c3400b5974d6e09f1^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:17:15 +0000 (00:17 +0100)]
Merge commit 'ab422974567ae73926c2308c3400b5974d6e09f1^' into HEAD

4 months agoMerge commit '9c7797a8c2d707ba4516d3d96d8dff6201476fb6' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:15:40 +0000 (00:15 +0100)]
Merge commit '9c7797a8c2d707ba4516d3d96d8dff6201476fb6' into HEAD

4 months agoMerge commit '126f707efbb5184178701cbdc753a10fd831374e' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:58:16 +0000 (23:58 +0100)]
Merge commit '126f707efbb5184178701cbdc753a10fd831374e' into HEAD

4 months agoMerge commit '126f707efbb5184178701cbdc753a10fd831374e^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:54:17 +0000 (23:54 +0100)]
Merge commit '126f707efbb5184178701cbdc753a10fd831374e^' into HEAD

4 months agoMerge commit 'f4a2ae2338962208b8039f154f5912402e94c378' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:42:52 +0000 (23:42 +0100)]
Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378' into HEAD

4 months agoMerge commit 'f4a2ae2338962208b8039f154f5912402e94c378^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:42:46 +0000 (23:42 +0100)]
Merge commit 'f4a2ae2338962208b8039f154f5912402e94c378^' into HEAD

4 months agoMerge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:38:46 +0000 (23:38 +0100)]
Merge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce' into HEAD

4 months agoMerge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:38:38 +0000 (23:38 +0100)]
Merge commit '8a30775b0d3037123ee540f7b65a736ad49e05ce^' into HEAD

4 months agoMerge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:34:31 +0000 (23:34 +0100)]
Merge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931' into HEAD

4 months agoMerge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:34:09 +0000 (23:34 +0100)]
Merge commit '33ebb0dff9bb022f1e0709e0e73faabfc3df7931^' into HEAD

4 months agoMerge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:24:35 +0000 (23:24 +0100)]
Merge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c' into HEAD

4 months agoMerge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:22:34 +0000 (23:22 +0100)]
Merge commit '4f01ae3761ca1f8dd7a33b833ae30624f047ac9c^' into HEAD

4 months agoMerge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:19:06 +0000 (23:19 +0100)]
Merge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82' into HEAD

4 months agoMerge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:18:49 +0000 (23:18 +0100)]
Merge commit 'ea1cd66f2200839d46a8b4dc140d18c00b849c82^' into HEAD

4 months agoMerge commit 'bc45e18d433f879a02e369d027829f90f9e85724' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:16:21 +0000 (23:16 +0100)]
Merge commit 'bc45e18d433f879a02e369d027829f90f9e85724' into HEAD

4 months agoMerge commit 'bc45e18d433f879a02e369d027829f90f9e85724^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 22:15:52 +0000 (23:15 +0100)]
Merge commit 'bc45e18d433f879a02e369d027829f90f9e85724^' into HEAD

4 months agoMerge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 21:57:58 +0000 (22:57 +0100)]
Merge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122' into HEAD

4 months agoMerge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 21:56:03 +0000 (22:56 +0100)]
Merge commit '0a85544e1aaeca41133ecfc438cda913dbc0f122^' into HEAD

4 months agoRemove dead code associated with `AST::ExternalFunctionItem`
0xn4utilus [Wed, 28 Feb 2024 14:05:30 +0000 (19:35 +0530)]
Remove dead code associated with `AST::ExternalFunctionItem`

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Remove dead code.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full-decls.h (class ExternalFunctionItem):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):
Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc (ExternalFunctionItem::as_string): Likewise.
(ExternalFunctionItem::accept_vis): Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Likewise.
* checks/errors/rust-ast-validation.h: Likewise.
* checks/errors/rust-feature-gate.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::visit):
Likewise.
* expand/rust-cfg-strip.h: Likewise.
* expand/rust-derive.h: Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):
Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* metadata/rust-export-metadata.cc (ExportContext::emit_function):
Likewise.
* parse/rust-parse-impl.h: Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit):
Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Likewise.
* resolve/rust-default-resolver.h: Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
* util/rust-attributes.h: Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/extern_func_with_body.rs: New test.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
4 months agoUpdate resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`
0xn4utilus [Sun, 25 Feb 2024 23:09:43 +0000 (04:39 +0530)]
Update resolver to use `AST::Function` instead of `AST::ExternalFunctionItem`

gcc/rust/ChangeLog:

* checks/errors/rust-feature-gate.cc (FeatureGate::visit):
Check if function is_external or not.
* hir/rust-ast-lower-extern.h: Use AST::Function
instead of AST::ExternalFunctionItem.
* parse/rust-parse-impl.h (Parser::parse_external_item):
Likewise.
(Parser::parse_pattern): Fix clang format.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveExternItem::visit):
Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Check if param has_pattern before using get_pattern.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
4 months agoUnify ASTValidation::visit for ExternalFunctionItem and Function
0xn4utilus [Sun, 25 Feb 2024 13:33:55 +0000 (19:03 +0530)]
Unify ASTValidation::visit for ExternalFunctionItem and Function

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add external function validation support. Add ErrorCode::E0130.
* parse/rust-parse-impl.h (Parser::parse_function): Parse
external functions from `parse_function`.
(Parser::parse_external_item): Clang format.
(Parser::parse_pattern): Clang format.
* parse/rust-parse.h: Add default parameter
`is_external` in `parse_function`.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
4 months agoAdd get_pattern_kind to Pattern
0xn4utilus [Sun, 25 Feb 2024 00:50:51 +0000 (06:20 +0530)]
Add get_pattern_kind to Pattern

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add Kind Enum to
Pattern.
* ast/rust-macro.h: Add get_pattern_kind().
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
4 months agoAdd support for external functions
0xn4utilus [Sun, 25 Feb 2024 00:02:26 +0000 (05:32 +0530)]
Add support for external functions

gcc/rust/ChangeLog:

* ast/rust-ast.cc (Function::Function): Add `is_external_function` field.
(Function::operator=): Likewise.
* ast/rust-ast.h: New constructor for ExternalItem.
* ast/rust-item.h (class Function): Add `is_external_function`
field. Update `get_node_id`.
* ast/rust-macro.h: Update copy constructor.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
4 months agoClean BiMap to use tl::optional for lookups
Sourabh Jaiswal [Fri, 1 Mar 2024 11:46:23 +0000 (19:46 +0800)]
Clean BiMap to use tl::optional for lookups

gcc/rust/Changelog:

* expand/rust-expand-visitor.cc
(ExpandVisitor::expand_inner_items): Adjust to use has_value ()
(ExpandVisitor::expand_inner_stmts): Likewise
* expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise
(make_macro_path_str): Likewise
* util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise
* util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional
(LangItem::toString) Likewise
* util/rust-token-converter.cc (handle_suffix): Adjust to use value.or ()
(from_literal) Likewise
* util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for
lookups

Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
4 months agoEnsure TupleStructPattern and TuplePattern have items
Owen Avery [Tue, 27 Feb 2024 21:34:23 +0000 (16:34 -0500)]
Ensure TupleStructPattern and TuplePattern have items

Note that instances of both classes which have been
moved from will have (items == nullptr).

gcc/rust/ChangeLog:

* ast/rust-pattern.h
(class TupleStructPattern): Assert that items != nullptr.
(class TuplePattern): Likewise.
(TupleStructPattern::has_items): Remove.
(TuplePattern::has_tuple_pattern_items): Likewise.
* parse/rust-parse-impl.h
(Parser::parse_ident_leading_pattern):
Prevent construction of TupleStructPattern with
(items == nullptr).
(Parser::parse_pattern_no_alt): Likewise.
* ast/rust-ast-collector.cc
(TokenCollector::visit): Remove usage of
TupleStructPattern::has_items.
* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Likewise.
* resolve/rust-early-name-resolver.cc
(EarlyNameResolver::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/pattern-struct.rs: Fix test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agoAdd curly brackets, formatted clang
jjasmine [Fri, 1 Mar 2024 21:40:17 +0000 (16:40 -0500)]
Add curly brackets, formatted clang

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting

4 months agoAdd error emitting when we can't resolve id expr
jjasmine [Fri, 1 Mar 2024 10:31:15 +0000 (05:31 -0500)]
Add error emitting when we can't resolve id expr

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add error emitting

4 months agoformat-args: Add documentation for future expansion of function
Arthur Cohen [Fri, 1 Mar 2024 14:37:45 +0000 (15:37 +0100)]
format-args: Add documentation for future expansion of function

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Add
documentation regarding future tasks.

4 months agolower: Add base for lowering FormatArgs nodes
Arthur Cohen [Thu, 22 Feb 2024 13:59:17 +0000 (14:59 +0100)]
lower: Add base for lowering FormatArgs nodes

gcc/rust/ChangeLog:

* Make-lang.in: Compile the new source file.
* ast/rust-ast-collector.cc (TokenCollector::visit): Error out when
visiting FormatArgs nodes.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise.
* ast/rust-ast.cc (FormatArgs::get_locus): New.
* ast/rust-builtin-ast-nodes.h: Improve FormatArgs API.
* ast/rust-fmt.cc (Pieces::~Pieces): Cleanup.
(Pieces::Pieces): Likewise.
* ast/rust-fmt.h (struct Pieces): Add pieces_vector member.
* hir/rust-ast-lower-format-args.cc: New file.
* hir/rust-ast-lower-format-args.h: New file.

4 months agoformat-args: Fix Rust interface and add input parsing.
Arthur Cohen [Fri, 16 Feb 2024 17:27:22 +0000 (18:27 +0100)]
format-args: Fix Rust interface and add input parsing.

gcc/rust/ChangeLog:

* Make-lang.in: Do not build Rust library in release mode.
* ast/rust-ast.cc: Make FormatArgs inherit from AST::Expr
* ast/rust-builtin-ast-nodes.h: Improve FormatArg* nodes and helpers.
* ast/rust-fmt.cc (Pieces::collect): Fix interface to match FFI function.
* ast/rust-fmt.h (collect_pieces): Likewise.
(struct Pieces): Add append_newline parameter.
* expand/rust-macro-builtins.cc: Add proper parsing of format_args
input.
* hir/rust-ast-lower-base.cc: Include diagnostics header.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Switch interface to use more parser
parameters.
* libformat_parser/src/bin.rs: Use new interface.

4 months agoparser: Add peek(n) method to parser
Arthur Cohen [Mon, 19 Feb 2024 19:41:50 +0000 (20:41 +0100)]
parser: Add peek(n) method to parser

gcc/rust/ChangeLog:

* parse/rust-parse.h: New method.

4 months agomacro-builtins: Add newline generic format_args!() handler
Arthur Cohen [Fri, 16 Feb 2024 15:19:27 +0000 (16:19 +0100)]
macro-builtins: Add newline generic format_args!() handler

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (format_args_maker): New function.
(try_expand_many_expr): Add comment about reworking function.
(MacroBuiltin::format_args_handler): Add newline parameter.
* expand/rust-macro-builtins.h: Likewise.

4 months agoast: Add base nodes for FormatArgs
Arthur Cohen [Thu, 15 Feb 2024 19:58:48 +0000 (20:58 +0100)]
ast: Add base nodes for FormatArgs

This commit adds a base for creating AST FormatArgs nodes after expanding
invocations of `format_args!()`. These nodes will then be expanded to
the proper runtime function calls (to core::fmt::rt) during the AST
lowering.

gcc/rust/ChangeLog:

* ast/rust-builtin-ast-nodes.h: New file.
* ast/rust-ast-full-decls.h (class FormatArgs): Declare new class.
* ast/rust-ast-collector.cc: Handle FormatArgs nodes properly.
* ast/rust-ast-collector.h: Likewise.
* ast/rust-ast-full.h: Likewise.
* ast/rust-ast-visitor.cc: Likewise.
* ast/rust-ast-visitor.h: Likewise.
* ast/rust-ast.cc: Likewise.
* ast/rust-ast.h: Likewise.
* expand/rust-derive.h: Likewise.
* hir/rust-ast-lower-base.cc: Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-expr.cc: Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* resolve/rust-ast-resolve-base.cc: Likewise.
* resolve/rust-ast-resolve-base.h: Likewise.

4 months agoMake DefaultResolver visit more of the AST
Owen Avery [Wed, 28 Feb 2024 22:42:49 +0000 (17:42 -0500)]
Make DefaultResolver visit more of the AST

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner,
ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr,
PathInExpression, EnumItemTuple, EnumItemStruct, and
EnumItemDiscriminant.
* ast/rust-item.h
(EnumItemDiscriminant::has_expr): New function.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agoextern-types: Lower to HIR::ExternalTypeItem properly
Arthur Cohen [Tue, 20 Feb 2024 15:22:20 +0000 (16:22 +0100)]
extern-types: Lower to HIR::ExternalTypeItem properly

gcc/rust/ChangeLog:

* hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes.
* hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private
visibility by default as extern types have no visibility - add a comment
about the correctness of this.

4 months agohir: Add ExternalTypeItem node
Arthur Cohen [Tue, 20 Feb 2024 14:45:35 +0000 (15:45 +0100)]
hir: Add ExternalTypeItem node

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h (class ExternalTypeItem): New class.
* hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise.
* backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem
node.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
(ExternalTypeItem::accept_vis): Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.h: Likewise.

4 months agoextern-types: Declare external types in name resolver.
Arthur Cohen [Tue, 20 Feb 2024 13:53:32 +0000 (14:53 +0100)]
extern-types: Declare external types in name resolver.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-implitem.h: Declare external types as new
types.

4 months agolang-items: Make lang items enum stronger, rename class, cleanup ns.
Arthur Cohen [Tue, 27 Feb 2024 13:39:22 +0000 (14:39 +0100)]
lang-items: Make lang items enum stronger, rename class, cleanup ns.

gcc/rust/ChangeLog:

* util/rust-lang-item.h (class RustLangItem): Renamed to...
(class LangItem): ...this. Rename ItemType enum to Kind
* util/rust-lang-item.cc: Rename methods to use new class name.
* backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API.
(CompileExpr::resolve_operator_overload): Likewise.
* backend/rust-compile-expr.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise.
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise.
(AutoderefCycle::cycle): Likewise.
* typecheck/rust-autoderef.h: Likewise.
* typecheck/rust-hir-type-bounds.h: Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise.
(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::get_lang_item): Likewise.
(Mappings::lookup_trait_item_lang_item): Likewise.
* util/rust-hir-map.h: Likewise.

4 months agolang-items: Cleanup parsing and lookups of lang items.
Arthur Cohen [Tue, 27 Feb 2024 12:35:50 +0000 (13:35 +0100)]
lang-items: Cleanup parsing and lookups of lang items.

gcc/rust/ChangeLog:

* Make-lang.in: Compile new rust-lang-item.o.
* util/rust-lang-item.h: Split into header and source.
* util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap
and returning optional values, cleanup handling of exhaustive lang item
lookups.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use
new optional API.

4 months agoMerge commit '705de6d54ca95b8277a15fe9a2255af6168ae086' into HEAD [#2123]
Thomas Schwinge [Thu, 29 Feb 2024 13:04:29 +0000 (14:04 +0100)]
Merge commit '705de6d54ca95b8277a15fe9a2255af6168ae086' into HEAD [#2123]

4 months agoFix small FixMe task in rust macro builtins
jjasmine [Fri, 23 Feb 2024 21:06:14 +0000 (13:06 -0800)]
Fix small FixMe task in rust macro builtins

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc: Change BuiltinMacro in
builtin_macro_from_string to tl::optional<>
* expand/rust-macro-builtins.h (enum class): Change BuiltinMacro
in builtin_macro_from_string to tl::optional<>
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Resolved wrong type dependency of builtin_macro_from_string

Signed-off-by: jjasmine <tanghocle456@gmail.com>
4 months agoAdjust error checks to match name resolution 2.0
Owen Avery [Fri, 23 Feb 2024 15:20:55 +0000 (10:20 -0500)]
Adjust error checks to match name resolution 2.0

gcc/testsuite/ChangeLog:

* rust/compile/bad_stmt_enums.rs: Adjust redefinition error.
* rust/compile/bad_toplevel_enums.rs: Likewise.
* rust/compile/redef_error1.rs: Likewise.
* rust/compile/redef_error3.rs: Likewise.
* rust/compile/redef_error4.rs: Likewise.
* rust/compile/redef_error6.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
4 months agoci: Install cargo on ubuntu 18.04 container.
Arthur Cohen [Mon, 26 Feb 2024 10:57:54 +0000 (11:57 +0100)]
ci: Install cargo on ubuntu 18.04 container.

ChangeLog:

* .github/workflows/ccpp.yml: Install cargo for GCC 4.8 job.

4 months agoformat-parser: Add `is_some_and` method for Option<T>
Arthur Cohen [Mon, 26 Feb 2024 10:55:47 +0000 (11:55 +0100)]
format-parser: Add `is_some_and` method for Option<T>

Workaround for Ubuntu 18.04, since we still use it for the GCC 4.8 CI.
The default Rust package is 1.65 (and unlikely to change I assume?),
but the generic format parser library uses `is_some_and` which was
introduced in 1.70. So this is a simple reimplementation, directly taken
from the standard library sources.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add IsSomeAnd<T>
trait, impl it for Option<T>.

4 months agolibformat_parser: Fix Rust warnings.
Arthur Cohen [Thu, 15 Feb 2024 12:11:26 +0000 (13:11 +0100)]
libformat_parser: Fix Rust warnings.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Remove
unused deprecated attribute and unused import.
* libformat_parser/src/lib.rs: Remove unused import.

4 months agorust-fmt: Store parsed string in Pieces struct
Arthur Cohen [Tue, 13 Feb 2024 15:31:25 +0000 (16:31 +0100)]
rust-fmt: Store parsed string in Pieces struct

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership
of the given string.
* ast/rust-fmt.h (struct Pieces): Store parsed string in the struct.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add debug prompt.

4 months agoformat_args: Parse entire token invocation
Arthur Cohen [Wed, 7 Feb 2024 11:46:16 +0000 (12:46 +0100)]
format_args: Parse entire token invocation

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Transform entire invocation token stream into string for the parser.

4 months agoformat_args: Parse format string properly
Arthur Cohen [Tue, 30 Jan 2024 15:16:36 +0000 (16:16 +0100)]
format_args: Parse format string properly

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Construct string to parser properly.

4 months agolibformat_parser: Send boxed values across FFI properly
Arthur Cohen [Tue, 30 Jan 2024 00:48:13 +0000 (01:48 +0100)]
libformat_parser: Send boxed values across FFI properly

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::~Pieces): Call libformat_parser's release
function in destructor.
* ast/rust-fmt.h (struct PieceSlice): Add capacity.
(destroy_pieces): New.
(struct Pieces): Add destructor.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Leak Boxes properly for C++ to
see them, add memory release function.

4 months agolibformat_parser: Update header and remove old interface
Arthur Cohen [Mon, 29 Jan 2024 21:06:39 +0000 (22:06 +0100)]
libformat_parser: Update header and remove old interface

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Use new Pieces API.
* ast/rust-fmt.h: Update interface with new FFI bindings.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add IntoFFI trait.
* libformat_parser/libformat-parser.h: Removed.

4 months agogit: Ignore libgrust build folders
Arthur Cohen [Mon, 29 Jan 2024 15:17:00 +0000 (16:17 +0100)]
git: Ignore libgrust build folders

ChangeLog:

* .gitignore: Add libgrust target folders to the ignore list.

4 months agolibformat_parser: Start experimenting with cbindgen
Arthur Cohen [Mon, 29 Jan 2024 15:14:13 +0000 (16:14 +0100)]
libformat_parser: Start experimenting with cbindgen

libgrust/ChangeLog:

* libformat_parser/cbindgen.toml: New file.
* libformat_parser/libformat-parser.h: New file.

gcc/rust/ChangeLog:

* ast/rust-fmt.h: Add remaining FFI types.

4 months agolibformat_parser: Add FFI safe interface
Arthur Cohen [Mon, 29 Jan 2024 15:13:24 +0000 (16:13 +0100)]
libformat_parser: Add FFI safe interface

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add generic
library.
* libformat_parser/src/lib.rs: Add base for FFI interface.

4 months agolibgrust: Add format_parser library
Arthur Cohen [Thu, 30 Nov 2023 13:11:41 +0000 (14:11 +0100)]
libgrust: Add format_parser library

Compile libformat_parser and link to it.

gcc/rust/ChangeLog:

* Make-lang.in: Compile libformat_parser.
* ast/rust-fmt.cc: New FFI definitions.
* ast/rust-fmt.h: Likewise.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call
into libformat_parser.
* expand/rust-macro-builtins.h: Define format_args!() handler proper.

libgrust/ChangeLog:

* libformat_parser/Cargo.lock: New file.
* libformat_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/src/lib.rs: New file.
* libformat_parser/src/bin.rs: New file.
* libformat_parser/src/lib.rs: New file.

4 months agofmt: Start working on format_args!() parser
Arthur Cohen [Thu, 9 Nov 2023 17:32:52 +0000 (18:32 +0100)]
fmt: Start working on format_args!() parser

This commit adds a base class for parsing the various constructs of a
Rust format string, according to the grammar in the reference:

https://doc.rust-lang.org/std/fmt/index.html#syntax

gcc/rust/ChangeLog:

* Make-lang.in: Compile rust-fmt object
* ast/rust-fmt.cc: New file.
* ast/rust-fmt.h: New file.

5 months agogccrs: minor cleanup in langhook.type_for_mode
Marc Poulhiès [Mon, 19 Feb 2024 21:52:29 +0000 (22:52 +0100)]
gccrs: minor cleanup in langhook.type_for_mode

gcc/rust/ChangeLog:

* rust-lang.cc (grs_langhook_type_for_mode): simplify code for
xImode. Add missing long_double_type_node.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
5 months agoFix false positive for top-level AltPattern
Owen Avery [Sun, 18 Feb 2024 05:19:25 +0000 (00:19 -0500)]
Fix false positive for top-level AltPattern

gcc/rust/ChangeLog:

* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit):
Reset is_let_top_level while visiting GroupedPattern.

gcc/testsuite/ChangeLog:

* rust/compile/let_alt.rs: Check for false positive.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
5 months agogccrs: fix powif64 intrinsic
Marc Poulhiès [Mon, 19 Feb 2024 21:36:39 +0000 (22:36 +0100)]
gccrs: fix powif64 intrinsic

The signature was incorrectly using an i64 for the integer power,
instead of an i32.

gcc/testsuite/ChangeLog:

* rust/compile/torture/intrinsics-math.rs: Adjust powif64
intrinsic signature.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
5 months agolibgrust: Add entry for maintainers
Pierre-Emmanuel Patry [Tue, 28 Nov 2023 12:40:55 +0000 (13:40 +0100)]
libgrust: Add entry for maintainers

ChangeLog:

* MAINTAINERS: Add maintainers for libgrust.

contrib/ChangeLog:

* gcc-changelog/git_commit.py: Add libgrust.

(cherry picked from commit e4f0eb725d836ef0eec780cbb9e7be0d31c6fe8b)

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
5 months agolibgrust: Add ChangeLog file
Pierre-Emmanuel Patry [Tue, 28 Nov 2023 12:39:35 +0000 (13:39 +0100)]
libgrust: Add ChangeLog file

libgrust/ChangeLog:

* ChangeLog: New file.

(cherry picked from commit a857ec6aada08d8c334c389c7b682198d749b6c9)

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
5 months agogccrs: Avoid *.bak suffixed tests - use dg-skip-if instead
Jakub Jelinek [Thu, 15 Feb 2024 12:55:49 +0000 (13:55 +0100)]
gccrs: Avoid *.bak suffixed tests - use dg-skip-if instead

On Fri, Feb 09, 2024 at 11:03:38AM +0100, Jakub Jelinek wrote:
> On Wed, Feb 07, 2024 at 12:43:59PM +0100, arthur.cohen@embecosm.com wrote:
> > This patch introduces one regression because generics are getting better
> > understood over time. The code here used to apply generics with the same
> > symbol from previous segments which was a bit of a hack with out limited
> > inference variable support. The regression looks like it will be related
> > to another issue which needs to default integer inference variables much
> > more aggresivly to default integer.
> >
> > Fixes #2723
> >     * rust/compile/issue-1773.rs: Moved to...
> >     * rust/compile/issue-1773.rs.bak: ...here.
>
> Please don't use such suffixes in the testsuite.
> Either delete the testcase, or xfail it somehow until the bug is fixed.

To be precise, I have scripts to look for backup files in the tree (*~,
*.bak, *.orig, *.rej etc.) and this stands in the way several times a day.

Here is a fix for that in patch form, tested on x86_64-linux with
make check-rust RUNTESTFLAGS='compile.exp=issue-1773.rs'

2024-02-15  Jakub Jelinek  <jakub@redhat.com>

* rust/compile/issue-1773.rs.bak: Rename to ...
* rust/compile/issue-1773.rs: ... this.  Add dg-skip-if directive.

5 months agoUpdate copyright years.
Sahil Yeole [Thu, 15 Feb 2024 20:48:44 +0000 (02:18 +0530)]
Update copyright years.

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
5 months agocontrib: Add libgrust to update-copyright.py script
Sahil Yeole [Thu, 15 Feb 2024 20:45:17 +0000 (02:15 +0530)]
contrib: Add libgrust to update-copyright.py script

contrib/ChangeLog:
* update-copyright.py: Add libgrust folder.

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
5 months agoAdd variadic check on function params
0xn4utilus [Wed, 14 Feb 2024 16:49:15 +0000 (22:19 +0530)]
Add variadic check on function params

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add variadic check on all parameters.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2850.rs: New test.

Signed-off-by: 0xn4utilus <gyanendrabanjare8@gmail.com>
5 months agoFix lookup of TuplePattern sub-pattern types
Owen Avery [Mon, 12 Feb 2024 23:20:19 +0000 (18:20 -0500)]
Fix lookup of TuplePattern sub-pattern types

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc
(CompilePatternLet::visit):
Lookup type of sub-pattern, not tuple pattern itself.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2847-b.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
5 months agogccrs: add powi intrinsics
Marc Poulhiès [Sun, 22 Oct 2023 16:52:22 +0000 (18:52 +0200)]
gccrs: add powi intrinsics

gcc/rust/ChangeLog:

* backend/rust-builtins.cc
(BuiltinsContext::register_rust_mappings): Add powi and reformat.
* backend/rust-builtins.h: Add missing copyright header.

gcc/testsuite/ChangeLog:

* rust/compile/torture/intrinsics-math.rs: Adjust pow test, add
test for powi.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
5 months agogccrs: Add testcase for #[rustc_const_stable]
Arthur Cohen [Wed, 7 Feb 2024 08:27:11 +0000 (09:27 +0100)]
gccrs: Add testcase for #[rustc_const_stable]

To ensure we don't introduce regressions back to issue #2314

gcc/testsuite/ChangeLog:

* rust/compile/rustc_const_stable.rs: New test.

5 months agoexpand: Fix formatting for "macro not found" error
Arthur Cohen [Tue, 6 Feb 2024 16:26:23 +0000 (17:26 +0100)]
expand: Fix formatting for "macro not found" error

gcc/rust/ChangeLog:

* expand/rust-macro-expand.h (struct MacroExpander): Nitpick: fix
formatting of emitted error.

5 months agoFix rebinding imports
Owen Avery [Wed, 21 Jun 2023 14:26:30 +0000 (10:26 -0400)]
Fix rebinding imports

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-item.cc
(flatten_glob): Use Import class.
(flatten_rebind): Likewise.
(flatten_list): Likewise.
(flatten): Likewise.
(flatten_use_dec_to_paths): Likewise.
(flatten_use_dec_to_imports): Likewise.
(ResolveItem::visit): Likewise.
(Import::add_prefix): New.
(rust_flatten_nested_glob): Adjust test.
(rust_flatten_glob): Likewise.
(rust_flatten_rebind_none): Likewise.
(rust_flatten_rebind): Likewise.
(rust_flatten_rebind_nested): Likewise.
(rust_flatten_list): Likewise.
* resolve/rust-ast-resolve-item.h
(class Import): New.

gcc/testsuite/ChangeLog:

* rust/compile/use_2.rs: New test.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
5 months agogccrs: Add testcase for matches!() macro
Arthur Cohen [Tue, 6 Feb 2024 16:01:46 +0000 (17:01 +0100)]
gccrs: Add testcase for matches!() macro

This adds a testcase for issue #2129.

gcc/testsuite/ChangeLog:

* rust/execute/torture/matches_macro.rs: New test.

5 months agogccrs: Fix typo in RegionConstraints instance
Arthur Cohen [Wed, 7 Feb 2024 14:42:18 +0000 (15:42 +0100)]
gccrs: Fix typo in RegionConstraints instance

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-implitem.h: Fix typo in field
(region_costraints -> region_constraints).

5 months agoFix macro parsing for trait items.
Kushal Pal [Fri, 26 Jan 2024 13:05:59 +0000 (18:35 +0530)]
Fix macro parsing for trait items.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_trait_item):
Handle macros in trait items similar to how its handled for trait
implementation items.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
5 months agoRemove obsolete classes and functions.
Kushal Pal [Fri, 26 Jan 2024 07:51:37 +0000 (13:21 +0530)]
Remove obsolete classes and functions.

Trait functions now use AST::Function class, so classes
AST::TraitItemFunc, AST::TraitItemMethod, AST::TraitFunctionDecl,
AST::TraitMethodDecl and their related functions can be removed.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit):
Remove obsolete classes and functions.
* ast/rust-ast-collector.h:
Likewise.
* ast/rust-ast-full-decls.h (class TraitFunctionDecl):
Likewise.
(class TraitItemFunc):
Likewise.
(class TraitMethodDecl):
Likewise.
(class TraitItemMethod):
Likewise.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):
Likewise.
* ast/rust-ast-visitor.h:
Likewise.
* ast/rust-ast.cc (TraitItemFunc::TraitItemFunc):
Likewise.
(TraitItemFunc::operator=):
Likewise.
(TraitItemFunc::as_string):
Likewise.
(TraitFunctionDecl::as_string):
Likewise.
(TraitItemMethod::TraitItemMethod):
Likewise.
(TraitItemMethod::operator=):
Likewise.
(TraitItemMethod::as_string):
Likewise.
(TraitMethodDecl::as_string):
Likewise.
(TraitItemFunc::accept_vis):
Likewise.
(TraitItemMethod::accept_vis):
Likewise.
* ast/rust-item.h (class TraitFunctionDecl):
Likewise.
(class TraitItemFunc):
Likewise.
(class TraitMethodDecl):
Likewise.
(class TraitItemMethod):
Likewise.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Likewise.
* checks/errors/rust-ast-validation.h:
Likewise.
* checks/errors/rust-feature-gate.h:
Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_trait_function_decl):
Likewise.
(CfgStrip::maybe_strip_trait_method_decl):
Likewise.
(CfgStrip::visit):
Likewise.
* expand/rust-cfg-strip.h:
Likewise.
* expand/rust-derive.h:
Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::expand_trait_function_decl):
Likewise.
(ExpandVisitor::expand_trait_method_decl):
Likewise.
(ExpandVisitor::visit):
Likewise.
* expand/rust-expand-visitor.h:
Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):
Likewise.
* hir/rust-ast-lower-base.h:
Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit):
Likewise.
* hir/rust-ast-lower-implitem.h:
Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit):
Likewise.
* resolve/rust-ast-resolve-base.h:
Likewise.
* resolve/rust-ast-resolve-implitem.h (visit):
Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
* resolve/rust-ast-resolve-item.h:
Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit):
Likewise.
* resolve/rust-default-resolver.h:
Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* resolve/rust-toplevel-name-resolver-2.0.h:
Likewise.
* util/rust-attributes.cc (AttributeChecker::visit):
Likewise.
* util/rust-attributes.h:
Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
5 months agoParse trait functions as `AST::Function`.
Kushal Pal [Fri, 26 Jan 2024 06:20:05 +0000 (11:50 +0530)]
Parse trait functions as `AST::Function`.

To use AST::Function for trait functions, we can parse trait functions
using available parse_function().

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_trait_item):
Use parse_function() to parse trait functions.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
5 months agoFix inconsistent formatting.
Kushal Pal [Fri, 26 Jan 2024 06:14:12 +0000 (11:44 +0530)]
Fix inconsistent formatting.

gcc/testsuite/ChangeLog:

* rust/compile/issue-2040.rs:
Enclose 'const' in single quotes.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
5 months agoAdd missing visitors for AST::Function.
Kushal Pal [Fri, 26 Jan 2024 06:05:24 +0000 (11:35 +0530)]
Add missing visitors for AST::Function.

To use AST::Function instead of AST::TraitItemFunc and
AST::TraitItemMethod, we need to provide similar visitors during
lowering and resolving phase.

gcc/rust/ChangeLog:

* hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit):
Provide visitor for AST::Function.
* hir/rust-ast-lower-implitem.h:
Likewise.
* resolve/rust-ast-resolve-implitem.h:
Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
* resolve/rust-ast-resolve-item.h:
Likewise.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
5 months agoAdd checks for Trait functions
Kushal Pal [Fri, 26 Jan 2024 05:55:10 +0000 (11:25 +0530)]
Add checks for Trait functions

Since we want to use AST::Function class for trait functions as well, we
need to check against specific conditions in ASTValidation phase.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (ASTValidation::visit):
Add checks for Trait functions.

Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
This page took 0.100324 seconds and 5 git commands to generate.