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]

[Fortran,Patch,committed] PR 41034 [4.5 Regression] Wrongly rejected proc pointer assignment with CDECL (compiler-directive_1.f90)


Hi all,

I committed attached patch as obvious.

There were two problems:

a) In the pointer assign check, I did not initialize the local ext_attr,
   i.e. using DLLEXPORT for one variable but not for the other could
   show an error message, even though it shouldn't.

b) In gfc_copy_attr: I simply overwrote the "dest" by "src". However,
   the logic of gfc_copy_attr seems to be that it merges the flages,
   i.e. attr.pointer is added if "src" is "attr.pointer" but it is
   not cleared in "dest" if it isn't. Now I simply add the bits.
   The failure was for
     !GCC$ ATTRIBUTES STDCALL :: ptr
     procedure(), pointer :: ptr
   If one reverts the order, it worked.

Build and regtested (check-fortran, check libgomp) on x86-64-linux
(64 bit mode). And committed as:

Sending        fortran/ChangeLog
Sending        fortran/expr.c
Sending        fortran/symbol.c
Transmitting file data ...
Committed revision 150678.

Tobias
2009-08-12  Tobias Burnus  <burnus@net-b.de>

	PR fortran/41034
	* symbol.c (gfc_copy_attr): Merge bits instead of replace
	bits in gfc_copy_attr.
	* gfc_check_pointer_assign (gfc_check_pointer_assign):
	Initialize ext_attr bits by zero.

Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c	(revision 150675)
+++ gcc/fortran/symbol.c	(working copy)
@@ -1641,7 +1641,9 @@ gfc_copy_attr (symbol_attribute *dest, s
 {
   int is_proc_lang_bind_spec;
   
-  dest->ext_attr = src->ext_attr;
+  /* In line with the other attributes, we only add bits but do not remove
+     them; cf. also PR 41034.  */
+  dest->ext_attr |= src->ext_attr;
 
   if (src->allocatable && gfc_add_allocatable (dest, where) == FAILURE)
     goto fail;
@@ -1712,7 +1714,7 @@ gfc_copy_attr (symbol_attribute *dest, s
   if (src->cray_pointer && gfc_add_cray_pointer (dest, where) == FAILURE)
     goto fail;
   if (src->cray_pointee && gfc_add_cray_pointee (dest, where) == FAILURE)
-    goto fail;    
+    goto fail;
 
   is_proc_lang_bind_spec = (src->flavor == FL_PROCEDURE ? 1 : 0);
   if (src->is_bind_c
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c	(revision 150675)
+++ gcc/fortran/expr.c	(working copy)
@@ -3192,16 +3192,15 @@ gfc_check_pointer_assign (gfc_expr *lval
 	  && lvalue->symtree->n.sym->attr.ext_attr
 	       != rvalue->symtree->n.sym->attr.ext_attr)
 	{
-	  symbol_attribute cdecl, stdcall, fastcall;
-	  unsigned calls;
+	  symbol_attribute calls;
 
-	  gfc_add_ext_attribute (&cdecl, EXT_ATTR_CDECL, NULL);
-	  gfc_add_ext_attribute (&stdcall, EXT_ATTR_STDCALL, NULL);
-	  gfc_add_ext_attribute (&fastcall, EXT_ATTR_FASTCALL, NULL);
-	  calls = cdecl.ext_attr | stdcall.ext_attr | fastcall.ext_attr;
+	  calls.ext_attr = 0;
+	  gfc_add_ext_attribute (&calls, EXT_ATTR_CDECL, NULL);
+	  gfc_add_ext_attribute (&calls, EXT_ATTR_STDCALL, NULL);
+	  gfc_add_ext_attribute (&calls, EXT_ATTR_FASTCALL, NULL);
 
-	  if ((calls & lvalue->symtree->n.sym->attr.ext_attr)
-	      != (calls & rvalue->symtree->n.sym->attr.ext_attr))
+	  if ((calls.ext_attr & lvalue->symtree->n.sym->attr.ext_attr)
+	      != (calls.ext_attr & rvalue->symtree->n.sym->attr.ext_attr))
 	    {
 	      gfc_error ("Mismatch in the procedure pointer assignment "
 			 "at %L: mismatch in the calling convention",

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