Author: majnemer
Date: Sat Oct 26 00:02:13 2013
New Revision: 193461

URL: http://llvm.org/viewvc/llvm-project?rev=193461&view=rev
Log:
Sema: Correctly build pointer-to-member arguments from a template argument with 
an IndirectFieldDecl

We only considered FieldDecl and CXXMethodDecl as appropriate which
would cause us to believe the IndirectFieldDecl corresponded to an
argument of it's field type instead of a pointer-to-member type.

This fixes PR17696.

Modified:
    cfe/trunk/lib/Sema/SemaTemplate.cpp
    cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=193461&r1=193460&r2=193461&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat Oct 26 00:02:13 2013
@@ -5075,7 +5075,8 @@ Sema::BuildExpressionFromDeclTemplateArg
   ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl());
 
   if (VD->getDeclContext()->isRecord() &&
-      (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD))) {
+      (isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
+       isa<IndirectFieldDecl>(VD))) {
     // If the value is a class member, we might have a pointer-to-member.
     // Determine whether the non-type template template parameter is of
     // pointer-to-member type. If so, we need to build an appropriate

Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=193461&r1=193460&r2=193461&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Sat Oct 26 00:02:13 2013
@@ -350,3 +350,17 @@ namespace rdar13806270 {
   };
   void foo() {}
 }
+
+namespace PR17696 {
+  struct a {
+    union {
+      int i;
+    };
+  };
+
+  template <int (a::*p)> struct b : a {
+    b() { this->*p = 0; }
+  };
+
+  b<&a::i> c; // okay
+}


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to