]> granicus.if.org Git - clang/commitdiff
Sema: Correctly build pointer-to-member arguments from a template argument with an...
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 26 Oct 2013 05:02:13 +0000 (05:02 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 26 Oct 2013 05:02:13 +0000 (05:02 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193461 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplate.cpp
test/SemaTemplate/temp_arg_nontype.cpp

index c8e2b0dd89666037344441f060e27cc9d8900466..198b479ba144b30fc76e572e223994e28d3fef7a 100644 (file)
@@ -5075,7 +5075,8 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
   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
index fcdfd458f34178e4a5c3e9f991b54046b59ac657..8f6cc192fa8b35e2b0f11b6e6703afb8827485e7 100644 (file)
@@ -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
+}