xref: /llvm-project/clang/test/Modules/pch-in-module-units.cppm (revision 2f0910d2d74419ef1ebf814b471af721ee78b464)
1// Test that we will skip ODR checks for declarations from PCH if they
2// were from GMF.
3//
4// RUN: rm -rf %t
5// RUN: mkdir -p %t
6// RUN: split-file %s %t
7//
8// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.cppm \
9// RUN:   -o %t/A.pcm -fskip-odr-check-in-gmf
10// RUN: %clang_cc1 -std=c++20 -DDIFF -x c++-header %t/foo.h \
11// RUN:   -emit-pch -o %t/foo.pch -fskip-odr-check-in-gmf
12// RUN: %clang_cc1 -std=c++20 %t/B.cppm -fmodule-file=A=%t/A.pcm -include-pch \
13// RUN:   %t/foo.pch -verify -fsyntax-only -fskip-odr-check-in-gmf
14
15//--- foo.h
16#ifndef FOO_H
17#define FOO_H
18inline int foo() {
19#ifndef DIFF
20  return 43;
21#else
22  return 45;
23#endif
24}
25
26class f {
27public:
28  int mem() {
29#ifndef DIFF
30    return 47;
31#else
32    return 45;
33#endif
34  }
35};
36#endif
37
38//--- A.cppm
39module;
40#include "foo.h"
41export module A;
42export using ::foo;
43export using ::f;
44
45//--- B.cppm
46// expected-no-diagnostics
47module;
48#include "foo.h"
49export module B;
50import A;
51export int b = foo() + f().mem();
52