On the PS4, the default C standard is C99 which differs from the current default of C11. This patch makes the default C99 when targeting the PS4. This change also renames the test ps4-cpu-defaults.cpp to ps4-misc-defaults.cpp so that the test I added for this makes more sense given the test filename.
What's the motivation for this change? Clang's C11 mode should accept all code accepted by its C99 mode (and conversely, most or perhaps all of the C11 language features are accepted by default in C99 mode as an extension). Is the problem the C11 standard library extensions?
From my understanding, there are 2 issues that block us. The first is that we currently do not ship all of the header files for C11. The second is that we do not yet fully have C11 library support yet for our platform.
How do things go wrong if Clang is used in C11 mode against a C99 library? Do you have code that conditionally uses C11 library features if they're available? (And thanks for explaining, by the way; this is useful information for when we next consider changing the default language mode -- we'll likely be changing the default C++ language mode soon.)
Anyway, it seems reasonable for the PS4 toolchain to control its defaults here, and the patch itself LGTM.
My understanding is that we currently do not ship all of the headers required for C11, so if users tried to use anything from those, they would be unable to do so. I am also under the impression that C11 requires some library support which we do not yet provide.
Thanks for the quick review!
To confirm and more directly answer your questions, we haven't encountered any situations where things have gone wrong when compiling in C11 mode against a C99 library. As far as we're aware, Clang doesn't have any problems in that area (e.g., we don't know of any situations where Clang in C11 mode is rejecting valid C99 code). We're just being conservative, in that since we don't provide C11 libraries and headers (and therefore we officially tell our customers we don't support C11), we don't want to run into situations where customers might conditionally enable a C11 library feature. We may revisit that approach sometime in the future depending on customer demand for C11 features, but at this point, we're defaulting to C99 just to be conservative.
Privately, PS4 defaults to C++11; we haven't sent that patch upstream because it would make tests fail on the PS4 bot. :-) This is the work Charles Li has been doing, to get the tests ready for the dialect change.