diff mbox

[GOOGLE] Disallow importing modules with different --std

Message ID CAO2gOZV6u7dH1gHLHa_vf8aBoPUH_M6LtHsXDB_3LQ+BUHn_zA@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen April 27, 2013, 2:57 a.m. UTC
This patch forbids modules to be imported as aux module if its --std
is different with the primary module.

Bootstrapped and passed regression test.

OK for google branches?

Thanks,
Dehao

   for (i = 0; force_matching_cg_opts[i].opt_str; i++)
@@ -426,6 +427,8 @@ incompatible_cl_args (struct gcov_module_info* mod
         char *option_string = mod_info1->string_array[start_index1 + i];

         check_cg_opts (cg_opts1, option_string);
+ if (strstr (option_string, "-std="))
+  std_opts1 = option_string;

         slot = htab_find_slot (option_tab1, option_string, INSERT);
         if (!*slot)
@@ -445,6 +448,8 @@ incompatible_cl_args (struct gcov_module_info* mod
         char *option_string = mod_info2->string_array[start_index2 + i];

         check_cg_opts (cg_opts2, option_string);
+ if (strstr (option_string, "-std="))
+  std_opts2 = option_string;

         slot = htab_find_slot (option_tab2, option_string, INSERT);
         if (!*slot)
@@ -454,6 +459,10 @@ incompatible_cl_args (struct gcov_module_info* mod
           }
       }

+  has_incompatible_std =
+      std_opts1 != std_opts2 && (std_opts1 == NULL || std_opts2 == NULL
+ || strcmp (std_opts1, std_opts2));
+
   /* Compare warning options. If these mismatch, we emit a warning.  */
   if (num_warning_opts1 != num_warning_opts2)
     warning_mismatch = true;
@@ -498,7 +507,7 @@ incompatible_cl_args (struct gcov_module_info* mod
    htab_delete (option_tab1);
    htab_delete (option_tab2);
    return ((flag_ripa_disallow_opt_mismatch && non_warning_mismatch)
-           || has_any_incompatible_cg_opts);
+           || has_any_incompatible_cg_opts || has_incompatible_std);
 }

 /* Support for module sorting based on user specfication.  */

Comments

Xinliang David Li April 27, 2013, 4:23 a.m. UTC | #1
ok with benchmark testing.

Need to be in all google branches (47, 48 and main)

David

On Fri, Apr 26, 2013 at 7:57 PM, Dehao Chen <dehao@google.com> wrote:
> This patch forbids modules to be imported as aux module if its --std
> is different with the primary module.
>
> Bootstrapped and passed regression test.
>
> OK for google branches?
>
> Thanks,
> Dehao
>
> Index: gcc/coverage.c
> ===================================================================
> --- gcc/coverage.c (revision 198353)
> +++ gcc/coverage.c (working copy)
> @@ -384,6 +384,7 @@ incompatible_cl_args (struct gcov_module_info* mod
>    char **warning_opts2 = XNEWVEC (char *, mod_info2->num_cl_args);
>    char **non_warning_opts1 = XNEWVEC (char *, mod_info1->num_cl_args);
>    char **non_warning_opts2 = XNEWVEC (char *, mod_info2->num_cl_args);
> +  char *std_opts1 = NULL, *std_opts2 = NULL;
>    unsigned int i, num_warning_opts1 = 0, num_warning_opts2 = 0;
>    unsigned int num_non_warning_opts1 = 0, num_non_warning_opts2 = 0;
>    bool warning_mismatch = false;
> @@ -396,7 +397,7 @@ incompatible_cl_args (struct gcov_module_info* mod
>      mod_info2->num_bracket_paths + mod_info2->num_cpp_defines +
>      mod_info2->num_cpp_includes;
>
> -  bool *cg_opts1, *cg_opts2, has_any_incompatible_cg_opts;
> +  bool *cg_opts1, *cg_opts2, has_any_incompatible_cg_opts,
> has_incompatible_std;
>    unsigned int num_cg_opts = 0;
>
>    for (i = 0; force_matching_cg_opts[i].opt_str; i++)
> @@ -426,6 +427,8 @@ incompatible_cl_args (struct gcov_module_info* mod
>          char *option_string = mod_info1->string_array[start_index1 + i];
>
>          check_cg_opts (cg_opts1, option_string);
> + if (strstr (option_string, "-std="))
> +  std_opts1 = option_string;
>
>          slot = htab_find_slot (option_tab1, option_string, INSERT);
>          if (!*slot)
> @@ -445,6 +448,8 @@ incompatible_cl_args (struct gcov_module_info* mod
>          char *option_string = mod_info2->string_array[start_index2 + i];
>
>          check_cg_opts (cg_opts2, option_string);
> + if (strstr (option_string, "-std="))
> +  std_opts2 = option_string;
>
>          slot = htab_find_slot (option_tab2, option_string, INSERT);
>          if (!*slot)
> @@ -454,6 +459,10 @@ incompatible_cl_args (struct gcov_module_info* mod
>            }
>        }
>
> +  has_incompatible_std =
> +      std_opts1 != std_opts2 && (std_opts1 == NULL || std_opts2 == NULL
> + || strcmp (std_opts1, std_opts2));
> +
>    /* Compare warning options. If these mismatch, we emit a warning.  */
>    if (num_warning_opts1 != num_warning_opts2)
>      warning_mismatch = true;
> @@ -498,7 +507,7 @@ incompatible_cl_args (struct gcov_module_info* mod
>     htab_delete (option_tab1);
>     htab_delete (option_tab2);
>     return ((flag_ripa_disallow_opt_mismatch && non_warning_mismatch)
> -           || has_any_incompatible_cg_opts);
> +           || has_any_incompatible_cg_opts || has_incompatible_std);
>  }
>
>  /* Support for module sorting based on user specfication.  */
diff mbox

Patch

Index: gcc/coverage.c
===================================================================
--- gcc/coverage.c (revision 198353)
+++ gcc/coverage.c (working copy)
@@ -384,6 +384,7 @@  incompatible_cl_args (struct gcov_module_info* mod
   char **warning_opts2 = XNEWVEC (char *, mod_info2->num_cl_args);
   char **non_warning_opts1 = XNEWVEC (char *, mod_info1->num_cl_args);
   char **non_warning_opts2 = XNEWVEC (char *, mod_info2->num_cl_args);
+  char *std_opts1 = NULL, *std_opts2 = NULL;
   unsigned int i, num_warning_opts1 = 0, num_warning_opts2 = 0;
   unsigned int num_non_warning_opts1 = 0, num_non_warning_opts2 = 0;
   bool warning_mismatch = false;
@@ -396,7 +397,7 @@  incompatible_cl_args (struct gcov_module_info* mod
     mod_info2->num_bracket_paths + mod_info2->num_cpp_defines +
     mod_info2->num_cpp_includes;

-  bool *cg_opts1, *cg_opts2, has_any_incompatible_cg_opts;
+  bool *cg_opts1, *cg_opts2, has_any_incompatible_cg_opts,
has_incompatible_std;
   unsigned int num_cg_opts = 0;