Patchwork [Fortran] PR54199 improve warning "is also the name of an intrinsic" for internal procedures

login
register
mail settings
Submitter Tobias Burnus
Date Aug. 9, 2012, 9:12 a.m.
Message ID <50237F0E.1040501@net-b.de>
Download mbox | patch
Permalink /patch/176032/
State New
Headers show

Comments

Tobias Burnus - Aug. 9, 2012, 9:12 a.m.
This patch makes the warning for internal procedures whose name is the 
same as the one of an intrinsic clearer. Initially, I though that one 
shouldn't warn for internal procedures, but others disagree. In any 
case, the warning text is better than original one.

Build and regstested on x86-64-linux.
OK for the trunk?

Tobias
Mikael Morin - Aug. 9, 2012, 11:11 a.m.
On 09/08/2012 11:12, Tobias Burnus wrote:
> This patch makes the warning for internal procedures whose name is the
> same as the one of an intrinsic clearer. Initially, I though that one
> shouldn't warn for internal procedures, but others disagree. In any
> case, the warning text is better than original one.
> 
> Build and regstested on x86-64-linux.
> OK for the trunk?

OK.

Patch

2012-08-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54199
	* intrinsic.c (gfc_warn_intrinsic_shadow): Better warning
	for internal procedures.

2012-08-09  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54199
	* gfortran.dg/intrinsic_shadow_4.f90: New.

diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 60c68fe..72b149f 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -4503,7 +4511,7 @@  gfc_warn_intrinsic_shadow (const gfc_symbol* sym, bool in_module, bool func)
     return;
 
   /* Emit the warning.  */
-  if (in_module)
+  if (in_module || sym->ns->proc_name)
     gfc_warning ("'%s' declared at %L may shadow the intrinsic of the same"
 		 " name.  In order to call the intrinsic, explicit INTRINSIC"
 		 " declarations may be required.",
--- /dev/null	2012-08-08 07:41:43.631684108 +0200
+++ gcc/gcc/testsuite/gfortran.dg/intrinsic_shadow_4.f90	2012-08-09 10:28:55.000000000 +0200
@@ -0,0 +1,12 @@ 
+! { dg-do compile }
+! { dg-options "-Wall" }
+!
+! PR fortran/54199
+!
+subroutine test()
+contains
+  real function fraction(x) ! { dg-warning "'fraction' declared at .1. may shadow the intrinsic of the same name.  In order to call the intrinsic, explicit INTRINSIC declarations may be required." }
+    real :: x
+    fraction = x
+  end function fraction
+end subroutine test