
Tracked at https://github.com/llvm/llvm-project/issues/112294 This patch implements from [basic.link]p14 to [basic.link]p18 partially. The explicitly missing parts are: - Anything related to specializations. - Decide if a pointer is associated with a TU-local value at compile time. - [basic.link]p15.1.2 to decide if a type is TU-local. - Diagnose if TU-local functions from other TU are collected to the overload set. See [basic.link]p19, the call to 'h(N::A{});' in translation unit #2 There should be other implicitly missing parts as the wording uses "names" briefly several times. But to implement this precisely, we have to visit the whole AST, including Decls, Expression and Types, which may be harder to implement and be more time-consuming for compilation time. So I choose to implement the common parts. It won't be too bad to miss some cases since we DIDN'T do any such checks in the past 3 years. Any new check is an improvement. Given modules have been basically available since clang15 without such checks, it will be user unfriendly if we give a hard error now. And there are a lot of cases which violating the rule actually just fine. So I decide to emit it as warnings instead of hard errors.
28 lines
494 B
C++
28 lines
494 B
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/A.cppm -o %t/A.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/A.cpp -fmodule-file=A=%t/A.pcm -fsyntax-only -verify
|
|
|
|
//--- A.cppm
|
|
export module A;
|
|
export template <class T>
|
|
class C {};
|
|
|
|
export template <class T>
|
|
void foo() {
|
|
C<T> value;
|
|
(void) value;
|
|
}
|
|
|
|
//--- A.cpp
|
|
// expected-no-diagnostics
|
|
import A;
|
|
namespace {
|
|
class Local {};
|
|
}
|
|
void test() {
|
|
foo<Local>();
|
|
}
|