| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm |
| 7 |
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only |
| 8 |
// |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/A.pcm |
| 10 |
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -o %t/B.pcm |
| 11 |
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only |
| 12 |
|
| 13 |
// Test that a textual #include sandwiched between two import declarations |
| 14 |
// of modules that both include the same header in their GMFs does not lose |
| 15 |
// enum declarations. See https://github.com/llvm/llvm-project/issues/188853 |
| 16 |
|
| 17 |
//--- enum.h |
| 18 |
#ifndef ENUM_H |
| 19 |
#define ENUM_H |
| 20 |
namespace ns { |
| 21 |
enum E { Value1, Value2, Value3 }; |
| 22 |
} |
| 23 |
#endif |
| 24 |
|
| 25 |
//--- A.cppm |
| 26 |
module; |
| 27 |
#include "enum.h" |
| 28 |
export module A; |
| 29 |
export auto a = ns::Value1; |
| 30 |
|
| 31 |
//--- B.cppm |
| 32 |
module; |
| 33 |
#include "enum.h" |
| 34 |
export module B; |
| 35 |
export auto b = ns::Value2; |
| 36 |
|
| 37 |
//--- use.cpp |
| 38 |
// expected-no-diagnostics |
| 39 |
import A; |
| 40 |
#include "enum.h" |
| 41 |
import B; |
| 42 |
|
| 43 |
auto x = ns::Value3; |
| 44 |
|
| 45 |
namespace ns { |
| 46 |
auto y = Value1; |
| 47 |
} |