https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97518
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:d6e5745a9a88314e27f387b2277299076862af67 commit r11-4924-gd6e5745a9a88314e27f387b2277299076862af67 Author: Marek Polacek <pola...@redhat.com> Date: Tue Nov 10 16:39:19 2020 -0500 c++: Tweak tsubst_qualified_id location. Retain the location when tsubstituting a qualified-id so that our static_assert diagnostic can benefit. Don't create useless location wrappers for temporary variables. gcc/ChangeLog: PR c++/97518 * tree.c (maybe_wrap_with_location): Don't add a location wrapper around an artificial and ignored decl. gcc/cp/ChangeLog: PR c++/97518 * pt.c (tsubst_qualified_id): Use EXPR_LOCATION of the qualified-id. Use it to maybe_wrap_with_location the final expression. gcc/testsuite/ChangeLog: PR c++/97518 * g++.dg/diagnostic/static_assert3.C: New test.