Commit 653109bd by Lee Millward Committed by Lee Millward

re PR c++/28741 (ICE with static member in invalid template class)

        PR c++/28741
        * tree.c (decl_anon_ns_mem_p): Robustify.
        * decl2.c (determine_visibility): Likewise.

        * g++.dg/template/void7.C: New test.

From-SVN: r116303
parent 623c65f1
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
PR c++/28505 PR c++/28505
* decl.c (grokdeclarator): Return early after * decl.c (grokdeclarator): Return early after
issuing diagnostic about an incomplete type. issuing diagnostic about an incomplete type.
PR c++/28741
* tree.c (decl_anon_ns_mem_p): Robustify.
* decl2.c (determine_visibility): Likewise.
2006-08-20 Mark Mitchell <mark@codesourcery.com> 2006-08-20 Mark Mitchell <mark@codesourcery.com>
......
...@@ -1753,20 +1753,24 @@ determine_visibility (tree decl) ...@@ -1753,20 +1753,24 @@ determine_visibility (tree decl)
? TYPE_TEMPLATE_INFO (TREE_TYPE (decl)) ? TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
: DECL_TEMPLATE_INFO (decl)); : DECL_TEMPLATE_INFO (decl));
tree args = TI_ARGS (tinfo); tree args = TI_ARGS (tinfo);
int depth = TMPL_ARGS_DEPTH (args);
tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo)); if (args != error_mark_node)
if (!DECL_VISIBILITY_SPECIFIED (decl))
{ {
DECL_VISIBILITY (decl) = DECL_VISIBILITY (pattern); int depth = TMPL_ARGS_DEPTH (args);
DECL_VISIBILITY_SPECIFIED (decl) tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
= DECL_VISIBILITY_SPECIFIED (pattern);
} if (!DECL_VISIBILITY_SPECIFIED (decl))
{
DECL_VISIBILITY (decl) = DECL_VISIBILITY (pattern);
DECL_VISIBILITY_SPECIFIED (decl)
= DECL_VISIBILITY_SPECIFIED (pattern);
}
/* FIXME should TMPL_ARGS_DEPTH really return 1 for null input? */ /* FIXME should TMPL_ARGS_DEPTH really return 1 for null input? */
if (args && depth > template_class_depth (class_type)) if (args && depth > template_class_depth (class_type))
/* Limit visibility based on its template arguments. */ /* Limit visibility based on its template arguments. */
constrain_visibility_for_template (decl, args); constrain_visibility_for_template (decl, args);
}
} }
if (class_type) if (class_type)
......
...@@ -1393,7 +1393,7 @@ decl_anon_ns_mem_p (tree decl) ...@@ -1393,7 +1393,7 @@ decl_anon_ns_mem_p (tree decl)
{ {
while (1) while (1)
{ {
if (decl == NULL_TREE) if (decl == NULL_TREE || decl == error_mark_node)
return false; return false;
if (TREE_CODE (decl) == NAMESPACE_DECL if (TREE_CODE (decl) == NAMESPACE_DECL
&& DECL_NAME (decl) == NULL_TREE) && DECL_NAME (decl) == NULL_TREE)
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
PR c++/28505 PR c++/28505
* g++.dg/parse/ctor7.C: New test. * g++.dg/parse/ctor7.C: New test.
* g++.dg/parse/ctor8.C: Likewise. * g++.dg/parse/ctor8.C: Likewise.
PR c++/28741
* g++.dg/template/void7.C: New test.
2006-08-21 Olivier Hainque <hainque@adacore.com> 2006-08-21 Olivier Hainque <hainque@adacore.com>
//PR c++/28741
template<void> struct A // { dg-error "not a valid type" }
{
static int i;
};
A<0> a;
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