File: misc-suspicious-semicolon-fail.cpp

package info (click to toggle)
llvm-toolchain-6.0 1%3A6.0.1-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 598,080 kB
  • sloc: cpp: 3,046,253; ansic: 595,057; asm: 271,965; python: 128,926; objc: 106,554; sh: 21,906; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,227; cs: 2,027; xml: 686; php: 212; csh: 117
file content (26 lines) | stat: -rw-r--r-- 1,004 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
// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- -DERROR 2>&1 \
// RUN:   | FileCheck %s -check-prefix=CHECK-ERROR \
// RUN:       -implicit-check-not="{{warning|error}}:"
// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic*" \
// RUN:    -- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \
// RUN:   | FileCheck %s -check-prefix=CHECK-WERROR \
// RUN:       -implicit-check-not="{{warning|error}}:"

// Note: This test verifies that, the checker does not emit any warning for
//       files that do not compile.

bool g();

void f() {
  if (g());
  // CHECK-WERROR: :[[@LINE-1]]:11: warning: potentially unintended semicolon [misc-suspicious-semicolon]
#if ERROR
  int a
  // CHECK-ERROR: :[[@LINE-1]]:8: error: expected ';' at end of declaration [clang-diagnostic-error]
#elif WERROR
  int a;
  // CHECK-WERROR: :[[@LINE-1]]:7: error: unused variable 'a' [clang-diagnostic-unused-variable]
#else
#error "One of ERROR or WERROR should be defined.
#endif
}