Fix C/should_fail/init2.c: if there is no outer_type (error case), just go on.
[cparser] / main.c
diff --git a/main.c b/main.c
index b93ac30..3245654 100644 (file)
--- a/main.c
+++ b/main.c
@@ -71,6 +71,7 @@
 #include "lang_features.h"
 #include "driver/firm_opt.h"
 #include "driver/firm_cmdline.h"
+#include "driver/firm_timing.h"
 #include "adt/error.h"
 #include "wrappergen/write_fluffy.h"
 #include "wrappergen/write_caml.h"
@@ -332,6 +333,7 @@ static FILE *preprocess(const char *fname, filetype_t filetype)
                        obstack_1grow(&cppflags_obst, ' ');
                        obstack_grow(&cppflags_obst, flags, len);
                }
+               obstack_1grow(&cppflags_obst, '\0');
                common_flags = obstack_finish(&cppflags_obst);
        }
 
@@ -684,6 +686,7 @@ int main(int argc, char **argv)
        file_list_entry_t *files                = NULL;
        file_list_entry_t *last_file            = NULL;
        bool               construct_dep_target = false;
+       bool               do_timing            = false;
        struct obstack     file_obst;
 
        atexit(free_temp_files);
@@ -752,7 +755,7 @@ int main(int argc, char **argv)
                /* use_builtins = true; */
                /* fallthrough */
        case 3:
-               set_option("jumpthreading");
+               set_option("thread-jumps");
                set_option("if-conv");
                /* fallthrough */
        case 2:
@@ -954,9 +957,10 @@ int main(int argc, char **argv)
                                        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)
+                                       if (res == 0) {
+                                               fprintf(stderr, "Unknown architecture '%s'\n", arch_opt);
                                                argument_errors = true;
-                                       else {
+                                       else {
                                                snprintf(arch_opt, sizeof(arch_opt), "%s-opt=%s", cpu_arch, opt);
                                                int res = firm_be_option(arch_opt);
                                                if (res == 0)
@@ -1078,6 +1082,8 @@ int main(int argc, char **argv)
                                        mode = PrintCaml;
                                } else if (streq(option, "print-jna")) {
                                        mode = PrintJna;
+                               } else if (streq(option, "time")) {
+                                       do_timing = true;
                                } else if (streq(option, "version")) {
                                        print_cparser_version();
                                        exit(EXIT_SUCCESS);
@@ -1185,6 +1191,9 @@ int main(int argc, char **argv)
        init_ast2firm();
        init_mangle();
 
+       if (do_timing)
+               timer_init();
+
        if (construct_dep_target) {
                if (outname != 0 && strlen(outname) >= 2) {
                        get_output_name(dep_target, sizeof(dep_target), outname, ".d");
@@ -1363,8 +1372,10 @@ do_parsing:
                        c_mode |= features_on;
                        c_mode &= ~features_off;
 
+                       timer_push(TV_PARSING);
                        init_tokens();
                        translation_unit_t *const unit = do_parsing(in, filename);
+                       timer_pop();
 
                        /* prints the AST even if errors occurred */
                        if (mode == PrintAst) {
@@ -1406,7 +1417,9 @@ do_parsing:
                                continue;
                        }
 
+                       timer_push(TV_CONSTRUCT);
                        translation_unit_to_firm(unit);
+                       timer_pop();
 
 graph_built:
                        if (mode == ParseOnly) {
@@ -1539,6 +1552,9 @@ graph_built:
                }
        }
 
+       if (do_timing)
+               timer_term(stderr);
+
        obstack_free(&cppflags_obst, NULL);
        obstack_free(&ldflags_obst, NULL);
        obstack_free(&file_obst, NULL);