HomePhabricator

[Sema] Error out early for tags defined inside an enumeration.

Authored by vsapsai on Sep 15 2017, 12:51 PM.

Description

[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.

rdar://problem/28530809

Reviewers: rnk, doug.gregor, rsmith

Reviewed By: doug.gregor

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D37089

llvm-svn: 313386

Details

Committed
vsapsaiSep 15 2017, 12:51 PM
Reviewer
doug.gregor
Differential Revision
D37089: [Sema] Error out early for tags defined inside an enumeration.
Parents
rGe28adb4fb2a1: [Analyzer] Check function name size before indexing.
Branches
Unknown
Tags
Unknown