diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0b9c1812421..671b36cc193 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-01-22 Ville Voutilainen + + PR c++/59482 + * parser.c (cp_parser_class_head): Push the class before parsing + the base-clause, pop after it. + 2014-01-20 Eric Botcazou * decl2.c (cpp_check): Revert prototype change. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c3016bcda4b..3bc943bd91e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19845,7 +19845,17 @@ cp_parser_class_head (cp_parser* parser, /* Get the list of base-classes, if there is one. */ if (cp_lexer_next_token_is (parser->lexer, CPP_COLON)) - bases = cp_parser_base_clause (parser); + { + /* PR59482: enter the class scope so that base-specifiers are looked + up correctly */ + if (type) + pushclass (type); + bases = cp_parser_base_clause (parser); + /* PR59482: get out of the previously pushed class scope so that the + subsequent pops pop the right thing */ + if (type) + popclass (); + } else bases = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 447d3c7401e..243a7607b7e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-01-22 Ville Voutilainen + + PR c++/59482 + * g++.dg/pr59482.C: New. + 2014-01-22 Bill Schmidt * gcc.dg/vmx/insert-vsx-be-order.c: New. diff --git a/gcc/testsuite/g++.dg/pr59482.C b/gcc/testsuite/g++.dg/pr59482.C new file mode 100644 index 00000000000..bde832909fe --- /dev/null +++ b/gcc/testsuite/g++.dg/pr59482.C @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +class aa { + friend class cc; + class bb {}; +}; + +class cc : aa::bb {};