mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Syntactically verify that initializer expressions of '@const' variables and argument expressions to '@const' parameters consist strictly of syntactically-verifiable set of basic values and operations
25 lines
955 B
Swift
25 lines
955 B
Swift
// Constant globals should "work" when referencing C-imported constants
|
|
// REQUIRES: swift_feature_CompileTimeValues
|
|
// REQUIRES: swift_feature_CompileTimeValuesPreview
|
|
// REQUIRES: rdar146952876
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// RUN: %target-swift-frontend -emit-ir -primary-file %t/main.swift -parse-as-library -import-bridging-header %t/bridging_header.h -enable-experimental-feature CompileTimeValues -enable-experimental-feature CompileTimeValuesPreview
|
|
// RUN: %target-swift-frontend -emit-ir -primary-file %t/main.swift -parse-as-library -import-bridging-header %t/bridging_header.h -enable-experimental-feature CompileTimeValues
|
|
|
|
//--- bridging_header.h
|
|
|
|
static const int c_integer = 42;
|
|
static const long c_long = 42;
|
|
|
|
struct CStruct {
|
|
int a, b, c, d;
|
|
};
|
|
|
|
//--- main.swift
|
|
|
|
@const let constGlobal1: Int = Int(c_integer)
|
|
@const let constGlobal2: Int = Int(c_long)
|
|
@const let constGlobal3: Int = MemoryLayout<CStruct>.size
|