aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand/rust-macro-builtins.h
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2025-07-24 11:32:43 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-08-05 16:36:59 +0200
commit689f2ffb73cac20d5f0c64b50625573a46305392 (patch)
treeef44bdfbd5cbdf3a362fefb0244ca2747ec932e0 /gcc/rust/expand/rust-macro-builtins.h
parentaa57360f2631fb5a90bdf2976ec2bba35e962cc1 (diff)
downloadgcc-689f2ffb73cac20d5f0c64b50625573a46305392.zip
gcc-689f2ffb73cac20d5f0c64b50625573a46305392.tar.gz
gcc-689f2ffb73cac20d5f0c64b50625573a46305392.tar.bz2
gccrs: expand: Add parser for offset_of!() and builtin resolution.
gcc/rust/ChangeLog: * Make-lang.in: Compile the offset_of handler. * lang.opt: Add -frust-assume-builtin-offset-of option. * ast/rust-ast.h: Add has_str() for const_TokenPtr. * expand/rust-macro-builtins.cc: Map offset_of as builtin. * expand/rust-macro-builtins.h: Declare it. * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Add hack for calling builtin offset_of!(). * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Likewise. * expand/rust-macro-builtins-offset-of.cc: New file. gcc/testsuite/ChangeLog: * rust/compile/offset_of1.rs: New test.
Diffstat (limited to 'gcc/rust/expand/rust-macro-builtins.h')
-rw-r--r--gcc/rust/expand/rust-macro-builtins.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h
index 541e956..b6c2907 100644
--- a/gcc/rust/expand/rust-macro-builtins.h
+++ b/gcc/rust/expand/rust-macro-builtins.h
@@ -19,6 +19,7 @@
#ifndef RUST_MACRO_BUILTINS_H
#define RUST_MACRO_BUILTINS_H
+#include "optional.h"
#include "rust-ast.h"
#include "rust-builtin-ast-nodes.h"
#include "rust-ast-fragment.h"
@@ -188,6 +189,9 @@ public:
format_args_handler (location_t invoc_locus, AST::MacroInvocData &invoc,
AST::InvocKind semicolon, AST::FormatArgs::Newline nl);
+ static tl::optional<AST::Fragment>
+ offset_of_handler (location_t, AST::MacroInvocData &, AST::InvocKind);
+
static tl::optional<AST::Fragment> sorry (location_t invoc_locus,
AST::MacroInvocData &invoc,
AST::InvocKind semicolon);