summaryrefslogtreecommitdiff
path: root/libcpp/init.c
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-12 19:43:25 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-12 19:43:25 +0000
commit2a6a6991c3901005b1f9b2809780c0e4655dd56b (patch)
treeb9bfc85db3cdd44094798b79ced86e5d51c66281 /libcpp/init.c
parent380c5f612a168b4a271b392ac16e202b4088c52d (diff)
downloadgcc-2a6a6991c3901005b1f9b2809780c0e4655dd56b.tar.gz
libcpp/:
* include/cpplib.h (struct cpp_options): Add warn_cxx_operator_names field. (NODE_WARN_OPERATOR): Define. (struct cpp_hashnode): Increase flags field to 10 bits, decrease type to 6 bits. * init.c (mark_named_operators): Add flags parameter. (cpp_post_options): Pick flags value to pass to mark_named_operators. * lex.c (lex_identifier): If NODE_WARN_OPERATOR is set, warn that identifier is an operator name in C++. gcc/: * fold-const.c (fold_unary): Rename local variable and to and_expr. * c-opts.c (c_common_handle_option): For -Wc++-compat set cpp_opts->warn_cxx_operator_names. gcc/testsuite/: * gcc.dg/Wcxx-compat-13.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148438 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/init.c')
-rw-r--r--libcpp/init.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libcpp/init.c b/libcpp/init.c
index 0f6f49f41da..e5be4e2b1b4 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -28,7 +28,7 @@ along with this program; see the file COPYING3. If not see
#include "localedir.h"
static void init_library (void);
-static void mark_named_operators (cpp_reader *);
+static void mark_named_operators (cpp_reader *, int);
static void read_original_filename (cpp_reader *);
static void read_original_directory (cpp_reader *);
static void post_options (cpp_reader *);
@@ -366,7 +366,7 @@ static const struct builtin_operator operator_array[] =
/* Mark the C++ named operators in the hash table. */
static void
-mark_named_operators (cpp_reader *pfile)
+mark_named_operators (cpp_reader *pfile, int flags)
{
const struct builtin_operator *b;
@@ -375,7 +375,7 @@ mark_named_operators (cpp_reader *pfile)
b++)
{
cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
- hp->flags |= NODE_OPERATOR;
+ hp->flags |= flags;
hp->is_directive = 0;
hp->directive_index = b->value;
}
@@ -512,13 +512,20 @@ static void sanity_checks (cpp_reader *pfile)
void
cpp_post_options (cpp_reader *pfile)
{
+ int flags;
+
sanity_checks (pfile);
post_options (pfile);
/* Mark named operators before handling command line macros. */
+ flags = 0;
if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
- mark_named_operators (pfile);
+ flags |= NODE_OPERATOR;
+ if (CPP_OPTION (pfile, warn_cxx_operator_names))
+ flags |= NODE_DIAGNOSTIC | NODE_WARN_OPERATOR;
+ if (flags != 0)
+ mark_named_operators (pfile, flags);
}
/* Setup for processing input from the file named FNAME, or stdin if