aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaOverload.cpp9
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp12
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 602ecd6602..e8dd56f66f 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1628,6 +1628,15 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
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 &&
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index 2d620b6da6..40492608c0 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -179,4 +179,14 @@ void static_func(); // expected-note {{previous declaration is here}}
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;
+}