From: David Majnemer Date: Tue, 10 Dec 2013 00:40:58 +0000 (+0000) Subject: Sema: Enforce C++11 pointer-to-member template arguments should rules X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe34a2b420c2b7f543443e5e847e6e58d5aae1cf;p=clang 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 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index d72c04c012..20a3d28331 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4584,9 +4584,7 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, else if ((DRE = dyn_cast(Arg))) { if (ValueDecl *VD = dyn_cast(DRE->getDecl())) { if (VD->getType()->isMemberPointerType()) { - if (isa(VD) || - (isa(VD) && - S.Context.getCanonicalType(VD->getType()).isConstQualified())) { + if (isa(VD)) { if (Arg->isTypeDependent() || Arg->isValueDependent()) { Converted = TemplateArgument(Arg); } else { diff --git a/test/SemaTemplate/instantiate-member-pointers.cpp b/test/SemaTemplate/instantiate-member-pointers.cpp index 0db90e3cbf..4757870d13 100644 --- a/test/SemaTemplate/instantiate-member-pointers.cpp +++ b/test/SemaTemplate/instantiate-member-pointers.cpp @@ -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 s; } + +namespace PR18192 { + struct A { struct { int n; }; }; + template struct X {}; + constexpr int A::*p = &A::n; + X

x; // expected-error{{not a pointer to member constant}} +}