diff options
author | Janus Weil <janus@gcc.gnu.org> | 2018-08-22 21:31:40 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2018-08-22 21:31:40 +0200 |
commit | bcddf743dd356082eca0a580881da0df683fe5ea (patch) | |
tree | aa45f8344f1f2d4f0e9854e2aafb26852eda8478 | |
parent | e9afbed0d65d7546b05cce3d5b5229b0046933ed (diff) | |
download | gcc-bcddf743dd356082eca0a580881da0df683fe5ea.zip gcc-bcddf743dd356082eca0a580881da0df683fe5ea.tar.gz gcc-bcddf743dd356082eca0a580881da0df683fe5ea.tar.bz2 |
re PR fortran/86935 (Bad locus in ASSOCIATE statement)
fix PR 86935
2018-08-22 Janus Weil <janus@gcc.gnu.org>
PR fortran/86935
* match.c (gfc_match_associate): Improve diagnostics for the ASSOCIATE
statement.
2018-08-22 Janus Weil <janus@gcc.gnu.org>
PR fortran/86935
* gfortran.dg/associate_3.f90: Update error message.
* gfortran.dg/associate_39.f90: New test case.
From-SVN: r263787
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/match.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_3.f03 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_39.f90 | 19 |
5 files changed, 44 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 88edff3..6bbf99c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-08-22 Janus Weil <janus@gcc.gnu.org> + + PR fortran/86935 + * match.c (gfc_match_associate): Improve diagnostics for the ASSOCIATE + statement. + 2018-08-22 Andrew Benson <abensonca@gmail.com> * module.c (load_generic_interfaces): Move call to find_symbol() diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 1ab0e0f..85247dd8 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1889,17 +1889,21 @@ gfc_match_associate (void) gfc_association_list* a; /* Match the next association. */ - if (gfc_match (" %n => %e", newAssoc->name, &newAssoc->target) - != MATCH_YES) + if (gfc_match (" %n =>", newAssoc->name) != MATCH_YES) + { + gfc_error ("Expected association at %C"); + goto assocListError; + } + + if (gfc_match (" %e", &newAssoc->target) != MATCH_YES) { /* Have another go, allowing for procedure pointer selectors. */ gfc_matching_procptr_assignment = 1; - if (gfc_match (" %n => %e", newAssoc->name, &newAssoc->target) - != MATCH_YES) - { - gfc_error ("Expected association at %C"); - goto assocListError; - } + if (gfc_match (" %e", &newAssoc->target) != MATCH_YES) + { + gfc_error ("Invalid association target at %C"); + goto assocListError; + } gfc_matching_procptr_assignment = 0; } newAssoc->where = gfc_current_locus; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 59a9038..8e70d05 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2018-08-22 Janus Weil <janus@gcc.gnu.org> + PR fortran/86935 + * gfortran.dg/associate_3.f90: Update error message. + * gfortran.dg/associate_39.f90: New test case. + +2018-08-22 Janus Weil <janus@gcc.gnu.org> + PR fortran/86888 * gfortran.dg/alloc_comp_basics_6.f90: Update an error message and add an additional case. diff --git a/gcc/testsuite/gfortran.dg/associate_3.f03 b/gcc/testsuite/gfortran.dg/associate_3.f03 index 20a375d..da7bec9 100644 --- a/gcc/testsuite/gfortran.dg/associate_3.f03 +++ b/gcc/testsuite/gfortran.dg/associate_3.f03 @@ -13,7 +13,7 @@ PROGRAM main ASSOCIATE (a => 1) 5 ! { dg-error "Junk after ASSOCIATE" } - ASSOCIATE (x =>) ! { dg-error "Expected association" } + ASSOCIATE (x =>) ! { dg-error "Invalid association target" } ASSOCIATE (=> 5) ! { dg-error "Expected association" } diff --git a/gcc/testsuite/gfortran.dg/associate_39.f90 b/gcc/testsuite/gfortran.dg/associate_39.f90 new file mode 100644 index 0000000..16357c3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_39.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! +! PR 86935: Bad locus in ASSOCIATE statement +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +implicit none + +type :: t + real :: r = 0.5 + integer :: i = 3 +end type + +type(t) :: x + +associate (r => x%r, & + i => x%ii) ! { dg-error "Invalid association target" } + +end |