| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// |
| 5 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o %t/tmp 2>&1 | FileCheck %t/a.cppm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -E -P -I%t -o - 2>&1 \ |
| 7 |
// RUN: -Wno-include-angled-in-module-purview | FileCheck %t/a.cppm --check-prefix=CHECK-NO-WARN |
| 8 |
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -E -P -I%t -o - 2>&1 | FileCheck %t/a.cppm --check-prefix=CHECK-NO-WARN |
| 9 |
|
| 10 |
//--- a.h |
| 11 |
// left empty |
| 12 |
|
| 13 |
//--- b.h |
| 14 |
#include <stddef.h> |
| 15 |
// The headers not get included shouldn't be affected. |
| 16 |
#ifdef WHATEVER |
| 17 |
#include <stdint.h> |
| 18 |
#endif |
| 19 |
|
| 20 |
//--- a.cppm |
| 21 |
module; |
| 22 |
#include <stddef.h> |
| 23 |
#include <a.h> |
| 24 |
#include <b.h> |
| 25 |
#include "a.h" |
| 26 |
#include "b.h" |
| 27 |
export module a; |
| 28 |
|
| 29 |
#include <stddef.h> |
| 30 |
#include <a.h> |
| 31 |
#include <b.h> |
| 32 |
#include "a.h" |
| 33 |
#include "b.h" |
| 34 |
|
| 35 |
// CHECK: a.cppm:9:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 36 |
// CHECK: a.cppm:10:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 37 |
// CHECK: a.cppm:11:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 38 |
// CHECK: In file included from {{.*}}/a.cppm:11 |
| 39 |
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 40 |
// CHECK: In file included from {{.*}}/a.cppm:13 |
| 41 |
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 42 |
|
| 43 |
module :private; |
| 44 |
#include <stddef.h> |
| 45 |
#include <a.h> |
| 46 |
#include <b.h> |
| 47 |
#include "a.h" |
| 48 |
#include "b.h" |
| 49 |
|
| 50 |
// CHECK: a.cppm:24:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 51 |
// CHECK: a.cppm:25:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 52 |
// CHECK: a.cppm:26:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 53 |
// CHECK: In file included from {{.*}}/a.cppm:26 |
| 54 |
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 55 |
// CHECK: In file included from {{.*}}/a.cppm:28 |
| 56 |
// CHECK-NEXT: b.h:1:10: warning: '#include <filename>' attaches the declarations to the named module 'a' |
| 57 |
|
| 58 |
// We should have catched all warnings. |
| 59 |
// CHECK: 10 warnings generated. |
| 60 |
|
| 61 |
// CHECK-NO-WARN-NOT: warning |
| 62 |
|
| 63 |
//--- b.cpp |
| 64 |
/// Don't recognize `module m);` as a module purview or report a spurious |
| 65 |
/// warning for <stddef.h>. |
| 66 |
struct module {}; |
| 67 |
void foo(module m); |
| 68 |
#include <stddef.h> |