PR c/69405 - [6 Regression] ICE in c_tree_printer on an invalid
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2016 23:19:05 +0000 (23:19 +0000)
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Jan 2016 23:19:05 +0000 (23:19 +0000)
    __atomic_fetch_add

gcc/testsuite/ChangeLog:
2016-01-20  Martin Sebor  <msebor@redhat.com>

        PR c/69405
        * gcc.dg/sync-fetch.c: New test.

gcc/c-family/ChangeLog:
2016-01-20  Martin Sebor  <msebor@redhat.com>

        PR c/69405
        * c-common.c (sync_resolve_size): Avoid printing diagnostic about
        an incompatible argument when the argument isn't a valid tree node.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232713 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/sync-fetch.c [new file with mode: 0644]

index a22485f..7bd1d5d 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-20  Martin Sebor  <msebor@redhat.com>
+
+       PR c/69405
+       * c-common.c (sync_resolve_size): Avoid printing diagnostic about
+       an incompatible argument when the argument isn't a valid tree node.
+
 2016-01-18  Jason Merrill  <jason@redhat.com>
 
        PR c++/68767
index 1a2c21b..378afae 100644 (file)
@@ -10704,8 +10704,11 @@ sync_resolve_size (tree function, vec<tree, va_gc> *params, bool fetch)
     return size;
 
  incompatible:
-  error ("operand type %qT is incompatible with argument %d of %qE",
-        argtype, 1, function);
+  /* Issue the diagnostic only if the argument is valid, otherwise
+     it would be redundant at best and could be misleading.  */
+  if (argtype != error_mark_node)
+    error ("operand type %qT is incompatible with argument %d of %qE",
+          argtype, 1, function);
   return 0;
 }
 
index 540e289..c05604b 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-20  Martin Sebor  <msebor@redhat.com>
+
+       PR c/69405
+       * gcc.dg/sync-fetch.c: New test.
+
 2016-01-21  Martin Sebor  <msebor@redhat.com>
 
        PR target/69252
@@ -11,7 +16,7 @@
 2016-01-21  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        PR c++/68810
-       * g++.dg/cpp0x/constexpr-reinterpret1.C: Fix line number that is                                                                           
+       * g++.dg/cpp0x/constexpr-reinterpret1.C: Fix line number that is
        expected to generate an error.
 
 2016-01-21  Bernd Schmidt  <bschmidt@redhat.com>
diff --git a/gcc/testsuite/gcc.dg/sync-fetch.c b/gcc/testsuite/gcc.dg/sync-fetch.c
new file mode 100644 (file)
index 0000000..44b6cdc
--- /dev/null
@@ -0,0 +1,115 @@
+/* PR c/69405 - [6 Regression] ICE in c_tree_printer on an invalid
+   __atomic_fetch_add */
+/* Test to verify that the diagnostic doesn't cause an ICE when any
+   of the arguments to __atomic_fetch_OP is undeclared.  */
+/* { dg-do compile } */
+
+void test_add_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_add (&a, &b, 0);   /* { dg-error ".b. undeclared" } */
+}
+
+void test_sub_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_sub (&a, &b, 0);      /* { dg-error ".b. undeclared" } */
+}
+
+void test_or_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_or (&a, &b, 0);      /* { dg-error ".b. undeclared" } */
+}
+
+void test_and_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_and (&a, &b, 0);      /* { dg-error ".b. undeclared" } */
+}
+
+void test_xor_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_xor (&a, &b, 0);      /* { dg-error ".b. undeclared" } */
+}
+
+void test_nand_undeclared_first_arg (void)
+{
+  int a = 0;
+  __atomic_fetch_nand (&a, &b, 0);      /* { dg-error ".b. undeclared" } */
+}
+
+
+void test_add_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_add (&a, &b, 0);   /* { dg-error ".a. undeclared" } */
+}
+
+void test_sub_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_sub (&a, &b, 0);      /* { dg-error ".a. undeclared" } */
+}
+
+void test_or_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_or (&a, &b, 0);      /* { dg-error ".a. undeclared" } */
+}
+
+void test_and_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_and (&a, &b, 0);      /* { dg-error ".a. undeclared" } */
+}
+
+void test_xor_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_xor (&a, &b, 0);      /* { dg-error ".a. undeclared" } */
+}
+
+void test_nand_undeclared_second_arg (void)
+{
+  int b = 0;
+  __atomic_fetch_nand (&a, &b, 0);      /* { dg-error ".a. undeclared" } */
+}
+
+
+void test_add_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_add (&a, &b, m);   /* { dg-error ".m. undeclared" } */
+}
+
+void test_sub_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_sub (&a, &b, m);      /* { dg-error ".m. undeclared" } */
+}
+
+void test_or_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_or (&a, &b, m);      /* { dg-error ".m. undeclared" } */
+}
+
+void test_and_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_and (&a, &b, m);      /* { dg-error ".m. undeclared" } */
+}
+
+void test_xor_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_xor (&a, &b, m);      /* { dg-error ".m. undeclared" } */
+}
+
+void test_nand_undeclared_third_arg (void)
+{
+  int a = 0, b = 0;
+  __atomic_fetch_nand (&a, &b, m);      /* { dg-error ".m. undeclared" } */
+}