diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index dcc103b178..877a9636e1 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -5426,7 +5426,16 @@ yyreduce: case 174: #line 1619 "dtool/src/cppparser/cppBison.yxx" /* yacc.c:1646 */ { - push_scope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope)); + // Create a scope for this function (in case it is a function) + CPPScope *scope = new CPPScope((yyvsp[-1].u.inst_ident)->get_scope(current_scope, global_scope), + CPPNameComponent(""), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } #line 5432 "built/tmp/cppBison.yxx.c" /* yacc.c:1646 */ break; diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index f5200316d0..04cdb53a4b 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -1617,7 +1617,16 @@ instance_identifier: } | instance_identifier '(' { - push_scope($1->get_scope(current_scope, global_scope)); + // Create a scope for this function (in case it is a function) + CPPScope *scope = new CPPScope($1->get_scope(current_scope, global_scope), + CPPNameComponent(""), V_private); + + // It still needs to be able to pick up any template arguments, if this is + // a definition for a method template. Add a fake "using" declaration to + // accomplish this. + scope->_using.insert(current_scope); + + push_scope(scope); } formal_parameter_list ')' function_post { diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 602f367722..7ed9a94faf 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -42,15 +42,14 @@ is_fully_specified() const { void CPPClassTemplateParameter:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (complete) { - if (_ident != NULL) { - out << "class "; - _ident->output(out, scope); - } else { - out << "class"; - } + out << "class"; if (_packed) { out << "..."; } + if (_ident != NULL) { + out << " "; + _ident->output(out, scope); + } if (_default_type) { out << " = "; _default_type->output(out, indent_level, scope, false); diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index 75eaa53c6a..dc8c7e0295 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -139,11 +139,12 @@ public: Templates _templates; CPPNameComponent _name; + typedef set Using; + Using _using; + protected: CPPScope *_parent_scope; CPPStructType *_struct_type; - typedef set Using; - Using _using; CPPVisibility _current_vis; private: