diff options
author | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-13 17:18:16 +0000 |
---|---|---|
committer | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-13 17:18:16 +0000 |
commit | 1b660ce9c6728305e41bf599f1934380dd6f0816 (patch) | |
tree | ec81a075ec22d3d04595189790e1a9ae9f6d0a6f | |
parent | 6ee2b510a4a1bec41601526bac33b94ea0e84bef (diff) | |
download | gcc-1b660ce9c6728305e41bf599f1934380dd6f0816.tar.gz |
2004-10-13 Andrew Pinski <pinskia@physics.uc.edu>
PR c++/17661
* testsuite/g++.dg/expr/for2.C: New test.
2004-10-13 Andrew Pinski <pinskia@physics.uc.edu>
PR c++/17661
* semantics.c (finish_for_expr): Convert expression to void
so that we don't create temporaries for a?b:c.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88992 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/for2.C | 15 |
4 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e488ee1bf1..270a4ebe2bd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-10-13 Andrew Pinski <pinskia@physics.uc.edu> + + PR c++/17661 + * semantics.c (finish_for_expr): Convert expression to void + so that we don't create temporaries for a?b:c. + 2004-10-13 Kazu Hirata <kazu@cs.umass.edu> * search.c: Fix a comment typo. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a4177856210..8a9cd42beaa 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -798,6 +798,14 @@ finish_for_expr (tree expr, tree for_stmt) cxx_incomplete_type_error (expr, TREE_TYPE (expr)); expr = error_mark_node; } + if (!processing_template_decl) + { + if (warn_sequence_point) + verify_sequence_points (expr); + expr = convert_to_void (expr, "3rd expression in for"); + } + else if (!type_dependent_expression_p (expr)) + convert_to_void (build_non_dependent_expr (expr), "3rd expression in for"); expr = maybe_cleanup_point_expr_void (expr); FOR_EXPR (for_stmt) = expr; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a87db9ace56..a861780a52b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-13 Andrew Pinski <pinskia@physics.uc.edu> + + PR c++/17661 + * testsuite/g++.dg/expr/for2.C: New test. + 2004-10-13 Eric Botcazou <ebotcazou@libertysurf.fr> * g++.dg/inherit/thunk1.C: Run on the SPARC. diff --git a/gcc/testsuite/g++.dg/expr/for2.C b/gcc/testsuite/g++.dg/expr/for2.C new file mode 100644 index 00000000000..52f76964179 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/for2.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// PR c++/17661 +// We used to try to create a temprary for the condition +// expression in the for which was wrong. + + +struct C +{ + C (const C &x); +}; +C &f(); +void breakme (C j, bool k) +{ + for (;; k ? j : f()) ; +} |