diff options
author | abutcher <abutcher@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-12 21:04:52 +0000 |
---|---|---|
committer | abutcher <abutcher@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-12 21:04:52 +0000 |
commit | 37afc90b6dcfc939c55fee6c94a0c1ff0a61b445 (patch) | |
tree | 09aeca39dd9caaa23fee35767bb1452967741f26 /gcc/cp/pt.c | |
parent | 11996e1f2aaf22004d73ce8c18e2a3292044687b (diff) | |
download | gcc-37afc90b6dcfc939c55fee6c94a0c1ff0a61b445.tar.gz |
Support using 'auto' in a function parameter list to introduce an implicit template parameter.
* cp-tree.h (type_uses_auto_or_concept): Declare.
(is_auto_or_concept): Declare.
* decl.c (grokdeclarator): Allow 'auto' parameters in lambdas with
-std=gnu++1y or -std=c++1y or, as a GNU extension, in plain functions.
* type-utils.h: New header defining ...
(find_type_usage): ... this new function based on pt.c (type_uses_auto)
for searching a type tree given a predicate.
* pt.c (type_uses_auto): Reimplement via type-utils.h (find_type_usage).
(is_auto_or_concept): New function.
(type_uses_auto_or_concept): New function.
* parser.h (struct cp_parser): Add fully_implicit_function_template_p.
* parser.c (cp_parser_new): Initialize fully_implicit_function_template_p.
(cp_parser_new): Initialize fully_implicit_function_template_p.
(cp_parser_lambda_expression): Copy and restore value of
fully_implicit_function_template_p as per other parser fields.
(cp_parser_parameter_declaration_list): Count generic
parameters and call ...
(add_implicit_template_parms): ... this new function to synthesize them
with help from type-utils.h (find_type_usage), ...
(tree_type_is_auto_or_concept): ... this new static function and ...
(make_generic_type_name): ... this new static function.
(cp_parser_direct_declarator): Account for implicit template parameters.
(cp_parser_lambda_declarator_opt): Finish fully implicit template if
necessary by calling ...
(finish_fully_implicit_template): ... this new function.
(cp_parser_member_declaration): Likewise.
(cp_parser_function_definition_after_declarator): Likewise.
* Make-lang.in (cp/pt.o): Add dependency on type-utils.h.
(cp/parser.o): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202540 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 93e6258bd63..de1022efec2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "toplev.h" #include "timevar.h" #include "tree-iterator.h" +#include "type-utils.h" /* The type of functions taking a tree, and some additional data, and returning an int. */ @@ -21110,31 +21111,35 @@ is_auto (const_tree type) return false; } -/* Returns true iff TYPE contains a use of 'auto'. Since auto can only - appear as a type-specifier for the declaration in question, we don't - have to look through the whole type. */ +/* Returns the TEMPLATE_TYPE_PARM in TYPE representing `auto' iff TYPE contains + a use of `auto'. Returns NULL_TREE otherwise. */ tree type_uses_auto (tree type) { - enum tree_code code; - if (is_auto (type)) - return type; + return find_type_usage (type, is_auto); +} - code = TREE_CODE (type); +/* Returns true iff TYPE is a TEMPLATE_TYPE_PARM representing 'auto', + 'decltype(auto)' or a concept. */ - if (code == POINTER_TYPE || code == REFERENCE_TYPE - || code == OFFSET_TYPE || code == FUNCTION_TYPE - || code == METHOD_TYPE || code == ARRAY_TYPE) - return type_uses_auto (TREE_TYPE (type)); +bool +is_auto_or_concept (const_tree type) +{ + return is_auto (type); // or concept +} - if (TYPE_PTRMEMFUNC_P (type)) - return type_uses_auto (TREE_TYPE (TREE_TYPE - (TYPE_PTRMEMFUNC_FN_TYPE (type)))); +/* Returns the TEMPLATE_TYPE_PARM in TYPE representing a generic type (`auto' or + a concept identifier) iff TYPE contains a use of a generic type. Returns + NULL_TREE otherwise. */ - return NULL_TREE; +tree +type_uses_auto_or_concept (tree type) +{ + return find_type_usage (type, is_auto_or_concept); } + /* For a given template T, return the vector of typedefs referenced in T for which access check is needed at T instantiation time. T is either a FUNCTION_DECL or a RECORD_TYPE. |