aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2008-08-27 16:06:00 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2008-08-27 16:06:00 +0000
commitd4033c81042ca6e288013027c4662734694aaa0c (patch)
treebd56272d2aa361afef5fa56a4f3eb69385986665 /gcc/cp
parentf5d09f36347c9c1c13c94db2ffa06df3388431a6 (diff)
downloadgcc-d4033c81042ca6e288013027c4662734694aaa0c.zip
gcc-d4033c81042ca6e288013027c4662734694aaa0c.tar.gz
gcc-d4033c81042ca6e288013027c4662734694aaa0c.tar.bz2
re PR c++/17880 (-Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.)
2008-08-27 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/17880 cp/ * semantics.c (maybe_convert_cond): Call verify_sequence_points. (finish_return_stmt): Likewise. (finish_switch_condition): Likewise. testsuite/ * g++.dg/warn/sequence-pt-1.C: New. * g++.dg/warn/sequence-pt-pr17880.C: New. From-SVN: r139625
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/semantics.c12
2 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b106fa5..7d2266c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2008-08-27 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+ PR c++/17880
+ * semantics.c (maybe_convert_cond): Call verify_sequence_points.
+ (finish_return_stmt): Likewise.
+ (finish_switch_condition): Likewise.
+
+2008-08-27 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
* cp-tree.h: Fix #error directive.
2008-08-26 Douglas Gregor <doug.gregor@gmail.com>
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index c7565a0..e044a43 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -572,7 +572,8 @@ finish_goto_stmt (tree destination)
}
/* COND is the condition-expression for an if, while, etc.,
- statement. Convert it to a boolean value, if appropriate. */
+ statement. Convert it to a boolean value, if appropriate.
+ In addition, verify sequence points if -Wsequence-point is enabled. */
static tree
maybe_convert_cond (tree cond)
@@ -585,6 +586,9 @@ maybe_convert_cond (tree cond)
if (processing_template_decl)
return cond;
+ if (warn_sequence_point)
+ verify_sequence_points (cond);
+
/* Do the conversion. */
cond = convert_from_reference (cond);
@@ -790,6 +794,9 @@ finish_return_stmt (tree expr)
return error_mark_node;
if (!processing_template_decl)
{
+ if (warn_sequence_point)
+ verify_sequence_points (expr);
+
if (DECL_DESTRUCTOR_P (current_function_decl)
|| (DECL_CONSTRUCTOR_P (current_function_decl)
&& targetm.cxx.cdtor_returns_this ()))
@@ -978,6 +985,9 @@ finish_switch_cond (tree cond, tree switch_stmt)
}
if (check_for_bare_parameter_packs (cond))
cond = error_mark_node;
+ else if (!processing_template_decl && warn_sequence_point)
+ verify_sequence_points (cond);
+
finish_cond (&SWITCH_STMT_COND (switch_stmt), cond);
SWITCH_STMT_TYPE (switch_stmt) = orig_type;
add_stmt (switch_stmt);