mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:16:05 +00:00

[module.unit]p1 specifies that module and import are invalid components of a module name, that module names cannot contain reserved identifiers, and that std followed by zero or more digits is reserved. The first issue (module and import pseudo-keywords) requires a diagnostic, the second issue (use of reserved identifiers) does not require a diagnostic. We diagnose both the same -- the code is ill- formed unless the module declaration is in a system "header". This allows STL implementations to use the reserved module names while preventing users from stealing them out from under us. Differential Revision: https://reviews.llvm.org/D136953
35 lines
935 B
C++
35 lines
935 B
C++
// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
|
|
|
|
module;
|
|
# 5 __FILE__ 1
|
|
class Pooh;
|
|
class Piglet;
|
|
# 8 "" 2
|
|
|
|
# 8 "" 1 3
|
|
export module std; // might happen, you can't say it won't!
|
|
# 9 "" 2 3
|
|
|
|
namespace std {
|
|
export template<typename T> class allocator {
|
|
// just for testing, not real!
|
|
void M (T *);
|
|
template <typename U> U *N (T *);
|
|
};
|
|
|
|
template<typename T> void allocator<T>::M (T *) {}
|
|
template<typename T> template<typename U> U *allocator<T>::N (T *) {
|
|
return nullptr;
|
|
}
|
|
|
|
// CHECK-DAG: void @_ZNStW3std9allocatorIiE1MEPi(
|
|
template void allocator<int>::M (int *);
|
|
// CHECK-DAG: @_ZNStW3std9allocatorIiE1NIfEEPT_Pi(
|
|
template float *allocator<int>::N<float> (int *);
|
|
}
|
|
|
|
// CHECK-DAG: @_ZNStW3std9allocatorI4PoohE1MEPS1_(
|
|
template void std::allocator<Pooh>::M (Pooh *);
|
|
// CHECK-DAG: @_ZNStW3std9allocatorI4PoohE1NI6PigletEEPT_PS1_(
|
|
template Piglet *std::allocator<Pooh>::N<Piglet> (Pooh *);
|