diff gcc/testsuite/gcc.dg/lvalue-9.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/lvalue-9.c	Thu Feb 13 11:34:05 2020 +0900
@@ -0,0 +1,77 @@
+/* Test handling of lvalues of incomplete types.  Bugs 36941, 88647
+   (invalid), 88827.  */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+struct S;
+
+extern struct S var;
+extern struct S *vp;
+extern int i;
+
+void
+f1 (void)
+{
+  var; /* { dg-error "has an incomplete type" } */
+  var, (void) 0; /* { dg-error "has an incomplete type" } */
+  (i
+   ? var /* { dg-error "has an incomplete type" } */
+   : var); /* { dg-error "has an incomplete type" } */
+}
+
+void
+f2 (void)
+{
+  (void) var; /* { dg-error "has an incomplete type" } */
+  (void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
+  (void) (i
+	  ? var /* { dg-error "has an incomplete type" } */
+	  : var); /* { dg-error "has an incomplete type" } */
+}
+
+void
+f3 (void)
+{
+  (const void) var; /* { dg-error "has an incomplete type" } */
+  (const void) (var, (void) 0); /* { dg-error "has an incomplete type" } */
+  (const void) (i
+		? var /* { dg-error "has an incomplete type" } */
+		: var); /* { dg-error "has an incomplete type" } */
+}
+
+void
+f4 (void)
+{
+  *vp; /* { dg-error "invalid use of undefined type" } */
+  *vp, (void) 0; /* { dg-error "invalid use of undefined type" } */
+  (i
+   ? *vp /* { dg-error "invalid use of undefined type" } */
+   : *vp); /* { dg-error "invalid use of undefined type" } */
+}
+
+void
+f5 (void)
+{
+  (void) *vp; /* { dg-error "invalid use of undefined type" } */
+  (void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
+  (void) (i
+	  ? *vp /* { dg-error "invalid use of undefined type" } */
+	  : *vp); /* { dg-error "invalid use of undefined type" } */
+}
+
+void
+f6 (void)
+{
+  (const void) *vp; /* { dg-error "invalid use of undefined type" } */
+  (const void) (*vp, (void) 0); /* { dg-error "invalid use of undefined type" } */
+  (const void) (i
+		? *vp /* { dg-error "invalid use of undefined type" } */
+		: *vp); /* { dg-error "invalid use of undefined type" } */
+}
+
+void
+f7 (void)
+{
+  /* This is invalid because of the constraints on [].  */
+  &vp[0]; /* { dg-error "invalid use of undefined type" } */
+}