aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-09-11 15:40:14 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2007-09-11 15:40:14 +0200
commitab0e176c5b252f6cf61e520b36f6c0d313a3281d (patch)
tree79484e03a465253f9b84c8b8966f361bbe454ca5 /gcc/doc
parente6ebd07f479b258643f61e4b49dc954b336142d5 (diff)
downloadgcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.zip
gcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.tar.gz
gcc-ab0e176c5b252f6cf61e520b36f6c0d313a3281d.tar.bz2
builtins.def (BUILT_IN_VA_ARG_PACK_LEN): New builtin.
* builtins.def (BUILT_IN_VA_ARG_PACK_LEN): New builtin. * builtins.c (expand_builtin) <case BUILT_IN_VA_ARG_PACK_LEN>: Issue error if __builtin_va_arg_pack_len () wasn't optimized out during inlining. * tree-inline.c (copy_bb): Replace __builtin_va_arg_pack_len () with the number of inline's anonymous arguments. * doc/extend.texi: Document __builtin_va_arg_pack_len (). * gcc.dg/va-arg-pack-len-1.c: New test. * g++.dg/va-arg-pack-len-1.C: New test. From-SVN: r128376
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 730940a..633913b 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -583,6 +583,41 @@ myprintf (FILE *f, const char *format, ...)
@end smallexample
@end deftypefn
+@deftypefn {Built-in Function} __builtin_va_arg_pack_len ()
+This built-in function returns the number of anonymous arguments of
+an inline function. It can be used only in inline functions which
+will be always inlined, never compiled as a separate function, such
+as those using @code{__attribute__ ((__always_inline__))} or
+@code{__attribute__ ((__gnu_inline__))} extern inline functions.
+For example following will do link or runtime checking of open
+arguments for optimized code:
+@smallexample
+#ifdef __OPTIMIZE__
+extern inline __attribute__((__gnu_inline__)) int
+myopen (const char *path, int oflag, ...)
+@{
+ if (__builtin_va_arg_pack_len () > 1)
+ warn_open_too_many_arguments ();
+
+ if (__builtin_constant_p (oflag))
+ @{
+ if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
+ @{
+ warn_open_missing_mode ();
+ return __open_2 (path, oflag);
+ @}
+ return open (path, oflag, __builtin_va_arg_pack ());
+ @}
+
+ if (__builtin_va_arg_pack_len () < 1)
+ return __open_2 (path, oflag);
+
+ return open (path, oflag, __builtin_va_arg_pack ());
+@}
+#endif
+@end smallexample
+@end deftypefn
+
@node Typeof
@section Referring to a Type with @code{typeof}
@findex typeof