aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2000-09-12 21:02:52 -0400
committerJason Merrill <jason@gcc.gnu.org>2000-09-12 21:02:52 -0400
commitf2ae0c45c0bf4868cd3207eaad54eedff4488edf (patch)
tree1e7159a57b47665ba88d5de38a5e4b6a58dbcfab /gcc
parent634dd0ca7756a22847e2327b6270792cbd042495 (diff)
downloadgcc-f2ae0c45c0bf4868cd3207eaad54eedff4488edf.zip
gcc-f2ae0c45c0bf4868cd3207eaad54eedff4488edf.tar.gz
gcc-f2ae0c45c0bf4868cd3207eaad54eedff4488edf.tar.bz2
decl.c (maybe_deduce_size_from_array_init): Set do_default for all non-extern arrays.
* decl.c (maybe_deduce_size_from_array_init): Set do_default for all non-extern arrays. * decl.c (grokdeclarator): Complain about 'friend T' for implicit typenames, too. Downgrade complaint to pedwarn. (xref_tag): Warn about surprising behavior of 'friend struct T'. * decl2.c (handle_class_head): Generate a TYPENAME_TYPE for 'class This::Inherited'. From-SVN: r36382
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/decl.c42
-rw-r--r--gcc/cp/decl2.c19
3 files changed, 59 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e5db96e..ddf6086 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+2000-09-12 Jason Merrill <jason@redhat.com>
+
+ * decl.c (maybe_deduce_size_from_array_init): Set do_default for
+ all non-extern arrays.
+
+ * decl.c (grokdeclarator): Complain about 'friend T' for implicit
+ typenames, too. Downgrade complaint to pedwarn.
+ (xref_tag): Warn about surprising behavior of 'friend struct T'.
+ * decl2.c (handle_class_head): Generate a TYPENAME_TYPE for
+ 'class This::Inherited'.
+
2000-09-12 Mark Mitchell <mark@codesourcery.com>
* decl.c (finish_case_label): Given the LABEL_DECL a
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5653a38..4430d55 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7654,12 +7654,9 @@ maybe_deduce_size_from_array_init (decl, init)
&& TYPE_DOMAIN (type) == NULL_TREE
&& TREE_CODE (decl) != TYPE_DECL)
{
- int do_default
- = (TREE_STATIC (decl)
- /* Even if pedantic, an external linkage array
- may have incomplete type at first. */
- ? pedantic && ! DECL_EXTERNAL (decl)
- : !DECL_EXTERNAL (decl));
+ /* do_default is really a C-ism to deal with tentative definitions.
+ But let's leave it here to ease the eventual merge. */
+ int do_default = !DECL_EXTERNAL (decl);
tree initializer = init ? init : DECL_INITIAL (decl);
int failure = complete_array_type (type, initializer, do_default);
@@ -11381,12 +11378,23 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
cp_error ("`inline' specified for friend class declaration");
inlinep = 0;
}
- if (!current_aggr && TREE_CODE (type) != TYPENAME_TYPE)
+
+ /* Until core issue 180 is resolved, allow 'friend typename A::B'.
+ But don't allow implicit typenames. */
+ if (!current_aggr && (TREE_CODE (type) != TYPENAME_TYPE
+ || IMPLICIT_TYPENAME_P (type)))
{
if (TREE_CODE (type) == TEMPLATE_TYPE_PARM)
- cp_error ("template parameters cannot be friends");
+ cp_pedwarn ("template parameters cannot be friends");
+ else if (TREE_CODE (type) == TYPENAME_TYPE)
+ cp_pedwarn ("\
+friend declaration requires class-key, i.e. `friend class %T::%T'",
+ constructor_name (current_class_type),
+ TYPE_IDENTIFIER (type));
else
- cp_error ("friend declaration requires `%#T'", type);
+ cp_pedwarn ("\
+friend declaration requires class-key, i.e. `friend %#T'",
+ type);
}
/* Only try to do this stuff if we didn't already give up. */
@@ -12896,6 +12904,22 @@ xref_tag (code_type_node, name, globalize)
else
t = IDENTIFIER_TYPE_VALUE (name);
+ /* Warn about 'friend struct Inherited;' doing the wrong thing. */
+ if (t && globalize && TREE_CODE (t) == TYPENAME_TYPE)
+ {
+ static int explained;
+
+ cp_warning ("`%s %T' declares a new type at namespace scope;\n\
+to refer to the inherited type, say `%s %T::%T'%s",
+ tag_name (tag_code), name, tag_name (tag_code),
+ constructor_name (current_class_type), TYPE_IDENTIFIER (t),
+ (!explained ? "\n\
+(names from dependent base classes are not visible to unqualified name lookup)"
+ : ""));
+
+ explained = 1;
+ }
+
if (t && TREE_CODE (t) != code && TREE_CODE (t) != TEMPLATE_TYPE_PARM
&& TREE_CODE (t) != BOUND_TEMPLATE_TEMPLATE_PARM)
t = NULL_TREE;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 250068a..a2cdb1d 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5437,7 +5437,7 @@ tree
handle_class_head (aggr, scope, id)
tree aggr, scope, id;
{
- tree decl;
+ tree decl = NULL_TREE;
if (TREE_CODE (id) == TYPE_DECL)
/* We must bash typedefs back to the main decl of the type. Otherwise
@@ -5447,7 +5447,7 @@ handle_class_head (aggr, scope, id)
decl = DECL_TEMPLATE_RESULT (id);
else
{
- tree current = current_scope();
+ tree current = current_scope ();
if (current == NULL_TREE)
current = current_namespace;
@@ -5455,7 +5455,17 @@ handle_class_head (aggr, scope, id)
scope = global_namespace;
if (scope == NULL_TREE)
scope = global_namespace;
- if (scope == current)
+
+ if (TYPE_P (scope))
+ {
+ /* According to the suggested resolution of core issue 180,
+ 'typename' is assumed after a class-key. */
+ decl = make_typename_type (scope, id, 1);
+ if (decl == error_mark_node)
+ return error_mark_node;
+ decl = TYPE_MAIN_DECL (decl);
+ }
+ else if (scope == current)
{
/* We've been given AGGR SCOPE::ID, when we're already inside SCOPE.
Be nice about it. */
@@ -5469,7 +5479,8 @@ handle_class_head (aggr, scope, id)
cp_error ("no file-scope type named `%D'", id);
/* Inject it at the current scope. */
- decl = TYPE_MAIN_DECL (xref_tag (aggr, id, 1));
+ if (!decl)
+ decl = TYPE_MAIN_DECL (xref_tag (aggr, id, 1));
}
/* Enter the SCOPE. If this turns out not to be a definition, the