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
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);
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. */
}
}
+ /* 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);
/* Subsequent preprocessor diagnostics should use compiler
diagnostic functions to get the compiler source location. */
- done_lexing = true;
+ override_libcpp_locations = true;
maybe_check_all_macros (parse_in);
because the location of the macro definition is incorrectly set. This is a
separate issue, will resolve it in a later patch. */
-#define X /* { dg-warning "-:-Wunused-macros" {} { xfail c++ } } */
+#define X /* { dg-warning "-:-Wunused-macros" } */
#pragma GCC diagnostic ignored "-Wunused-macros"