aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2009-06-12 19:43:25 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2009-06-12 19:43:25 +0000
commit3d8b2a98ca3c4d46030c839ad89ed7f3800a9fbf (patch)
treeb9bfc85db3cdd44094798b79ced86e5d51c66281 /gcc
parent737142ced7510afcd0144c866d9169ac7cbf3fb6 (diff)
downloadgcc-3d8b2a98ca3c4d46030c839ad89ed7f3800a9fbf.zip
gcc-3d8b2a98ca3c4d46030c839ad89ed7f3800a9fbf.tar.gz
gcc-3d8b2a98ca3c4d46030c839ad89ed7f3800a9fbf.tar.bz2
cpplib.h (struct cpp_options): Add warn_cxx_operator_names field.
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. From-SVN: r148438
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-opts.c1
-rw-r--r--gcc/fold-const.c9
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/Wcxx-compat-13.c26
5 files changed, 44 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2e8f5eb..d8c08aa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2009-06-12 Ian Lance Taylor <iant@google.com>
+
+ * 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.
+
2009-06-12 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR tree-opt/38865
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index df6fdad..0050ab5 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -445,6 +445,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
implies -Wenum-compare. */
if (warn_enum_compare == -1 && value)
warn_enum_compare = value;
+ cpp_opts->warn_cxx_operator_names = value;
break;
case OPT_Wdeprecated:
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ab3942f..433ec60 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8290,13 +8290,14 @@ fold_unary (enum tree_code code, tree type, tree op0)
&& TREE_CODE (op0) == BIT_AND_EXPR
&& TREE_CODE (TREE_OPERAND (op0, 1)) == INTEGER_CST)
{
- tree and = op0;
- tree and0 = TREE_OPERAND (and, 0), and1 = TREE_OPERAND (and, 1);
+ tree and_expr = op0;
+ tree and0 = TREE_OPERAND (and_expr, 0);
+ tree and1 = TREE_OPERAND (and_expr, 1);
int change = 0;
- if (TYPE_UNSIGNED (TREE_TYPE (and))
+ if (TYPE_UNSIGNED (TREE_TYPE (and_expr))
|| (TYPE_PRECISION (type)
- <= TYPE_PRECISION (TREE_TYPE (and))))
+ <= TYPE_PRECISION (TREE_TYPE (and_expr))))
change = 1;
else if (TYPE_PRECISION (TREE_TYPE (and1))
<= HOST_BITS_PER_WIDE_INT
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8c21893..8904945 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-12 Ian Lance Taylor <iant@google.com>
+
+ * gcc.dg/Wcxx-compat-13.c: New testcase.
+
2009-06-12 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR tree-opt/38865
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-13.c b/gcc/testsuite/gcc.dg/Wcxx-compat-13.c
new file mode 100644
index 0000000..1882396
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wcxx-compat-13.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+int and; /* { dg-warning "operator" } */
+int and_eq; /* { dg-warning "operator" } */
+int bitand; /* { dg-warning "operator" } */
+int bitor; /* { dg-warning "operator" } */
+int compl; /* { dg-warning "operator" } */
+int not; /* { dg-warning "operator" } */
+int not_eq; /* { dg-warning "operator" } */
+int or; /* { dg-warning "operator" } */
+int or_eq; /* { dg-warning "operator" } */
+int xor; /* { dg-warning "operator" } */
+int xor_eq; /* { dg-warning "operator" } */
+
+#define M1 and /* { dg-warning "operator" } */
+#define M2 and_eq /* { dg-warning "operator" } */
+#define M3 bitand /* { dg-warning "operator" } */
+#define M4 bitor /* { dg-warning "operator" } */
+#define M5 compl /* { dg-warning "operator" } */
+#define M6 not /* { dg-warning "operator" } */
+#define M7 not_eq /* { dg-warning "operator" } */
+#define M8 or /* { dg-warning "operator" } */
+#define M9 or_eq /* { dg-warning "operator" } */
+#define M10 xor /* { dg-warning "operator" } */
+#define M11 xor_eq /* { dg-warning "operator" } */