Patchwork PR 60414: Patch proposal

login
register
mail settings
Submitter Andre Vehreschild
Date July 18, 2014, 10:02 a.m.
Message ID <20140718120209.4adf6cb7@vepi2.private>
Download mbox | patch
Permalink /patch/371435/
State New
Headers show

Comments

Andre Vehreschild - July 18, 2014, 10:02 a.m.
Hi all,

this is my first try to submit a patch, so please be kind and correct me when I
do something wrong.

I was contracted to fix some issues listed in the bugtracker for fortran.
Please find attached my first attempt for bug PR60414 (I'll attach it to the
bug in the tracker in a second).

The bug terminates the compiler, because in the translation phase an unexpected
construction is seen as actual argument. I tracked down the location where the
decision to construct the parse tree seen is made and deduced, that the
parameter matching is not respecting the array_ref done in the code not
compiling. I have fixed this by checking if the ->ref member of the actual
argument is set. The analysis continues and the test case created for it
compile fine now.

Patch content:
- Changelog entry in gcc/fortran/Changelog
- Changelog entry in gcc/testsuite/Changelog
- Patch in interface.c: two line comment, one line actual code
- Testcase in gcc/testsuite/fortran.dg/unlimited_polymorphism_18.f90

Regards,
	Andre

Patch

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c33936b..cb01a13 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@ 
+2014-07-19  Andre Vehreschild <vehre@gmx.de>
+
+	PR fortran/60414
+	* interface.c (compare_parameter): Fix compile bug: During resolution
+	of generic an array reference in the actual argument was not
+	respected. Fixed by checking, if the ref member is non-null. Testcase
+	unlimited_polymorphism_18.f90 add.
+
 2014-06-15  Tobias Burnus  <burnus@net-b.de>
 
 	* symbol.c (check_conflict): Add codimension conflict with
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index b210d18..8658003 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2156,7 +2156,10 @@  compare_parameter (gfc_symbol *formal, gfc_expr *actual,
   if (symbol_rank (formal) == actual->rank || symbol_rank (formal) == -1)
     return 1;
 
+  /* Only check ranks compatibility, if actual is not an array reference,
+     i.e., actual(i) indicated by actual->ref being set. */
   if (actual->ts.type == BT_CLASS && CLASS_DATA (actual)->as
+        && !actual->ref
 	&& CLASS_DATA (actual)->as->rank == symbol_rank (formal))
     return 1;
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f6e9f23..84e16da 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2014-07-19  Andre Vehreschild <vehre@gmx.de>
+
+	* gfortran.dg/unlimited_polymorphism_18.f90: Check according to 
+	PR 60414
+
 2014-07-17  Richard Sandiford  <rdsandiford@googlemail.com>
 
 	* gcc.target/mips/umips-lwp-1.c (foo): Use a shift/add sequence