]> granicus.if.org Git - clang/commitdiff
[modules] Set the lexical DC for dummy tag decls that refer to hidden
authorAlex Lorenz <arphaman@gmail.com>
Fri, 11 Aug 2017 12:06:52 +0000 (12:06 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 11 Aug 2017 12:06:52 +0000 (12:06 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310706 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Modules/Inputs/innerstructredef.h [new file with mode: 0644]
test/Modules/Inputs/module.map
test/Modules/inner-struct-redefines-invisible.m [new file with mode: 0644]

index d19ace9c43bc2094dff2820316dbc7fbbd4fd9ee..86c367097f7ab6c4bcc85c1e7685383dda99677a 100644 (file)
@@ -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/test/Modules/Inputs/innerstructredef.h b/test/Modules/Inputs/innerstructredef.h
new file mode 100644 (file)
index 0000000..600f44e
--- /dev/null
@@ -0,0 +1,6 @@
+struct Outer {
+// This definition is actually hidden since only submodule 'one' is imported.
+struct Inner {
+  int x;
+} field;
+};
index 4cb3e8a02804592a281c618810d49e646dbaced8..4788daa431662be7be8b6acd3f1c22b374f3e03e 100644 (file)
@@ -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 (file)
index 0000000..ecf6d80
--- /dev/null
@@ -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;
+};