+ } else if (option[0] == 'W') {
+ if (strstart(option + 1, "l,")) // a gcc-style linker option
+ {
+ const char *opt;
+ GET_ARG_AFTER(opt, "-Wl,");
+ add_flag(&ldflags_obst, "-Wl,%s", opt);
+ }
+ else set_warning_opt(&option[1]);
+ } else if(option[0] == 'm') {
+ /* -m options */
+ const char *opt;
+ char arch_opt[64];
+
+ GET_ARG_AFTER(opt, "-m");
+ if (strstart(opt, "arch=")) {
+ GET_ARG_AFTER(opt, "-march=");
+ snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ else {
+ snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ }
+ } else if (strstart(opt, "tune=")) {
+ GET_ARG_AFTER(opt, "-mtune=");
+ snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ } else if (strstart(opt, "cpu=")) {
+ GET_ARG_AFTER(opt, "-mcpu=");
+ snprintf(arch_opt, sizeof(arch_opt), "%s-arch=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ } else if (strstart(opt, "fpmath=")) {
+ GET_ARG_AFTER(opt, "-mfpmath=");
+ if (streq(opt, "387"))
+ opt = "x87";
+ else if (streq(opt, "sse"))
+ opt = "sse2";
+ else {
+ fprintf(stderr, "error: option -mfpumath supports only 387 or sse\n");
+ argument_errors = true;
+ }
+ if(!argument_errors) {
+ snprintf(arch_opt, sizeof(arch_opt), "%s-fpunit=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ }
+ } else if (strstart(opt, "preferred-stack-boundary=")) {
+ GET_ARG_AFTER(opt, "-mpreferred-stack-boundary=");
+ snprintf(arch_opt, sizeof(arch_opt), "%s-stackalign=%s", cpu_arch, opt);
+ int res = firm_be_option(arch_opt);
+ if (res == 0)
+ argument_errors = true;
+ } else if (streq(opt, "omit-leaf-frame-pointer")) {
+ set_be_option("omitleaffp=1");
+ } else if (streq(opt, "no-omit-leaf-frame-pointer")) {
+ set_be_option("omitleaffp=0");
+ } else {
+ char *endptr;
+ long int value = strtol(opt, &endptr, 10);
+ if (*endptr != '\0') {
+ fprintf(stderr, "error: wrong option '-m %s'\n", opt);
+ argument_errors = true;
+ }
+ if (value != 16 && value != 32 && value != 64) {
+ fprintf(stderr, "error: option -m supports only 16, 32 or 64\n");
+ argument_errors = true;
+ } else {
+ machine_size = (unsigned int)value;
+ }
+ }
+ } else if (streq(option, "pg")) {
+ set_be_option("gprof");
+ add_flag(&ldflags_obst, "-pg");
+ } else if (streq(option, "pedantic") ||
+ streq(option, "ansi")) {
+ fprintf(stderr, "warning: ignoring gcc option '%s'\n", arg);
+ } else if (streq(option, "shared")) {
+ add_flag(&ldflags_obst, "-shared");
+ } else if (strstart(option, "std=")) {
+ if (streq(&option[4], "c99")) {
+ c_mode = _C89|_C99;
+ } else if (streq(&option[4], "c89")) {
+ c_mode = _C89;
+ } else if (streq(&option[4], "gnu99")) {
+ c_mode = _C89|_C99|_GNUC;
+ } else if (streq(&option[4], "microsoft")) {
+ c_mode = _C89|_C99|_MS;
+ } else
+ fprintf(stderr, "warning: ignoring gcc option '%s'\n", arg);
+ } else if (streq(option, "version")) {
+ print_cparser_version();
+ } else if (option[0] == '-') {
+ /* double dash option */
+ ++option;
+ if (streq(option, "gcc")) {
+ c_mode |= _GNUC;
+ } else if (streq(option, "no-gcc")) {
+ c_mode &= ~_GNUC;
+ } else if (streq(option, "ms")) {
+ c_mode |= _MS;
+ } else if (streq(option, "no-ms")) {
+ c_mode &= ~_MS;
+ } else if (streq(option, "signed-chars")) {
+ char_is_signed = true;
+ } else if (streq(option, "unsigned-chars")) {
+ char_is_signed = false;
+ } else if (streq(option, "strict")) {
+ strict_mode = true;
+ } else if (streq(option, "lextest")) {
+ mode = LexTest;
+ } else if (streq(option, "benchmark")) {
+ mode = BenchmarkParser;
+ } else if (streq(option, "print-ast")) {
+ mode = PrintAst;
+ } else if (streq(option, "print-implicit-cast")) {
+ print_implicit_casts = true;
+ } else if (streq(option, "print-parenthesis")) {
+ print_parenthesis = true;
+ } else if (streq(option, "print-fluffy")) {
+ mode = PrintFluffy;
+ } else if (streq(option, "print-caml")) {
+ mode = PrintCaml;
+ } else if (streq(option, "version")) {
+ print_cparser_version();
+ exit(EXIT_SUCCESS);
+ } else if (streq(option, "dump-function")) {
+ ++i;
+ if(i >= argc) {
+ fprintf(stderr, "error: "
+ "expected argument after '--dump-function'\n");
+ argument_errors = true;
+ break;
+ }
+ dumpfunction = argv[i];
+ mode = CompileDump;
+ } else {
+ fprintf(stderr, "error: unknown argument '%s'\n", arg);
+ argument_errors = true;