xref: /llvm-project/clang/test/Modules/partial_specialization.cppm (revision da00c60dae0040185dc45039c4397f6e746548e9)
1// RUN: rm -rf %t
2// RUN: split-file %s %t
3// RUN: cd %t
4//
5// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/A.cppm -o %t/A.pcm
6// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
7//
8// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.cppm -o %t/A.pcm
9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
10//
11//--- foo.h
12template<typename T, typename U>
13inline constexpr bool IsSame = false;
14
15template<typename T>
16inline constexpr bool IsSame<T, T> = true;
17
18template <typename T>
19class A {
20public:
21    A();
22    ~A() noexcept(IsSame<T, T>);
23};
24
25//--- A.cppm
26module;
27#include "foo.h"
28export module A;
29export using ::A;
30
31//--- Use.cpp
32import A;
33void bool_consume(bool b);
34void use() {
35    A<int> a{};
36    bool_consume(IsSame); // expected-error {{use of undeclared identifier 'IsSame'}}
37}
38