llvm-capstone/clang/test/Modules/submodules.cpp
Richard Smith 0a088ead85 Improve diagnostics for missing import / #include of module.
Fix a few bugs where we would fail to properly determine header to
module correspondence when determining whether to suggest a #include or
import, and suggest a #include more often in language modes where there
is no import syntax. Generally, if the target is in a header with
include guards or #pragma once, we should suggest either #including or
importing that header, and not importing a module that happens to
textually include it.

In passing, improve the notes we attach to the corresponding
diagnostics: calling an entity that we couldn't see "previous" is
confusing.
2020-04-28 18:41:14 -07:00

29 lines
1.1 KiB
C++

// RUN: rm -rf %t
// RUN: %clang_cc1 -x objective-c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/submodules %s -verify
// FIXME: When we have a syntax for modules in C++, use that.
@import std.vector;
vector<int> vi;
// Note: remove_reference is not visible yet.
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}}
// expected-note@Inputs/submodules/type_traits.h:2{{not visible}}
// expected-note@Inputs/submodules/hash_map.h:1{{not visible}}
@import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
vector<float> vf;
remove_reference<int&>::type *int_ptr2 = 0;
@import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
@import std; // import everything in 'std'
// hash_map still isn't available.
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}}
@import std.hash_map;
hash_map<int, float> ints_to_floats2;