File: pound_diagnostics.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (84 lines) | stat: -rw-r--r-- 3,536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// RUN: %target-typecheck-verify-swift
// RUN: %target-swift-frontend -c -verify %s -o /dev/null

#warning("this should be a warning") // expected-warning {{this should be a warning}}
#error("this should be an error") // expected-error {{this should be an error}}

#if false
#error("this shouldn't cause any errors")
#endif

#if true
#error("this should also be an error") // expected-error {{this should also be an error}}
#endif

#error() // expected-error {{expected string literal in #error directive}}
#warning() // expected-error {{expected string literal in #warning directive}}

#error(test 123) // expected-error {{expected string literal in #error directive}}{{8-8="}}{{16-16="}}

#error test 123 // expected-error {{expected string literal in #error directive}}{{8-8=("}}{{16-16=")}}

#error "no parentheses error" // expected-error {{#error directive requires parentheses}}{{8-8=(}}{{30-30=)}}
#warning "no parentheses warning" // expected-error {{#warning directive requires parentheses}}{{10-10=(}}{{34-34=)}}

#error "left parentheses error") // expected-error {{expected '(' in #error directive}}{{8-8=(}}
#warning("right parentheses warning" // expected-error {{expected ')' in #warning directive}}{{37-37=)}}

#error("interp\("olation")") // expected-error {{string interpolation is not allowed in #error directive}}
#warning("interp\("olation")") // expected-error {{string interpolation is not allowed in #warning directive}}

#error("extra tokens") var i = 0 // expected-error {{extra tokens following #error directive}}
#warning("extra tokens") var j = 0 // expected-error {{extra tokens following #warning directive}}

class RegularClass {
  #error("errors can be nested in classes") // expected-error {{errors can be nested in classes}}
}

struct RegularStruct {
  #error("errors can be nested in structs") // expected-error {{errors can be nested in structs}}
}

protocol RegularProtocol {
  #warning("warnings can be nested in protocols") // expected-warning {{warnings can be nested in protocols}}
}

extension RegularClass {
  #error("errors can be nested in extensions") // expected-error {{errors can be nested in extensions}}
}

func foo() {
  #error("errors can be nested in functions") // expected-error {{errors can be nested in functions}}

  switch 34 {
  #warning("warnings can be nested in switch statements") // expected-warning {{warnings can be nested in switch statements}}
  #if true
  #error("errors can be nested in if-configs inside switch statements too") // expected-error {{errors can be nested in if-configs inside switch statements too}}
  case 5:
  #warning("way too many levels of nesting") // expected-warning {{way too many levels of nesting}}
  #elseif false
  #error("this still shouldn't trip")
  #endif
  default: break
  }
}

public // expected-error @+1 {{expected declaration}}
#warning("public warning") // expected-warning {{public warning}}
func bar() {}

class C { // expected-note {{in declaration of 'C'}}
  private // expected-error @+1 {{expected declaration}}
  #error("private error") // expected-error  {{private error}}
  func bar() {}
}

protocol MyProtocol {
  #warning("warnings can show up in protocols too!") // expected-warning {{warnings can show up in protocols too!}}
}

#warning("""
         warnings support multi-line string literals
         """) // expected-warning @-2 {{warnings support multi-line string literals}}

#warning(#"warnings support \(custom string delimiters)"#) // expected-warning {{warnings support \\(custom string delimiters)}}