Hi Denis, Hi Anatoly, Hi Eric,

  The patch below fixes the current problem building gcc for the avr-elf
  toolchain by providing a local copy of the c_addr_space_name
  function.  I am not sure if the space names are correct, but at least
  this allows me to build the port.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2011-11-30  Nick Clifton  <ni...@redhat.com>

        * config/avr/avr.c (avr_c_addr_space_name): New function.
        (avr_out_lpm): Use it.
        (avr_pgm_check_var_decl): Use it.
        (avr_insert_attributes): Use it.

Index: gcc/config/avr/avr.c
===================================================================
--- gcc/config/avr/avr.c        (revision 181835)
+++ gcc/config/avr/avr.c        (working copy)
@@ -2566,7 +2566,26 @@
   return "";
 }
 
+/* c_addr_space_name() is not available when building lto1,
+   so we must provide our own version.  */
 
+static const char *
+avr_c_addr_space_name (addr_space_t as)
+{
+  switch (as)
+    {
+    case ADDR_SPACE_GENERIC: return "<gerneric>";
+    case ADDR_SPACE_PGM:     return "<program>";
+    case ADDR_SPACE_PGM1:    return "<program-1>";
+    case ADDR_SPACE_PGM2:    return "<program-2>";
+    case ADDR_SPACE_PGM3:    return "<program-3>";
+    case ADDR_SPACE_PGM4:    return "<program-4>";
+    case ADDR_SPACE_PGM5:    return "<program-5>";
+    case ADDR_SPACE_PGMX:    return "<program-X>";
+    default: gcc_unreachable ();
+    }
+}
+
 /* If PLEN == NULL: Ouput instructions to load a value from a memory location
    OP[1] in AS1 to register OP[0].
    If PLEN != 0 set *PLEN to the length in words of the instruction sequence.
@@ -2589,7 +2608,7 @@
   if (MEM_P (dest))
     {
       warning (0, "writing to address space %qs not supported",
-               c_addr_space_name (MEM_ADDR_SPACE (dest)));
+               avr_c_addr_space_name (MEM_ADDR_SPACE (dest)));
       
       return "";
     }
@@ -6919,10 +6938,10 @@
     {
       if (TYPE_P (node))
         error ("pointer targeting address space %qs must be const in %qT",
-               c_addr_space_name (as), node);
+               avr_c_addr_space_name (as), node);
       else
         error ("pointer targeting address space %qs must be const in %s %q+D",
-               c_addr_space_name (as), reason, node);
+               avr_c_addr_space_name (as), reason, node);
     }
 
   return reason == NULL;
@@ -6959,7 +6978,7 @@
           const char *reason = "__attribute__((progmem))";
 
           if (!ADDR_SPACE_GENERIC_P (as))
-            reason = c_addr_space_name (as);
+            reason = avr_c_addr_space_name (as);
           
           if (avr_log.progmem)
             avr_edump ("\n%?: %t\n%t\n", node, node0);

Reply via email to