Skip to content

Commit 0bdd794

Browse files
author
dmalcolm
committed
C: fix logic within c_expr::get_location
In r251239 I added a c_expr::get_location method for use by c_parser_expr_list for building the vec<location_t> for an expression list, rather than using the location of the first token. When determining whether to use the location within the tree node, or fall back to the range in the c_expr, I used EXPR_CAN_HAVE_LOCATION, rather than EXPR_HAS_LOCATION. This meant that any tree nodes of kinds that *can* have a location but which erroneously had EXPR_LOCATION (value) == UNKNOWN_LOCATION had that value added to the vec<location_t>, leading to missing location information when reporting on the issue (seen with gcc.dg/Wtraditional-conversion-2.c for m68k). This patch addresses this in two ways: (a) it fixes the specific issue in this failing test case, by setting up the location properly on the EXCESS_PRECISION_EXPR. (b) updating c_expr::get_location by only using the EXPR_LOCATION if it's sane. Arguably this is papering over bugs, but they are pre-existing ones exposed by r251239, and I'd rather have this fix in place than play whack-a-mole on any other such "missing location" bugs that are lurking in the codebase. gcc/c/ChangeLog: * c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather than CAN_HAVE_LOCATION_P when determining whether to use the location_t value within "value". gcc/c-family/ChangeLog: * c-lex.c (interpret_float): Use token location when building an EXCESS_PRECISION_EXPR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251335 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent c40aecf commit 0bdd794

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

gcc/c-family/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2017-08-24 David Malcolm <dmalcolm@redhat.com>
2+
3+
* c-lex.c (interpret_float): Use token location
4+
when building an EXCESS_PRECISION_EXPR.
5+
16
2017-08-21 David Malcolm <dmalcolm@redhat.com>
27

38
* c-common.c (check_function_arguments): Add "arglogs" param; pass

gcc/c-family/c-lex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ interpret_float (const cpp_token *token, unsigned int flags,
988988
}
989989

990990
if (type != const_type)
991-
value = build1 (EXCESS_PRECISION_EXPR, type, value);
991+
value = build1_loc (token->src_loc, EXCESS_PRECISION_EXPR, type, value);
992992

993993
return value;
994994
}

gcc/c/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2017-08-24 David Malcolm <dmalcolm@redhat.com>
2+
3+
* c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather
4+
than CAN_HAVE_LOCATION_P when determining whether to use the
5+
location_t value within "value".
6+
17
2017-08-21 David Malcolm <dmalcolm@redhat.com>
28

39
* c-parser.c (c_parser_expr_list): Use c_expr::get_location ()

gcc/c/c-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct c_expr
149149

150150
location_t get_location () const
151151
{
152-
if (CAN_HAVE_LOCATION_P (value))
152+
if (EXPR_HAS_LOCATION (value))
153153
return EXPR_LOCATION (value);
154154
else
155155
return make_location (get_start (), get_start (), get_finish ());

0 commit comments

Comments
 (0)