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 32
32
#include " swift/Basic/Assertions.h"
33
33
#include " clang/AST/DeclCXX.h"
34
34
#include " clang/AST/DeclObjC.h"
35
+ #include " clang/AST/Type.h"
35
36
36
37
using namespace swift ;
37
38
@@ -1862,6 +1863,15 @@ bool isFragileClangType(clang::QualType type) {
1862
1863
// Builtin clang types are compatible with library evolution.
1863
1864
if (underlyingTypePtr->isBuiltinType ())
1864
1865
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
+ }
1865
1875
// Pointers to non-fragile types are non-fragile.
1866
1876
if (underlyingTypePtr->isPointerType ())
1867
1877
return isFragileClangType (underlyingTypePtr->getPointeeType ());
Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ struct CStruct {
39
39
}
40
40
#endif
41
41
42
+ typedef void ( * my_sighandler_t) ( int) ;
43
+ typedef void ( * my_other_cb) ( CxxStruct) ;
44
+
42
45
//--- test.swift
43
46
44
47
import CxxModule
@@ -55,3 +58,9 @@ public func useCxxEnum(_ x: CxxEnum) { // expected-error {{cannot use enum 'CxxE
55
58
// expected-error@+1 {{cannot use struct 'CxxStruct' here; C++ types from imported module 'CxxModule' do not support library evolution}}
56
59
public func usesCxxStruct( _ x: CxxStruct ) {
57
60
}
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