re PR c/17384 (ICE with mode attribute on structures)
authorRichard Henderson <rth@redhat.com>
Wed, 13 Oct 2004 23:31:23 +0000 (16:31 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 13 Oct 2004 23:31:23 +0000 (16:31 -0700)
        PR c/17384
        * c-common.c (handle_mode_attribute): Disallow mode changes that
        alter the CODE of the top-level type.

        * crtstuff.c (__FRAME_END__): Remove mode attribute.  Find 32-bit
        integer from internal limits macros.
        * config/i386/mm3dnow.h (__v2sf): Fix base type.

From-SVN: r89009

gcc/ChangeLog
gcc/c-common.c
gcc/config/i386/mm3dnow.h
gcc/crtstuff.c
gcc/testsuite/gcc.dg/attr-mode-1.c [new file with mode: 0644]

index 826702127d569ac6e0309e89745d96bb3acd554f..647941c6ecdc54ea8114f9d6d1b88d6760754d05 100644 (file)
@@ -1,3 +1,13 @@
+2004-10-13  Richard Henderson  <rth@redhat.com>
+
+        PR c/17384
+        * c-common.c (handle_mode_attribute): Disallow mode changes that
+        alter the CODE of the top-level type.
+        * crtstuff.c (__FRAME_END__): Remove mode attribute.  Find 32-bit
+        integer from internal limits macros.
+        * config/i386/mm3dnow.h (__v2sf): Fix base type.
+
 2004-10-13  Richard Henderson  <rth@redhat.com>
  
         PR debug/13841
index b2751f39226183faa82f907eae05b8cd26d95049..2e634fae9ba350a3c69c9fab9cfe6483510dce61 100644 (file)
@@ -4303,7 +4303,10 @@ handle_mode_attribute (tree *node, tree name, tree args,
       else
        for (j = 0; j < NUM_MACHINE_MODES; j++)
          if (!strcmp (p, GET_MODE_NAME (j)))
-           mode = (enum machine_mode) j;
+           {
+             mode = (enum machine_mode) j;
+             break;
+           }
 
       if (mode == VOIDmode)
        {
@@ -4363,7 +4366,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
 
       if (typefm == NULL_TREE)
        {
-         error ("no data type for mode %<%s%>", p);
+         error ("no data type for mode %qs", p);
          return NULL_TREE;
        }
       else if (TREE_CODE (type) == ENUMERAL_TYPE)
@@ -4373,8 +4376,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
             this mode for this type.  */
          if (TREE_CODE (typefm) != INTEGER_TYPE)
            {
-             error ("cannot use mode %qs for enumeral types",
-                    GET_MODE_NAME (mode));
+             error ("cannot use mode %qs for enumeral types", p);
              return NULL_TREE;
            }
 
@@ -4383,6 +4385,12 @@ handle_mode_attribute (tree *node, tree name, tree args,
          TYPE_PRECISION (type) = TYPE_PRECISION (typefm);
          typefm = type;
        }
+      else if (TREE_CODE (type) != TREE_CODE (typefm))
+       {
+         error ("mode %qs applied to inappropriate type", p);
+         return NULL_TREE;
+       }
+
       *node = typefm;
 
       /* No need to layout the type here.  The caller should do this.  */
index 7987c0a1419c8ae46d5e903ce3b5027e7c73f487..158825450965d1b89ba070400b3ac110470602cb 100644 (file)
@@ -35,7 +35,7 @@
 #include <mmintrin.h>
 
 /* Internal data types for implementing the intrinsics.  */
-typedef int __v2sf __attribute__ ((__mode__ (__SF__), __vector_size__ (8)));
+typedef float __v2sf __attribute__ ((__vector_size__ (8)));
 
 static __inline void
 _m_femms (void)
index ecb3dea314ac56891116c6db0100f4e07e37f640..22f221b90b2b64cb8f67931cc3da1d8e96891730 100644 (file)
@@ -455,9 +455,18 @@ STATIC func_ptr __DTOR_END__[1]
 #ifdef EH_FRAME_SECTION_NAME
 /* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
    this would be the 'length' field in a real FDE.  */
-STATIC EH_FRAME_SECTION_CONST int __FRAME_END__[]
-     __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
-                    aligned(4)))
+# if __INT_MAX__ == 2147483647
+typedef int int32;
+# elif __LONG_MAX__ == 2147483647
+typedef long int32;
+# elif __SHRT_MAX__ == 2147483647
+typedef short int32;
+# else
+#  error "Missing a 4 byte integer"
+# endif
+STATIC EH_FRAME_SECTION_CONST int32 __FRAME_END__[]
+     __attribute__ ((unused, section(EH_FRAME_SECTION_NAME),
+                    aligned(sizeof(int32))))
      = { 0 };
 #endif /* EH_FRAME_SECTION_NAME */
 
diff --git a/gcc/testsuite/gcc.dg/attr-mode-1.c b/gcc/testsuite/gcc.dg/attr-mode-1.c
new file mode 100644 (file)
index 0000000..e60d01b
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR c/17384 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+typedef struct __attribute__((mode(SI))) { 
+    unsigned    INT0    :1, 
+                RES0    :1, 
+                        :6, 
+                INT1    :1, 
+                RES1    :1, 
+                        :6, 
+                        :16; 
+} MCR;  /* { dg-error "inappropriate type" } */