summaryrefslogtreecommitdiffstats
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index dd842852cc7..5ec00aa4250 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -744,18 +744,24 @@ same_translation_unit_p (tree t1, tree t2)
while (t1 && TREE_CODE (t1) != TRANSLATION_UNIT_DECL)
switch (TREE_CODE_CLASS (TREE_CODE (t1)))
{
- case 'd': t1 = DECL_CONTEXT (t1); break;
- case 't': t1 = TYPE_CONTEXT (t1); break;
- case 'x': t1 = BLOCK_SUPERCONTEXT (t1); break; /* assume block */
+ case tcc_declaration:
+ t1 = DECL_CONTEXT (t1); break;
+ case tcc_type:
+ t1 = TYPE_CONTEXT (t1); break;
+ case tcc_exceptional:
+ t1 = BLOCK_SUPERCONTEXT (t1); break; /* assume block */
default: gcc_unreachable ();
}
while (t2 && TREE_CODE (t2) != TRANSLATION_UNIT_DECL)
switch (TREE_CODE_CLASS (TREE_CODE (t2)))
{
- case 'd': t2 = DECL_CONTEXT (t2); break;
- case 't': t2 = TYPE_CONTEXT (t2); break;
- case 'x': t2 = BLOCK_SUPERCONTEXT (t2); break; /* assume block */
+ case tcc_declaration:
+ t2 = DECL_CONTEXT (t2); break;
+ case tcc_type:
+ t2 = TYPE_CONTEXT (t2); break;
+ case tcc_exceptional:
+ t2 = BLOCK_SUPERCONTEXT (t2); break; /* assume block */
default: gcc_unreachable ();
}
@@ -1200,7 +1206,7 @@ default_function_array_conversion (tree exp)
int volatilep = 0;
int lvalue_array_p;
- if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r' || DECL_P (exp))
+ if (REFERENCE_CLASS_P (exp) || DECL_P (exp))
{
constp = TREE_READONLY (exp);
volatilep = TREE_THIS_VOLATILE (exp);
@@ -2232,7 +2238,8 @@ parser_build_binary_op (enum tree_code code, struct c_expr arg1,
|| code2 == PLUS_EXPR || code2 == MINUS_EXPR)
warning ("suggest parentheses around arithmetic in operand of |");
/* Check cases like x|y==z */
- if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
+ if (TREE_CODE_CLASS (code1) == tcc_comparison
+ || TREE_CODE_CLASS (code2) == tcc_comparison)
warning ("suggest parentheses around comparison in operand of |");
}
@@ -2244,7 +2251,8 @@ parser_build_binary_op (enum tree_code code, struct c_expr arg1,
|| code2 == PLUS_EXPR || code2 == MINUS_EXPR)
warning ("suggest parentheses around arithmetic in operand of ^");
/* Check cases like x^y==z */
- if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
+ if (TREE_CODE_CLASS (code1) == tcc_comparison
+ || TREE_CODE_CLASS (code2) == tcc_comparison)
warning ("suggest parentheses around comparison in operand of ^");
}
@@ -2254,13 +2262,14 @@ parser_build_binary_op (enum tree_code code, struct c_expr arg1,
|| code2 == PLUS_EXPR || code2 == MINUS_EXPR)
warning ("suggest parentheses around + or - in operand of &");
/* Check cases like x&y==z */
- if (TREE_CODE_CLASS (code1) == '<' || TREE_CODE_CLASS (code2) == '<')
+ if (TREE_CODE_CLASS (code1) == tcc_comparison
+ || TREE_CODE_CLASS (code2) == tcc_comparison)
warning ("suggest parentheses around comparison in operand of &");
}
/* Similarly, check for cases like 1<=i<=10 that are probably errors. */
- if (TREE_CODE_CLASS (code) == '<'
- && (TREE_CODE_CLASS (code1) == '<'
- || TREE_CODE_CLASS (code2) == '<'))
+ if (TREE_CODE_CLASS (code) == tcc_comparison
+ && (TREE_CODE_CLASS (code1) == tcc_comparison
+ || TREE_CODE_CLASS (code2) == tcc_comparison))
warning ("comparisons like X<=Y<=Z do not have their mathematical meaning");
}
@@ -2604,7 +2613,7 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
to which the address will point. Note that you can't get a
restricted pointer by taking the address of something, so we
only have to deal with `const' and `volatile' here. */
- if ((DECL_P (arg) || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r')
+ if ((DECL_P (arg) || REFERENCE_CLASS_P (arg))
&& (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg)))
argtype = c_build_type_variant (argtype,
TREE_READONLY (arg),
@@ -3208,7 +3217,7 @@ build_c_cast (tree type, tree expr)
else
TREE_OVERFLOW (value) = 0;
- if (TREE_CODE_CLASS (TREE_CODE (ovalue)) == 'c')
+ if (CONSTANT_CLASS_P (ovalue))
/* Similarly, constant_overflow cannot have become
cleared. */
TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
@@ -6396,7 +6405,7 @@ c_finish_return (tree retval)
case ADDR_EXPR:
inner = TREE_OPERAND (inner, 0);
- while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r'
+ while (REFERENCE_CLASS_P (inner)
&& TREE_CODE (inner) != INDIRECT_REF)
inner = TREE_OPERAND (inner, 0);
@@ -6744,7 +6753,7 @@ c_process_expr_stmt (tree expr)
/* If the expression is not of a type to which we cannot assign a line
number, wrap the thing in a no-op NOP_EXPR. */
- if (DECL_P (expr) || TREE_CODE_CLASS (TREE_CODE (expr)) == 'c')
+ if (DECL_P (expr) || CONSTANT_CLASS_P (expr))
expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
if (EXPR_P (expr))
OpenPOWER on IntegriCloud