mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
(cherry picked from commit c019b669a1)
51 lines
1.1 KiB
C++
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"}}
|