cpplearner created this revision.
cpplearner added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.
This will allow the following code:
struct base {};
using cbase = const base;
struct inherit : cbase {
using cbase::cbase; // previously error: 'cbase' (aka 'const base') is
not a direct base of 'inherit', cannot inherit constructors
};
See
https://stackoverflow.com/questions/50534219/inherit-from-const-type-passed-as-template-parameter
Repository:
rC Clang
https://reviews.llvm.org/D47419
Files:
lib/Sema/SemaDeclCXX.cpp
test/CXX/special/class.inhctor/elsewhere.cpp
Index: test/CXX/special/class.inhctor/elsewhere.cpp
===================================================================
--- test/CXX/special/class.inhctor/elsewhere.cpp
+++ test/CXX/special/class.inhctor/elsewhere.cpp
@@ -62,3 +62,4 @@
G(int &) : G(0) {}
};
G<B1> g(123);
+G<const B1> g2(123);
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -9686,7 +9686,8 @@
QualType DesiredBase,
bool &AnyDependentBases) {
// Check whether the named type is a direct base class.
- CanQualType CanonicalDesiredBase =
DesiredBase->getCanonicalTypeUnqualified();
+ CanQualType CanonicalDesiredBase = DesiredBase->getCanonicalTypeUnqualified()
+ .getUnqualifiedType();
for (auto &Base : Derived->bases()) {
CanQualType BaseType = Base.getType()->getCanonicalTypeUnqualified();
if (CanonicalDesiredBase == BaseType)
Index: test/CXX/special/class.inhctor/elsewhere.cpp
===================================================================
--- test/CXX/special/class.inhctor/elsewhere.cpp
+++ test/CXX/special/class.inhctor/elsewhere.cpp
@@ -62,3 +62,4 @@
G(int &) : G(0) {}
};
G<B1> g(123);
+G<const B1> g2(123);
Index: lib/Sema/SemaDeclCXX.cpp
===================================================================
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -9686,7 +9686,8 @@
QualType DesiredBase,
bool &AnyDependentBases) {
// Check whether the named type is a direct base class.
- CanQualType CanonicalDesiredBase = DesiredBase->getCanonicalTypeUnqualified();
+ CanQualType CanonicalDesiredBase = DesiredBase->getCanonicalTypeUnqualified()
+ .getUnqualifiedType();
for (auto &Base : Derived->bases()) {
CanQualType BaseType = Base.getType()->getCanonicalTypeUnqualified();
if (CanonicalDesiredBase == BaseType)
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits