On Thu, Nov 20, 2014 at 11:30:11PM +0100, Mark Wielaard wrote:
> --- a/gcc/config/avr/avr-c.c
> +++ b/gcc/config/avr/avr-c.c
> @@ -386,7 +386,8 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
>       (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not
>       implemented in GCC up to now.  */
>  
> -  if (!strcmp (lang_hooks.name, "GNU C"))
> +  if (strncmp (lang_hooks.name, "GNU C", 5) == 0
> +      && strncmp (lang_hooks.name, "GNU C++", 7) != 0)

I wonder if the tests for C language shouldn't be better done
as (strncmp (lang_hooks.name, "GNU C", 5) == 0
    && strchr ("0123456789", lang_hooks.name[5]) != NULL)
or (strncmp (lang_hooks.name, "GNU C", 5) == 0
    && (ISDIGIT (lang_hooks.name[5]) || lang_hooks.name[5] == '\0'))
to make it explicit what we are looking for, not what we aren't.

> +      either, so for now use 0.  Match GNU C++ first, since it needs to
> +      be compared with strncmp, like GNU C, which has the same prefix.  */
> +      if (! strncmp (language_string, "GNU C++", 7)
> +            || ! strcmp (language_string, "GNU Objective-C++"))

Wrong formatting, || should be below ! on the previous line.

> +     i = 9;
> +      else if (! strncmp (language_string, "GNU C", 5)
>         || ! strcmp (language_string, "GNU GIMPLE")
>         || ! strcmp (language_string, "GNU Go"))

And here too.  But if you use a different check for C (see above), you could
avoid moving the C++ case first.

> --- a/gcc/langhooks.h
> +++ b/gcc/langhooks.h
> @@ -261,7 +261,8 @@ struct lang_hooks_for_lto
>  
>  struct lang_hooks
>  {
> -  /* String identifying the front end.  e.g. "GNU C++".  */
> +  /* String identifying the front end.  e.g. "GNU C++".
> +     Might include language version being used.  */

As we no longer have GNU C++ as any name, using it as an example
is weird.  So,
  /* String identifying the front end and optionally language standard
     version, e.g. "GNU C++98" or "GNU Java".  */
?

LGTM otherwise.

        Jakub

Reply via email to