summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-14 08:50:01 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-09-14 08:50:01 +0000
commit8b76fbe9f4f17730a880a2a8328af059aa8b1ba7 (patch)
tree6931625451a04ffd6e6f89ff91104156c0dfa780 /gcc/gimplify.c
parent7b666a86b5e97caaf523fbef72b9dbb791e48d77 (diff)
downloadgcc-8b76fbe9f4f17730a880a2a8328af059aa8b1ba7.tar.gz
2012-09-14 Richard Guenther <rguenther@suse.de>
* builtin-types.def (BT_FN_CONST_STRING): Add. * builtins.def (BUILT_IN_FILE, BUILT_IN_FUNCTION, BUILT_IN_LINE): New builtins. * gimplify.c (gimplify_call_expr): Expand them. * doc/extend.texi (__builtin_LINE, __builtin_FUNCTION, __builtin_FILE): Document. * g++.dg/torture/builtin-location.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 03973537ee6..f73ac1e83ea 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2498,21 +2498,11 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
transform all calls in the same manner as the expanders do, but
we do transform most of them. */
fndecl = get_callee_fndecl (*expr_p);
- if (fndecl && DECL_BUILT_IN (fndecl))
- {
- tree new_tree = fold_call_expr (input_location, *expr_p, !want_value);
-
- if (new_tree && new_tree != *expr_p)
- {
- /* There was a transformation of this call which computes the
- same value, but in a more efficient way. Return and try
- again. */
- *expr_p = new_tree;
- return GS_OK;
- }
-
- if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
- && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_VA_START)
+ if (fndecl
+ && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (fndecl))
+ {
+ case BUILT_IN_VA_START:
{
builtin_va_start_p = TRUE;
if (call_expr_nargs (*expr_p) < 2)
@@ -2527,6 +2517,40 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value)
*expr_p = build_empty_stmt (EXPR_LOCATION (*expr_p));
return GS_OK;
}
+ break;
+ }
+ case BUILT_IN_LINE:
+ {
+ expanded_location loc = expand_location (EXPR_LOCATION (*expr_p));
+ *expr_p = build_int_cst (TREE_TYPE (*expr_p), loc.line);
+ return GS_OK;
+ }
+ case BUILT_IN_FILE:
+ {
+ expanded_location loc = expand_location (EXPR_LOCATION (*expr_p));
+ *expr_p = build_string_literal (strlen (loc.file) + 1, loc.file);
+ return GS_OK;
+ }
+ case BUILT_IN_FUNCTION:
+ {
+ const char *function;
+ function = IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
+ *expr_p = build_string_literal (strlen (function) + 1, function);
+ return GS_OK;
+ }
+ default:
+ ;
+ }
+ if (fndecl && DECL_BUILT_IN (fndecl))
+ {
+ tree new_tree = fold_call_expr (input_location, *expr_p, !want_value);
+ if (new_tree && new_tree != *expr_p)
+ {
+ /* There was a transformation of this call which computes the
+ same value, but in a more efficient way. Return and try
+ again. */
+ *expr_p = new_tree;
+ return GS_OK;
}
}