Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CXX / basic / basic.link / p3.cpp
blob23f39d11b655a6d9e09b77535eb38ff34fe754cd
1 // RUN: %clang_cc1 -std=c++2a -verify %s
2 // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=1
3 // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=2
5 module;
7 #if IMPORT_ERROR != 2
8 struct import { struct inner {}; };
9 #endif
10 struct module { struct inner {}; };
12 constexpr int n = 123;
14 export module m; // #1
16 // Import errors are fatal, so we test them in isolation.
17 #if IMPORT_ERROR == 1
18 import x = {}; // expected-error {{module 'x' not found}}
20 #elif IMPORT_ERROR == 2
21 struct X;
22 template<int> struct import;
23 template<> struct import<n> {
24 static X y;
27 // This is not valid because the 'import <n>' is a pp-import, even though it
28 // grammatically can't possibly be an import declaration.
29 struct X {} import<n>::y; // expected-error {{'n' file not found}}
31 #else
32 module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}}
33 // expected-note@#1 {{previous module declaration}}
35 ::import x = {};
36 ::module y = {};
38 import::inner xi = {};
39 module::inner yi = {};
41 namespace N {
42 module a;
43 import b;
46 extern "C++" module cxxm;
47 extern "C++" import cxxi;
49 template<typename T> module module_var_template;
51 // This is a variable named 'import' that shadows the type 'import' above.
52 struct X {} import;
53 #endif