This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Dummy procedures.


In some cases we never find out is a dummy procedure is a function or a 
subroutine. It doesn't really matter which we treat it as because it is never 
called. We just need to make sure we are consistent. Patch below fixes this.

Paul

2004-01-10  Paul Brook  <paul@codesourcery.com>

	* trans-decl.c (gfc_get_symbol_decl): Don't set subroutine attr.
	* trans-types.c (gfc_sym_type): Handle external dummy procedures.
	(gfc_return_by_reference): Correct condition.
	(gfc_get_function_type): Ditto.

	* gfortran.fortran-torture/execute/mystery_proc.f90: New test.
	* gfortran.fortran-torture/compile/mystery_proc.f90: Remove.
Index: trans-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/trans-decl.c,v
retrieving revision 1.1.2.29
diff -u -p -r1.1.2.29 trans-decl.c
--- trans-decl.c	10 Jan 2004 16:59:14 -0000	1.1.2.29
+++ trans-decl.c	11 Jan 2004 12:55:28 -0000
@@ -683,9 +683,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
   /* Catch function declarations.  Only used for actual parameters.  */
   if (sym->attr.flavor == FL_PROCEDURE)
     {
-      if (!(sym->attr.function || sym->attr.subroutine))
-	sym->attr.subroutine = 1;
-
       decl = gfc_get_extern_function_decl (sym);
       return decl;
     }
Index: trans-types.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/Attic/trans-types.c,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 trans-types.c
--- trans-types.c	12 Dec 2003 12:47:08 -0000	1.1.2.8
+++ trans-types.c	11 Jan 2004 12:55:29 -0000
@@ -888,8 +888,8 @@ gfc_build_pointer_type (gfc_symbol * sym
 
 /* Return the type for a symbol.  Special handling is required for character
    types to get the correct level of indirection.
-   For functions, returns the return type.
-   For Subroutines returns void_type_node.
+   For functions return the return type.
+   For subroutines return void_type_node.
  */
 tree
 gfc_sym_type (gfc_symbol * sym)
@@ -898,14 +898,12 @@ gfc_sym_type (gfc_symbol * sym)
   tree base_type;
   int byref;
 
-  /* It's possible thet we never find out if a dummy procedure is a function
-     or a subroutine, so assume it's a subroutine.  */
   if (sym->attr.flavor == FL_PROCEDURE && !sym->attr.function)
     return void_type_node;
 
   if (sym->backend_decl)
     {
-      if (sym->attr.function || sym->attr.subroutine)
+      if (sym->attr.function)
 	return TREE_TYPE (TREE_TYPE (sym->backend_decl));
       else
 	return TREE_TYPE (sym->backend_decl);
@@ -1103,7 +1101,7 @@ gfc_get_derived_type (gfc_symbol * deriv
 int
 gfc_return_by_reference (gfc_symbol * sym)
 {
-  if (sym->attr.subroutine)
+  if (!sym->attr.function)
     return 0;
 
   assert (sym->attr.function);
@@ -1133,8 +1131,8 @@ gfc_get_function_type (gfc_symbol * sym)
   int nstr;
   int alternate_return;
 
-  /* make sure this symbol is a function or a subroutine.  */
-  assert (sym->attr.function || sym->attr.subroutine);
+  /* Make sure this symbol is a function or a subroutine.  */
+  assert (sym->attr.flavor == FL_PROCEDURE);
 
   if (sym->backend_decl)
     return TREE_TYPE (sym->backend_decl);
@@ -1161,7 +1159,7 @@ gfc_get_function_type (gfc_symbol * sym)
       arg = f->sym;
       if (arg)
 	{
-	  if (arg->attr.function || arg->attr.subroutine)
+	  if (arg->attr.flavor == FL_PROCEDURE)
 	    {
 	      type = gfc_get_function_type (arg);
 	      type = build_pointer_type (type);
@@ -1203,7 +1201,7 @@ gfc_get_function_type (gfc_symbol * sym)
 
   if (alternate_return)
     type = integer_type_node;
-  else if (sym->attr.subroutine || gfc_return_by_reference (sym))
+  else if (!sym->attr.function || gfc_return_by_reference (sym))
     type = void_type_node;
   else
     type = gfc_sym_type (sym);

Attachment: mystery_proc.f90
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]