[Bug c/89658] New: __BASE_FILE__ is not preserved when using -fdirectives-only

2019-03-11 Thread jpewhacker at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89658

Bug ID: 89658
   Summary: __BASE_FILE__ is not preserved when using
-fdirectives-only
   Product: gcc
   Version: 8.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jpewhacker at gmail dot com
  Target Milestone: ---

Created attachment 45938
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45938&action=edit
test.c

When using "-E -fdirectives-only" to preprocess a file, then compiling it later
with "-fprocessed -fdirectives-only", __BASE_FILE__ is not correctly preserved.
__FILE__ is preserved due to file and line number directives in the
preprocessed output, but __BASE_FILE__ gets lost.

The attached source program can demonstrate this behaviour as follows:

 $ gcc -o preprocess.c -E test.c -fdirectives-only && gcc -o test -xc
preprocess.c -fpreprocessed -fdirectives-only && ./test
 __BASE_FILE__ = preprocess.c
 __FILE__ = test.c

As can be seen, __FILE__ is correctly set from the original input file, but
__BASE_FILE__ picks up the name of the preprocessed intermediate file (and
doesn't match the initial __FILE__ as expected).


Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-libmpx
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --enable-cet --with-tune=generic
--with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC)

[Bug preprocessor/91152] New: endif-label error when using #pragma with -fdirectives-only

2019-07-12 Thread jpewhacker at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91152

Bug ID: 91152
   Summary: endif-label error when using #pragma with
-fdirectives-only
   Product: gcc
   Version: 9.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: preprocessor
  Assignee: unassigned at gcc dot gnu.org
  Reporter: jpewhacker at gmail dot com
  Target Milestone: ---

Created attachment 46595
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46595&action=edit
test.c

When using "-E -fdirectives-only" some pragmas enclosed in #if blocks will
cause endif-labels warning and also fail to preprocess correctly (the pragma is
remove from the processed output).

The attached program source can demonstrate this behaviour as follows:

 $ gcc -DUSE_OPENMP -fopenmp -E -fdirectives-only -o preprocess.c test.c &&
grep "pragma omp" preprocess.c
 test.c:4:7: warning: extra tokens at end of #endif directive [-Wendif-labels]
 4 | #pragma omp threadprivate(state)
   |   ^

Note the lack of pragma in the pre-processed output


Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.1.1 20190503 (Red Hat 9.1.1-1) (GCC)