aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbeamandala <mandalapubhavesh@gmail.com>2025-03-20 17:34:48 -0500
committerArthur Cohen <arthur.cohen@embecosm.com>2025-04-14 18:23:55 +0200
commite84f76dc584192826700ebb89f726984b0788259 (patch)
tree1d02f4395e9aec2cbb14ae86decb5a7696f19473 /gcc
parent497ed6099b2c9f8f37b0acca5b7e2800ee1d9331 (diff)
downloadgcc-e84f76dc584192826700ebb89f726984b0788259.zip
gcc-e84f76dc584192826700ebb89f726984b0788259.tar.gz
gcc-e84f76dc584192826700ebb89f726984b0788259.tar.bz2
gccrs: Add `#[track_caller]` as known attribute
gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::builtin_transcribers): Add entry for track_caller. * util/rust-attribute-values.h: add `TRACK_CALLER` attribute. * util/rust-attributes.cc: add `track_caller` attribute definition. gcc/testsuite/ChangeLog: * rust/compile/track_caller.rs: New test. Signed-off-by: Bhavesh Mandalapu <mandalapubhavesh@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/expand/rust-macro-builtins.cc1
-rw-r--r--gcc/rust/util/rust-attribute-values.h1
-rw-r--r--gcc/rust/util/rust-attributes.cc3
-rw-r--r--gcc/testsuite/rust/compile/track_caller.rs6
4 files changed, 10 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 39c4c46..a1388fb 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -137,6 +137,7 @@ std::unordered_map<std::string, AST::MacroTranscriberFunc>
{"cfg_accessible", MacroBuiltin::sorry},
{"rustc_const_stable", MacroBuiltin::sorry},
{"rustc_const_unstable", MacroBuiltin::sorry},
+ {"track_caller", MacroBuiltin::sorry},
/* Derive builtins do not need a real transcriber, but still need one. It
should however never be called since builtin derive macros get expanded
differently, and benefit from knowing on what kind of items they are
diff --git a/gcc/rust/util/rust-attribute-values.h b/gcc/rust/util/rust-attribute-values.h
index 9ef5cc5..d579fa2 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -58,6 +58,7 @@ public:
static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
static constexpr auto &MAY_DANGLE = "may_dangle";
static constexpr auto &PRELUDE_IMPORT = "prelude_import";
+ static constexpr auto &TRACK_CALLER = "track_caller";
};
} // namespace Values
} // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 03452c7..df0fe1b 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -75,7 +75,8 @@ static const BuiltinAttrDefinition __definitions[]
// assuming we keep these for static analysis
{Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
{Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
- {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION}};
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
+ {Attrs::TRACK_CALLER, CODE_GENERATION}};
BuiltinAttributeMappings *
BuiltinAttributeMappings::get ()
diff --git a/gcc/testsuite/rust/compile/track_caller.rs b/gcc/testsuite/rust/compile/track_caller.rs
new file mode 100644
index 0000000..fd1d842
--- /dev/null
+++ b/gcc/testsuite/rust/compile/track_caller.rs
@@ -0,0 +1,6 @@
+#[track_caller]
+fn foo() {}
+
+fn main() {
+ foo();
+}