brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · c774157 Raw
85 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir %t3// RUN: split-file %s %t4//5// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \6// RUN:     -emit-module %t/modules.map \7// RUN:     -o %t/module.pcm8//9//10// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t/module.pcm  \11// RUN:     -fmodule-map-file=%t/modules.map \12// RUN:     -fsyntax-only -verify %t/use.cpp13//14//--- use.cpp15// expected-no-diagnostics16 17#include "concepts.h"18#include "format.h"19 20template <class T> void foo()21  requires same_as<T, T>22{}23 24//--- modules.map25module "library" {26	export *27	module "concepts" {28		export *29		header "concepts.h"30	}31	module "compare" {32		export *33		header "compare.h"34	}35	module "format" {36		export *37		header "format.h"38	}39}40 41//--- concepts.h42#ifndef SAMEAS_CONCEPTS_H_43#define SAMEAS_CONCEPTS_H_44 45#include "same_as.h"46 47#endif // SAMEAS_CONCEPTS_H48 49//--- same_as.h50#ifndef SAME_AS_H51#define SAME_AS_H52 53template <class T, class U>54concept same_as_impl = __is_same(T, U);55 56template <class T, class U>57concept same_as = same_as_impl<T, U> && same_as_impl<U, T>;58#endif // SAME_AS_H59 60 61//--- compare.h62#ifndef COMPARE_H63#define COMPARE_H64 65#include "same_as.h"66#include "concepts.h"67 68template <class T> void foo()69  requires same_as<T, int>70{}71#endif // COMPARE_H72 73//--- format.h74#ifndef FORMAT_H75#define FORMAT_H76 77#include "same_as.h"78#include "concepts.h"79 80template <class T> void bar()81  requires same_as<T, int>82{}83 84#endif // FORMAT_H85