bug 1339921 - disable clang's shadowed field warning in a mozilla::pkix gtest class r=Cykesiopka,dholbert
authorDavid Keeler <dkeeler@mozilla.com>
Tue, 14 Mar 2017 15:58:04 -0700
changeset 348040 9ba79bf5e771b08b5b7e93f424f9c88083679eee
parent 348039 a0ce34028d020282ca9ed8bf1986cd16d992156e
child 348043 fbc855e10da9081c3e79b5471a782827a2149ec3
push id88135
push userkwierso@gmail.com
push dateThu, 16 Mar 2017 21:07:17 +0000
treeherdermozilla-inbound@32d95add349f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCykesiopka, dholbert
bugs1339921
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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,