mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ASTGen] Generate miscellaneous builtin pound
`#error`, `#warning`, and `#assert`. Also #_hasSymbol statement condition
This commit is contained in:
@@ -58,5 +58,7 @@ func testPoundIf() {
|
||||
// pass
|
||||
} else if #unavailable(macOS 80) {
|
||||
// pass
|
||||
} else if #_hasSymbol(Int.self) { // expected-warning {{struct 'Int' is not a weakly linked declaration}}
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,3 +36,18 @@ struct S {
|
||||
|
||||
struct ExpansionRequirementTest<each T> {}
|
||||
extension ExpansionRequirementTest where repeat each T == Int {} // expected-error {{same-element requirements are not yet supported}}
|
||||
|
||||
|
||||
#warning("this is a warning") // expected-warning {{this is a warning}}
|
||||
|
||||
func testDiagnosticInFunc() {
|
||||
#error("this is an error") // expected-error {{this is an error}}
|
||||
}
|
||||
|
||||
class TestDiagnosticInNominalTy {
|
||||
#error("this is an error member") // expected-error {{this is an error member}}
|
||||
}
|
||||
|
||||
#if FLAG_NOT_ENABLED
|
||||
#error("error in inactive") // no diagnostis
|
||||
#endif
|
||||
|
||||
21
test/ASTGen/pound_assert.swift
Normal file
21
test/ASTGen/pound_assert.swift
Normal file
@@ -0,0 +1,21 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend-dump-parse -enable-experimental-feature ParserASTGen \
|
||||
// RUN: -enable-experimental-feature StaticAssert \
|
||||
// RUN: | %sanitize-address > %t/astgen.ast
|
||||
// RUN: %target-swift-frontend-dump-parse \
|
||||
// RUN: -enable-experimental-feature StaticAssert \
|
||||
// RUN: | %sanitize-address > %t/cpp-parser.ast
|
||||
|
||||
// RUN: %diff -u %t/astgen.ast %t/cpp-parser.ast
|
||||
|
||||
// RUN: %target-swift-emit-sil -verify %s -enable-experimental-feature ParserASTGen \
|
||||
// RUN: -enable-experimental-feature StaticAssert
|
||||
|
||||
// REQUIRES: swift_swift_parser
|
||||
// REQUIRES: swift_feature_ParserASTGen
|
||||
// REQUIRES: swift_feature_StaticAssert
|
||||
|
||||
func testPoundAssert() {
|
||||
#assert(1 == 1.0, "1 must be 1.0") // OK
|
||||
#assert(1 == 1.5, "1 is 1.5 ??") // expected-error {{1 is 1.5 ??}}
|
||||
}
|
||||
Reference in New Issue
Block a user