aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-03-31 01:52:42 -0800
committerRichard Henderson <rth@gcc.gnu.org>2002-03-31 01:52:42 -0800
commit9602f5a04b6c2a3877b8001b8ee7df74cfde4a9c (patch)
tree08485e14eaa9f1372587d43f25c3a7c01bc9dfc4 /gcc/builtins.c
parentb56bc85a40b31394439c3a29ddaf71f17654b83d (diff)
downloadgcc-9602f5a04b6c2a3877b8001b8ee7df74cfde4a9c.zip
gcc-9602f5a04b6c2a3877b8001b8ee7df74cfde4a9c.tar.gz
gcc-9602f5a04b6c2a3877b8001b8ee7df74cfde4a9c.tar.bz2
builtins.c (expand_builtin_va_arg): Give warnings not errors for promoted argument types; build trap.
* builtins.c (expand_builtin_va_arg): Give warnings not errors for promoted argument types; build trap. (expand_builtin_trap): New. (expand_builtin): Use it. * stmt.c (expand_nl_goto_receivers): Likewise. * expr.h (expand_builtin_trap): Declare. * libfuncs.h (LTI_abort, abort_libfunc): New. * optabs.c (init_optabs): Init abort_libfunc. * gcc.dg/va-arg-1.c: Expect warnings, not errors. From-SVN: r51643
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index eb117ce..effd70d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3079,7 +3079,7 @@ expand_builtin_va_arg (valist, type)
else if ((promoted_type = (*lang_type_promotes_to) (type)) != NULL_TREE)
{
const char *name = "<anonymous type>", *pname = 0;
- static int gave_help;
+ static bool gave_help;
if (TYPE_NAME (type))
{
@@ -3098,13 +3098,24 @@ expand_builtin_va_arg (valist, type)
pname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (promoted_type)));
}
- error ("`%s' is promoted to `%s' when passed through `...'", name, pname);
+ /* Unfortunately, this is merely undefined, rather than a constraint
+ violation, so we cannot make this an error. If this call is never
+ executed, the program is still strictly conforming. */
+ warning ("`%s' is promoted to `%s' when passed through `...'",
+ name, pname);
if (! gave_help)
{
- gave_help = 1;
- error ("(so you should pass `%s' not `%s' to `va_arg')", pname, name);
+ gave_help = true;
+ warning ("(so you should pass `%s' not `%s' to `va_arg')",
+ pname, name);
}
+ /* We can, however, treat "undefined" any way we please.
+ Call abort to encourage the user to fix the program. */
+ expand_builtin_trap ();
+
+ /* This is dead code, but go ahead and finish so that the
+ mode of the result comes out right. */
addr = const0_rtx;
}
else
@@ -3556,6 +3567,18 @@ expand_builtin_expect_jump (exp, if_false_label, if_true_label)
return ret;
}
+
+void
+expand_builtin_trap ()
+{
+#ifdef HAVE_trap
+ if (HAVE_trap)
+ emit_insn (gen_trap ());
+ else
+#endif
+ emit_library_call (abort_libfunc, LCT_NORETURN, VOIDmode, 0);
+ emit_barrier ();
+}
/* Expand an expression EXP that calls a built-in function,
with result going to TARGET if that's convenient
@@ -3890,13 +3913,7 @@ expand_builtin (exp, target, subtarget, mode, ignore)
}
case BUILT_IN_TRAP:
-#ifdef HAVE_trap
- if (HAVE_trap)
- emit_insn (gen_trap ());
- else
-#endif
- error ("__builtin_trap not supported by this target");
- emit_barrier ();
+ expand_builtin_trap ();
return const0_rtx;
case BUILT_IN_PUTCHAR: