c++: Member initializer list diagnostic locations [PR94024]
authorPatrick Palka <ppalka@redhat.com>
Tue, 4 Aug 2020 14:11:35 +0000 (10:11 -0400)
committerPatrick Palka <ppalka@redhat.com>
Tue, 4 Aug 2020 14:11:35 +0000 (10:11 -0400)
commit843710c037c1396dcdbc23e5b6b456b8ae6e2b8b
tree75dae029db26c025f3c25904c70b1cec9057bd9e
parent1af5cdd77985daf76130f527deac425c43df9f49
c++: Member initializer list diagnostic locations [PR94024]

This patch preserves the source locations of each node in a member
initializer list so that during processing of the list we can set
input_location appropriately for generally more accurate diagnostic
locations.  Since TREE_LIST nodes are tcc_exceptional, they can't have
source locations, so we instead store the location in a dummy
tcc_expression node within the TREE_TYPE of the list node.

gcc/cp/ChangeLog:

PR c++/94024
* init.c (sort_mem_initializers): Preserve TREE_TYPE of the
member initializer list node.
(emit_mem_initializers): Set input_location when performing each
member initialization.
* parser.c (cp_parser_mem_initializer): Attach the source
location of this initializer to a dummy EMPTY_CLASS_EXPR
within the TREE_TYPE of the list node.
* pt.c (tsubst_initializer_list): Preserve TREE_TYPE of the
member initializer list node.

gcc/testsuite/ChangeLog:

PR c++/94024
* g++.dg/diagnostic/mem-init1.C: New test.
gcc/cp/init.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/g++.dg/diagnostic/mem-init1.C [new file with mode: 0644]