summaryrefslogtreecommitdiff
path: root/gcc/doc/extend.texi
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-11 13:40:14 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-11 13:40:14 +0000
commit4e1d7ea46e9e60154f976a52a62b115ce5a0803a (patch)
tree79484e03a465253f9b84c8b8966f361bbe454ca5 /gcc/doc/extend.texi
parentc50ab07115770a13ea245b18969cffcc09a295c8 (diff)
downloadgcc-4e1d7ea46e9e60154f976a52a62b115ce5a0803a.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128376 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc/extend.texi')
-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 730940a49dd..633913bb88d 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