bug 1339921 - disable clang's shadowed field warning in a mozilla::pkix gtest class r?Cykesiopka,dholbert draft
authorDavid Keeler <dkeeler@mozilla.com>
Tue, 14 Mar 2017 15:58:04 -0700
changeset 500140 61f932ba2d2463fdd943aab3d02a0730dfef0533
parent 500108 3945f2297b997d59662bdb8ac20e092363eea532
child 549543 5ef47e0dc02fc25fabbf1e99f839ae5cee414032
push id49619
push userbmo:dkeeler@mozilla.com
push dateThu, 16 Mar 2017 17:07:00 +0000
reviewersCykesiopka, dholbert
bugs1339921
milestone55.0a1
bug 1339921 - disable clang's shadowed field warning in a mozilla::pkix gtest class r?Cykesiopka,dholbert pkixocsp_VerifyEncodedResponse_GetCertTrust has a field trustDomain that deliberately shadows the field it inherits from so that code doesn't use it by accident. MozReview-Commit-ID: 1Y4W6sA7lHD
security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
--- a/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
+++ b/security/pkix/test/gtest/pkixocsp_VerifyEncodedOCSPResponse.cpp
@@ -994,17 +994,33 @@ public:
       trustLevel = certTrustLevel;
       return Success;
     }
 
     ByteString certDER;
     TrustLevel certTrustLevel;
   };
 
+// trustDomain deliberately shadows the inherited field so that it isn't used
+// by accident. See bug 1339921.
+// Unfortunately GCC can't parse __has_warning("-Wshadow-field") even if it's
+// the latter part of a conjunction that would evaluate to false, so we have to
+// wrap it in a separate preprocessor conditional rather than using &&.
+#if defined(__clang__)
+  #if __has_warning("-Wshadow-field")
+    #pragma clang diagnostic push
+    #pragma clang diagnostic ignored "-Wshadow-field"
+  #endif
+#endif
   TrustDomain trustDomain;
+#if defined(__clang__)
+  #if __has_warning("-Wshadow-field")
+    #pragma clang diagnostic pop
+  #endif
+#endif
   ByteString signerCertDER;
   ByteString responseString;
   Input response; // references data in responseString
 };
 
 TEST_F(pkixocsp_VerifyEncodedResponse_GetCertTrust, InheritTrust)
 {
   ASSERT_TRUE(trustDomain.SetCertTrust(signerCertDER,