re PR c++/5373 (Statement expressions broken in C++)
authorMark Mitchell <mark@codesourcery.com>
Sat, 13 Apr 2002 07:10:12 +0000 (07:10 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sat, 13 Apr 2002 07:10:12 +0000 (07:10 +0000)
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

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/stmtexpr1.C [new file with mode: 0644]

index ca9251a..e615310 100644 (file)
@@ -1,5 +1,11 @@
 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.
        * call.c (add_template_candidate_real): Do not treat member
        templates as copy constructors.
index fb6e182..f53ac28 100644 (file)
@@ -203,6 +203,7 @@ finish_expr_stmt (expr)
      tree expr;
 {
   tree r = NULL_TREE;
+  tree expr_type = NULL_TREE;;
 
   if (expr != NULL_TREE)
     {
@@ -213,6 +214,9 @@ finish_expr_stmt (expr)
              || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
        expr = default_conversion (expr);
       
+      /* Remember the type of the expression.  */
+      expr_type = TREE_TYPE (expr);
+
       if (stmts_are_full_exprs_p ())
        expr = convert_to_void (expr, "statement");
       
@@ -223,7 +227,7 @@ finish_expr_stmt (expr)
 
   /* This was an expression-statement, so we save the type of the
      expression.  */
-  last_expr_type = expr ? TREE_TYPE (expr) : NULL_TREE;
+  last_expr_type = expr_type;
 
   return r;
 }
index b04b99b..d3391f0 100644 (file)
@@ -1,8 +1,10 @@
 2002-04-12  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++ 5373.
+       * g++.dg/parse/stmtexpr1.C: New test.
+
        PR c++/5189.
-       * call.c (add_template_candidate_real): Do not treat member
-       templates as copy constructors.
+       * g++.dg/template/copy1.C: New test.
 
 2002-04-12  Richard Henderson  <rth@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/parse/stmtexpr1.C b/gcc/testsuite/g++.dg/parse/stmtexpr1.C
new file mode 100644 (file)
index 0000000..4455398
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile }
+// { dg-options "" }
+
+int
+main (int argc, char **argv)
+{
+  int a = ({ 1 ? 0 : 1; });
+  return ({ argc > 1 ? 1 : 0; });
+}