[m-dev.] for review: duplicate arguments in `:- pragma c_code'

Peter Ross petdr at cs.mu.OZ.AU
Fri Dec 10 12:13:41 AEDT 1999


On 10-Dec-1999, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> 
> Estimated hours taken: 1
> 
> compiler/make_hlds.m:
> 	Report errors if a variable occurs multiple times in the
> 	argument list of a `:- pragma c_code' declaration.
> 
> doc/reference_manual.texi:
> 	Document that variables should occur only once in a
> 	`:- pragma c_code' argument list.
> 

s/should/must/

> tests/invalid/Mmakefile:
> tests/invalid/pragma_c_code_dup_var.m:
> tests/invalid/pragma_c_code_dup_var.err_exp:
> 	Test case.
> 
> 
> 
> Index: compiler/make_hlds.m
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/compiler/make_hlds.m,v
> retrieving revision 1.319
> diff -u -u -r1.319 make_hlds.m
> --- make_hlds.m	1999/12/03 12:55:03	1.319
> +++ make_hlds.m	1999/12/09 22:19:10
> @@ -4485,48 +4489,94 @@
> +
> +	( { MultipleArgs = [_ | _] } ->
> +		{ ClausesInfo = ClausesInfo0 },
> +		{ Info = Info0 },
> +		prog_out__write_context(Context),
> +		io__write_string("In `:- pragma c_code' declaration for "),
> +		{ adjust_func_arity(PredOrFunc, OrigArity, Arity) },
> +		hlds_out__write_simple_call_id(
> +			PredOrFunc - PredName/OrigArity),
> +		io__write_string(":\n"),
> +		prog_out__write_context(Context),
> +		io__write_string("  error: "),
> +		(
> +			{ MultipleArgs = [MultipleArg] },
> +			io__write_string("variable `"),
> +			mercury_output_var(MultipleArg, PVarSet, no),
> +			io__write_string("' occurs multiple times\n")
> +		;
> +			{ MultipleArgs = [_, _ | _] },
> +			io__write_string("variables `"),
> +			mercury_output_vars(MultipleArgs, PVarSet, no),
> +			io__write_string(
> +				"' occur multiple times\n")
> +		),
> +		prog_out__write_context(Context),
> +		io__write_string("  in the argument list.\n"),
> +		io__set_exit_status(1)
> +	;

Use the error_util module to generate the error messages.

Also do you need to call module_info_incr_errors?

Otherwise the diff looks fine.

Pete
--------------------------------------------------------------------------
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