1*d652bdd0SRichard Smith // RUN: %clang_cc1 -std=c++2a -verify %s 2*d652bdd0SRichard Smith // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=1 3*d652bdd0SRichard Smith // RUN: %clang_cc1 -std=c++2a -verify %s -DIMPORT_ERROR=2 4*d652bdd0SRichard Smith 5*d652bdd0SRichard Smith module; 6*d652bdd0SRichard Smith 7*d652bdd0SRichard Smith #if IMPORT_ERROR != 2 8*d652bdd0SRichard Smith struct import { struct inner {}; }; 9*d652bdd0SRichard Smith #endif 10*d652bdd0SRichard Smith struct module { struct inner {}; }; 11*d652bdd0SRichard Smith 12*d652bdd0SRichard Smith constexpr int n = 123; 13*d652bdd0SRichard Smith 14*d652bdd0SRichard Smith export module m; // #1 15*d652bdd0SRichard Smith 16*d652bdd0SRichard Smith // Import errors are fatal, so we test them in isolation. 17*d652bdd0SRichard Smith #if IMPORT_ERROR == 1 18*d652bdd0SRichard Smith import x = {}; // expected-error {{module 'x' not found}} 19*d652bdd0SRichard Smith 20*d652bdd0SRichard Smith #elif IMPORT_ERROR == 2 21*d652bdd0SRichard Smith struct X; 22*d652bdd0SRichard Smith template<int> struct import; 23*d652bdd0SRichard Smith template<> struct import<n> { 24*d652bdd0SRichard Smith static X y; 25*d652bdd0SRichard Smith }; 26*d652bdd0SRichard Smith 27*d652bdd0SRichard Smith // This is not valid because the 'import <n>' is a pp-import, even though it 28*d652bdd0SRichard Smith // grammatically can't possibly be an import declaration. 29*d652bdd0SRichard Smith struct X {} import<n>::y; // expected-error {{'n' file not found}} 30*d652bdd0SRichard Smith 31*d652bdd0SRichard Smith #else 32*d652bdd0SRichard Smith module y = {}; // expected-error {{multiple module declarations}} expected-error 2{{}} 33*d652bdd0SRichard Smith // expected-note@#1 {{previous module declaration}} 34*d652bdd0SRichard Smith 35*d652bdd0SRichard Smith ::import x = {}; 36*d652bdd0SRichard Smith ::module y = {}; 37*d652bdd0SRichard Smith 38*d652bdd0SRichard Smith import::inner xi = {}; 39*d652bdd0SRichard Smith module::inner yi = {}; 40*d652bdd0SRichard Smith 41*d652bdd0SRichard Smith namespace N { 42*d652bdd0SRichard Smith module a; 43*d652bdd0SRichard Smith import b; 44*d652bdd0SRichard Smith } 45*d652bdd0SRichard Smith 46*d652bdd0SRichard Smith extern "C++" module cxxm; 47*d652bdd0SRichard Smith extern "C++" import cxxi; 48*d652bdd0SRichard Smith 49*d652bdd0SRichard Smith template<typename T> module module_var_template; 50*d652bdd0SRichard Smith 51*d652bdd0SRichard Smith // This is a variable named 'import' that shadows the type 'import' above. 52*d652bdd0SRichard Smith struct X {} import; 53*d652bdd0SRichard Smith #endif 54