r265838 - [modules] Handle merged fields in designated initializers.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 8 12:57:40 PDT 2016
Author: rsmith
Date: Fri Apr 8 14:57:40 2016
New Revision: 265838
URL: http://llvm.org/viewvc/llvm-project?rev=265838&view=rev
Log:
[modules] Handle merged fields in designated initializers.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
cfe/trunk/test/Modules/merge-decl-context.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=265838&r1=265837&r2=265838&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Apr 8 14:57:40 2016
@@ -2227,8 +2227,10 @@ InitListChecker::CheckDesignatedInitiali
for (auto *FI : RT->getDecl()->fields()) {
if (FI->isUnnamedBitfield())
continue;
- if (KnownField == FI)
+ if (declaresSameEntity(KnownField, FI)) {
+ KnownField = FI;
break;
+ }
++FieldIndex;
}
@@ -2241,11 +2243,11 @@ InitListChecker::CheckDesignatedInitiali
FieldIndex = 0;
if (!VerifyOnly) {
FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion();
- if (CurrentField && CurrentField != *Field) {
+ if (CurrentField && !declaresSameEntity(CurrentField, *Field)) {
assert(StructuredList->getNumInits() == 1
&& "A union should never have more than one initializer!");
- // we're about to throw away an initializer, emit warning
+ // We're about to throw away an initializer, emit warning.
SemaRef.Diag(D->getFieldLoc(),
diag::warn_initializer_overrides)
<< D->getSourceRange();
Modified: cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h?rev=265838&r1=265837&r2=265838&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h Fri Apr 8 14:57:40 2016
@@ -21,4 +21,8 @@ inline A<int> ff(int i) {
return fff<A<int>>(&i);
}
+struct Aggregate {
+ int member;
+};
+
#endif
Modified: cfe/trunk/test/Modules/merge-decl-context.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-decl-context.cpp?rev=265838&r1=265837&r2=265838&view=diff
==============================================================================
--- cfe/trunk/test/Modules/merge-decl-context.cpp (original)
+++ cfe/trunk/test/Modules/merge-decl-context.cpp Fri Apr 8 14:57:40 2016
@@ -18,7 +18,13 @@
// RUN: -fmodule-map-file=%S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \
// RUN: -emit-llvm -o %t/test.o %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodule-map-file=%S/Inputs/merge-decl-context/merge-decl-context.modulemap -I%S/Inputs \
+// RUN: -emit-llvm -o %t/test.o -DNO_TEXTUAL_INCLUSION %s
+
+#ifndef NO_TEXTUAL_INCLUSION
#include "Inputs/merge-decl-context/a.h"
+#endif
#include "Inputs/merge-decl-context/b.h"
#include "Inputs/merge-decl-context/c.h"
#include "Inputs/merge-decl-context/d.h"
@@ -26,3 +32,5 @@
void t() {
ff(42);
}
+
+static_assert(Aggregate{.member = 1}.member == 1, "");
More information about the cfe-commits
mailing list