1 /* Test for various combinations of const, arrays and typedefs: 2 should never actually get const on the final array type, but 3 all should end up in a read-only section. PR c/12165. */ 4 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */ 5 /* { dg-do compile } */ 6 /* { dg-options "-Wno-discarded-array-qualifiers" } */ 7 /* { dg-additional-options "-fno-pie" { target pie } } */ 8 /* The MMIX port always switches to the .data section at the end of a file. */ 9 /* { dg-final { scan-assembler-not "\\.data(?!\\.rel\\.ro)" { xfail powerpc*-*-aix* mmix-*-* x86_64-*-mingw* } } } */ 10 /* { dg-final { scan-assembler-symbol-section {^_?a$} {^\.(const|rodata|srodata)|\[RO\]} } } */ 11 static const int a[2] = { 1, 2 }; 12 /* { dg-final { scan-assembler-symbol-section {^_?a1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ 13 const int a1[2] = { 1, 2 }; 14 typedef const int ci; 15 /* { dg-final { scan-assembler-symbol-section {^_?b$} {^\.(const|rodata|srodata)|\[RO\]} } } */ 16 static ci b[2] = { 3, 4 }; 17 /* { dg-final { scan-assembler-symbol-section {^_?b1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ 18 ci b1[2] = { 3, 4 }; 19 typedef int ia[2]; 20 /* { dg-final { scan-assembler-symbol-section {^_?c$} {^\.(const|rodata|srodata)|\[RO\]} } } */ 21 static const ia c = { 5, 6 }; 22 /* { dg-final { scan-assembler-symbol-section {^_?c1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ 23 const ia c1 = { 5, 6 }; 24 typedef const int cia[2]; 25 /* { dg-final { scan-assembler-symbol-section {^_?d$} {^\.(const|rodata|srodata)|\[RO\]} } } */ 26 static cia d = { 7, 8 }; 27 /* { dg-final { scan-assembler-symbol-section {^_?d1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ 28 cia d1 = { 7, 8 }; 29 /* { dg-final { scan-assembler-symbol-section {^_?e$} {^\.(const|rodata|srodata)|\[RO\]} } } */ 30 static cia e[2] = { { 1, 2 }, { 3, 4 } }; 31 /* { dg-final { scan-assembler-symbol-section {^_?e1$} {^\.(const|rodata|srodata|sdata)|\[RO\]} } } */ 32 cia e1[2] = { { 1, 2 }, { 3, 4 } }; 33 /* { dg-final { scan-assembler-symbol-section {^_?p$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 34 void *const p = &a; 35 /* { dg-final { scan-assembler-symbol-section {^_?q$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 36 void *const q = &b; 37 /* { dg-final { scan-assembler-symbol-section {^_?r$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 38 void *const r = &c; 39 /* { dg-final { scan-assembler-symbol-section {^_?s$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 40 void *const s = &d; 41 /* { dg-final { scan-assembler-symbol-section {^_?t$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 42 void *const t = &e; 43 /* { dg-final { scan-assembler-symbol-section {^_?p1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 44 void *const p1 = &a1; 45 /* { dg-final { scan-assembler-symbol-section {^_?q1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 46 void *const q1 = &b1; 47 /* { dg-final { scan-assembler-symbol-section {^_?r1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 48 void *const r1 = &c1; 49 /* { dg-final { scan-assembler-symbol-section {^_?s1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 50 void *const s1 = &d1; 51 /* { dg-final { scan-assembler-symbol-section {^_?t1$} {^\.(const|rodata|srodata|sdata)|\[RW\]} } } */ 52 void *const t1 = &e1; 53