aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-08-01 05:53:37 +0200
committerMartin Liska <mliska@suse.cz>2022-08-01 05:53:37 +0200
commit89eca196c99645ee1abefcf8b4a9dd84edd87ad6 (patch)
tree185cc8907ce37e82132f395cb52611f029215355 /gcc/c-family
parent3a4cd5dc6faca8fed7fa256c4c06f4999b5a1f9c (diff)
parent4a7274ddc4970c1ad011343ed285d6219dffa396 (diff)
downloadgcc-89eca196c99645ee1abefcf8b4a9dd84edd87ad6.zip
gcc-89eca196c99645ee1abefcf8b4a9dd84edd87ad6.tar.gz
gcc-89eca196c99645ee1abefcf8b4a9dd84edd87ad6.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-common.cc10
-rw-r--r--gcc/c-family/c-common.h8
-rw-r--r--gcc/c-family/c-opts.cc6
4 files changed, 26 insertions, 7 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 73e959d..68fc6e2 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-31 Lewis Hyatt <lhyatt@gmail.com>
+
+ PR c++/66290
+ * c-common.h: Rename global done_lexing to
+ override_libcpp_locations.
+ * c-common.cc (c_cpp_diagnostic): Likewise.
+ * c-opts.cc (c_common_finish): Set override_libcpp_locations
+ (formerly done_lexing) immediately prior to calling cpp_finish ().
+
2022-07-27 Lewis Hyatt <lhyatt@gmail.com>
* c-ppoutput.cc (token_streamer::stream): Update input_location
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 655c3ae..6e41ceb 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -284,9 +284,11 @@ int c_inhibit_evaluation_warnings;
be generated. */
bool in_late_binary_op;
-/* Whether lexing has been completed, so subsequent preprocessor
- errors should use the compiler's input_location. */
-bool done_lexing = false;
+/* Depending on which phase of processing we are in, we may need
+ to prefer input_location to libcpp's locations. (Specifically,
+ after the C++ lexer is done lexing tokens, but prior to calling
+ cpp_finish (), we need to do so. */
+bool override_libcpp_locations;
/* Information about how a function name is generated. */
struct fname_var_t
@@ -6681,7 +6683,7 @@ c_cpp_diagnostic (cpp_reader *pfile ATTRIBUTE_UNUSED,
default:
gcc_unreachable ();
}
- if (done_lexing)
+ if (override_libcpp_locations)
richloc->set_range (0, input_location, SHOW_RANGE_WITH_CARET);
diagnostic_set_info_translated (&diagnostic, msg, ap,
richloc, dlevel);
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index f906439..c06769b 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -767,10 +767,12 @@ extern int max_tinst_depth;
extern int c_inhibit_evaluation_warnings;
-/* Whether lexing has been completed, so subsequent preprocessor
- errors should use the compiler's input_location. */
+/* Depending on which phase of processing we are in, we may need
+ to prefer input_location to libcpp's locations. (Specifically,
+ after the C++ lexer is done lexing tokens, but prior to calling
+ cpp_finish (), we need to do so. */
-extern bool done_lexing;
+extern bool override_libcpp_locations;
/* C types are partitioned into three subsets: object, function, and
incomplete types. */
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index b9f01a6..4e14636 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1281,6 +1281,12 @@ c_common_finish (void)
}
}
+ /* When we call cpp_finish (), it may generate some diagnostics using
+ locations it remembered from the preprocessing phase, e.g. for
+ -Wunused-macros. So inform c_cpp_diagnostic () not to override those
+ locations with input_location, which would be incorrect now. */
+ override_libcpp_locations = false;
+
/* For performance, avoid tearing down cpplib's internal structures
with cpp_destroy (). */
cpp_finish (parse_in, deps_stream);