Files
swift-mirror/test/Interop/Cxx/class/constructor-inherited-from-base-irgen.cpp
Pavel Yaskevich c019b669a1 [Tests] NFC: Rename a few Cxx tests to use .cpp extension instead of .swift
These are split-file C++ tests, this is a problem for swift-syntax
because `.swift` tests get parsed for round-trip testing if
swift-syntax is located near swift.
2025-05-31 10:49:50 -07:00

51 lines
1.1 KiB
C++

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %target-swiftxx-frontend -emit-ir -I %t/Inputs -validate-tbd-against-ir=none %t/test.swift | %FileCheck %s
//--- Inputs/module.modulemap
module BaseConstructor {
header "test.h"
requires cplusplus
}
//--- Inputs/test.h
extern void referencedSymbol();
inline void emittedIntoSwiftObject() { referencedSymbol(); }
class BaseClass {
public:
inline BaseClass() : x(0) {}
inline BaseClass(bool v, const BaseClass &) {
if (v)
emittedIntoSwiftObject();
}
int x;
};
class DerivedClass: public BaseClass {
int y;
public:
using BaseClass::BaseClass;
inline DerivedClass(int y) : y(y) {}
inline int test() const {
DerivedClass m(true, *this);
return m.x;
}
};
//--- test.swift
import BaseConstructor
public func test() {
let i = DerivedClass(0)
let v = i.test()
}
// Make sure we reach clang declarations accessible from base constructors:
// CHECK: define linkonce_odr{{( dso_local)?}} void @{{_Z22emittedIntoSwiftObjectv|"\?emittedIntoSwiftObject@@YAXXZ"}}