From 585ba38fd5ce6275d2dca6592867e8aa8106406b Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 19 Oct 2009 20:03:02 +0200 Subject: [PATCH] re PR fortran/41755 (Segfault on invalid code) 2009-10-19 Tobias Burnus Steven G. Kargl PR fortran/41755 * symbol.c (gfc_undo_symbols): Add NULL check. * match.c (gfc_match_equivalence): Add check for missing comma. 2009-10-19 Tobias Burnus PR fortran/41755 * gfortran.dg/equiv_8.f90: New test. * gfortran.dg/class_allocate_1.f03: Remove obsolete FIXME. Co-Authored-By: Steven G. Kargl From-SVN: r152983 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/match.c | 5 ++++- gcc/fortran/symbol.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/class_allocate_1.f03 | 3 +-- gcc/testsuite/gfortran.dg/equiv_8.f90 | 7 +++++++ 6 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/equiv_8.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b90f9c583c4..3f07da5315f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2009-10-19 Tobias Burnus + Steven G. Kargl + + PR fortran/41755 + * symbol.c (gfc_undo_symbols): Add NULL check. + * match.c (gfc_match_equivalence): Add check for + missing comma. + 2009-10-19 Richard Guenther PR fortran/41494 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d75ef0ea2f5..87216062bec 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -3750,7 +3750,10 @@ gfc_match_equivalence (void) if (gfc_match_eos () == MATCH_YES) break; if (gfc_match_char (',') != MATCH_YES) - goto syntax; + { + gfc_error ("Expecting a comma in EQUIVALENCE at %C"); + goto cleanup; + } } return MATCH_YES; diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 2641df82b35..837a357d9fb 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -2741,7 +2741,7 @@ gfc_undo_symbols (void) if (p->gfc_new) { /* Symbol was new. */ - if (p->attr.in_common && p->common_block->head) + if (p->attr.in_common && p->common_block && p->common_block->head) { /* If the symbol was added to any common block, it needs to be removed to stop the resolver looking diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0042764aea8..bce4d7cb84f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2009-10-19 Tobias Burnus + + PR fortran/41755 + * gfortran.dg/equiv_8.f90: New test. + * gfortran.dg/class_allocate_1.f03: Remove obsolete FIXME. + 2009-10-19 Joseph Myers * gcc.target/arm/neon-thumb2-move.c: New test. diff --git a/gcc/testsuite/gfortran.dg/class_allocate_1.f03 b/gcc/testsuite/gfortran.dg/class_allocate_1.f03 index 719d90cf8f9..67c8065794b 100644 --- a/gcc/testsuite/gfortran.dg/class_allocate_1.f03 +++ b/gcc/testsuite/gfortran.dg/class_allocate_1.f03 @@ -68,8 +68,7 @@ i = 0 allocate(t2 :: cp2) -! FIXME: Not yet supported: source= -! allocate(cp, source = cp2) + allocate(cp, source = cp2) allocate(t2 :: cp3) allocate(cp, source=cp3) select type (cp) diff --git a/gcc/testsuite/gfortran.dg/equiv_8.f90 b/gcc/testsuite/gfortran.dg/equiv_8.f90 new file mode 100644 index 00000000000..a2ed7f0349e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/equiv_8.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! +! PR fortran/41755 +! + common /uno/ aa + equivalence (aa,aaaaa) (bb,cc) ! { dg-error "Expecting a comma in EQUIVALENCE" } + end