diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-08-09 19:52:35 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-08-09 19:52:35 +0000 |
commit | fa6ddf2354750ce657590f07e89e1153c2077b03 (patch) | |
tree | 642699475c334e9848542f89bced5ff0c706e4ed | |
parent | 993412fa6275aabe1ff0da37d2291d406d58bfb0 (diff) | |
download | ppe42-gcc-fa6ddf2354750ce657590f07e89e1153c2077b03.tar.gz ppe42-gcc-fa6ddf2354750ce657590f07e89e1153c2077b03.zip |
* c-typeck.c (process_init_element): For -Wtraditional, warn about
initialization of unions.
* invoke.texi (-Wtraditional): Document new behavior.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35595 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-typeck.c | 9 | ||||
-rw-r--r-- | gcc/invoke.texi | 7 |
3 files changed, 23 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f040ed8ffc9..2ff8a183c81 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2000-08-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * c-typeck.c (process_init_element): For -Wtraditional, warn about + initialization of unions. + + * invoke.texi (-Wtraditional): Document new behavior. + 2000-08-09 Zack Weinberg <zack@wolery.cumb.org> * configure.in (--enable-c-cpplib): Uncomment. Use AC_DEFINE diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 0adc24a39eb..66ec40e3034 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -6400,6 +6400,15 @@ process_init_element (value) fieldtype = TYPE_MAIN_VARIANT (fieldtype); fieldcode = TREE_CODE (fieldtype); + /* Warn that traditional C rejects initialization of unions. + We skip the warning if the value is zero. This is done + under the assumption that the zero initializer in user + code appears conditioned on e.g. __STDC__ to avoid + "missing initializer" warnings and relies on default + initialization to zero in the traditional C case. */ + if (warn_traditional && !integer_zerop (value)) + warning ("traditional C rejects initialization of unions"); + /* Accept a string constant to initialize a subarray. */ if (value != 0 && fieldcode == ARRAY_TYPE diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 487e95e16c4..a1096f1d274 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -1831,6 +1831,13 @@ Initialization of automatic aggregates. @item Identifier conflicts with labels. Traditional C lacks a separate namespace for labels. + +@item +Initialization of unions. If the initializer is zero, the warning is +omitted. This is done under the assumption that the zero initializer in +user code appears conditioned on e.g. @code{__STDC__} to avoid missing +initializer warnings and relies on default initialization to zero in the +traditional C case. @end itemize @item -Wundef |