On 05/26/2012 04:21 PM, Jason Merrill wrote:
I think I would rather fix stabilize_expr to handle void arguments properly: basically just stick the whole argument in *initp and return void_zero_node.
Ok. Like this it works, if I understand your suggestion.
Thanks, Paolo. ////////////////////
/cp 2012-05-26 Paolo Carlini <paolo.carl...@oracle.com> PR c++/53491 * tree.c (stabilize_expr): Handle exp of void type. /testsuite 2012-05-26 Paolo Carlini <paolo.carl...@oracle.com> PR c++/53491 * g++.dg/parse/crash60.C: New.
Index: testsuite/g++.dg/parse/crash60.C =================================================================== --- testsuite/g++.dg/parse/crash60.C (revision 0) +++ testsuite/g++.dg/parse/crash60.C (revision 0) @@ -0,0 +1,14 @@ +// PR c++/53491 + +struct M +{ + void pop(); +}; + +void foo() +{ + int result = 0; + M m; + + result += m.pop(); // { dg-error "invalid operands|in evaluation" } +} Index: cp/tree.c =================================================================== --- cp/tree.c (revision 187915) +++ cp/tree.c (working copy) @@ -3279,7 +3279,12 @@ stabilize_expr (tree exp, tree* initp) { tree init_expr; - if (!TREE_SIDE_EFFECTS (exp)) + if (VOID_TYPE_P (TREE_TYPE (exp))) + { + *initp = exp; + return void_zero_node; + } + else if (!TREE_SIDE_EFFECTS (exp)) init_expr = NULL_TREE; /* There are no expressions with REFERENCE_TYPE, but there can be call arguments with such a type; just treat it as a pointer. */