summaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-09-23 11:39:39 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2007-09-23 11:39:39 +0200
commitd2af6a68d8806cb9c6d2b2e6170f341bea8658e3 (patch)
tree0774e6c9fcd6e02b542fd8dfa85b60147d10b8cc /gcc/doc
parentd752cfdb114944cf3c800fcc2e4d030ab392c52c (diff)
downloadgcc-d2af6a68d8806cb9c6d2b2e6170f341bea8658e3.tar.gz
expr.c (expand_expr_real_1): Use get_callee_fndecl instead of checking CALL_EXPR_FN directly to test for...
* expr.c (expand_expr_real_1) <case CALL_EXPR>: Use get_callee_fndecl instead of checking CALL_EXPR_FN directly to test for builtins. If error or warning attributes are present, print error resp. warning. * c-common.c (handle_error_attribute): New function. (c_common_attribute_table): Add error and warning attributes. * doc/extend.texi: Document error and warning attributes. * gcc.dg/va-arg-pack-len-1.c: Use error and warning attributes. * gcc.dg/va-arg-pack-len-2.c: New test. * g++.dg/ext/va-arg-pack-len-1.C: Use error and warning attributes. * g++.dg/ext/va-arg-pack-len-2.C: New test. From-SVN: r128687
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/extend.texi27
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index de3a1211c73..a4f7a3a68ce 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1803,7 +1803,8 @@ attributes are currently defined for functions on all targets:
@code{destructor}, @code{used}, @code{unused}, @code{deprecated},
@code{weak}, @code{malloc}, @code{alias}, @code{warn_unused_result},
@code{nonnull}, @code{gnu_inline}, @code{externally_visible},
-@code{hot}, @code{cold} and @code{artificial}.
+@code{hot}, @code{cold}, @code{artificial}, @code{error}
+and @code{warning}.
Several other attributes are defined for functions on particular
target systems. Other attributes, including @code{section} are
supported for variables declarations (@pxref{Variable Attributes}) and
@@ -1941,6 +1942,30 @@ Whether the function itself is considered for inlining depends on its size and
the current inlining parameters. The @code{flatten} attribute only works
reliably in unit-at-a-time mode.
+@item error ("@var{message}")
+@cindex @code{error} function attribute
+If this attribute is used on a function declaration and a call to such a function
+is not eliminated through dead code elimination or other optimizations, an error
+which will include @var{message} will be diagnosed. This is useful
+for compile time checking, especially together with @code{__builtin_constant_p}
+and inline functions where checking the inline function arguments is not
+possible through @code{extern char [(condition) ? 1 : -1];} tricks.
+While it is possible to leave the function undefined and thus invoke
+a link failure, when using this attribute the problem will be diagnosed
+earlier and with exact location of the call even in presence of inline
+functions or when not emitting debugging information.
+
+@item warning ("@var{message}")
+@cindex @code{warning} function attribute
+If this attribute is used on a function declaration and a call to such a function
+is not eliminated through dead code elimination or other optimizations, a warning
+which will include @var{message} will be diagnosed. This is useful
+for compile time checking, especially together with @code{__builtin_constant_p}
+and inline functions. While it is possible to define the function with
+a message in @code{.gnu.warning*} section, when using this attribute the problem
+will be diagnosed earlier and with exact location of the call even in presence
+of inline functions or when not emitting debugging information.
+
@item cdecl
@cindex functions that do pop the argument stack on the 386
@opindex mrtd