gcc/ChangeLog:

2017-03-06  Martin Liska  <mli...@suse.cz>

        PR target/65705
        PR target/69804
        * toplev.c (process_options): Disable -fcheck-pointer-bounds with
        sanitizers.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  <mli...@suse.cz>

        PR target/65705
        PR target/69804
        * gcc.target/i386/pr71458.c: Update scanned pattern.
---
 gcc/testsuite/gcc.target/i386/pr71458.c |  2 +-
 gcc/toplev.c                            | 29 +++++++++++++----------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c 
b/gcc/testsuite/gcc.target/i386/pr71458.c
index 27e7764b5a0..2faf6bb9391 100644
--- a/gcc/testsuite/gcc.target/i386/pr71458.c
+++ b/gcc/testsuite/gcc.target/i386/pr71458.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target { ! x32 } } } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */
-/* { dg-error "-fcheck-pointer-bounds is not supported with -fsanitize=bounds" 
"" { target *-*-* } 0 } */
+/* { dg-error "-fcheck-pointer-bounds is not supported with Undefined Behavior 
Sanitizer" "" { target *-*-* } 0 } */
 
 enum {} a[0];
 void fn1(int);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index beb581aba55..b8f87b878da 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1274,22 +1274,19 @@ process_options (void)
          flag_check_pointer_bounds = 0;
        }
 
-      if (flag_sanitize & SANITIZE_ADDRESS)
-       {
-         error_at (UNKNOWN_LOCATION,
-                   "-fcheck-pointer-bounds is not supported with "
-                   "Address Sanitizer");
-         flag_check_pointer_bounds = 0;
-       }
-
-      if (flag_sanitize & SANITIZE_BOUNDS)
-       {
-         error_at (UNKNOWN_LOCATION,
-                   "-fcheck-pointer-bounds is not supported with "
-                   "-fsanitize=bounds");
-         flag_check_pointer_bounds = 0;
-       }
-
+      const char *sanitizer_names[] = { "Address", "Undefined Behavior",
+       "Leak", "Thread" };
+      const int sanitizer_flags[] = { SANITIZE_ADDRESS, SANITIZE_UNDEFINED,
+       SANITIZE_LEAK, SANITIZE_THREAD };
+
+      for (unsigned i = 0; i < sizeof (sanitizer_flags) / sizeof (int); i++)
+       if (flag_sanitize & sanitizer_flags[i])
+         {
+           error_at (UNKNOWN_LOCATION,
+                     "-fcheck-pointer-bounds is not supported with "
+                     "%s Sanitizer", sanitizer_names[i]);
+           flag_check_pointer_bounds = 0;
+         }
     }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.11.1


Reply via email to