xref: /aosp_15_r20/external/clang/test/Modules/submodules.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: rm -rf %t
2*67e74705SXin Li // RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules %s -verify
3*67e74705SXin Li // FIXME: When we have a syntax for modules in C++, use that.
4*67e74705SXin Li 
5*67e74705SXin Li @import std.vector;
6*67e74705SXin Li 
7*67e74705SXin Li vector<int> vi;
8*67e74705SXin Li 
9*67e74705SXin Li // Note: remove_reference is not visible yet.
10*67e74705SXin Li remove_reference<int&>::type *int_ptr = 0; // expected-error{{declaration of 'remove_reference' must be imported from module 'std.type_traits' before it is required}}
11*67e74705SXin Li // expected-note@Inputs/submodules/type_traits.h:2{{previous}}
12*67e74705SXin Li // expected-note@Inputs/submodules/hash_map.h:1{{previous}}
13*67e74705SXin Li 
14*67e74705SXin Li @import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
15*67e74705SXin Li 
16*67e74705SXin Li vector<float> vf;
17*67e74705SXin Li remove_reference<int&>::type *int_ptr2 = 0;
18*67e74705SXin Li 
19*67e74705SXin Li @import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
20*67e74705SXin Li 
21*67e74705SXin Li @import std; // import everything in 'std'
22*67e74705SXin Li 
23*67e74705SXin Li // hash_map still isn't available.
24*67e74705SXin Li hash_map<int, float> ints_to_floats; // expected-error{{declaration of 'hash_map' must be imported from module 'std.hash_map' before it is required}}
25*67e74705SXin Li 
26*67e74705SXin Li @import std.hash_map;
27*67e74705SXin Li 
28*67e74705SXin Li hash_map<int, float> ints_to_floats2;
29