diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc5f2f53b7f5586c6a23560ef3d269a890bf83ed..d9efc18cfe2e0863853c2c69ac98022acbf294d8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-17  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* tree-nomudflap.c (gate_mudflap): New static function.
+	(pass_mudflap_1): Use it as gate function.
+	(pass_mudflap_2): Likewise.
+
 2007-09-17  Jan Hubicka  <jh@suse.cz>
 
 	PR middle-end/33348
diff --git a/gcc/tree-nomudflap.c b/gcc/tree-nomudflap.c
index e48aff2cb96ed25ea088c18d2da8cf3ff8170e0f..a59b9da0b4ededf095bf9404f894408b015ef6e3 100644
--- a/gcc/tree-nomudflap.c
+++ b/gcc/tree-nomudflap.c
@@ -84,10 +84,16 @@ mf_mark (tree t ATTRIBUTE_UNUSED)
 
 /* The pass structures must exist, but need not do anything.  */
 
+static bool
+gate_mudflap (void)
+{
+  return flag_mudflap != 0;
+}
+
 struct tree_opt_pass pass_mudflap_1 = 
 {
   "mudflap1",				/* name */
-  NULL,					/* gate */
+  gate_mudflap,                         /* gate */
   NULL,					/* execute */
   NULL,					/* sub */
   NULL,					/* next */
@@ -104,7 +110,7 @@ struct tree_opt_pass pass_mudflap_1 =
 struct tree_opt_pass pass_mudflap_2 = 
 {
   "mudflap2",				/* name */
-  NULL,					/* gate */
+  gate_mudflap,                         /* gate */
   NULL,					/* execute */
   NULL,					/* sub */
   NULL,					/* next */