aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Avery <powerboat9.gamer@gmail.com>2023-05-16 00:31:38 -0400
committerCohenArthur <arthur.cohen@embecosm.com>2023-05-16 08:22:35 +0000
commite02b4427f87be6d5f433e1965d36b3f197fca90f (patch)
treef66a86c3827033588a4590756063d7d329be6370
parent136ef0912e962052446de93d822c4661578d805a (diff)
downloadgcc-e02b4427f87be6d5f433e1965d36b3f197fca90f.zip
gcc-e02b4427f87be6d5f433e1965d36b3f197fca90f.tar.gz
gcc-e02b4427f87be6d5f433e1965d36b3f197fca90f.tar.bz2
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 179560d..0b5163c 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 9dea83c..68b41f7 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 *