c-typeck.c (c_alignof): Error on incomplete types.
authorStan Shebs <shebs@apple.com>
Tue, 14 Mar 2000 08:24:21 +0000 (08:24 +0000)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 14 Mar 2000 08:24:21 +0000 (00:24 -0800)
        * c-typeck.c (c_alignof): Error on incomplete types.
        * extend.texi (Alignment): Document this.

From-SVN: r32522

gcc/ChangeLog
gcc/c-typeck.c
gcc/extend.texi

index 2559e36c5f42b3efb7fea6dbddd0b159bdef386f..74499929f3dae157e58d98499c1e2fd4e4b3f160 100644 (file)
@@ -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.
index 2cac8875ca5573c978239ae2ee994afccb0ed8a3..886e07102f6751a48276cc17b4c05c464dae63ce 100644 (file)
@@ -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);
 }
 \f
index fa13154d7feb1e8834dbdfec76f87ac531ef07c1..475241aadde3ae8e422157790d72c3680ecf956e 100644 (file)
@@ -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.