[all-commits] [llvm/llvm-project] 5b0bce: [Clang][Parser] Fix name lookup of template parame...
Younan Zhang via All-commits
all-commits at lists.llvm.org
Sat Aug 31 02:36:12 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5b0bcec93dbc2e5bec049c452b157548334c5e28
https://github.com/llvm/llvm-project/commit/5b0bcec93dbc2e5bec049c452b157548334c5e28
Author: Younan Zhang <zyn7109 at gmail.com>
Date: 2024-08-31 (Sat, 31 Aug 2024)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/Sema/SemaTemplate.cpp
M clang/test/CXX/temp/temp.res/temp.local/p8.cpp
Log Message:
-----------
[Clang][Parser] Fix name lookup of template parameters for out-of-line specializations (#101020)
Since the implementation of DR458 (d1446017), we have had an algorithm
that template parameters would take precedence over its parent scopes at
the name lookup. However, we failed to handle the following case where
the member function declaration is not yet deferral parsed (This is
where the patch of DR458 applies):
```cpp
namespace NS {
int CC;
template <typename> struct C;
}
template <typename CC>
struct NS::C {
void foo(CC);
};
```
When parsing the parameter of the function declaration `void foo(CC)`,
we used to perform a name lookup following such a Scope chain:
```
FunctionScope foo (failed)
RecordScope C (failed)
NamespaceScope NS (found `int CC`)
(If failed)
TemplateParameterScope of C
```
This doesn't seem right because according to `[temp.local]`, a template
parameter scope should be searched before its parent scope to which the
parameter appertains. This patch corrects the search scopes by setting a
lookup Entity for template parameter Scopes so that we can bail out in
CppNameLookup() when reaching the RecordScope. Afterward, the search
chain would be like:
```
FunctionScope foo (failed)
RecordScope C (failed)
TemplateParameterScope of C (found CC)
(If failed)
NamespaceScope NS
```
Fixes https://github.com/llvm/llvm-project/issues/64082
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