-
Notifications
You must be signed in to change notification settings - Fork 2
/
filter.pl
executable file
·84 lines (75 loc) · 3.47 KB
/
filter.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl -wT
use strict;
my $error = 0;
while (<>) {
chomp;
next if m!^Hint: (?:Start|End) of reading config file /home/$ENV{USER}/\.fpc\.cfg$!os;
next if m!^Free Pascal Compiler version 2\.7\.1 \[[-/0-9]+] for x86_64$!os;
next if m!^Copyright \(c\) 1993-.... by Florian Klaempfl and others$!os;
next if m!^Target OS: Linux for x86-64$!os;
next if m!^Compiling .+$!os;
next if m!^.+\([0-9]+,[0-9]+\) Hint: Parameter ".+" not used$!os;
next if m!^.+\([0-9]+,[0-9]+\) Hint: Value parameter ".+" is assigned but never used$!os;
next if m!^.+\([0-9]+,[0-9]+\) Warning: Constructor should be public$!os; # i'll use whatever visibility i want, thanks
next if m!^.+\([0-9]+,[0-9]+\) Hint: Inlining disabled$!os;
next if m!^Error: .+ppcx64 returned an error exitcode \(normal if you did not specify a source file to be compiled\)$!os;
next if m!^Linking ../bin/[-a-z_0-9]+$!os;
next if m!^[0-9]+ lines compiled, [0-9.]+ sec *$!os;
next if m!^[0-9]+ (?:hint|warning|note)\(s\) issued$!os;
if (m!^([^(]+)\(([0-9]+),([0-9]+)\) Warning: (?:Comparison might be always true due to range of constant and expression|unreachable code)$!os) {
my $file = $1;
my $line = $2;
# column is $3 but we don't care
open(FILE, $file) or die "could not open $file: $!\n";
local $_;
<FILE> for (1..$line-1);
my $statement = <FILE>;
close(FILE);
next if $statement =~ m/^ *Assert\(/os;
}
if (m!^([^(]+)\(([0-9]+),([0-9]+)\) Hint: Conversion between ordinals and pointers is not portable$!os) {
my $file = $1;
my $line = $2;
# column is $3 but we don't care
open(FILE, $file) or die "could not open $file: $!\n";
local $_;
<FILE> for (1..$line-1);
my $statement = <FILE>;
close(FILE);
next if $statement =~ m/PtrUInt\(/os;
}
if (m!^([^(]+)\(([0-9]+),([0-9]+)\) Warning: (?:Type size mismatch, possible loss of data / range check error)$!os) {
my $file = $1;
my $line = $2;
# column is $3 but we don't care
open(FILE, $file) or die "could not open $file: $!\n";
my @lines = <FILE>;
close(FILE);
if ($lines[$line-2] =~ m!^ *if \(Length\((.+)\) > [0-9]+\) then\n$!os) {
my $expression = $1;
if ($lines[$line-1] =~ m!^ *for .+ := Low\(\Q$expression\E\) to High\(\Q$expression\E\) do\n$!s or
$lines[$line-1] =~ m!^ *for .+ := High\(\Q$expression\E\) downto Low\(\Q$expression\E\) do\n$!s) {
next;
}
}
}
if (m!^([^(]+)\(([0-9]+),([0-9]+)\) (Warning: .+)$!os) {
my $file = $1;
my $line = $2;
# column is $3 but we don't care
my $message = $4;
open(FILE, $file) or die "could not open $file: $!\n";
local $_;
<FILE> for (1..$line-1);
my $statement = <FILE>;
close(FILE);
next if $statement =~ m/ {BOGUS \Q$message\E}\n$/s;
}
next if m!^.+\([0-9]+,[0-9]+\) Hint: Local const "magic." is not used$!os;
$error = 1 if m!^Fatal: Compilation aborted$!os;
print "$_\n";
}
exit 1 if $error;
# next if m!^.+\([0-9]+,[0-9]+\) Hint: Value parameter ".+" is assigned but never used$!os;
# next if m!^.+\([0-9]+,[0-9]+\) Warning: Mixing signed expressions and longwords gives a 64bit result$!os;
# next if m!^.+\([0-9]+,[0-9]+\) Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors\.$!os;