Clang Project

clang_source_code/test/Modules/tag-injection.cpp
1// RUN: rm -rf %t
2// RUN: mkdir %t
3// RUN: echo 'struct tm;' > %t/a.h
4// RUN: echo 'struct X {}; void foo(struct tm*);' > %t/b.h
5// RUN: echo 'module X { module a { header "a.h" } module b { header "b.h" } }' > %t/x.modulemap
6// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -fmodule-map-file=%t/x.modulemap %s -I%t -verify -std=c++11
7// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -fmodule-map-file=%t/x.modulemap %s -I%t -verify -fmodules-local-submodule-visibility -std=c++11
8
9#include "a.h"
10
11using ::tm;
12
13struct A {
14  // This use of 'struct X' makes the declaration (but not definition) of X visible.
15  virtual void f(struct X *p);
16};
17
18namespace N {
19  struct B : A {
20    void f(struct X *q) override;
21  };
22}
23
24X x; // expected-error {{definition of 'X' must be imported from module 'X.b' before it is required}}
25// expected-note@b.h:1 {{here}}
26