PR c++/11945
* pt.c (build_non_dependent_expr): Look inside COND_EXPR and
COMPOUND_EXPR.
* semantics.c (finish_expr_stmt): Always convert to void.
* typeck.c (build_x_compound_exp): Always convert to void.
testsuite:
PR c++/11945
* g++.dg/warn/noeffect2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70606
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-08-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/11945
+ * pt.c (build_non_dependent_expr): Look inside COND_EXPR and
+ COMPOUND_EXPR.
+ * semantics.c (finish_expr_stmt): Always convert to void.
+ * typeck.c (build_x_compound_exp): Always convert to void.
+
2003-08-19 Mark Mitchell <mark@codesourcery.com>
PR c++/11684
types. */
if (TREE_CODE (expr) == OVERLOAD)
return expr;
+
+ if (TREE_CODE (expr) == COND_EXPR)
+ return build (COND_EXPR,
+ TREE_TYPE (expr),
+ TREE_OPERAND (expr, 0),
+ build_non_dependent_expr (TREE_OPERAND (expr, 1)),
+ build_non_dependent_expr (TREE_OPERAND (expr, 2)));
+ if (TREE_CODE (expr) == COMPOUND_EXPR)
+ return build (COMPOUND_EXPR,
+ TREE_TYPE (expr),
+ TREE_OPERAND (expr, 0),
+ build_non_dependent_expr (TREE_OPERAND (expr, 1)));
+
/* Otherwise, build a NON_DEPENDENT_EXPR.
REFERENCE_TYPEs are not stripped for expressions in templates
{
if (!processing_template_decl)
expr = convert_to_void (expr, "statement");
+ else if (!type_dependent_expression_p (expr))
+ convert_to_void (build_non_dependent_expr (expr), "statement");
r = add_stmt (build_stmt (EXPR_STMT, expr));
}
tree
build_compound_expr (tree lhs, tree rhs)
{
- if (!processing_template_decl)
- {
- lhs = decl_constant_value (lhs);
- lhs = convert_to_void (lhs, "left-hand operand of comma");
- }
+ lhs = decl_constant_value (lhs);
+ lhs = convert_to_void (lhs, "left-hand operand of comma");
if (lhs == error_mark_node || rhs == error_mark_node)
return error_mark_node;
+2003-08-20 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/11945
+ * g++.dg/warn/noeffect2.C: New test.
+
2003-08-19 Mark Mitchell <mark@codesourcery.com>
PR c++/10926
2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/11957
+ * g++.dg/warn/noeffect1.C: New test.
+
* g++.dg/template/scope2.C: New test.
* g++.dg/template/error2.C: Correct dg-error
--- /dev/null
+// { dg-do compile }
+// { dg-options "-Wall" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 18 Aug 2003 <nathan@codesourcery.com>
+// Origin PR 11945 gerald@pfeifer.com
+
+// PR 11945 inconsistent warnings
+
+extern "C" void FormatDisk();
+ template <class T>
+ struct C {
+ C(){ FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
+ };
+ template <class T>
+ void f() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
+void g() { FormatDisk(), 0; } // { dg-warning "right-hand operand of comma" "" }
+