Consolidate CU language setting
The DWARF reader currently sets the CU's language in two different
spots. It is primarily done in prepare_one_comp_unit, but
read_file_scope also checks the producer and may change the language
based on the result.
This patch consolidates all language-setting into
prepare_one_comp_unit. set_cu_language is renamed and changed not to
set language_defn; instead that is done in prepare_one_comp_unit after
the correct language enum value is chosen.
This fixes a minor latent bug, which is that read_file_scope could set
the language enum value to language_opencl, but then neglected to
reset language_defn in this case.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_file_scope): Don't call set_cu_language.
(dwarf_lang_to_enum_language): Rename from set_cu_language. Don't
set language_defn. Handle DW_LANG_OpenCL.
(prepare_one_comp_unit): Check producer and set language_defn.