This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: CHILL warning question ... (grant.c & typeck.c spots)


Oooops. Meant to say "I approve"

Dave

Kaveh R. Ghazi wrote:

>  > From: Dave Brolley <brolley@cygnus.com>
>  >
>  > Kaveh R. Ghazi wrote:
>  >
>  > >  ---------------------------
>  > > grant.c: In function `decode_decl_selective':
>  > > grant.c:2508: warning: enumeration value `__DUMMY' not handled in switch
>  > > [...]
>  > > grant.c:2508: warning: case value `29' not in enumerated type `chill_tree_code'
>  > > grant.c:2508: warning: case value `31' not in enumerated type `chill_tree_code'
>  > > grant.c:2508: warning: case value `32' not in enumerated type `chill_tree_code'
>  > > grant.c:2508: warning: case value `33' not in enumerated type `chill_tree_code'
>  > > grant.c:2508: warning: case value `36' not in enumerated type `chill_tree_code'
>  > > ---------------------------
>  >
>  > This one uses enumerators from both enum tree_code and enum chill_tree_code. I think one
>  > way to get rid of the warnings might be to change the switch statement itself to
>  >
>  > switch ((int)TREE_CODE (decl))
>  >
>  > since enumerators have type int in C anyway. A default: label will get rid of the other
>  > warning, but I'm not sure myself whether it should abort, or fall though.
>  >
>  > > grant.c: In function `really_grant_this':
>  > > grant.c:2792: warning: enumeration value `__DUMMY' not handled in switch
>  > > [...]
>  > > grant.c:2792: warning: case value `29' not in enumerated type `chill_tree_code'
>  > > grant.c:2792: warning: case value `31' not in enumerated type `chill_tree_code'
>  > > grant.c:2792: warning: case value `32' not in enumerated type `chill_tree_code'
>  > > grant.c:2792: warning: case value `33' not in enumerated type `chill_tree_code'
>  > > ---------------------------
>  >
>  > Same with this one, except it seems clear that the default: should fall through in order
>  > to generrate the error message.
>  >
>  > > typeck.c: In function `chill_resulting_class':
>  > > typeck.c:2039: warning: enumeration value `CH_NULL_CLASS' not handled in switch
>  > > typeck.c:2039: warning: enumeration value `CH_REFERENCE_CLASS' not handled in switch
>  > > ---------------------------
>  > > typeck.c:2055: warning: enumeration value `CH_NULL_CLASS' not handled in switch
>  > > typeck.c:2055: warning: enumeration value `CH_REFERENCE_CLASS' not handled in switch
>  > > ---------------------------
>  > > typeck.c:2071: warning: enumeration value `CH_NULL_CLASS' not handled in switch
>  > > typeck.c:2071: warning: enumeration value `CH_REFERENCE_CLASS' not handled in switch
>  > > ---------------------------
>  > > typeck.c:2072: warning: enumeration value `CH_NULL_CLASS' not handled in switch
>  > > typeck.c:2072: warning: enumeration value `CH_REFERENCE_CLASS' not handled in switch
>  > > ---------------------------
>  >
>  > These should all have default: labels which fall through in order to generate the error
>  > message at the bottom of the function. The outer switch should also have breaks added
>  > for each block.
>  >
>  > Dave
>
>         Based on the above, I check in the following patch.
>
>                 --Kaveh
>
> Index: ChangeLog
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/gcc/ch/ChangeLog,v
> retrieving revision 1.14
> diff -u -p -r1.14 ChangeLog
> --- ChangeLog   1998/09/29 18:41:02     1.14
> +++ ChangeLog   1998/09/30 23:04:06
> @@ -1,3 +1,12 @@
> +Wed Sep 30 19:03:02 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
> +
> +       * grant.c (decode_decl_selective): Cast switch's enum argument to
> +       an int.
> +       (really_grant_this): Add default case in switch.
> +
> +       * typeck.c (chill_resulting_class): Add default cases in switch.
> +       Also add `break' statements after each case.
> +
>  Tue Sep 29 21:37:33 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
>
>         * ch-tree.h (build_compare_expr): Change first argument's type
> Index: grant.c
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/gcc/ch/grant.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 grant.c
> --- grant.c     1998/09/20 06:43:12     1.2
> +++ grant.c     1998/09/30 23:04:07
> @@ -2405,7 +2405,7 @@ decode_decl_selective (decl, all_decls)
>
>    CH_ALREADY_GRANTED (decl) = 1;
>
> -  switch ((enum chill_tree_code)TREE_CODE (decl))
> +  switch ((int)TREE_CODE (decl))
>      {
>      case VAR_DECL:
>      case BASED_DECL:
> @@ -2789,6 +2789,8 @@ really_grant_this (decl, granted_decls)
>         return search_in_list (DECL_NAME (decl), granted_decls);
>        else
>         return 1;
> +    default:
> +      break;
>      }
>
>    /* this nerver should happen */
> Index: typeck.c
> ===================================================================
> RCS file: /egcs/carton/cvsfiles/egcs/gcc/ch/typeck.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 typeck.c
> --- typeck.c    1998/09/20 06:43:23     1.4
> +++ typeck.c    1998/09/30 23:04:07
> @@ -2036,7 +2036,10 @@ chill_resulting_class (class1, class2)
>           class.mode
>             = CH_ROOT_MODE (CH_RESULTING_MODE (class1.mode, class2.mode));
>           return class;
> +       default:
> +         break;
>         }
> +      break;
>      case CH_DERIVED_CLASS:
>        switch (class2.kind)
>         {
> @@ -2052,7 +2055,10 @@ chill_resulting_class (class1, class2)
>           class.kind = CH_DERIVED_CLASS;
>           class.mode = CH_ROOT_MODE (class1.mode);
>           return class;
> +       default:
> +         break;
>         }
> +      break;
>      case CH_ALL_CLASS:
>        switch (class2.kind)
>         {
> @@ -2068,7 +2074,12 @@ chill_resulting_class (class1, class2)
>           class.kind = CH_DERIVED_CLASS;
>           class.mode = CH_ROOT_MODE (class2.mode);
>           return class;
> +       default:
> +         break;
>         }
> +      break;
> +    default:
> +      break;
>      }
>    error ("internal error in chill_root_resulting_mode");
>    class.kind = CH_VALUE_CLASS;





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]