re PR c++/83059 (ICE on invalid C++ code: in tree_to_uhwi, at tree.c:6633)
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 Nov 2017 08:06:28 +0000 (09:06 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Nov 2017 08:06:28 +0000 (09:06 +0100)
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

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr83059.c [new file with mode: 0644]

index 207e6f32b2e0dc000dd75eec4f76cc7db12274c9..a7bbd9c0a99bcc8358c0b725857d106dacb22a8d 100644 (file)
@@ -1,5 +1,9 @@
 2017-11-21  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index 1e5c3d3e18722383bd52404a063eac283ecaf8b2..7258f865fb9dc3592982c00dc726e5efed509116 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-21  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <dmalcolm@redhat.com>
 
        PR c/81404
index 65d37c60c48127dc8973cdbeda439b11a4ee7b99..969f41bdd8cabc406b432c36efba7af73f857311 100644 (file)
@@ -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)))
index 1775697a4d8ce0be0df4f331658115b07fbade08..b32288608d98867a712510d222fa57f278ee7a15 100644 (file)
@@ -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));
index ca2206c575cb6a4e17c79566716afffccf09577f..05638e790dcf329378ab4ce1720055a0dbd39e88 100644 (file)
@@ -1,5 +1,8 @@
 2017-11-21  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..44ff67c
--- /dev/null
@@ -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 } */
+}