diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index 1ec800526f7d0978ab513c21d80f2f57558dace2..b79cf96f55c84b6babf4a95f5e8cffa31a9b8f3e 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -854,7 +854,7 @@ parse_optimize_options (tree args)
     {
       unsigned opt_index = decoded_options[i].opt_index;
       if (opt_index >= cl_options_count
-	  && ! (cl_options[opt_index].flags & CL_OPTIMIZATION))
+	  || ! (cl_options[opt_index].flags & CL_OPTIMIZATION))
 	{
 	  ret = false;
 	  warning (OPT_Wattributes,