[Committed] Add C testcases for PR 86659
diff mbox series

Message ID CA+=Sn1=WRuXK6siPz1imOu4S+hrfHf-r84mk0EShEEHz+5h1gg@mail.gmail.com
State New
Headers show
Series
  • [Committed] Add C testcases for PR 86659
Related show

Commit Message

Andrew Pinski Dec. 13, 2019, 8:30 a.m. UTC
Hi all,
  Since Ada is not always tested and I had received a testcase from a
customer for the same issue (I had backported the patch which caused
it), I thought I would create a full testcase that fails with C code.

NOTE this does not fail on x86_64 (nor aarch64) before the patch for
PR86659 due to SLOW_BYTE_ACCESS set to 0.  But I changed
SLOW_BYTE_ACCESS to be 1 when I was testing the code.

Committed as obvious after a simple test.

Thanks,
Andrew Pinski

testsuite/ChangeLog:
2019-12-13  Andrew Pinski  <apinski@marvell.com>

       * gcc.c-torture/execute/pr86659-1.c: New test.
       * gcc.c-torture/execute/pr86659-2.c: New test.

Patch
diff mbox series

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 279337)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2019-12-13  Andrew Pinski  <apinski@marvell.com>
+
+	* gcc.c-torture/execute/pr86659-1.c: New test.
+	* gcc.c-torture/execute/pr86659-2.c: New test.
+
 2019-12-12  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/92904
Index: gcc.c-torture/execute/pr86659-1.c
===================================================================
--- gcc.c-torture/execute/pr86659-1.c	(nonexistent)
+++ gcc.c-torture/execute/pr86659-1.c	(working copy)
@@ -0,0 +1,42 @@ 
+#define ENDIANBIG __attribute((scalar_storage_order ("big-endian")))
+
+typedef struct ENDIANBIG 
+{
+  unsigned long long  field0:29;
+  unsigned long long  field1:4; 
+  unsigned long long  field2:31;
+}struct1;  
+
+int
+main(void)
+{
+  int value1 = 0;
+  int value2 = 0;
+  int value3 = 0;
+  unsigned int flag;
+  struct1 var1;
+  var1.field0 = 23;
+  
+  flag = var1.field0;
+  value1 = ((var1.field0)?10:20);
+  if(var1.field0)
+    {
+      value2 =  10;
+    } else
+    {
+      value2 = 20;
+    }
+
+  value3 = ((flag)?10:20);
+
+  if (value1 != 10)
+    __builtin_abort ();
+
+  if (value2 != 10)
+    __builtin_abort ();
+
+  if (value3 != 10)
+    __builtin_abort ();
+
+  return 0;
+}
Index: gcc.c-torture/execute/pr86659-2.c
===================================================================
--- gcc.c-torture/execute/pr86659-2.c	(nonexistent)
+++ gcc.c-torture/execute/pr86659-2.c	(working copy)
@@ -0,0 +1,42 @@ 
+#define ENDIANBIG __attribute((scalar_storage_order ("little-endian")))
+
+typedef struct ENDIANBIG 
+{
+  unsigned long long  field0:29;
+  unsigned long long  field1:4; 
+  unsigned long long  field2:31;
+}struct1;  
+
+int
+main(void)
+{
+  int value1 = 0;
+  int value2 = 0;
+  int value3 = 0;
+  unsigned int flag;
+  struct1 var1;
+  var1.field0 = 23;
+  
+  flag = var1.field0;
+  value1 = ((var1.field0)?10:20);
+  if(var1.field0)
+    {
+      value2 =  10;
+    } else
+    {
+      value2 = 20;
+    }
+
+  value3 = ((flag)?10:20);
+
+  if (value1 != 10)
+    __builtin_abort ();
+
+  if (value2 != 10)
+    __builtin_abort ();
+
+  if (value3 != 10)
+    __builtin_abort ();
+
+  return 0;
+}