[cfe-dev] GNU extensions to C99 designated initializers gnu99-init-1.c test case

SENTHIL KUMAR THANGAVELU senthil.t at samsung.com
Tue Oct 9 07:49:09 PDT 2012


Hi all,
    I have the following test program and the output if I print n in gdb is also added, used llvm 3.1 release. Looking into InitListChecker::CheckDesignatedInitializer in SemaInit.cpp. Any comments or insights are welcome from clang parser experts. This test case is a reduced version of gcc regression test case gnu99-init-1.c .

struct I { int J; int K[3]; int L; };
struct M { int N; struct I O[3]; int P; };
struct M n[] = { [0 ... 1].O[1 ... 2].K[0 ... 1] = 4, 5, 6, 7};
int main (void)
{
}

=============== gcc output ===============
{N = 0, O = {{J = 0, K = {0, 0, 0}, L = 0}, {J = 0, K = {4, 4, 0}, L = 0}, {J = 0, K = {4, 4, 0}, L = 0}}, P = 0}, 
{N = 0, O = {{J = 0, K = {0, 0, 0}, L = 0}, {J = 0, K = {4, 4, 0}, L = 0}, {J = 0, K = {4, 4, 5}, L = 6}}, P = 7}

=============== clang output ===============
{N = 0, O = {{J = 0, K = {0, 0, 0}, L = 0}, {J = 0, K = {4, 4, 5}, L = 0}, {J = 0, K = {4, 4, 5}, L = 6}}, P = 0}, 
{N = 0, O = {{J = 0, K = {0, 0, 0}, L = 0}, {J = 0, K = {4, 4, 5}, L = 0}, {J = 0, K = {4, 4, 5}, L = 6}}, P = 7}

Regards
Senthil Kumar




More information about the cfe-dev mailing list