llvm-project/clang/test/Modules/expose-static-inline-from-gmf-3.cppm
Jan Kokemüller e50ec3e46b
[Clang][Sema] Expose static inline functions from GMF (#104701)
In C, it is a common pattern to have `static inline` functions in
headers to avoid ODR issues. Currently, when those headers are included
in a GMF, the names are not found when two-phase name lookup and ADL is
involved. Those names are removed by `Sema::AddOverloadCandidate`.

Similarly, in C++, sometimes people use templates with internal linkage
in headers.

As the GMF was designed to be a transitional mechanism for headers,
special case those functions in `Sema::AddOverloadCandidate`.

This fixes <https://github.com/llvm/llvm-project/issues/98021>.
2024-12-31 09:53:29 +08:00

25 lines
491 B
C++

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only -Xclang -verify
//--- a.h
namespace ns {
template <typename G> static void func() {}
template <typename T = long> void a() { func<T>(); }
}
//--- a.cppm
module;
#include "a.h"
export module a;
export using ns::a;
//--- test.cc
import a;
auto m = (a(), 0);
// expected-no-diagnostics