Making Clang Lit tests C++11 compatible

Li, Charles charles_li at playstation.sony.com
Thu Jul 30 16:14:52 PDT 2015


Hi Clang developers,


We, here at Sony, have changed the default C++ language standard for PlayStation 4 to C++11 instead of C++98.
When we ran the Clang Lit tests, 231 tests failed.
We are currently going through and fixing each test to allow for flexible compatibility with current and future C++ standards.
 
Attached is the first fix. This simple fix made the C++ standard dialect explicit on 5 five test file. 
Here are a brief description for each change:

  test/Lexer/cxx0x_keyword_as_cxx98.cpp
    This test checks for diagnostics on C++11 keywords when compiling on older dialects.
    For this test, I have made the C++ dialects explicit to C++98 and C++03.

  test/Lexer/has_feature_cxx0x.cpp
    This test checks for supported language features when compiling at various dialects.
    For this test, I have made the C++ dialects explicit to C++98 and C++03.

  test/Lexer/ms-extensions.cpp
    This test checks for the Warning diagnostic on user-defined literal on older dialects.
    For this test, I have made the C++ dialects explicit to C++98 and C++03.

  test/Preprocessor/macro-reserved.cpp
    This test checks for reserved keywords prior to C++11.
    For this test, I have made the C++ dialects explicit to C++98 and C++03.

  test/Preprocessor/macro-reserved-cxx11.cpp
    This test checks for reserved keywords on C++11.
    Since C++11 and C++14 share the same keywords, I have added a RUN line for C++14.
    Please let me know if you feel a separate test file should be created for C++14.


All of the above 5 tests are relatively straight forward tests checking for C++ dialect specific behavior.
I personally feel adding "-std=" flags to the RUN line of each of the above test will suffice.
While there are other tests that can be fixed with such a straight forward fix, 
many of the other tests will require more nuanced modifications to the test code in order to 
accommodate for finer differences in the C++ dialects.
I hope to expand the scope of the discussion as this work progresses.

The final goal of this project, to be submitted over several patches, is to, without breaking the 
current state, arrive at a situation where the clang lit tests can pass, with no further 
changes to tests, if the default language dialect is changed from C++98 to C++11.

This will make the task of changing the default dialect a trivial step, whenever it happens. 
Meanwhile, it will help any current clang users who are setting the default to C++11, as we do.


Sincerely,
Charles Li
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LexPre.patch
Type: application/octet-stream
Size: 2655 bytes
Desc: LexPre.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150730/71f27987/attachment.obj>


More information about the cfe-commits mailing list