Commit 84a900c9 by Andrew Pinski Committed by Andrew Pinski

re PR c++/22154 ([DR 382] qualified names should allow typename keyword in front…

re PR c++/22154 ([DR 382] qualified names should allow typename keyword in front of it (even in non-templates))

2009-07-13  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/22154
        * parser.c (cp_parser_elaborated_type_specifier): Accept typename in
        front of qualified names.

2009-07-13  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/22154
        * g++.old-deja/g++.pt/typename10.C: Update for DR 382, typename in
        front of qualified names are allowed.
        * g++.dg/parse/crash10.C: Likewise.
        * g++.dg/parse/error15.C: Likewise.
        * g++.dg/parse/typename9.C: Likewise.
        * g++.dg/parse/error8.C: Likewise.

From-SVN: r149590
parent acbdc378
2009-07-13 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/22154
* parser.c (cp_parser_elaborated_type_specifier): Accept typename in
front of qualified names.
2009-07-12 Jason Merrill <jason@redhat.com> 2009-07-12 Jason Merrill <jason@redhat.com>
PR c++/36628 PR c++/36628
......
...@@ -11591,6 +11591,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -11591,6 +11591,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
tree identifier; tree identifier;
tree type = NULL_TREE; tree type = NULL_TREE;
tree attributes = NULL_TREE; tree attributes = NULL_TREE;
tree globalscope;
cp_token *token = NULL; cp_token *token = NULL;
/* See if we're looking at the `enum' keyword. */ /* See if we're looking at the `enum' keyword. */
...@@ -11622,9 +11623,6 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -11622,9 +11623,6 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer);
/* Remember that it's a `typename' type. */ /* Remember that it's a `typename' type. */
tag_type = typename_type; tag_type = typename_type;
/* The `typename' keyword is only allowed in templates. */
if (!processing_template_decl)
permerror (input_location, "using %<typename%> outside of template");
} }
/* Otherwise it must be a class-key. */ /* Otherwise it must be a class-key. */
else else
...@@ -11637,10 +11635,10 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, ...@@ -11637,10 +11635,10 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
} }
/* Look for the `::' operator. */ /* Look for the `::' operator. */
cp_parser_global_scope_opt (parser, globalscope = cp_parser_global_scope_opt (parser,
/*current_scope_valid_p=*/false); /*current_scope_valid_p=*/false);
/* Look for the nested-name-specifier. */ /* Look for the nested-name-specifier. */
if (tag_type == typename_type) if (tag_type == typename_type && !globalscope)
{ {
if (!cp_parser_nested_name_specifier (parser, if (!cp_parser_nested_name_specifier (parser,
/*typename_keyword_p=*/true, /*typename_keyword_p=*/true,
......
2009-07-13 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR C++/22154
* g++.old-deja/g++.pt/typename10.C: Update for DR 382, typename in
front of qualified names are allowed.
* g++.dg/parse/crash10.C: Likewise.
* g++.dg/parse/error15.C: Likewise.
* g++.dg/parse/typename9.C: Likewise.
* g++.dg/parse/error8.C: Likewise.
2009-07-13 Janus Weil <janus@gcc.gnu.org> 2009-07-13 Janus Weil <janus@gcc.gnu.org>
PR fortran/40646 PR fortran/40646
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
class class
{ {
typename:: // { dg-error "" "" } typename::
; // { dg-error "" "" } ; // { dg-error "" "" }
...@@ -14,7 +14,7 @@ N::A f2; // { dg-error "1:invalid use of template-name 'N::A' witho ...@@ -14,7 +14,7 @@ N::A f2; // { dg-error "1:invalid use of template-name 'N::A' witho
N::INVALID f3; // { dg-error "1:'INVALID' in namespace 'N' does not name a type" } N::INVALID f3; // { dg-error "1:'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "1:'INVALID' in class 'N::C' does not name a type" } N::C::INVALID f4; // { dg-error "1:'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "1:'K' in namespace 'N' does not name a type" } N::K f6; // { dg-error "1:'K' in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "1:using 'typename' outside of template" "1" } typename N::A f7;
// { dg-error "13:invalid use of template-name 'N::A' without an argument list" "13" { target *-*-* } 17 } // { dg-error "13:invalid use of template-name 'N::A' without an argument list" "13" { target *-*-* } 17 }
// { dg-error "17:invalid type in declaration before ';' token" "17" { target *-*-* } 17 } // { dg-error "17:invalid type in declaration before ';' token" "17" { target *-*-* } 17 }
...@@ -24,7 +24,7 @@ struct B ...@@ -24,7 +24,7 @@ struct B
N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" } N::INVALID f3; // { dg-error "3:'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" } N::C::INVALID f4; // { dg-error "3:'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" } N::K f6; // { dg-error "3:'K' in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "3:using 'typename' outside of template" } typename N::A f7;
// { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 27 } // { dg-error "15:invalid use of template-name 'N::A' without an argument list" "15" { target *-*-* } 27 }
}; };
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
struct A { friend typename struct B; }; struct A { friend typename struct B; };
// { dg-error "19:using 'typename' outside of template" "" { target *-*-* } 4 }
// { dg-error "28:expected nested-name-specifier before 'struct'" "" { target *-*-* } 4 } // { dg-error "28:expected nested-name-specifier before 'struct'" "" { target *-*-* } 4 }
// { dg-error "35:multiple types in one declaration" "" { target *-*-* } 4 } // { dg-error "35:multiple types in one declaration" "" { target *-*-* } 4 }
// { dg-error "12:friend declaration does not name a class or function" "" { target *-*-* } 4 } // { dg-error "12:friend declaration does not name a class or function" "" { target *-*-* } 4 }
// check that using a qualified name with a typename does
// not report an error.
struct A { typedef int X; }; struct A { typedef int X; };
int i = typename A::X(); // { dg-error "typename" } int i = typename A::X();
...@@ -4,4 +4,4 @@ struct S { ...@@ -4,4 +4,4 @@ struct S {
typedef int I; typedef int I;
}; };
void f(typename S::I); // { dg-error "" } using typename outside of template void f(typename S::I);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment