[Tests] Making Lit Tests C++11 compatibile

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 16:49:59 PST 2015


You use this pattern in a few places:

+#if (__cplusplus <= 199711L) // C or C++03 or earlier modes

Please remove the "C or" from the tests that are not actually run in C mode
(most or all of these tests make no sense in C, so the comment is
confusing). Also remove the parens.

Otherwise, this looks good to me, thank you!

On Tue, Nov 10, 2015 at 4:28 PM, Li, Charles via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Hello Clang developers,
>
>
>
>
>
> I am back again with another patch to make Clang Lit tests C++11
> compatible.
>
> There are 26 tests in total.
>
> These are mainly diagnostics verifications where C++98/03 and C++11 differ.
>
> I tried to preserve as much coverage as possible.
>
> Unless otherwise stated, these tests have their RUN line expanded to run
> at: default C++ dialect, C++98 and C++11.
>
>
>
> Here are the description of what I did with each in the order as they
> appear in the patch.
>
>
>
> test/CXX/class.access/class.friend/p2-cxx03.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "non-class friend type 'T' is a C++11 extension"
>
>
>
> test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "explicit conversion functions are a C++11 extension"
>
>
>
> test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "befriending enumeration type 'enum E' is a C++11 extension"
>
>
>
> test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
>
>   Verify for different diagnostic between C++03 and earlier vs C++11 and
> later
>
>   C++03: conversion from string literal to 'char *' is deprecated
>
>   C++11: ISO C++11 does not allow conversion from string literal to 'char
> *'
>
>
>
> test/CodeGen/ubsan-type-blacklist.cpp
>
>   Relaxed FileCheck string to accommodate changes in LLVM-IR on actual
> argument type for “bar”.
>
>   C++03: %class.Bar* @bar
>
>   C++11: { i8** }* @bar
>
>
>
> test/FixIt/fixit-vexing-parse.cpp
>
>   Set this test to always run at C++98.
>
>   C++11 coverage is provided by fixit-vexing-parse-cxx0x.cpp.
>
>
>
> test/SemaCXX/addr-of-overloaded-function.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "default template arguments for a function template are a C++11
> extension"
>
>
>
> test/SemaCXX/const-cast.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "rvalue references are a C++11 extension"
>
>
>
> test/SemaCXX/convert-to-bool.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "explicit conversion functions are a C++11 extension"
>
>
>
> test/SemaCXX/copy-initialization.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "rvalue references are a C++11 extension"
>
>
>
> test/SemaCXX/cxx0x-return-init-list.cpp
>
>   Force this test to always run at C++03 (-std=c++98).
>
>   This test verifies for very basic initializer return support in C++98.
>
>   It checks for the following diagnostic at C++03
>
>   "generalized initializer lists are a C++11 extension"
>
>
>
> test/SemaCXX/decltype-crash.cpp
>
>   Force this test to always run at C++03 (-std=c++98).
>
>   This test verifies against decltype crash back in 2009.
>
>
>
> test/SemaCXX/gnu-flags.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   “in-class initializer for static data member is not a constant
> expression; folding it to a constant is a GNU extension”
>
>
>
> test/SemaCXX/invalid-member-expr.cpp
>
>   For code:  pair<int, int> z = minmax({});
>
>   Empty initializer list is valid in C++11, but since minmax is not
> defined anywhere in the program, compiler issues an error.
>
>   Therefore, in C++03 and earlier, we check for diagnostic: “expected
> expression”
>
>   In C++11 and later, we check for diagnostic: “use of undeclared
> identifier 'minmax'”
>

I would prefer to add a declaration of 'minmax' to the test, but I'm OK
with this approach too.


> test/SemaCXX/member-expr.cpp
>
>   In C++11, “template” can be used outside of a template.
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   “'template' keyword outside of a template”
>
>
>
> test/SemaCXX/member-pointer.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "use of enumeration in a nested name specifier is a C++11 extension"
>
>
>
> test/SemaCXX/new-array-size-conv.cpp
>
>   Only verify the following two diagnostic on C++03 and earlier.
>
>   “implicit conversion from array size expression of type 'ValueInt' to
> integral type 'int' is a C++11 extension”
>
>   “implicit conversion from array size expression of type 'ValueEnum' to
> enumeration type 'E' is a C++11 extension”
>
>
>
> test/SemaCXX/offsetof.cpp
>
>   Force this test to be C++98 only. Test offsetof-0x.cpp exists to verify
> for C++11 behavior
>
>   Diagnostic change
>
>   C++98: warning: offset of on non-POD type
>
>   C++11: warning: offset of on non-standard-layout type
>
>
>
> test/SemaCXX/printf-block.cpp
>
>   This test verifies the diagnostic when trying to pass a non-POD struct
> then access its string value.
>
>   C++11 allows passing non-POD objects via va_arg (5.2.2/7). But since the
> object does not have a c_str() method. So the compiler will issue a warning
> on that
>
>   Here are the different diagnostics we verify for.
>
>   C++03: cannot pass non-POD object of type 'HasNoCStr' to variadic block;
> expected type from format string was 'char *'
>
>   C++11: format specifies type 'char *' but the argument has type
> 'HasNoCStr'
>
>
>
> test/SemaCXX/undefined-internal.cpp
>
>   Verify for different diagnostics depending on the dialect.
>
>   C++03: “C++98 requires an accessible copy constructor”
>
>   C++03: “copying parameter of type 'PR9323::(anonymous
> namespace)::Uncopyable' when binding a reference to a temporary would
> invoke an inaccessible constructor in C++98”
>
>
>
> test/SemaObjCXX/crash.mm
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   “variadic templates are a C++11 extension”
>
>
>
> test/SemaObjCXX/vararg-non-pod.mm
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   “cannot pass object of non-POD type 'C' through variadic method; call
> will abort at runtime”
>
>
>
> test/SemaTemplate/default-arguments.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   “default template arguments for a function template are a C++11
> extension”
>
>
>
> test/SemaTemplate/temp_class_spec_neg.cpp
>
>   Only verify the following diagnostic on C++03 and earlier.
>
>   "first declaration of class template partial specialization of 'A'
> outside namespace 'M' is a C++11 extension"
>
>
>
> test/SemaTemplate/typename-specifier-4.cpp
>
>   Keywords "template"and "typename" can be used outside a template in
> C++11.
>
>   Only verify the following two diagnostics on C++03 and earlier.
>
>   'template' keyword outside of a template
>
>   'typename' occurs outside of a template
>
>
>
> test/SemaTemplate/typename-specifier.cpp
>
>   Only verify all occurrences the following diagnostics on C++03 and
> earlier.
>
>   'typename' occurs outside of a template
>
>
>
>
>
> Cheers,
>
> Charles
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151110/200cd6b5/attachment.html>


More information about the cfe-commits mailing list