From 0e642d0671db79acb4bccc4268e461fdcf5c1cdf Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 6 Dec 2011 20:52:39 +0100 Subject: re PR c++/51430 (ICE with array as static const member) PR c++/51430 * pt.c (tsubst_decl): Don't call strip_array_domain on error_mark_node. * g++.dg/template/static32.C: New test. From-SVN: r182063 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/pt.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/static32.C | 9 +++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/static32.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f979af5..defc0a5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-12-06 Jakub Jelinek + + PR c++/51430 + * pt.c (tsubst_decl): Don't call strip_array_domain on + error_mark_node. + 2011-12-06 Paolo Carlini PR c++/51431 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 15ef7a0..7603c11 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10622,7 +10622,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) type = DECL_ORIGINAL_TYPE (t); else type = TREE_TYPE (t); - if (TREE_CODE (t) == VAR_DECL && VAR_HAD_UNKNOWN_BOUND (t)) + if (TREE_CODE (t) == VAR_DECL + && VAR_HAD_UNKNOWN_BOUND (t) + && type != error_mark_node) type = strip_array_domain (type); type = tsubst (type, args, complain, in_decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2353dd9..507f9df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-06 Jakub Jelinek + + PR c++/51430 + * g++.dg/template/static32.C: New test. + 2011-12-06 Uros Bizjak * g++.dg/opt/pr51396.C: Use dg-additional-options. diff --git a/gcc/testsuite/g++.dg/template/static32.C b/gcc/testsuite/g++.dg/template/static32.C new file mode 100644 index 0000000..b17d14d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static32.C @@ -0,0 +1,9 @@ +// PR c++/51430 +// { dg-do compile } + +template struct A +{ + static const int x[] = 0; // { dg-error "in-class initialization|initializer fails" } +}; + +A<0> a; -- cgit v1.1