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.  */

Reply via email to