diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-09-23 11:39:39 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-09-23 11:39:39 +0200 |
commit | d2af6a68d8806cb9c6d2b2e6170f341bea8658e3 (patch) | |
tree | 0774e6c9fcd6e02b542fd8dfa85b60147d10b8cc /gcc/expr.c | |
parent | d752cfdb114944cf3c800fcc2e4d030ab392c52c (diff) | |
download | gcc-d2af6a68d8806cb9c6d2b2e6170f341bea8658e3.zip gcc-d2af6a68d8806cb9c6d2b2e6170f341bea8658e3.tar.gz gcc-d2af6a68d8806cb9c6d2b2e6170f341bea8658e3.tar.bz2 |
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/expr.c')
-rw-r--r-- | gcc/expr.c | 41 |
1 files changed, 26 insertions, 15 deletions
@@ -8002,21 +8002,32 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, inlining. */ if (CALL_EXPR_VA_ARG_PACK (exp)) error ("invalid use of %<__builtin_va_arg_pack ()%>"); - /* Check for a built-in function. */ - if (TREE_CODE (CALL_EXPR_FN (exp)) == ADDR_EXPR - && (TREE_CODE (TREE_OPERAND (CALL_EXPR_FN (exp), 0)) - == FUNCTION_DECL) - && DECL_BUILT_IN (TREE_OPERAND (CALL_EXPR_FN (exp), 0))) - { - if (DECL_BUILT_IN_CLASS (TREE_OPERAND (CALL_EXPR_FN (exp), 0)) - == BUILT_IN_FRONTEND) - return lang_hooks.expand_expr (exp, original_target, - tmode, modifier, - alt_rtl); - else - return expand_builtin (exp, target, subtarget, tmode, ignore); - } - + { + tree fndecl = get_callee_fndecl (exp), attr; + + if (fndecl + && (attr = lookup_attribute ("error", + DECL_ATTRIBUTES (fndecl))) != NULL) + error ("call to %qs declared with attribute error: %s", + lang_hooks.decl_printable_name (fndecl, 1), + TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); + if (fndecl + && (attr = lookup_attribute ("warning", + DECL_ATTRIBUTES (fndecl))) != NULL) + warning (0, "call to %qs declared with attribute warning: %s", + lang_hooks.decl_printable_name (fndecl, 1), + TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)))); + + /* Check for a built-in function. */ + if (fndecl && DECL_BUILT_IN (fndecl)) + { + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_FRONTEND) + return lang_hooks.expand_expr (exp, original_target, + tmode, modifier, alt_rtl); + else + return expand_builtin (exp, target, subtarget, tmode, ignore); + } + } return expand_call (exp, target, ignore); case NON_LVALUE_EXPR: |