return false;
if (!TYPE_ATOMIC (TREE_TYPE (expr)))
return false;
+ if (!COMPLETE_TYPE_P (TREE_TYPE (expr)))
+ return false;
if (!lvalue_p (expr))
return false;
if (convert_p)
exp = default_function_array_conversion (loc, exp);
- if (!VOID_TYPE_P (TREE_TYPE (exp.value)))
+ if (!VOID_TYPE_P (TREE_TYPE (exp.value))
+ || (flag_isoc2y
+ && TYPE_QUALS (TREE_TYPE (exp.value)) != TYPE_UNQUALIFIED))
exp.value = require_complete_type (loc, exp.value);
if (for_init || !RECORD_OR_UNION_TYPE_P (TREE_TYPE (exp.value)))
{
--- /dev/null
+/* Test ICE accessing _Atomic void object. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11" } */
+
+extern _Atomic void x;
+
+void
+f (void)
+{
+ /* This has undefined behavior (lvalue conversion on an incomplete type) but
+ should not produce an ICE. */
+ x;
+}
--- /dev/null
+/* Test C2y constraint against lvalue conversion of lvalues with incomplete
+ type: not applied in C23 mode. Although it is not clear that these
+ constructs are valid in C23, we allow certain cases of qualified void
+ there. */
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+
+struct s;
+union u;
+
+extern struct s vs, *ps;
+extern _Atomic struct s vas, *pas;
+extern union u vu, *pu;
+extern _Atomic union u vau, *pau;
+
+extern const void cv, *pcv;
+extern _Atomic void av, *pav;
+
+void
+f ()
+{
+ vs; /* { dg-error "incomplete type" } */
+ *ps; /* { dg-error "invalid use of undefined type" } */
+ vas; /* { dg-error "incomplete type" } */
+ *pas; /* { dg-error "invalid use of undefined type" } */
+ vu; /* { dg-error "incomplete type" } */
+ *pu; /* { dg-error "invalid use of undefined type" } */
+ vau; /* { dg-error "incomplete type" } */
+ *pau; /* { dg-error "invalid use of undefined type" } */
+ cv;
+ *pcv;
+ /* { dg-warning "dereferencing" "dereferencing" { target *-*-* } .-1 } */
+ av;
+ *pav;
+ /* { dg-warning "dereferencing" "dereferencing" { target *-*-* } .-1 } */
+}
--- /dev/null
+/* Test C2y constraint against lvalue conversion of lvalues with incomplete
+ type. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+struct s;
+union u;
+
+extern struct s vs, *ps;
+extern _Atomic struct s vas, *pas;
+extern union u vu, *pu;
+extern _Atomic union u vau, *pau;
+
+extern const void cv, *pcv;
+extern _Atomic void av, *pav;
+
+void
+f ()
+{
+ vs; /* { dg-error "incomplete type" } */
+ *ps; /* { dg-error "invalid use of undefined type" } */
+ vas; /* { dg-error "incomplete type" } */
+ *pas; /* { dg-error "invalid use of undefined type" } */
+ vu; /* { dg-error "incomplete type" } */
+ *pu; /* { dg-error "invalid use of undefined type" } */
+ vau; /* { dg-error "incomplete type" } */
+ *pau; /* { dg-error "invalid use of undefined type" } */
+ cv; /* { dg-error "incomplete type" } */
+ *pcv; /* { dg-error "invalid use of void expression" } */
+ /* { dg-warning "dereferencing" "dereferencing" { target *-*-* } .-1 } */
+ av; /* { dg-error "incomplete type" } */
+ *pav; /* { dg-error "invalid use of void expression" } */
+ /* { dg-warning "dereferencing" "dereferencing" { target *-*-* } .-1 } */
+}