[cfe-commits] r131076 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/MicrosoftExtensions.cpp
Francois Pichet
pichet2000 at gmail.com
Sun May 8 15:52:41 PDT 2011
Author: fpichet
Date: Sun May 8 17:52:41 2011
New Revision: 131076
URL: http://llvm.org/viewvc/llvm-project?rev=131076&view=rev
Log:
Allow implicit conversion from function pointer to void* in Microsoft mode.
Necessary to parse MFC code.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=131076&r1=131075&r2=131076&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun May 8 17:52:41 2011
@@ -1628,6 +1628,15 @@
return true;
}
+ // MSVC allows implicit function to void* type conversion.
+ if (getLangOptions().Microsoft && FromPointeeType->isFunctionType() &&
+ ToPointeeType->isVoidType()) {
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ToPointeeType,
+ ToType, Context);
+ return true;
+ }
+
// When we're overloading in C, we allow a special kind of pointer
// conversion for compatible-but-not-identical pointee types.
if (!getLangOptions().CPlusPlus &&
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=131076&r1=131075&r2=131076&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Sun May 8 17:52:41 2011
@@ -179,4 +179,14 @@
static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
{
-}
\ No newline at end of file
+}
+
+long function_prototype(int a);
+long (*function_ptr)(int a);
+
+void function_to_voidptr_conv() {
+ void *a1 = function_prototype;
+ void *a2 = &function_prototype;
+ void *a1 = function_ptr;
+ void *a2 = &function_ptr;
+}
More information about the cfe-commits
mailing list