Hi Jason, > In this testcase we weren't catching the error in A::f because the parameter > 'I' wasn't in scope, so the default argument for 'b' found the global > typedef I. Fixed by pushing the parms before parsing. This is a bit > complicated because pushdecl clears DECL_CHAIN; do_push_parm_decls deals > with this by nreversing first, but that doesn't work here because we only > want to push them one at a time; if we pushed all of them before parsing, > we'd wrongly reject A::g. > > Tested x86_64-pc-linux-gnu, applying to trunk. > > gcc/cp/ChangeLog: > > * parser.c (cp_parser_primary_expression): Distinguish > parms from vars in error. > (cp_parser_late_parsing_default_args): Pushdecl parms > as we go.
this patch broke i386-pc-solaris2.11 and sparc-sun-solaris2.11 bootstrap with gcc 8.1.0 in stage 1: /vol/gcc/src/hg/master/local/gcc/cp/parser.c: In function 'void cp_parser_late_parsing_default_args(cp_parser*, tree)': /vol/gcc/src/hg/master/local/gcc/cp/parser.c:30618:28: error: ambiguous overload for 'operator[]' (operand types are 'releasing_vec' and 'int') tree parmdecl = parms[i]; ^ /vol/gcc/src/hg/master/local/gcc/cp/parser.c:30618:28: note: candidate: 'operator[](releasing_vec::vec_t* {aka vec<tree_node*, va_gc>*}, int)' <built-in> In file included from /vol/gcc/src/hg/master/local/gcc/cp/parser.c:25: /vol/gcc/src/hg/master/local/gcc/cp/cp-tree.h:965:9: note: candidate: 'tree_node*& releasing_vec::operator[](unsigned int) const' tree& operator[] (unsigned i) const { return (*v)[i]; } ^~~~~~~~ In file included from /vol/gcc/src/hg/master/local/gcc/c-family/c-common.h:26, from /vol/gcc/src/hg/master/local/gcc/cp/cp-tree.h:40, from /vol/gcc/src/hg/master/local/gcc/cp/parser.c:25: /vol/gcc/src/hg/master/local/gcc/cp/parser.c:30647:24: error: ambiguous overload for 'operator[]' (operand types are 'releasing_vec' and 'int') DECL_CHAIN (parms[i]) = parm; ^ /vol/gcc/src/hg/master/local/gcc/tree.h:286:26: note: in definition of macro 'CONTAINS_STRUCT_CHECK' (contains_struct_check ((T), (STRUCT), __FILE__, __LINE__, __FUNCTION__)) ^ /vol/gcc/src/hg/master/local/gcc/tree.h:2424:27: note: in expansion of macro 'TREE_CHAIN' #define DECL_CHAIN(NODE) (TREE_CHAIN (DECL_MINIMAL_CHECK (NODE))) [...] Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University