mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 23:25:24 +02:00
system.h (HAVE_DESIGNATED_INITIALIZERS, [...]): Do not use "defined" in macros.
gcc: 2016-11-23 Paolo Bonzini <bonzini@gnu.org> * system.h (HAVE_DESIGNATED_INITIALIZERS, HAVE_DESIGNATED_UNION_INITIALIZERS): Do not use "defined" in macros. * doc/cpp.texi (Defined): Mention -Wexpansion-to-defined. * doc/cppopts.texi (Invocation): Document -Wexpansion-to-defined. * doc/invoke.texi (Warning Options): Document -Wexpansion-to-defined. gcc/c-family: 2016-11-23 Paolo Bonzini <bonzini@gnu.org> * c.opt (Wexpansion-to-defined): New. gcc/testsuite: 2016-11-23 Paolo Bonzini <bonzini@gnu.org> * gcc.dg/cpp/defined.c: Mark newly introduced warnings and adjust for warning->pedwarn change. * gcc.dg/cpp/defined-syshdr.c, gcc.dg/cpp/defined-Wexpansion-to-defined.c, gcc.dg/cpp/defined-Wextra-Wno-expansion-to-defined.c, gcc.dg/cpp/defined-Wextra.c, gcc.dg/cpp/defined-Wno-expansion-to-defined.c: New testcases. libcpp: 2016-11-23 Paolo Bonzini <bonzini@gnu.org> * include/cpplib.h (struct cpp_options): Add new member warn_expansion_to_defined. (CPP_W_EXPANSION_TO_DEFINED): New enum member. * expr.c (parse_defined): Warn for all uses of "defined" in macros, and tie warning to CPP_W_EXPANSION_TO_DEFINED. Make it a pedwarning instead of a warning. * system.h (HAVE_DESIGNATED_INITIALIZERS): Do not use "defined" in macros. From-SVN: r242743
This commit is contained in:
committed by
Paolo Bonzini
parent
baf53c4739
commit
fb2675cb46
@@ -1,3 +1,14 @@
|
||||
2016-11-23 Paolo Bonzini <bonzini@gnu.org>
|
||||
|
||||
* include/cpplib.h (struct cpp_options): Add new member
|
||||
warn_expansion_to_defined.
|
||||
(CPP_W_EXPANSION_TO_DEFINED): New enum member.
|
||||
* expr.c (parse_defined): Warn for all uses of "defined"
|
||||
in macros, and tie warning to CPP_W_EXPANSION_TO_DEFINED.
|
||||
Make it a pedwarning instead of a warning.
|
||||
* system.h (HAVE_DESIGNATED_INITIALIZERS): Do not use
|
||||
"defined" in macros.
|
||||
|
||||
2016-11-17 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* charset.c (cpp_interpret_string_1): Skip locations from
|
||||
|
||||
@@ -1031,9 +1031,11 @@ parse_defined (cpp_reader *pfile)
|
||||
|
||||
if (node)
|
||||
{
|
||||
if (pfile->context != initial_context && CPP_PEDANTIC (pfile))
|
||||
cpp_error (pfile, CPP_DL_WARNING,
|
||||
"this use of \"defined\" may not be portable");
|
||||
if ((pfile->context != initial_context
|
||||
|| initial_context != &pfile->base_context)
|
||||
&& CPP_OPTION (pfile, warn_expansion_to_defined))
|
||||
cpp_pedwarning (pfile, CPP_W_EXPANSION_TO_DEFINED,
|
||||
"this use of \"defined\" may not be portable");
|
||||
|
||||
_cpp_mark_macro_used (node);
|
||||
if (!(node->flags & NODE_USED))
|
||||
|
||||
@@ -415,6 +415,10 @@ struct cpp_options
|
||||
/* Nonzero means warn if undefined identifiers are evaluated in an #if. */
|
||||
unsigned char warn_undef;
|
||||
|
||||
/* Nonzero means warn if "defined" is encountered in a place other than
|
||||
an #if. */
|
||||
unsigned char warn_expansion_to_defined;
|
||||
|
||||
/* Nonzero means warn of unused macros from the main file. */
|
||||
unsigned char warn_unused_macros;
|
||||
|
||||
@@ -1040,7 +1044,8 @@ enum {
|
||||
CPP_W_DATE_TIME,
|
||||
CPP_W_PEDANTIC,
|
||||
CPP_W_C90_C99_COMPAT,
|
||||
CPP_W_CXX11_COMPAT
|
||||
CPP_W_CXX11_COMPAT,
|
||||
CPP_W_EXPANSION_TO_DEFINED
|
||||
};
|
||||
|
||||
/* Output a diagnostic of some kind. */
|
||||
|
||||
@@ -375,9 +375,12 @@ extern void abort (void);
|
||||
??? C99 designated initializers are not supported by most C++
|
||||
compilers, including G++. -- gdr, 2005-05-18 */
|
||||
#if !defined(HAVE_DESIGNATED_INITIALIZERS)
|
||||
#ifdef __cplusplus
|
||||
#define HAVE_DESIGNATED_INITIALIZERS 0
|
||||
#else
|
||||
#define HAVE_DESIGNATED_INITIALIZERS \
|
||||
(!defined(__cplusplus) \
|
||||
&& ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)))
|
||||
((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
|
||||
Reference in New Issue
Block a user