Skip to content

Commit

Permalink
Ignore -O, -W and -g and other flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 30, 2020
1 parent f688d63 commit 91438ca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ static void parse_args(int argc, char **argv) {
continue;
}

// These options are ignored for now.
if (!strncmp(argv[i], "-O", 2) ||
!strncmp(argv[i], "-W", 2) ||
!strncmp(argv[i], "-g", 2) ||
!strncmp(argv[i], "-std=", 5) ||
!strcmp(argv[i], "-ffreestanding") ||
!strcmp(argv[i], "-fno-builtin") ||
!strcmp(argv[i], "-fno-omit-frame-pointer") ||
!strcmp(argv[i], "-fno-stack-protector") ||
!strcmp(argv[i], "-fno-strict-aliasing") ||
!strcmp(argv[i], "-m64") ||
!strcmp(argv[i], "-mno-red-zone") ||
!strcmp(argv[i], "-w"))
continue;

if (argv[i][0] == '-' && argv[i][1] != '\0')
error("unknown argument: %s", argv[i]);

Expand Down
6 changes: 6 additions & 0 deletions test/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,10 @@ check -D
echo foo | $chibicc -Dfoo=bar -Ufoo -E - | grep -q foo
check -U

# ignored options
$chibicc -c -O -Wall -g -std=c11 -ffreestanding -fno-builtin \
-fno-omit-frame-pointer -fno-stack-protector -fno-strict-aliasing \
-m64 -mno-red-zone -w -o /dev/null $tmp/empty.c
check 'ignored options'

echo OK

0 comments on commit 91438ca

Please sign in to comment.