From 7621f5d5fb2a0f99dc1c218778863053844d262d Mon Sep 17 00:00:00 2001
From: Volker Reichelt <reichelt@gcc.gnu.org>
Date: Thu, 20 Mar 2008 16:37:47 +0000
Subject: [PATCH] common.opt (Wmudflap): New option.

	* common.opt (Wmudflap): New option.
	* tree-mudflap.c (mf_xform_derefs_1): Guard warning by OPT_Wmudflap.
	(mx_register_decls): Likewise.
	(mudflap_finish_file): Likewise.
	* doc/invoke.texi: Document -Wno-mudflap.

	* testsuite/libmudflap.c/pass63-frag.c: New test.

From-SVN: r133385
---
 gcc/ChangeLog                                   | 10 +++++++++-
 gcc/common.opt                                  |  4 ++++
 gcc/doc/invoke.texi                             |  7 ++++++-
 gcc/tree-mudflap.c                              |  9 ++++++---
 libmudflap/ChangeLog                            |  4 ++++
 libmudflap/testsuite/libmudflap.c/pass63-frag.c |  6 ++++++
 6 files changed, 35 insertions(+), 5 deletions(-)
 create mode 100644 libmudflap/testsuite/libmudflap.c/pass63-frag.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 67e924abaf99..800769650c0d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,12 @@
-2008-03-20	Kai Tietz  <kai.tietz@onevision.com>
+2008-03-20  Volker Reichelt  <v.reichelt@netcologne.de>
+
+	* common.opt (Wmudflap): New option.
+	* tree-mudflap.c (mf_xform_derefs_1): Guard warning by OPT_Wmudflap.
+	(mx_register_decls): Likewise.
+	(mudflap_finish_file): Likewise.
+	* doc/invoke.texi: Document -Wno-mudflap.
+
+2008-03-20  Kai Tietz  <kai.tietz@onevision.com>
 
 	* c-format.c (replace_format_name_to_system_name): New.
 	(cmp_attribs): New.
diff --git a/gcc/common.opt b/gcc/common.opt
index 74b3255afc78..ae0009cf446f 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -144,6 +144,10 @@ Wmissing-noreturn
 Common Var(warn_missing_noreturn) Warning
 Warn about functions which might be candidates for __attribute__((noreturn))
 
+Wmudflap
+Common Var(warn_mudflap) Init(1) Warning
+Warn about constructs not instrumented by -fmudflap
+
 Woverflow
 Common Var(warn_overflow) Init(1) Warning
 Warn about overflow in arithmetic expressions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index fc5e8dd99b8a..1d45490c21ba 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -245,7 +245,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wlogical-op -Wlong-long @gol
 -Wmain  -Wmissing-braces  -Wmissing-field-initializers @gol
 -Wmissing-format-attribute  -Wmissing-include-dirs @gol
--Wmissing-noreturn @gol
+-Wmissing-noreturn  -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
 -Woverlength-strings  -Wpacked  -Wpadded @gol
 -Wparentheses  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
@@ -4052,6 +4052,11 @@ This option is only supported for C and Objective-C@.  It is implied by
 This option is only active when @option{-fstack-protector} is active.  It
 warns about functions that will not be protected against stack smashing.
 
+@item -Wno-mudflap
+@opindex Wno-mudflap
+Suppress warnings about constructs that cannot be instrumented by
+@option{-fmudflap}.
+
 @item -Woverlength-strings
 @opindex Woverlength-strings
 @opindex Wno-overlength-strings
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index cb0b44936016..59f4beca2b0d 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -857,7 +857,8 @@ mf_xform_derefs_1 (block_stmt_iterator *iter, tree *tp,
       break;
 
     case ARRAY_RANGE_REF:
-      warning (0, "mudflap checking not yet implemented for ARRAY_RANGE_REF");
+      warning (OPT_Wmudflap,
+	       "mudflap checking not yet implemented for ARRAY_RANGE_REF");
       return;
 
     case BIT_FIELD_REF:
@@ -1043,7 +1044,8 @@ mx_register_decls (tree decl, tree *stmt_list)
           if (tsi_end_p (initially_stmts))
 	    {
 	      if (!DECL_ARTIFICIAL (decl))
-		warning (0, "mudflap cannot track %qs in stub function",
+		warning (OPT_Wmudflap,
+			 "mudflap cannot track %qs in stub function",
 			 IDENTIFIER_POINTER (DECL_NAME (decl)));
 	    }
 	  else
@@ -1272,7 +1274,8 @@ mudflap_finish_file (void)
 
           if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
             {
-              warning (0, "mudflap cannot track unknown size extern %qs",
+              warning (OPT_Wmudflap,
+		       "mudflap cannot track unknown size extern %qs",
                        IDENTIFIER_POINTER (DECL_NAME (obj)));
               continue;
             }
diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog
index cb1ac1cf413f..178c7d0e1732 100644
--- a/libmudflap/ChangeLog
+++ b/libmudflap/ChangeLog
@@ -1,3 +1,7 @@
+2008-03-20  Volker Reichelt  <v.reichelt@netcologne.de>
+
+	* testsuite/libmudflap.c/pass63-frag.c: New test.
+
 2008-03-16  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
 	* aclocal.m4: Regenerate.
diff --git a/libmudflap/testsuite/libmudflap.c/pass63-frag.c b/libmudflap/testsuite/libmudflap.c/pass63-frag.c
new file mode 100644
index 000000000000..a5ad8f26b08f
--- /dev/null
+++ b/libmudflap/testsuite/libmudflap.c/pass63-frag.c
@@ -0,0 +1,6 @@
+/* Check -Wno-mudflap flag */
+/* { dg-do compile } */
+/* { dg-options "-fmudflap -Wno-mudflap" } */
+
+extern char x[];
+int main() { return x[3]; }  /* { dg-bogus "mudflap cannot track" } */
-- 
GitLab