blob: f9156497bc6b170fc5519ce055fd055800510440 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -emit-module-interface -o %t/m1.pcm
// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -emit-module-interface -o %t/m2.pcm
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \
// RUN: -verify
//
// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -Wall -emit-module-interface -o %t/m1.pcm
// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -Wall -emit-module-interface -o %t/m2.pcm
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \
// RUN: -verify -Wall
//
// RUN: %clang_cc1 -std=c++20 %t/m1.cppm -Wdecls-in-multiple-modules -emit-module-interface -o %t/m1.pcm
// RUN: %clang_cc1 -std=c++20 %t/m2.cppm -Wdecls-in-multiple-modules -emit-module-interface -o %t/m2.pcm
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/use.cc -fsyntax-only \
// RUN: -verify -Wdecls-in-multiple-modules -DWARNING
//--- foo.h
#ifndef FOO_H
#define FOO_H
enum E { E1, E2 };
int a = 43;
class foo {
public:
void consume(E, int);
};
inline void func() {}
void fwd_decl();
#endif
//--- m1.cppm
module;
#include "foo.h"
export module m1;
export {
using ::foo;
using ::a;
using ::func;
using ::fwd_decl;
using ::E;
}
//--- m2.cppm
module;
#include "foo.h"
export module m2;
export {
using ::foo;
using ::a;
using ::func;
using ::fwd_decl;
using ::E;
}
//--- use.cc
import m1;
import m2;
void use();
void use() {
E e = E1;
foo f;
f.consume(e, a);
func();
fwd_decl();
}
#ifndef WARNING
// expected-no-diagnostics
#else
// expected-warning@* {{declaration 'E' is detected to be defined in multiple module units}}
// expected-warning@* {{declaration 'foo' is detected to be defined in multiple module units}}
// expected-warning@* {{declaration 'a' is detected to be defined in multiple module units}}
// expected-warning@* {{declaration 'func' is detected to be defined in multiple module units}}
// expected-note@* 1+ {{}}
#endif
|