File: warning-suppression-mappings.cpp

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,235,796 kB
  • sloc: cpp: 7,617,614; ansic: 1,433,901; asm: 1,058,726; python: 252,096; f90: 94,671; objc: 70,753; lisp: 42,813; pascal: 18,401; sh: 10,032; ml: 5,111; perl: 4,720; awk: 3,523; makefile: 3,401; javascript: 2,272; xml: 892; fortran: 770
file content (31 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (6)
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
// Check for warnings
// RUN: not %clang --warning-suppression-mappings=foo.txt -fsyntax-only %s 2>&1 | FileCheck -check-prefix MISSING_MAPPING %s
// RUN: not %clang -cc1 --warning-suppression-mappings=foo.txt -fsyntax-only %s 2>&1 | FileCheck -check-prefix MISSING_MAPPING %s
// MISSING_MAPPING: error: no such file or directory: 'foo.txt'

// Check that it's no-op when diagnostics aren't enabled.
// RUN: %clang -cc1 -Wno-everything -Werror --warning-suppression-mappings=%S/Inputs/suppression-mapping.txt -fsyntax-only %s 2>&1 | FileCheck -check-prefix WARNINGS_DISABLED --allow-empty %s
// WARNINGS_DISABLED-NOT: warning:
// WARNINGS_DISABLED-NOT: error:

// RUN: %clang -cc1 -verify -Wformat=2 -Wunused --warning-suppression-mappings=%S/Inputs/suppression-mapping.txt -fsyntax-only %s

__attribute__((__format__ (__printf__, 1, 2)))
void format_err(const char* const pString, ...);

namespace {
void foo() {
  const char *x;
  format_err(x); // Warning suppressed here.
  const char *y; // expected-warning{{unused variable 'y'}}
}
}

#line 42 "foo/bar.h"
namespace {
void bar() { // expected-warning{{unused function 'bar'}}
  const char *x;
  format_err(x); // expected-warning{{format string is not a string literal (potentially insecure)}} \
                 // expected-note{{treat the string as an argument to avoid this}}
}
}