diff options
| author | welinder@troll.com <welinder@troll.com> | 2004-10-07 12:47:04 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:03:31 -0700 |
| commit | 0f294b33a6c6f0052ff45f366eea49f56e36bc33 (patch) | |
| tree | f208b14b6486c65f5a0a04aa4211435494213b92 | |
| parent | 3bc7425b7a1e6bbc4890a42266d8a568074e83fc (diff) | |
| download | sparse-dev-0f294b33a6c6f0052ff45f366eea49f56e36bc33.tar.gz | |
lib.c:
Handle -U.
cgcc:
Teach cgcc about "-v".
Teach cgcc not to run compiler when "-E" is seen.
Add define for __SIZE_TYPE__.
| -rw-r--r-- | cgcc | 30 | ||||
| -rw-r--r-- | lib.c | 14 |
2 files changed, 38 insertions, 6 deletions
@@ -8,6 +8,7 @@ my $m64 = 0; my $has_specs = 0; my $do_check = 0; my $do_compile = 1; +my $verbose = 0; foreach (@ARGV) { # Look for a .c file. We don't want to run the checker on .o or .so files @@ -23,11 +24,16 @@ foreach (@ARGV) { next; } - if (/^-no-compile$/) { + if ($_ eq '-no-compile') { $do_compile = 0; next; } + # If someone adds "-E", don't pre-process twice. + $do_compile = 0 if $_ eq '-E'; + + $verbose = 1 if $_ eq '-v'; + my $this_arg = ' ' . "e_arg ($_); $cc .= $this_arg unless &check_only_option ($_); $check .= $this_arg; @@ -39,9 +45,11 @@ if ($do_check) { if ($arch =~ /^(i.?86|athlon)$/) { $check .= &integer_types (8, 16, 32, $m64 ? 64 : 32, 64); $check .= &float_types (1, 1, 21, [24,8], [53,11], [64,15]); + $check .= &define_size_t ($m64 ? "long unsigned int" : "unsigned int"); } elsif ($arch =~ /^(sun4u)$/) { $check .= &integer_types (8, 16, 32, $m64 ? 64 : 32, 64); $check .= &float_types (1, 1, 33, [24,8], [53,11], [113,15]); + $check .= &define_size_t ($m64 ? "long unsigned int" : "unsigned int"); } if (!$has_specs) { @@ -49,14 +57,20 @@ if ($do_check) { chomp $os; $check .= &add_specs (lc $os); } +} -# print "$check\n"; + +if ($do_check) { + print "$check\n" if $verbose; # exit 1; + system ($check); } +if ($do_compile) { + print "$cc\n" if $verbose; + exec ($cc); +} -system ($check) if $do_check; -exec ($cc) if $do_compile; exit 0; # ----------------------------------------------------------------------------- @@ -174,6 +188,14 @@ sub float_types { # ----------------------------------------------------------------------------- +sub define_size_t { + my ($text) = @_; + # We have to undef in order to override checks internal definition. + return ' -U__SIZE_TYPE__ ' . "e_arg ("-D__SIZE_TYPE__=$text"); +} + +# ----------------------------------------------------------------------------- + sub add_specs { my ($spec) = @_; if ($spec eq 'sunos') { @@ -677,7 +677,7 @@ char **handle_switch_o(char *arg, char **next) return next; // "-ofoo" or (bogus) terminal "-o" } -struct warning { +const struct warning { const char *name; int *flag; } warnings[] = { @@ -713,6 +713,15 @@ char **handle_switch_W(char *arg, char **next) return next; } +char **handle_switch_U(char *arg, char **next) +{ + const char *name = arg + 1; + add_pre_buffer ("#undef %s\n", name); + return next; +} + + + char **handle_nostdinc(char *arg, char **next) { add_pre_buffer("#nostdinc\n"); @@ -736,12 +745,13 @@ char **handle_switch(char *arg, char **next) switch (*arg) { case 'D': rc = handle_switch_D(arg, next); break; case 'E': rc = handle_switch_E(arg, next); break; - case 'v': rc = handle_switch_v(arg, next); break; case 'I': rc = handle_switch_I(arg, next); break; case 'i': rc = handle_switch_i(arg, next); break; case 'M': rc = handle_switch_M(arg, next); break; case 'm': rc = handle_switch_m(arg, next); break; case 'o': rc = handle_switch_o(arg, next); break; + case 'U': rc = handle_switch_U(arg, next); break; + case 'v': rc = handle_switch_v(arg, next); break; case 'W': rc = handle_switch_W(arg, next); break; default: break; |
