xref: /llvm-project/clang/test/Modules/pr76638.cppm (revision 8eea582dcb900afb45866a09296624b6fef9dd20)
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/mod1.cppm -emit-module-interface -o %t/mod1.pcm
6// RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -fmodule-file=mod1=%t/mod1.pcm \
7// RUN:     -fsyntax-only -verify
8//
9// RUN: %clang_cc1 -std=c++20 %t/mod3.cppm -emit-module-interface -o %t/mod3.pcm
10// RUN: %clang_cc1 -std=c++20 %t/mod4.cppm -fmodule-file=mod3=%t/mod3.pcm \
11// RUN:     -fsyntax-only -verify
12
13// Testing the behavior of `-fskip-odr-check-in-gmf`
14// RUN: %clang_cc1 -std=c++20 %t/mod3.cppm -fskip-odr-check-in-gmf \
15// RUN:     -emit-module-interface -o %t/mod3.pcm
16// RUN: %clang_cc1 -std=c++20 %t/mod4.cppm -fmodule-file=mod3=%t/mod3.pcm \
17// RUN:     -fskip-odr-check-in-gmf -DSKIP_ODR_CHECK_IN_GMF -fsyntax-only -verify
18
19//--- size_t.h
20
21extern "C" {
22    typedef unsigned int size_t;
23}
24
25//--- csize_t
26namespace std {
27            using :: size_t;
28}
29
30//--- align.h
31namespace std {
32    enum class align_val_t : size_t {};
33}
34
35//--- mod1.cppm
36module;
37#include "size_t.h"
38#include "align.h"
39export module mod1;
40export using std::align_val_t;
41
42//--- mod2.cppm
43// expected-no-diagnostics
44module;
45#include "size_t.h"
46#include "csize_t"
47#include "align.h"
48export module mod2;
49import mod1;
50export using std::align_val_t;
51
52//--- signed_size_t.h
53// Test that we can still find the case if the underlying type is different
54extern "C" {
55    typedef signed int size_t;
56}
57
58//--- mod3.cppm
59module;
60#include "size_t.h"
61#include "align.h"
62export module mod3;
63export using std::align_val_t;
64
65//--- mod4.cppm
66module;
67#include "signed_size_t.h"
68#include "csize_t"
69#include "align.h"
70export module mod4;
71import mod3;
72export using std::align_val_t;
73
74#ifdef SKIP_ODR_CHECK_IN_GMF
75// expected-no-diagnostics
76#else
77// expected-error@align.h:* {{'std::align_val_t' has different definitions in different modules; defined here first difference is enum with specified type 'size_t' (aka 'int')}}
78// expected-note@align.h:* {{but in 'mod3.<global>' found enum with specified type 'size_t' (aka 'unsigned int')}}
79#endif
80