diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2002-07-03 02:41:34 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2002-07-03 02:41:34 +0000 |
commit | 622d373136e1c847532de2ec61aff8334e5f46da (patch) | |
tree | a69a06c021b85c28921ce3c2d3d47eedb700c92c /gcc/c-parse.in | |
parent | 9bb46191b454e5d8b7b7be1bad7403c4139b591b (diff) | |
download | gcc-622d373136e1c847532de2ec61aff8334e5f46da.tar.gz |
c-parse.in (parsing_iso_function_signature): New variable.
gcc:
* c-parse.in (parsing_iso_function_signature): New variable.
(extdef_1): New, copied from...
(extdef): ... here. Reset parsing_iso_function_signature.
(old_style_parm_decls): Reset parsing_iso_function_signature.
(old_style_parm_decls_1): New, copied from old_style_parm_decls.
Warn about ISO C style function definitions.
(nested_function, notype_nested_function): Reset
parsing_iso_function_signature.
(parmlist_2): Set parsing_iso_function_signature.
* doc/invoke.texi (-Wtraditional): Document new behavior.
gcc/testsuite:
* gcc.dg/cpp/tr-warn2.c: Use traditional C style function definitions.
* gcc.dg/wtr-aggr-init-1.c: Likewise.
* gcc.dg/wtr-conversion-1.c: Likewise.
* gcc.dg/wtr-escape-1.c: Likewise.
* gcc.dg/wtr-int-type-1.c: Likewise.
* gcc.dg/wtr-label-1.c: Likewise.
* gcc.dg/wtr-static-1.c: Likewise.
* gcc.dg/wtr-strcat-1.c: Likewise.
* gcc.dg/wtr-suffix-1.c: Likewise.
* gcc.dg/wtr-switch-1.c: Likewise.
* gcc.dg/wtr-unary-plus-1.c: Likewise.
* gcc.dg/wtr-union-init-1.c: Likewise.
* gcc.dg/wtr-union-init-2.c: Likewise.
* gcc.dg/wtr-union-init-3.c: Likewise.
* gcc.dg/wtr-func-def-1.c: New test.
From-SVN: r55201
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 6ce9a2e9516..2a948328f73 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -331,6 +331,8 @@ ifc #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */ end ifc +static bool parsing_iso_function_signature; + /* Tell yyparse how to print a token's value, if yydebug is set. */ #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL) @@ -382,6 +384,10 @@ extdefs: ; extdef: + extdef_1 + { parsing_iso_function_signature = false; } /* Reset after any external definition. */ + +extdef_1: fndef | datadef ifobjc @@ -787,7 +793,19 @@ objc_string: end ifobjc old_style_parm_decls: + old_style_parm_decls_1 + { + parsing_iso_function_signature = false; /* Reset after decls. */ + } + +old_style_parm_decls_1: /* empty */ + { + if (warn_traditional && !in_system_header + && parsing_iso_function_signature) + warning ("traditional C rejects ISO C style function definitions"); + parsing_iso_function_signature = false; /* Reset after warning. */ + } | datadecls | datadecls ELLIPSIS /* ... is used here to indicate a varargs function. */ @@ -1586,6 +1604,7 @@ nested_function: pop_function_context (); YYERROR1; } + parsing_iso_function_signature = false; /* Don't warn about nested functions. */ } old_style_parm_decls { store_parm_decls (); } @@ -1616,6 +1635,7 @@ notype_nested_function: pop_function_context (); YYERROR1; } + parsing_iso_function_signature = false; /* Don't warn about nested functions. */ } old_style_parm_decls { store_parm_decls (); } @@ -2540,7 +2560,9 @@ parmlist_2: /* empty */ error ("ISO C requires a named argument before `...'"); } | parms - { $$ = get_parm_info (1); } + { $$ = get_parm_info (1); + parsing_iso_function_signature = true; + } | parms ',' ELLIPSIS { $$ = get_parm_info (0); } ; |