From: "Andrew Pinski" <pinskia@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix middle-end/32813 ICE in annotate_all_with_locus
Date: Sat, 04 Aug 2007 11:41:00 -0000 [thread overview]
Message-ID: <de8d50360708040441v3724cc9bkb01ba5e177c43a9d@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
Hi,
The fortran front-end calls annotate_all_with_locus with a statement
list which included coumpound statement which was generated by fold
and annotate_all_with_locus does not like the compound expression at
all. The compound expression was generated when fold was folding
COND_EXPR<SAVE_EXPR, EMPTY_STMT, EMPTY_STMT> and decided it needed to
keep around the SAVE_EXPR (which is correct). Since we really don't
need to generate a compound expression here, I changed
omit_one_operand and pedantic_omit_one_operand for this case to just
return a cast to void type of the ommited expression.
I also had to fix up gfortran.fortran-torture/compile to run through
all the options instead of just -O.
OK? Bootstrapped and tested on i686-apple-darwin8.10 with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* fold-const.c (omit_one_operand): Return only the ommitted expression
if the result is an empty statement.
(pedantic_omit_one_operand): Likewise.
* gfortran.fortran-torture/compile/emptyif-1.f90: New test.
* lib/fortran-torture.exp (fortran-torture): Use TORTURE_OPTIONS instead
of just -O.
[-- Attachment #2: fixpr32813.diff.txt --]
[-- Type: text/plain, Size: 2280 bytes --]
Index: fold-const.c
===================================================================
--- fold-const.c (revision 127204)
+++ fold-const.c (working copy)
@@ -3277,6 +3277,11 @@ omit_one_operand (tree type, tree result
{
tree t = fold_convert (type, result);
+ /* If the resulting operand is an empty statement, just return the ommited
+ statement casted to void. */
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
@@ -3290,6 +3295,11 @@ pedantic_omit_one_operand (tree type, tr
{
tree t = fold_convert (type, result);
+ /* If the resulting operand is an empty statement, just return the ommited
+ statement casted to void. */
+ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted))
+ return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted));
+
if (TREE_SIDE_EFFECTS (omitted))
return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t);
Index: testsuite/gfortran.fortran-torture/compile/emptyif-1.f90
===================================================================
--- testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 (revision 0)
+++ testsuite/gfortran.fortran-torture/compile/emptyif-1.f90 (revision 0)
@@ -0,0 +1,10 @@
+program emptyif
+
+ implicit none
+ integer i,K(4)
+
+ if (K(i)==0) then
+ ! do absolutely nothing
+ end if
+
+end program
Index: testsuite/lib/fortran-torture.exp
===================================================================
--- testsuite/lib/fortran-torture.exp (revision 127204)
+++ testsuite/lib/fortran-torture.exp (working copy)
@@ -347,6 +347,7 @@ proc search_for_re { file pattern } {
proc fortran-torture { args } {
global srcdir subdir
global compiler_conditional_xfail_data
+ global TORTURE_OPTIONS
set src [lindex $args 0]
if { [llength $args] > 1 } {
@@ -371,7 +372,7 @@ proc fortran-torture { args } {
}
# loop through all the options
- set option_list [list { "-O" } ]
+ set option_list $TORTURE_OPTIONS
foreach option $option_list {
# torture_compile_xfail is set by the .x script (if present)
next reply other threads:[~2007-08-04 11:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-04 11:41 Andrew Pinski [this message]
2007-08-08 0:39 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=de8d50360708040441v3724cc9bkb01ba5e177c43a9d@mail.gmail.com \
--to=pinskia@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).