[clang][bytecode][NFC] Only get expr when checking for UB (#125397)
[llvm-project.git] / clang / test / CXX / basic / basic.link / p3.cpp
blob01202264d2591b884c076f9ae5605312622cfdc9
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 {{expected ';' after module name}}
19 // expected-error@-1 {{module 'x' not found}}
21 #elif IMPORT_ERROR == 2
22 struct X;
23 template<int> struct import;
24 template<> struct import<n> {
25 static X y;
28 // This is not valid because the 'import <n>' is a pp-import, even though it
29 // grammatically can't possibly be an import declaration.
30 struct X {} import<n>::y; // expected-error {{'n' file not found}}
32 #else
33 module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}}
34 // expected-note@#1 {{previous module declaration}}
36 ::import x = {};
37 ::module y = {};
39 import::inner xi = {};
40 module::inner yi = {};
42 namespace N {
43 module a;
44 import b;
47 extern "C++" module cxxm;
48 extern "C++" import cxxi;
50 template<typename T> module module_var_template;
52 // This is a variable named 'import' that shadows the type 'import' above.
53 struct X {} import;
54 #endif