Disable -Wformat-nonliteral in parts of printcmd.c
commit 3322c5d9a1
("Remove unneeded explicit .o targets") broke the
build with clang, because -Wno-format-nonliteral was in fact needed.
This patch fixes the problem by introducing
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL and using it in printcmd.c. This
seems preferable to reverting the patch because now the warning
suppression is more targeted.
gdb/ChangeLog
2018-09-05 Simon Marchi <simon.marchi@ericsson.com>
* printcmd.c (printf_c_string): Use
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
(printf_wide_c_string, printf_pointer, ui_printf): Likewise.
include/ChangeLog
2018-09-05 Simon Marchi <simon.marchi@ericsson.com>
* diagnostics.h (DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL): New macro.
This commit is contained in:
parent
4f075c06a3
commit
af39b1c216
|
@ -1,3 +1,9 @@
|
|||
2018-09-05 Simon Marchi <simon.marchi@ericsson.com>
|
||||
|
||||
* printcmd.c (printf_c_string): Use
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
|
||||
(printf_wide_c_string, printf_pointer, ui_printf): Likewise.
|
||||
|
||||
2018-09-05 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* cli/cli-cmds.c (shell_escape, edit_command): Remove cast.
|
||||
|
|
|
@ -2200,7 +2200,10 @@ printf_c_string (struct ui_file *stream, const char *format,
|
|||
tem = value_as_address (value);
|
||||
if (tem == 0)
|
||||
{
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, format, "(null)");
|
||||
DIAGNOSTIC_POP
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2221,7 +2224,10 @@ printf_c_string (struct ui_file *stream, const char *format,
|
|||
read_memory (tem, str, j);
|
||||
str[j] = 0;
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, format, (char *) str);
|
||||
DIAGNOSTIC_POP
|
||||
}
|
||||
|
||||
/* Subroutine of ui_printf to simplify it.
|
||||
|
@ -2245,7 +2251,10 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
|
|||
tem = value_as_address (value);
|
||||
if (tem == 0)
|
||||
{
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, format, "(null)");
|
||||
DIAGNOSTIC_POP
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2272,7 +2281,10 @@ printf_wide_c_string (struct ui_file *stream, const char *format,
|
|||
&output, translit_char);
|
||||
obstack_grow_str0 (&output, "");
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, format, obstack_base (&output));
|
||||
DIAGNOSTIC_POP
|
||||
}
|
||||
|
||||
/* Subroutine of ui_printf to simplify it.
|
||||
|
@ -2400,13 +2412,19 @@ printf_pointer (struct ui_file *stream, const char *format,
|
|||
*fmt_p++ = 'l';
|
||||
*fmt_p++ = 'x';
|
||||
*fmt_p++ = '\0';
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, fmt, val);
|
||||
DIAGNOSTIC_POP
|
||||
}
|
||||
else
|
||||
{
|
||||
*fmt_p++ = 's';
|
||||
*fmt_p++ = '\0';
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, fmt, "(nil)");
|
||||
DIAGNOSTIC_POP
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2507,8 +2525,11 @@ ui_printf (const char *arg, struct ui_file *stream)
|
|||
&output, translit_char);
|
||||
obstack_grow_str0 (&output, "");
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, current_substring,
|
||||
obstack_base (&output));
|
||||
DIAGNOSTIC_POP
|
||||
}
|
||||
break;
|
||||
case long_long_arg:
|
||||
|
@ -2516,7 +2537,10 @@ ui_printf (const char *arg, struct ui_file *stream)
|
|||
{
|
||||
long long val = value_as_long (val_args[i]);
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, current_substring, val);
|
||||
DIAGNOSTIC_POP
|
||||
break;
|
||||
}
|
||||
#else
|
||||
|
@ -2526,14 +2550,20 @@ ui_printf (const char *arg, struct ui_file *stream)
|
|||
{
|
||||
int val = value_as_long (val_args[i]);
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, current_substring, val);
|
||||
DIAGNOSTIC_POP
|
||||
break;
|
||||
}
|
||||
case long_arg:
|
||||
{
|
||||
long val = value_as_long (val_args[i]);
|
||||
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, current_substring, val);
|
||||
DIAGNOSTIC_POP
|
||||
break;
|
||||
}
|
||||
/* Handles floating-point values. */
|
||||
|
@ -2557,7 +2587,10 @@ ui_printf (const char *arg, struct ui_file *stream)
|
|||
have modified GCC to include -Wformat-security by
|
||||
default, which will warn here if there is no
|
||||
argument. */
|
||||
DIAGNOSTIC_PUSH
|
||||
DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
fprintf_filtered (stream, current_substring, 0);
|
||||
DIAGNOSTIC_POP
|
||||
break;
|
||||
default:
|
||||
internal_error (__FILE__, __LINE__,
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2018-09-05 Simon Marchi <simon.marchi@ericsson.com>
|
||||
|
||||
* diagnostics.h (DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL): New macro.
|
||||
|
||||
2018-08-31 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* elf/ppc64.h (R_PPC64_REL16_HIGH, R_PPC64_REL16_HIGHA),
|
||||
|
|
|
@ -59,6 +59,10 @@
|
|||
# define DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES \
|
||||
DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
|
||||
# endif
|
||||
|
||||
# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
|
||||
DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
|
||||
|
||||
#elif defined (__GNUC__) /* GCC */
|
||||
|
||||
# define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
|
||||
|
@ -66,6 +70,10 @@
|
|||
|
||||
# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
|
||||
DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
|
||||
|
||||
# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL \
|
||||
DIAGNOSTIC_IGNORE ("-Wformat-nonliteral")
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
|
||||
|
@ -92,4 +100,8 @@
|
|||
# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION
|
||||
#endif
|
||||
|
||||
#ifndef DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
# define DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
|
||||
#endif
|
||||
|
||||
#endif /* DIAGNOSTICS_H */
|
||||
|
|
Loading…
Reference in New Issue