An incomplete type argument to several traits is specified to be undefined
behavior in the library; since it's a compile-time property, we diagnose
it. But apparently some code was relying on the previous behavior of not
diagnosing. So let's make it a permerror.
The assert in cxx_incomplete_type_diagnostic didn't like that, and I don't
see the point of having the assert, so let's just remove it.
PR c++/109277
gcc/cp/ChangeLog:
* semantics.cc (check_trait_type): Handle incomplete type directly.
* typeck2.cc (cxx_incomplete_type_diagnostic): Remove assert.
gcc/testsuite/ChangeLog:
* g++.dg/ext/is_convertible5.C: New test.
if (VOID_TYPE_P (type))
return true;
- return !!complete_type_or_else (strip_array_types (type), NULL_TREE);
+ type = complete_type (strip_array_types (type));
+ if (!COMPLETE_TYPE_P (type)
+ && cxx_incomplete_type_diagnostic (NULL_TREE, type, DK_PERMERROR)
+ && !flag_permissive)
+ return false;
+ return true;
}
/* Process a trait expression. */
{
bool is_decl = false, complained = false;
- gcc_assert (diag_kind == DK_WARNING
- || diag_kind == DK_PEDWARN
- || diag_kind == DK_ERROR);
-
/* Avoid duplicate error message. */
if (TREE_CODE (type) == ERROR_MARK)
return false;
--- /dev/null
+// PR c++/109277
+// { dg-do compile { target c++11 } }
+// { dg-options -fpermissive }
+
+struct a;
+struct b{};
+static_assert (!__is_convertible (a, b), ""); // { dg-warning "incomplete" }