Re: r269398 - Add support for derived class special members hiding functions brought in from

2016-05-16 Thread Vassil Vassilev via cfe-commits

The reduced reproducer: https://llvm.org/bugs/show_bug.cgi?id=27754
On 14/05/16 01:23, Richard Smith wrote:
Update: Vassil and I have dug into this a bit offline. It looks like 
the root cause is a likely-pre-existing bug where we somehow import a 
default constructor for a class from a module but don't set the "has a 
default constructor" flag on the class definition.


On Fri, May 13, 2016 at 2:54 AM, Vassil Vassilev 
> wrote:


Hi Richard,
  I believe this broke our modules builds. Last successful one was
with r269388 and the current with r269389 fails with:


/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 error: constructor cannot be redeclared
 struct integral_constant
^

/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 note: previous implicit declaration is here
 struct integral_constant
^

/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TGenericClassInfo.cxx:18:10:
 fatal error: could not build module 'TCollectionProxyInfo.h'
#include "TCollectionProxyInfo.h"
  ^~~~
2 errors generated.

and


/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
error: multiple overloads of 'nothrow_t' instantiate to the same signature 
'void ()'
   struct nothrow_t { };
  ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:253:8: note: in 
instantiation of function template specialization '__gnu_cxx::new_allocator 
>::construct, const std::pair &>' requested here
 { __a.construct(__p, std::forward<_Args>(__args)...); }
   ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:399:4: note: in 
instantiation of function template specialization 'std::allocator_traits 
> >::_S_construct, const std::pair &>' requested here
 { _S_construct(__a, __p, std::forward<_Args>(__args)...); }
   ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/stl_vector.h:917:21: note: in 
