Bug 41827 - [Cleanup] Remove SET_EXPR_LOCATION in gfc_trans_code
Summary: [Cleanup] Remove SET_EXPR_LOCATION in gfc_trans_code
Status: SUSPENDED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2009-10-26 09:27 UTC by janus
Modified: 2021-02-12 09:41 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-06-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-10-26 09:27:38 UTC
At the end of gfc_trans_code one finds the following:


      gfc_set_backend_locus (&code->loc);

      if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
	{
	  if (TREE_CODE (res) != STATEMENT_LIST)
	    SET_EXPR_LOCATION (res, input_location);
	    
	  /* Add the new statement to the block.  */
	  gfc_add_expr_to_block (&block, res);
	}
    }

  /* Return the finished block.  */
  return gfc_finish_block (&block);
}


In principle the call to SET_EXPR_LOCATION should not be needed here, since the location should already be set correctly at this point; cf. the discussion in 

http://gcc.gnu.org/ml/fortran/2009-10/msg00205.html

and follow-ups. However, this patch

Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (Revision 153547)
+++ gcc/fortran/trans.c (Arbeitskopie)
@@ -1281,9 +1281,6 @@ gfc_trans_code (gfc_code * code)

       if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
        {
-         if (TREE_CODE (res) != STATEMENT_LIST)
-           SET_EXPR_LOCATION (res, input_location);
-
          /* Add the new statement to the block.  */
          gfc_add_expr_to_block (&block, res);
        }

yields (at least) the following regressions:

FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90  -O   (test for errors, line 20)                             
FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90  -O   (test for errors, line 14)                             
FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90  -O   (test for errors, line 20)                             
FAIL: gfortran.dg/gomp/appendix-a/a.24.1.f90  -O  (test for excess errors)                                
FAIL: gfortran.dg/gomp/appendix-a/a.35.1.f90  -O   (test for warnings, line 13)                           
FAIL: gfortran.dg/gomp/appendix-a/a.35.1.f90  -O  (test for excess errors)                                
FAIL: gfortran.dg/gomp/appendix-a/a.35.3.f90  -O   (test for warnings, line 10)                           
FAIL: gfortran.dg/gomp/appendix-a/a.35.3.f90  -O  (test for excess errors)                                
FAIL: gfortran.dg/gomp/appendix-a/a.35.4.f90  -O   (test for warnings, line 11)                           
FAIL: gfortran.dg/gomp/appendix-a/a.35.4.f90  -O  (test for excess errors)                                
FAIL: gfortran.dg/gomp/appendix-a/a.35.6.f90  -O   (test for warnings, line 9)                            
FAIL: gfortran.dg/gomp/appendix-a/a.35.6.f90  -O  (test for excess errors)                                
FAIL: gfortran.dg/gomp/block-1.f90  -O   (test for errors, line 5)                                        
FAIL: gfortran.dg/gomp/block-1.f90  -O  (test for excess errors)                                          
FAIL: gfortran.dg/gomp/crayptr3.f90  -O   (test for errors, line 19)                                      
FAIL: gfortran.dg/gomp/crayptr3.f90  -O   (test for errors, line 20)
FAIL: gfortran.dg/gomp/crayptr3.f90  -O  (test for excess errors)
FAIL: gfortran.dg/gomp/pr33439.f90  -O   (test for errors, line 8)
FAIL: gfortran.dg/gomp/pr33439.f90  -O   (test for errors, line 10)
FAIL: gfortran.dg/gomp/pr33439.f90  -O   (test for errors, line 21)
FAIL: gfortran.dg/gomp/pr33439.f90  -O   (test for errors, line 22)
FAIL: gfortran.dg/gomp/pr33439.f90  -O   (test for errors, line 33)
FAIL: gfortran.dg/gomp/pr33439.f90  -O  (test for excess errors)
FAIL: gfortran.dg/gomp/sharing-1.f90  -O   (test for errors, line 12)
FAIL: gfortran.dg/gomp/sharing-1.f90  -O   (test for errors, line 24)
FAIL: gfortran.dg/gomp/sharing-1.f90  -O   (test for errors, line 25)
FAIL: gfortran.dg/gomp/sharing-1.f90  -O   (test for errors, line 26)
FAIL: gfortran.dg/gomp/sharing-1.f90  -O  (test for excess errors)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 12)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 16)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 57)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 58)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 64)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O   (test for errors, line 65)
FAIL: gfortran.dg/gomp/sharing-2.f90  -O  (test for excess errors)
FAIL: gfortran.dg/gomp/sharing-3.f90  -O   (test for errors, line 28)
FAIL: gfortran.dg/gomp/sharing-3.f90  -O   (test for errors, line 30)
FAIL: gfortran.dg/gomp/sharing-3.f90  -O   (test for errors, line 33)
FAIL: gfortran.dg/gomp/sharing-3.f90  -O   (test for errors, line 34)
FAIL: gfortran.dg/gomp/sharing-3.f90  -O  (test for excess errors)

One should find out for which kind of statements the SET_EXPR_LOCATION is actually needed, and fix those in an appropriate way.
Comment 1 janus 2009-11-17 11:47:59 UTC
Since all regressions are OpenMP related, the following patch works without any testsuite failures:

Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (revision 154189)
+++ gcc/fortran/trans.c (working copy)
@@ -1281,7 +1281,7 @@ gfc_trans_code (gfc_code * code)

       if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
        {
-         if (TREE_CODE (res) != STATEMENT_LIST)
+         if (TREE_CODE (res) != STATEMENT_LIST && gfc_option.flag_openmp)
            SET_EXPR_LOCATION (res, input_location);

          /* Add the new statement to the block.  */
Comment 2 Daniel Franke 2010-04-30 21:54:10 UTC
See PR41359 for another use of SET_EXPR_LOCATION.
Comment 3 Dominique d'Humieres 2013-06-15 11:04:54 UTC
Is this PR another WONTFIX?
Comment 4 Dominique d'Humieres 2013-06-16 18:06:03 UTC
Moving to waiting.
Comment 5 Eric Gallager 2017-07-27 17:47:40 UTC
(In reply to Dominique d'Humieres from comment #4)
> Moving to waiting.

SUSPENDED would probably be better