Skip to content
Snippets Groups Projects
  • Lewis Hyatt's avatar
    336ce497
    libcpp: Fix ICE on directive inside _Pragma() operator [PR67046] · 336ce497
    Lewis Hyatt authored
    get__Pragma_string() in directives.cc is responsible for lexing the parens
    and the string argument from a _Pragma("...") operator. This function does
    not handle the case when the closing paren is not on the same line as the
    string; in that case, libcpp will by default reuse the token buffer it
    previously used for the string, so that the string token returned by
    get__Pragma_string() may be corrupted, as shown in the testcase. Fix using
    the existing keep_tokens mechanism that temporarily disables the reuse of
    token buffers.
    
    libcpp/ChangeLog:
    
    	PR preprocessor/67046
    	* directives.cc (_cpp_do__Pragma): Increment pfile->keep_tokens to
    	ensure the returned string token is valid.
    
    gcc/testsuite/ChangeLog:
    
    	PR preprocessor/67046
    	* c-c++-common/cpp/pr67046.c: New test.
    336ce497
    History
    libcpp: Fix ICE on directive inside _Pragma() operator [PR67046]
    Lewis Hyatt authored
    get__Pragma_string() in directives.cc is responsible for lexing the parens
    and the string argument from a _Pragma("...") operator. This function does
    not handle the case when the closing paren is not on the same line as the
    string; in that case, libcpp will by default reuse the token buffer it
    previously used for the string, so that the string token returned by
    get__Pragma_string() may be corrupted, as shown in the testcase. Fix using
    the existing keep_tokens mechanism that temporarily disables the reuse of
    token buffers.
    
    libcpp/ChangeLog:
    
    	PR preprocessor/67046
    	* directives.cc (_cpp_do__Pragma): Increment pfile->keep_tokens to
    	ensure the returned string token is valid.
    
    gcc/testsuite/ChangeLog:
    
    	PR preprocessor/67046
    	* c-c++-common/cpp/pr67046.c: New test.