diff gcc/testsuite/g++.dg/ext/flexary27.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children 1830386684a0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/g++.dg/ext/flexary27.C	Thu Oct 25 07:37:49 2018 +0900
@@ -0,0 +1,25 @@
+// PR c++/81922
+// { dg-do compile }
+
+struct S { const char *a; char b[]; };	// { dg-error "forbids flexible array member" }
+struct T { int a; int b[]; };	// { dg-error "forbids flexible array member" }
+#if __cplusplus >= 201103L
+S c[] { "", "" };		// { dg-error "initialization of flexible array member in a nested context" "" { target c++11 } }
+				// { dg-error "initialization of a flexible array member" "" { target c++11 } .-1 }
+S d[] { "", { 0 } };		// { dg-error "initialization of flexible array member in a nested context" "" { target c++11 } }
+				// { dg-error "initialization of a flexible array member" "" { target c++11 } .-1 }
+T e[] { 1, { 2 }, 3, { 4 } };	// { dg-error "initialization of flexible array member in a nested context" "" { target c++11 } }
+				// { dg-error "initialization of a flexible array member" "" { target c++11 } .-1 }
+T f[] { 1, {}, 3, {} };		// { dg-error "initialization of a flexible array member" "" { target c++11 } }
+T g { 1, { 1, 2, 3 } };		// { dg-error "initialization of a flexible array member" "" { target c++11 } }
+S h { "abcd", "" };		// { dg-error "initialization of a flexible array member" "" { target c++11 } }
+#endif
+S i[] = { "", "", "", "" };	// { dg-error "initialization of flexible array member in a nested context" }
+				// { dg-error "initialization of a flexible array member" "" { target *-*-* } .-1 }
+S j[] = { "", { 1 }, "", { 2, 3 } };	// { dg-error "initialization of flexible array member in a nested context" }
+				// { dg-error "initialization of a flexible array member" "" { target *-*-* } .-1 }
+T k[] = { 1, { 2 }, 3, { 4 } };	// { dg-error "initialization of flexible array member in a nested context" }
+				// { dg-error "initialization of a flexible array member" "" { target *-*-* } .-1 }
+T l[] = { 1, {}, 3, {} };	// { dg-error "initialization of a flexible array member" }
+T m = { 1, { 1, 2, 3 } };	// { dg-error "initialization of a flexible array member" }
+S n = { "", "abcde" };		// { dg-error "initialization of a flexible array member" }