|| TREE_CODE (t1) == ERROR_MARK || TREE_CODE (t2) == ERROR_MARK)
return true;
+ /* Qualifiers must match. C99 6.7.3p9 */
+
+ if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
+ return false;
+
/* Enumerated types are compatible with integer types, but this is
not transitive: two enumerated types in the same translation unit
are compatible with each other only if they are the same type. */
if (TREE_CODE (t1) != TREE_CODE (t2))
return false;
- /* Qualifiers must match. C99 6.7.3p9 */
-
- if (TYPE_QUALS (t1) != TYPE_QUALS (t2))
- return false;
-
/* Allow for two different type nodes which have essentially the same
definition. Note that we already checked for equality of the type
qualifiers (just above). */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-std=c23" } */
+
+const enum E { A } *x;
+
+/* qualifier mismatch */
+_Static_assert(_Generic(x, unsigned int *: 0, default: 1), "");
+
--- /dev/null
+/* { dg-do compile } */
+
+enum E { E1 = -1, E2 = 0, E3 = 1 };
+const volatile enum E i2;
+extern int i2; /* { dg-error "conflicting type qualifiers" } */
+