as7: add --no-label-warnings flag

This commit is contained in:
phil
2019-10-29 21:29:55 -04:00
parent be3f9de0e2
commit f9dbe7e946
+7 -7
View File
@@ -40,6 +40,7 @@ my $debug = 0; # Run in debug mode
my $format = 'a7out'; # output format my $format = 'a7out'; # output format
my $namelist = 0; # output n.out file my $namelist = 0; # output n.out file
my $output = 'a.out'; # output file my $output = 'a.out'; # output file
my $no_label_warnings = 0; # suppress multiply defined label warnings
# keep this near the GetOptions call to make it easy to add documentation! # keep this near the GetOptions call to make it easy to add documentation!
sub usage { sub usage {
@@ -52,6 +53,7 @@ GetOptions(
'format|f=s' => \$format, 'format|f=s' => \$format,
'namelist|n' => \$namelist, 'namelist|n' => \$namelist,
'output|o=s' => \$output, 'output|o=s' => \$output,
'no-label-warnings' => \$no_label_warnings,
) or usage(); ) or usage();
usage() if ( @ARGV < 1 ); usage() if ( @ARGV < 1 );
@@ -284,25 +286,23 @@ sub set_label
if ( defined( $Llabel{$file}{$label} ) && $Llabel{$file}{$label} != $loc ) { if ( defined( $Llabel{$file}{$label} ) && $Llabel{$file}{$label} != $loc ) {
# non-fatal: as.s doesn't even warn!!!! # non-fatal: as.s doesn't even warn!!!!
print STDERR "$file:$lineno: Local label $label multiply defined\n" print STDERR "$file:$lineno: Local label $label multiply defined\n"
if ($stage == 2); if ($stage == 2 && !$no_label_warnings);
} }
else { else {
$Llabel{$file}{$label} = $loc; $Llabel{$file}{$label} = $loc;
printf( "Set local label %s to %#o\n", $label, $loc ) if ($debug); printf( "Set local label %s to %#o\n", $label, $loc ) if ($debug);
} }
} else { } else {
# An error to have different values # original as doesn't complain about multiple definitions of labels
# (Space Travel depends on this). Now a warning (on by default)
if ( defined( $Glabel{$label} ) && $Glabel{$label} != $loc ) { if ( defined( $Glabel{$label} ) && $Glabel{$label} != $loc ) {
# non-fatal: as.s doesn't even warn!!!! print STDERR "$file:$lineno: Warning: Global label $label multiply defined\n"
print STDERR "$file:$lineno: NOTE: Global label $label multiply defined (not an error)\n" if ($stage == 2 && !$no_label_warnings);
if ($stage == 2);
} }
else {
$Glabel{$label} = $loc; $Glabel{$label} = $loc;
printf( "Set global label %s to %#o\n", $label, $loc ) if ($debug); printf( "Set global label %s to %#o\n", $label, $loc ) if ($debug);
} }
} }
}
# Get the value of a global or local label # Get the value of a global or local label
sub get_label sub get_label