mirror of https://github.com/microsoft/clang.git
Sema: Enforce C++11 pointer-to-member template arguments should rules
The standard is pretty clear on what it allows inside of template arguments for non-type template parameters of pointer-to-member. They must be of the form &qualified-id and cannot come from sources like constexpr VarDecls or things of that nature. This fixes PR18192. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196852 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
cdc988f427
commit
fe34a2b420
|
@ -4584,9 +4584,7 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S,
|
|||
else if ((DRE = dyn_cast<DeclRefExpr>(Arg))) {
|
||||
if (ValueDecl *VD = dyn_cast<ValueDecl>(DRE->getDecl())) {
|
||||
if (VD->getType()->isMemberPointerType()) {
|
||||
if (isa<NonTypeTemplateParmDecl>(VD) ||
|
||||
(isa<VarDecl>(VD) &&
|
||||
S.Context.getCanonicalType(VD->getType()).isConstQualified())) {
|
||||
if (isa<NonTypeTemplateParmDecl>(VD)) {
|
||||
if (Arg->isTypeDependent() || Arg->isValueDependent()) {
|
||||
Converted = TemplateArgument(Arg);
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
||||
struct Y {
|
||||
int x;
|
||||
};
|
||||
|
@ -65,3 +65,10 @@ namespace ValueDepMemberPointer {
|
|||
}
|
||||
S<int> s;
|
||||
}
|
||||
|
||||
namespace PR18192 {
|
||||
struct A { struct { int n; }; };
|
||||
template<int A::*> struct X {};
|
||||
constexpr int A::*p = &A::n;
|
||||
X<p> x; // expected-error{{not a pointer to member constant}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue