Commit 903f51d9 by Richard Henderson

[multiple changes]

2000-06-26  Joseph S. Myers  <jsm28@cam.ac.uk>

        * 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  <rth@cygnus.com>

        * c-typeck.c (pedwarn_c99): New.
        * diagnostic.c (verror, vwarning, vpedwarn): Export.
        * toplev.h: Prototype them.

From-SVN: r34713
parent 774d2baf
2000-06-26 Joseph S. Myers <jsm28@cam.ac.uk>
* 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 <rth@cygnus.com>
* c-typeck.c (pedwarn_c99): New.
* diagnostic.c (verror, vwarning, vpedwarn): Export.
* toplev.h: Prototype them.
2000-06-26 J. David Anglin <dave@hiauly1.hia.nrc.ca> 2000-06-26 J. David Anglin <dave@hiauly1.hia.nrc.ca>
* c-typeck.c (digest_init): Return error_mark_node node when * c-typeck.c (digest_init): Return error_mark_node node when
......
...@@ -3955,7 +3955,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -3955,7 +3955,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
error ("`long long long' is too long for GCC"); error ("`long long long' is too long for GCC");
else 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'"); pedwarn ("ANSI C does not support `long long'");
longlong = 1; longlong = 1;
} }
...@@ -4018,7 +4019,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4018,7 +4019,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
if ((warn_implicit_int || warn_return_type) && funcdef_flag) if ((warn_implicit_int || warn_return_type) && funcdef_flag)
warn_about_return_type = 1; warn_about_return_type = 1;
else if (warn_implicit_int || flag_isoc99) 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; defaulted_int = 1;
...@@ -4168,11 +4169,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4168,11 +4169,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
restrictp = !! (specbits & 1 << (int) RID_RESTRICT) + TYPE_RESTRICT (type); restrictp = !! (specbits & 1 << (int) RID_RESTRICT) + TYPE_RESTRICT (type);
volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type); volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
inlinep = !! (specbits & (1 << (int) RID_INLINE)); inlinep = !! (specbits & (1 << (int) RID_INLINE));
if (constp > 1) if (constp > 1 && ! flag_isoc99)
pedwarn ("duplicate `const'"); pedwarn ("duplicate `const'");
if (restrictp > 1) if (restrictp > 1 && ! flag_isoc99)
pedwarn ("duplicate `restrict'"); pedwarn ("duplicate `restrict'");
if (volatilep > 1) if (volatilep > 1 && ! flag_isoc99)
pedwarn ("duplicate `volatile'"); pedwarn ("duplicate `volatile'");
if (! flag_gen_aux_info && (TYPE_QUALS (type))) if (! flag_gen_aux_info && (TYPE_QUALS (type)))
type = TYPE_MAIN_VARIANT (type); type = TYPE_MAIN_VARIANT (type);
...@@ -4526,11 +4527,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4526,11 +4527,11 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
error ("invalid type modifier within pointer declarator"); error ("invalid type modifier within pointer declarator");
} }
} }
if (constp > 1) if (constp > 1 && ! flag_isoc99)
pedwarn ("duplicate `const'"); pedwarn ("duplicate `const'");
if (volatilep > 1) if (volatilep > 1 && ! flag_isoc99)
pedwarn ("duplicate `volatile'"); pedwarn ("duplicate `volatile'");
if (restrictp > 1) if (restrictp > 1 && ! flag_isoc99)
pedwarn ("duplicate `restrict'"); pedwarn ("duplicate `restrict'");
type_quals = ((constp ? TYPE_QUAL_CONST : 0) type_quals = ((constp ? TYPE_QUAL_CONST : 0)
...@@ -5743,7 +5744,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes) ...@@ -5743,7 +5744,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes)
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1)))) 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. */ /* Make it return void instead. */
TREE_TYPE (decl1) TREE_TYPE (decl1)
= build_function_type (void_type_node, = build_function_type (void_type_node,
...@@ -5751,7 +5752,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes) ...@@ -5751,7 +5752,7 @@ start_function (declspecs, declarator, prefix_attributes, attributes)
} }
if (warn_about_return_type) 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 /* Save the parm names or decls from this function's declarator
where store_parm_decls will find them. */ where store_parm_decls will find them. */
......
...@@ -1781,7 +1781,8 @@ yylex () ...@@ -1781,7 +1781,8 @@ yylex ()
{ {
if (spec_long_long) if (spec_long_long)
error ("three `l's in integer constant"); 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"); pedwarn ("ANSI C forbids long long integer constants");
spec_long_long = 1; spec_long_long = 1;
} }
......
...@@ -297,6 +297,8 @@ extern void c_expand_asm_operands PARAMS ((tree, tree, tree, ...@@ -297,6 +297,8 @@ extern void c_expand_asm_operands PARAMS ((tree, tree, tree,
const char *, int)); const char *, int));
extern void c_expand_return PARAMS ((tree)); extern void c_expand_return PARAMS ((tree));
extern tree c_expand_start_case PARAMS ((tree)); extern tree c_expand_start_case PARAMS ((tree));
extern void pedwarn_c99 PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1;
/* in c-iterate.c */ /* in c-iterate.c */
extern void init_iterators PARAMS ((void)); extern void init_iterators PARAMS ((void));
......
...@@ -6623,8 +6623,9 @@ c_expand_return (retval) ...@@ -6623,8 +6623,9 @@ c_expand_return (retval)
if (!retval) if (!retval)
{ {
current_function_returns_null = 1; current_function_returns_null = 1;
if (warn_return_type && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE) if ((warn_return_type || flag_isoc99)
warning ("`return' with no value, in function returning non-void"); && valtype != 0 && TREE_CODE (valtype) != VOID_TYPE)
pedwarn_c99 ("`return' with no value, in function returning non-void");
expand_null_return (); expand_null_return ();
} }
else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE) else if (valtype == 0 || TREE_CODE (valtype) == VOID_TYPE)
...@@ -6752,3 +6753,27 @@ c_expand_start_case (exp) ...@@ -6752,3 +6753,27 @@ c_expand_start_case (exp)
return 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);
}
...@@ -64,14 +64,11 @@ static void v_error_with_file_and_line PARAMS ((const char *, int, ...@@ -64,14 +64,11 @@ static void v_error_with_file_and_line PARAMS ((const char *, int,
const char *, va_list)); const char *, va_list));
static void v_error_with_decl PARAMS ((tree, 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 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 vfatal PARAMS ((const char *, va_list)) ATTRIBUTE_NORETURN;
static void v_warning_with_file_and_line PARAMS ((const char *, int, static void v_warning_with_file_and_line PARAMS ((const char *, int,
const char *, va_list)); const char *, va_list));
static void v_warning_with_decl PARAMS ((tree, 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 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_decl PARAMS ((tree, const char *, va_list));
static void v_pedwarn_with_file_and_line PARAMS ((const char *, int, static void v_pedwarn_with_file_and_line PARAMS ((const char *, int,
const char *, va_list)); const char *, va_list));
...@@ -858,7 +855,7 @@ v_error_for_asm (insn, msgid, ap) ...@@ -858,7 +855,7 @@ v_error_for_asm (insn, msgid, ap)
/* Report an error at the current line number. */ /* Report an error at the current line number. */
static void void
verror (msgid, ap) verror (msgid, ap)
const char *msgid; const char *msgid;
va_list ap; va_list ap;
...@@ -946,7 +943,7 @@ v_warning_for_asm (insn, msgid, ap) ...@@ -946,7 +943,7 @@ v_warning_for_asm (insn, msgid, ap)
/* Report a warning at the current line number. */ /* Report a warning at the current line number. */
static void void
vwarning (msgid, ap) vwarning (msgid, ap)
const char *msgid; const char *msgid;
va_list ap; va_list ap;
...@@ -957,7 +954,7 @@ vwarning (msgid, ap) ...@@ -957,7 +954,7 @@ vwarning (msgid, ap)
/* These functions issue either warnings or errors depending on /* These functions issue either warnings or errors depending on
-pedantic-errors. */ -pedantic-errors. */
static void void
vpedwarn (msgid, ap) vpedwarn (msgid, ap)
const char *msgid; const char *msgid;
va_list ap; va_list ap;
......
...@@ -70,10 +70,13 @@ extern void _fatal_insn PARAMS ((const char *, ...@@ -70,10 +70,13 @@ extern void _fatal_insn PARAMS ((const char *,
#endif #endif
extern void warning PARAMS ((const char *, ...)) extern void warning PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1; ATTRIBUTE_PRINTF_1;
extern void vwarning PARAMS ((const char *, va_list));
extern void error PARAMS ((const char *, ...)) extern void error PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1; ATTRIBUTE_PRINTF_1;
extern void verror PARAMS ((const char *, va_list));
extern void pedwarn PARAMS ((const char *, ...)) extern void pedwarn PARAMS ((const char *, ...))
ATTRIBUTE_PRINTF_1; ATTRIBUTE_PRINTF_1;
extern void vpedwarn PARAMS ((const char *, va_list));
extern void pedwarn_with_file_and_line PARAMS ((const char *, int, extern void pedwarn_with_file_and_line PARAMS ((const char *, int,
const char *, ...)) const char *, ...))
ATTRIBUTE_PRINTF_3; ATTRIBUTE_PRINTF_3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment