This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
-Wtraditional patch to detect unary plus op & automatic aggregate init
- To: gcc-patches at gcc dot gnu dot org
- Subject: -Wtraditional patch to detect unary plus op & automatic aggregate init
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Sun, 9 Jul 2000 14:24:13 -0400 (EDT)
This patch enhances -Wtraditional to detect the use of the unary plus
operator and automatic aggregate initialization. Both of these are
rejected by traditional C.
I'm midway through stage2 on i686-pc-linux-gnu and it managed to
detect the unary plus operator usage in cppexp.c:845 which is killing
sunos4 bootstraps recently. No problems so far.
Assuming bootstrap completes, okay to install?
--Kaveh
2000-07-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-parse.in (unop +): Warn about the unary plus operator for
traditional C.
* c-typeck.c (store_init_value): Warn about automatic aggregate
initialization for traditional C.
* invoke.texi (-Wtraditional): Document new warnings.
diff -rup ../egcs-CVS20000709/gcc/c-parse.in egcs-CVS20000709/gcc/c-parse.in
--- ../egcs-CVS20000709/gcc/c-parse.in Tue Jun 20 10:39:20 2000
+++ egcs-CVS20000709/gcc/c-parse.in Sun Jul 9 12:38:47 2000
@@ -411,7 +411,12 @@ unop: '&'
| '-'
{ $$ = NEGATE_EXPR; }
| '+'
- { $$ = CONVERT_EXPR; }
+ { $$ = CONVERT_EXPR;
+ifc
+ if (warn_traditional)
+ warning ("traditional C rejects the unary plus operator");
+end ifc
+ }
| PLUSPLUS
{ $$ = PREINCREMENT_EXPR; }
| MINUSMINUS
diff -rup ../egcs-CVS20000709/gcc/c-typeck.c egcs-CVS20000709/gcc/c-typeck.c
--- ../egcs-CVS20000709/gcc/c-typeck.c Mon Jul 3 11:00:40 2000
+++ egcs-CVS20000709/gcc/c-typeck.c Sun Jul 9 12:40:52 2000
@@ -4401,6 +4401,10 @@ store_init_value (decl, init)
}
#endif
+ if (warn_traditional
+ && AGGREGATE_TYPE_P (TREE_TYPE (decl)) && ! TREE_STATIC (decl))
+ warning ("traditional C rejects automatic aggregate initialization");
+
DECL_INITIAL (decl) = value;
/* ANSI wants warnings about out-of-range constant initializers. */
diff -rup ../egcs-CVS20000709/gcc/invoke.texi egcs-CVS20000709/gcc/invoke.texi
--- ../egcs-CVS20000709/gcc/invoke.texi Thu Jul 6 07:54:23 2000
+++ egcs-CVS20000709/gcc/invoke.texi Sun Jul 9 12:48:16 2000
@@ -1824,6 +1824,12 @@ Usage of ANSI string concatenation is de
@item
A function macro appears without arguments.
+
+@item
+The unary plus operator.
+
+@item
+Initialization of automatic aggregates.
@end itemize
@item -Wundef