Commit 9d27bffe by Stan Shebs Committed by Richard Henderson

c-typeck.c (c_alignof): Error on incomplete types.

        * c-typeck.c (c_alignof): Error on incomplete types.
        * extend.texi (Alignment): Document this.

From-SVN: r32522
parent d9420976
2000-03-14 Stan Shebs <shebs@apple.com>
* c-typeck.c (c_alignof): Error on incomplete types.
* extend.texi (Alignment): Document this.
2000-03-13 Zack Weinberg <zack@wolery.cumb.org>
* cppfiles.c: Include mkdeps.h.
......
......@@ -781,6 +781,12 @@ c_alignof (type)
if (code == VOID_TYPE || code == ERROR_MARK)
return size_one_node;
if (TYPE_SIZE (type) == 0)
{
error ("__alignof__ applied to an incomplete type");
return size_zero_node;
}
return size_int (TYPE_ALIGN (type) / BITS_PER_UNIT);
}
......
......@@ -1879,6 +1879,8 @@ the value of @code{__alignof__ (foo1.y)} is probably 2 or 4, the same as
@code{__alignof__ (int)}, even though the data type of @code{foo1.y}
does not itself demand any alignment.@refill
It is an error to ask for the alignment of an incomplete type.
A related feature which lets you specify the alignment of an object is
@code{__attribute__ ((aligned (@var{alignment})))}; see the following
section.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment