Skip to content

Commit 3129f75

Browse files
committed
eliminate template type constraint and add additional tests
1 parent 3ffaa3a commit 3129f75

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2655,7 +2655,7 @@ CXXBaseSpecifier *Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
26552655
return nullptr;
26562656
}
26572657

2658-
if (BaseType.hasQualifiers() && !isa<SubstTemplateTypeParmType>(BaseType)) {
2658+
if (BaseType.hasQualifiers()) {
26592659
std::string Quals =
26602660
BaseType.getQualifiers().getAsString(Context.getPrintingPolicy());
26612661
Diag(BaseLoc, diag::warn_qual_base_type)

clang/test/SemaCXX/warn-base-type-qualifiers.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// RUN: %clang_cc1 %s -std=c++11 -Wignored-qualifiers -verify
22

3+
template <typename T> struct add_const {
4+
using type = const T;
5+
};
6+
template <typename T> using add_const_t = typename add_const<T>::type;
7+
38
class A { };
49

510
typedef const A A_Const;
@@ -13,8 +18,18 @@ class C : public A_Const_Volatile { }; // expected-warning {{'const volatile' qu
1318
struct D {
1419
D(int);
1520
};
16-
template <typename T> struct E : T {
21+
22+
template <typename T> struct E : T { // expected-warning {{'const' qualifier on base class type 'const D' have no effect}} \
23+
// expected-note {{base class 'const D' specified here}}
1724
using T::T;
1825
E(int &) : E(0) {}
1926
};
20-
E<const D> e(1);
27+
E<const D> e(1); // expected-note {{in instantiation of template class 'E<const D>' requested here}}
28+
29+
template <typename T>
30+
struct G : add_const<T>::type { // expected-warning {{'const' qualifier on base class type 'add_const<D>::type' (aka 'const D') have no effect}} \
31+
// expected-note {{base class 'add_const<D>::type' (aka 'const D') specified here}}
32+
using T::T;
33+
G(int &) : G(0) {}
34+
};
35+
G<D> g(1); // expected-note {{in instantiation of template class 'G<D>' requested here}}

0 commit comments

Comments
 (0)