Skip to content

Commit d038fa7

Browse files
authored
Merge pull request #70401 from apple/egorzhdan/reference-semantics-warning
[cxx-interop] Fix incorrect diagnostic for non-imported functions
2 parents 35eb5cb + 4a77ae8 commit d038fa7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,13 +3202,16 @@ namespace {
32023202

32033203
if (auto recordType = dyn_cast<clang::RecordType>(
32043204
decl->getReturnType().getCanonicalType())) {
3205-
Impl.addImportDiagnostic(
3206-
decl, Diagnostic(diag::reference_passed_by_value,
3207-
Impl.SwiftContext.AllocateCopy(
3208-
recordType->getDecl()->getNameAsString()),
3209-
"the return"),
3210-
decl->getLocation());
3211-
return recordHasReferenceSemantics(recordType->getDecl());
3205+
if (recordHasReferenceSemantics(recordType->getDecl())) {
3206+
Impl.addImportDiagnostic(
3207+
decl,
3208+
Diagnostic(diag::reference_passed_by_value,
3209+
Impl.SwiftContext.AllocateCopy(
3210+
recordType->getDecl()->getNameAsString()),
3211+
"the return"),
3212+
decl->getLocation());
3213+
return true;
3214+
}
32123215
}
32133216

32143217
return false;

0 commit comments

Comments
 (0)