Skip to content
Snippets Groups Projects
  • Lewis Hyatt's avatar
    8c56d697
    libcpp: Fix _Pragma("GCC system_header") [PR114436] · 8c56d697
    Lewis Hyatt authored
    _Pragma("GCC system_header") currently takes effect only partially. It does
    succeed in updating the line_map, so that checks like in_system_header_at()
    return correctly, but it does not update pfile->buffer->sysp.  One result is
    that a subsequent #include does not set up the system header state properly
    for the newly included file, as pointed out in the PR. Fix by propagating
    the new system header state back to the buffer after processing the pragma.
    
    libcpp/ChangeLog:
    
    	PR preprocessor/114436
    	* directives.cc (destringize_and_run): If the _Pragma changed the
    	buffer system header state (e.g. because it was "GCC
    	system_header"), propagate that change back to the actual buffer
    	too.
    
    gcc/testsuite/ChangeLog:
    
    	PR preprocessor/114436
    	* c-c++-common/cpp/pragma-system-header-1.h: New test.
    	* c-c++-common/cpp/pragma-system-header-2.h: New test.
    	* c-c++-common/cpp/pragma-system-header.c: New test.
    8c56d697
    History
    libcpp: Fix _Pragma("GCC system_header") [PR114436]
    Lewis Hyatt authored
    _Pragma("GCC system_header") currently takes effect only partially. It does
    succeed in updating the line_map, so that checks like in_system_header_at()
    return correctly, but it does not update pfile->buffer->sysp.  One result is
    that a subsequent #include does not set up the system header state properly
    for the newly included file, as pointed out in the PR. Fix by propagating
    the new system header state back to the buffer after processing the pragma.
    
    libcpp/ChangeLog:
    
    	PR preprocessor/114436
    	* directives.cc (destringize_and_run): If the _Pragma changed the
    	buffer system header state (e.g. because it was "GCC
    	system_header"), propagate that change back to the actual buffer
    	too.
    
    gcc/testsuite/ChangeLog:
    
    	PR preprocessor/114436
    	* c-c++-common/cpp/pragma-system-header-1.h: New test.
    	* c-c++-common/cpp/pragma-system-header-2.h: New test.
    	* c-c++-common/cpp/pragma-system-header.c: New test.