aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--cgcc30
-rw-r--r--lib.c14
2 files changed, 38 insertions, 6 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') {
diff --git a/lib.c b/lib.c
index aa059c37..86b44485 100644
--- a/lib.c
+++ b/lib.c
@@ -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;