Lewis Hyatt 78673484b4 c-family: Improve location for -Wunknown-pragmas in a _Pragma [PR118838]
The warning for -Wunknown-pragmas is issued at the location provided by
libcpp to the def_pragma() callback. This location is
cpp_reader::directive_line, which is a location for the start of the line
only; it is also not a valid location in case the unknown pragma was lexed
from a _Pragma string. These factors make it impossible to suppress
-Wunknown-pragmas via _Pragma("GCC diagnostic...") directives on the same
source line, as in the PR and the test case. Address that by issuing the
warning at a better location returned by cpp_get_diagnostic_override_loc().
libcpp already maintains this location to handle _Pragma-related diagnostics
internally; it was needed also to make a publicly accessible version of it.

gcc/c-family/ChangeLog:

	PR c/118838
	* c-lex.cc (cb_def_pragma): Call cpp_get_diagnostic_override_loc()
	to get a valid location at which to issue -Wunknown-pragmas, in case
	it was triggered from a _Pragma.

libcpp/ChangeLog:

	PR c/118838
	* errors.cc (cpp_get_diagnostic_override_loc): New function.
	* include/cpplib.h (cpp_get_diagnostic_override_loc): Declare.

gcc/testsuite/ChangeLog:

	PR c/118838
	* c-c++-common/cpp/pragma-diagnostic-loc-2.c: New test.
	* g++.dg/gomp/macro-4.C: Adjust expected output.
	* gcc.dg/gomp/macro-4.c: Likewise.
	* gcc.dg/cpp/Wunknown-pragmas-1.c: Likewise.
2025-04-27 22:35:25 -04:00
2025-04-16 00:18:18 +00:00
2025-04-27 00:16:47 +00:00
2025-04-02 00:18:25 +00:00
2025-03-30 00:16:46 +00:00
2025-04-17 00:18:03 +00:00
2025-04-11 00:17:32 +00:00
2025-04-26 00:19:18 +00:00
2025-04-22 00:17:26 +00:00
2025-04-23 00:18:18 +00:00
2025-04-25 00:18:00 +00:00
2025-04-26 00:19:18 +00:00
2025-04-01 00:19:09 +00:00
2025-03-30 00:16:46 +00:00
2025-04-13 00:17:09 +00:00
2025-04-10 00:18:06 +00:00
2025-04-26 00:19:18 +00:00
2025-04-26 00:19:18 +00:00
2025-04-23 00:18:18 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.7 GiB
Languages
C++ 30.7%
C 30.1%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.5%