1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
// RUN: -emit-module %t/modules.map \
// RUN: -o %t/module.pcm
//
//
// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t/module.pcm \
// RUN: -fmodule-map-file=%t/modules.map \
// RUN: -fsyntax-only -verify %t/use.cpp
//
//--- use.cpp
// expected-no-diagnostics
#include "concepts.h"
#include "format.h"
template <class T> void foo()
requires same_as<T, T>
{}
//--- modules.map
module "library" {
export *
module "concepts" {
export *
header "concepts.h"
}
module "compare" {
export *
header "compare.h"
}
module "format" {
export *
header "format.h"
}
}
//--- concepts.h
#ifndef SAMEAS_CONCEPTS_H_
#define SAMEAS_CONCEPTS_H_
#include "same_as.h"
#endif // SAMEAS_CONCEPTS_H
//--- same_as.h
#ifndef SAME_AS_H
#define SAME_AS_H
template <class T, class U>
concept same_as_impl = __is_same(T, U);
template <class T, class U>
concept same_as = same_as_impl<T, U> && same_as_impl<U, T>;
#endif // SAME_AS_H
//--- compare.h
#ifndef COMPARE_H
#define COMPARE_H
#include "same_as.h"
#include "concepts.h"
template <class T> void foo()
requires same_as<T, int>
{}
#endif // COMPARE_H
//--- format.h
#ifndef FORMAT_H
#define FORMAT_H
#include "same_as.h"
#include "concepts.h"
template <class T> void bar()
requires same_as<T, int>
{}
#endif // FORMAT_H
|