On Sun Jun 15 06:26:12 2008, [email protected] wrote:
> On Sunday 15 June 2008 03:31:56 Patrick R. Michaud wrote:
>
> > On Sat, Jun 14, 2008 at 08:58:22PM -0400, Bob Rogers wrote:
> > > [...] And
> > > the easiest fix would be to decide not to support it at all.
> > +1. Another +1 if we can somehow get IMCC to report an error
> > when there's a label/symbol conflict.
>
> I think that may be possible. I'll look into it while I'm fixing
> another bug
> in register allocation today.
>
> -- c
>
The attached patch makes imcc fail more gracefully when a symreg and a
label have the same name. I'm not exactly sure if this is the kind of
fix that we're looking for, but it does report the correct line number
for rgrjr's example.
Index: t/compilers/imcc/syn/labels.t
===================================================================
--- t/compilers/imcc/syn/labels.t (revision 38180)
+++ t/compilers/imcc/syn/labels.t (working copy)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Config;
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
##############################
pir_output_is( <<'CODE', <<'OUT', "goto 1" );
@@ -56,7 +56,17 @@
/no label offset defined/
OUT
+##############################
+pir_error_output_like( <<'CODE', <<'OUT', "duplicate symbol" );
+.sub main
+ .local int foo
+ foo:
+.end
+CODE
+/duplicate symbol/
+OUT
+
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
Index: compilers/imcc/symreg.c
===================================================================
--- compilers/imcc/symreg.c (revision 38180)
+++ compilers/imcc/symreg.c (working copy)
@@ -1021,6 +1021,9 @@
{
ASSERT_ARGS(mk_local_label)
IMC_Unit * const unit = IMCC_INFO(interp)->last_unit;
+ SymReg * const s = _get_sym(&unit->hash, name);
+ if (s && s->type != VTADDRESS)
+ IMCC_fataly(interp, EXCEPTION_SYNTAX_ERROR, "duplicate symbol '%s'", name);
return _mk_address(interp, &unit->hash, name, U_add_uniq_label);
}
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev