[all-commits] [llvm/llvm-project] 847466: [C++20] [Modules] Make the linkage consistent for ...

Chuanqi Xu via All-commits all-commits at lists.llvm.org
Wed Mar 23 19:24:59 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 84746686088799ec9e3cc5ea0a64df81423da290
      https://github.com/llvm/llvm-project/commit/84746686088799ec9e3cc5ea0a64df81423da290
  Author: Chuanqi Xu <yedeng.yd at linux.alibaba.com>
  Date:   2022-03-24 (Thu, 24 Mar 2022)

  Changed paths:
    M clang/lib/AST/Decl.cpp
    M clang/unittests/AST/DeclTest.cpp

  Log Message:
  -----------
  [C++20] [Modules] Make the linkage consistent for template and its
specialization

Before the patch, the compiler would crash for the test due to
inconsistent linkage.

This patch tries to avoid it by make the linkage consistent for template
and its specialization. After the patch, the behavior of compiler would
be partially correct for the case.
The correct one is:

```
export template<class T>
void f() {}

template<>
void f<int>() {}
```

In this case, the linkage for both declaration should be external (the
wording I get by consulting in WG21 is "the linkage for name f should be
external").

And for the case:
```
template<class T>
void f() {}

export template<>
void f<int>() {}
```

Compiler should reject it. This isn't done now. After all, this patch would
stop a crash.

Reviewed By: iains, aaron.ballman, dblaikie

Differential Revision: https://reviews.llvm.org/D120397




More information about the All-commits mailing list