diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-05-12 16:52:06 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-05-12 16:52:06 -0400 |
commit | 3e948d645bc9086eee28407fcc67d05b3450bb78 (patch) | |
tree | b455149506a401eb0f8438ebdd7e7c93789fdffb /gcc/cp/cp-tree.h | |
parent | 995060aa5eb85a9a6d06c5cf9e87650522ccee3f (diff) | |
download | gcc-3e948d645bc9086eee28407fcc67d05b3450bb78.zip gcc-3e948d645bc9086eee28407fcc67d05b3450bb78.tar.gz gcc-3e948d645bc9086eee28407fcc67d05b3450bb78.tar.bz2 |
c++: tighten TMPL_ARGS_LEVEL macro
This patch makes TMPL_ARGS_LEVEL verify the level argument is valid when
the one-dimensional vector case. Doing so uncovered a couple of latent
issues: in try_class_unification, we weren't correctly copying targs
when it's two-dimensional, and in unify_pack_expansion it seems an
inequality test needs to be reversed. This patch fixes both issues, and
in passing makes the former function free the temporary copy of targs.
gcc/cp/ChangeLog:
* cp-tree.h (TMPL_ARGS_LEVEL): Assert LEVEL is 1 when
TMPL_ARGS_HAVE_MULTIPLE_LEVELS is false.
* pt.cc (try_class_unification): Correctly copy multidimensional
targs. Free the copy of targs.
(unify_pack_expansion): Fix level comparison.
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r-- | gcc/cp/cp-tree.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b6961a7..b2df6fc 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3783,7 +3783,8 @@ struct GTY(()) lang_decl { args is level 1, not level 0. */ #define TMPL_ARGS_LEVEL(ARGS, LEVEL) \ (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (ARGS) \ - ? TREE_VEC_ELT (ARGS, (LEVEL) - 1) : (ARGS)) + ? TREE_VEC_ELT (ARGS, (LEVEL) - 1) \ + : (gcc_checking_assert ((LEVEL) == 1), (ARGS))) /* Set the LEVELth level of the template ARGS to VAL. This macro does not work with single-level argument vectors. */ |