llvm-project/clang/test/Modules/concept_differ.cpp
Chuanqi Xu 4b95a5a772 [Modules] Add ODR Check for concepts
Closing https://github.com/llvm/llvm-project/issues/56310

Previously we don't check the contents of concept so it might merge
inconsistent results.

Important Note: this patch might break existing code but the behavior
might be right.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D129104
2022-07-12 23:45:53 +08:00

36 lines
694 B
C++

// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%t/module.map %t/foo.cpp -verify
//--- module.map
module "foo" {
export *
header "foo.h"
}
module "bar" {
export *
header "bar.h"
}
//--- foo.h
template <class T>
concept A = true;
//--- bar.h
template <class T>
concept A = false;
//--- foo.cpp
#include "bar.h"
#include "foo.h"
template <class T> void foo() requires A<T> {} // expected-error 1+{{reference to 'A' is ambiguous}}
// expected-note@* 1+{{candidate found by name lookup}}
int main() {
foo<int>();
return 0;
}