From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 4B862381F704; Wed, 8 Jun 2022 12:08:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B862381F704 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Merge #938 X-Act-Checkin: gcc X-Git-Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 752bf6c80a922e09edf5bcb53e15e08e83057a7f X-Git-Newrev: 9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84 Message-Id: <20220608120810.4B862381F704@sourceware.org> Date: Wed, 8 Jun 2022 12:08:10 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:08:10 -0000 https://gcc.gnu.org/g:9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84 commit 9fb06d66cef70584e7aa2fa3a6ad22ef7def6b84 Merge: 752bf6c80a9 37415eec774 Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> Date: Thu Feb 17 17:02:43 2022 +0000 Merge #938 938: First pass at declarative macro expansion r=philberty a=philberty 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 Co-authored-by: Philip Herron Diff: gcc/rust/ast/rust-ast-full-test.cc | 13 - gcc/rust/ast/rust-ast.h | 224 +++++++-- gcc/rust/ast/rust-macro.h | 100 ++-- gcc/rust/expand/rust-macro-expand.cc | 632 ++++++++++++++++++++++++-- gcc/rust/expand/rust-macro-expand.h | 148 +++++- gcc/rust/hir/rust-ast-lower-expr.h | 10 + gcc/rust/hir/rust-ast-lower-implitem.h | 20 + gcc/rust/hir/rust-ast-lower-item.h | 10 + gcc/rust/hir/rust-ast-lower-stmt.h | 10 + gcc/rust/lex/rust-lex.h | 19 + gcc/rust/parse/rust-parse-impl.h | 26 ++ gcc/rust/parse/rust-parse.cc | 26 -- gcc/rust/parse/rust-parse.h | 46 +- gcc/rust/resolve/rust-ast-resolve-expr.h | 7 + gcc/rust/resolve/rust-ast-resolve-implitem.h | 21 + gcc/rust/resolve/rust-ast-resolve-item.h | 14 + gcc/rust/resolve/rust-ast-resolve-stmt.h | 8 + gcc/rust/resolve/rust-ast-resolve-toplevel.h | 7 + gcc/rust/resolve/rust-ast-resolve.cc | 40 ++ gcc/rust/resolve/rust-name-resolver.h | 9 + gcc/rust/typecheck/rust-tycheck-dump.h | 6 + gcc/rust/util/rust-hir-map.cc | 20 + gcc/rust/util/rust-hir-map.h | 7 + gcc/testsuite/rust/execute/torture/macros1.rs | 13 + gcc/testsuite/rust/execute/torture/macros2.rs | 40 ++ gcc/testsuite/rust/execute/torture/macros3.rs | 61 +++ gcc/testsuite/rust/execute/torture/macros4.rs | 15 + gcc/testsuite/rust/execute/torture/macros5.rs | 13 + gcc/testsuite/rust/execute/torture/macros6.rs | 12 + gcc/testsuite/rust/execute/xfail/macro2.rs | 30 -- gcc/testsuite/rust/execute/xfail/macro3.rs | 45 -- 31 files changed, 1383 insertions(+), 269 deletions(-)