<div dir="ltr"><div>I think we more commonly say "function pointer":</div><div><br></div><div>$ grep 'pointer-to-function' include/clang/Basic/Diagnostic*td | wc -l</div><div> 3</div><div>$ grep 'function pointer' include/clang/Basic/Diagnostic*td | wc -l</div><div> 7</div><div><br></div><div>For "object pointer" and "pointer-to-object" it's currently a tie. For "member pointer" and "pointer-to-member", the former is more common too. We should probably make all of these consistent – any preferences? "foo pointer" reads easier to me than "pointer-to-foo", but I'm not a native speaker.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 31, 2015 at 1:42 AM, David Majnemer via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Sat Oct 31 03:42:14 2015<br>
New Revision: 251738<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=251738&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=251738&view=rev</a><br>
Log:<br>
[MSVC Compat] Permit conversions from pointer-to-function to pointer-to-object iff -fms-compatibility<br>
<br>
We permit implicit conversion from pointer-to-function to<br>
pointer-to-object when -fms-extensions is specified. This is rather<br>
unfortunate, move this into -fms-compatibility and only permit it within<br>
system headers unless -Wno-error=microsoft-cast is specified.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Sema/SemaOverload.cpp<br>
cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp<br>
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251738&r1=251737&r2=251738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=251738&r1=251737&r2=251738&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Oct 31 03:42:14 2015<br>
@@ -2635,6 +2635,10 @@ def warn_impcast_null_pointer_to_integer<br>
def warn_impcast_floating_point_to_bool : Warning<<br>
"implicit conversion turns floating-point number into bool: %0 to %1">,<br>
InGroup<ImplicitConversionFloatingPointToBool>;<br>
+def ext_ms_impcast_fn_obj : ExtWarn<<br>
+ "implicit conversion between pointer-to-function and pointer-to-object is a "<br>
+ "Microsoft extension">,<br>
+ InGroup<MicrosoftCast>, DefaultError, SFINAEFailure;<br>
<br>
def warn_impcast_pointer_to_bool : Warning<<br>
"address of%select{| function| array}0 '%1' will always evaluate to "<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=251738&r1=251737&r2=251738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=251738&r1=251737&r2=251738&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sat Oct 31 03:42:14 2015<br>
@@ -2104,7 +2104,7 @@ bool Sema::IsPointerConversion(Expr *Fro<br>
}<br>
<br>
// MSVC allows implicit function to void* type conversion.<br>
- if (getLangOpts().MicrosoftExt && FromPointeeType->isFunctionType() &&<br>
+ if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() &&<br>
ToPointeeType->isVoidType()) {<br>
ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,<br>
ToPointeeType,<br>
@@ -2666,6 +2666,14 @@ bool Sema::CheckPointerConversion(Expr *<br>
// The conversion was successful.<br>
Kind = CK_DerivedToBase;<br>
}<br>
+<br>
+ if (!IsCStyleOrFunctionalCast && FromPointeeType->isFunctionType() &&<br>
+ ToPointeeType->isVoidType()) {<br>
+ assert(getLangOpts().MSVCCompat &&<br>
+ "this should only be possible with MSVCCompat!");<br>
+ Diag(From->getExprLoc(), diag::ext_ms_impcast_fn_obj)<br>
+ << From->getSourceRange();<br>
+ }<br>
}<br>
} else if (const ObjCObjectPointerType *ToPtrType =<br>
ToType->getAs<ObjCObjectPointerType>()) {<br>
<br>
Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=251738&r1=251737&r2=251738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=251738&r1=251737&r2=251738&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp Sat Oct 31 03:42:14 2015<br>
@@ -12,3 +12,12 @@ void (*PR23733_1)() = static_cast<FnPtrT<br>
void (*PR23733_2)() = FnPtrTy((void *)0);<br>
void (*PR23733_3)() = (FnPtrTy)((void *)0);<br>
void (*PR23733_4)() = reinterpret_cast<FnPtrTy>((void *)0);<br>
+<br>
+long function_prototype(int a);<br>
+long (*function_ptr)(int a);<br>
+<br>
+void function_to_voidptr_conv() {<br>
+ void *a1 = function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}<br>
+ void *a2 = &function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}<br>
+ void *a3 = function_ptr; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}<br>
+}<br>
<br>
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=251738&r1=251737&r2=251738&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=251738&r1=251737&r2=251738&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Sat Oct 31 03:42:14 2015<br>
@@ -153,16 +153,6 @@ static void static_func() // expected-wa<br>
extern const int static_var; // expected-note {{previous declaration is here}}<br>
static const int static_var = 3; // expected-warning {{redeclaring non-static 'static_var' as static is a Microsoft extension}}<br>
<br>
-long function_prototype(int a);<br>
-long (*function_ptr)(int a);<br>
-<br>
-void function_to_voidptr_conv() {<br>
- void *a1 = function_prototype;<br>
- void *a2 = &function_prototype;<br>
- void *a3 = function_ptr;<br>
-}<br>
-<br>
-<br>
void pointer_to_integral_type_conv(char* ptr) {<br>
char ch = (char)ptr;<br>
short sh = (short)ptr;<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>