| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// Treat the behavior of using headers as baseline. |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/use-header.cc -isystem %t -fsyntax-only -verify |
| 7 |
// |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -isystem %t -emit-module-interface -o %t/a.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 %t/use-module.cc -isystem %t -fmodule-file=a=%t/a.pcm -fsyntax-only -verify |
| 10 |
|
| 11 |
// Test again with reduced BMI. |
| 12 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -isystem %t -emit-reduced-module-interface -o %t/a.pcm |
| 13 |
// RUN: %clang_cc1 -std=c++20 %t/use-module.cc -isystem %t -fmodule-file=a=%t/a.pcm -fsyntax-only -verify |
| 14 |
|
| 15 |
//--- sys.h |
| 16 |
#ifndef SYS_H |
| 17 |
#define SYS_H |
| 18 |
|
| 19 |
#pragma GCC system_header |
| 20 |
|
| 21 |
template <class C> |
| 22 |
struct [[deprecated]] iterator {}; |
| 23 |
|
| 24 |
_Pragma("GCC diagnostic push") |
| 25 |
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"") |
| 26 |
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") |
| 27 |
|
| 28 |
template <class C> |
| 29 |
struct reverse_iterator |
| 30 |
: public iterator<C> {}; |
| 31 |
|
| 32 |
_Pragma("GCC diagnostic pop") |
| 33 |
|
| 34 |
template <class T> |
| 35 |
class C { |
| 36 |
public: |
| 37 |
void i() { |
| 38 |
reverse_iterator<T> i; |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
#endif |
| 43 |
|
| 44 |
//--- use-header.cc |
| 45 |
// expected-no-diagnostics |
| 46 |
// However, we see unexpected warnings |
| 47 |
#include <sys.h> |
| 48 |
|
| 49 |
void use() { |
| 50 |
C<int>().i(); |
| 51 |
} |
| 52 |
|
| 53 |
//--- a.cppm |
| 54 |
module; |
| 55 |
#include <sys.h> |
| 56 |
export module a; |
| 57 |
export using ::iterator; |
| 58 |
export using ::C; |
| 59 |
|
| 60 |
//--- use-module.cc |
| 61 |
// expected-no-diagnostics |
| 62 |
import a; |
| 63 |
|
| 64 |
void use() { |
| 65 |
C<int>().i(); |
| 66 |
} |