This is an archive of the discontinued LLVM Phabricator instance.

Lit C++11 Compatibility Patch #7
ClosedPublic

Authored by tigerleapgorge on Apr 13 2016, 11:58 AM.

Details

Summary

13 tests have been updated for C++11 compatibility.

CXX/class.access/class.access.dcl/p1.cpp

Access declarations are deprecated in C++11.
As a result, there are 4 types of diagnostics changes:

For simple access declarations, there is a change in diagnostics.
  C++98: warning: access declarations are deprecated; use using declarations instead
  C++11: error: ISO C++11 does not allow access declarations; use using declarations instead

For Self-referential access declarations, there is also an additional error message.
  C++98: warning: access declarations are deprecated; use using declarations instead
  C++11: error: ISO C++11 does not allow access declarations; use using declarations instead
  C++11: error: using declaration refers to its own class

For an access declaration of a non-base method, there is a different additional error message.
  C++98: warning: access declarations are deprecated; use using declarations instead
  C++11: error: ISO C++11 does not allow access declarations; use using declarations instead
  C++11: error: using declaration refers into 'Subclass::', which is not a base class of 'C'

For self-referential access declaration with local declaration, there is the additional error message but one less note message.
  C++98: warning: access declarations are deprecated; use using declarations instead [-Wdeprecated]
  C++98: error: using declaration refers to its own class
  C++98: note: target of using declaration
  C++11: error: ISO C++11 does not allow access declarations; use using declarations instead
  C++11: error: using declaration refers to its own class

CXX/temp/temp.spec/temp.expl.spec/p2.cpp

Guard multiple instances of the following diagnostics to C++98.
  C++98: warning: first declaration of function template specialization of 'f0' outside namespace 'N0' is a C++11 extension
  C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.expl.spec/p3.cpp

Guard one instance of the following diagnostics to C++98.
  C++98: warning: first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension
  C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.explicit/p2.cpp
CXX/temp/temp.spec/temp.explicit/p5.cpp

In C++98 with -Wc++11-compat, Out-of-scope explicit instantiations of template is a Warning.
In C++11, it is now an Error.
  C++98: warning: explicit instantiation of 'N::f1' must occur in namespace 'N'
  C++11: error: explicit instantiation of 'N::f1' must occur in namespace 'N'

CodeGenCXX/debug-info-static-member.cpp

In C++11, replace “const” with “constexpr” for in-class static initializer of non-integral type.
Otherwise compiler would complain: 
  C++11: error: in-class initializer for static data member of type 'const float' requires 'constexpr' specifier

SemaCXX/dcl_init_aggr.cpp

Diagnostic change due to initializer list
  C++98: error: non-aggregate type 'NonAggregate' cannot be initialized with an initializer list
  C++11: error no matching constructor for initialization of 'NonAggregate'
         note: candidate constructor (the implicit copy constructor) not viable
         note: candidate constructor (the implicit move constructor) not viable
         note: candidate constructor not viable

Diagnostic Change
  C++98: conversion from string literal to 'char *' is deprecated
  C++11: ISO C++11 does not allow conversion from string literal to 'char *'

Addition C++11 move constructor diagnostics
  C++11: note: candidate constructor (the implicit move constructor) not viable

