gcc/cp/ChangeLog:
PR c++/36408
* cp-tree.h (empty_expr_stmt_p): Declare ...
* semantics.c (empty_expr_stmt_p): ... this.
* pt.c (tsubst_copy_and_build) <STMT_EXPR>: Use it.
gcc/testsuite/ChangeLog:
PR c++/36408
* g++.dg/template/stmtexpr2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154731
138bc75d-0d04-0410-961f-
82ee72b054a4
+2009-11-28 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/36408
+ * cp-tree.h (empty_expr_stmt_p): Declare ...
+ * semantics.c (empty_expr_stmt_p): ... this.
+ * pt.c (tsubst_copy_and_build) <STMT_EXPR>: Use it.
+
2009-11-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/38656
extern tree finish_stmt_expr_expr (tree, tree);
extern tree finish_stmt_expr (tree, bool);
extern tree stmt_expr_value_expr (tree);
+bool empty_expr_stmt_p (tree);
extern tree perform_koenig_lookup (tree, VEC(tree,gc) *);
extern tree finish_call_expr (tree, VEC(tree,gc) **, bool,
bool, tsubst_flags_t);
stmt_expr = finish_stmt_expr (stmt_expr, false);
cur_stmt_expr = old_stmt_expr;
+ /* If the resulting list of expression statement is empty,
+ fold it further into void_zero_node. */
+ if (empty_expr_stmt_p (cur_stmt_expr))
+ cur_stmt_expr = void_zero_node;
+
return stmt_expr;
}
return t;
}
+/* Return TRUE iff EXPR_STMT is an empty list of
+ expression statements. */
+
+bool
+empty_expr_stmt_p (tree expr_stmt)
+{
+ tree body = NULL_TREE;
+
+ if (expr_stmt)
+ {
+ if (TREE_CODE (expr_stmt) == EXPR_STMT)
+ body = EXPR_STMT_EXPR (expr_stmt);
+ else if (TREE_CODE (expr_stmt) == STATEMENT_LIST)
+ body = expr_stmt;
+ }
+
+ if (body)
+ {
+ if (TREE_CODE (body) == STATEMENT_LIST)
+ return tsi_end_p (tsi_start (body));
+ else
+ return empty_expr_stmt_p (body);
+ }
+ return false;
+}
+
/* Perform Koenig lookup. FN is the postfix-expression representing
the function (or functions) to call; ARGS are the arguments to the
call. Returns the functions to be considered by overload
+2009-11-28 Dodji Seketeli <dodji@redhat.com>
+
+ PR c++/36408
+ * g++.dg/template/stmtexpr2.C: New test.
+
2009-11-28 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42183
--- /dev/null
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin: PR c++/36408
+// { dg-options "" }
+// { dg-do compile }
+
+template<int>
+void
+foo()
+{
+ int i = ({ }); // { dg-error "void value not ignored" }
+}
+
+template<int>
+void
+bar()
+{
+ int i = ({ ({}); }); // { dg-error "void value not ignored" }
+}
+
+int
+main ()
+{
+ foo<0> ();
+ bar<0> ();
+}
+