From: Steven G. Kargl Date: Thu, 9 Sep 2010 18:52:11 +0000 (+0000) Subject: dummy_optional_arg.f90: New test. X-Git-Tag: releases/gcc-4.6.0~4463 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26865ab4e8a09b607fae1c338137a4ac65c476cc;p=thirdparty%2Fgcc.git dummy_optional_arg.f90: New test. 2010-09-09 Steven G. Kargl * gfortran.dg/dummy_optional_arg.f90: New test. 2010-09-09 Steven G. Kargl * fortran/expr.c (check_inquiry): OPTIONAL attribute is not allowed for dummy argument that appears in a specification statement. From-SVN: r164120 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5e3def2dd4ac..29b8a2696d21 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2010-09-09 Steven G. Kargl + + * fortran/expr.c (check_inquiry): OPTIONAL attribute is not allowed + for dummy argument that appears in a specification statement. + 2010-09-09 Mikael Morin * trans-array.c (gfc_get_array_ref_dim): New function. diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 959546672e00..76ceec957151 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2305,6 +2305,12 @@ check_inquiry (gfc_expr *e, int not_restricted) && ap->expr->expr_type != EXPR_VARIABLE && check_restricted (ap->expr) == FAILURE) return MATCH_ERROR; + + if (not_restricted == 0 + && ap->expr->expr_type == EXPR_VARIABLE + && ap->expr->symtree->n.sym->attr.dummy + && ap->expr->symtree->n.sym->attr.optional) + return MATCH_NO; } return MATCH_YES; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f0acf7a3fff..fbbbd56911ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-09-09 Steven G. Kargl + + * gfortran.dg/dummy_optional_arg.f90: New test. + 2010-09-08 Jan Hubicka PR tree-optimization/45598 diff --git a/gcc/testsuite/gfortran.dg/dummy_optional_arg.f90 b/gcc/testsuite/gfortran.dg/dummy_optional_arg.f90 new file mode 100644 index 000000000000..4c0417bffc09 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dummy_optional_arg.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/45495 +! +! Code originally submitted by Philip Mason +! +function jack(aa) + character(len=*), intent(in) :: aa + optional :: aa + character(len=len(aa)+1) :: jack ! { dg-error "cannot be OPTIONAL" } + jack = '' +end function jack + +function diane(aa) + character(len=*), intent(out) :: aa + character(len=len(aa)+1) :: diane + diane = '012345678901' + aa = 'abcdefghijklmn' +end function diane