summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/designated-initializers.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-08 20:44:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-08 20:44:28 +0000
commit559c9fb134623e73e8c46d15b15a72fb3d350ec1 (patch)
tree926928b1c72c4a9b122ac205294b7330aae91587 /clang/test/Sema/designated-initializers.c
parent8ed5b7700860f5a158d6d7577cd9bdc499baa066 (diff)
downloadbcm5719-llvm-559c9fb134623e73e8c46d15b15a72fb3d350ec1.tar.gz
bcm5719-llvm-559c9fb134623e73e8c46d15b15a72fb3d350ec1.zip
This patch fixes multiple issues in clang's designated init builder and
completes support for C1X anonymous struct/union init features: * Indexed anonymous member initializers should not be expanded. Doing so makes little sense and would cause unresolvable semantic ambiguity in valid code (regression introduced by r69153). * Subobject initialization of (possibly nested) anonymous members are now referred to with paths relative to the naming record context, eliminating the synthesis of incorrect implicit InitListExprs that caused CodeGen to assert. * Field lookup was missing a null check in IdentifierInfo comparison which caused lookup for a known (already resolved) field to match the first unnamed data member it encountered leading to silent miscompilation. * Subobject paths are no longer built using the general purpose Sema::BuildAnonymousStructUnionMemberPath(). If any corner cases crop up, we will now assert earlier in Sema instead of passing invalid InitListExprs through to CodeGen. Fixes PR6955, from Alp Toker! llvm-svn: 116098
Diffstat (limited to 'clang/test/Sema/designated-initializers.c')
-rw-r--r--clang/test/Sema/designated-initializers.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/Sema/designated-initializers.c b/clang/test/Sema/designated-initializers.c
index 7e4ed6892ae..c9a8482e85d 100644
--- a/clang/test/Sema/designated-initializers.c
+++ b/clang/test/Sema/designated-initializers.c
@@ -249,3 +249,31 @@ struct expr expr0 = {
}
}
};
+
+// PR6955
+
+struct ds {
+ struct {
+ struct {
+ unsigned int a;
+ };
+ unsigned int b;
+ struct {
+ unsigned int c;
+ };
+ };
+};
+
+// C1X lookup-based anonymous member init cases
+struct ds ds0 = {
+ { {
+ .a = 1 // expected-note{{previous initialization is here}}
+ } },
+ .a = 2, // expected-warning{{initializer overrides prior initialization of this subobject}}
+ .b = 3
+};
+struct ds ds1 = { .c = 0 };
+struct ds ds2 = { { {
+ .a = 0,
+ .b = 1 // expected-error{{field designator 'b' does not refer to any field}}
+} } };
OpenPOWER on IntegriCloud