From 80b1331c3edd4d2b88c59165061e404e04f854a9 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 23 Jun 2002 20:10:09 +0000 Subject: [PATCH] parse.y (parse_scoped_id): New function. * parse.y (parse_scoped_id): New function. (primary): Use it. * cp-tree.h (do_scoped_id): Adjust declaration. * lex.c (do_scoped_id): Remove call to yylex. * decl2.c (build_expr_from_tree): Adjust use of do_scoped_id. * typeck2.c (add_exception_specifier): Use tree_cons, rather than expanding it inline. From-SVN: r54930 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/cp-tree.h | 2 +- gcc/cp/decl2.c | 5 ++++- gcc/cp/lex.c | 18 ++---------------- gcc/cp/parse.y | 24 ++++++++++++++++++++++-- gcc/cp/typeck2.c | 6 +----- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7df80c8f6b1..6cbaf2a376f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2002-06-23 Mark Mitchell + + * parse.y (parse_scoped_id): New function. + (primary): Use it. + * cp-tree.h (do_scoped_id): Adjust declaration. + * lex.c (do_scoped_id): Remove call to yylex. + * decl2.c (build_expr_from_tree): Adjust use of do_scoped_id. + * typeck2.c (add_exception_specifier): Use tree_cons, rather than + expanding it inline. + 2002-06-23 Matt Thomas * decl.c (finish_function): Change "#ifdef VMS_TARGET" to diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 04f0e1bb5e1..6b39adade38 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4044,7 +4044,7 @@ extern void note_list_got_semicolon PARAMS ((tree)); extern void do_pending_lang_change PARAMS ((void)); extern void see_typename PARAMS ((void)); extern tree do_identifier PARAMS ((tree, int, tree)); -extern tree do_scoped_id PARAMS ((tree, int)); +extern tree do_scoped_id PARAMS ((tree, tree)); extern tree identifier_typedecl_value PARAMS ((tree)); extern tree build_lang_decl PARAMS ((enum tree_code, tree, tree)); extern void retrofit_lang_decl PARAMS ((tree)); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 1188bb2acc8..72930c233b7 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3652,7 +3652,10 @@ build_expr_from_tree (t) case LOOKUP_EXPR: if (LOOKUP_EXPR_GLOBAL (t)) - return do_scoped_id (TREE_OPERAND (t, 0), 0); + { + tree token = TREE_OPERAND (t, 0); + return do_scoped_id (token, IDENTIFIER_GLOBAL_VALUE (token)); + } else return do_identifier (TREE_OPERAND (t, 0), 0, NULL_TREE); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index ae2cd326ac8..a5e0b106827 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -1281,24 +1281,10 @@ do_identifier (token, parsing, args) } tree -do_scoped_id (token, parsing) +do_scoped_id (token, id) tree token; - int parsing; + tree id; { - tree id; - /* during parsing, this is ::name. Otherwise, it is black magic. */ - if (parsing) - { - id = make_node (CPLUS_BINDING); - if (!qualified_lookup_using_namespace (token, global_namespace, id, 0)) - id = NULL_TREE; - else - id = BINDING_VALUE (id); - } - else - id = IDENTIFIER_GLOBAL_VALUE (token); - if (parsing && yychar == YYEMPTY) - yychar = yylex (); if (!id || (TREE_CODE (id) == FUNCTION_DECL && DECL_ANTICIPATED (id))) { diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 4847b3f7a22..31a9ee007cb 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -130,6 +130,7 @@ static tree parse_bitfield PARAMS ((tree, tree, tree)); static tree parse_method PARAMS ((tree, tree, tree)); static void frob_specs PARAMS ((tree, tree)); static void check_class_key PARAMS ((tree, tree)); +static tree parse_scoped_id PARAMS ((tree)); /* Cons up an empty parameter list. */ static inline tree @@ -1706,14 +1707,14 @@ primary: check_for_new_type ("typeid", $3); $$ = get_typeid (type); } | global_scope IDENTIFIER - { $$ = do_scoped_id ($2, 1); } + { $$ = parse_scoped_id ($2); } | global_scope template_id { $$ = $2; } | global_scope operator_name { got_scope = NULL_TREE; if (TREE_CODE ($2) == IDENTIFIER_NODE) - $$ = do_scoped_id ($2, 1); + $$ = parse_scoped_id ($2); else $$ = $2; } @@ -4022,4 +4023,23 @@ free_parser_stacks () } } +/* Return the value corresponding to TOKEN in the global scope. */ + +static tree +parse_scoped_id (token) + tree token; +{ + tree id; + + id = make_node (CPLUS_BINDING); + if (!qualified_lookup_using_namespace (token, global_namespace, id, 0)) + id = NULL_TREE; + else + id = BINDING_VALUE (id); + if (yychar == YYEMPTY) + yychar = yylex(); + + return do_scoped_id (token, id); +} + #include "gt-cp-parse.h" diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index e034d50c096..2cb4cc3b01e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1372,11 +1372,7 @@ add_exception_specifier (list, spec, complain) if (same_type_p (TREE_VALUE (probe), spec)) break; if (!probe) - { - spec = build_tree_list (NULL_TREE, spec); - TREE_CHAIN (spec) = list; - list = spec; - } + list = tree_cons (NULL_TREE, spec, list); } else if (complain) cxx_incomplete_type_error (NULL_TREE, core);