1
1
// RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp
2
- // RUN: not clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes,clang-diagnostic-zero-length-array' -export-fixes=%t.yaml -- -Wmissing-prototypes -Wzero-length-array > %t.msg 2>&1
2
+ // RUN: not clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes,clang-diagnostic-zero-length-array' --warnings-as-errors='clang-diagnostic-missing-prototypes,google-explicit-constructor' - export-fixes=%t.yaml -- -Wmissing-prototypes -Wzero-length-array > %t.msg 2>&1
3
3
// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{warning|error|note}}:'
4
4
// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
5
5
#define X (n ) void n ## n() {}
@@ -10,9 +10,10 @@ int b[0];
10
10
void test (x);
11
11
struct Foo {
12
12
member;
13
+ Foo (int ) {}
13
14
};
14
15
15
- // CHECK-MESSAGES: -input.cpp:2:1: warning : no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
16
+ // CHECK-MESSAGES: -input.cpp:2:1: error : no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes,-warnings-as-errors ]
16
17
// CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
17
18
// CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
18
19
// CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
@@ -21,6 +22,7 @@ struct Foo {
21
22
// CHECK-MESSAGES: -input.cpp:4:7: warning: zero size arrays are an extension [clang-diagnostic-zero-length-array]
22
23
// CHECK-MESSAGES: -input.cpp:6:11: error: unknown type name 'x' [clang-diagnostic-error]
23
24
// CHECK-MESSAGES: -input.cpp:8:3: error: a type specifier is required for all declarations [clang-diagnostic-error]
25
+ // CHECK-MESSAGES: -input.cpp:9:3: error: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [google-explicit-constructor,-warnings-as-errors]
24
26
25
27
// CHECK-YAML: ---
26
28
// CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp'
@@ -52,7 +54,7 @@ struct Foo {
52
54
// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
53
55
// CHECK-YAML-NEXT: FileOffset: 13
54
56
// CHECK-YAML-NEXT: Replacements: []
55
- // CHECK-YAML-NEXT: Level: Warning
57
+ // CHECK-YAML-NEXT: Level: Error
56
58
// CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
57
59
// CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-error
58
60
// CHECK-YAML-NEXT: DiagnosticMessage:
@@ -94,4 +96,16 @@ struct Foo {
94
96
// CHECK-YAML-NEXT: Replacements: []
95
97
// CHECK-YAML-NEXT: Level: Error
96
98
// CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
99
+ // CHECK-YAML-NEXT: - DiagnosticName: google-explicit-constructor
100
+ // CHECK-YAML-NEXT: DiagnosticMessage:
101
+ // CHECK-YAML-NEXT: Message: single-argument constructors must be marked explicit to avoid unintentional implicit conversions
102
+ // CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
103
+ // CHECK-YAML-NEXT: FileOffset: 96
104
+ // CHECK-YAML-NEXT: Replacements:
105
+ // CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp'
106
+ // CHECK-YAML-NEXT: Offset: 96
107
+ // CHECK-YAML-NEXT: Length: 0
108
+ // CHECK-YAML-NEXT: ReplacementText: 'explicit '
109
+ // CHECK-YAML-NEXT: Level: Error
110
+ // CHECK-YAML-NEXT: BuildDirectory: '{{.*}}'
97
111
// CHECK-YAML-NEXT: ...
0 commit comments