diff options
author | Lee Millward <lee.millward@codesourcery.com> | 2006-08-21 17:41:18 +0000 |
---|---|---|
committer | Lee Millward <lmillward@gcc.gnu.org> | 2006-08-21 17:41:18 +0000 |
commit | 653109bdf206ff0fa3fc0a73d8144f91066ab2c4 (patch) | |
tree | 661f91dbd081e065fa90c558a7d00cd684aa2e99 /gcc | |
parent | 623c65f1732d0ee0fc163921272d152b50211710 (diff) | |
download | gcc-653109bdf206ff0fa3fc0a73d8144f91066ab2c4.zip gcc-653109bdf206ff0fa3fc0a73d8144f91066ab2c4.tar.gz gcc-653109bdf206ff0fa3fc0a73d8144f91066ab2c4.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 28 | ||||
-rw-r--r-- | gcc/cp/tree.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/void7.C | 8 |
5 files changed, 32 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 10d0538..758f877 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 <mark@codesourcery.com> diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 8b39b81..0de2756 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)); + + 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); + /* 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 90839b7..bb579a6 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 a277501..c40d500 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 <hainque@adacore.com> diff --git a/gcc/testsuite/g++.dg/template/void7.C b/gcc/testsuite/g++.dg/template/void7.C new file mode 100644 index 0000000..2c464b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/void7.C @@ -0,0 +1,8 @@ +//PR c++/28741 + +template<void> struct A // { dg-error "not a valid type" } +{ + static int i; +}; + +A<0> a; |