From a5b3de4a896d8c05deaa72d1331ffc2796c39d34 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 7 Dec 2016 12:52:39 +0000 Subject: [PATCH] * cp-tree.h (enum cp_tree_index): Add CPTI_AUTO_IDENTIFIER & CPTI_DECLTYPE_AUTO_IDENTIFIER. (auto_identifier, decltype_auto_identifier): New. *decl.c (initialize_predefined_identifiers): Add 'auto' and 'decltype(auto)'. (grokdeclarator): Use cached identifier. * pt.c (make_decltype_auto, make_auto, make_constrained_auto, is_auto): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@243342 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 11 +++++++++++ gcc/cp/cp-tree.h | 5 +++++ gcc/cp/decl.c | 4 +++- gcc/cp/pt.c | 10 +++++----- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f16813d1be0..3964cfd5aa9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2016-12-07 Nathan Sidwell + + * cp-tree.h (enum cp_tree_index): Add CPTI_AUTO_IDENTIFIER & + CPTI_DECLTYPE_AUTO_IDENTIFIER. + (auto_identifier, decltype_auto_identifier): New. + *decl.c (initialize_predefined_identifiers): Add 'auto' and + 'decltype(auto)'. + (grokdeclarator): Use cached identifier. + * pt.c (make_decltype_auto, make_auto, make_constrained_auto, + is_auto): Likewise. + 2016-12-02 Jakub Jelinek PR c++/78649 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5674886b26f..f7da76a8e81 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1117,6 +1117,8 @@ enum cp_tree_index CPTI_PFN_IDENTIFIER, CPTI_VPTR_IDENTIFIER, CPTI_STD_IDENTIFIER, + CPTI_AUTO_IDENTIFIER, + CPTI_DECLTYPE_AUTO_IDENTIFIER, CPTI_LANG_NAME_C, CPTI_LANG_NAME_CPLUSPLUS, @@ -1200,6 +1202,9 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; #define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER] /* The name of the std namespace. */ #define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER] +/* auto and declspec(auto) identifiers. */ +#define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER] +#define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER] /* The name of a C++17 deduction guide. */ #define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] #define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f0850d726ed..d7dbf94c076 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4034,6 +4034,8 @@ initialize_predefined_identifiers (void) { "__vtt_parm", &vtt_parm_identifier, 0 }, { "::", &global_scope_name, 0 }, { "std", &std_identifier, 0 }, + { "auto", &auto_identifier, 0 }, + { "decltype(auto)", &decltype_auto_identifier, 0 }, { NULL, NULL, 0 } }; @@ -10600,7 +10602,7 @@ grokdeclarator (const cp_declarator *declarator, gcc_unreachable (); } if (TREE_CODE (type) != TEMPLATE_TYPE_PARM - || TYPE_IDENTIFIER (type) != get_identifier ("auto")) + || TYPE_IDENTIFIER (type) != auto_identifier) { if (type != error_mark_node) { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b51e5801109..3b80ca402e7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -24302,13 +24302,13 @@ make_auto_1 (tree name, bool set_canonical) tree make_decltype_auto (void) { - return make_auto_1 (get_identifier ("decltype(auto)"), true); + return make_auto_1 (decltype_auto_identifier, true); } tree make_auto (void) { - return make_auto_1 (get_identifier ("auto"), true); + return make_auto_1 (auto_identifier, true); } /* Return a C++17 deduction placeholder for class template TMPL. */ @@ -24330,7 +24330,7 @@ make_template_placeholder (tree tmpl) tree make_constrained_auto (tree con, tree args) { - tree type = make_auto_1 (get_identifier ("auto"), false); + tree type = make_auto_1 (auto_identifier, false); /* Build the constraint. */ tree tmpl = DECL_TI_TEMPLATE (con); @@ -25016,8 +25016,8 @@ bool is_auto (const_tree type) { if (TREE_CODE (type) == TEMPLATE_TYPE_PARM - && (TYPE_IDENTIFIER (type) == get_identifier ("auto") - || TYPE_IDENTIFIER (type) == get_identifier ("decltype(auto)") + && (TYPE_IDENTIFIER (type) == auto_identifier + || TYPE_IDENTIFIER (type) == decltype_auto_identifier || CLASS_PLACEHOLDER_TEMPLATE (type))) return true; else -- 2.11.4.GIT