]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/83059 (ICE on invalid C++ code: in tree_to_uhwi, at tree.c:6633)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 16:48:43 +0000 (18:48 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 16:48:43 +0000 (18:48 +0200)
Backported from mainline
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.

* c-c++-common/pr83059.c: New test.

From-SVN: r262032

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

index 39314b27ef0225ccf0b868c420e06c8aab3f40a7..c9f7773022d823339dba427e78ce80bf65e3d0b5 100644 (file)
@@ -1,3 +1,12 @@
+2018-06-25  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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.
+
 2018-06-20  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index d6572f71d0dcb99a99fcd19d9e1f3da5657bf17d..ad029ea6b3d2dcd7dc0edb30370485911f237235 100644 (file)
@@ -10963,13 +10963,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 a9629a6e0c4ebe8fe8f0d904fca21da9805a6bd1..51b8a478c14160ac36d7f47fc75def49b8f19081 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-11-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/83059
+       * c-c++-common/pr83059.c: New test.
+
        2017-11-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/82781
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..9a6ff5e
--- /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 "\[uU]nknown architecture specifi" "" { target *-*-* } .-1 } */
+  /* { dg-warning "failure memory model cannot be stronger than success memory model" "" { target *-*-* } .-2 } */
+}