From af7a6137cc03ec0dc98bdcf39e41f4815199c2f2 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 31 Mar 2017 17:09:48 -0400 Subject: [PATCH] Bug 1291397. Work around clang bug that they didn't actually manage to ship a fix for which causes it to give spurious warnings it shouldn't be giving, which are then fatal due to -Werror. r=dholbert MozReview-Commit-ID: GbMEvoxGpH1 --- dom/bindings/Codegen.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index fde25ce82e04..dac2e65b06de 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -4690,14 +4690,24 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # For JS-implemented APIs, we refuse to allow passing objects that the # API consumer does not subsume. The extra parens around # ($${passedToJSImpl}) suppress unreachable code warnings when - # $${passedToJSImpl} is the literal `false`. + # $${passedToJSImpl} is the literal `false`. But Apple is shipping a + # buggy clang (clang 3.9) in Xcode 8.3, so there even the parens are not + # enough. So we manually disable some warnings in clang. if not isinstance(descriptorProvider, Descriptor) or descriptorProvider.interface.isJSImplemented(): templateBody = fill( """ + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wunreachable-code" + #pragma clang diagnostic ignored "-Wunreachable-code-return" + #endif // __clang__ if (($${passedToJSImpl}) && !CallerSubsumes($${val})) { ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "${sourceDescription}"); $*{exceptionCode} } + #ifdef __clang__ + #pragma clang diagnostic pop + #endif // __clang__ """, sourceDescription=sourceDescription, exceptionCode=exceptionCode) + templateBody @@ -5896,14 +5906,24 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, # For JS-implemented APIs, we refuse to allow passing objects that the # API consumer does not subsume. The extra parens around # ($${passedToJSImpl}) suppress unreachable code warnings when - # $${passedToJSImpl} is the literal `false`. + # $${passedToJSImpl} is the literal `false`. But Apple is shipping a + # buggy clang (clang 3.9) in Xcode 8.3, so there even the parens are not + # enough. So we manually disable some warnings in clang. if not isinstance(descriptorProvider, Descriptor) or descriptorProvider.interface.isJSImplemented(): templateBody = fill( """ + #ifdef __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wunreachable-code" + #pragma clang diagnostic ignored "-Wunreachable-code-return" + #endif // __clang__ if (($${passedToJSImpl}) && !CallerSubsumes($${val})) { ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "${sourceDescription}"); $*{exceptionCode} } + #ifdef __clang__ + #pragma clang diagnostic pop + #endif // __clang__ """, sourceDescription=sourceDescription, exceptionCode=exceptionCode) + templateBody