diff options
| author | Bill Wendling <isanbard@gmail.com> | 2013-12-10 06:41:28 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2013-12-10 06:41:28 +0000 |
| commit | 2b3c4937d643743717b13bd8a374a72bc0eb7542 (patch) | |
| tree | 289742e2a813092bfd34cb205f8464ebf0a4f794 | |
| parent | 01f3d00bc5074a2f105eda35ef7aee8088e938d6 (diff) | |
| download | clang-2b3c4937d643743717b13bd8a374a72bc0eb7542.tar.gz clang-2b3c4937d643743717b13bd8a374a72bc0eb7542.tar.bz2 clang-2b3c4937d643743717b13bd8a374a72bc0eb7542.tar.xz | |
Merging r196852:
------------------------------------------------------------------------
r196852 | majnemer | 2013-12-09 16:40:58 -0800 (Mon, 09 Dec 2013) | 10 lines
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/branches/release_34@196885 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | lib/Sema/SemaTemplate.cpp | 4 | ||||
| -rw-r--r-- | test/SemaTemplate/instantiate-member-pointers.cpp | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 56eedc97a9..950edba46d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4588,9 +4588,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 { 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<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}} +} |
