summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-12-30 10:07:13 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2003-12-30 10:07:13 +0000
commit59939326e8c8d082a53fe39198788a7c06d39a61 (patch)
tree782381548209213cb65d0241617ed7102f9f7f2d
parent9335a12b467e7b3378ffd14987a576f182353ac3 (diff)
downloadgcc-59939326e8c8d082a53fe39198788a7c06d39a61.tar.gz
cp:
PR c++/13494 * tree.c (build_cplus_array_type_1): Only build a minimal array type for dependent types or domains. testsuite: PR c++/13494 * g++.dg/template/array2-1.C: New test. * g++.dg/template/array2-2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75225 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/tree.c11
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/template/array2-1.C14
-rw-r--r--gcc/testsuite/g++.dg/template/array2-2.C14
5 files changed, 43 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1d61141af04..15947ba7a3b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/13494
+ * tree.c (build_cplus_array_type_1): Only build a minimal array
+ type for dependent types or domains.
+
2003-12-29 Nathan Sidwell <nathan@codesourcery.com>
PR c++/12774
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 426c3d7c9ed..bedbbe96b44 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -363,14 +363,9 @@ build_cplus_array_type_1 (tree elt_type, tree index_type)
if (elt_type == error_mark_node || index_type == error_mark_node)
return error_mark_node;
- /* Don't do the minimal thing just because processing_template_decl is
- set; we want to give string constants the right type immediately, so
- we don't have to fix them up at instantiation time. */
- if ((processing_template_decl
- && index_type && TYPE_MAX_VALUE (index_type)
- && TREE_CODE (TYPE_MAX_VALUE (index_type)) != INTEGER_CST)
- || uses_template_parms (elt_type)
- || (index_type && uses_template_parms (index_type)))
+ if (dependent_type_p (elt_type)
+ || (index_type
+ && value_dependent_expression_p (TYPE_MAX_VALUE (index_type))))
{
t = make_node (ARRAY_TYPE);
TREE_TYPE (t) = elt_type;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 879d4ee88ca..992e6f4345a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2003-12-30 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/13494
+ * g++.dg/template/array2-1.C: New test.
+ * g++.dg/template/array2-2.C: New test.
+
2003-12-29 Mark Mitchell <mark@codesourcery.com>
* g++.old-deja/g++.pt/static11.C: Correct XFAIL syntax.
diff --git a/gcc/testsuite/g++.dg/template/array2-1.C b/gcc/testsuite/g++.dg/template/array2-1.C
new file mode 100644
index 00000000000..2980a1fd186
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/array2-1.C
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-fabi-version=1" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 29 Dec 2003 <nathan@codesourcery.com>
+
+// PR c++/13494. ICE
+
+template<typename T>
+int foo(int d[][4])
+{
+ return d[0][0];
+}
+
diff --git a/gcc/testsuite/g++.dg/template/array2-2.C b/gcc/testsuite/g++.dg/template/array2-2.C
new file mode 100644
index 00000000000..dd3e7f0e265
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/array2-2.C
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-options "-fabi-version=2" }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 29 Dec 2003 <nathan@codesourcery.com>
+
+// PR c++/13494. ICE
+
+template<typename T>
+int foo(int d[][4])
+{
+ return d[0][0];
+}
+