On 8 Mar 2005 at 4:59, Frank Heckenbach wrote:
Waldek Hebisch wrote:
Prof A Olowofoyeku wrote:
Which gives a warning under GPC - and I am not sure what the warning means. The declaration:
TYPE TDllFunc = FUNCTION : Pointer attribute(stdcall);
gives this warning: "warning: `stdcall' attribute only applies to function types"
I thought I was applying the attribute to a function type? So what's with the warning?
Internally there is no variables of function type. Pascal function type is really a "reference" and was not recgnized by attribute handling code. The attribute was ignored, so the call would go wrong. The following should fix the problem:
--- p/declarations.c.bb 2005-03-08 03:21:43.209468768 +0100 +++ p/declarations.c 2005-03-08 03:21:49.310541264 +0100 @@ -2089,7 +2089,10 @@ } else tt = &TREE_CHAIN (*tt);
- pascal_decl_attributes (d, attributes);
- if (TREE_CODE (*d) == POINTER_TYPE || TREE_CODE (*d) ==
- REFERENCE_TYPE)
- pascal_decl_attributes (&(TREE_TYPE (*d)), attributes);
- else
- pascal_decl_attributes (d, attributes);
}
void
OK (chief56.pas), though I think we should add this:
--- p/declarations.c.orig Tue Mar 8 04:50:42 2005 +++ p/declarations.c Tue Mar 8 04:51:37 2005 @@ -2190,8 +2190,12 @@ } else tt = &TREE_CHAIN (*tt);
- if (TREE_CODE (*d) == POINTER_TYPE || TREE_CODE (*d) ==
REFERENCE_TYPE) - pascal_decl_attributes (&(TREE_TYPE (*d)), attributes); + if ((TREE_CODE (*d) == POINTER_TYPE || TREE_CODE (*d) == REFERENCE_TYPE) + && TREE_CODE (TREE_TYPE (*d)) == FUNCTION_TYPE) + { + TREE_TYPE (*d) = build_type_copy (TREE_TYPE (*d)); + pascal_decl_attributes (&(TREE_TYPE (*d)), attributes); + } else pascal_decl_attributes (d, attributes); }
I'm not sure if the type copy is really necessary, but checking the target type is, otherwise such an attribute would go wrong:
[...]
Both patches work ok. Problem fixed. Thanks.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/