re PR c++/23993 (Mysterious compiler error when accessing a 2d-array in a template...
authorMark Mitchell <mark@codesourcery.com>
Thu, 22 Sep 2005 00:11:22 +0000 (00:11 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 22 Sep 2005 00:11:22 +0000 (00:11 +0000)
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

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array14.C [new file with mode: 0644]

index 56c3a2ccb5223c5a4ac0325c3044e07f2d9bb234..4627b8b3a1f38090732968339ae2e365084df382 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-21  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23993
+       * init.c (integral_constant_value): Use DECL_INTEGRAL_CONSTANT_VAR_P.
+
 2005-09-21  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23965
index 50b0bcabb46651d49d53aa9da5b1d79f461400ed..2b8d768ae00f462d8bc283e9994555093e1253ef 100644 (file)
@@ -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
index 1830984d4458f0946163254754c6d16daf5c1b44..24cdbb299ada4e7293be20e9b2ba7783f7b76699 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-21  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/23993
+       * g++.dg/template/array14.C: New test.
+
 2005-09-21  Erik Edelmann  <erik.edelmann@iki.fi>
 
        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 (file)
index 0000000..71a03f3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/23993
+
+const int data[2][4] = {
+  { 0, 1, 2, 3 }
+};
+
+template <typename T>
+void t(int k) {
+  int candidate = data[1][k];
+}