aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/interface.c
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gmx.de>2015-04-28 21:03:01 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2015-04-28 21:03:01 +0200
commit77b7d71e793213a330ccb19dbf3c54323c656539 (patch)
tree687628690dd631060e30c2ad86efe1d98649dc21 /gcc/fortran/interface.c
parentf307500830e39dbab2e0bc904aecbfc1995216ac (diff)
downloadgcc-77b7d71e793213a330ccb19dbf3c54323c656539.zip
gcc-77b7d71e793213a330ccb19dbf3c54323c656539.tar.gz
gcc-77b7d71e793213a330ccb19dbf3c54323c656539.tar.bz2
interface.c (gfc_compare_types): Check for unlimited polymorphism flag in the correct position indepent of the...
gcc/fortran/ChangeLog: 2015-04-28 Andre Vehreschild <vehre@gmx.de> * interface.c (gfc_compare_types): Check for unlimited polymorphism flag in the correct position indepent of the _data component being present or not. This prevents a segfault, when the _data component is not present. * symbol.c (gfc_type_compatible): Same. gcc/testsuite/ChangeLog: 2015-04-28 Andre Vehreschild <vehre@gmx.de> * gfortran.dg/implicit_class_1.f90: Adding flag to check, if segfault is fixed. From-SVN: r222539
Diffstat (limited to 'gcc/fortran/interface.c')
-rw-r--r--gcc/fortran/interface.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 320eb01..d4c2629 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -484,13 +484,24 @@ gfc_compare_types (gfc_typespec *ts1, gfc_typespec *ts2)
if (ts1->type == BT_VOID || ts2->type == BT_VOID)
return 1;
- if (ts1->type == BT_CLASS
- && ts1->u.derived->components->ts.u.derived->attr.unlimited_polymorphic)
+ /* The _data component is not always present, therefore check for its
+ presence before assuming, that its derived->attr is available.
+ When the _data component is not present, then nevertheless the
+ unlimited_polymorphic flag may be set in the derived type's attr. */
+ if (ts1->type == BT_CLASS && ts1->u.derived->components
+ && ((ts1->u.derived->attr.is_class
+ && ts1->u.derived->components->ts.u.derived->attr
+ .unlimited_polymorphic)
+ || ts1->u.derived->attr.unlimited_polymorphic))
return 1;
/* F2003: C717 */
if (ts2->type == BT_CLASS && ts1->type == BT_DERIVED
- && ts2->u.derived->components->ts.u.derived->attr.unlimited_polymorphic
+ && ts2->u.derived->components
+ && ((ts2->u.derived->attr.is_class
+ && ts2->u.derived->components->ts.u.derived->attr
+ .unlimited_polymorphic)
+ || ts2->u.derived->attr.unlimited_polymorphic)
&& (ts1->u.derived->attr.sequence || ts1->u.derived->attr.is_bind_c))
return 1;