]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add missing linemap to lexer
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 29 Aug 2023 15:24:03 +0000 (17:24 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:34 +0000 (19:04 +0100)
When some proc macro create tokens and later have some code referring to
those created tokens the code was missing a linemap since the pointer
was null, throwing an ICE.

gcc/rust/ChangeLog:

* expand/rust-proc-macro.cc (tokenstream_from_string): Change
linemap null pointer to the current linemap.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/expand/rust-proc-macro.cc

index f0f6d65f8cf9064b2ebbb0c1d6291e908534f1b8..2fdfcb20b19b9e5ef26851d23897da68b482a0df 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "rust-diagnostics.h"
 #include "rust-proc-macro.h"
+#include "rust-session-manager.h"
 #include "rust-lex.h"
 #include "rust-token-converter.h"
 #include "rust-attributes.h"
@@ -68,7 +69,7 @@ ProcMacro::TokenStream
 tokenstream_from_string (std::string &data, bool &lex_error)
 {
   // FIXME: Insert location pointing to call site in tokens
-  Lexer lex (data, nullptr);
+  Lexer lex (data, Session::get_instance ().linemap);
 
   std::vector<const_TokenPtr> tokens;
   TokenPtr ptr;