This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
revised patch for compare1.c and cast-qual-1.c test failures
- To: Zack Weinberg <zack at bitmover dot com>
- Subject: revised patch for compare1.c and cast-qual-1.c test failures
- From: Gavin Romig-Koch <gavin at cygnus dot com>
- Date: Thu, 28 Oct 1999 17:14:50 -0400 (EDT)
- Cc: gcc-patches at gcc dot gnu dot org
- References: <199910271911.MAA07403@zack.bitmover.com>
Zack Weinberg writes:
> 1999-10-27 12:05 -0700 Zack Weinberg <zack@bitmover.com>
>
> * c-parse.in (primary: IDENTIFIER): When parsing an
> enumeration constant, generate ((enum foo) 12) not ((int) 12).
> * c-typeck.c (build_conditional_expr): If -Wsign-compare, warn
> about (expr ? signed : unsigned).
> (build_c_cast): Strip only one level of POINTER_TYPE nodes
> to check for mismatched qualifiers.
>
> * c-common.c (check_case_value): Use STRIP_NOPS not
> STRIP_TYPE_NOPS.
> * c-decl.c (grokdeclarator, build_enumerator): Likewise.
OK, except for the follow:
> Index: c-parse.in
> --- c-parse.in 1999/10/26 18:13:37 1.26
> +++ c-parse.in 1999/10/27 19:05:06
> @@ -786,10 +786,9 @@ end ifobjc
>
> if (TREE_CODE ($$) == CONST_DECL)
> {
> - $$ = DECL_INITIAL ($$);
> - /* This is to prevent an enum whose value is 0
> - from being considered a null pointer constant. */
> - $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
> + /* Preserve the type of an enumeration constant. */
> + $$ = build1 (NOP_EXPR, TREE_TYPE ($$),
> + DECL_INITIAL ($$));
> TREE_CONSTANT ($$) = 1;
> }
> }
I think the old comment contained useful information that shouldn't
be dropped.
> ===================================================================
> Index: c-typeck.c
> --- c-typeck.c 1999/10/27 05:32:42 1.42
> +++ c-typeck.c 1999/10/27 19:05:08
> @@ -3653,15 +3673,10 @@ build_c_cast (type, expr)
> && TREE_CODE (type) == POINTER_TYPE
> && TREE_CODE (otype) == POINTER_TYPE)
> {
> - /* Go to the innermost object being pointed to. */
> - tree in_type = type;
> - tree in_otype = otype;
> -
> - while (TREE_CODE (in_type) == POINTER_TYPE)
> - in_type = TREE_TYPE (in_type);
> - while (TREE_CODE (in_otype) == POINTER_TYPE)
> - in_otype = TREE_TYPE (in_otype);
> -
> + /* Strip one level of pointerness. */
> + tree in_type = TREE_TYPE (type);
> + tree in_otype = TREE_TYPE (otype);
> +
> if (TYPE_QUALS (in_otype) & ~TYPE_QUALS (in_type))
> /* There are qualifiers present in IN_OTYPE that are not
> present in IN_TYPE. */
I think we need to be warning about loss of qualifiers at every level,
not just the first or the last.
-gavin...