From b262d64c1284f296fe80f6706fb5a5a689ed5e1c Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 24 Feb 1999 19:11:35 -0500 Subject: [PATCH] typeck.c (convert_for_assignment): Allow boolean integral constant expressions to convert to null pointer. * typeck.c (convert_for_assignment): Allow boolean integral constant expressions to convert to null pointer. * decl.c (lookup_namespace_name): Resolve namespace aliases. * class.c (push_nested_class): Allow namespaces. * decl2.c (set_decl_namespace): Add friendp parameter. * decl.c (grokfndecl): Pass it. (grokvardecl): Likewise. * cp-tree.h: Change declaration. From-SVN: r25420 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/class.c | 4 ++-- gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 8 +++++--- gcc/cp/decl2.c | 6 ++++-- gcc/cp/typeck.c | 4 +++- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 348739f079c..7aa0ff95815 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +1999-02-24 Mike Stump + + * typeck.c (convert_for_assignment): Allow boolean integral constant + expressions to convert to null pointer. + +1999-02-24 Martin von Loewis + + * decl.c (lookup_namespace_name): Resolve namespace aliases. + + * class.c (push_nested_class): Allow namespaces. + + * decl2.c (set_decl_namespace): Add friendp parameter. + * decl.c (grokfndecl): Pass it. + (grokvardecl): Likewise. + * cp-tree.h: Change declaration. + 1999-02-24 Jason Merrill * pt.c (tsubst): Allow an array of explicit size zero. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d2eaa9751ea..7e916123c2b 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4897,9 +4897,9 @@ push_nested_class (type, modify) { tree context; - my_friendly_assert (!type || TREE_CODE (type) != NAMESPACE_DECL, 980711); - + /* A namespace might be passed in error cases, like A::B:C. */ if (type == NULL_TREE || type == error_mark_node || ! IS_AGGR_TYPE (type) + || TREE_CODE (type) == NAMESPACE_DECL || TREE_CODE (type) == TEMPLATE_TYPE_PARM || TREE_CODE (type) == TEMPLATE_TEMPLATE_PARM) return; diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 861f3954700..62ffbf0e4bd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -2874,7 +2874,7 @@ extern tree build_expr_from_tree PROTO((tree)); extern tree reparse_decl_as_expr PROTO((tree, tree)); extern tree finish_decl_parsing PROTO((tree)); extern tree check_cp_case_value PROTO((tree)); -extern void set_decl_namespace PROTO((tree, tree)); +extern void set_decl_namespace PROTO((tree, tree, int)); extern tree current_decl_namespace PROTO((void)); extern void push_decl_namespace PROTO((tree)); extern void pop_decl_namespace PROTO((void)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 95bd6f9a90b..4cd37a7a3ff 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5029,6 +5029,8 @@ lookup_namespace_name (namespace, name) return error_mark_node; } + namespace = ORIGINAL_NAMESPACE (namespace); + my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 373); val = binding_init (&_b); @@ -8381,7 +8383,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, /* If this decl has namespace scope, set that up. */ if (in_namespace) - set_decl_namespace (decl, in_namespace); + set_decl_namespace (decl, in_namespace, friendp); else if (publicp && ! ctype) DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); @@ -8666,7 +8668,7 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) decl = build_decl (VAR_DECL, declarator, complete_type (type)); if (context) - set_decl_namespace (decl, context); + set_decl_namespace (decl, context, 0); context = DECL_CONTEXT (decl); if (declarator && context && current_lang_name != lang_name_c) @@ -8674,7 +8676,7 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) } if (in_namespace) - set_decl_namespace (decl, in_namespace); + set_decl_namespace (decl, in_namespace, 0); if (RIDBIT_SETP (RID_EXTERN, specbits)) { diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 61a88eb4a40..cc38dab438f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4186,9 +4186,10 @@ qualified_lookup_using_namespace (name, scope, result, flags) outside scope. */ void -set_decl_namespace (decl, scope) +set_decl_namespace (decl, scope, friendp) tree decl; tree scope; + int friendp; { tree old; if (scope == std_node) @@ -4196,7 +4197,8 @@ set_decl_namespace (decl, scope) /* Get rid of namespace aliases. */ scope = ORIGINAL_NAMESPACE (scope); - if (!is_namespace_ancestor (current_namespace, scope)) + /* It is ok for friends to be qualified in parallel space. */ + if (!friendp && !is_namespace_ancestor (current_namespace, scope)) cp_error ("declaration of `%D' not in a namespace surrounding `%D'", decl, scope); DECL_CONTEXT (decl) = FROB_CONTEXT (scope); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 83d13f195ee..426d02b0903 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6771,7 +6771,9 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) } return cp_convert (type, rhs); } - else if (codel == POINTER_TYPE && coder == INTEGER_TYPE) + else if (codel == POINTER_TYPE + && (coder == INTEGER_TYPE + || coder == BOOLEAN_TYPE)) { /* An explicit constant 0 can convert to a pointer, but not a 0 that results from casting or folding. */ -- 2.30.2