[clang] Add the check of membership in decltype for the issue #58674#
authorLiming Liu <gangliugangliu.ml@outlook.com>
Wed, 4 Jan 2023 15:46:03 +0000 (07:46 -0800)
committerErich Keane <erich.keane@intel.com>
Wed, 4 Jan 2023 15:47:17 +0000 (07:47 -0800)
commit85960043d594fc12d340ccb66a30861b023ab496
treef7dd7355022f15813cab135e53c7c732c460fd5e
parentfa8448c1b18bfe7ffa89f91ab0cfc16f2f83760d
[clang] Add the check of membership in decltype for the issue #58674#

Originally, the code would take a lookup result as a member in the
current scope and build a member expression accordingly, if the lookup
result was not an operand of the address operator, or it was a field
declaration. However, a field declaration may come from another class,
and cause the issue #58674.

Thus, this patch fixes the issue via checking where does the field
declaration comes from, and if it comes from another class, then marks
it as not member in the current scope. The parent scopes of the current
scope are also checked, as the current scope may be associated to a
lambda or friend declaration.

Differential Revision: https://reviews.llvm.org/D137531
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/decltype.cpp