gcc/libstdc++-v3
Jakub Jelinek 2132a36370 c++: Fix source_location inconsistency between calls from templates and non-templates [PR99672]
The srcloc19.C testcase shows inconsistency in
std::source_location::current() locations between calls from
templates and non-templates.  The location used by __builtin_source_location
comes in both cases from input_location which is set on it by bot_manip
when handling the default argument, called during finish_call_expr.
The problem is that in templates that input_location comes from the
CALL_EXPR we built earlier and that has the combined locus with
range between first character of the function name and closing paren
with caret on the opening paren, so something printed as caret as:
foobar ();
~~~~~~^~
But outside of templates, finish_call_expr is called when input_location
is just the closing paren token, i.e.
foobar ();
        ^
and only after that returns we create the combined location and set
the CALL_EXPR location to that.  So, it means std::source_location::current()
reports in templates the column of opening (, while outside of templates
closing ).

The following patch makes it consistent by creating the combined location
already before calling finish_call_expr and temporarily overriding
input_location to that.

2021-03-25  Jakub Jelinek  <jakub@redhat.com>

	PR c++/99672
	* parser.c (cp_parser_postfix_expression): For calls, create
	combined_loc and temporarily set input_location to it before
	calling finish_call_expr.

	* g++.dg/concepts/diagnostic2.C: Adjust expected caret line.
	* g++.dg/cpp1y/builtin_location.C (f4, n6): Move #line directives
	to match locus changes.
	* g++.dg/cpp2a/srcloc1.C: Adjust expected column numbers.
	* g++.dg/cpp2a/srcloc2.C: Likewise.
	* g++.dg/cpp2a/srcloc15.C: Likewise.
	* g++.dg/cpp2a/srcloc16.C: Likewise.
	* g++.dg/cpp2a/srcloc19.C: New test.
	* g++.dg/modules/adhoc-1_b.C: Adjust expected column numbers
	and caret line.
	* g++.dg/modules/macloc-1_c.C: Adjust expected column numbers.
	* g++.dg/modules/macloc-1_d.C: Likewise.
	* g++.dg/plugin/diagnostic-test-expressions-1.C: Adjust expected
	caret line.

	* testsuite/18_support/source_location/consteval.cc (main): Adjust
	expected column numbers.
	* testsuite/18_support/source_location/1.cc (main): Likewise.
2021-03-25 21:35:11 +01:00
..
config libstdc++: Remove symbols for new std::call_once implementation [PR 99341] 2021-03-16 12:25:28 +00:00
doc libstdc++: Document library versioning for GCC 11 2021-02-25 15:35:59 +00:00
include libstdc++: Avoid accidental ADL when calling make_reverse_iterator 2021-03-23 16:34:42 +00:00
libsupc++ libstdc++: Declare malloc for freestanding 2021-03-25 18:25:40 +00:00
po Update copyright years. 2021-01-04 10:26:59 +01:00
python libstdc++: Fix find_type helper to work consistently 2021-03-11 17:52:56 +00:00
scripts libstdc++: Add simd testsuite 2021-01-27 16:37:26 +00:00
src libstdc++: Remove symbols for new std::call_once implementation [PR 99341] 2021-03-16 12:25:28 +00:00
testsuite c++: Fix source_location inconsistency between calls from templates and non-templates [PR99672] 2021-03-25 21:35:11 +01:00
acinclude.m4
aclocal.m4
ChangeLog Daily bump. 2021-03-24 00:16:25 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
ChangeLog-2020 libstdc++: Fix typo in ChangeLog-2020 2021-01-13 11:02:13 +00:00
config.h.in
configure Update GNU/Hurd configure support 2021-01-05 16:04:14 -07:00
configure.ac
configure.host
crossconfig.m4
fragment.am
linkage.m4
Makefile.am Update copyright years. 2021-01-04 10:26:59 +01:00
Makefile.in
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.