diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9ea747dcf1f78f7e0134b8025cadfd0bafcba9e1..27b488216c917b28372eecbb47bd4d0901796bd3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-01-13  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/34601
+	* emit-rtl.c (set_reg_attrs_for_decl_rtl): Use DECL_MODE
+	instead of TYPE_MODE to deal with calls from expand_one_error_var.
+
 2008-01-13  Uros Bizjak  <ubizjak@gmail.com>
 
 	* gcse.c (cprop_jump): Call validate_unshare_change instead of
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 5a2aede40ddc740601896073da727c37d5182cc7..bef4d58f53d03419be4b4acc3fa67979c9c99c49 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1006,7 +1006,7 @@ set_reg_attrs_for_decl_rtl (tree t, rtx x)
   if (REG_P (x))
     REG_ATTRS (x)
       = get_reg_attrs (t, byte_lowpart_offset (GET_MODE (x),
-					       TYPE_MODE (TREE_TYPE (t))));
+					       DECL_MODE (t)));
   if (GET_CODE (x) == CONCAT)
     {
       if (REG_P (XEXP (x, 0)))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b067970ec88dc3ae2b7dd04ab0a84ac0f81615dd..521407af5acf5e7af2165868fc2535099f9fd86d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-13  Richard Guenther  <rguenther@suse.de>
+
+	PR middle-end/34601
+	* gcc.dg/noncompile/incomplete-4.c: New testcase.
+
 2008-01-13  Jan Hubicka  <jh@suse.cz>
 
 	PR middle-end/32135
diff --git a/gcc/testsuite/gcc.dg/noncompile/incomplete-4.c b/gcc/testsuite/gcc.dg/noncompile/incomplete-4.c
new file mode 100644
index 0000000000000000000000000000000000000000..a4f47694d65b807e1e346d7332e3e4f3dc1a6acc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/incomplete-4.c
@@ -0,0 +1,4 @@
+void foo()
+{
+  enum E e; /* { dg-error "storage size" } */
+}