aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-11-10 16:39:19 -0500
committerMarek Polacek <polacek@redhat.com>2020-11-11 12:36:52 -0500
commitd6e5745a9a88314e27f387b2277299076862af67 (patch)
tree71ce4bec306b8303730e6a6c4257c3109ed045b2 /gcc/tree.c
parent2e8b368c3d33fd8ddafdd37f8e1b2ba45d1a122e (diff)
downloadgcc-d6e5745a9a88314e27f387b2277299076862af67.zip
gcc-d6e5745a9a88314e27f387b2277299076862af67.tar.gz
gcc-d6e5745a9a88314e27f387b2277299076862af67.tar.bz2
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.
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 1d4a1da..1ad4ad5 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -15041,6 +15041,10 @@ maybe_wrap_with_location (tree expr, location_t loc)
if (EXCEPTIONAL_CLASS_P (expr))
return expr;
+ /* Compiler-generated temporary variables don't need a wrapper. */
+ if (DECL_P (expr) && DECL_ARTIFICIAL (expr) && DECL_IGNORED_P (expr))
+ return expr;
+
/* If any auto_suppress_location_wrappers are active, don't create
wrappers. */
if (suppress_location_wrappers > 0)