[llvm-branch-commits] [cfe-branch] r196885 - Merging r196852:

Bill Wendling isanbard at gmail.com
Mon Dec 9 22:41:28 PST 2013


Author: void
Date: Tue Dec 10 00:41:28 2013
New Revision: 196885

URL: http://llvm.org/viewvc/llvm-project?rev=196885&view=rev
Log:
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.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
    cfe/branches/release_34/test/SemaTemplate/instantiate-member-pointers.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 10 00:41:28 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195495,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196143,196145,196153,196189-196192,196198-196199,196206,196208-196209,196211,196215,196359-196362,196370,196387,196423,196454,196456,196459,196488,196532-196533,196535,196538,196588,196593,196599,196612,196630,196658,196712,196720,196724,196771
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195249,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195495,195501,195547,195556,195558,195587,195620,195635,195669,195687,195693,195710,195713,195716,195756,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196045,196048,196050,196058,196114-196115,196143,196145,196153,196189-196192,196198-196199,196206,196208-196209,196211,196215,196359-196362,196370,196387,196423,196454,196456,196459,196488,196532-196533,196535,196538,196588,196593,196599,196612,196630,196658,196712,196720,196724,196771,196852
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaTemplate.cpp?rev=196885&r1=196884&r2=196885&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaTemplate.cpp Tue Dec 10 00:41:28 2013
@@ -4588,9 +4588,7 @@ static bool CheckTemplateArgumentPointer
   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 {

Modified: cfe/branches/release_34/test/SemaTemplate/instantiate-member-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaTemplate/instantiate-member-pointers.cpp?rev=196885&r1=196884&r2=196885&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaTemplate/instantiate-member-pointers.cpp (original)
+++ cfe/branches/release_34/test/SemaTemplate/instantiate-member-pointers.cpp Tue Dec 10 00:41:28 2013
@@ -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}}
+}





More information about the llvm-branch-commits mailing list