[Issue 7396] Indicate default alignment with 0.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 31 06:24:54 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7396



--- Comment #20 from Iain Buclaw <ibuclaw at ubuntu.com> 2012-01-31 06:24:46 PST ---
I can't seem to get git working at work. :)



(In reply to comment #16)
> 
> Yes, I agree.  My proposal was the following.
> 
> // excerpt from parse.c line 503.
> case TOKalign:
> {   unsigned n;
> 
>   s = NULL;
>   nextToken();
>   if (token.value == TOKlparen)
>   {
>     nextToken();
>     if (token.value == TOKint32v && token.uns64value > 0)
>       n = (unsigned)token.uns64value;
>     else
>     {   error("positive integer expected, not %s", token.toChars());
>         n = 1;
>     }
>     nextToken();
>     check(TOKrparen);
>   }
>   else
> -    n = global.structalign; // default
> +    n = 0; // default
> 
>   a = parseBlock();
>   s = new AlignDeclaration(n, a);
>   break;
> }
> 
> Now the compiler can test for 0 and know that default alignment is required. 
> This removes the ambiguity with the current implementation.

Daniel, to add to that:

  if (token.value == TOKlparen)
  {
    nextToken();
    if (token.value == TOKint32v && token.uns64value > 0)
+   {
+     if (token.value & (token.value - 1))
+         error("align must be a power of 2, not %s", token.toChars());
      n = (unsigned)token.uns64value;
+   }
    else
    {   error("positive integer expected, not %s", token.toChars());
        n = 1;
    }
    nextToken();
    check(TOKrparen);
  }



And in attrib.h:
 struct AlignDeclaration : AttribDeclaration
 {
-    unsigned salign;
+    unsigned salign;          // alignment in effect, must be power of 2.
+                              // 0 if using default align for target.

     AlignDeclaration(unsigned sa, Dsymbols *decl);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list