summaryrefslogtreecommitdiff
path: root/clang/test/ClangScanDeps/diagnostic-pragmas.c
blob: 520f82047d2b12f4f9b4b937d87b584af93b8db3 (plain)
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
// Test scanning deps does not have more errors than the regular compilation.

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json

// Check the regular compilation does not fail.
// RUN: %clang -fsyntax-only %t/test.c -I %t/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -Wnon-modular-include-in-module -Werror=non-modular-include-in-module

// And now scanning deps should succeed too.
// RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1

//--- cdb.json.template
[
  {
    "directory": "DIR",
    "command": "clang -fsyntax-only DIR/test.c -I DIR/include -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -Wnon-modular-include-in-module -Werror=non-modular-include-in-module",
    "file": "DIR/test.c"
  },
]

//--- include/nonmodular.h
// empty

//--- include/modular-includer.h
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnon-modular-include-in-module"
#include <nonmodular.h>
#pragma clang diagnostic pop

//--- include/module.modulemap
module ModularIncluder { header "modular-includer.h" }

//--- test.c
#include <modular-includer.h>