diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-08-15 00:24:02 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-08-15 00:24:02 +0000 |
commit | af145231499333600c48437ed838de2903172704 (patch) | |
tree | 27b1bb188c53539c96b6282e498afccdd81b876d | |
parent | b52dc49165b05501903ea7355e646467da025c3a (diff) |
Merging r310706 and r310829:
------------------------------------------------------------------------
r310706 | arphaman | 2017-08-11 05:06:52 -0700 (Fri, 11 Aug 2017) | 11 lines
[modules] Set the lexical DC for dummy tag decls that refer to hidden
declarations that are made visible after the dummy is parsed and ODR verified
Prior to this commit the
"(getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one."),"
assertion failure was triggered during semantic analysis of the dummy
tag declaration that was declared in another tag declaration because its
lexical context did not point to the outer tag decl.
rdar://32292196
------------------------------------------------------------------------
------------------------------------------------------------------------
r310829 | arphaman | 2017-08-14 03:59:44 -0700 (Mon, 14 Aug 2017) | 5 lines
Set the lexical context for dummy tag decl inside createTagFromNewDecl
This is a follow-up to r310706. This change has been recommended by
Bruno Cardoso Lopes and Richard Smith.
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@310902 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 1 | ||||
-rw-r--r-- | test/Modules/Inputs/innerstructredef.h | 6 | ||||
-rw-r--r-- | test/Modules/Inputs/module.map | 9 | ||||
-rw-r--r-- | test/Modules/inner-struct-redefines-invisible.m | 12 |
4 files changed, 28 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 6bcb023174..62d9a6a2b4 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -13293,6 +13293,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, AddMsStructLayoutForRecord(RD); } } + New->setLexicalDeclContext(CurContext); return New; }; diff --git a/test/Modules/Inputs/innerstructredef.h b/test/Modules/Inputs/innerstructredef.h new file mode 100644 index 0000000000..600f44e41c --- /dev/null +++ b/test/Modules/Inputs/innerstructredef.h @@ -0,0 +1,6 @@ +struct Outer { +// This definition is actually hidden since only submodule 'one' is imported. +struct Inner { + int x; +} field; +}; diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index 4cb3e8a028..4788daa431 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -451,3 +451,12 @@ module DebugNestedB { module objcAtKeywordMissingEnd { header "objcAtKeywordMissingEnd.h" } + +module innerstructredef { + module one { + header "empty.h" + } + module two { + header "innerstructredef.h" + } +} diff --git a/test/Modules/inner-struct-redefines-invisible.m b/test/Modules/inner-struct-redefines-invisible.m new file mode 100644 index 0000000000..ecf6d808df --- /dev/null +++ b/test/Modules/inner-struct-redefines-invisible.m @@ -0,0 +1,12 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify %s +// expected-no-diagnostics + +@import innerstructredef.one; + +struct Outer { +// Should set lexical context when parsing 'Inner' here, otherwise there's a crash: +struct Inner { + int x; +} field; +}; |