Add f2008 to description

2021-07-24 Thread Vivek Rao via Fortran
The gfortran page https://gcc.gnu.org/wiki/GFortran says, "Gfortran is the name 
of the GNU Fortran project, developing a free Fortran 95/2003/2008 compiler for 
GCC, the GNU Compiler Collection."  Since Fortran 2018 features are being 
added, I suggest that 95/2003/2008 be replaced by 95/2003/2008/2018. Or maybe 
just 2018, since Fortran is largely backwards compatible and compilers do not 
remove the ability to compile even deleted features.

I thank the gfortran developers for a tool I use daily.

Vivek Rao



Add F2018 to description

2021-07-24 Thread Vivek Rao via Fortran
The previous message was garbled and wrongly titled.

I suggest that "2018" be added to the description of gfortran at 
https://gcc.gnu.org/wiki/GFortran

Vivek Rao


Re: [PATCH v2, Fortran] [PR libfortran/101317] Bind(c): Improve error checking in CFI_* functions

2021-07-24 Thread Sandra Loosemore

On 7/22/21 1:54 AM, Tobias Burnus wrote:

Hi Sandra,

On 21.07.21 20:01, Sandra Loosemore wrote:
Hmmm. CFI_establish explicitly says that the elem_len has to be 
greater than zero.  It seems somewhat confusing that it's inconsistent 
with the other functions that take an elem_len argument.


Congratulation – we have found a bug in the spec, which is also
present in the current draft (21-007). I have now written to J3:
https://mailman.j3-fortran.org/pipermail/j3/2021-July/013189.html


That discussion seems to have wandered off into some other direction so 
I'm not sure whether it really clarifies this problem.  For the purposes 
of this patch I have left in the test for elem_len > 0 in CFI_establish 
where the standard explicitly has that requirement and removed it from 
the other functions where I'd added it just to be consistent.


How about PRIiPTR + ptrdiff_t instead of %d + (int) cast? At least as 
positive value, extent may exceed INT_MAX.
Hmmm, there are similar problems in existing code in other functions 
in this file (e.g., CFI_section).


I think that you could fix as well. At least for size(array), it is not 
uncommon that this exceeds MAX_INT.


OK, I have done that throughout the file, and also made the wording 
change you asked for.  While I was at it, I went through all the 
diagnostic messages in the file and simplified the wording of a few 
other messages as well, fixed typos and inconsistent capitalization and 
missing punctuation and things like that.  As documentation maintainer I 
can self-approve those changes but of course I'll address complaints 
from the Fortran experts with what I've done there.


Here's a new patch.  For this version I've split off the fixes for the 
new tests in the TS29113 testsuite and merged them back into a new 
version of the main patch, which I will be posting soon.


-Sandra
commit 4940cf8cd97e718e7e9a89784e1f788d51ce64c2
Author: Sandra Loosemore 
Date:   Thu Jul 15 08:48:45 2021 -0700

[PR libfortran/101317] Bind(c): Improve error checking in CFI_* functions

This patch adds additional run-time checking for invalid arguments to
CFI_establish and CFI_setpointer.  It also changes existing messages
throughout the CFI_* functions to use PRIiPTR to format CFI_index_t
values instead of casting them to int and using %d (which may not work
on targets where int is a smaller type), simplifies wording of some
messages, and fixes issues with capitalization, typos, and the like.
Additionally some coding standards problems such as >80 character lines
are addressed.

2021-07-24  Sandra Loosemore  

	PR libfortran/101317

libgfortran/
	* runtime/ISO_Fortran_binding.c: Include .
	(CFI_address): Tidy error messages and comments.
	(CFI_allocate): Likewise.
	(CFI_deallocate): Likewise.
	(CFI_establish): Likewise.  Add new checks for validity of
	elem_len when it's used, plus type argument and extents.
	(CFI_is_contiguous): Tidy error messages and comments.
	(CFI_section): Likewise.  Refactor some repetitive code to
	make it more understandable.
	(CFI_select_part): Likewise.
	(CFI_setpointer): Likewise.  Check that source is not an
	unallocated allocatable array or an assumed-size array.

gcc/testsuite/
	* gfortran.dg/ISO_Fortran_binding_17.f90: Fix typo in error
	message patterns.

diff --git a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.f90 b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.f90
index bb30931..5902334 100644
--- a/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.f90
+++ b/gcc/testsuite/gfortran.dg/ISO_Fortran_binding_17.f90
@@ -71,7 +71,7 @@
end block blk2
 end
 
-! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = -1, lower_bound = 0, upper bound = 4, extend = 4(\n|\r\n|\r)" }
-! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = 5, lower_bound = 0, upper bound = 4, extend = 4(\n|\r\n|\r).*" }
-! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = -3, lower_bound = -2, upper bound = 6, extend = 4(\n|\r\n|\r)" }
-! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = 2, lower_bound = -2, upper bound = 6, extend = 4(\n|\r\n|\r)" }
+! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = -1, lower_bound = 0, upper bound = 4, extent = 4(\n|\r\n|\r)" }
+! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = 5, lower_bound = 0, upper bound = 4, extent = 4(\n|\r\n|\r).*" }
+! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = -3, lower_bound = -2, upper bound = 6, extent = 4(\n|\r\n|\r)" }
+! { dg-output "CFI_address: subscripts\\\[0\\\] is out of bounds. For dimension = 0, subscripts = 2, lower_bound = -2, upper bound = 6,