[all-commits] [llvm/llvm-project] 9cfb13: [Clang][Sema] Defer instantiation of exception spe...
Krystian Stasiowski via All-commits
all-commits at lists.llvm.org
Mon Feb 26 06:59:07 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9cfb138eccb83b5876928b08be346fde5ca78b47
https://github.com/llvm/llvm-project/commit/9cfb138eccb83b5876928b08be346fde5ca78b47
Author: Krystian Stasiowski <sdkrystian at gmail.com>
Date: 2024-02-26 (Mon, 26 Feb 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/SemaTemplate.cpp
M clang/lib/Sema/SemaTemplateDeduction.cpp
A clang/test/CXX/except/except.spec/p13.cpp
M clang/test/SemaTemplate/class-template-noexcept.cpp
Log Message:
-----------
[Clang][Sema] Defer instantiation of exception specification until after partial ordering when determining primary template (#82417)
Consider the following:
```
struct A {
static constexpr bool x = true;
};
template<typename T, typename U>
void f(T, U) noexcept(T::y); // #1, error: no member named 'y' in 'A'
template<typename T, typename U>
void f(T, U*) noexcept(T::x); // #2
template<>
void f(A, int*) noexcept; // explicit specialization of #2
```
We currently instantiate the exception specification of all candidate
function template specializations when deducting template arguments for
an explicit specialization, which results in a error despite `#1` not
being selected by partial ordering as the most specialized template.
According to [except.spec] p13:
> An exception specification is considered to be needed when:
> - [...]
> - the exception specification is compared to that of another
declaration (e.g., an explicit specialization or an overriding virtual
function);
Assuming that "comparing declarations" means "determining whether the
declarations correspond and declare the same entity" (per [basic.scope.scope] p4 and
[basic.link] p11.1, respectively), the exception specification does _not_ need to be
instantiated until _after_ partial ordering, at which point we determine
whether the implicitly instantiated specialization and the explicit
specialization declare the same entity (the determination of whether two
functions/function templates correspond does not consider the exception
specifications).
This patch defers the instantiation of the exception specification until
a single function template specialization is selected via partial
ordering, matching the behavior of GCC, EDG, and
MSVC: see https://godbolt.org/z/Ebb6GTcWE.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list