xref: /llvm-project/clang/test/Modules/diagnostics.modulemap (revision 8839e278ffcadc62b333423de07756488cae980f)
149532137SNico Weber// RUN: rm -rf %t
2040e1266SRichard Smith// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s --implicit-check-not error:
3ac425e91SRichard Smith
4ae6df27eSRichard Smith// CHECK: In file included from {{.*}}diagnostics-aux.modulemap:3:
5ae6df27eSRichard Smith// CHECK: diagnostics-aux-2.modulemap:2:3: error: expected
6ae6df27eSRichard Smith
7ac425e91SRichard Smith// PR22299: Ensure we can produce diagnostics for duplicate modules from -fmodule-map-file=.
8ac425e91SRichard Smith//
98f4d3ff1SRichard Smith// CHECK: diagnostics.modulemap:[[@LINE+2]]:8: error: redefinition of module 'foo'
108f4d3ff1SRichard Smith// CHECK: diagnostics-aux.modulemap:1:8: note: previously defined here
11ac425e91SRichard Smithmodule foo {}
120414b857SRichard Smith
130414b857SRichard Smith//* Check that we accept BCPL comments properly, not just as an extension. */
148f4d3ff1SRichard Smith
158f4d3ff1SRichard Smithmodule bad_use {
168f4d3ff1SRichard Smith  // CHECK: diagnostics.modulemap:[[@LINE+1]]:22: error: use declarations are only allowed in top-level modules
178f4d3ff1SRichard Smith  module submodule { use foo }
188f4d3ff1SRichard Smith}
19040e1266SRichard Smith
20040e1266SRichard Smithmodule header_attr {
21040e1266SRichard Smith  // CHECK: diagnostics.modulemap:[[@LINE+1]]:20: error: expected a header attribute name
22040e1266SRichard Smith  header "foo.h" { x }
23040e1266SRichard Smith  // CHECK: diagnostics.modulemap:[[@LINE+1]]:27: error: header attribute 'size' specified multiple times
24040e1266SRichard Smith  header "bar.h" { size 1 size 2 }
25040e1266SRichard Smith  // CHECK: diagnostics.modulemap:[[@LINE+1]]:25: error: expected integer literal as value for header attribute 'size'
26040e1266SRichard Smith  header "baz.h" { size "30 kilobytes" }
27040e1266SRichard Smith
28040e1266SRichard Smith  header "quux.h" { size 1 mtime 2 }
29040e1266SRichard Smith  header "no_attrs.h" {}
30040e1266SRichard Smith}
31*8839e278SVolodymyr Sapsai
32*8839e278SVolodymyr Sapsai// CHECK: diagnostics.modulemap:[[@LINE+1]]:8: error: no module named 'unknown' found, parent module must be defined before the submodule
33*8839e278SVolodymyr Sapsaimodule unknown.submodule {}
34*8839e278SVolodymyr Sapsaimodule known_top_level {}
35*8839e278SVolodymyr Sapsai// CHECK: diagnostics.modulemap:[[@LINE+1]]:24: error: no module named 'unknown' in 'known_top_level', parent module must be defined before the submodule
36*8839e278SVolodymyr Sapsaimodule known_top_level.unknown.submodule {}
37