[m-dev.] diff: MLDS back-end fix for #line problem with #define MR_PROC_LABEL

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Aug 11 13:15:10 AEST 2000


Estimated hours taken: 1

Fix a bug where the MLDS back-end was generating #line directives in
the middle of #defines when outputting the `#define MR_PROC_LABEL' for
pragma c_code.

compiler/mlds_to_c.m:
	Don't output #line directives for name/1 target_code_components.

compiler/mlds.m:
	Document the above change.

Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.30
diff -u -d -r1.30 mlds.m
--- compiler/mlds.m	2000/08/09 07:47:15	1.30
+++ compiler/mlds.m	2000/08/11 03:04:49
@@ -921,8 +921,11 @@
 			% raw_target_code holds C code that the
 			% compiler has generated.  To ensure that
 			% following `#line' directives work OK,
-			% the string in a raw_target_code must
-			% end in `\n' (or `\n' followed by whitespace).
+			% either the string in a raw_target_code must
+			% end in `\n' (or `\n' followed by whitespace),
+			% or the following target_code_component must be 
+			% a `name(Name)' component, for which we do not
+			% output #line directives.
 	;	target_code_input(mlds__rval)
 	;	target_code_output(mlds__lval)
 	;	name(mlds__entity_name)
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.50
diff -u -d -r1.50 mlds_to_c.m
--- compiler/mlds_to_c.m	2000/08/09 07:47:16	1.50
+++ compiler/mlds_to_c.m	2000/08/11 03:02:13
@@ -2464,8 +2464,13 @@
 	mlds_output_lval(Lval),
 	io__write_string("\n").
 mlds_output_target_code_component(ModuleName, _Context, name(Name)) -->
-	mlds_output_fully_qualified_name(qual(ModuleName, Name)).
-	
+	% Note: `name(Name)' target_code_components are used to
+	% generate the #define for `MR_PROC_LABEL'.
+	% The fact that they're used in a #define means that we can't do
+	% an mlds_output_context(Context) here, since #line directives
+	% aren't allowed inside #defines.
+	mlds_output_fully_qualified_name(qual(ModuleName, Name)),
+	io__write_string("\n").
 
 :- pred mlds_output_init_args(list(mlds__rval), list(mlds__type), mlds__context,
 		int, mlds__lval, mlds__tag, indent, io__state, io__state).

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