From 448545cb51bdf3d74c3d75f3b88dbf8c7a8de984 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 17 Mar 2009 19:31:18 -0400 Subject: decl.c (grokfndecl): Set DECL_CONTEXT on parms. cp/: * decl.c (grokfndecl): Set DECL_CONTEXT on parms. (duplicate_decls): Adjust DECL_CONTEXT of newdecl's parms. * pt.c (check_explicit_specialization): Likewise. (tsubst_copy) [PARM_DECL]: Return a dummy parm if we don't have a local specialization. * tree.c (cp_tree_equal) [PARM_DECL]: Check type and index, not name. * decl2.c (parm_index): New fn. * semantics.c (finish_decltype_type): Don't use describable_type. * mangle.c (write_expression): Likewise. Mangle ALIGNOF_EXPR. Give a sorry for unsupported codes rather than crash. Mangle conversions with other than 1 operand. New mangling for PARM_DECL. * operators.def (ALIGNOF_EXPR): Mangle as az. * include/demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_FUNCTION_PARAM. * libiberty/cp-demangle.c (d_make_function_param): new fn. (cplus_demangle_mangled_name): Work around abi v2 bug. (d_expr_primary): Likewise. (cplus_demangle_operators): Add alignof ops. (d_expression): Handle function parameters and conversions with other than 1 operand. (d_print_comp): Handle function parameters. Fix bug with function used in type of function. From-SVN: r144924 --- gcc/cp/decl2.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc/cp/decl2.c') diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d570150..deba8b4 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3907,4 +3907,27 @@ mark_used (tree decl) processing_template_decl = saved_processing_template_decl; } +/* Given function PARM_DECL PARM, return its index in the function's list + of parameters, beginning with 1. */ + +int +parm_index (tree parm) +{ + int index; + tree arg; + + for (index = 1, arg = DECL_ARGUMENTS (DECL_CONTEXT (parm)); + arg; + ++index, arg = TREE_CHAIN (arg)) + { + if (DECL_NAME (parm) == DECL_NAME (arg)) + break; + if (DECL_ARTIFICIAL (arg)) + --index; + } + + gcc_assert (arg); + return index; +} + #include "gt-cp-decl2.h" -- cgit v1.1