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]

[Patch, Fortran] Fix CRITICAL handling with -fcoarray=lib


It turned out that the CRITICAL patch had two issues:

a) The lock variable was named "__lock_var@0". That's unambiguous but the linker didn't like the file name. As the variable is unused (only the associated token gets used), the assembler error only occurred with -O0 and hence not in the test suite. That's now fixed by using valid mangled name; I did the same for the type, which shouldn't show up in the assembly except for the DWARF type output. But for completeness, I have also mangled it properly.

b) I somehow mixed up the arguments of LOCK; the lock_acquired argument is a pointer to a Boolean variable, telling whether the lock could be obtained. For CRITICAL, we want to pass NULL, which means that LOCK waits until the lock can be obtained. That issue was caught by coarray/sync_{1,3}.f90, but somehow, I had missed it.

Committed as obvious in Rev. 214029.

Tobias
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 214027)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2014-08-15  Tobias Burnus  <burnus@net-b.de>
+
+	* resolve.c (resolve_critical): Fix name mangling.
+	* trans-stmt.c (gfc_trans_critical): Fix lock call.
+
 2014-08-15  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
 	PR fortran/44054
Index: resolve.c
===================================================================
--- resolve.c	(revision 214027)
+++ resolve.c	(working copy)
@@ -8485,13 +8485,14 @@ resolve_critical (gfc_code *code)
   if (gfc_option.coarray != GFC_FCOARRAY_LIB)
     return;
 
-  symtree = gfc_find_symtree (gfc_current_ns->sym_root, "__lock_type@0");
+  symtree = gfc_find_symtree (gfc_current_ns->sym_root,
+			      GFC_PREFIX ("lock_type"));
   if (symtree)
     lock_type = symtree->n.sym;
   else
     {
-      if (gfc_get_sym_tree ("__lock_type@0", gfc_current_ns, &symtree,
-	  false) != 0)
+      if (gfc_get_sym_tree (GFC_PREFIX ("lock_type"), gfc_current_ns, &symtree,
+			    false) != 0)
 	gcc_unreachable ();
       lock_type = symtree->n.sym;
       lock_type->attr.flavor = FL_DERIVED;
@@ -8500,7 +8501,7 @@ resolve_critical (gfc_code *code)
       lock_type->intmod_sym_id = ISOFORTRAN_LOCK_TYPE;
     }
 
-  sprintf(name, "__lock_var@%d",serial++);
+  sprintf(name, GFC_PREFIX ("lock_var") "%d",serial++);
   if (gfc_get_sym_tree (name, gfc_current_ns, &symtree, false) != 0)
     gcc_unreachable ();
 
Index: trans-stmt.c
===================================================================
--- trans-stmt.c	(revision 214027)
+++ trans-stmt.c	(working copy)
@@ -1121,7 +1121,7 @@ gfc_trans_critical (gfc_code *code)
       token = GFC_TYPE_ARRAY_CAF_TOKEN (TREE_TYPE (token));
       tmp = build_call_expr_loc (input_location, gfor_fndecl_caf_lock, 7,
 				 token, integer_zero_node, integer_one_node,
-				 boolean_true_node, null_pointer_node,
+				 null_pointer_node, null_pointer_node,
 				 null_pointer_node, integer_zero_node);
       gfc_add_expr_to_block (&block, tmp);
     }

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