Debian Codegraph @

clang/test/CXX/module/cpp.pre/module_decl.cpp

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/line.cpp -verify -o %t/line.pcm
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/gnu_line_marker.cpp -verify -o %t/gnu_line_marker.pcm
6 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/include.cpp -verify -o %t/include.pcm
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/ident.cpp -verify -o %t/ident.pcm
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_comment.cpp -verify -o %t/pragma_comment.pcm
9 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_mark.cpp -verify -o %t/pragma_mark.pcm
10 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_detect_mismatch.cpp -verify -o %t/pragma_detect_mismatch.pcm
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_clang_debug.cpp -verify -o %t/pragma_clang_debug.pcm
12 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_message.cpp -verify -o %t/pragma_message.pcm
13 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_gcc_warn.cpp -verify -o %t/pragma_gcc_warn.pcm
14 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_gcc_error.cpp -verify -o %t/pragma_gcc_error.pcm
15 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_diag_push_pop.cpp -verify -o %t/pragma_diag_push_pop.pcm
16 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_diag_ignore.cpp -verify -o %t/pragma_diag_ignore.pcm
17 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_opencl_ext.cpp -verify -o %t/pragma_opencl_ext.pcm
18 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_push_pop.cpp -verify -o %t/pragma_push_pop.pcm
19 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_exec_charset.cpp -verify -o %t/pragma_exec_charset.pcm
20 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/pragma_clang_assume_nonnull.cpp -verify -o %t/pragma_clang_assume_nonnull.pcm
21 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/marco_expand.cpp -DMACRO="" -verify -o %t/marco_expand.pcm
22 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/define.cpp -verify -o %t/define.pcm
23 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/undef.cpp -verify -o %t/undef.pcm
24 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/defined.cpp -verify -o %t/defined.pcm
25 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/has_embed.cpp -verify -o %t/has_embed.pcm
26 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/has_include.cpp -verify -o %t/has_include.pcm
27
28 //--- header.h
29 #ifndef HEADER_H
30 #define HEADER_H
31
32 #endif // HEADER_H
33
34 //--- line.cpp
35 // expected-no-diagnostics
36 #line 3
37 export module M;
38
39 //--- gnu_line_marker.cpp
40 // expected-no-diagnostics
41 # 1 __FILE__ 1 3
42 export module M;
43
44 //--- include.cpp
45 #include "header.h" // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
46 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
47
48 //--- ident.cpp
49 // expected-no-diagnostics
50 #ident "$Header:$"
51 export module M;
52
53 //--- pragma_comment.cpp
54 // expected-no-diagnostics
55 #pragma comment(lib, "msvcrt.lib")
56 export module M;
57
58 //--- pragma_mark.cpp
59 // expected-no-diagnostics
60 #pragma mark LLVM's world
61 export module M;
62
63 //--- pragma_detect_mismatch.cpp
64 // expected-no-diagnostics
65 #pragma detect_mismatch("test", "1")
66 export module M;
67
68 //--- pragma_clang_debug.cpp
69 // expected-no-diagnostics
70 #pragma clang __debug dump Test
71 export module M;
72
73 //--- pragma_message.cpp
74 #pragma message "test" // expected-warning {{test}}
75 export module M;
76
77 //--- pragma_gcc_warn.cpp
78 #pragma GCC warning "Foo" // expected-warning {{Foo}}
79 export module M;
80
81 //--- pragma_gcc_error.cpp
82 #pragma GCC error "Foo" // expected-error {{Foo}}
83 export module M;
84
85 //--- pragma_diag_push_pop.cpp
86 // expected-no-diagnostics
87 #pragma gcc diagnostic push
88 #pragma gcc diagnostic pop
89 export module M;
90
91 //--- pragma_diag_ignore.cpp
92 // expected-no-diagnostics
93 #pragma GCC diagnostic ignored "-Wframe-larger-than"
94 export module M;
95
96 //--- pragma_opencl_ext.cpp
97 // expected-no-diagnostics
98 #pragma OPENCL EXTENSION __cl_clang_variadic_functions : enable
99 export module M;
100
101 //--- pragma_push_pop.cpp
102 // expected-no-diagnostics
103 #pragma warning(push)
104 #pragma warning(pop)
105 export module M;
106
107 //--- pragma_exec_charset.cpp
108 // expected-no-diagnostics
109 #pragma execution_character_set(push, "UTF-8")
110 #pragma execution_character_set(pop)
111 export module M;
112
113 //--- pragma_clang_assume_nonnull.cpp
114 // expected-no-diagnostics
115 #pragma clang assume_nonnull begin
116 #pragma clang assume_nonnull end
117 export module M;
118
119 //--- marco_expand.cpp
120 MACRO // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
121 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
122
123 //--- define.cpp
124 // This is a comment
125 #define I32 int // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
126 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
127 export I32 i32;
128
129 //--- undef.cpp
130 #undef FOO // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
131 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
132
133 //--- defined.cpp
134 #if defined(FOO) // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
135 #endif
136 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
137
138 //--- has_embed.cpp
139 #if __has_embed(__FILE__ ext::token(0xB055)) // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}}
140 #endif
141 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}
142
143 //--- has_include.cpp
144 #if __has_include(<stdio.h>) || __has_include_next(<stdlib.h>) // expected-note {{add 'module;' to the start of the file to introduce a global module fragment}} \
145 // expected-warning {{#include_next in primary source file; will search from start of include path}}
146 #endif
147 export module M; // expected-error {{module declaration must occur at the start of the translation unit}}