The bug is a regression: An error was printed with 4.1.x but since 4.3.x
one gets an ICE. [No idea what GCC 4.2 does.] The solution is simply:
Returning if there is a MATCH_ERROR.
See PR (esp. comment 2) for a more detailed description:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163#c0
Build and regtested on x86-64-linux.
OK for the trunk? And to which version should it be backported? Only
4.6? Also 4.5? Or even 4.4?
Tobias
2011-08-23 Tobias Burnus <bur...@net-b.de>
PR fortran/50163
* check_init_expr (check_init_expr): Return when an error occured.
2011-08-23 Tobias Burnus <bur...@net-b.de>
PR fortran/50163
* gfortran.dg/initialization_28.f90: New.
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 9922094..b050b11 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2481,6 +2481,9 @@ check_init_expr (gfc_expr *e)
m = MATCH_ERROR;
}
+ if (m == MATCH_ERROR)
+ return FAILURE;
+
/* Try to scalarize an elemental intrinsic function that has an
array argument. */
isym = gfc_find_function (e->symtree->n.sym->name);
--- /dev/null 2011-08-23 07:28:57.751883742 +0200
+++ gcc/gcc/testsuite/gfortran.dg/initialization_28.f90 2011-08-23 14:02:02.000000000 +0200
@@ -0,0 +1,9 @@
+! { dg-do compile }
+!
+! PR fortran/50163
+!
+! Contributed by Philip Mason
+!
+character(len=2) :: xx ='aa'
+integer :: iloc=index(xx,'bb') ! { dg-error "has not been declared or is a variable" }
+end