diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 10d0538f80b..758f877187f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 8b39b81901a..0de2756620e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 90839b73ab3..bb579a6f739 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a277501ab34..c40d5007cae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/g++.dg/template/void7.C b/gcc/testsuite/g++.dg/template/void7.C new file mode 100644 index 00000000000..2c464b3a055 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/void7.C @@ -0,0 +1,8 @@ +//PR c++/28741 + +template struct A // { dg-error "not a valid type" } +{ + static int i; +}; + +A<0> a;