diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 81db24fb8e1..f4a7d8e13eb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2000-06-26 Joseph S. Myers + + * c-decl.c (grokdeclarator): Don't warn about `long long' in C99. + Make warnings about implicit int be pedwarns in C99. Don't warn + about duplicate type qualifiers in C99. + (start_function): Make warning about implict int return type be a + pedwarn in C99. + * c-lex.c (yylex): Don't warn about `long long' in C99. + * c-typeck.c (c_expand_return): In C99, always pedwarn about + `return' with no value in function returning non-void. + +2000-06-26 Richard Henderson + + * c-typeck.c (pedwarn_c99): New. + * diagnostic.c (verror, vwarning, vpedwarn): Export. + * toplev.h: Prototype them. + 2000-06-26 J. David Anglin * c-typeck.c (digest_init): Return error_mark_node node when @@ -11,7 +28,7 @@ 2000-06-25 Theodore Papadopoulo - * gengenrtl.c (special_rtx): Fix typo in comment. + * gengenrtl.c (special_rtx): Fix typo in comment. 2000-06-26 Michael Hayes @@ -50,7 +67,7 @@ 2000-06-25 John David Anglin - * config/vax/vax.h (TARGET_SWITCHES): Provide descriptions. + * config/vax/vax.h (TARGET_SWITCHES): Provide descriptions. 2000-06-25 Herman A.J. ten Brugge diff --git a/gcc/c-decl.c b/gcc/c-decl.c index cabc4c197e2..54acc37b459 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -3955,7 +3955,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) error ("`long long long' is too long for GCC"); else { - if (pedantic && ! in_system_header && warn_long_long) + if (pedantic && !flag_isoc99 && ! in_system_header + && warn_long_long) pedwarn ("ANSI C does not support `long long'"); longlong = 1; } @@ -4018,7 +4019,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) if ((warn_implicit_int || warn_return_type) && funcdef_flag) warn_about_return_type = 1; else if (warn_implicit_int || flag_isoc99) - warning ("type defaults to `int' in declaration of `%s'", name); + pedwarn_c99 ("type defaults to `int' in declaration of `%s'", name); } defaulted_int = 1; @@ -4168,11 +4169,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) restrictp = !! (specbits & 1 << (int) RID_RESTRICT) + TYPE_RESTRICT (type); volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type); inlinep = !! (specbits & (1 << (int) RID_INLINE)); - if (constp > 1) + if (constp > 1 && ! flag_isoc99) pedwarn ("duplicate `const'"); - if (restrictp > 1) + if (restrictp > 1 && ! flag_isoc99) pedwarn ("duplicate `restrict'"); - if (volatilep > 1) + if (volatilep > 1 && ! flag_isoc99) pedwarn ("duplicate `volatile'"); if (! flag_gen_aux_info && (TYPE_QUALS (type))) type = TYPE_MAIN_VARIANT (type); @@ -4526,11 +4527,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) error ("invalid type modifier within pointer declarator"); } } - if (constp > 1) + if (constp > 1 && ! flag_isoc99) pedwarn ("duplicate `const'"); - if (volatilep > 1) + if (volatilep > 1 && ! flag_isoc99) pedwarn ("duplicate `volatile'"); - if (restrictp > 1) + if (restrictp > 1 && ! flag_isoc99) pedwarn ("duplicate `restrict'"); type_quals = ((constp ? TYPE_QUAL_CONST : 0) @@ -5743,7 +5744,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes) if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1)))) { - error ("return-type is an incomplete type"); + error ("return type is an incomplete type"); /* Make it return void instead. */ TREE_TYPE (decl1) = build_function_type (void_type_node, @@ -5751,7 +5752,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes) } if (warn_about_return_type) - warning ("return-type defaults to `int'"); + pedwarn_c99 ("return type defaults to `int'"); /* Save the parm names or decls from this function's declarator where store_parm_decls will find them. */ diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 41a88b0e667..8b917ff56a2 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -1781,7 +1781,8 @@ yylex () { if (spec_long_long) error ("three `l's in integer constant"); - else if (pedantic && ! in_system_header && warn_long_long) + else if (pedantic && ! flag_isoc99 + && ! in_system_header && warn_long_long) pedwarn ("ANSI C forbids long long integer constants"); spec_long_long = 1; } diff --git a/gcc/c-tree.h b/gcc/c-tree.h index 7c86e2676d0..474aaaec1d5 100644 --- a/gcc/c-tree.h +++ b/gcc/c-tree.h @@ -297,6 +297,8 @@ extern void c_expand_asm_operands PARAMS ((tree, tree, tree, const char *, int)); extern void c_expand_return PARAMS ((tree)); extern tree c_expand_start_case PARAMS ((tree)); +extern void pedwarn_c99 PARAMS ((const char *, ...)) + ATTRIBUTE_PRINTF_1; /* in c-iterate.c */ extern void init_iterators PARAMS ((void)); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index cd9da659e53..c882dd90386 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -6623,8 +6623,9 @@ c_expand_return (retval) if (!retval) { current_function_returns_null = 1; - if (warn_return_type && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE) - warning ("`return' with no value, in function returning non-void"); + if ((warn_return_type || flag_isoc99) + && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE) + pedwarn_c99 ("`return' with no value, in function returning non-void"); expand_null_return (); } else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) @@ -6752,3 +6753,27 @@ c_expand_start_case (exp) return exp; } + +/* Issue an ISO C99 pedantic warning MSGID. */ + +void +pedwarn_c99 VPARAMS ((const char *msgid, ...)) +{ +#ifndef ANSI_PROTOTYPES + const char *msgid; +#endif + va_list ap; + + VA_START (ap, msgid); + +#ifndef ANSI_PROTOTYPES + msgid = va_arg (ap, const char *); +#endif + + if (flag_isoc99) + vpedwarn (msgid, ap); + else + vwarning (msgid, ap); + + va_end (ap); +} diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 36d4b403745..564c4883cf6 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -64,14 +64,11 @@ static void v_error_with_file_and_line PARAMS ((const char *, int, const char *, va_list)); static void v_error_with_decl PARAMS ((tree, const char *, va_list)); static void v_error_for_asm PARAMS ((rtx, const char *, va_list)); -static void verror PARAMS ((const char *, va_list)); static void vfatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN; static void v_warning_with_file_and_line PARAMS ((const char *, int, const char *, va_list)); static void v_warning_with_decl PARAMS ((tree, const char *, va_list)); static void v_warning_for_asm PARAMS ((rtx, const char *, va_list)); -static void vwarning PARAMS ((const char *, va_list)); -static void vpedwarn PARAMS ((const char *, va_list)); static void v_pedwarn_with_decl PARAMS ((tree, const char *, va_list)); static void v_pedwarn_with_file_and_line PARAMS ((const char *, int, const char *, va_list)); @@ -858,7 +855,7 @@ v_error_for_asm (insn, msgid, ap) /* Report an error at the current line number. */ -static void +void verror (msgid, ap) const char *msgid; va_list ap; @@ -946,7 +943,7 @@ v_warning_for_asm (insn, msgid, ap) /* Report a warning at the current line number. */ -static void +void vwarning (msgid, ap) const char *msgid; va_list ap; @@ -957,7 +954,7 @@ vwarning (msgid, ap) /* These functions issue either warnings or errors depending on -pedantic-errors. */ -static void +void vpedwarn (msgid, ap) const char *msgid; va_list ap; diff --git a/gcc/toplev.h b/gcc/toplev.h index 952d3631bb3..dd359f770a0 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -70,10 +70,13 @@ extern void _fatal_insn PARAMS ((const char *, #endif extern void warning PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; +extern void vwarning PARAMS ((const char *, va_list)); extern void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; +extern void verror PARAMS ((const char *, va_list)); extern void pedwarn PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1; +extern void vpedwarn PARAMS ((const char *, va_list)); extern void pedwarn_with_file_and_line PARAMS ((const char *, int, const char *, ...)) ATTRIBUTE_PRINTF_3;