instantiation of function template specialization 'std::allocator_traits 
> >::construct, const std::pair &>' requested here
 _Alloc_traits::construct(this->_M_impl, 
this->_M_impl._M_finish,
^

/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TSchemaRule.cxx:873:21:
 note: in instantiation of member function 'std::vector, 
std::allocator > >::push_back' requested here
   fVersionVect->push_back( verpair );
 ^

/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
note: previous implicit declaration is here
   struct nothrow_t { };

Shall I start reducing the issues one by one or we can revert this
patch? Vassil On 13/05/16 08:47, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri May 13 01:47:56 2016
New Revision: 269398

URL:http://llvm.org/viewvc/llvm-project?rev=269398=rev
Log:
Add support for derived class special members hiding functions brought in 
from
a base class via a using-declaration. If a class has a using-declaration
declaring either a constructor or an assignment operator, eagerly declare 
its
special members in case they need to displace a shadow declaration from a
using-declaration.

Modified:
 cfe/trunk/include/clang/AST/DeclCXX.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
 cfe/trunk/test/SemaCUDA/implicit-member-target.cu 

 cfe/trunk/test/SemaCXX/constructor-recovery.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h

URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=269398=269397=269398=diff

==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 13 01:47:56 2016
@@ -382,6 +382,14 @@ class CXXRecordDecl : public RecordDecl
  /// provided 

Re: r269398 - Add support for derived class special members hiding functions brought in from

2016-05-13 Thread Richard Smith via cfe-commits
Update: Vassil and I have dug into this a bit offline. It looks like the
root cause is a likely-pre-existing bug where we somehow import a default
constructor for a class from a module but don't set the "has a default
constructor" flag on the class definition.

On Fri, May 13, 2016 at 2:54 AM, Vassil Vassilev 
wrote:

> Hi Richard,
>   I believe this broke our modules builds. Last successful one was with
> r269388 and the current with r269389 fails with:
>
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
>  error: constructor cannot be redeclared
> struct integral_constant
>^
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
>  note: previous implicit declaration is here
> struct integral_constant
>^
> /mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TGenericClassInfo.cxx:18:10:
>  fatal error: could not build module 'TCollectionProxyInfo.h'
> #include "TCollectionProxyInfo.h"
>  ^~~~
> 2 errors generated.
>
> and
>
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10:
>  error: multiple overloads of 'nothrow_t' instantiate to the same signature 
> 'void ()'
>   struct nothrow_t { };
>  ^
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:253:8:
>  note: in instantiation of function template specialization 
> '__gnu_cxx::new_allocator >::construct int>, const std::pair &>' requested here
> { __a.construct(__p, std::forward<_Args>(__args)...); }
>   ^
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:399:4:
>  note: in instantiation of function template specialization 
> 'std::allocator_traits > 
> >::_S_construct, const std::pair &>' requested 
> here
> { _S_construct(__a, __p, std::forward<_Args>(__args)...); }
>   ^
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/stl_vector.h:917:21:
>  note: in instantiation of function template specialization 
> 'std::allocator_traits > 
> >::construct, const std::pair &>' requested here
> _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
>^
> /mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TSchemaRule.cxx:873:21:
>  note: in instantiation of member function 'std::vector, 
> std::allocator > >::push_back' requested here
>   fVersionVect->push_back( verpair );
> ^
> /usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10:
>  note: previous implicit declaration is here
>   struct nothrow_t { };
>
>
> Shall I start reducing the issues one by one or we can revert this patch?
> Vassil On 13/05/16 08:47, Richard Smith via cfe-commits wrote:
>
> Author: rsmith
> Date: Fri May 13 01:47:56 2016
> New Revision: 269398
>
> URL: http://llvm.org/viewvc/llvm-project?rev=269398=rev
> Log:
> Add support for derived class special members hiding functions brought in from
> a base class via a using-declaration. If a class has a using-declaration
> declaring either a constructor or an assignment operator, eagerly declare its
> special members in case they need to displace a shadow declaration from a
> using-declaration.
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
> cfe/trunk/test/SemaCUDA/implicit-member-target.cu
> cfe/trunk/test/SemaCXX/constructor-recovery.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=269398=269397=269398=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 13 01:47:56 2016
> @@ -382,6 +382,14 @@ class CXXRecordDecl : public RecordDecl
>  /// provided default ctor also doesn't have an in-class initializer.
>  unsigned HasUninitializedFields : 1;
>
> +/// \brief True if there are any member using-declarations that inherit
> +/// constructors from a base class.
> +unsigned HasInheritedConstructor : 1;
> +
> +/// \brief 

Re: r269398 - Add support for derived class special members hiding functions brought in from

2016-05-13 Thread Vassil Vassilev via cfe-commits

Hi Richard,
  I believe this broke our modules builds. Last successful one was with 
r269388 and the current with r269389 fails with:


/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 error: constructor cannot be redeclared
struct integral_constant
   ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/type_traits:69:12:
 note: previous implicit declaration is here
struct integral_constant
   ^
/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TGenericClassInfo.cxx:18:10:
 fatal error: could not build module 'TCollectionProxyInfo.h'
#include "TCollectionProxyInfo.h"
 ^~~~
2 errors generated.

and

/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
error: multiple overloads of 'nothrow_t' instantiate to the same signature 
'void ()'
  struct nothrow_t { };
 ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:253:8: note: in 
instantiation of function template specialization '__gnu_cxx::new_allocator 
>::construct, const std::pair &>' requested here
{ __a.construct(__p, std::forward<_Args>(__args)...); }
  ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/alloc_traits.h:399:4: note: in instantiation 
of function template specialization 'std::allocator_traits > 
>::_S_construct, const std::pair &>' requested here
{ _S_construct(__a, __p, std::forward<_Args>(__args)...); }
  ^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/bits/stl_vector.h:917:21: note: in instantiation 
of function template specialization 'std::allocator_traits > 
>::construct, const std::pair &>' requested here
_Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
   ^
/mnt/build/workspace/root-nightly-master-cxxmodules/BUILDTYPE/Release/COMPILER/native/LABEL/sft-fedora-1/clang_build_269398/ROOT/src/core/meta/src/TSchemaRule.cxx:873:21:
 note: in instantiation of member function 'std::vector, 
std::allocator > >::push_back' requested here
  fVersionVect->push_back( verpair );
^
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../include/c++/4.9.2/new:99:10: 
note: previous implicit declaration is here
  struct nothrow_t { };

Shall I start reducing the issues one by one or we can revert this 
patch? Vassil On 13/05/16 08:47, Richard Smith via cfe-commits wrote:

Author: rsmith
Date: Fri May 13 01:47:56 2016
New Revision: 269398

URL: http://llvm.org/viewvc/llvm-project?rev=269398=rev
Log:
Add support for derived class special members hiding functions brought in from
a base class via a using-declaration. If a class has a using-declaration
declaring either a constructor or an assignment operator, eagerly declare its
special members in case they need to displace a shadow declaration from a
using-declaration.

Modified:
 cfe/trunk/include/clang/AST/DeclCXX.h
 cfe/trunk/include/clang/Sema/Sema.h
 cfe/trunk/lib/AST/ASTImporter.cpp
 cfe/trunk/lib/AST/DeclCXX.cpp
 cfe/trunk/lib/Sema/SemaDeclCXX.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
 cfe/trunk/test/SemaCUDA/implicit-member-target.cu
 cfe/trunk/test/SemaCXX/constructor-recovery.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=269398=269397=269398=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 13 01:47:56 2016
@@ -382,6 +382,14 @@ class CXXRecordDecl : public RecordDecl
  /// provided default ctor also doesn't have an in-class initializer.
  unsigned HasUninitializedFields : 1;
  
+/// \brief True if there are any member using-declarations that inherit

+/// constructors from a base class.
+unsigned HasInheritedConstructor : 1;
+
+/// \brief True if there are any member using-declarations named
+/// 'operator='.
+unsigned HasInheritedAssignment : 1;
+
  /// \brief These flags are \c true if a defaulted corresponding special
  /// member can't be fully analyzed without performing overload resolution.
  /// @{
@@ -1308,6 +1316,18 @@ public:
  return data().HasNonLiteralTypeFieldsOrBases;
}
  