The next 2 lines caused a lot of diff.
  Source: TooFewError too_few_error = { 1 }
  C++98: error: no matching constructor for initialization of 'NoDefaultConstructor'
         note: candidate constructor not viable: requires 1 argument, but 0 were provided
         note: candidate constructor (the implicit copy constructor) not viable
         note: in implicit initialization of field 'nodef' with omitted initializer
         error: implicit default constructor for 'TooFewError' must explicitly initialize
                the member 'nodef' which does not have a default constructor
         note: member is declared here
         note: 'NoDefaultConstructor' declared here

  C++11: error: no matching constructor for initialization of 'NoDefaultConstructor'
         note: candidate constructor not viable: requires 1 argument, but 0 were provided
         note: candidate constructor (the implicit copy constructor) not viable
         note: candidate constructor (the implicit move constructor) not viable
         note: in implicit initialization of field 'nodef' with omitted initializer

  Source: TooFewError too_few_okay2[2] = { 1, 1 };
  C++98: note: implicit default constructor for 'TooFewError' first required here
         note: 'NoDefaultConstructor' declared her
  C++11: error: no matching constructor for initialization of 'NoDefaultConstructor'
        note: candidate constructor not viable: requires 1 argument, but 0 were provided
         note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
         note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided
         note: in implicit initialization of field 'nodef' with omitted initializer
         note: in implicit initialization of array element 1 with omitted initializer

SemaCXX/type-convert-construct.cpp

*Note: Run line used “–std=gnu++XX” instead of “c++” due to use of “typeof”.
New C++11 error message for int and pointer comparison
  C++11: error: comparison between pointer and integer ('T' (aka 'int') and 'int *')

Change in diagnostics:
  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 *'

  C++98: Warning: conversion from string literal to 'wchar_t *' is deprecated
  C++11: Warning: ISO C++11 does not allow conversion from string literal to 'wchar_t

SemaCXX/vararg-non-pod.cpp

Clang in C++11 now allows non-POD type to be passed via variadic argument.
However, Clang still does not allow non-trivial type to be passed 
(according C++11 standard 5.2.2\7 [expr.call] this behavior is “implementation defined”)

Restrict the following warnings on non-POD types to C++98/03
  C++98: warning: cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime
  C++98: warning: cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime
  C++98: warning: cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime
  C++98: warning: cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime

Change in diagnostics for non-trivial type
  C++98: warning: cannot pass object of non-POD type 'Base' through variadic function; call will abort at runtime
  C++11: warning: cannot pass object of non-trivial type 'Base' through variadic function; call will abort at runtime

SemaTemplate/class-template-spec.cpp

Restrict the following diagnostics to C++98/03

  C++98: warning: first declaration of class template specialization of 'B' outside namespace 'N' is a C++11 extension 
         note: explicitly specialized declaration is here

  C++98: Warning: variadic templates are a C++11 extension

  C++98: Warning: alias declarations are a C++11 extension

SemaTemplate/instantiate-cast.cpp

When there is no matching conversion, C++98 tries copy and default constructors 
whereas C++11 tries copy, move and default constructors.
Therefore, there is one additional move constructor Note message in C++11
  C++11: note: candidate constructor (the implicit copy constructor) not viable: 
               no known conversion from 'int' to 'const A' for 1st argument

SemaTemplate/instantiate-expr-4.cpp

Added C++11 specific diagnostics 
3 instances of move constructor diagnostics 
  C++11:  candidate constructor (the implicit move constructor) not viable

1 instance of initializer list narrowing diagnostics
  C++11: error: type 'float' cannot be narrowed to 'int' in initializer list
         note: in instantiation of member function 'InitList1<int [1], float>::f' requested here
         note: insert an explicit cast to silence this issue

SemaTemplate/instantiate-member-class.cpp

Guard C++98/03 Specific warning
  C++98:  Warning: alias declarations are a C++11 extension

Change in diagnostics, C++98/03 allows for ‘0’ to null pointer conversion during initialization, C++11 does not. 
  C++98: warning: expression which evaluates to zero treated as a null pointer constant of type 'int *'
  C++11: Error: cannot initialize a variable of type 'int *' with an rvalue of type 'int'

Diff Detail

Repository
rL LLVM

Event Timeline

tigerleapgorge retitled this revision from to Lit C++11 Compatibility Patch #7.
tigerleapgorge updated this object.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.
rsmith accepted this revision.Apr 13 2016, 12:22 PM
rsmith edited edge metadata.
This revision is now accepted and ready to land.Apr 13 2016, 12:22 PM
This revision was automatically updated to reflect the committed changes.