File: pragma_module.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (52 lines) | stat: -rw-r--r-- 2,250 bytes parent folder | download | duplicates (8)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: echo 'module foo { module a {} module b {} } module bar {} module if {}' > %t/module.modulemap
// RUN: %clang_cc1 -fmodules -fmodule-name=if -x c %t/module.modulemap -emit-module -o %t/if.pcm
// RUN: %clang_cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify -fmodule-name=foo -fmodule-map-file=%t/module.modulemap
// RUN: %clang_cc1 -E -fmodules %s -fmodule-file=%t/if.pcm -verify -fmodule-name=foo -fmodule-map-file=%t/module.modulemap -fmodules-local-submodule-visibility -DLOCAL_VIS

// Just checking the syntax here; the semantics are tested elsewhere.
#pragma clang module import // expected-error {{expected module name}}
#pragma clang module import ! // expected-error {{expected module name}}
#pragma clang module import if // ok
#pragma clang module import foo ? bar // expected-warning {{extra tokens at end of #pragma}}
#pragma clang module import foo. // expected-error {{expected identifier after '.' in module name}}
#pragma clang module import foo.bar.baz.quux // expected-error {{no submodule named 'bar' in module 'foo'}}

#pragma clang module begin ! // expected-error {{expected module name}}

#pragma clang module begin foo.a blah // expected-warning {{extra tokens}}
 #pragma clang module begin foo.a // nesting is OK
  #define X 1 // expected-note 0-1{{previous}}
  #ifndef X
  #error X should be defined here
  #endif
 #pragma clang module end
 
 #ifndef X
 #error X should still be defined
 #endif
#pragma clang module end foo.a // expected-warning {{extra tokens}}

// #pragma clang module begin/end also import the module into the enclosing context
#ifndef X
#error X should still be defined
#endif

#pragma clang module begin foo.b
 #if defined(X) && defined(LOCAL_VIS)
 #error under -fmodules-local-submodule-visibility, X should not be defined
 #endif

 #if !defined(X) && !defined(LOCAL_VIS)
 #error without -fmodules-local-submodule-visibility, X should still be defined
 #endif

 #pragma clang module import foo.a
 #ifndef X
 #error X should be defined here
 #endif
#pragma clang module end

#pragma clang module end // expected-error {{no matching '#pragma clang module begin'}}
#pragma clang module begin foo.a // expected-error {{no matching '#pragma clang module end'}}