diff options
author | Stan Shebs <shebs@apple.com> | 2000-03-14 08:24:21 +0000 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2000-03-14 00:24:21 -0800 |
commit | 9d27bffe6db1773316c444e5cf1de5fa3a698dc5 (patch) | |
tree | 436c07ae50d58c69b35870f134bd22257f49ce84 /gcc | |
parent | d9420976f2ab42d24519b10b2ae8671b9aa9661b (diff) | |
download | gcc-9d27bffe6db1773316c444e5cf1de5fa3a698dc5.zip gcc-9d27bffe6db1773316c444e5cf1de5fa3a698dc5.tar.gz gcc-9d27bffe6db1773316c444e5cf1de5fa3a698dc5.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-typeck.c | 6 | ||||
-rw-r--r-- | gcc/extend.texi | 2 |
3 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2559e36..7449992 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 2cac887..886e071 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -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); } diff --git a/gcc/extend.texi b/gcc/extend.texi index fa13154..475241a 100644 --- a/gcc/extend.texi +++ b/gcc/extend.texi @@ -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. |