From 6ea20bd0218fd6386cef3701befa653cee6f1101 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 10 Oct 2019 00:10:17 -0400 Subject: [PATCH] * cp-tree.h (template_info_decl_check): Check ENABLE_TREE_CHECKING. From-SVN: r276787 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/cp-tree.h | 62 ++++++++++++++++++++++++++++++-------------------------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e47e8ca..2a35bf2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-10-09 Jason Merrill + + * cp-tree.h (template_info_decl_check): Check ENABLE_TREE_CHECKING. + 2019-10-09 Marek Polacek PR c++/91364 - P0388R4: Permit conversions to arrays of unknown bound. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index c1301a4..663d84b 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -593,15 +593,46 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM) #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) + +/* Returns t iff the node can have a TEMPLATE_INFO field. */ + +inline tree +template_info_decl_check (const_tree t, const char* f, int l, const char* fn) +{ + switch (TREE_CODE (t)) + { + case VAR_DECL: + case FUNCTION_DECL: + case FIELD_DECL: + case TYPE_DECL: + case CONCEPT_DECL: + case TEMPLATE_DECL: + return const_cast(t); + default: + break; + } + tree_check_failed (t, f, l, fn, + VAR_DECL, FUNCTION_DECL, FIELD_DECL, TYPE_DECL, + CONCEPT_DECL, TEMPLATE_DECL, 0); + gcc_unreachable (); +} + +#define TEMPLATE_INFO_DECL_CHECK(NODE) \ + template_info_decl_check ((NODE), __FILE__, __LINE__, __FUNCTION__) + #define THUNK_FUNCTION_CHECK(NODE) __extension__ \ ({ __typeof (NODE) const __t = (NODE); \ if (TREE_CODE (__t) != FUNCTION_DECL || !__t->decl_common.lang_specific \ || !__t->decl_common.lang_specific->u.fn.thunk_p) \ tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, 0); \ __t; }) -#else + +#else /* ENABLE_TREE_CHECKING */ + +#define TEMPLATE_INFO_DECL_CHECK(NODE) (NODE) #define THUNK_FUNCTION_CHECK(NODE) (NODE) -#endif + +#endif /* ENABLE_TREE_CHECKING */ /* Language-dependent contents of an identifier. */ @@ -3348,33 +3379,6 @@ struct GTY(()) lang_decl { #define TEMPLATE_DECL_COMPLEX_ALIAS_P(NODE) \ DECL_LANG_FLAG_2 (TEMPLATE_DECL_CHECK (NODE)) -/* Returns t iff the node can have a TEMPLATE_INFO field. */ - -inline tree -template_info_decl_check (const_tree t, const char* f, int l, const char* fn) -{ - switch (TREE_CODE (t)) - { - case VAR_DECL: - case FUNCTION_DECL: - case FIELD_DECL: - case TYPE_DECL: - case CONCEPT_DECL: - case TEMPLATE_DECL: - return const_cast(t); - default: - break; - } - tree_check_failed (t, f, l, fn, - VAR_DECL, FUNCTION_DECL, FIELD_DECL, TYPE_DECL, - CONCEPT_DECL, TEMPLATE_DECL, 0); - gcc_unreachable (); -} - - -#define TEMPLATE_INFO_DECL_CHECK(NODE) \ - template_info_decl_check ((NODE), __FILE__, __LINE__, __FUNCTION__) - /* Nonzero for a type which is an alias for another type; i.e, a type which declaration was written 'using name-of-type = another-type'. */ -- 2.7.4