Rather obvious after finding it …
I first used "&& t != FAILURE"; however, that gives additional error
messages of the form:
class(t0), pointer :: foo(3) ! { dg-error "must have a deferred shape" }
1
Error: Component 'foo' with CLASS at (1) must be allocatable or pointer
Thus, I decided to always call gfc_build_class_symbol.
Committed (Rev. 187214) after building and regtesting it on
x86-64-gnu-linux.
Tobias
2012-05-06 Tobias Burnus <bur...@net-b.de>
PR fortran/41587
* decl.c (build_struct): Don't ignore FAILED status.
2012-05-06 Tobias Burnus <bur...@net-b.de>
PR fortran/41587
* gfortran.dg/class_array_13.f90: New.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 4da21c3..b527dd0 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1653,17 +1653,20 @@ build_struct (const char *name, gfc_charlen *cl, gfc_expr **init,
}
scalar:
if (c->ts.type == BT_CLASS)
{
bool delayed = (gfc_state_stack->sym == c->ts.u.derived)
|| (!c->ts.u.derived->components
&& !c->ts.u.derived->attr.zero_comp);
- return gfc_build_class_symbol (&c->ts, &c->attr, &c->as, delayed);
+ gfc_try t2 = gfc_build_class_symbol (&c->ts, &c->attr, &c->as, delayed);
+
+ if (t != FAILURE)
+ t = t2;
}
return t;
}
/* Match a 'NULL()', and possibly take care of some side effects. */
--- /dev/null 2012-05-04 18:48:20.115791170 +0200
+++ gcc/gcc/testsuite/gfortran.dg/class_array_13.f90 2012-05-06 18:48:31.000000000 +0200
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! PR fortran/41587
+!
+
+type t0
+ integer :: j = 42
+end type t0
+
+type t
+ integer :: i
+ class(t0), allocatable :: foo(3) ! { dg-error "must have a deferred shape" }
+end type t
+
+type t2
+ integer :: i
+ class(t0), pointer :: foo(3) ! { dg-error "must have a deferred shape" }
+end type t2
+
+type t3
+ integer :: i
+ class(t0), allocatable :: foo[3] ! { dg-error "Upper bound of last coarray dimension must be '\\*'" }
+end type t3
+
+end