diff options
author | Bernhard Reutner-Fischer <aldot@gcc.gnu.org> | 2021-11-06 06:48:00 +0100 |
---|---|---|
committer | Bernhard Reutner-Fischer <aldot@gcc.gnu.org> | 2022-11-17 20:40:47 +0100 |
commit | 3f467ea953431aa6af12aaed6d32f476f7ace1e5 (patch) | |
tree | 0be64260e8c3e15302747260c0ebad452a2d77a8 | |
parent | 19be89d79ee149e812ccc6027956cefb7f3e1016 (diff) | |
download | gcc-3f467ea953431aa6af12aaed6d32f476f7ace1e5.zip gcc-3f467ea953431aa6af12aaed6d32f476f7ace1e5.tar.gz gcc-3f467ea953431aa6af12aaed6d32f476f7ace1e5.tar.bz2 |
c: Set the locus of the function result decl
gcc/c/ChangeLog:
* c-decl.cc (start_function): Set the result decl source
location to the location of the typespec.
-rw-r--r-- | gcc/c/c-decl.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index 36de778..098e475 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -10059,6 +10059,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, tree decl1, old_decl; tree restype, resdecl; location_t loc; + location_t result_loc; current_function_returns_value = 0; /* Assume, until we see it does. */ current_function_returns_null = 0; @@ -10285,8 +10286,11 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, push_scope (); declare_parm_level (); + /* Set the result decl source location to the location of the typespec. */ + result_loc = (declspecs->locations[cdw_typespec] == UNKNOWN_LOCATION + ? loc : declspecs->locations[cdw_typespec]); restype = TREE_TYPE (TREE_TYPE (current_function_decl)); - resdecl = build_decl (loc, RESULT_DECL, NULL_TREE, restype); + resdecl = build_decl (result_loc, RESULT_DECL, NULL_TREE, restype); DECL_ARTIFICIAL (resdecl) = 1; DECL_IGNORED_P (resdecl) = 1; DECL_RESULT (current_function_decl) = resdecl; |