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]
Other format: [Raw text]

Re: [C PATCH] Make attributes accept enum values (PR c/50459)


On 04/14/2014 10:32 AM, Marek Polacek wrote:
> +      if (TREE_CODE (val) != IDENTIFIER_NODE
> +	  && TREE_CODE (val) != FUNCTION_DECL)
> +	val = default_conversion (val);
> +      else if (TREE_CODE (val) == IDENTIFIER_NODE)
> +	{
> +	  tree t = lookup_name (val);
> +	  if (t && TREE_CODE (t) == CONST_DECL)
> +	    val = default_conversion (t);
> +	}

In addition to Jason's comment, a general style point:

  if (X != A && X != B)
    ...
  else if (X == A)
    ...

should be written

  if (X == A)
    ...
  else if (X != B)
    ...

As a general rule, positive tests are easier to reason with than negative tests.


r~


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