diff mbox

[Fortran] PR54389 - DECL_PURE_P: set for implicit_pure but not for impure elemental

Message ID 503C8692.2090003@net-b.de
State New
Headers show

Commit Message

Tobias Burnus Aug. 28, 2012, 8:51 a.m. UTC
DECL_PURE_P was also set for elemental procedures, which is wrong if 
they are IMPURE.

Additionally, we do the same checks for PURE also for 
attr.implicit_pure. I think the checks are strict enough that we can 
dare to set DECL_PURE_P also for gfortran's attr.implicit_pure 
procedures. What do you think?

Build on x86-64-linux. (I will also regtest it.)
OK for the trunk?

Tobias

Comments

Mikael Morin Aug. 28, 2012, 6:05 p.m. UTC | #1
On 28/08/2012 10:51, Tobias Burnus wrote:
> DECL_PURE_P was also set for elemental procedures, which is wrong if
> they are IMPURE.
> 
> Additionally, we do the same checks for PURE also for
> attr.implicit_pure. I think the checks are strict enough that we can
> dare to set DECL_PURE_P also for gfortran's attr.implicit_pure
> procedures. What do you think?
Let's try.

> 
> Build on x86-64-linux. (I will also regtest it.)
> OK for the trunk?
OK (if it passes).

Mikael
diff mbox

Patch

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

        PR fortran/54389
	* trans-decl.c (gfc_get_extern_function_decl,
	build_function_decl): Don't mark impure elemental
	functions as DECL_PURE_P and honour implicit_pure.

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 35a859b..7e59cb6 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1783,7 +1783,7 @@  gfc_get_extern_function_decl (gfc_symbol * sym)
   /* Set attributes for PURE functions. A call to PURE function in the
      Fortran 95 sense is both pure and without side effects in the C
      sense.  */
-  if (sym->attr.pure || sym->attr.elemental)
+  if (sym->attr.pure || sym->attr.implicit_pure)
     {
       if (sym->attr.function && !gfc_return_by_reference (sym))
 	DECL_PURE_P (fndecl) = 1;
@@ -1912,7 +1912,7 @@  build_function_decl (gfc_symbol * sym, bool global)
   /* Set attributes for PURE functions. A call to a PURE function in the
      Fortran 95 sense is both pure and without side effects in the C
      sense.  */
-  if (attr.pure || attr.elemental)
+  if (attr.pure || attr.implicit_pure)
     {
       /* TODO: check if a pure SUBROUTINE has no INTENT(OUT) arguments
 	 including an alternate return. In that case it can also be