From patchwork Fri Jul 23 16:04:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 59815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B91F01007D1 for ; Sat, 24 Jul 2010 02:04:47 +1000 (EST) Received: (qmail 12594 invoked by alias); 23 Jul 2010 16:04:42 -0000 Received: (qmail 11961 invoked by uid 22791); 23 Jul 2010 16:04:37 -0000 X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Jul 2010 16:04:28 +0000 Received: from [192.168.178.22] (port-92-204-52-63.dynamic.qsc.de [92.204.52.63]) by mx01.qsc.de (Postfix) with ESMTP id 2B53E3D90F; Fri, 23 Jul 2010 18:04:25 +0200 (CEST) Message-ID: <4C49BD88.5060108@net-b.de> Date: Fri, 23 Jul 2010 18:04:24 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Fortran] RFC: Enabling -fwhole-file by default Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org I would like to enable -fwhole-file by default. As written before, the advantages are - Fixes some wrong-code issues (e.g. PR 44945) - Improves diagnostic - Improves (non-LTO) optimizations - More consistent codepath: The same for default, LTO and -fwhole-program I think -fwhole-file is now stable enough to be enabled by default; one can still use -fno-whole-file to disable it. (Though, I like to remove that "no" option in the next release, i.e. 4.7.) Before one can enable -fwhole-file, one should apply the following two patches: http://gcc.gnu.org/ml/fortran/2010-07/msg00311.html http://gcc.gnu.org/ml/fortran/2010-07/msg00320.html In addition, some changes to the test suite were necessary: Some changed messages due to the different code path, a bunch of warnings, some code fixes - see attached patch. With the two patches mentioned above and the attached patch, I only see one test-suite failure: gfortran.dg/common_resize_1.f where a warning about different COMMON sizes disappears with -fwhole-file (cf. PR 45045 and related PR 45044). I would suggest to XFAIL that check if we cannot fix it soon. The change to the compare_parameter is for gfortran.dg/hollerith.f90; otherwise, one gets the warning: "Type mismatch in argument 'h' at (1); passed HOLLERITH to INTEGER(8)". I think this warning does not make much sense for Hollerith (enabled by default; error with -pedantic) - and with -pedantic one already gets warnings - e.g. for the line in question a "Hollerith constant" warning. Build and regtested on x86-64-linux - with common_resize_1.f as only failure. OK for the trunk? Jakub might want to have a look at the libgomp/testsuite/ change. Tobias PS: If it is OK, I will write a changelog. gcc/fortran/interface.c | 1 gcc/fortran/options.c | 2 gcc/testsuite/gfortran.dg/bounds_check_strlen_1.f90 | 2 gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90 | 2 gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 | 5 + gcc/testsuite/gfortran.dg/entry_17.f90 | 4 gcc/testsuite/gfortran.dg/func_decl_4.f90 | 13 ++- gcc/testsuite/gfortran.dg/func_decl_5.f90 | 15 +++ gcc/testsuite/gfortran.dg/g77/19990218-0.f | 2 gcc/testsuite/gfortran.dg/g77/19990218-1.f | 2 gcc/testsuite/gfortran.dg/g77/970625-2.f | 2 gcc/testsuite/gfortran.dg/generic_actual_arg.f90 | 2 gcc/testsuite/gfortran.dg/global_references_1.f90 | 6 - gcc/testsuite/gfortran.dg/integer_exponentiation_2.f90 | 20 ++-- gcc/testsuite/gfortran.dg/intrinsic_std_1.f90 | 16 +-- gcc/testsuite/gfortran.dg/intrinsic_std_6.f90 | 41 ++++++++++ gcc/testsuite/gfortran.dg/loc_1.f90 | 3 gcc/testsuite/gfortran.dg/pr20865.f90 | 2 gcc/testsuite/gfortran.dg/pr37243.f | 6 - gcc/testsuite/gfortran.dg/sizeof.f90 | 4 gcc/testsuite/gfortran.dg/use_only_1.f90 | 1 gcc/testsuite/gfortran.dg/used_before_typed_4.f90 | 2 libgomp/testsuite/libgomp.fortran/appendix-a/a.28.5.f90 | 5 + 23 files changed, 115 insertions(+), 43 deletions(-) Index: gcc/fortran/interface.c =================================================================== --- gcc/fortran/interface.c (revision 162456) +++ gcc/fortran/interface.c (working copy) @@ -1470,6 +1470,7 @@ compare_parameter (gfc_symbol *formal, g } if ((actual->expr_type != EXPR_NULL || actual->ts.type != BT_UNKNOWN) + && actual->ts.type != BT_HOLLERITH && !gfc_compare_types (&formal->ts, &actual->ts)) { if (where) Index: gcc/fortran/options.c =================================================================== --- gcc/fortran/options.c (revision 162456) +++ gcc/fortran/options.c (working copy) @@ -96,7 +96,7 @@ gfc_init_options (unsigned int argc, con gfc_option.flag_default_real = 0; gfc_option.flag_dollar_ok = 0; gfc_option.flag_underscoring = 1; - gfc_option.flag_whole_file = 0; + gfc_option.flag_whole_file = 1; gfc_option.flag_f2c = 0; gfc_option.flag_second_underscore = -1; gfc_option.flag_implicit_none = 0; Index: gcc/testsuite/gfortran.dg/func_decl_4.f90 =================================================================== --- gcc/testsuite/gfortran.dg/func_decl_4.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/func_decl_4.f90 (working copy) @@ -3,13 +3,18 @@ ! ! Functions shall not have an initializer. ! +! Due to -fwhole-file, the function declaration +! warnings come before the init warnings; thus +! the warning for the WRONG lines have been moved to +! func_decl_5.f90 +! -function f1() ! { dg-error "cannot have an initializer" } - integer :: f1 = 42 +function f1() + integer :: f1 = 42 ! WRONG, see func_decl_5.f90 end function -function f2() RESULT (r) ! { dg-error "cannot have an initializer" } - integer :: r = 42 +function f2() RESULT (r) + integer :: r = 42 ! WRONG, see func_decl_5.f90 end function function f3() RESULT (f3) ! { dg-error "must be different than function name" } Index: gcc/testsuite/gfortran.dg/intrinsic_std_6.f90 =================================================================== --- gcc/testsuite/gfortran.dg/intrinsic_std_6.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/intrinsic_std_6.f90 (revision 0) @@ -0,0 +1,41 @@ +! { dg-do compile } +! { dg-options "-std=f95 -Wintrinsics-std -fdump-tree-original" } + +! +! See intrinsic_std_1.f90 for more compile-time checks +! + +! PR fortran/33141 +! Check for the expected behaviour when an intrinsic function/subroutine is +! called that is not available in the defined standard or that is a GNU +! extension: +! There should be a warning emitted on the call, and the reference should be +! treated like an external call. +! For declaring a non-standard intrinsic INTRINSIC, a hard error should be +! generated, of course. + +SUBROUTINE no_implicit + IMPLICIT NONE + REAL :: asinh ! { dg-warning "Fortran 2008" } + + ! abort is a GNU extension + CALL abort () ! { dg-warning "extension" } + + ! ASINH is an intrinsic of F2008 + ! The warning should be issued in the declaration above where it is declared + ! EXTERNAL. + WRITE (*,*) ASINH (1.) ! { dg-warning "Fortran 2008" } +END SUBROUTINE no_implicit + +SUBROUTINE implicit_type + ! acosh has implicit type + + WRITE (*,*) ACOSH (1.) ! { dg-warning "Fortran 2008" } + WRITE (*,*) ACOSH (1.) ! { dg-bogus "Fortran 2008" } +END SUBROUTINE implicit_type + +! Scan that really external functions are called. +! { dg-final { scan-tree-dump " abort " "original" } } +! { dg-final { scan-tree-dump " asinh " "original" } } +! { dg-final { scan-tree-dump " acosh " "original" } } +! { dg-final { cleanup-tree-dump "original" } } Index: gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90 (working copy) @@ -22,7 +22,7 @@ end subroutine gfcbug34 ! This is PR25669 subroutine foo (a) real a(*) - call bar (a, LBOUND(a),2) + call bar (a, LBOUND(a),2) ! { dg-warning "Rank mismatch in argument" } end subroutine foo subroutine bar (b, i, j) real b(i:j) Index: gcc/testsuite/gfortran.dg/global_references_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/global_references_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/global_references_1.f90 (working copy) @@ -32,11 +32,11 @@ function h(x) ! { dg-error "is alr end function h SUBROUTINE TT() - CHARACTER(LEN=10), EXTERNAL :: j + CHARACTER(LEN=10), EXTERNAL :: j ! { dg-warning "Return type mismatch" } CHARACTER(LEN=10) :: T ! PR20881=========================================================== ! Error only appears once but testsuite associates with both lines. - T = j () ! { dg-error "is already being used as a FUNCTION" } + T = j (1.0) ! { dg-error "is already being used as a SUBROUTINE" } print *, T END SUBROUTINE TT @@ -78,7 +78,7 @@ end ! Lahey - 2636-S: "SOURCE.F90", line 81: ! Subroutine 'j' is previously referenced as a function in 'line 39'. -SUBROUTINE j (x) ! { dg-error "is already being used as a FUNCTION" } +SUBROUTINE j (x) ! { dg-error "is already being used as a SUBROUTINE" } integer a(10) common /bar/ a ! Global entity foo real x Index: gcc/testsuite/gfortran.dg/generic_actual_arg.f90 =================================================================== --- gcc/testsuite/gfortran.dg/generic_actual_arg.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/generic_actual_arg.f90 (working copy) @@ -37,7 +37,7 @@ USE TEST USE TEST2 CALL F(CALCULATION) ! { dg-error "GENERIC procedure" } -CALL F(CALCULATION2) ! OK because there is a same name specific +CALL F(CALCULATION2) ! OK because there is a same name specific, but: ! { dg-warning "More actual than formal arguments" } END SUBROUTINE F() Index: gcc/testsuite/gfortran.dg/entry_17.f90 =================================================================== --- gcc/testsuite/gfortran.dg/entry_17.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/entry_17.f90 (working copy) @@ -24,7 +24,7 @@ function test3() ! { dg-warning "Obsoles return entry bar3() bar3 = "" -end function test3 ! { dg-warning "Obsolescent feature" } +end function test3 function test4(n) ! { dg-error "returning variables of different string lengths" } integer :: n @@ -52,4 +52,4 @@ function test6() ! { dg-warning "Obsoles return entry bar6() bar6 = "" -end function test6 ! { dg-warning "Obsolescent feature" } +end function test6 Index: gcc/testsuite/gfortran.dg/used_before_typed_4.f90 =================================================================== --- gcc/testsuite/gfortran.dg/used_before_typed_4.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/used_before_typed_4.f90 (working copy) @@ -22,5 +22,5 @@ END SUBROUTINE test PROGRAM main IMPLICIT NONE INTEGER :: arr1(42), arr2(42) - CALL test (3, arr1, 2, arr2) + CALL test (3, arr1, 2, arr2) ! { dg-warning "Type mismatch in argument" } END PROGRAM main Index: gcc/testsuite/gfortran.dg/bounds_check_strlen_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/bounds_check_strlen_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/bounds_check_strlen_1.f90 (working copy) @@ -12,7 +12,7 @@ END SUBROUTINE test PROGRAM main IMPLICIT NONE - CALL test ('abc') ! String is too short. + CALL test ('abc') ! { dg-warning "Character length of actual argument shorter" } END PROGRAM main ! { dg-output "shorter than the declared one for dummy argument 'str' \\(3/5\\)" } Index: gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 =================================================================== --- gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/char_array_structure_constructor.f90 (working copy) @@ -1,4 +1,9 @@ ! { dg-do run } +! { dg-options "-fwhole-file" } +! +! PR fortran/19107 +! -fwhole-file flag added for PR fortran/44945 +! ! This test the fix of PR19107, where character array actual ! arguments in derived type constructors caused an ICE. ! It also checks that the scalar counterparts are OK. Index: gcc/testsuite/gfortran.dg/intrinsic_std_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/intrinsic_std_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/intrinsic_std_1.f90 (working copy) @@ -1,5 +1,9 @@ ! { dg-do compile } -! { dg-options "-std=f95 -Wintrinsics-std -fdump-tree-original" } +! { dg-options "-std=f95 -Wintrinsics-std" } + +! +! See intrinsic_std_6.f90 for the dump check. +! ! PR fortran/33141 ! Check for the expected behaviour when an intrinsic function/subroutine is @@ -32,8 +36,8 @@ END SUBROUTINE implicit_type SUBROUTINE specification_expression CHARACTER(KIND=selected_char_kind("ascii")) :: x -! { dg-error "must be an intrinsic function" "" { target "*-*-*" } 34 } -! { dg-warning "Fortran 2003" "" { target "*-*-*" } 34 } +! { dg-error "must be an intrinsic function" "" { target "*-*-*" } 38 } +! { dg-warning "Fortran 2003" "" { target "*-*-*" } 38 } END SUBROUTINE specification_expression SUBROUTINE intrinsic_decl @@ -41,9 +45,3 @@ SUBROUTINE intrinsic_decl INTRINSIC :: atanh ! { dg-error "Fortran 2008" } INTRINSIC :: abort ! { dg-error "extension" } END SUBROUTINE intrinsic_decl - -! Scan that really external functions are called. -! { dg-final { scan-tree-dump " abort " "original" } } -! { dg-final { scan-tree-dump " asinh " "original" } } -! { dg-final { scan-tree-dump " acosh " "original" } } -! { dg-final { cleanup-tree-dump "original" } } Index: gcc/testsuite/gfortran.dg/func_decl_5.f90 =================================================================== --- gcc/testsuite/gfortran.dg/func_decl_5.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/func_decl_5.f90 (revision 0) @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-c" } +! +! Functions shall not have an initializer. +! +! Some tests were moved from func_decl_4.f90 to here. +! + +function f1() ! { dg-error "cannot have an initializer" } + integer :: f1 = 42 +end function + +function f2() RESULT (r) ! { dg-error "cannot have an initializer" } + integer :: r = 42 +end function Index: gcc/testsuite/gfortran.dg/sizeof.f90 =================================================================== --- gcc/testsuite/gfortran.dg/sizeof.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/sizeof.f90 (working copy) @@ -82,7 +82,7 @@ subroutine check_derived () call abort end subroutine check_derived -call check_int () -call check_real () +call check_int (1) +call check_real (1.0, (/1.0, 2.0, 3.0, 4.0, 5.0/)) call check_derived () end Index: gcc/testsuite/gfortran.dg/pr20865.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr20865.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/pr20865.f90 (working copy) @@ -8,5 +8,5 @@ integer :: i, st st(i) = (i*i+2) - call tt(st) ! { dg-error "Statement function .* is not allowed as an actual argument" } + call tt(st) ! { dg-error "Statement function .* is not allowed as an actual argument|Invalid procedure argument" } end Index: gcc/testsuite/gfortran.dg/integer_exponentiation_2.f90 =================================================================== --- gcc/testsuite/gfortran.dg/integer_exponentiation_2.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/integer_exponentiation_2.f90 (working copy) @@ -139,16 +139,16 @@ subroutine foo(a) call gee_i(i**(-huge(0_4))) call gee_i(i**(-huge(0_4)-1_4)) - call gee_i(i**0_8) - call gee_i(i**1_8) - call gee_i(i**2_8) - call gee_i(i**3_8) - call gee_i(i**(-1_8)) - call gee_i(i**(-2_8)) - call gee_i(i**(-3_8)) - call gee_i(i**huge(0_8)) - call gee_i(i**(-huge(0_8))) - call gee_i(i**(-huge(0_8)-1_8)) + call gee_i(i**0_8) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**1_8) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**2_8) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**3_8) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**(-1_8)) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**(-2_8)) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**(-3_8)) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**huge(0_8)) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**(-huge(0_8))) ! { dg-warning "Type mismatch in argument" } + call gee_i(i**(-huge(0_8)-1_8)) ! { dg-warning "Type mismatch in argument" } ! Real call gee_r(a**0_1) Index: gcc/testsuite/gfortran.dg/g77/19990218-0.f =================================================================== --- gcc/testsuite/gfortran.dg/g77/19990218-0.f (revision 162456) +++ gcc/testsuite/gfortran.dg/g77/19990218-0.f (working copy) @@ -2,7 +2,7 @@ c { dg-do compile } program test double precision a,b,c data a,b/1.0d-46,1.0d0/ - c=fun(a,b) + c=fun(a,b) ! { dg-error "Return type mismatch of function" } print*,'in main: fun=',c end double precision function fun(a,b) Index: gcc/testsuite/gfortran.dg/g77/19990218-1.f =================================================================== --- gcc/testsuite/gfortran.dg/g77/19990218-1.f (revision 162456) +++ gcc/testsuite/gfortran.dg/g77/19990218-1.f (working copy) @@ -20,6 +20,6 @@ c program test double precision a,b,c data a,b/1.0d-46,1.0d0/ - c=fun(a,b) + c=fun(a,b) ! { dg-error "Return type mismatch of function" } print*,'in main: fun=',c end Index: gcc/testsuite/gfortran.dg/g77/970625-2.f =================================================================== --- gcc/testsuite/gfortran.dg/g77/970625-2.f (revision 162456) +++ gcc/testsuite/gfortran.dg/g77/970625-2.f (working copy) @@ -40,7 +40,7 @@ PROGRAM = THEN - IF ELSE IF = THEN .GT. IF IF (THEN.GT.REAL) THEN - CALL FUNCTION PROGRAM (ELSE IF, GO TO PROGRAM, THEN) + CALL FUNCTION PROGRAM (ELSE IF, GO TO PROGRAM, THEN) ! { dg-warning "Type mismatch in argument" } ELSE IF (ELSE IF) THEN REAL = THEN + END DO END IF Index: gcc/testsuite/gfortran.dg/pr37243.f =================================================================== --- gcc/testsuite/gfortran.dg/pr37243.f (revision 162456) +++ gcc/testsuite/gfortran.dg/pr37243.f (working copy) @@ -20,8 +20,8 @@ IF (I .EQ. M) GO TO 160 I1 = I+1 DO 140 J = I1,M - DUM = -DDOT(N,V(1,J),1,V(1,I),1) - CALL DAXPY(N,DUM,V(1,I),1,V(1,J),1) + DUM = -DDOT(N,V(1,J),1,V(1,I),1) ! { dg-warning "More actual than formal arguments" } + CALL DAXPY(N,DUM,V(1,I),1,V(1,J),1) ! { dg-warning "More actual than formal arguments" } 140 CONTINUE 160 CONTINUE IF (M .EQ. N) RETURN @@ -35,7 +35,7 @@ IF (J .GT. N) GO TO 320 DO 240 K = 1,N 240 V(K,I) = ZERO - CALL DAXPY(N,DUM,V(1,I),1,V(1,I),1) + CALL DAXPY(N,DUM,V(1,I),1,V(1,I),1) ! { dg-warning "More actual than formal arguments" } 260 CONTINUE DUMI = ZERO DO 280 K = 1,N Index: gcc/testsuite/gfortran.dg/use_only_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/use_only_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/use_only_1.f90 (working copy) @@ -73,6 +73,7 @@ contains USE xmod, ONLY: xfoobar_renamed => xfoobar USE ymod, ONLY: yfoobar_renamed => yfoobar USE ymod + implicit integer(4) (a-z) if (xfoobar_renamed (42) == xfoobar ()) call abort () if (yfoobar_renamed (42) == yfoobar ()) call abort () end subroutine Index: gcc/testsuite/gfortran.dg/loc_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/loc_1.f90 (revision 162456) +++ gcc/testsuite/gfortran.dg/loc_1.f90 (working copy) @@ -17,9 +17,10 @@ subroutine fn end subroutine fn subroutine foo (ii) + use iso_c_binding, only: c_intptr_t common /targ/targ integer targ(10) - integer ii + integer(c_intptr_t) ii targ(2) = ii end subroutine foo Index: libgomp/testsuite/libgomp.fortran/appendix-a/a.28.5.f90 =================================================================== --- libgomp/testsuite/libgomp.fortran/appendix-a/a.28.5.f90 (revision 162456) +++ libgomp/testsuite/libgomp.fortran/appendix-a/a.28.5.f90 (working copy) @@ -1,4 +1,9 @@ ! { dg-do compile } +! { dg-options "-w" } +! +! "-w" added as libgomp/testsuite seemingly cannot parse with +! dg-warning Fortran's output. Fortran warns for "call sub1(a)" +! that there is a "Rank mismatch in argument 'x'". SUBROUTINE SUB1(X) DIMENSION X(10)