From: Mark Mitchell Date: Thu, 22 Sep 2005 00:11:22 +0000 (+0000) Subject: re PR c++/23993 (Mysterious compiler error when accessing a 2d-array in a template... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f513e31f31fa83363571d192abcbb0571518a665;p=gcc.git re PR c++/23993 (Mysterious compiler error when accessing a 2d-array in a template class) PR c++/23993 * init.c (integral_constant_value): Use DECL_INTEGRAL_CONSTANT_VAR_P. PR c++/23993 * g++.dg/template/array14.C: New test. From-SVN: r104511 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 56c3a2ccb52..4627b8b3a1f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-09-21 Mark Mitchell + + PR c++/23993 + * init.c (integral_constant_value): Use DECL_INTEGRAL_CONSTANT_VAR_P. + 2005-09-21 Volker Reichelt PR c++/23965 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 50b0bcabb46..2b8d768ae00 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1567,12 +1567,8 @@ build_offset_ref (tree type, tree name, bool address_p) tree integral_constant_value (tree decl) { - while ((TREE_CODE (decl) == CONST_DECL - || (TREE_CODE (decl) == VAR_DECL - /* And so are variables with a 'const' type -- unless they - are also 'volatile'. */ - && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)) - && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)))) + while (TREE_CODE (decl) == CONST_DECL + || DECL_INTEGRAL_CONSTANT_VAR_P (decl)) { tree init; /* If DECL is a static data member in a template class, we must diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1830984d445..24cdbb299ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-21 Mark Mitchell + + PR c++/23993 + * g++.dg/template/array14.C: New test. + 2005-09-21 Erik Edelmann PR fortran/19929 diff --git a/gcc/testsuite/g++.dg/template/array14.C b/gcc/testsuite/g++.dg/template/array14.C new file mode 100644 index 00000000000..71a03f3bf30 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/array14.C @@ -0,0 +1,10 @@ +// PR c++/23993 + +const int data[2][4] = { + { 0, 1, 2, 3 } +}; + +template +void t(int k) { + int candidate = data[1][k]; +}