[PATCH] D20710: Lit C++11 Compatibility Patch #9
Charles Li via cfe-commits
cfe-commits at lists.llvm.org
Thu May 26 16:05:40 PDT 2016
tigerleapgorge created this revision.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.
Hi everyone,
I am back again with Lit test C++11 compatibility patch #9.
30 tests are updated this time.
They are follows.
CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
Operator delete’s throwing prototype has changed. (C++ standard 18.6 [support.dynamic])
C++98 prototype: void operator delete (void* ptr) throw();
C++11 prototype: void operator delete (void* ptr) noexcept;
This test redeclares operator delete without “noexcept”
Added the following expected Warning for C++11 (2 instances)
C++11: warning: function previously declared with an explicit
exception specification redeclared with an implicit
exception specification [-Wimplicit-exception-spec-mismatch]
CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
Operator new’s throwing prototype has changed:
C++98 prototype: void* operator new (std::size_t size) throw (std::bad_alloc);
C++11 prototype: void* operator new (std::size_t size);
This test declares operator new with “throw(std::bad_alloc)” then
redeclares operator new again without a throw.
In C++11 the redeclaration is the same as the prototype.
Restricted the following to warning C++98.
C++98: warning: 'operator new' is missing exception specification
'throw(std::bad_alloc)' [-Wmissing-exception-spec]
note: previous declaration is here
Operator delete’s throwing prototype has also changed
(see previous test p2-noexceptions.cpp for prototypes):
This test declares operator delete with “throw()”,
then redeclares operator delete without a throw.
Expect the following change in diagnostics.
C++98: warning: 'operator delete' is missing exception specification
'throw()' [-Wmissing-exception-spec]
note: previous declaration is here
C++11: warning: function previously declared with an explicit exception
specification redeclared with an implicit exception
specification [-Wimplicit-exception-spec-mismatch]
note: previous declaration is here
CXX/class.access/class.friend/p1.cpp
This test verifies when a class befriends another class.
C++11’s “constexpr” feature interferes with
Clang’s “befriend implicitly-declared members” feature.
This test contains 2 parts: test6 and test7.
Test6: (r101122 – “Allow classes to befriend implicitly-declared members.”)
Struct A is declared as POD.
Struct B befriends A’s implicitly-declared constructor.
This amounts to a re-declaration of struct A with a different const-ness.
Therefore, add the following diagnostics to the expected diagnostics.
C++11: error: non-constexpr declaration of 'A' follows constexpr declaration
note: previous declaration is here
For test7: (r101173 – “Support befriending members of class template specializations.”)
This test is intended to verify A’s private constructor inside
struct template X’s specialization.
However, struct X’s constructor and destructor are explicitly declared,
struct X’s copy-constructor is implicitly declared.
When class A befriends X’s implicitly declared copy-constructor,
Clang issues a similar error to that of test 6.
But, this error stops the generation of subsequent errors.
Since the intended target of this test are the subsequent errors,
I added a struct X copy constructor declaration to stop the first error.
CXX/class.access/p4.cpp
When constructing a class that contains a member that cannot be initialized,
C++98 and C++11 issues similar diagnostics but in opposite order.
C++98 messages begin with the innermost member that failed to initialize.
C++11 messages begin with the outermost constructor that was implicitly deleted.
The diff here is quite large. It has 3 parts.
Test2: Change in diagnostics. (2 sets)
C++98: error: base class 'test2::A' has private default constructor
note: declared private here
note: implicit default constructor for 'test2::B' first required here
C++11: error: call to implicitly-deleted default constructor of 'test2::B'
note: default constructor of 'B' is implicitly deleted because
base class 'test2::A' has an inaccessible default constructor
C++98: error: inherited virtual base class 'test2::A' has private default constructor
note: declared private here
note: implicit default constructor for 'test2::D' first required here
C++11: error: call to implicitly-deleted default constructor of 'test2::D'
note: default constructor of 'D' is implicitly deleted because
base class 'test2::A' has an inaccessible default constructor
Test3:
Massive reduction in diagnostics issued.
Class template “Base” has a private destructor.
Class “Derived3” multiple-inherits specializations of “Base”
and derived class of specializations of “Base”.
In C++98/03, Clang issues diagnostics for all paths of the
inheritances from Base to Derived3.
In C++11, Clang issues diagnostics on just the first path.
C++98: error: base class 'Base<3>' has private destructor
note: implicitly declared private here
note: implicit default constructor for 'test3::Base3' first required here
error: base class 'Base<2>' has private destructor
note: implicitly declared private here
note: implicit default constructor for 'test3::Base2' first required here
error: base class 'Base<0>' has private destructor
note: implicitly declared private here
error: base class 'Base<1>' has private destructor
note: implicitly declared private here
error: base class 'test3::Base2' has private destructor
note: implicitly declared private here
error: inherited virtual base class 'Base<2>' has private destructor
note: implicitly declared private here
error: inherited virtual base class 'Base<3>' has private destructor
note: implicitly declared private here
note: implicit default constructor for 'test3::Derived3' first required here
error: base class 'Base<0>' has private destructor
note: implicitly declared private here
error: base class 'Base<1>' has private destructor
note: implicitly declared private here
error: base class 'test3::Base2' has private destructor
note: implicitly declared private here
error: inherited virtual base class 'Base<2>' has private destructor
note: implicitly declared private here
error: inherited virtual base class 'Base<3>' has private destructor
note: implicitly declared private here
note: implicit destructor for 'test3::Derived3' first required here
C++11: error: call to implicitly-deleted default constructor of 'test3::Derived3'
note: default constructor of 'Derived3' is implicitly deleted because
base class 'Base<0>' has an inaccessible destructor
Test5: Change in diagnostics (4 sets)
C++98: error: 'operator=' is a private member of 'test5::A'
note: implicitly declared private here
note: implicit copy assignment operator for 'test5::Test1'
first required here
C++11: error: object of type 'test5::Test1' cannot be assigned because its
copy assignment operator is implicitly deleted
note: copy assignment operator of 'Test1' is implicitly deleted because
field 'a' has an inaccessible copy assignment operator
C++98: error: 'operator=' is a private member of 'test5::A'
note: implicitly declared private here
note: implicit copy assignment operator for 'test5::Test2'
first required here
C++11: error: object of type 'test5::Test2' cannot be assigned because its
copy assignment operator is implicitly deleted
note: copy assignment operator of 'Test2' is implicitly deleted because
base class 'test5::A' has an inaccessible copy assignment operator
C++98: error: field of type 'test6::A' has private copy constructor
note: declared private here
note: implicit copy constructor for 'test6::Test1' first required here
C++11: error: call to implicitly-deleted copy constructor of 'test6::Test1'
note: copy constructor of 'Test1' is implicitly deleted because field
'a' has an inaccessible copy constructor
C++98: error: base class 'test6::A' has private copy constructor
note: declared private here
note: implicit copy constructor for 'test6::Test2' first required here
C++11: error: call to implicitly-deleted copy constructor of 'test6::Test2'
note: copy constructor of 'Test2' is implicitly deleted because base
class 'test6::A' has an inaccessible copy constructor
CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
This test verifies “using” declarations.
Add 2 Errors for C++11.
C++11: error: using declaration refers into 'Subclass::',
which is not a base class of 'C'
C++11: error: using declaration refers to its own class
The accompanying Note is no longer issued in C++11, guard it to C++98/03.
Existing: error: using declaration refers to its own class
C++98 only: note: target of using declaration
CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
For this test to compile under C++98/03.
Lit test CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp covers C++11 behavior.
CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
Force this test to run under C++98/03.
Lit test CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp covers C++11 behavior.
CXX/dcl.decl/dcl.init/p5.cpp
Similar to test CXX/class.access/p4.cpp
When constructing a class that contains a member that cannot be initialized,
C++98 and C++11 issues similar diagnostics but in opposite order.
C++98 messages begin with the innermost member that failed to initialize.
C++11 messages begin with the outermost constructor that was implicitly deleted.
C++98: error: implicit default constructor for 'S' must explicitly initialize
the reference member 'x'
note: declared here
note: implicit default constructor for 'S' first required here
C++11: error: call to implicitly-deleted default constructor of 'S'
note: default constructor of 'S' is implicitly deleted because
field 'x' of reference type 'int &' would not be initialized
C++98: error: reference to type 'int' requires an initializer
note: in value-initialization of type 'S' here
C++11: error: call to implicitly-deleted default constructor of 'S'
note: default constructor of 'S' is implicitly deleted because
field 'x' of reference type 'int &' would not be initialized
C++98: error: reference to type 'int' requires an initializer
note: in value-initialization of type 'S' here
note: in value-initialization of type 'T' here
C++11: error: call to implicitly-deleted default constructor of 'T'
note: default constructor of 'T' is implicitly deleted because
base class 'S' has a deleted default constructor
note: default constructor of 'S' is implicitly deleted because
field 'x' of reference type 'int &' would not be initialized
C++98: error: reference to type 'int' requires an initializer
note: in value-initialization of type 'S' here
note: in value-initialization of type 'T' here
note: in value-initialization of type 'U' here
C++11: error: call to implicitly-deleted default constructor of 'U'
note: default constructor of 'U' is implicitly deleted because
field 't' has a deleted default constructor
note: default constructor of 'T' is implicitly deleted because
base class 'S' has a deleted default constructor
note: default constructor of 'S' is implicitly deleted because
field 'x' of reference type 'int &' would not be initialized
Restrict the following Warning to C++98 (2 instances)
C++98: warning: in-class initialization of non-static data member is
a C++11 extension
CXX/special/class.dtor/p9.cpp
Change in diagnostics when a derived class overloads the delete operator
without declaring an overriding destructor.
*This test make use of sizeof() therefore is marked with –std=gnu++XX
instead of the usual –std=c++XX
C++98: error: no suitable member 'operator delete' in 'C'
note: member 'operator delete' declared here
note: implicit destructor for 'test2::C' first required here
C++11: error: deleted function '~C' cannot override a non-deleted function
note: overridden virtual function is here
error: attempt to use a deleted function
note: virtual destructor requires an unambiguous,
accessible 'operator delete'
CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
Change in diagnostics due to constexpr in C++11 (3 instances)
C++98: error: non-type template argument for template parameter of
pointer type 'int (*) (int)' must have its address taken
C++11: error: non-type template argument of type 'int (*)(int)' is not
a constant expression
note: read of non-constexpr variable 'funcptr' is not allowed
in a constant expression
note: declared here
Similar change as above, only difference is in the Note message. (1 instance)
C++98: error: non-type template argument for template parameter of pointer type
'int *' must have its address taken
C++11: error: non-type template argument of type 'int' is not a constant expression
note: read of non-const variable 'baz' is not allowed in a constant expression
note: declared here
Restrict the following message to C++98. (1 instance)
C++98: warning: address non-type template argument cannot be surrounded
by parentheses
CXX/temp/temp.spec/temp.expl.spec/p4.cpp
Change in diagnostics.
C++98: error: implicit default constructor for 'X<IntHolder, int>::Inner'
must explicitly initialize the member 'value' which does not
have a default constructor
note: member is declared here
note: 'IntHolder' declared here
note: implicit default constructor for 'X<IntHolder, int>::Inner'
first required here
C++11: error: call to implicitly-deleted default constructor of
'X<IntHolder, int>::Inner'
note: default constructor of 'Inner' is implicitly deleted because
field 'value' has no default constructor
Addition Note in C++11 accompanying the existing Error. (2 instances)
C++98 and C++11: error: no matching constructor for initialization of 'IntHolder'
C++98 and C++11: candidate constructor (the implicit copy constructor) not viable
New to C++11: note: candidate constructor (the implicit move constructor) not viable
CXX/temp/temp.spec/temp.explicit/p4.cpp
Restrict the following C++98 specific Warnings (5 instances)
C++98: warning: explicit instantiation of 'f0<long>' that occurs after
an explicit specialization will be ignored (C++11 extension)
note: previous template specialization is here
Restrict the following C++98 specific Warning (1 instance)
C++98: warning: extern templates are a C++11 extension [-Wc++11-extensions]
CodeGenCXX/debug-info-use-after-free.cpp
Mark base class destructor “~AAA(){}” as “protected” so that the derived class
“C3” can inherit from it.
Otherwise we would get the following Error in C++11:
C++11: error: deleted function '~C3' cannot override a non-deleted function
note: overridden virtual function is here
CodeGenCXX/dynamic-cast-hint.cpp
Mark base class destructors protected so that they can be inherited.
Otherwise we would get the following Error in C++11:
C++11: error: deleted function '~C' cannot override a non-deleted function
note: overridden virtual function is here
OpenMP/distribute_collapse_messages.cpp
2 additional Notes in C++11 following existing error. (4 instances)
C++98 and C++11: error: expression is not an integral constant expression
New to C++11: note: non-constexpr function 'foobool' cannot be used in
a constant expression
New to C++11: note: declared here
Change in diagnostics (3 instances)
C++98: error: expression is not an integral constant expression
C++11: error: integral constant expression must have integral or unscoped
enumeration type, not 'char *'
OpenMP/ordered_messages.cpp
In this test, foo() is being used in the place of an integral constant.
C++11 added 2 additional Notes following the existing Warning (2 instances)
C++98 and C++11: error: expression is not an integral constant expression
New to C++11: note: non-constexpr function 'foo' cannot be used in
a constant expression
New to C++11: note: declared here
OpenMP/target_parallel_for_collapse_messages.cpp
Same as above, C++11 added 2 new Notes following the existing Warning (4 instances)
Existing: error: expression is not an integral constant expression
C++11: note: non-constexpr function 'foobool' cannot be used in
a constant expression
C++11: note: declared here
Change in diagnostics (2 instances)
C++98: expression is not an integral constant expression
C++11: integral constant expression must have integral or unscoped
enumeration type, not 'char *'
OpenMP/target_parallel_for_ordered_messages.cpp
Nearly identical to the test above (target_parallel_for_collapse_messages.cpp).
SemaCXX/i-c-e-cxx.cpp
This test verifies GNU extensions.
Change in diagnostics.
C++98: error: expression is not an integral constant expression
C++11: error: case value is not a constant expression
Restrict the following to C++98:
C++98: note: read of object outside its lifetime is not allowed
in a constant expression
C++98: warning: no case matching constant switch condition '1'
C++98: warning: in-class initializer for static data member is not a constant
expression; folding it to a constant is a GNU extension
C++98: warning: 'long long' is a C++11 extension [-Wc++11-long-long]
C++98: warning: warning: variable length array folded to constant array as an
extension [-Wgnu-folding-constant]
note: initializer of 'nonconst' is not a constant expression
note: declared here
SemaCXX/implicit-virtual-member-functions.cpp
Change in diagnostics (3 instances)
C++98: error: no suitable member 'operator delete' in 'B'
note: member 'operator delete' declared here
note: implicit destructor for 'B' first required here
C++11: error: deleted function '~B' cannot override a non-deleted function
note: overridden virtual function is here
Added diagnostics in C++11 when target is Microsoft.
C++11: error: attempt to use a deleted function
note: virtual destructor requires an unambiguous, accessible
'operator delete'
SemaCXX/new-delete.cpp
C++11 has one additional note following no matching constructor error.
Existing: error: no matching constructor for initialization of 'S'
Existing: note: candidate constructor (the implicit copy constructor) not viable
C++11: candidate constructor (the implicit move constructor) not viable
Restrict the following to C++98.
C++98: warning: 'operator new' is missing exception specification
'throw(std::bad_alloc)'
C++98: warning: 'operator new' is missing exception specification
'throw(std::bad_alloc)'
C++98: note: previous declaration is here
Add the following to C++11:
C++11: warning: function previously declared with an explicit exception specification
redeclared with an implicit exception specification
Change in diagnostic severity:
C++98: error: array size is negative
C++11: warning: array size is negative
C++98: error: array is too large (2000000000 elements)
C++11: warning: array is too large (2000000000 elements)
Change in diagnostics (2 instances)
C++98: error: array size expression must have integral or enumeration type, not 'S'
C++11: error: array size expression must have integral or unscoped enumeration type,
not 'S'
Change in diagnostics
C++98: error: expected expression
C++11: error: expected variable name or 'this' in lambda capture list
C++98: error: no suitable member 'operator delete' in 'X11'
note: member 'operator delete' declared here
note: implicit destructor for 'X11' first required here
C++11: error: deleted function '~X11' cannot override a non-deleted function
note: overridden virtual function is here
error: attempt to use a deleted function
note: virtual destructor requires an unambiguous, accessible 'operator delete'
C++98: error: field of type 'ArrayNewNeedsDtor::A' has private destructor
note: declared private here
note: implicit destructor for 'ArrayNewNeedsDtor::B' first required here
C++11: error: attempt to use a deleted function
note: destructor of 'B' is implicitly deleted because field 'a' has an
inaccessible destructor
SemaCXX/no-wchar.cpp
C++11 had deprecated wchar_t.
Change in diagnostics.
C++98: conversion from string literal to 'wchar_t *'
(aka 'unsigned short *') is deprecated
C++11: ISO C++11 does not allow conversion from string literal to 'wchar_t *'
(aka 'unsigned short *')
SemaCXX/virtual-member-functions-key-function.cpp
Change in diagnostics (2 instances)
C++98: error: no suitable member 'operator delete' in 'B'
note: member 'operator delete' declared here
note: implicit destructor for 'B' first required here
C++11: error: deleted function '~B' cannot override a non-deleted function
note: overridden virtual function is here
SemaCXX/warn-bool-conversion.cpp
C++11 is more strict with pointer initializations.
Boolean literal conversion diagnostics changed from Warning in C++98/03 to
Error with Note in C++11.
C++98: warning: initialization of pointer of type 'int *' to null from a
constant boolean expression [-Wbool-conversion]
C++11: error: cannot initialize a variable of type 'int *' with an
rvalue of type 'bool'
C++98: warning: initialization of pointer of type 'int *' to null from a
constant boolean expression [-Wbool-conversion]
C++11: error: cannot initialize a parameter of type 'int *' with an
rvalue of type 'bool'
note: passing argument to parameter 'j' here
C++98: warning: initialization of pointer of type 'int *' to null from a
constant boolean expression [-Wbool-conversion]
C++11: error: no matching function for call to 'foo'
note: candidate function not viable: requires 2 arguments, but 1 was provided
Calling the function “void foo(int* i, int *j=(false))” with one actual argument
was OK in C++98/03, but is an Error in C++11.
Added the following.
C++11: Error: no matching function for call to 'foo'.
SemaCXX/zero-length-arrays.cpp
In this test, class Bar has contains 3 zero-length arrays of class Foo.
Class Foo has a private copy constructor.
Bar’s implicit copy constructor was considered undefined was C++98/03,
it is considered deleted in C++11. [class.copy] 12.8 \ 11.
http://en.cppreference.com/w/cpp/language/copy_constructor#Deleted_implicitly-declared_copy_constructor
Added the followed expected diagnostics for C++11.
C++11: error: call to implicitly-deleted copy constructor of 'Bar'
note: copy constructor of 'Bar' is implicitly deleted because
field 'foos' has an inaccessible copy constructor
SemaTemplate/instantiate-c99.cpp
Added static_cast<>() inside designated initializers.
Otherwise compiling this test in C++11 would result in the following Error.
C++11: error: non-constant-expression cannot be narrowed from type 'int'
to 'float' in initializer list [-Wc++11-narrowing]
SemaTemplate/temp_explicit.cpp
Restrict the following to C++98.
C++98: warning: explicit instantiation of 'X0<char, char>' that occurs
after an explicit specialization will be ignored
(C++11 extension) [-Wc++11-extensions]
note: previous template specialization is here
Change in severity for the follow 3 diagnostics.
C++98: warning: explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'
C++11: error: explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'
C++98: warning: explicit instantiation of 'N1::X7' must occur in namespace 'N1'
C++11: error: explicit instantiation of 'N1::X7' must occur in namespace 'N1'
C++98: warning: explicit instantiation of 'X9' must occur at global scope
C++11: error: explicit instantiation of 'X9' must occur at global scope
SemaTemplate/value-dependent-null-pointer-constant.cpp
String literal and int is no longer compatible in C++11.
Added 3 expected Errors for C++11.
C++11: error: incompatible operand types ('const char *' and 'int')
C++11: error: incompatible operand types ('int' and 'const char *')
C++11: error: comparison between pointer and integer ('const char *' and 'int')
SemaTemplate/virtual-member-functions.cpp
Change in diagnostics when derived class inherits a private destructor
in the base class.
C++98: error: base class 'PR7114::A' has private destructor
note: implicitly declared private here
note: implicit destructor for 'PR7114::B<float>::Inner' first required here
C++11: error: deleted function '~Inner' cannot override a non-deleted function
note: in instantiation of member class 'PR7114::B<int>::Inner' requested here
note: in instantiation of template class 'PR7114::B<int>' requested here
note: overridden virtual function is here
error: deleted function '~Inner' cannot override a non-deleted function
note: in instantiation of member class 'PR7114::B<float>::Inner' requested here
note: in instantiation of template class 'PR7114::B<float>' requested here
note: overridden virtual function is here
error: deleted function '~X' cannot override a non-deleted function
note: in instantiation of template class 'PR7114::X<int>' requested here
note: overridden virtual function is here
Sincerely,
Charles Li
http://reviews.llvm.org/D20710
Files:
test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp
test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
test/CXX/class.access/class.friend/p1.cpp
test/CXX/class.access/p4.cpp
test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
test/CXX/dcl.decl/dcl.init/p5.cpp
test/CXX/special/class.dtor/p9.cpp
test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
test/CXX/temp/temp.spec/temp.explicit/p4.cpp
test/CodeGenCXX/debug-info-use-after-free.cpp
test/CodeGenCXX/dynamic-cast-hint.cpp
test/OpenMP/distribute_collapse_messages.cpp
test/OpenMP/ordered_messages.cpp
test/OpenMP/target_parallel_for_collapse_messages.cpp
test/OpenMP/target_parallel_for_ordered_messages.cpp
test/SemaCXX/i-c-e-cxx.cpp
test/SemaCXX/implicit-virtual-member-functions.cpp
test/SemaCXX/new-delete.cpp
test/SemaCXX/no-wchar.cpp
test/SemaCXX/virtual-member-functions-key-function.cpp
test/SemaCXX/warn-bool-conversion.cpp
test/SemaCXX/zero-length-arrays.cpp
test/SemaTemplate/instantiate-c99.cpp
test/SemaTemplate/temp_explicit.cpp
test/SemaTemplate/value-dependent-null-pointer-constant.cpp
test/SemaTemplate/virtual-member-functions.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20710.58714.patch
Type: text/x-patch
Size: 76718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160526/ae9b7fd6/attachment-0001.bin>
More information about the cfe-commits
mailing list