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 33
33
#include " swift/Basic/Assertions.h"
34
34
#include " clang/AST/DeclCXX.h"
35
35
#include " clang/AST/DeclObjC.h"
36
+ #include " clang/AST/Type.h"
36
37
37
38
using namespace swift ;
38
39
@@ -1947,6 +1948,15 @@ bool isFragileClangType(clang::QualType type) {
1947
1948
// Builtin clang types are compatible with library evolution.
1948
1949
if (underlyingTypePtr->isBuiltinType ())
1949
1950
return false ;
1951
+ if (const auto *ft = dyn_cast<clang::FunctionType>(underlyingTypePtr)) {
1952
+ if (const auto *fpt =
1953
+ dyn_cast<clang::FunctionProtoType>(underlyingTypePtr)) {
1954
+ for (auto paramTy : fpt->getParamTypes ())
1955
+ if (isFragileClangType (paramTy))
1956
+ return true ;
1957
+ }
1958
+ return isFragileClangType (ft->getReturnType ());
1959
+ }
1950
1960
// Pointers to non-fragile types are non-fragile.
1951
1961
if (underlyingTypePtr->isPointerType ())
1952
1962
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