summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog18
-rw-r--r--gcc/cp/cp-tree.h5
-rw-r--r--gcc/cp/decl.c13
-rw-r--r--gcc/cp/except.c1
-rw-r--r--gcc/cp/lang-options.h2
-rw-r--r--gcc/cp/lex.c23
-rw-r--r--gcc/cp/pt.c1
-rw-r--r--gcc/cp/search.c19
-rw-r--r--gcc/cp/semantics.c34
9 files changed, 76 insertions, 40 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 37c16b3f6cf..665f35d0155 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,21 @@
+1998-09-01 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (lookup_name_real): Also do implicit typename thing for
+ artificial TYPE_DECLs.
+ * search.c (lookup_field): Likewise.
+ (lookup_fnfields, lookup_field): Adjust for implicit typename kludge.
+ * semantics.c (begin_constructor_declarator): Use enter_scope_of.
+ (enter_scope_of): Extract type from implicit typename.
+ (begin_class_definition): Likewise.
+ * lex.c (identifier_type): Handle implicit typename when checking
+ for SELFNAME.
+
+ * cp-tree.h: Declare flag_strict_prototype.
+ * lex.c (do_scoped_id, do_identifier): Don't implicitly_declare if
+ -fstrict-prototype.
+ * decl.c (init_decl_processing): If -f{no,-}strict-prototype wasn't
+ specified, set it to the value of pedantic.
+
1998-09-01 Mark Mitchell <mark@markmitchell.com>
* decl2.c (arg_assoc): Handle template-id expressions as arguments.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e4b07be0ad9..096617a5aa4 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -477,6 +477,11 @@ extern int flag_do_squangling;
required. */
extern int flag_optional_diags;
+/* Nonzero means do not consider empty argument prototype to mean function
+ takes no arguments. */
+
+extern int flag_strict_prototype;
+
/* Nonzero means output .vtable_{entry,inherit} for use in doing vtable gc. */
extern int flag_vtable_gc;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fe9160dc2c0..2abcd1ac180 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5091,8 +5091,7 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
else if (processing_template_decl
&& classval && TREE_CODE (classval) == TYPE_DECL
&& ! currently_open_class (DECL_CONTEXT (classval))
- && uses_template_parms (current_class_type)
- && ! DECL_ARTIFICIAL (classval))
+ && uses_template_parms (current_class_type))
classval = lookup_field (current_class_type, name, 0, 1);
/* yylex() calls this with -2, since we should never start digging for
@@ -5470,7 +5469,6 @@ init_decl_processing ()
int wchar_type_size;
tree temp;
tree array_domain_type;
- extern int flag_strict_prototype;
tree vb_off_identifier = NULL_TREE;
/* Function type `char *(char *, char *)' and similar ones */
tree string_ftype_ptr_ptr, int_ftype_string_string;
@@ -5492,12 +5490,9 @@ init_decl_processing ()
current_lang_name = NULL_TREE;
if (flag_strict_prototype == 2)
- {
- if (pedantic)
- strict_prototypes_lang_c = strict_prototypes_lang_cplusplus;
- }
- else
- strict_prototypes_lang_c = flag_strict_prototype;
+ flag_strict_prototype = pedantic;
+
+ strict_prototypes_lang_c = flag_strict_prototype;
/* Initially, C. */
current_lang_name = lang_name_c;
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index b441c6b628d..69315beba39 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -826,7 +826,6 @@ process_start_catch_block (declspecs, declarator)
}
-
/* Call this to end a catch block. Its responsible for emitting the
code to handle jumping back to the correct place, and for emitting
the label to jump to if this catch block didn't match. */
diff --git a/gcc/cp/lang-options.h b/gcc/cp/lang-options.h
index 97ec99b38e7..e6ad6595b10 100644
--- a/gcc/cp/lang-options.h
+++ b/gcc/cp/lang-options.h
@@ -1,5 +1,5 @@
/* Definitions for switches for C++.
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1998 Free Software Foundation, Inc.
This file is part of GNU CC.
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 859a6bea2af..b789b28438b 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -2754,6 +2754,7 @@ int
identifier_type (decl)
tree decl;
{
+ tree t;
if (TREE_CODE (decl) == TEMPLATE_DECL)
{
if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
@@ -2763,7 +2764,6 @@ identifier_type (decl)
}
if (looking_for_template && really_overloaded_fn (decl))
{
- tree t;
for (t = decl; t != NULL_TREE; t = OVL_CHAIN (t))
if (DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (t)))
return PFUNCNAME;
@@ -2772,10 +2772,20 @@ identifier_type (decl)
return NSNAME;
if (TREE_CODE (decl) != TYPE_DECL)
return IDENTIFIER;
- if (((got_scope && TREE_TYPE (decl) == got_scope)
- || TREE_TYPE (decl) == current_class_type)
- && DECL_ARTIFICIAL (decl))
+ if (DECL_ARTIFICIAL (decl) && TREE_TYPE (decl) == current_class_type)
+ return SELFNAME;
+
+ /* A constructor declarator for a template type will get here as an
+ implicit typename, a TYPENAME_TYPE with a type. */
+ t = got_scope;
+ if (t && TREE_CODE (t) == TYPENAME_TYPE)
+ t = TREE_TYPE (t);
+ decl = TREE_TYPE (decl);
+ if (TREE_CODE (decl) == TYPENAME_TYPE)
+ decl = TREE_TYPE (decl);
+ if (t && t == decl)
return SELFNAME;
+
return TYPENAME;
}
@@ -2902,7 +2912,7 @@ do_identifier (token, parsing, args)
cp_error ("`%D' not defined", token);
id = error_mark_node;
}
- else if (in_call)
+ else if (in_call && ! flag_strict_prototype)
{
id = implicitly_declare (token);
}
@@ -3054,7 +3064,8 @@ do_scoped_id (token, parsing)
LOOKUP_EXPR_GLOBAL (id) = 1;
return id;
}
- if (parsing && (yychar == '(' || yychar == LEFT_RIGHT))
+ if (parsing && (yychar == '(' || yychar == LEFT_RIGHT)
+ && ! flag_strict_prototype)
id = implicitly_declare (token);
else
{
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index fff3fbc048d..aadd36d6c71 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2598,7 +2598,6 @@ coerce_template_template_parms (parm_parms, arg_parms, in_decl, outer_args)
return 1;
}
-
/* Convert the indicated template ARG as necessary to match the
indicated template PARM. Returns the converted ARG, or
error_mark_node if the conversion was unsuccessful. Error messages
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index fa3109daac6..1c3a187abeb 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1030,9 +1030,12 @@ lookup_field (xbasetype, name, protect, want_type)
basetype_chain = TREE_CHAIN (basetype_chain);
basetype_path = TREE_VALUE (basetype_chain);
if (TREE_CHAIN (basetype_chain))
- my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
- == TREE_VALUE (TREE_CHAIN (basetype_chain)),
- 980827);
+ my_friendly_assert
+ ((BINFO_INHERITANCE_CHAIN (basetype_path)
+ == TREE_VALUE (TREE_CHAIN (basetype_chain)))
+ /* We only approximate base info for partial instantiations. */
+ || current_template_parms,
+ 980827);
else
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
== NULL_TREE, 980827);
@@ -1187,7 +1190,6 @@ lookup_field (xbasetype, name, protect, want_type)
/* Do implicit typename stuff. */
if (rval && TREE_CODE (rval) == TYPE_DECL
- && ! DECL_ARTIFICIAL (rval)
&& processing_template_decl
&& ! currently_open_class (BINFO_TYPE (rval_binfo))
&& uses_template_parms (type))
@@ -1480,9 +1482,12 @@ lookup_fnfields (basetype_path, name, complain)
basetype_chain = TREE_CHAIN (basetype_chain);
basetype_path = TREE_VALUE (basetype_chain);
if (TREE_CHAIN (basetype_chain))
- my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
- == TREE_VALUE (TREE_CHAIN (basetype_chain)),
- 980827);
+ my_friendly_assert
+ ((BINFO_INHERITANCE_CHAIN (basetype_path)
+ == TREE_VALUE (TREE_CHAIN (basetype_chain)))
+ /* We only approximate base info for partial instantiations. */
+ || current_template_parms,
+ 980827);
else
my_friendly_assert (BINFO_INHERITANCE_CHAIN (basetype_path)
== NULL_TREE, 980827);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6bb3cd05123..10ffe1987bf 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1114,13 +1114,7 @@ begin_constructor_declarator (scope, name)
tree name;
{
tree result = build_parse_node (SCOPE_REF, scope, name);
-
- if (scope != current_class_type)
- {
- push_nested_class (scope, 3);
- TREE_COMPLEXITY (result) = current_class_depth;
- }
-
+ enter_scope_of (result);
return result;
}
@@ -1214,24 +1208,27 @@ tree
begin_class_definition (t)
tree t;
{
- tree new_type = t;
-
push_obstacks_nochange ();
end_temporary_allocation ();
if (t == error_mark_node
|| ! IS_AGGR_TYPE (t))
{
- t = new_type = make_lang_type (RECORD_TYPE);
+ t = make_lang_type (RECORD_TYPE);
pushtag (make_anon_name (), t, 0);
}
+
+ /* In a definition of a member class template, we will get here with an
+ implicit typename, a TYPENAME_TYPE with a type. */
+ if (TREE_CODE (t) == TYPENAME_TYPE)
+ t = TREE_TYPE (t);
+
if (TYPE_SIZE (t))
duplicate_tag_error (t);
if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
{
t = make_lang_type (TREE_CODE (t));
pushtag (TYPE_IDENTIFIER (t), t, 0);
- new_type = t;
}
if (processing_template_decl && TYPE_CONTEXT (t)
&& TREE_CODE (TYPE_CONTEXT (t)) != NAMESPACE_DECL
@@ -1267,9 +1264,9 @@ begin_class_definition (t)
CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
}
#if 0
- t = TYPE_IDENTIFIER ($<ttype>0);
- if (t && IDENTIFIER_TEMPLATE (t))
- overload_template_name (t, 1);
+ tmp = TYPE_IDENTIFIER ($<ttype>0);
+ if (tmp && IDENTIFIER_TEMPLATE (tmp))
+ overload_template_name (tmp, 1);
#endif
reset_specialization();
@@ -1278,7 +1275,7 @@ begin_class_definition (t)
that we can get it back later. */
begin_tree ();
- return new_type;
+ return t;
}
/* Finish a class definition T, with the indicated COMPONENTS, and
@@ -1432,6 +1429,13 @@ enter_scope_of (sr)
}
else if (scope != current_class_type)
{
+ if (TREE_CODE (scope) == TYPENAME_TYPE)
+ {
+ /* In a declarator for a template class member, the scope will
+ get here as an implicit typename, a TYPENAME_TYPE with a type. */
+ scope = TREE_TYPE (scope);
+ TREE_OPERAND (sr, 0) = scope;
+ }
push_nested_class (scope, 3);
TREE_COMPLEXITY (sr) = current_class_depth;
}