<div dir="ltr">On Tue, Oct 22, 2013 at 2:56 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Tue Oct 22 16:56:38 2013<br>
New Revision: 193203<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=193203&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=193203&view=rev</a><br>
Log:<br>
Sema: Allow IndirectFieldDecl to appear in a non-type template argument<br>
<br>
We would not identify pointer-to-member construction in a non-type<br>
template argument if it was either a FieldDecl or a CXXMethodDecl.<br>
However, this would incorrectly reject declarations that were injected<br>
via an IndirectFieldDecl (e.g. a field inside of an anonymous union).<br></blockquote><div><br></div><div>Is this really correct? Such fields are not members of the enclosing non-anonymous struct. &Z::union_member below should have type "int Z::<anonymous union>::*", not "int Z::*", as far as I can tell.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This fixes PR17657.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=193203&r1=193202&r2=193203&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=193203&r1=193202&r2=193203&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Tue Oct 22 16:56:38 2013<br>
@@ -4609,8 +4609,11 @@ static bool CheckTemplateArgumentPointer<br>
diag::err_template_arg_not_pointer_to_member_form)<br>
<< Arg->getSourceRange();<br>
<br>
- if (isa<FieldDecl>(DRE->getDecl()) || isa<CXXMethodDecl>(DRE->getDecl())) {<br>
+ if (isa<FieldDecl>(DRE->getDecl()) ||<br>
+ isa<IndirectFieldDecl>(DRE->getDecl()) ||<br>
+ isa<CXXMethodDecl>(DRE->getDecl())) {<br>
assert((isa<FieldDecl>(DRE->getDecl()) ||<br>
+ isa<IndirectFieldDecl>(DRE->getDecl()) ||<br>
!cast<CXXMethodDecl>(DRE->getDecl())->isStatic()) &&<br>
"Only non-static member pointers can make it here");<br>
<br>
<br>
Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=193203&r1=193202&r2=193203&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp?rev=193203&r1=193202&r2=193203&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp (original)<br>
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype.cpp Tue Oct 22 16:56:38 2013<br>
@@ -75,6 +75,9 @@ struct Z {<br>
<br>
int int_member;<br>
float float_member;<br>
+ union {<br>
+ int union_member;<br>
+ };<br>
};<br>
template<int (Z::*pmf)(int)> struct A6; // expected-note{{template parameter is declared here}}<br>
A6<&Z::foo> *a17_1;<br>
@@ -88,6 +91,7 @@ A7<&Z::int_member> *a18_1;<br>
A7c<&Z::int_member> *a18_2;<br>
A7<&Z::float_member> *a18_3; // expected-error{{non-type template argument of type 'float Z::*' cannot be converted to a value of type 'int Z::*'}}<br>
A7c<(&Z::int_member)> *a18_4; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}}<br>
+A7c<&Z::union_member> *a18_5;<br></blockquote><div><br></div><div>Can we mangle this?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
template<unsigned char C> struct Overflow; // expected-note{{template parameter is declared here}}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>