aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-05-16 00:31:38 -0400
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:37:19 +0100
commit7c317571911ee3e9525513634c7e6bc6820dca7c (patch)
tree8cc7b9897d4fbecb9513586cfb22197684a282ba
parent48408712cc8cc39cba50c10938a284661ddece87 (diff)
downloadgcc-7c317571911ee3e9525513634c7e6bc6820dca7c.zip
gcc-7c317571911ee3e9525513634c7e6bc6820dca7c.tar.gz
gcc-7c317571911ee3e9525513634c7e6bc6820dca7c.tar.bz2
gccrs: Change return type of token_id_keyword_string
gcc/rust/ChangeLog: * lex/rust-token.cc (token_id_keyword_string): Return std::string reference. * lex/rust-token.h (token_id_keyword_string): Return std::string reference. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
-rw-r--r--gcc/rust/lex/rust-token.cc13
-rw-r--r--gcc/rust/lex/rust-token.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/gcc/rust/lex/rust-token.cc b/gcc/rust/lex/rust-token.cc
index 2956d92..777b4e1 100644
--- a/gcc/rust/lex/rust-token.cc
+++ b/gcc/rust/lex/rust-token.cc
@@ -74,20 +74,23 @@ token_id_is_keyword (TokenId id)
}
/* gets the string associated with a keyword */
-const char *
+const std::string &
token_id_keyword_string (TokenId id)
{
switch (id)
{
-#define RS_TOKEN_KEYWORD(id, str) \
- case id: \
- return str;
+#define RS_TOKEN_KEYWORD(id, str_ptr) \
+ case id: { \
+ static const std::string str (str_ptr); \
+ return str; \
+ } \
+ gcc_unreachable ();
#define RS_TOKEN(a, b)
RS_TOKEN_LIST
#undef RS_TOKEN_KEYWORD
#undef RS_TOKEN
default:
- return nullptr;
+ gcc_unreachable ();
}
}
diff --git a/gcc/rust/lex/rust-token.h b/gcc/rust/lex/rust-token.h
index 48640f5..c7ec753 100644
--- a/gcc/rust/lex/rust-token.h
+++ b/gcc/rust/lex/rust-token.h
@@ -230,7 +230,7 @@ token_id_to_str (TokenId id);
bool
token_id_is_keyword (TokenId id);
/* gets the string associated with a keyword */
-const char *
+const std::string &
token_id_keyword_string (TokenId id);
// Get type hint description as a string.
const char *