Do not warn about unused macros while processing #pragma GCC optimize
libcpp PR c++/91318 * include/cpplib.h: Added cpp_define_unused(), cpp_define_formatted_unused() * directives.c: Likewise. gcc/c-family PR c++/91318 * c-cppbuiltin.c: c_cpp_builtins_optimize_pragma(): use cpp_define_unused()
This commit is contained in:
parent
e7e0eeeb6e
commit
6f1ae1ecd3
|
@ -581,41 +581,41 @@ c_cpp_builtins_optimize_pragma (cpp_reader *pfile, tree prev_tree,
|
||||||
/* Other target-independent built-ins determined by command-line
|
/* Other target-independent built-ins determined by command-line
|
||||||
options. */
|
options. */
|
||||||
if (!prev->x_optimize_size && cur->x_optimize_size)
|
if (!prev->x_optimize_size && cur->x_optimize_size)
|
||||||
cpp_define (pfile, "__OPTIMIZE_SIZE__");
|
cpp_define_unused (pfile, "__OPTIMIZE_SIZE__");
|
||||||
else if (prev->x_optimize_size && !cur->x_optimize_size)
|
else if (prev->x_optimize_size && !cur->x_optimize_size)
|
||||||
cpp_undef (pfile, "__OPTIMIZE_SIZE__");
|
cpp_undef (pfile, "__OPTIMIZE_SIZE__");
|
||||||
|
|
||||||
if (!prev->x_optimize && cur->x_optimize)
|
if (!prev->x_optimize && cur->x_optimize)
|
||||||
cpp_define (pfile, "__OPTIMIZE__");
|
cpp_define_unused (pfile, "__OPTIMIZE__");
|
||||||
else if (prev->x_optimize && !cur->x_optimize)
|
else if (prev->x_optimize && !cur->x_optimize)
|
||||||
cpp_undef (pfile, "__OPTIMIZE__");
|
cpp_undef (pfile, "__OPTIMIZE__");
|
||||||
|
|
||||||
prev_fast_math = fast_math_flags_struct_set_p (prev);
|
prev_fast_math = fast_math_flags_struct_set_p (prev);
|
||||||
cur_fast_math = fast_math_flags_struct_set_p (cur);
|
cur_fast_math = fast_math_flags_struct_set_p (cur);
|
||||||
if (!prev_fast_math && cur_fast_math)
|
if (!prev_fast_math && cur_fast_math)
|
||||||
cpp_define (pfile, "__FAST_MATH__");
|
cpp_define_unused (pfile, "__FAST_MATH__");
|
||||||
else if (prev_fast_math && !cur_fast_math)
|
else if (prev_fast_math && !cur_fast_math)
|
||||||
cpp_undef (pfile, "__FAST_MATH__");
|
cpp_undef (pfile, "__FAST_MATH__");
|
||||||
|
|
||||||
if (!prev->x_flag_signaling_nans && cur->x_flag_signaling_nans)
|
if (!prev->x_flag_signaling_nans && cur->x_flag_signaling_nans)
|
||||||
cpp_define (pfile, "__SUPPORT_SNAN__");
|
cpp_define_unused (pfile, "__SUPPORT_SNAN__");
|
||||||
else if (prev->x_flag_signaling_nans && !cur->x_flag_signaling_nans)
|
else if (prev->x_flag_signaling_nans && !cur->x_flag_signaling_nans)
|
||||||
cpp_undef (pfile, "__SUPPORT_SNAN__");
|
cpp_undef (pfile, "__SUPPORT_SNAN__");
|
||||||
|
|
||||||
if (!prev->x_flag_errno_math && cur->x_flag_errno_math)
|
if (!prev->x_flag_errno_math && cur->x_flag_errno_math)
|
||||||
cpp_undef (pfile, "__NO_MATH_ERRNO__");
|
cpp_undef (pfile, "__NO_MATH_ERRNO__");
|
||||||
else if (prev->x_flag_errno_math && !cur->x_flag_errno_math)
|
else if (prev->x_flag_errno_math && !cur->x_flag_errno_math)
|
||||||
cpp_define (pfile, "__NO_MATH_ERRNO__");
|
cpp_define_unused (pfile, "__NO_MATH_ERRNO__");
|
||||||
|
|
||||||
if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)
|
if (!prev->x_flag_finite_math_only && cur->x_flag_finite_math_only)
|
||||||
{
|
{
|
||||||
cpp_undef (pfile, "__FINITE_MATH_ONLY__");
|
cpp_undef (pfile, "__FINITE_MATH_ONLY__");
|
||||||
cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
|
cpp_define_unused (pfile, "__FINITE_MATH_ONLY__=1");
|
||||||
}
|
}
|
||||||
else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only)
|
else if (prev->x_flag_finite_math_only && !cur->x_flag_finite_math_only)
|
||||||
{
|
{
|
||||||
cpp_undef (pfile, "__FINITE_MATH_ONLY__");
|
cpp_undef (pfile, "__FINITE_MATH_ONLY__");
|
||||||
cpp_define (pfile, "__FINITE_MATH_ONLY__=0");
|
cpp_define_unused (pfile, "__FINITE_MATH_ONLY__=0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2412,6 +2412,15 @@ cpp_define (cpp_reader *pfile, const char *str)
|
||||||
run_directive (pfile, T_DEFINE, buf, count);
|
run_directive (pfile, T_DEFINE, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Like cpp_define, but does not warn about unused macro. */
|
||||||
|
void
|
||||||
|
cpp_define_unused (cpp_reader *pfile, const char *str)
|
||||||
|
{
|
||||||
|
unsigned char warn_unused_macros = CPP_OPTION (pfile, warn_unused_macros);
|
||||||
|
CPP_OPTION (pfile, warn_unused_macros) = 0;
|
||||||
|
cpp_define (pfile, str);
|
||||||
|
CPP_OPTION (pfile, warn_unused_macros) = warn_unused_macros;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use to build macros to be run through cpp_define() as
|
/* Use to build macros to be run through cpp_define() as
|
||||||
described above.
|
described above.
|
||||||
|
@ -2431,6 +2440,20 @@ cpp_define_formatted (cpp_reader *pfile, const char *fmt, ...)
|
||||||
free (ptr);
|
free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Like cpp_define_formatted, but does not warn about unused macro. */
|
||||||
|
void
|
||||||
|
cpp_define_formatted_unused (cpp_reader *pfile, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start (ap, fmt);
|
||||||
|
ptr = xvasprintf (fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
|
||||||
|
cpp_define_unused (pfile, ptr);
|
||||||
|
free (ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Slight variant of the above for use by initialize_builtins. */
|
/* Slight variant of the above for use by initialize_builtins. */
|
||||||
void
|
void
|
||||||
|
|
|
@ -1076,8 +1076,12 @@ extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
|
||||||
/* Used to register macros and assertions, perhaps from the command line.
|
/* Used to register macros and assertions, perhaps from the command line.
|
||||||
The text is the same as the command line argument. */
|
The text is the same as the command line argument. */
|
||||||
extern void cpp_define (cpp_reader *, const char *);
|
extern void cpp_define (cpp_reader *, const char *);
|
||||||
|
extern void cpp_define_unused (cpp_reader *, const char *);
|
||||||
extern void cpp_define_formatted (cpp_reader *pfile,
|
extern void cpp_define_formatted (cpp_reader *pfile,
|
||||||
const char *fmt, ...) ATTRIBUTE_PRINTF_2;
|
const char *fmt, ...) ATTRIBUTE_PRINTF_2;
|
||||||
|
extern void cpp_define_formatted_unused (cpp_reader *pfile,
|
||||||
|
const char *fmt,
|
||||||
|
...) ATTRIBUTE_PRINTF_2;
|
||||||
extern void cpp_assert (cpp_reader *, const char *);
|
extern void cpp_assert (cpp_reader *, const char *);
|
||||||
extern void cpp_undef (cpp_reader *, const char *);
|
extern void cpp_undef (cpp_reader *, const char *);
|
||||||
extern void cpp_unassert (cpp_reader *, const char *);
|
extern void cpp_unassert (cpp_reader *, const char *);
|
||||||
|
|
Loading…
Reference in New Issue