public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] c-family: Fix option check in handle_pragma_diagnostic [PR106252]
@ 2022-07-11 14:25 Lewis Hyatt
  0 siblings, 0 replies; only message in thread
From: Lewis Hyatt @ 2022-07-11 14:25 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 287 bytes --]

Hello-

PR106252 notes an error found by the address sanitizer from r13-1544. This was
my mistake during refactoring of handle_pragma_diagnostic(), the check
for the option arg was moved earlier than it should be. Committed the obvious
fix putting this back where it was before.

-Lewis

[-- Attachment #2: pr106252.txt --]
[-- Type: text/plain, Size: 1433 bytes --]

c-family: Fix option check in handle_pragma_diagnostic [PR106252]

In r13-1544, handle_pragma_diagnostic was refactored to support processing
early pragmas. During that process the part looking up option arguments was
inadvertenly moved too early, prior to checking the option was valid, causing
PR106252. Fixed by moving the check back where it goes.

gcc/c-family/ChangeLog:

	PR preprocessor/106252
	* c-pragma.cc (handle_pragma_diagnostic_impl): Don't look up the
	option argument prior to verifying the option was found.

diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index 62bce2ed0f5..789719e6e6a 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -1009,10 +1009,6 @@ handle_pragma_diagnostic_impl ()
   if (early && !c_option_is_from_cpp_diagnostics (option_index))
     return;
 
-  const char *arg = NULL;
-  if (cl_options[option_index].flags & CL_JOINED)
-    arg = data.option_str + 1 + cl_options[option_index].opt_len;
-
   if (option_index == OPT_SPECIAL_unknown)
     {
       if (want_diagnostics)
@@ -1052,6 +1048,10 @@ handle_pragma_diagnostic_impl ()
       return;
     }
 
+  const char *arg = NULL;
+  if (cl_options[option_index].flags & CL_JOINED)
+    arg = data.option_str + 1 + cl_options[option_index].opt_len;
+
   struct cl_option_handlers handlers;
   set_default_handlers (&handlers, NULL);
   /* FIXME: input_location isn't the best location here, but it is

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-11 14:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-11 14:25 [COMMITTED] c-family: Fix option check in handle_pragma_diagnostic [PR106252] Lewis Hyatt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).