+  /// \brief Determine whether this class has a using-declaration that names

+  /// a base class constructor.
+  bool 

r269398 - Add support for derived class special members hiding functions brought in from

2016-05-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 13 01:47:56 2016
New Revision: 269398

URL: http://llvm.org/viewvc/llvm-project?rev=269398=rev
Log:
Add support for derived class special members hiding functions brought in from
a base class via a using-declaration. If a class has a using-declaration
declaring either a constructor or an assignment operator, eagerly declare its
special members in case they need to displace a shadow declaration from a
using-declaration.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
cfe/trunk/test/SemaCUDA/implicit-member-target.cu
cfe/trunk/test/SemaCXX/constructor-recovery.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=269398=269397=269398=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 13 01:47:56 2016
@@ -382,6 +382,14 @@ class CXXRecordDecl : public RecordDecl
 /// provided default ctor also doesn't have an in-class initializer.
 unsigned HasUninitializedFields : 1;
 
+/// \brief True if there are any member using-declarations that inherit
+/// constructors from a base class.
+unsigned HasInheritedConstructor : 1;
+
+/// \brief True if there are any member using-declarations named
+/// 'operator='.
+unsigned HasInheritedAssignment : 1;
+
 /// \brief These flags are \c true if a defaulted corresponding special
 /// member can't be fully analyzed without performing overload resolution.
 /// @{
@@ -1308,6 +1316,18 @@ public:
 return data().HasNonLiteralTypeFieldsOrBases;
   }
 
+  /// \brief Determine whether this class has a using-declaration that names
+  /// a base class constructor.
+  bool hasInheritedConstructor() const {
+return data().HasInheritedConstructor;
+  }
+
+  /// \brief Determine whether this class has a using-declaration that names
+  /// a base class assignment operator.
+  bool hasInheritedAssignment() const {
+return data().HasInheritedAssignment;
+  }
+
   /// \brief Determine whether this class is considered trivially copyable per
   /// (C++11 [class]p6).
   bool isTriviallyCopyable() const;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=269398=269397=269398=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 13 01:47:56 2016
@@ -4540,6 +4540,9 @@ public:
   /// class.
   void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
 
+  /// \brief Check a completed declaration of an implicit special member.
+  void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD);
+
   /// \brief Determine whether the given function is an implicitly-deleted
   /// special member function.
   bool isImplicitlyDeleted(FunctionDecl *FD);

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=269398=269397=269398=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri May 13 01:47:56 2016
@@ -2115,6 +2115,8 @@ bool ASTNodeImporter::ImportDefinition(R
 ToData.HasUninitializedReferenceMember
   = FromData.HasUninitializedReferenceMember;
 ToData.HasUninitializedFields = FromData.HasUninitializedFields;
+ToData.HasInheritedConstructor = FromData.HasInheritedConstructor;
+ToData.HasInheritedAssignment = FromData.HasInheritedAssignment;
 ToData.NeedOverloadResolutionForMoveConstructor
   = FromData.NeedOverloadResolutionForMoveConstructor;
 ToData.NeedOverloadResolutionForMoveAssignment

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=269398=269397=269398=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri May 13 01:47:56 2016
@@ -53,6 +53,7 @@ CXXRecordDecl::DefinitionData::Definitio
   HasPublicFields(false), HasMutableFields(false), 
HasVariantMembers(false),
   HasOnlyCMembers(true), HasInClassInitializer(false),
   HasUninitializedReferenceMember(false), HasUninitializedFields(false),
+  HasInheritedConstructor(false), HasInheritedAssignment(false),
   NeedOverloadResolutionForMoveConstructor(false),