This is an archive of the discontinued LLVM Phabricator instance.

[SemaDeclCXX] Allow inheriting constructor declaration that specify a cv-qualified type
ClosedPublic

Authored by cpplearner on May 27 2018, 3:36 AM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

cpplearner created this revision.May 27 2018, 3:36 AM
rustam added a subscriber: rustam.May 27 2018, 11:27 AM

I believe this fixed the bug #37600

rsmith added inline comments.May 27 2018, 7:39 PM
lib/Sema/SemaDeclCXX.cpp
9690 ↗(On Diff #148744)

How are we getting a qualified type here? Is this actually a bug in getCanonicalTypeUnqualified?

cpplearner added inline comments.May 30 2018, 5:34 AM
lib/Sema/SemaDeclCXX.cpp
9690 ↗(On Diff #148744)

It seems that getCanonicalTypeUnqualified does not strip qualifiers from the canonical type. I guess "Unqualified" here just means the method does not include local qualifiers, unlike QualType::getCanonicalType.

Thus, in the case of using cbase = const base;, getCanonicalTypeUnqualified will return the canonical type of cbase as is, which is const base, a const-qualified type.

Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2019, 3:27 AM
rjmccall accepted this revision.Aug 12 2019, 10:27 AM
rjmccall added inline comments.
lib/Sema/SemaDeclCXX.cpp
9690 ↗(On Diff #148744)

Maybe we should have a method that promises to return an unqualified type.

This change seems reasonable overall.

This revision is now accepted and ready to land.Aug 12 2019, 10:27 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2019, 1:57 PM