diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-09-23 09:39:39 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-09-23 09:39:39 +0000 |
commit | 9da7609fac097fe36a39a35d8cae017960c1ec8b (patch) | |
tree | 0774e6c9fcd6e02b542fd8dfa85b60147d10b8cc /gcc/expr.c | |
parent | 89e467fcd334103b08144dd4ea4f13706dd44f0d (diff) |
* 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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@128687 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/expr.c')
-rw-r--r-- | gcc/expr.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/gcc/expr.c b/gcc/expr.c index c7b29b53c94..afd01acb4aa 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -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: |