112 lines · plain
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm6// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm7// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface \8// RUN: -fprebuilt-module-path=%t -o %t/c.pcm9// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \10// RUN: -fsyntax-only -verify11 12// Test again with reduced BMI.13// RUN: rm -rf %t14// RUN: mkdir -p %t15// RUN: split-file %s %t16//17// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm18// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm19// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface \20// RUN: -fprebuilt-module-path=%t -o %t/c.pcm21// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \22// RUN: -fsyntax-only -verify23 24//--- foo.h25#ifndef FOO_H26#define FOO_H27 28template<class _Tp>29concept __has_member_value_type = requires { typename _Tp::value_type; };30 31template<class _Tp>32concept __has_member_element_type = requires { typename _Tp::element_type; };33 34template <class _Tp>35inline constexpr bool is_object_v = __is_object(_Tp);36 37template<class> struct __cond_value_type {};38 39template<class _Tp>40requires is_object_v<_Tp>41struct __cond_value_type<_Tp> { using value_type = bool; };42 43template<class> struct indirectly_readable_traits {44 static constexpr int value = false;45};46#endif47 48//--- foo.member_value_type.h49#include "foo.h"50template<__has_member_value_type _Tp>51struct indirectly_readable_traits<_Tp> : __cond_value_type<typename _Tp::value_type> {52 static constexpr int value = false;53};54 55//--- foo.memeber_element_type.h56#include "foo.h"57template<__has_member_element_type _Tp>58struct indirectly_readable_traits<_Tp> : __cond_value_type<typename _Tp::element_type> {59 static constexpr int value = false;60};61 62template<__has_member_value_type _Tp>63 requires __has_member_element_type<_Tp>64struct indirectly_readable_traits<_Tp> {65 static constexpr int value = true;66};67 68//--- foo.a.h69#include "foo.h"70#include "foo.member_value_type.h"71#include "foo.memeber_element_type.h"72template <typename T>73using AType = indirectly_readable_traits<T>;74 75//--- a.cppm76module;77#include "foo.a.h"78export module a;79 80export using ::AType;81 82//--- b.cppm83module;84#include "foo.h"85#include "foo.memeber_element_type.h"86export module b;87 88//--- c.cppm89export module c;90 91export import a;92export import b;93 94//--- use.cpp95// expected-no-diagnostics96import c;97 98template <typename T>99class U {100public:101 using value_type = T;102 using element_type = T;103};104 105template <typename T>106class V {107public:108};109 110static_assert(!AType<V<int*>>::value);111static_assert(AType<U<int**>>::value);112