* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147989
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
do
{
- code = va_arg (ap, enum tree_code);
+ code = (enum tree_code) va_arg (ap, int);
switch (code)
{
case 0:
do
{
- code = va_arg (ap, enum tree_code);
+ code = (enum tree_code) va_arg (ap, int);
switch (code)
{
case 0:
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 %<)%>");
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,
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. */
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);
+}
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. */
+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
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)
+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
--- /dev/null
+/* { 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 } */