Add const qualifiers at various places.
[binutils-gdb.git] / gas / config / tc-cr16.c
index 2df4e346099e8ef0f354828817332511bdefb80a..b3e0924f784a2ce38b779de41f06f944badb6c66 100644 (file)
@@ -1,6 +1,5 @@
 /* tc-cr16.c -- Assembler code for the CR16 CPU core.
-   Copyright 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2007-2016 Free Software Foundation, Inc.
 
    Contributed by M R Swami Reddy <MR.Swami.Reddy@nsc.com>
 
@@ -207,7 +206,7 @@ l_cons (int nbytes)
                   return;
                 }
 
-              value |= ((~(-1 << width) & exp.X_add_number)
+              value |= ((~(-(1 << width)) & exp.X_add_number)
                         << ((BITS_PER_CHAR * nbytes) - bits_available));
 
               if ((bits_available -= width) == 0
@@ -336,7 +335,7 @@ get_register_pair (char *reg_name)
   char tmp_rp[16]="\0";
 
   /* Add '(' and ')' to the reg pair, if its not present.  */
-  if (reg_name[0] != '(') 
+  if (reg_name[0] != '(')
     {
       tmp_rp[0] = '(';
       strcat (tmp_rp, reg_name);
@@ -350,7 +349,7 @@ get_register_pair (char *reg_name)
     return rreg->value.reg_val;
 
   return nullregister;
-} 
+}
 
 /* Get the index register 'reg_name'.  */
 
@@ -493,10 +492,9 @@ cr16_force_relocation (fixS *fix)
 /* Record a fixup for a cons expression.  */
 
 void
-cr16_cons_fix_new (fragS *frag, int offset, int len, expressionS *exp)
+cr16_cons_fix_new (fragS *frag, int offset, int len, expressionS *exp,
+                  bfd_reloc_code_real_type rtype)
 {
-  int rtype = BFD_RELOC_UNUSED;
-
   switch (len)
     {
     default: rtype = BFD_RELOC_NONE; break;
@@ -522,12 +520,11 @@ arelent *
 tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
 {
   arelent * reloc;
-  bfd_reloc_code_real_type code;
 
   /* If symbols are local and resolved, then no relocation needed.  */
-  if ( ((fixP->fx_addsy) 
+  if ( ((fixP->fx_addsy)
         && (S_GET_SEGMENT (fixP->fx_addsy) == absolute_section))
-       || ((fixP->fx_subsy) 
+       || ((fixP->fx_subsy)
           && (S_GET_SEGMENT (fixP->fx_subsy) == absolute_section)))
      return NULL;
 
@@ -582,14 +579,12 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS * fixP)
            && GOT_symbol
           && fixP->fx_addsy == GOT_symbol)
        {
-           code = BFD_RELOC_CR16_GOT_REGREL20;
            reloc->addend = fixP->fx_offset = reloc->address;
        }
       else if ((fixP->fx_r_type == BFD_RELOC_CR16_GOTC_REGREL20)
            && GOT_symbol
           && fixP->fx_addsy == GOT_symbol)
        {
-           code = BFD_RELOC_CR16_GOTC_REGREL20;
            reloc->addend = fixP->fx_offset = reloc->address;
        }
 #endif
@@ -937,7 +932,7 @@ process_label_constant (char *str, ins * cr16_ins)
       else if (strneq (input_line_pointer, "@GOT", 4)
           || strneq (input_line_pointer, "@got", 4))
        {
-          if ((strneq (input_line_pointer, "+", 1)) 
+          if ((strneq (input_line_pointer, "+", 1))
               || (strneq (input_line_pointer, "-", 1)))
            as_warn (_("GOT bad expression with %s."), input_line_pointer);
 
@@ -1549,28 +1544,25 @@ is_bcc_insn (char * op)
 
 /* Cinv instruction requires special handling.  */
 
-static int
+static void
 check_cinv_options (char * operand)
 {
   char *p = operand;
-  int i_used = 0, u_used = 0, d_used = 0;
 
   while (*++p != ']')
     {
-      if (*p == ',' || *p == ' ')
-        continue;
-
-      else if (*p == 'i')
-        i_used = 1;
-      else if (*p == 'u')
-        u_used = 1;
-      else if (*p == 'd')
-        d_used = 1;
-      else
-        as_bad (_("Illegal `cinv' parameter: `%c'"), *p);
+      switch (*p)
+       {
+       case ',':
+       case ' ':
+       case 'i':
+       case 'u':
+       case 'd':
+         break;
+       default:
+         as_bad (_("Illegal `cinv' parameter: `%c'"), *p);
+       }
     }
-
-  return 0;
 }
 
 /* Retrieve the opcode image of a given register pair.
@@ -2465,7 +2457,7 @@ print_insn (ins *insn)
              int size;
 
              reloc_howto = bfd_reloc_type_lookup (stdoutput, insn->rtype);
-  
+
              if (!reloc_howto)
                abort ();
 
@@ -2504,7 +2496,6 @@ md_assemble (char *op)
 {
   ins cr16_ins;
   char *param, param1[32];
-  char c;
 
   /* Reset global variables for a new instruction.  */
   reset_vars (op);
@@ -2512,7 +2503,6 @@ md_assemble (char *op)
   /* Strip the mnemonic.  */
   for (param = op; *param != 0 && !ISSPACE (*param); param++)
     ;
-  c = *param;
   *param++ = '\0';
 
   /* bCC instuctions and adjust the mnemonic by adding extra white spaces.  */