@@ -1016,16 +1016,21 @@ static struct symbol *evaluate_compare(struct expression *expr)
struct symbol *ctype;
const char *typediff;
- expr->flags = left->flags & right->flags & ~CEF_CONST_MASK;
- expr->flags &= ~CEF_ADDR;
-
/* Type types? */
- if (is_type_type(ltype) && is_type_type(rtype))
+ if (is_type_type(ltype) && is_type_type(rtype)) {
+ /*
+ * __builtin_types_compatible_p() yields an integer
+ * constant expression
+ */
+ expr->flags = CEF_SET_ICE;
goto OK;
+ }
if (is_safe_type(left->ctype) || is_safe_type(right->ctype))
warning(expr->pos, "testing a 'safe expression'");
+ expr->flags = left->flags & right->flags & ~CEF_CONST_MASK & ~CEF_ADDR;
+
/* number on number */
if (lclass & rclass & TYPE_NUM) {
ctype = usual_conversions(expr->op, expr->left, expr->right,
@@ -131,7 +131,6 @@ static struct token *parse_type(struct token *token, struct expression **tree)
{
struct symbol *sym;
*tree = alloc_expression(token->pos, EXPR_TYPE);
- (*tree)->flags = CEF_SET_ICE; /* sic */
token = typename(token, &sym, NULL);
if (sym->ident)
sparse_error(token->pos,
@@ -459,8 +458,6 @@ struct token *primary_expression(struct token *token, struct expression **tree)
}
if (token->special == '[' && lookup_type(token->next)) {
expr = alloc_expression(token->pos, EXPR_TYPE);
- /* sic */
- expr->flags = CEF_SET_ICE;
token = typename(token->next, &expr->symbol, NULL);
token = expect(token, ']', "in type expression");
break;
new file mode 100644
@@ -0,0 +1,8 @@
+static int a[] = {[__builtin_types_compatible_p(int, int)] = 0};
+
+/*
+ * check-name: __builtin_types_compatible_p() constness verification.
+ *
+ * check-error-start
+ * check-error-end
+ */