On Wed, Nov 12, 2014 at 5:31 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Wed, Nov 12, 2014 at 04:46:39PM +0100, Mark Wielaard wrote:
>> I don't mind changing the language hook to return the actual DW_LANG_*
>> constant directly, that seems like a nice cleanup.
>>
>> But I don't think we can just replace TRANSLATION_UNIT_LANGUAGE and
>> lang_hooks.name. The name is (explicitly) const and isused to identify
>
> It is const char *name; , so it isn't const, just what it points is const.
> So you can change if (just after parsing the options set
>   lang_hooks.name = "GNU C11";
> or similar).
>
>> the frontend used for a particular language in various places (for
>> example some backends seem to use it to write out some language/abi
>> information, or to detect when to use IEEE compliance mode, pch uses it
>> to match whether a header can be reused, the constant folder uses it to
>> make some decisions, etc.
>
> If Richard prefers to use lang_hooks.name, I'd just change all the users
> of lang_hooks.name or TRANSLATION_UNIT_LANGUAGE that need changing.
> For PCH it is ok as is, parsing a header can depend on the language version,
> for the cases that strcmp (lang_hooks.name, "GNU C++") I'd replace it
> with strncmp (lang_hooks.name, "GNU C++", 7), you are not going to change
> the ObjC/ObjC++ stuff, just in dwarf2out.c in addition to handling the new
> names you also need to do something better for the LTO merging of
> TRANSLATION_UNIT_LANGUAGE - say if merging "GNU C", "GNU C99" and "GNU C11",
> pick up the newest out of those, if C++ is mixed into it, pick probably the
> highest C++ version.

Right.

(that lang_hooks.name checks in fold-const.c really really really have to go!)

Btw, I have nothing against changing TRANSLATION_UNIT_LANGUAGE
to DW_LANG_* directly - we only use it for choosing the language
of the dwarf unit.  This would of course mean to change its initialization
from

  TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.name;

to sth like

  TRANSLATION_UNIT_LANGUAGE (tu) = lang_hooks.dw_lang;

which means adding a langhook (thus more similar to your original
patch).

Richard.

>>
>> So shall I change the patch so that the lang hook explicitly encodes the
>> DW_LANG_* constant/language standard variant in use, but keep
>> lang_hooks.name as is to not break any other users?
>
>         Jakub

Reply via email to