[PATCH] D60956: [Sema] Fix the lookup for a declaration conflicting with an enumerator (bogus use of LookupResult::getAsSingle)

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 09:02:42 PDT 2019


riccibruno updated this revision to Diff 196264.
riccibruno added a comment.

- Added a test (see `N_shadow)` for the behavior of `Wshadow`. This test showed that I forgot to change `CheckShadow(New, PrevDecl, R);` to `CheckShadow(New, PrevDecl->getUnderlyingDecl(), R);` to match change in the condition of the if statement.

- Added a test which exposes a new problem that this patch incidentally solves (see `N_conflicting_namespace_alias`). Because of the using directive `using namespace M;`, the namespace alias `i` for the namespace `Q` if found in the redeclaration lookup. Before this patch, since `getAsSingle` used internally `getUnderlyingDecl()`, `PrevDecl` was for the `NamespaceDecl` for `Q`, and not for the `VarDecl` for `Q::i`. Then the declaration for the enumerator `i` was mistakenly rejected since `Q` is in the same scope.

- Clarified some comments.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60956/new/

https://reviews.llvm.org/D60956

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/dcl.dcl/dcl.enum/p11-enumerator_scope.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60956.196264.patch
Type: text/x-patch
Size: 12020 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190423/b0e88a8a/attachment-0001.bin>


More information about the cfe-commits mailing list