OSDN Git Service

2004-10-25 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Oct 2004 13:27:32 +0000 (13:27 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Oct 2004 13:27:32 +0000 (13:27 +0000)
        PR middle-end/17407
        * c-decl.c (grokdeclarator) <case cdk_array>: Remove the call
        layout_type as it is already done by build_array_type.
        * tree.c (build_array_type): Layout the type even

2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR c++/18121
        * decl.c (grokdeclarator) <case cdk_array>: Remove the call
        layout_type as it is already done by create_array_type_for_decl.

2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/17407
        * gcc.c-torture/compile/pr17407.c: New test.

        PR c++/18121
        * g++.dg/template/array8.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89533 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/array8.C [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr17407.c [new file with mode: 0644]
gcc/tree.c

index 039be86..16777c9 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/17407
+       * c-decl.c (grokdeclarator) <case cdk_array>: Remove the call
+       layout_type as it is already done by build_array_type.
+       * tree.c (build_array_type): Layout the type even
+
 2004-10-25  Alexandre Oliva  <aoliva@redhat.com>
 
        * config/frv/linux.h (TARGET_C99_FUNCTIONS): Define to 0.
index a2443ec..08f7909 100644 (file)
@@ -4133,14 +4133,9 @@ grokdeclarator (const struct c_declarator *declarator,
               zero.  */
            if (size && integer_zerop (size))
              {
-               layout_type (type);
                TYPE_SIZE (type) = bitsize_zero_node;
                TYPE_SIZE_UNIT (type) = size_zero_node;
              }
-           else if (declarator->kind == cdk_pointer)
-             /* We can never complete an array type which is the
-                target of a pointer, so go ahead and lay it out.  */
-             layout_type (type);
 
            if (decl_context != PARM
                && (array_ptr_quals != TYPE_UNQUALIFIED
index b5dae49..8e759ff 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR c++/18121
+       * decl.c (grokdeclarator) <case cdk_array>: Remove the call
+       layout_type as it is already done by create_array_type_for_decl.
+
 2004-10-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/18095
index 21ffb51..2aca629 100644 (file)
@@ -7214,13 +7214,6 @@ grokdeclarator (const cp_declarator *declarator,
        case cdk_array:
          type = create_array_type_for_decl (dname, type,
                                             declarator->u.array.bounds);
-         if (inner_declarator
-             && (inner_declarator->kind == cdk_pointer
-                 || inner_declarator->kind == cdk_reference
-                 || inner_declarator->kind == cdk_ptrmem))
-           /* We can never complete an array type which is the
-              target of a pointer, so go ahead and lay it out.  */
-           layout_type (type);
          break;
 
        case cdk_function:
index f6de047..765daa2 100644 (file)
@@ -1,3 +1,11 @@
+2004-10-25  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/17407
+       * gcc.c-torture/compile/pr17407.c: New test.
+
+       PR c++/18121
+       * g++.dg/template/array8.C: New test.
+
 2004-10-25  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR other/18138
diff --git a/gcc/testsuite/g++.dg/template/array8.C b/gcc/testsuite/g++.dg/template/array8.C
new file mode 100644 (file)
index 0000000..9fd33a4
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/18121
+
+// We were trying to layout the array
+// type but since the type/value of A<N>::i
+// was not known at template declation type,
+// we were crashing
+
+template<int> struct A
+{
+    static int const i = 1;
+};
+
+template<int N> struct B
+{
+    typedef int (*p)[A<N>::i];
+};
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr17407.c b/gcc/testsuite/gcc.c-torture/compile/pr17407.c
new file mode 100644 (file)
index 0000000..a06ab17
--- /dev/null
@@ -0,0 +1,15 @@
+typedef struct libxml_xpathCallback { 
+  void *ns_uri; 
+} libxml_xpathCallback; 
+typedef libxml_xpathCallback libxml_xpathCallbackArray[]; 
+libxml_xpathCallbackArray *libxml_xpathCallbacks; 
+
+void foo1(void);
+void 
+foo (void) 
+{ 
+  if ((*libxml_xpathCallbacks)[3].ns_uri != ((void *)0)) foo1(); 
+} 
index b132571..18dec5e 100644 (file)
@@ -4333,9 +4333,12 @@ build_array_type (tree elt_type, tree index_type)
   t = make_node (ARRAY_TYPE);
   TREE_TYPE (t) = elt_type;
   TYPE_DOMAIN (t) = index_type;
-
+  
   if (index_type == 0)
-    return t;
+    {
+      layout_type (t);
+      return t;
+    }
 
   hashcode = iterative_hash_object (TYPE_HASH (elt_type), hashcode);
   hashcode = iterative_hash_object (TYPE_HASH (index_type), hashcode);