This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR34342 - Some BOZ -std=f* diagnostics
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 05 Dec 2007 18:56:42 +0100
- Subject: [Patch, Fortran] PR34342 - Some BOZ -std=f* diagnostics
:ADDPATCH fortran:
gfortran did not diagnose using the postfix BOZ notation (e.g. '....'z)
as extension without returning a MATCH_ERROR.
I also added a std_notify for using BOZ outside DATA statements.
Additionally, I removed a couple of full stops in the error messages.
Build and regression tested on x86-64-linux.
OK for the trunk?
Tobias
PS: Missing is an error message for using BOZ to initialize non-integers
in DATA statements.
And supporting Fortran 2003 BOZ needs also some patches ;-)
2007-12-05 Tobias Burnus <burnus@net-b.de>
PR fortran/34333
* primary.c (match_boz_constant): Add gfc_notify_std diagnostics.
2007-12-05 Tobias Burnus <burnus@net-b.de>
PR fortran/34333
* gfortran.dg/boz_7.f90: New.
* gfortran.dg/int_1.f90: Disable -pedantic option.
* gfortran.dg/boz_1.f90: Ditto.
* gfortran.dg/boz_3.f90: Ditto.
* gfortran.dg/pr16433.f: Accomodate for new BOZ warning.
* gfortran.dg/ibits.f90: Ditto.
* gfortran.dg/unf_io_convert_1.f90: Ditto.
* gfortran.dg/unf_io_convert_2.f90: Ditto.
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (Revision 130625)
+++ gcc/fortran/primary.c (Arbeitskopie)
@@ -351,7 +351,7 @@ match_boz_constant (gfc_expr **result)
if (x_hex && pedantic
&& (gfc_notify_std (GFC_STD_GNU, "Extension: Hexadecimal "
- "constant at %C uses non-standard syntax.")
+ "constant at %C uses non-standard syntax")
== FAILURE))
return MATCH_ERROR;
@@ -388,8 +388,11 @@ match_boz_constant (gfc_expr **result)
default:
goto backup;
}
- gfc_notify_std (GFC_STD_GNU, "Extension: BOZ constant "
- "at %C uses non-standard postfix syntax.");
+
+ if (gfc_notify_std (GFC_STD_GNU, "Extension: BOZ constant "
+ "at %C uses non-standard postfix syntax")
+ == FAILURE)
+ return MATCH_ERROR;
}
gfc_current_locus = old_loc;
@@ -419,6 +422,14 @@ match_boz_constant (gfc_expr **result)
return MATCH_ERROR;
}
+ /* FIXME: Fortran 2003 allows BOZ also in REAL(), CMPLX(), INT();
+ see PR18026 and PR29471. */
+ if (!gfc_in_match_data ()
+ && (gfc_notify_std (GFC_STD_GNU, "Extension: BOZ used outside a DATA "
+ "statement at %C")
+ == FAILURE))
+ return MATCH_ERROR;
+
*result = e;
return MATCH_YES;
Index: gcc/testsuite/gfortran.dg/pr16433.f
===================================================================
--- gcc/testsuite/gfortran.dg/pr16433.f (Revision 130626)
+++ gcc/testsuite/gfortran.dg/pr16433.f (Arbeitskopie)
@@ -1,6 +1,6 @@
! { dg-do compile }
real x
double precision dx
- x = x'2ffde' ! { dg-warning "exadecimal constant" "Hex constant can't begin with x" }
+ data x/x'2ffde'/ ! { dg-warning "exadecimal constant" "Hex constant can't begin with x" }
dx = x ! { dg-bogus "exadecimal constant" "Hex constant where there is none" }
end
Index: gcc/testsuite/gfortran.dg/ibits.f90
===================================================================
--- gcc/testsuite/gfortran.dg/ibits.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/ibits.f90 (Arbeitskopie)
@@ -2,7 +2,7 @@
! Test that the mask is properly converted to the kind type of j in ibits.
program ibits_test
implicit none
- integer(8), parameter :: n = z'00000000FFFFFFFF'
+ integer(8), parameter :: n = z'00000000FFFFFFFF' ! { dg-warning "BOZ used outside a DATA statement" }
integer(8) i,j,k,m
j = 1
do i=1,70
Index: gcc/testsuite/gfortran.dg/int_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/int_1.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/int_1.f90 (Arbeitskopie)
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options "-std=gnu" }
!
! 13.7.53 INT(A [, KIND])
!
Index: gcc/testsuite/gfortran.dg/boz_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/boz_1.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/boz_1.f90 (Arbeitskopie)
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options "-std=gnu" }
! Test the boz handling
program boz
Index: gcc/testsuite/gfortran.dg/boz_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/boz_3.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/boz_3.f90 (Arbeitskopie)
@@ -1,4 +1,5 @@
! { dg-do run }
+! { dg-options "-std=gnu" }
! Test that the BOZ constant on the RHS, which are of different KIND than
! the LHS, are correctly converted.
!
Index: gcc/testsuite/gfortran.dg/unf_io_convert_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/unf_io_convert_1.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/unf_io_convert_1.f90 (Arbeitskopie)
@@ -18,9 +18,9 @@ program main
integer i
character*4 str
- m(1) = Z'11223344'
- m(2) = Z'55667788'
- n = Z'77AABBCC'
+ m(1) = Z'11223344' ! { dg-warning "BOZ used outside a DATA statement" }
+ m(2) = Z'55667788' ! { dg-warning "BOZ used outside a DATA statement" }
+ n = Z'77AABBCC' ! { dg-warning "BOZ used outside a DATA statement" }
str = 'asdf'
do i = 1,size
r(i) = i
@@ -46,7 +46,7 @@ program main
read(9) str
!
! check results
- if (m(1).ne.Z'11223344') then
+ if (m(1).ne.Z'11223344') then ! { dg-warning "BOZ used outside a DATA statement" }
if (debug) then
print '(A,Z8)','m(1) incorrect. m(1) = ',m(1)
else
@@ -54,7 +54,7 @@ program main
endif
endif
- if (m(2).ne.Z'55667788') then
+ if (m(2).ne.Z'55667788') then ! { dg-warning "BOZ used outside a DATA statement" }
if (debug) then
print '(A,Z8)','m(2) incorrect. m(2) = ',m(2)
else
@@ -62,7 +62,7 @@ program main
endif
endif
- if (n.ne.Z'77AABBCC') then
+ if (n.ne.Z'77AABBCC') then ! { dg-warning "BOZ used outside a DATA statement" }
if (debug) then
print '(A,Z8)','n incorrect. n = ',n
else
Index: gcc/testsuite/gfortran.dg/boz_7.f90
===================================================================
--- gcc/testsuite/gfortran.dg/boz_7.f90 (Revision 0)
+++ gcc/testsuite/gfortran.dg/boz_7.f90 (Revision 0)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-std=f95 -pedantic" }
+!
+! PR fortran/34342
+!
+! Some BOZ extensions where not diagnosed
+!
+integer :: k, m
+integer :: j = z'000abc' ! { dg-error "Extension: BOZ used outside a DATA statement" }
+data k/x'0003'/ ! { dg-error "uses non-standard syntax" }
+data m/'0003'z/ ! { dg-error "uses non-standard postfix syntax" }
+end
Index: gcc/testsuite/gfortran.dg/unf_io_convert_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/unf_io_convert_2.f90 (Revision 130626)
+++ gcc/testsuite/gfortran.dg/unf_io_convert_2.f90 (Arbeitskopie)
@@ -15,26 +15,26 @@ program main
close(10,status="delete")
open (10, form="unformatted",convert="big_endian") ! { dg-warning "Extension: CONVERT" }
- i = (/ Z'11223344', Z'55667700' /)
+ i = (/ Z'11223344', Z'55667700' /) ! { dg-warning "BOZ used outside a DATA statement" }
write (10) i
rewind (10)
read (10) b
- if (any(b /= (/ Z'11', Z'22', Z'33', Z'44', Z'55', Z'66', Z'77', Z'00' /))) &
+ if (any(b /= (/ Z'11', Z'22', Z'33', Z'44', Z'55', Z'66', Z'77', Z'00' /))) & ! { dg-warning "BOZ used outside a DATA statement" }
call abort
backspace 10
read (10) j
- if (j /= Z'1122334455667700') call abort
+ if (j /= Z'1122334455667700') call abort ! { dg-warning "BOZ used outside a DATA statement" }
close (10, status="delete")
open (10, form="unformatted", convert="little_endian") ! { dg-warning "Extension: CONVERT" }
write (10) i
rewind (10)
read (10) b
- if (any(b /= (/ Z'44', Z'33', Z'22', Z'11', Z'00', Z'77', Z'66', Z'55' /))) &
+ if (any(b /= (/ Z'44', Z'33', Z'22', Z'11', Z'00', Z'77', Z'66', Z'55' /))) & ! { dg-warning "BOZ used outside a DATA statement" }
call abort
backspace 10
read (10) j
- if (j /= Z'5566770011223344') call abort
+ if (j /= Z'5566770011223344') call abort ! { dg-warning "BOZ used outside a DATA statement" }
close (10, status="delete")
end program main