shafik created this revision.
shafik added a reviewer: rsmith.

We have an example showing that a nested designators are a c99 extension but 
not an example showing how to achieve the same thing using a brace-init-list in 
a designated-initializer-clause.


https://reviews.llvm.org/D68722

Files:
  clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp


Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===================================================================
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -37,7 +37,8 @@
   .x = 2 // reorder-error {{ISO C++ requires field designators to be specified 
in declaration order; field 'y' will be initialized after field 'x'}}
 };
 int arr[3] = {[1] = 5}; // pedantic-error {{array designators are a C99 
extension}}
-B b = {.a.x = 0}; // pedantic-error {{nested designators are a C99 extension}}
+B b1 = {.a.x = 0}; // pedantic-error {{nested designators are a C99 extension}}
+B b2 = {.a = {.x = 0, .y = 1}}; // ok, we don't need nested designators to 
initialize the members of A
 A a2 = {
   .x = 1, // pedantic-error {{mixture of designated and non-designated 
initializers in the same initializer list is a C99 extension}}
   2 // pedantic-note {{first non-designated initializer is here}}


Index: clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
===================================================================
--- clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx2a-initializer-aggregates.cpp
@@ -37,7 +37,8 @@
   .x = 2 // reorder-error {{ISO C++ requires field designators to be specified in declaration order; field 'y' will be initialized after field 'x'}}
 };
 int arr[3] = {[1] = 5}; // pedantic-error {{array designators are a C99 extension}}
-B b = {.a.x = 0}; // pedantic-error {{nested designators are a C99 extension}}
+B b1 = {.a.x = 0}; // pedantic-error {{nested designators are a C99 extension}}
+B b2 = {.a = {.x = 0, .y = 1}}; // ok, we don't need nested designators to initialize the members of A
 A a2 = {
   .x = 1, // pedantic-error {{mixture of designated and non-designated initializers in the same initializer list is a C99 extension}}
   2 // pedantic-note {{first non-designated initializer is here}}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to