Commit 0481bc21 by Mark Mitchell Committed by Mark Mitchell

re PR c++/5373 (Statement expressions broken in C++)

	PR c++ 5373.
	* g++.dg/parse/stmtexpr1.C: New test.

	PR c++/5373.
	* semantics.c (finish_expr_stmt): Remember the type of the
	expression before any conversions are performed.

From-SVN: r52264
parent 1d405c5e
2002-04-12 Mark Mitchell <mark@codesourcery.com> 2002-04-12 Mark Mitchell <mark@codesourcery.com>
PR c++/5373.
* semantics.c (finish_expr_stmt): Remember the type of the
expression before any conversions are performed.
2002-04-12 Mark Mitchell <mark@codesourcery.com>
PR c++/5189. PR c++/5189.
* call.c (add_template_candidate_real): Do not treat member * call.c (add_template_candidate_real): Do not treat member
templates as copy constructors. templates as copy constructors.
......
...@@ -203,6 +203,7 @@ finish_expr_stmt (expr) ...@@ -203,6 +203,7 @@ finish_expr_stmt (expr)
tree expr; tree expr;
{ {
tree r = NULL_TREE; tree r = NULL_TREE;
tree expr_type = NULL_TREE;;
if (expr != NULL_TREE) if (expr != NULL_TREE)
{ {
...@@ -213,6 +214,9 @@ finish_expr_stmt (expr) ...@@ -213,6 +214,9 @@ finish_expr_stmt (expr)
|| TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)) || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
expr = default_conversion (expr); expr = default_conversion (expr);
/* Remember the type of the expression. */
expr_type = TREE_TYPE (expr);
if (stmts_are_full_exprs_p ()) if (stmts_are_full_exprs_p ())
expr = convert_to_void (expr, "statement"); expr = convert_to_void (expr, "statement");
...@@ -223,7 +227,7 @@ finish_expr_stmt (expr) ...@@ -223,7 +227,7 @@ finish_expr_stmt (expr)
/* This was an expression-statement, so we save the type of the /* This was an expression-statement, so we save the type of the
expression. */ expression. */
last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE; last_expr_type = expr_type;
return r; return r;
} }
......
2002-04-12 Mark Mitchell <mark@codesourcery.com> 2002-04-12 Mark Mitchell <mark@codesourcery.com>
PR c++ 5373.
* g++.dg/parse/stmtexpr1.C: New test.
PR c++/5189. PR c++/5189.
* call.c (add_template_candidate_real): Do not treat member * g++.dg/template/copy1.C: New test.
templates as copy constructors.
2002-04-12 Richard Henderson <rth@redhat.com> 2002-04-12 Richard Henderson <rth@redhat.com>
......
// { dg-do compile }
// { dg-options "" }
int
main (int argc, char **argv)
{
int a = ({ 1 ? 0 : 1; });
return ({ argc > 1 ? 1 : 0; });
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment