Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: unknown warning group '-Wdouble-promotion', ignored #1959

Open
ryandesign opened this issue Jun 13, 2020 · 0 comments
Open

error: unknown warning group '-Wdouble-promotion', ignored #1959

ryandesign opened this issue Jun 13, 2020 · 0 comments

Comments

@ryandesign
Copy link

Describe the bug
catch2 fails to build on OS X 10.10 Yosemite using the version of Apple clang in Xcode 7.2.1, the latest version that is compatible with Yosemite. The error is:

/path/to/catch2-2.12.1/projects/SelfTest/UsageTests/Condition.tests.cpp:13:41: error: unknown warning group '-Wdouble-promotion', ignored [-Werror,-Wunknown-pragmas]
#       pragma clang diagnostic ignored "-Wdouble-promotion"
                                        ^

Expected behavior
Successful build

Reproduction steps
Build catch2 with Apple clang from Xcode 7.2.1 on OS X 10.10 Yosemite.

Platform information:

  • OS: OS X 10.10 Yosemite
  • Compiler+version: Apple LLVM version 7.0.2 (clang-700.1.81)
  • Catch version: 2.12.1

Additional context

The problem is happening because Condition.tests.cpp contains this code:

#ifdef __clang__
#   pragma clang diagnostic push
#   pragma clang diagnostic ignored "-Wpadded"
// Wdouble-promotion is not supported until 3.8
#   if (__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ > 7)
#       pragma clang diagnostic ignored "-Wdouble-promotion"
#   endif    
#endif

This code fails to take into account the fact that Apple clang and open source clang use different version numbering schemes. Although this flag may have been introduced in open source clang 3.8, it was evidently not introduced in Apple clang until a later version number.

Any time you want to check the clang version number, you must first check whether you are dealing with Apple clang or open source clang. You can do this by checking whether __apple_build_version__ is defined. If it is, then it's Apple clang. If you know which Apple build version the feature was introduced in, you can compare that build version with that define.

For example, on this version of Apple clang from Xcode 7.2.1:

$ clang -dM -E - < /dev/null -Wdouble-promotion | grep -E '(clang|apple)'
warning: unknown warning option '-Wdouble-promotion'; did you mean '-Wdocumentation'? [-Wunknown-warning-option]
1 warning generated.
#define __VERSION__ "4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)"
#define __apple_build_version__ 7000181
#define __clang__ 1
#define __clang_major__ 7
#define __clang_minor__ 0
#define __clang_patchlevel__ 2
#define __clang_version__ "7.0.2 (clang-700.1.81)"

On another machine running the next version of OS X, 10.11 El Capitan, with the newer Xcode 8.2.1 that can run on that system, -Wdouble-promotion appears to be supported. Its Apple clang version info:

$ clang -dM -E - < /dev/null -Wdouble-promotion | grep -E '(clang|apple)'
#define __VERSION__ "4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)"
#define __apple_build_version__ 8000042
#define __clang__ 1
#define __clang_major__ 8
#define __clang_minor__ 0
#define __clang_patchlevel__ 0
#define __clang_version__ "8.0.0 (clang-800.0.42.1)"

So I suggest that you check if __apple_build_version__ is defined.
If yes and it's >= 8000038 then -Wdouble-promotion is supported.
If no then do your existing check using __clang_major__ and __clang_minor__.

(800.0.38 is the version number of Apple clang in Xcode 8.0, the first version of Xcode compatible with OS X 10.11 El Capitan. It is Apple's tendency to introduce new features in new major Xcode versions so I assume they introduced this flag in this version.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant