[m-dev.] diff: fix "non-static follows static" warnings
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Nov 15 08:22:55 AEDT 1999
Estimated hours taken: 0.5
compiler/export.m:
Fix a bug: ensure that we declare local procedures using
`Declare_static' rather than `Declare_entry'. This fixes
some warnings issued by gcc 2.95 about "non-static declaration
follows static" that indicated places where the C code that
we generated code did not conform to the ANSI/ISO C standard.
Workspace: /d-drive/home/hg/fjh/mercury
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.28
diff -u -d -r1.28 export.m
--- compiler/export.m 1999/09/17 17:18:57 1.28
+++ compiler/export.m 1999/11/14 21:09:57
@@ -85,7 +85,7 @@
export__get_c_export_decls_2(_Preds, [], []).
export__get_c_export_decls_2(Preds, [E|ExportedProcs], C_ExportDecls) :-
E = pragma_exported_proc(PredId, ProcId, C_Function),
- get_export_info(Preds, PredId, ProcId, C_RetType,
+ get_export_info(Preds, PredId, ProcId, _Exported, C_RetType,
_DeclareReturnVal, _FailureAction, _SuccessAction,
HeadArgInfoTypes),
get_argument_declarations(HeadArgInfoTypes, no, ArgDecls),
@@ -164,7 +164,7 @@
export__to_c(_Preds, [], _Module, []).
export__to_c(Preds, [E|ExportedProcs], Module, ExportedProcsCode) :-
E = pragma_exported_proc(PredId, ProcId, C_Function),
- get_export_info(Preds, PredId, ProcId,
+ get_export_info(Preds, PredId, ProcId, Exported,
C_RetType, MaybeDeclareRetval, MaybeFail, MaybeSucceed,
ArgInfoTypes),
get_argument_declarations(ArgInfoTypes, yes, ArgDecls),
@@ -177,6 +177,12 @@
code_util__make_proc_label(Module, PredId, ProcId, ProcLabel),
llds_out__get_proc_label(ProcLabel, yes, ProcLabelString),
+ ( Exported = yes ->
+ DeclareString = "Declare_entry"
+ ;
+ DeclareString = "Declare_static"
+ ),
+
string__append_list([ "\n",
C_RetType, "\n",
C_Function, "(", ArgDecls, ")\n{\n",
@@ -189,7 +195,7 @@
"\trestore_registers();\n",
InputArgs,
"\tsave_transient_registers();\n",
- "\t{\n\tDeclare_entry(",
+ "\t{\n\t", DeclareString, "(",
ProcLabelString,
");\n",
"\t(void) MR_call_engine(ENTRY(",
@@ -213,14 +219,19 @@
% Figure out the C return type, the actions on success
% and failure, and the argument locations/modes/types
% for a given procedure.
-:- pred get_export_info(pred_table, pred_id, proc_id,
+:- pred get_export_info(pred_table, pred_id, proc_id, bool,
string, string, string, string,
assoc_list(arg_info, type)).
-:- mode get_export_info(in, in, in, out, out, out, out, out) is det.
+:- mode get_export_info(in, in, in, out, out, out, out, out, out) is det.
-get_export_info(Preds, PredId, ProcId, C_RetType,
+get_export_info(Preds, PredId, ProcId, Exported, C_RetType,
MaybeDeclareRetval, MaybeFail, MaybeSucceed, ArgInfoTypes) :-
map__lookup(Preds, PredId, PredInfo),
+ ( procedure_is_exported(PredInfo, ProcId) ->
+ Exported = yes
+ ;
+ Exported = no
+ ),
pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
pred_info_procedures(PredInfo, ProcTable),
map__lookup(ProcTable, ProcId, ProcInfo),
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list