Skip to content
Snippets Groups Projects
  • Tobias Burnus's avatar
    0078a058
    libcpp: Fix _Pragma expansion [PR102409] · 0078a058
    Tobias Burnus authored
    Both #pragma and _Pragma ended up as CPP_PRAGMA. Presumably since
    r131819 (2008, GCC 4.3) for PR34692, pragmas are not expanded in
    macro arguments but are output as is before. From the old bug report,
    that was to fix usage like
      FOO (
        #pragma GCC diagnostic
      )
    However, that change also affected _Pragma such that
      BAR (
        "1";
        _Pragma("omp ..."); )
    yielded
      #pragma omp ...
    followed by what BAR expanded too, possibly including '"1";'.
    
    This commit adds a flag, PRAGMA_OP, to tokens to make the two
    distinguishable - and include again _Pragma in the expanded arguments.
    
    libcpp/ChangeLog:
    
    	PR c++/102409
    	* directives.c (destringize_and_run): Add PRAGMA_OP to the
    	CPP_PRAGMA token's flags to mark is as coming from _Pragma.
    	* include/cpplib.h (PRAGMA_OP): #define, to be used with token flags.
    	* macro.c (collect_args): Only handle CPP_PRAGMA special if PRAGMA_OP
    	is set.
    
    gcc/testsuite/ChangeLog:
    
    	* c-c++-common/gomp/pragma-1.c: New test.
    	* c-c++-common/gomp/pragma-2.c: New test.
    0078a058
    History
    libcpp: Fix _Pragma expansion [PR102409]
    Tobias Burnus authored
    Both #pragma and _Pragma ended up as CPP_PRAGMA. Presumably since
    r131819 (2008, GCC 4.3) for PR34692, pragmas are not expanded in
    macro arguments but are output as is before. From the old bug report,
    that was to fix usage like
      FOO (
        #pragma GCC diagnostic
      )
    However, that change also affected _Pragma such that
      BAR (
        "1";
        _Pragma("omp ..."); )
    yielded
      #pragma omp ...
    followed by what BAR expanded too, possibly including '"1";'.
    
    This commit adds a flag, PRAGMA_OP, to tokens to make the two
    distinguishable - and include again _Pragma in the expanded arguments.
    
    libcpp/ChangeLog:
    
    	PR c++/102409
    	* directives.c (destringize_and_run): Add PRAGMA_OP to the
    	CPP_PRAGMA token's flags to mark is as coming from _Pragma.
    	* include/cpplib.h (PRAGMA_OP): #define, to be used with token flags.
    	* macro.c (collect_args): Only handle CPP_PRAGMA special if PRAGMA_OP
    	is set.
    
    gcc/testsuite/ChangeLog:
    
    	* c-c++-common/gomp/pragma-1.c: New test.
    	* c-c++-common/gomp/pragma-2.c: New test.