The machinery added to permit a static_cast from void-ptr to fn-ptr
unintentionally gets triggered for c-style casts and function-style
casts. The observable effect was a diagnostic issued inappropriately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239382
91177308-0d34-0410-b5e6-
96231b3b80d8
// Microsoft permits static_cast from 'pointer-to-void' to
// 'pointer-to-function'.
- if (Self.getLangOpts().MSVCCompat && DestPointee->isFunctionType()) {
+ if (!CStyle && Self.getLangOpts().MSVCCompat &&
+ DestPointee->isFunctionType()) {
Self.Diag(OpRange.getBegin(), diag::ext_ms_cast_fn_obj) << OpRange;
Kind = CK_BitCast;
return TC_Success;
ENUM var2 = (ENUM)3;
enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-void (*PR23733)() = static_cast<void (*)()>((void *)0); // expected-warning {{static_cast between pointer-to-function and pointer-to-object is a Microsoft extension}}
+typedef void (*FnPtrTy)();
+void (*PR23733_1)() = static_cast<FnPtrTy>((void *)0); // expected-warning {{static_cast between pointer-to-function and pointer-to-object is a Microsoft extension}}
+void (*PR23733_2)() = FnPtrTy((void *)0);
+void (*PR23733_3)() = (FnPtrTy)((void *)0);
+void (*PR23733_4)() = reinterpret_cast<FnPtrTy>((void *)0);