+ } else if(option[0] == 'W') {
+ if(strncmp(option + 1, "l,", 2) == 0) // a gcc-style linker option
+ {
+ const char *opt;
+ GET_ARG_AFTER(opt, "-Wl,");
+ add_flag(&ldflags_obst, "%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(strncmp(opt, "arch=", 5) == 0) {
+ 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(strncmp(opt, "tune=", 5) == 0) {
+ 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(strncmp(opt, "cpu=", 4) == 0) {
+ 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(strncmp(opt, "fpmath=", 7) == 0) {
+ GET_ARG_AFTER(opt, "-mfpmath=");
+ if(strcmp(opt, "387") == 0)
+ opt = "x87";
+ else if(strcmp(opt, "sse") == 0)
+ 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(strncmp(opt, "preferred-stack-boundary=", 25) == 0) {
+ 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(strcmp(opt, "omit-leaf-frame-pointer") == 0) {
+ set_be_option("omitleaffp=1");
+ } else if(strcmp(opt, "no-omit-leaf-frame-pointer") == 0) {
+ 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(strcmp(option, "pg") == 0) {
+ set_be_option("gprof");
+ add_flag(&ldflags_obst, "-pg");
+ } else if(strcmp(option, "pedantic") == 0) {
+ fprintf(stderr, "warning: ignoring gcc option '%s'\n", arg);
+ } else if(strcmp(option, "shared") == 0) {
+ add_flag(&ldflags_obst, "-shared");
+ } else if(strncmp(option, "std=", 4) == 0) {
+ if(strcmp(&option[4], "c99") == 0) {
+ c_mode = _C89|_C99;
+ } else if(strcmp(&option[4], "c89") == 0) {
+ c_mode = _C89;
+ } else if(strcmp(&option[4], "gnu99") == 0) {
+ c_mode = _C89|_C99|_GNUC;
+ } else if(strcmp(&option[4], "microsoft") == 0) {
+ c_mode = _C89|_C99|_MS;
+ } else
+ fprintf(stderr, "warning: ignoring gcc option '%s'\n", arg);
+ } else if(strcmp(option, "version") == 0) {
+ print_cparser_version();
+ } else if (option[0] == '-') {
+ /* double dash option */
+ ++option;
+ if(strcmp(option, "gcc") == 0) {
+ c_mode |= _GNUC;
+ } else if(strcmp(option, "no-gcc") == 0) {
+ c_mode &= ~_GNUC;
+ } else if(strcmp(option, "ms") == 0) {
+ c_mode |= _MS;
+ } else if(strcmp(option, "no-ms") == 0) {
+ c_mode &= ~_MS;
+ } else if(strcmp(option, "signed-chars") == 0) {
+ char_is_signed = true;
+ } else if(strcmp(option, "unsigned-chars") == 0) {
+ char_is_signed = false;
+ } else if(strcmp(option, "strict") == 0) {
+ strict_mode = true;
+ } else if(strcmp(option, "lextest") == 0) {
+ mode = LexTest;
+ } else if(strcmp(option, "benchmark") == 0) {
+ mode = BenchmarkParser;
+ } else if(strcmp(option, "print-ast") == 0) {
+ mode = PrintAst;
+ } else if(strcmp(option, "print-implicit-cast") == 0) {
+ print_implicit_casts = true;
+ } else if(strcmp(option, "print-parenthesis") == 0) {
+ print_parenthesis = true;
+ } else if(strcmp(option, "print-fluffy") == 0) {
+ mode = PrintFluffy;
+ } else if(strcmp(option, "print-caml") == 0) {
+ mode = PrintCaml;
+ } else if(strcmp(option, "version") == 0) {
+ print_cparser_version();
+ exit(EXIT_SUCCESS);
+ } else if(strcmp(option, "dump-function") == 0) {
+ ++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;