[PATCH] Fix PR c/18282 - 3.4.3 regression from 3.4.2, 3.3.x and 4.0

Jakub Jelinek jakub@redhat.com
Tue Nov 2 22:07:00 GMT 2004


Hi!

PR c/17384 patch broke code used e.g. by DHCP - using
mode attribute (with integral mode) on enums.
The following patch just makes that accepted, doesn't try to change what
GCC used to do in such cases with enum's type (unlike GCC 4.0 which 
deals with TYPE_PRECISION etc.).
Is this ok for 3.4.3 if bootstrap/regtesting succeeds?

2004-11-02  Jakub Jelinek  <jakub@redhat.com>

	PR c/18282
	* c-common.c (handle_mode_attribute): Allow mode attribute
	on enums when the mode is integral.

--- gcc/c-common.c.jj	2004-10-29 15:17:50.000000000 +0200
+++ gcc/c-common.c	2004-11-02 22:57:23.824108588 +0100
@@ -4765,6 +4765,15 @@ handle_mode_attribute (tree *node, tree 
 							mode);
 	      *node = ptr_type;
 	    }
+          else if (TREE_CODE (type) == ENUMERAL_TYPE)
+            {
+	      if (TREE_CODE (typefm) != INTEGER_TYPE)
+		{
+		  error ("cannot use mode `%s' for enumeral types", p);
+		  return NULL_TREE;
+		}
+	      *node = typefm;
+	    }
 	  else if (VECTOR_MODE_P (mode)
 		   ? TREE_CODE (type) != TREE_CODE (TREE_TYPE (typefm))
 		   : TREE_CODE (type) != TREE_CODE (typefm))
--- gcc/testsuite/gcc.c-torture/compile/20041102-1.c.jj	2004-11-02 23:01:42.022223483 +0100
+++ gcc/testsuite/gcc.c-torture/compile/20041102-1.c	2004-11-02 23:00:55.000000000 +0100
@@ -0,0 +1,5 @@
+/* PR c/18282 */
+typedef enum { B1 = 1, B2 = 2, B4 = 4, B8 = 8, B16 = 16 } B;
+
+B __attribute__ ((mode (QI))) bqi;
+B __attribute__ ((mode (word))) bword;

	Jakub



More information about the Gcc-patches mailing list