mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-23 18:01:22 +08:00
builtins.c (validate_gimple_arglist): Don't use va_arg with enum type.
./: * builtins.c (validate_gimple_arglist): Don't use va_arg with enum type. * calls.c (emit_library_call_value_1): Likewise. * c-typeck.c (c_build_va_arg): New function. * c-tree.h (c_build_va_arg): Declare. * c-parser.c (c_parser_postfix_expression): Call c_build_va_arg instead of build_va_arg. cp/: * error.c (cp_printer): Don't use va_arg with enum type. testsuite/: * gcc.dg/Wcxx-compat-11.c: New testcase. From-SVN: r147989
This commit is contained in:
parent
b0999b0114
commit
72b5577d91
@ -1,3 +1,14 @@
|
||||
2009-05-29 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
* builtins.c (validate_gimple_arglist): Don't use va_arg with
|
||||
enum type.
|
||||
* calls.c (emit_library_call_value_1): Likewise.
|
||||
|
||||
* c-typeck.c (c_build_va_arg): New function.
|
||||
* c-tree.h (c_build_va_arg): Declare.
|
||||
* c-parser.c (c_parser_postfix_expression): Call c_build_va_arg
|
||||
instead of build_va_arg.
|
||||
|
||||
2009-05-29 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* tree-ssa-loop-ivopts.c (strip_offset_1) <MULT_EXPR>: New case.
|
||||
|
@ -11231,7 +11231,7 @@ validate_gimple_arglist (const_gimple call, ...)
|
||||
|
||||
do
|
||||
{
|
||||
code = va_arg (ap, enum tree_code);
|
||||
code = (enum tree_code) va_arg (ap, int);
|
||||
switch (code)
|
||||
{
|
||||
case 0:
|
||||
@ -11282,7 +11282,7 @@ validate_arglist (const_tree callexpr, ...)
|
||||
|
||||
do
|
||||
{
|
||||
code = va_arg (ap, enum tree_code);
|
||||
code = (enum tree_code) va_arg (ap, int);
|
||||
switch (code)
|
||||
{
|
||||
case 0:
|
||||
|
@ -5338,6 +5338,7 @@ c_parser_postfix_expression (c_parser *parser)
|
||||
expr.value = error_mark_node;
|
||||
break;
|
||||
}
|
||||
loc = c_parser_peek_token (parser)->location;
|
||||
t1 = c_parser_type_name (parser);
|
||||
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
|
||||
"expected %<)%>");
|
||||
@ -5348,9 +5349,9 @@ c_parser_postfix_expression (c_parser *parser)
|
||||
else
|
||||
{
|
||||
tree type_expr = NULL_TREE;
|
||||
expr.value = build_va_arg (e1.value, groktypename (t1,
|
||||
&type_expr,
|
||||
NULL));
|
||||
expr.value = c_build_va_arg (e1.value,
|
||||
groktypename (t1, &type_expr, NULL),
|
||||
loc);
|
||||
if (type_expr)
|
||||
{
|
||||
expr.value = build2 (C_MAYBE_CONST_EXPR,
|
||||
|
@ -650,6 +650,7 @@ extern tree c_finish_omp_parallel (tree, tree);
|
||||
extern tree c_begin_omp_task (void);
|
||||
extern tree c_finish_omp_task (tree, tree);
|
||||
extern tree c_finish_omp_clauses (tree);
|
||||
extern tree c_build_va_arg (tree, tree, location_t);
|
||||
|
||||
/* Set to 0 at beginning of a function definition, set to 1 if
|
||||
a return statement that specifies a return value is seen. */
|
||||
|
@ -9976,3 +9976,14 @@ c_build_qualified_type (tree type, int type_quals)
|
||||
|
||||
return build_qualified_type (type, type_quals);
|
||||
}
|
||||
|
||||
/* Build a VA_ARG_EXPR for the C parser. */
|
||||
|
||||
tree
|
||||
c_build_va_arg (tree expr, tree type, location_t loc)
|
||||
{
|
||||
if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE)
|
||||
warning_at (loc, OPT_Wc___compat,
|
||||
"C++ requires promoted type, not enum type, in %<va_arg%>");
|
||||
return build_va_arg (expr, type);
|
||||
}
|
||||
|
@ -3445,7 +3445,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
|
||||
for (; count < nargs; count++)
|
||||
{
|
||||
rtx val = va_arg (p, rtx);
|
||||
enum machine_mode mode = va_arg (p, enum machine_mode);
|
||||
enum machine_mode mode = (enum machine_mode) va_arg (p, int);
|
||||
|
||||
/* We cannot convert the arg value to the mode the library wants here;
|
||||
must do it earlier where we know the signedness of the arg. */
|
||||
|
@ -1,3 +1,7 @@
|
||||
2009-05-29 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
* error.c (cp_printer): Don't use va_arg with enum type.
|
||||
|
||||
2009-05-28 Dodji Seketeli <dodji@redhat.com>
|
||||
|
||||
PR c++/39754
|
||||
|
@ -2761,8 +2761,8 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
|
||||
const char *result;
|
||||
tree t = NULL;
|
||||
#define next_tree (t = va_arg (*text->args_ptr, tree))
|
||||
#define next_tcode va_arg (*text->args_ptr, enum tree_code)
|
||||
#define next_lang va_arg (*text->args_ptr, enum languages)
|
||||
#define next_tcode ((enum tree_code) va_arg (*text->args_ptr, int))
|
||||
#define next_lang ((enum languages) va_arg (*text->args_ptr, int))
|
||||
#define next_int va_arg (*text->args_ptr, int)
|
||||
|
||||
if (precision != 0 || wide)
|
||||
|
@ -1,3 +1,7 @@
|
||||
2009-05-29 Ian Lance Taylor <iant@google.com>
|
||||
|
||||
* gcc.dg/Wcxx-compat-11.c: New testcase.
|
||||
|
||||
2009-05-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
PR fortran/40019
|
||||
|
21
gcc/testsuite/gcc.dg/Wcxx-compat-11.c
Normal file
21
gcc/testsuite/gcc.dg/Wcxx-compat-11.c
Normal file
@ -0,0 +1,21 @@
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-Wc++-compat" } */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
enum E { A };
|
||||
|
||||
extern void f2 (int);
|
||||
void
|
||||
f1 (int n, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, n);
|
||||
f2 (va_arg (ap, int));
|
||||
f2 (va_arg (ap, _Bool)); /* { dg-warning "promoted" } */
|
||||
f2 (va_arg (ap, enum E)); /* { dg-warning "promoted" } */
|
||||
}
|
||||
|
||||
/* Match extra informative notes. */
|
||||
/* { dg-message "note:" "expected" { target *-*-* } 0 } */
|
Loading…
x
Reference in New Issue
Block a user