xref: /llvm-project/clang/test/Modules/pr91105.cppm (revision f9d76197ff0099502cf001abe3f5310c5bc4532d)
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/bar.cppm -emit-module-interface -o %t/bar.pcm
6// RUN: %clang_cc1 -std=c++20 %t/foo.cc -fmodule-file=bar=%t/bar.pcm -fsyntax-only -verify
7//
8// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/bar.cppm -emit-module-interface \
9// RUN:     -o %t/bar.pcm
10// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/foo.cc \
11// RUN:     -fmodule-file=bar=%t/bar.pcm -fsyntax-only -verify
12//
13// RUN: %clang_cc1 -std=c++20 %t/bar.cppm -emit-reduced-module-interface -o %t/bar.pcm
14// RUN: %clang_cc1 -std=c++20 %t/foo.cc -fmodule-file=bar=%t/bar.pcm -fsyntax-only -verify
15//
16// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/bar.cppm -emit-reduced-module-interface \
17// RUN:     -o %t/bar.pcm
18// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/foo.cc \
19// RUN:     -fmodule-file=bar=%t/bar.pcm -fsyntax-only -verify
20
21//--- h.hpp
22#pragma once
23
24struct T {
25    constexpr T(const char *) {}
26};
27template <char... c>
28struct t {
29    inline constexpr operator T() const { return {s}; }
30
31private:
32    inline static constexpr char s[]{c..., '\0'};
33};
34
35//--- bar.cppm
36module;
37#include "h.hpp"
38export module bar;
39export inline constexpr auto k = t<'k'>{};
40
41//--- foo.cc
42// expected-no-diagnostics
43#include "h.hpp"
44import bar;
45void f() {
46  T x = k;
47}
48