[gcc r14-7999] gccrs: Add missing linemap to lexer

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:12:18 GMT 2024


https://gcc.gnu.org/g:1501eed45018df1365c7d2a06772ca82dca1b8fe

commit r14-7999-g1501eed45018df1365c7d2a06772ca82dca1b8fe
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Tue Aug 29 17:24:03 2023 +0200

    gccrs: Add missing linemap to lexer
    
    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>

Diff:
---
 gcc/rust/expand/rust-proc-macro.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc
index f0f6d65f8cf..2fdfcb20b19 100644
--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -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;


More information about the Gcc-cvs mailing list