Page MenuHomePhabricator

Lit C++11 Compatibility Patch #9
ClosedPublic

Authored by tigerleapgorge on May 26 2016, 4:05 PM.

Details

Summary

Continuing to make Lit tests C++11 compatibility.
11 tests in this patch.

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

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/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

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')

Diff Detail

Repository
rL LLVM

Event Timeline

tigerleapgorge retitled this revision from to Lit C++11 Compatibility Patch #9.
tigerleapgorge updated this object.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.

Forgot to provide context last time.
Last patch was created using command: svn diff
This patch was created using command: svn diff --diff-cmd=diff -x -U999999

Lit C++11 compatibility patch #9

Update patch again to expect for latest Trunk C++11 diagnostics.
Tests in CXX directory are already passing in C++11, so they are removed from this patch.
Of the remaining tests, 4 tests are modified to accommodate for changes is diagnostics.

SemaCXX/implicit-virtual-member-functions.cpp

Additional Note message in latest Trunk (3 instances).
  Note: virtual destructor requires an unambiguous, accessible 'operator delete'

SemaCXX/new-delete.cpp

Warning no longer exist in latest Trunk
  Warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification

Previous severity change (C++98 Warning  to C++11 Error) has been fixed in latest Trunk.
Revert following 2 message back to Error.
  Error: array size is negative
  Error: array is too large (2000000000 elements)

Additional Note message (1 instance).
  Note: virtual destructor requires an unambiguous, accessible 'operator delete'

SemaCXX/virtual-member-functions-key-function.cpp

Additional Note message (2 instances)
  Note: virtual destructor requires an unambiguous, accessible 'operator delete'

SemaTemplate/virtual-member-functions.cpp

Additional Note message (3 instances)
  Note: destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor
  Note: destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor
  Note: destructor of 'X<int>' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor

Forgot to include all context inside the previous revision.

Previous patch: svn diff
This patch: svn diff --diff-cmd=diff -x -U999999

Update again, remove 4 OpenMP tests here because they have been checked in rL294025 under review D29480.
13 tests left.

tigerleapgorge edited the summary of this revision. (Show Details)Feb 3 2017, 11:34 AM
tigerleapgorge edited the summary of this revision. (Show Details)

2 tests have been reviewed in D29520
They are: implicit-virtual-member-functions.cpp and virtual-member-functions.cpp
Remove these from this patch.

tigerleapgorge edited the summary of this revision. (Show Details)Feb 6 2017, 2:48 PM
tigerleapgorge edited the summary of this revision. (Show Details)Feb 10 2017, 1:44 PM
rsmith accepted this revision.Feb 24 2017, 1:15 PM

LGTM

This revision is now accepted and ready to land.Feb 24 2017, 1:15 PM
This revision was automatically updated to reflect the committed changes.