Clang Project

clang_source_code/test/Modules/merge-enumerators.cpp
1// RUN: rm -rf %t
2// RUN: mkdir %t
3// RUN: echo 'namespace N { enum E { A }; }' > %t/a.h
4// RUN: echo '#include "a.h"' > %t/b.h
5// RUN: touch %t/x.h
6// RUN: echo 'module B { module b { header "b.h" } module x { header "x.h" } }' > %t/b.modulemap
7// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -fmodule-map-file=%t/b.modulemap %s -I%t -verify -fmodules-local-submodule-visibility
8// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -fmodule-map-file=%t/b.modulemap %s -I%t -verify -fmodules-local-submodule-visibility -DMERGE_LATE
9
10#ifndef MERGE_LATE
11// expected-no-diagnostics
12#include "a.h"
13#endif
14
15#include "x.h"
16
17#ifdef MERGE_LATE
18namespace N {
19  enum { A } a; // expected-note {{candidate}}
20  // expected-note@a.h:1 {{candidate}} (from module B.b)
21}
22#include "a.h"
23#endif
24
25N::E e = N::A;
26#ifdef MERGE_LATE
27// expected-error@-2 {{ambiguous}}
28#endif
29