aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1999-02-24 19:11:35 -0500
committerJason Merrill <jason@gcc.gnu.org>1999-02-24 19:11:35 -0500
commitb262d64c1284f296fe80f6706fb5a5a689ed5e1c (patch)
tree2e55f1d1d0b102bcae197fd603f70ef89b5a72c8
parent1b14496f064242b4217bd1c6f8caf900d5794854 (diff)
downloadgcc-b262d64c1284f296fe80f6706fb5a5a689ed5e1c.zip
gcc-b262d64c1284f296fe80f6706fb5a5a689ed5e1c.tar.gz
gcc-b262d64c1284f296fe80f6706fb5a5a689ed5e1c.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog16
-rw-r--r--gcc/cp/class.c4
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/decl2.c6
-rw-r--r--gcc/cp/typeck.c4
6 files changed, 31 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 348739f..7aa0ff9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,19 @@
+1999-02-24 Mike Stump <mrs@wrs.com>
+
+ * typeck.c (convert_for_assignment): Allow boolean integral constant
+ expressions to convert to null pointer.
+
+1999-02-24 Martin von Loewis <loewis@informatik.hu-berlin.de>
+
+ * 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 <jason@yorick.cygnus.com>
* pt.c (tsubst): Allow an array of explicit size zero.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d2eaa97..7e91612 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 861f395..62ffbf0 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 95bd6f9..4cd37a7 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 61a88eb..cc38dab 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 83d13f1..426d02b 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. */