aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgcc
diff options
authorwelinder@troll.com <welinder@troll.com>2004-10-07 12:47:04 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:31 -0700
commit0f294b33a6c6f0052ff45f366eea49f56e36bc33 (patch)
treef208b14b6486c65f5a0a04aa4211435494213b92 /cgcc
parent3bc7425b7a1e6bbc4890a42266d8a568074e83fc (diff)
downloadsparse-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__.
Diffstat (limited to 'cgcc')
-rw-r--r--cgcc30
1 files changed, 26 insertions, 4 deletions
diff --git a/cgcc b/cgcc
index 0c3e621f..80c85128 100644
--- a/cgcc
+++ b/cgcc
@@ -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 = ' ' . &quote_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__ ' . &quote_arg ("-D__SIZE_TYPE__=$text");
+}
+
+# -----------------------------------------------------------------------------
+
sub add_specs {
my ($spec) = @_;
if ($spec eq 'sunos') {