File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
test/Interop/Cxx/library-evolution Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 3232#include " swift/Basic/Assertions.h"
3333#include " clang/AST/DeclCXX.h"
3434#include " clang/AST/DeclObjC.h"
35+ #include " clang/AST/Type.h"
3536
3637using namespace swift ;
3738
@@ -1862,6 +1863,15 @@ bool isFragileClangType(clang::QualType type) {
18621863 // Builtin clang types are compatible with library evolution.
18631864 if (underlyingTypePtr->isBuiltinType ())
18641865 return false ;
1866+ if (const auto *ft = dyn_cast<clang::FunctionType>(underlyingTypePtr)) {
1867+ if (const auto *fpt =
1868+ dyn_cast<clang::FunctionProtoType>(underlyingTypePtr)) {
1869+ for (auto paramTy : fpt->getParamTypes ())
1870+ if (isFragileClangType (paramTy))
1871+ return true ;
1872+ }
1873+ return isFragileClangType (ft->getReturnType ());
1874+ }
18651875 // Pointers to non-fragile types are non-fragile.
18661876 if (underlyingTypePtr->isPointerType ())
18671877 return isFragileClangType (underlyingTypePtr->getPointeeType ());
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ struct CStruct {
3939}
4040#endif
4141
42+ typedef void ( * my_sighandler_t) ( int) ;
43+ typedef void ( * my_other_cb) ( CxxStruct) ;
44+
4245//--- test.swift
4346
4447import CxxModule
@@ -55,3 +58,9 @@ public func useCxxEnum(_ x: CxxEnum) { // expected-error {{cannot use enum 'CxxE
5558// expected-error@+1 {{cannot use struct 'CxxStruct' here; C++ types from imported module 'CxxModule' do not support library evolution}}
5659public func usesCxxStruct( _ x: CxxStruct ) {
5760}
61+
62+ public func usesTypeAliasToFuncPtr( _ x: my_sighandler_t ) {
63+ }
64+
65+ public func usesTypeAliasToFuncPtr2( _ x: my_other_cb ) { // expected-error {{cannot use type alias 'my_other_cb' here; C++ types from imported module 'CxxModule' do not support library evolution}}
66+ }
You can’t perform that action at this time.
0 commit comments