Commit a1bcc528 by Jason Merrill Committed by Jason Merrill

pt.c (do_type_instantiation): Add complain parm; don't complain if called recursively.

        * pt.c (do_type_instantiation): Add complain parm; don't complain
        if called recursively.
        * cp-tree.h, parse.y: Adjust.

From-SVN: r35467
parent 57cac714
2000-08-02 Jason Merrill <jason@redhat.com>
* pt.c (do_type_instantiation): Add complain parm; don't complain
if called recursively.
* cp-tree.h, parse.y: Adjust.
2000-08-02 Zack Weinberg <zack@wolery.cumb.org> 2000-08-02 Zack Weinberg <zack@wolery.cumb.org>
* decl2.c: Silently ignore -Wstrict-prototypes; warn about * decl2.c: Silently ignore -Wstrict-prototypes; warn about
......
...@@ -4260,7 +4260,7 @@ extern void mark_decl_instantiated PARAMS ((tree, int)); ...@@ -4260,7 +4260,7 @@ extern void mark_decl_instantiated PARAMS ((tree, int));
extern int more_specialized PARAMS ((tree, tree, tree)); extern int more_specialized PARAMS ((tree, tree, tree));
extern void mark_class_instantiated PARAMS ((tree, int)); extern void mark_class_instantiated PARAMS ((tree, int));
extern void do_decl_instantiation PARAMS ((tree, tree, tree)); extern void do_decl_instantiation PARAMS ((tree, tree, tree));
extern void do_type_instantiation PARAMS ((tree, tree)); extern void do_type_instantiation PARAMS ((tree, tree, int));
extern tree instantiate_decl PARAMS ((tree, int)); extern tree instantiate_decl PARAMS ((tree, int));
extern tree get_bindings PARAMS ((tree, tree, tree)); extern tree get_bindings PARAMS ((tree, tree, tree));
extern void add_tree PARAMS ((tree)); extern void add_tree PARAMS ((tree));
......
...@@ -962,7 +962,7 @@ identifier_defn: ...@@ -962,7 +962,7 @@ identifier_defn:
explicit_instantiation: explicit_instantiation:
TEMPLATE begin_explicit_instantiation typespec ';' TEMPLATE begin_explicit_instantiation typespec ';'
{ do_type_instantiation ($3.t, NULL_TREE); { do_type_instantiation ($3.t, NULL_TREE, 1);
yyungetc (';', 1); } yyungetc (';', 1); }
end_explicit_instantiation end_explicit_instantiation
| TEMPLATE begin_explicit_instantiation typed_declspecs declarator | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
...@@ -976,7 +976,7 @@ explicit_instantiation: ...@@ -976,7 +976,7 @@ explicit_instantiation:
{ do_decl_instantiation (NULL_TREE, $3, NULL_TREE); } { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
end_explicit_instantiation end_explicit_instantiation
| SCSPEC TEMPLATE begin_explicit_instantiation typespec ';' | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
{ do_type_instantiation ($4.t, $1); { do_type_instantiation ($4.t, $1, 1);
yyungetc (';', 1); } yyungetc (';', 1); }
end_explicit_instantiation end_explicit_instantiation
| SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
......
...@@ -9267,9 +9267,15 @@ mark_class_instantiated (t, extern_p) ...@@ -9267,9 +9267,15 @@ mark_class_instantiated (t, extern_p)
} }
} }
/* Perform an explicit instantiation of template class T. STORAGE, if
non-null, is the RID for extern, inline or static. COMPLAIN is
non-zero if this is called from the parser, zero if called recursively,
since the standard is unclear (as detailed below). */
void void
do_type_instantiation (t, storage) do_type_instantiation (t, storage, complain)
tree t, storage; tree t, storage;
int complain;
{ {
int extern_p = 0; int extern_p = 0;
int nomem_p = 0; int nomem_p = 0;
...@@ -9293,8 +9299,9 @@ do_type_instantiation (t, storage) ...@@ -9293,8 +9299,9 @@ do_type_instantiation (t, storage)
if (!COMPLETE_TYPE_P (t)) if (!COMPLETE_TYPE_P (t))
{ {
cp_error ("explicit instantiation of `%#T' before definition of template", if (complain)
t); cp_error ("explicit instantiation of `%#T' before definition of template",
t);
return; return;
} }
...@@ -9324,8 +9331,11 @@ do_type_instantiation (t, storage) ...@@ -9324,8 +9331,11 @@ do_type_instantiation (t, storage)
No program shall both explicitly instantiate and explicitly No program shall both explicitly instantiate and explicitly
specialize a template. */ specialize a template. */
cp_error ("explicit instantiation of `%#T' after", t); if (complain)
cp_error_at ("explicit specialization here", t); {
cp_error ("explicit instantiation of `%#T' after", t);
cp_error_at ("explicit specialization here", t);
}
return; return;
} }
else if (CLASSTYPE_EXPLICIT_INSTANTIATION (t)) else if (CLASSTYPE_EXPLICIT_INSTANTIATION (t))
...@@ -9339,7 +9349,8 @@ do_type_instantiation (t, storage) ...@@ -9339,7 +9349,8 @@ do_type_instantiation (t, storage)
was `extern'. If EXTERN_P then the second is. If -frepo, chances was `extern'. If EXTERN_P then the second is. If -frepo, chances
are we already got marked as an explicit instantion because of the are we already got marked as an explicit instantion because of the
repo file. All these cases are OK. */ repo file. All these cases are OK. */
if (!CLASSTYPE_INTERFACE_ONLY (t) && !extern_p && !flag_use_repository) if (!CLASSTYPE_INTERFACE_ONLY (t) && !extern_p && !flag_use_repository
&& complain)
cp_pedwarn ("duplicate explicit instantiation of `%#T'", t); cp_pedwarn ("duplicate explicit instantiation of `%#T'", t);
/* If we've already instantiated the template, just return now. */ /* If we've already instantiated the template, just return now. */
...@@ -9398,7 +9409,7 @@ do_type_instantiation (t, storage) ...@@ -9398,7 +9409,7 @@ do_type_instantiation (t, storage)
for (tmp = CLASSTYPE_TAGS (t); tmp; tmp = TREE_CHAIN (tmp)) for (tmp = CLASSTYPE_TAGS (t); tmp; tmp = TREE_CHAIN (tmp))
if (IS_AGGR_TYPE (TREE_VALUE (tmp)) if (IS_AGGR_TYPE (TREE_VALUE (tmp))
&& !uses_template_parms (CLASSTYPE_TI_ARGS (TREE_VALUE (tmp)))) && !uses_template_parms (CLASSTYPE_TI_ARGS (TREE_VALUE (tmp))))
do_type_instantiation (TYPE_MAIN_DECL (TREE_VALUE (tmp)), storage); do_type_instantiation (TYPE_MAIN_DECL (TREE_VALUE (tmp)), storage, 0);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment