diff options
author | Daniel Kraft <d@domob.eu> | 2008-07-24 20:52:51 +0200 |
---|---|---|
committer | Daniel Kraft <domob@gcc.gnu.org> | 2008-07-24 20:52:51 +0200 |
commit | c3005b0f0c8081ccb719740c3c27ee13d5697add (patch) | |
tree | 85be9ebc4a554eb2712749c7968b5f149a50d8eb /gcc/fortran/resolve.c | |
parent | befdf74172fe5f6d61f708e152f2e54540b75f21 (diff) | |
download | gcc-c3005b0f0c8081ccb719740c3c27ee13d5697add.zip gcc-c3005b0f0c8081ccb719740c3c27ee13d5697add.tar.gz gcc-c3005b0f0c8081ccb719740c3c27ee13d5697add.tar.bz2 |
re PR fortran/33141 (Intrinsic procedures: Improve warning/error with -std=*)
2008-07-24 Daniel Kraft <d@domob.eu>
PR fortran/33141
* lang.opt (Wnonstd-intrinsics): Removed option.
(Wintrinsics-std), (Wintrinsic-shadow): New options.
* invoke.texi (Option Summary): Removed -Wnonstd-intrinsics
from the list and added -Wintrinsics-std and -Wintrinsic-shadow.
(Error and Warning Options): Documented the new options and removed
the documentation for -Wnonstd-intrinsics.
* gfortran.h (gfc_option_t): New members warn_intrinsic_shadow and
warn_intrinsics_std, removed warn_nonstd_intrinsics.
(gfc_is_intrinsic): Renamed from gfc_intrinsic_name.
(gfc_warn_intrinsic_shadow), (gfc_check_intrinsic_standard): New.
* decl.c (match_procedure_decl): Replaced gfc_intrinsic_name by
the new name gfc_is_intrinsic.
(warn_intrinsic_shadow): New helper method.
(gfc_match_function_decl), (gfc_match_subroutine): Call the new method
warn_intrinsic_shadow to check the just-parsed procedure.
* expr.c (check_init_expr): Call new gfc_is_intrinsic to check whether
the function called is really an intrinsic in the selected standard.
* intrinsic.c (gfc_is_intrinsic): Renamed from gfc_intrinsic_name and
extended to take into account the selected standard settings when trying
to find out whether a symbol is an intrinsic or not.
(gfc_check_intrinsic_standard): Made public and extended.
(gfc_intrinsic_func_interface), (gfc_intrinsic_sub_interface): Removed
the calls to check_intrinsic_standard, this check now happens inside
gfc_is_intrinsic.
(gfc_warn_intrinsic_shadow): New method defined.
* options.c (gfc_init_options): Initialize new warning flags to false
and removed intialization of Wnonstd-intrinsics flag.
(gfc_post_options): Removed logic for Wnonstd-intrinsics flag.
(set_Wall): Set new warning flags and removed Wnonstd-intrinsics flag.
(gfc_handle_option): Handle the new flags and removed handling of the
old Wnonstd-intrinsics flag.
* primary.c (gfc_match_rvalue): Replaced call to gfc_intrinsic_name by
the new name gfc_is_intrinsic.
* resolve.c (resolve_actual_arglist): Ditto.
(resolve_generic_f), (resolve_unknown_f): Ditto.
(is_external_proc): Ditto.
(resolve_generic_s), (resolve_unknown_s): Ditto.
(resolve_symbol): Ditto and ensure for symbols declared INTRINSIC that
they are really available in the selected standard setting.
2008-07-24 Daniel Kraft <d@domob.eu>
PR fortran/33141
* gfortran.dg/intrinsic_shadow_1.f03: New test for -Wintrinsic-shadow.
* gfortran.dg/intrinsic_shadow_2.f03: Ditto.
* gfortran.dg/intrinsic_shadow_3.f03: Ditto.
* gfortran.dg/intrinsic_std_1.f90: New test for -Wintrinsics-std.
* gfortran.dg/intrinsic_std_2.f90: Ditto.
* gfortran.dg/intrinsic_std_3.f90: Ditto.
* gfortran.dg/intrinsic_std_4.f90: Ditto.
* gfortran.dg/warn_std_1.f90: Removed option -Wnonstd-intrinsics.
* gfortran.dg/warn_std_2.f90: Replaced -Wnonstd-intrinsics by
-Wintrinsics-std and adapted expected errors/warnings.
* gfortran.dg/warn_std_3.f90: Ditto.
* gfortran.dg/c_sizeof_2.f90: Adapted expected error/warning message.
* gfortran.dg/gamma_2.f90: Ditto.
* gfortran.dg/selected_char_kind_3.f90: Ditto.
* gfortran.dg/fmt_g0_2.f08: Call with -fall-intrinsics to allow abort.
From-SVN: r138122
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 056ff0e..0b27da1 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1076,7 +1076,7 @@ resolve_actual_arglist (gfc_actual_arglist *arg, procedure_type ptype) if (!sym->attr.intrinsic && !(sym->attr.external || sym->attr.use_assoc || sym->attr.if_source == IFSRC_IFBODY) - && gfc_intrinsic_name (sym->name, sym->attr.subroutine)) + && gfc_is_intrinsic (sym, sym->attr.subroutine, e->where)) sym->attr.intrinsic = 1; if (sym->attr.proc == PROC_ST_FUNCTION) @@ -1535,7 +1535,7 @@ generic: /* Last ditch attempt. See if the reference is to an intrinsic that possesses a matching interface. 14.1.2.4 */ - if (sym && !gfc_intrinsic_name (sym->name, 0)) + if (sym && !gfc_is_intrinsic (sym, 0, expr->where)) { gfc_error ("There is no specific function for the generic '%s' at %L", expr->symtree->n.sym->name, &expr->where); @@ -1673,7 +1673,7 @@ resolve_unknown_f (gfc_expr *expr) /* See if we have an intrinsic function reference. */ - if (gfc_intrinsic_name (sym->name, 0)) + if (gfc_is_intrinsic (sym, 0, expr->where)) { if (gfc_intrinsic_func_interface (expr, 1) == MATCH_YES) return SUCCESS; @@ -1721,13 +1721,13 @@ is_external_proc (gfc_symbol *sym) { if (!sym->attr.dummy && !sym->attr.contained && !(sym->attr.intrinsic - || gfc_intrinsic_name (sym->name, sym->attr.subroutine)) + || gfc_is_intrinsic (sym, sym->attr.subroutine, sym->declared_at)) && sym->attr.proc != PROC_ST_FUNCTION && !sym->attr.use_assoc && sym->name) return true; - else - return false; + + return false; } @@ -2469,7 +2469,7 @@ generic: that possesses a matching interface. 14.1.2.4 */ sym = c->symtree->n.sym; - if (!gfc_intrinsic_name (sym->name, 1)) + if (!gfc_is_intrinsic (sym, 1, c->loc)) { gfc_error ("There is no specific subroutine for the generic '%s' at %L", sym->name, &c->loc); @@ -2748,7 +2748,7 @@ resolve_unknown_s (gfc_code *c) /* See if we have an intrinsic function reference. */ - if (gfc_intrinsic_name (sym->name, 1)) + if (gfc_is_intrinsic (sym, 1, c->loc)) { if (gfc_intrinsic_sub_interface (c, 1) == MATCH_YES) return SUCCESS; @@ -7961,24 +7961,45 @@ resolve_symbol (gfc_symbol *sym) type to avoid spurious warnings. */ if (sym->attr.flavor != FL_MODULE && sym->attr.intrinsic) { - if (gfc_intrinsic_name (sym->name, 0)) + gfc_intrinsic_sym* isym; + const char* symstd; + + /* We already know this one is an intrinsic, so we don't call + gfc_is_intrinsic for full checking but rather use gfc_find_function and + gfc_find_subroutine directly to check whether it is a function or + subroutine. */ + + if ((isym = gfc_find_function (sym->name))) { if (sym->ts.type != BT_UNKNOWN && gfc_option.warn_surprising) - gfc_warning ("Type specified for intrinsic function '%s' at %L is ignored", - sym->name, &sym->declared_at); + gfc_warning ("Type specified for intrinsic function '%s' at %L is" + " ignored", sym->name, &sym->declared_at); } - else if (gfc_intrinsic_name (sym->name, 1)) + else if ((isym = gfc_find_subroutine (sym->name))) { if (sym->ts.type != BT_UNKNOWN) { - gfc_error ("Intrinsic subroutine '%s' at %L shall not have a type specifier", - sym->name, &sym->declared_at); + gfc_error ("Intrinsic subroutine '%s' at %L shall not have a type" + " specifier", sym->name, &sym->declared_at); return; } } else { - gfc_error ("Intrinsic '%s' at %L does not exist", sym->name, &sym->declared_at); + gfc_error ("'%s' declared INTRINSIC at %L does not exist", + sym->name, &sym->declared_at); + return; + } + + /* Check it is actually available in the standard settings. */ + if (gfc_check_intrinsic_standard (isym, &symstd, false, sym->declared_at) + == FAILURE) + { + gfc_error ("The intrinsic '%s' declared INTRINSIC at %L is not" + " available in the current standard settings but %s. Use" + " an appropriate -std=* option or enable -fall-intrinsics" + " in order to use it.", + sym->name, &sym->declared_at, symstd); return; } } |