gcc/libgomp/testsuite
Lewis Hyatt 98e2676558 c: Fix location for _Pragma tokens [PR97498]
The handling of #pragma GCC diagnostic uses input_location, which is not always
as precise as needed; in particular the relative location of some tokens and a
_Pragma directive will crucially determine whether a given diagnostic is enabled
or suppressed in the desired way. PR97498 shows how the C frontend ends up with
input_location pointing to the beginning of the line containing a _Pragma()
directive, resulting in the wrong behavior if the diagnostic to be modified
pertains to some tokens found earlier on the same line. This patch fixes that by
addressing two issues:

    a) libcpp was not assigning a valid location to the CPP_PRAGMA token
    generated by the _Pragma directive.
    b) C frontend was not setting input_location to something reasonable.

With this change, the C frontend is able to change input_location to point to
the _Pragma token as needed.

This is just a two-line fix (one for each of a) and b)), the testsuite changes
were needed only because the location on the tested warnings has been somewhat
improved, so the tests need to look for the new locations.

gcc/c/ChangeLog:

	PR preprocessor/97498
	* c-parser.cc (c_parser_pragma): Set input_location to the
	location of the pragma, rather than the start of the line.

libcpp/ChangeLog:

	PR preprocessor/97498
	* directives.cc (destringize_and_run): Override the location of
	the CPP_PRAGMA token from a _Pragma directive to the location of
	the expansion point, as is done for the tokens lexed from it.

gcc/testsuite/ChangeLog:

	PR preprocessor/97498
	* c-c++-common/pr97498.c: New test.
	* c-c++-common/gomp/pragma-3.c: Adapt for improved warning locations.
	* c-c++-common/gomp/pragma-5.c: Likewise.
	* gcc.dg/pragma-message.c: Likewise.

libgomp/ChangeLog:

	* testsuite/libgomp.oacc-c-c++-common/reduction-5.c: Adapt for
	improved warning locations.
	* testsuite/libgomp.oacc-c-c++-common/vred2d-128.c: Likewise.

(cherry picked from commit 0587cef3d7)
2022-08-01 13:38:24 -04:00
..
config Update copyright years. 2022-01-03 10:42:10 +01:00
lib Improve Intel MIC offloading XFAILing for 'omp_get_device_num' 2022-01-13 13:09:36 +01:00
libgomp.c libgomp: Fix up target-31.c test [PR106045] 2022-06-28 17:31:53 +02:00
libgomp.c++ LTO: Fixes for renaming issues with offload/OpenMP [PR104285] 2022-03-23 09:44:39 +01:00
libgomp.c-c++-common openmp: Fix up handling of non-rectangular simd loops with pointer type iterators [PR106449] 2022-07-30 11:34:31 +02:00
libgomp.fortran OpenMP: Fix nested use_device_ptr 2022-04-05 08:31:34 -07:00
libgomp.graphite Update copyright years. 2022-01-03 10:42:10 +01:00
libgomp.oacc-c [testsuite] Unset 'offload_target' after use 2020-07-24 14:00:43 +02:00
libgomp.oacc-c++ nvptx: update fix for -Wformat-diag 2022-01-19 08:27:00 +01:00
libgomp.oacc-c-c++-common c: Fix location for _Pragma tokens [PR97498] 2022-08-01 13:38:24 -04:00
libgomp.oacc-fortran Fix up 'libgomp.oacc-fortran/print-1.f90' GCN offloading compilation [PR104717] 2022-04-28 15:15:29 +02:00
Makefile.am libgomp/test: Remove a build sysroot fix regression 2020-04-06 23:32:45 +01:00
Makefile.in libgomp: Regenerate configure files with automake 1.15.1 2020-10-02 12:08:47 +02:00
libgomp-site-extra.exp.in libgomp/test: Remove a build sysroot fix regression 2020-04-06 23:32:45 +01:00
libgomp-test-support.exp.in libgomp/test: Remove a build sysroot fix regression 2020-04-06 23:32:45 +01:00