c-decl.c (define_label): Warn about identifier conflicts with labels in traditional C.

* c-decl.c (define_label): Warn about identifier conflicts with
	labels in traditional C.

	* 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.

From-SVN: r34997
This commit is contained in:
Kaveh R. Ghazi 2000-07-12 20:15:20 +00:00 committed by Kaveh Ghazi
parent 8364301f5a
commit 895ea61453
5 changed files with 37 additions and 1 deletions

View File

@ -1,3 +1,16 @@
2000-07-12 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-decl.c (define_label): Warn about identifier conflicts with
labels in traditional C.
* 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.
2000-07-12 Gabriel Dos Reis <gdr@codesourcery.com>
* Makefile.in (c-errors.o): Fix thinko in dependency.

View File

@ -2706,6 +2706,10 @@ define_label (filename, line, name)
decl = lookup_label (name);
}
if (warn_traditional && lookup_name (name))
warning ("traditional C lacks a separate namespace for labels, identifier `%s' conflicts",
IDENTIFIER_POINTER (name));
if (DECL_INITIAL (decl) != 0)
{
error ("duplicate label `%s'", IDENTIFIER_POINTER (name));

View File

@ -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

View File

@ -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. */

View File

@ -1824,6 +1824,16 @@ Usage of ANSI string concatenation is detected.
@item
A function macro appears without arguments.
@item
The unary plus operator.
@item
Initialization of automatic aggregates.
@item
Identifier conflicts with labels. Traditional C lacks a separate
namespace for labels.
@end itemize
@item -Wundef