Lit Test C++11 compatibility patch #5
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 9 13:25:59 PST 2015
Essentially LGTM. A few comments below, feel free to commit once you've
addressed them.
On Tue, Nov 24, 2015 at 9:53 AM, Li, Charles <
charles_li at playstation.sony.com> wrote:
> Hi Everyone,
>
>
>
>
>
> I am continuing with updating Lit tests to be C++11 compatible.
>
> Here is the fifth patch. This patch contains 20 tests.
>
+#if __cplusplus <= 199711L // C++03 or earlier
I don't think these comments are useful. It's reasonable to expect that
anyone updating Clang's C++ conformance tests knows what __cplusplus means.
> These are mostly diagnostics changes due to new C++11 features and changes
> in the standard.
>
>
>
> Here are the explanations for each test in the order that they appear in
> the patch.
>
>
>
> CXX/class/class.nest/p1.cpp
>
> Sizeof has been extended to apply to non-static data members without an
> object [n2253].
>
> Restrict the following to C++98/03.
>
> error: invalid use of non-static data member 'x'
>
>
>
> Parser/cxx-casting.cpp
>
> Restrict Digraph errors to C++98/03.
>
> C++98 error: found '<::' after a template name which forms the digraph
> '<:' (aka '[') and a ':', did you mean '< ::'?
>
>
>
> Parser/cxx-reference.cpp
>
> rvalue references is now support
>
> Restrict the following to C++98/03.
>
> C++98 Warning rvalue references are a C++11 extension
>
>
>
> Parser/cxx-template-argument.cpp
>
> Consecutive right angle brackets is no longer a syntax error in C++11
>
> Restrict the following to C++98/03
>
> C++98: error: a space is required between consecutive right angle
> brackets (use '> >')
>
>
>
> Parser/cxx-typeof.cpp
>
> Using __typeof to derive the type of a non-static data member was an
> Error in C++98/03. It is now accepted in in C++11.
>
> Note 1: I could not find GCC documentation on this change,
>
> but given C++11 has decltype now works on non-static data
> members, this appears logical.
>
> Note 2: This test uses GNU extension "typeof".
>
> Therefore the Runs line are expanded with -std=gnu++98 and
> "-std=gnu++11"
>
> instead of the usual "-std=c++98" and "-std=c++11"
>
>
>
> Parser/objc-init.m
>
> Added C++11 error and note diagnostics on narrowing conversion.
>
> Error: non-constant-expression cannot be narrowed from type 'unsigned
> int' to 'int' in initializer list
>
> Note: insert an explicit cast to silence this issue
>
> *Please Note: Since this is an Objective-C test, the Run line has not
> been changed.
>
You should be able to split the -x objective-c++ RUN: line into two.
Parser/objcxx-lambda-expressions-neg.mm
>
> []{}; is now an valid Lambda expression.
>
> Restrict "warning: expected expression" to C++98/03.
>
>
>
> SemaCXX/decl-expr-ambiguity.cpp
>
> Change in ambiguity diagnostics due to introduction of initializer list.
>
> C++11 has 1 extra Note following the pre-existing warning
>
> warning: empty parentheses interpreted as a function declaration
> [-Wvexing-parse]
>
> note: replace parentheses with an initializer to declare a variable
>
>
>
> *Note: The Run lines are left as-is because this test verifies for
> default diagnostic for "typeof"
>
> Diagnostics will change if I explicitly specify any dialect.
>
> Default (no -std=<dialect> flag): error: extension used
> [-Werror,-Wlanguage-extension-token]
>
> C++ (-std=c++<number> flag): error: expected '(' for
> function-style cast or type construction
>
> GNU++ (-std=gnu++<number> flag): No diagnostic.
>
The default mode is gnu++98; specifying -std=gnu++98 should not cause a
change in behavior. Did you perhaps accidentally remove the
-pedantic-errors flag when you added -std=gnu++98?
SemaCXX/overload-call.cpp
>
> This change has 3 separate issues. First two are overload resolutions.
> Last one is C++98/03 specific diagnostic.
>
>
>
> 1. When the actual arg is a string literal and 2 candidate functions
> exist. One with formal argument “char *”, the other with “bool”
>
> In C++98/03, Clang picks "char *" and issues a deprecated writable
> wring diagnostics.
>
> In C++11 , Clang uses picks the "bool" candidate and issues a return
> type miss match diagnostics.
>
> Default converstion from "const char *" to "bool" came from C++11
> standard 4.12\1 [conv.bool]
>
> Reference:
> http://stackoverflow.com/questions/26413951/overloaded-bool-string-ambiguity
>
> The difference in diagnostics are as follows:
>
> C++98 (argument type mismatch): conversion from string literal to
> 'char *' is deprecated
>
> C++11 (return type mismatch): cannot initialize a variable of type
> 'int *' with an rvalue of type 'double *'
>
>
>
> 2. Similar to point 1. This time the 2 overloaded functions have formal
> args "char *" and "void *".
>
> In this case Clang picks "char *" but issues a slightly different error:
>
> C++98 warning: conversion from string literal to 'char *' is
> deprecated
>
> C++11 warning: ISO C++11 does not allow conversion from string
> literal to 'char *'
>
>
>
> 3. Restrict the following diagnostics to C++98/03
>
> Warning: rvalue references are a C++11 extension
>
> Warning: deleted function definitions are a C++11 extension
>
>
>
>
>
> SemaCXX/pragma-init_seg.cpp
>
> In C++11 Clang issues an additional note follow pre-existing error.
>
> Add the following Note to C++11.
>
> Error: initializer for thread-local variable must be a constant
> expression
>
> Note: use 'thread_local' to allow this
>
>
>
> SemaCXX/typo-correction-delayed.cpp
>
> C++11 allows initializer list to be pass as actual arguments.
>
> Restrict the following to C++98
>
> error: expected expression
>
>
>
> SemaCXX/unknown-type-name.cpp
>
> Restrict the following to C++98
>
> Warning: deleted function definitions are a C++11 extension
>
>
>
> SemaCXX/writable-strings-deprecated.cpp
>
> Writable strings generates different diagnostics between C++98/03 and
> C++11.
>
> By default, at both dialects issues warning.
>
> C++98: warning: conversion from string literal to 'char *' is
> deprecated [-Werror,-Wc++11-compat-deprecated-writable-strings]
>
> C++11: warning: ISO C++11 does not allow conversion from string
> literal to 'char *' [-Wwritable-strings]
>
> This test verifies for -W flag's modifications to the severity level of
> the above diagnostics.
>
> I have refectories the preprocessor code The expected Warning or Error
> now corresponds to the C++ dialect level.
>
> I have made the C++ dialect on the RUN lines explicit.
>
> In the process I added 2 RUN lines, default with no -W switches and C98
> with no -W switches.
>
>
>
> SemaObjCXX/message.mm
>
> Tyename can now be used outside of tempalte
>
> Restrict the following to C++98
>
> warning: 'typename' occurs outside of a template
>
>
>
> SemaTemplate/instantiate-function-2.cpp
>
> Restrict the following to C++98
>
> warning: alias declarations are a C++11 extension
>
>
>
> SemaTemplate/instantiate-static-var.cpp
>
> Diagnostic changes in C++11 with the introduction of "constexpr"
>
> C++98: warning: in-class initializer for static data member of type
> 'const float' is a GNU extension
>
> C++11: error: in-class initializer for static data member of type
> 'const float' requires 'constexpr' specifier
>
> C++11: note: add 'constexpr'
>
>
>
> SemaTemplate/nested-name-spec-template.cpp
>
> The keyword “template” can now be used outside of templates.
>
> Restrict warning to C++98/03.
>
> Warning: 'template' keyword outside of a template
>
>
>
> SemaTemplate/overload-candidates.cpp
>
> Only checks the following diagnostics for C++98/03
>
> warning: default template arguments for a function template are a
> C++11 extension
>
> warning: alias declarations are a C++11 extension
>
>
>
> SemaTemplate/partial-spec-instantiate.cpp
>
> problem/9169404 tests for narrowing -1 to bool
>
> Narrowing conversion is now an error in C++11
>
> Added verification for the following at C++11
>
> Error: non-type template argument evaluates to -1, which cannot be
> narrowed to type 'bool'
>
>
>
> SemaTemplate/temp_arg_template.cpp
>
> Restrict digraph and variadic template diagnostics to C++98
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151209/f0d48075/attachment-0001.html>
More information about the cfe-commits
mailing list