[mlir][PDLL] Allow (and ignore) `-D` tablegen macros. (#124166)
[llvm-project.git] / clang / test / CXX / basic / basic.scope / basic.scope.namespace / p2.cpp
blobd70eb7de22c6a15ee9cd7a17077c9a6e40a45f8c
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: echo '#ifndef FOO_H' > %t/foo.h
4 // RUN: echo '#define FOO_H' >> %t/foo.h
5 // RUN: echo 'extern int in_header;' >> %t/foo.h
6 // RUN: echo '#endif' >> %t/foo.h
7 // RUN: %clang_cc1 -std=c++2a -I%t -emit-module-interface -DINTERFACE %s -o %t.pcm
8 // RUN: %clang_cc1 -std=c++2a -I%t -fmodule-file=A=%t.pcm -DIMPLEMENTATION %s -verify -fno-modules-error-recovery
9 // RUN: %clang_cc1 -std=c++2a -I%t -fmodule-file=A=%t.pcm %s -verify -fno-modules-error-recovery
11 #ifdef INTERFACE
12 module;
13 #include "foo.h"
14 // FIXME: The following need to be moved to a header file. The global module
15 // fragment is only permitted to contain preprocessor directives.
16 int global_module_fragment;
17 export module A;
18 export int exported;
19 int not_exported;
20 static int internal;
22 module :private;
23 int not_exported_private;
24 static int internal_private;
25 #else
27 #ifdef IMPLEMENTATION
28 module;
29 #endif
31 void test_early() {
32 in_header = 1; // expected-error {{use of undeclared identifier 'in_header'}}
33 // expected-note@* {{not visible}}
35 global_module_fragment = 1; // expected-error {{use of undeclared identifier 'global_module_fragment'}}
37 exported = 1; // expected-error {{use of undeclared identifier 'exported'}}
39 not_exported = 1; // expected-error {{use of undeclared identifier 'not_exported'}}
41 // FIXME: We need better diagnostic message for static variable.
42 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
44 not_exported_private = 1; // expected-error {{undeclared identifier}}
46 internal_private = 1; // expected-error {{undeclared identifier}}
49 #ifdef IMPLEMENTATION
50 module A;
51 #else
52 import A;
53 #endif
55 void test_late() {
56 in_header = 1; // expected-error {{missing '#include "foo.h"'; 'in_header' must be declared before it is used}}
57 // expected-note@* {{not visible}}
59 global_module_fragment = 1; // expected-error {{missing '#include'; 'global_module_fragment' must be declared before it is used}}
61 exported = 1;
63 not_exported = 1;
64 #ifndef IMPLEMENTATION
65 // expected-error@-2 {{use of undeclared identifier 'not_exported'; did you mean 'exported'?}}
66 // expected-note@p2.cpp:18 {{'exported' declared here}}
67 #endif
69 internal = 1; // expected-error {{use of undeclared identifier 'internal'}}
71 not_exported_private = 1;
72 #ifndef IMPLEMENTATION
73 // FIXME: should not be visible here
74 // expected-error@-3 {{undeclared identifier}}
75 #endif
77 internal_private = 1; // expected-error {{use of undeclared identifier 'internal_private'}}
80 #endif