From 3dcc3ef2a12a9e0965dd80d7c32a26bda892d861 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Thu, 25 Sep 2008 17:01:16 +0200 Subject: [PATCH] re PR fortran/37504 (Wrongly rejects: unprotected_pointer => protected_pointer) 2008-09-25 Tobias Burnus PR fortran/37504 * expr.c (gfc_check_pointer_assign): Allow assignment of protected pointers. * match.c (gfc_match_assignment,gfc_match_pointer_assignment): Remove unreachable code. 2008-09-25 Tobias Burnus PR fortran/37504 * gfortran.dg/protected_7.f90: New test. From-SVN: r140663 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/expr.c | 3 ++- gcc/fortran/match.c | 17 ----------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/protected_7.f90 | 22 ++++++++++++++++++++++ 5 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/protected_7.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c8301f6..16ed9e9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2008-09-25 Tobias Burnus + + PR fortran/37504 + * expr.c (gfc_check_pointer_assign): Allow assignment of + protected pointers. + * match.c (gfc_match_assignment,gfc_match_pointer_assignment): + Remove unreachable code. + 2008-09-24 Tobias Burnus * options.c (set_default_std_flags,gfc_init_options): diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index e15412a..7b741b8 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -3076,7 +3076,8 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue) return FAILURE; } - if (attr.is_protected && attr.use_assoc) + if (attr.is_protected && attr.use_assoc + && !(attr.pointer || attr.proc_pointer)) { gfc_error ("Pointer assignment target has PROTECTED " "attribute at %L", &rvalue->where); diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index f7ff9bb..c8fd30d 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1293,15 +1293,6 @@ gfc_match_assignment (void) return MATCH_NO; } - if (lvalue->symtree->n.sym->attr.is_protected - && lvalue->symtree->n.sym->attr.use_assoc) - { - gfc_current_locus = old_loc; - gfc_free_expr (lvalue); - gfc_error ("Setting value of PROTECTED variable at %C"); - return MATCH_ERROR; - } - rvalue = NULL; m = gfc_match (" %e%t", &rvalue); if (m != MATCH_YES) @@ -1353,14 +1344,6 @@ gfc_match_pointer_assignment (void) if (m != MATCH_YES) goto cleanup; - if (lvalue->symtree->n.sym->attr.is_protected - && lvalue->symtree->n.sym->attr.use_assoc) - { - gfc_error ("Assigning to a PROTECTED pointer at %C"); - m = MATCH_ERROR; - goto cleanup; - } - new_st.op = EXEC_POINTER_ASSIGN; new_st.expr = lvalue; new_st.expr2 = rvalue; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0be7f7d..2941ac9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-25 Tobias Burnus + + PR fortran/37504 + * gfortran.dg/protected_7.f90: New test. + 2008-09-24 Steve Ellcey * gcc.dg/vect/O3-vect-pr34223.c: Check vect_int_mult. diff --git a/gcc/testsuite/gfortran.dg/protected_7.f90 b/gcc/testsuite/gfortran.dg/protected_7.f90 new file mode 100644 index 0000000..0325a49 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/protected_7.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! PR fortran/37504 +! +module m + implicit none + integer, pointer, protected :: protected_pointer + integer, target, protected :: protected_target +end module m + +program p + use m + implicit none + integer, pointer :: unprotected_pointer + ! The next two lines should be rejected; see PR 37513 why + ! we get such a strange error message. + protected_pointer => unprotected_pointer ! { dg-error "only allowed in specification part" } + protected_pointer = unprotected_pointer ! { dg-error "only allowed in specification part" } + unprotected_pointer => protected_target ! { dg-error "target has PROTECTED attribute" } + unprotected_pointer => protected_pointer ! OK +end program p + +! { dg-final { cleanup-modules "m" } } -- 2.7.4