This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Binutils Port - Infineon xc16x family.


On 03 March 2006 15:19, Shrirang Khishti wrote:

> Hi Nick
> 
>   Thanks for the change suggested by you.
>   I checked the Patch you have send and , its working fine so you can
> add it to the sources.
> One confusing thing is that it is not working if use "Return NULL" in
> both the conditions.

  But if you remove the braces, that's the same thing as returning NULL in
both cases, and you said that that works (because that's what Nick's patch
does), and there /really/ should not be a difference between this:

   static const char *
   parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	    const char **strp,
	    int opindex ATTRIBUTE_UNUSED,
	    long *valuep ATTRIBUTE_UNUSED)
   {
     if (**strp == '#')
       {
         ++*strp;
         return NULL;
       }
     return NULL;
   }

and this:

   static const char *
   parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	    const char **strp,
	    int opindex ATTRIBUTE_UNUSED,
	    long *valuep ATTRIBUTE_UNUSED)
   {
     if (**strp == '#')
         ++*strp;
     return NULL;
   }


  It's not valid C code to try and fall off the end of a non-void function
without returning a proper value, so your original code:

>  Code1:	 "If ( condition  ) 
>  		 {
>  		 Str ++ ;
>   	 	 Return NULL;
>  		 }"

or in other words:

   static const char *
   parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
	    const char **strp,
	    int opindex ATTRIBUTE_UNUSED,
	    long *valuep ATTRIBUTE_UNUSED)
   {
     if (**strp == '#')
       {
         ++*strp;
         return NULL;
       }
   }

simply /has/ to be incorrect.  Looking back at your original patch, I see that
you had some code in the else clause that once returned a value, but you've
commented it out:

+/* Handle '#' prefixes (i.e. skip over them).  */
+static const char *parse_hash (cd, strp, opindex, valuep)
+     CGEN_CPU_DESC cd ATTRIBUTE_UNUSED;
+     const char **strp;
+     int opindex ATTRIBUTE_UNUSED;
+     unsigned long *valuep ATTRIBUTE_UNUSED;
+{
+     if (**strp == '#')
+     {
+         ++*strp;
+     	 return NULL;
+     }
+   //  else
+   //      return cgen_parse_unsigned_integer (cd, strp, opindex, valuep);
+}


  Whenever that "else return cgen_parse_unsigned_integer ..." bit got
commented out, someone should have arranged to return a different value
instead.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]