aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-02-04 18:35:18 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-02-04 18:35:18 +0000
commit9baa27a975e184773ffb8ec4297db8ce34291246 (patch)
tree4cb6604e4f32e48c7a452d221aa65ba75a1c7912 /gcc/cp/parser.c
parent772fec9a0e7d39b1713715db88977ca07b4333b4 (diff)
downloadgcc-9baa27a975e184773ffb8ec4297db8ce34291246.zip
gcc-9baa27a975e184773ffb8ec4297db8ce34291246.tar.gz
gcc-9baa27a975e184773ffb8ec4297db8ce34291246.tar.bz2
re PR c++/13969 (static const value rejected as template parameter)
PR c++/13969 * g++.dg/template/static6.C: New test. PR c++/13969 * cp-tree.h (fold_non_dependent_expr): New function. * parser.c (cp_parser_fold_non_dependent_expr): Remove. (cp_parser_template_argument): Use fold_non_dependent_expr. (cp_parser_direct_declarator): Likewise. * pt.c (fold_non_dependent_expr): New function. (convert_nontype_argument): Use it. (tsubst_qualified_id): Simplify. (tsubst_copy_and_build): Likewise. From-SVN: r77260
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4905b94..4ee1aa6 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1669,8 +1669,6 @@ static tree cp_parser_sizeof_operand
(cp_parser *, enum rid);
static bool cp_parser_declares_only_class_p
(cp_parser *);
-static tree cp_parser_fold_non_dependent_expr
- (tree);
static bool cp_parser_friend_p
(tree);
static cp_token *cp_parser_require
@@ -8411,7 +8409,7 @@ cp_parser_template_argument (cp_parser* parser)
argument = cp_parser_constant_expression (parser,
/*allow_non_constant_p=*/false,
/*non_constant_p=*/NULL);
- argument = cp_parser_fold_non_dependent_expr (argument);
+ argument = fold_non_dependent_expr (argument);
if (!maybe_type_id)
return argument;
if (!cp_parser_next_token_ends_template_argument_p (parser))
@@ -10417,7 +10415,7 @@ cp_parser_direct_declarator (cp_parser* parser,
/*allow_non_constant=*/true,
&non_constant_p);
if (!non_constant_p)
- bounds = cp_parser_fold_non_dependent_expr (bounds);
+ bounds = fold_non_dependent_expr (bounds);
}
else
bounds = NULL_TREE;
@@ -14734,37 +14732,6 @@ cp_parser_declares_only_class_p (cp_parser *parser)
|| cp_lexer_next_token_is (parser->lexer, CPP_COMMA));
}
-/* Simplify EXPR if it is a non-dependent expression. Returns the
- (possibly simplified) expression. */
-
-static tree
-cp_parser_fold_non_dependent_expr (tree expr)
-{
- /* If we're in a template, but EXPR isn't value dependent, simplify
- it. We're supposed to treat:
-
- template <typename T> void f(T[1 + 1]);
- template <typename T> void f(T[2]);
-
- as two declarations of the same function, for example. */
- if (processing_template_decl
- && !type_dependent_expression_p (expr)
- && !value_dependent_expression_p (expr))
- {
- HOST_WIDE_INT saved_processing_template_decl;
-
- saved_processing_template_decl = processing_template_decl;
- processing_template_decl = 0;
- expr = tsubst_copy_and_build (expr,
- /*args=*/NULL_TREE,
- tf_error,
- /*in_decl=*/NULL_TREE,
- /*function_p=*/false);
- processing_template_decl = saved_processing_template_decl;
- }
- return expr;
-}
-
/* DECL_SPECIFIERS is the representation of a decl-specifier-seq.
Returns TRUE iff `friend' appears among the DECL_SPECIFIERS. */