[Sema] Error out early for tags defined inside an enumeration.
This fixes PR28903 by avoiding access check for inner enum constant. We
are performing access check because one enum constant references another
and because enum is defined in CXXRecordDecl. But access check doesn't
work because FindDeclaringClass doesn't expect more than one EnumDecl
and because inner enum has access AS_none due to not being an immediate
child of a record.
The change detects an enum is defined in wrong place and allows to skip
parsing its body. Access check is skipped together with body parsing.
There was no crash in C, added test case to cover the new error.
Reviewers: rnk, doug.gregor, rsmith
Reviewed By: doug.gregor
Differential Revision: https://reviews.llvm.org/D37089
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313386 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit eae7634a7793e0900b2aec61ced419578e69b258)
4 files changed