if (data->equiv && data->pointedto)
return true;
- if (!data->anon_field && NULL_TREE == TYPE_NAME (t1))
+ /* Different types without tag are incompatible except as an anonymous
+ field or when forming equivalence classes for TYPE_CANONICAL. */
+ if (!data->anon_field && !data->equiv && NULL_TREE == TYPE_NAME (t1))
return false;
if (!data->anon_field && TYPE_STUB_DECL (t1) != TYPE_STUB_DECL (t2))
* { dg-options "-std=gnu23 -O2" }
*/
-/* This test checks that an incompatible definition of
+/* This used to check that an incompatible definition of
* a tagged type without tag can be assumed not to alias.
- * and that this is exploited during optimization. */
+ * and that this is exploited during optimization.
+ * Because PR117490 we now check the opposite. */
-// not sure this is wise, but this was already like this before
typedef struct { int x; } foo_t;
{
foo_t y;
- if (1 != test_foo(&y, &y))
+ if (2 != test_foo(&y, &y))
__builtin_abort();
return 0;
__builtin_abort();
struct bar4 z4;
-
+#if 0
+ // we used to test this, but this would be incorrect
+ // if there is a declaration in another TU cf. PR117490
if (1 != test_bar4(&z4, &z4))
__builtin_abort();
-
+#endif
return 0;
}
/* PR debug/86985 */
/* { dg-do run } */
-/* { dg-options "-g" } */
+/* { dg-options "-std=c17 -g" } */
+
+/* FIXME: Use -std=c17 until PR113688 if fixed. */
struct {
int foo;
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2 -std=c23" } */
+
+typedef struct {
+ int i1;
+} s1;
+
+typedef struct {
+ int i1;
+} s2_alt;
+
+[[gnu::noinline,gnu::noipa]]
+int f2(s1 *s1p, s2_alt *s2p) {
+ s1p->i1 = 2;
+ s2p->i1 = 3;
+ return s1p->i1 * 3;
+}
+
+int main()
+{
+ s1 a;
+ if (9 != f2(&a, (void*)&a))
+ __builtin_abort();
+}
+