Under some error condition we can end up with NULL_TREEs for
the type of bitfields, which can cause an ICE when testing for
type compatibility. Add the missing check.
PR c/121217
gcc/c/ChangeLog:
* c-typeck.cc (tagged_types_tu_compatible_p): Add check.
gcc/testsuite/ChangeLog:
* gcc.dg/pr121217.c: New test.
ft2 = DECL_BIT_FIELD_TYPE (s2);
}
+ if (!ft1 || !ft2)
+ return false;
+
if (TREE_CODE (ft1) == ERROR_MARK || TREE_CODE (ft2) == ERROR_MARK)
return false;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-std=gnu17" } */
+
+typedef union{
+ char *nordic_ref;
+ unsigned long long int bit_number;
+ enum PinMode mode : 2; /* { dg-warning "narrower" } */
+ /* { dg-error "field 'mode'" "" { target *-*-* } .-1 } */
+ unsigned char value;
+ } s; typedef struct{
+ union{
+ char *nordic_ref;
+ unsigned long long int bit_number;
+ enum PinMode mode : 2; /* { dg-warning "narrower" } */
+ /* { dg-error "field 'mode'" "" { target *-*-* } .-1 } */
+ unsigned char value;
+ } s;
+} /* { dg-error "expected identifier" } */
+