From: Jakub Jelinek Date: Tue, 21 Nov 2017 08:06:28 +0000 (+0100) Subject: re PR c++/83059 (ICE on invalid C++ code: in tree_to_uhwi, at tree.c:6633) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d44ed508a66686e0c2fdf48f4cd4a9ad8a1b0547;p=gcc.git re PR c++/83059 (ICE on invalid C++ code: in tree_to_uhwi, at tree.c:6633) PR c++/83059 * c-common.c (get_atomic_generic_size): Use TREE_INT_CST_LOW instead of tree_to_uhwi, formatting fix. * config/i386/i386.c (ix86_memmodel_check): Start -Winvalid-memory-model diagnostics with lowercase letter. * c-c++-common/pr83059.c: New test. From-SVN: r254990 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 207e6f32b2e..a7bbd9c0a99 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2017-11-21 Jakub Jelinek + PR c++/83059 + * config/i386/i386.c (ix86_memmodel_check): Start + -Winvalid-memory-model diagnostics with lowercase letter. + PR debug/82718 * dwarf2out.c (dw_loc_list): If crtl->has_bb_partition, temporarily set in_cold_section_p to the partition containing loc_list->first. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1e5c3d3e187..7258f865fb9 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-11-21 Jakub Jelinek + + PR c++/83059 + * c-common.c (get_atomic_generic_size): Use TREE_INT_CST_LOW + instead of tree_to_uhwi, formatting fix. + 2017-11-20 David Malcolm PR c/81404 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 65d37c60c48..969f41bdd8c 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6671,13 +6671,14 @@ get_atomic_generic_size (location_t loc, tree function, tree p = (*params)[x]; if (TREE_CODE (p) == INTEGER_CST) { - int i = tree_to_uhwi (p); - if (i < 0 || (memmodel_base (i) >= MEMMODEL_LAST)) - { - warning_at (loc, OPT_Winvalid_memory_model, - "invalid memory model argument %d of %qE", x + 1, - function); - } + /* memmodel_base masks the low 16 bits, thus ignore any bits above + it by using TREE_INT_CST_LOW instead of tree_to_*hwi. Those high + bits will be checked later during expansion in target specific + way. */ + if (memmodel_base (TREE_INT_CST_LOW (p)) >= MEMMODEL_LAST) + warning_at (loc, OPT_Winvalid_memory_model, + "invalid memory model argument %d of %qE", x + 1, + function); } else if (!INTEGRAL_TYPE_P (TREE_TYPE (p))) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 1775697a4d8..b32288608d9 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -49066,7 +49066,7 @@ ix86_memmodel_check (unsigned HOST_WIDE_INT val) || ((val & IX86_HLE_ACQUIRE) && (val & IX86_HLE_RELEASE))) { warning (OPT_Winvalid_memory_model, - "Unknown architecture specific memory model"); + "unknown architecture specific memory model"); return MEMMODEL_SEQ_CST; } strong = (is_mm_acq_rel (model) || is_mm_seq_cst (model)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ca2206c575c..05638e790dc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-11-21 Jakub Jelinek + PR c++/83059 + * c-c++-common/pr83059.c: New test. + PR debug/82718 * gcc.dg/debug/dwarf2/pr82718-1.c: New test. * gcc.dg/debug/dwarf2/pr82718-2.c: New test. diff --git a/gcc/testsuite/c-c++-common/pr83059.c b/gcc/testsuite/c-c++-common/pr83059.c new file mode 100644 index 00000000000..44ff67c879d --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr83059.c @@ -0,0 +1,10 @@ +/* PR c++/83059 */ +/* { dg-do compile } */ + +void +foo (int *p, int *q, int *r) +{ + __atomic_compare_exchange (p, q, r, 0, 0, -1); /* { dg-warning "invalid memory model argument 6" } */ + /* { dg-warning "unknown architecture specifi" "" { target *-*-* } .-1 } */ + /* { dg-warning "failure memory model cannot be stronger than success memory model" "" { target *-*-* } .-2 } */ +}