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
This commit is contained in:
Lee Millward 2006-08-21 17:41:18 +00:00 committed by Lee Millward
parent 623c65f173
commit 653109bdf2
5 changed files with 32 additions and 13 deletions

View File

@ -7,6 +7,10 @@
PR c++/28505
* decl.c (grokdeclarator): Return early after
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>

View File

@ -1753,20 +1753,24 @@ determine_visibility (tree decl)
? TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
: DECL_TEMPLATE_INFO (decl));
tree args = TI_ARGS (tinfo);
int depth = TMPL_ARGS_DEPTH (args);
tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
if (!DECL_VISIBILITY_SPECIFIED (decl))
if (args != error_mark_node)
{
DECL_VISIBILITY (decl) = DECL_VISIBILITY (pattern);
DECL_VISIBILITY_SPECIFIED (decl)
= DECL_VISIBILITY_SPECIFIED (pattern);
}
int depth = TMPL_ARGS_DEPTH (args);
tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
/* FIXME should TMPL_ARGS_DEPTH really return 1 for null input? */
if (args && depth > template_class_depth (class_type))
/* Limit visibility based on its template arguments. */
constrain_visibility_for_template (decl, args);
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? */
if (args && depth > template_class_depth (class_type))
/* Limit visibility based on its template arguments. */
constrain_visibility_for_template (decl, args);
}
}
if (class_type)

View File

@ -1393,7 +1393,7 @@ decl_anon_ns_mem_p (tree decl)
{
while (1)
{
if (decl == NULL_TREE)
if (decl == NULL_TREE || decl == error_mark_node)
return false;
if (TREE_CODE (decl) == NAMESPACE_DECL
&& DECL_NAME (decl) == NULL_TREE)

View File

@ -6,6 +6,9 @@
PR c++/28505
* g++.dg/parse/ctor7.C: New test.
* g++.dg/parse/ctor8.C: Likewise.
PR c++/28741
* g++.dg/template/void7.C: New test.
2006-08-21 Olivier Hainque <hainque@adacore.com>

View File

@ -0,0 +1,8 @@
//PR c++/28741
template<void> struct A // { dg-error "not a valid type" }
{
static int i;
};
A<0> a;