aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/cp-tree.h
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-09-27 14:19:55 -0400
committerJason Merrill <jason@gcc.gnu.org>2019-09-27 14:19:55 -0400
commitc872f1506d46ceba10776d0ebc86b4126273a419 (patch)
tree2a0a2e3ea4616da4030026f5092c505936d412e3 /gcc/cp/cp-tree.h
parent975d043ff6b6f8a9e9ff0be799701fc1d842bb83 (diff)
downloadgcc-c872f1506d46ceba10776d0ebc86b4126273a419.zip
gcc-c872f1506d46ceba10776d0ebc86b4126273a419.tar.gz
gcc-c872f1506d46ceba10776d0ebc86b4126273a419.tar.bz2
cp-tree.h (class iloc_sentinel): New.
* cp-tree.h (class iloc_sentinel): New. We didn't already have a sentinel for input_location, and while temp_override would work, it would also happily set input_location to 0, which breaks things that try to look up the associated filename. * decl.c (grokdeclarator, finish_enum_value_list): Use it. * mangle.c (mangle_decl_string): Use it. * pt.c (perform_typedefs_access_check): Use it. From-SVN: r276191
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r--gcc/cp/cp-tree.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 8fc3fc1..be1a44e 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1762,6 +1762,24 @@ public:
~warning_sentinel() { flag = val; }
};
+/* RAII sentinel to temporarily override input_location. This will not set
+ input_location to UNKNOWN_LOCATION or BUILTINS_LOCATION. */
+
+class iloc_sentinel
+{
+ location_t saved_loc;
+public:
+ iloc_sentinel (location_t loc): saved_loc (input_location)
+ {
+ if (loc >= RESERVED_LOCATION_COUNT)
+ input_location = loc;
+ }
+ ~iloc_sentinel ()
+ {
+ input_location = saved_loc;
+ }
+};
+
/* RAII sentinel that saves the value of a variable, optionally
overrides it right away, and restores its value when the sentinel
id destructed. */