summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp1
-rw-r--r--clang/test/Modules/Inputs/innerstructredef.h6
-rw-r--r--clang/test/Modules/Inputs/module.map9
-rw-r--r--clang/test/Modules/inner-struct-redefines-invisible.m12
4 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index d19ace9c43b..86c367097f7 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
// comparison.
SkipBody->CheckSameAsPrevious = true;
SkipBody->New = createTagFromNewDecl();
+ SkipBody->New->setLexicalDeclContext(CurContext);
SkipBody->Previous = Hidden;
} else {
SkipBody->ShouldSkip = true;
diff --git a/clang/test/Modules/Inputs/innerstructredef.h b/clang/test/Modules/Inputs/innerstructredef.h
new file mode 100644
index 00000000000..600f44e41cf
--- /dev/null
+++ b/clang/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/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map
index 4cb3e8a0280..4788daa4316 100644
--- a/clang/test/Modules/Inputs/module.map
+++ b/clang/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/clang/test/Modules/inner-struct-redefines-invisible.m b/clang/test/Modules/inner-struct-redefines-invisible.m
new file mode 100644
index 00000000000..ecf6d808df3
--- /dev/null
+++ b/clang/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;
+};
OpenPOWER on IntegriCloud