- if ((is_type_arithmetic(type_left) && is_type_arithmetic(type_right)) ||
- (is_type_pointer(type_left) && is_null_pointer_constant(right)) ||
- (is_type_atomic(type_left, ATOMIC_TYPE_BOOL)
- && is_type_pointer(type_right))) {
- return orig_type_left;
- }
+ if(is_type_pointer(type_left)) {
+ if(is_null_pointer_constant(right)) {
+ return orig_type_left;
+ } else if(is_type_pointer(type_right)) {
+ type_t *points_to_left
+ = skip_typeref(type_left->pointer.points_to);
+ type_t *points_to_right
+ = skip_typeref(type_right->pointer.points_to);
+
+ /* the left type has all qualifiers from the right type */
+ unsigned missing_qualifiers
+ = points_to_right->base.qualifiers & ~points_to_left->base.qualifiers;
+ if(missing_qualifiers != 0) {
+ errorf(source_position,
+ "destination type '%T' in %s from type '%T' lacks qualifiers '%Q' in pointed-to type", type_left, context, type_right, missing_qualifiers);
+ return orig_type_left;
+ }