Page MenuHomePhabricator

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

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

Details

Reviewers
rsmith
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
rC Clang

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

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

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.