summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/guality
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-23 19:37:40 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2010-07-23 19:37:40 +0000
commit10ada81fea4490f94ba2eb5923bf5baa367a38bd (patch)
tree437dca120093cc7b1f6debf6f6b31779526c7192 /gcc/testsuite/gcc.dg/guality
parent95a236de8aa10bf009e9368dfd28f95a980e5570 (diff)
parent3bd7a983695352a99f7dd597725eb5b839d4b4cf (diff)
downloadgcc-10ada81fea4490f94ba2eb5923bf5baa367a38bd.tar.gz
Merged with trunk at revision 162480.ifunc
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/ifunc@162483 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/guality')
-rw-r--r--gcc/testsuite/gcc.dg/guality/asm-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/guality/guality.exp1
-rw-r--r--gcc/testsuite/gcc.dg/guality/guality.h28
-rw-r--r--gcc/testsuite/gcc.dg/guality/nrv-1.c29
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr43141.c16
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr45003-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr45003-2.c31
-rw-r--r--gcc/testsuite/gcc.dg/guality/pr45003-3.c31
8 files changed, 175 insertions, 17 deletions
diff --git a/gcc/testsuite/gcc.dg/guality/asm-1.c b/gcc/testsuite/gcc.dg/guality/asm-1.c
new file mode 100644
index 00000000000..5279722c094
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/asm-1.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+struct A { int x; unsigned short y; char z[64]; };
+
+void __attribute__((noinline))
+foo (struct A *p, char *q)
+{
+ int f = &p->z[p->y] - q;
+ asm volatile ("nop");
+ asm volatile ("nop" : : "g" (f)); /* { dg-final { gdb-test 12 "f" "14" } } */
+ asm volatile ("" : : "g" (p), "g" (q));
+}
+
+int
+main ()
+{
+ struct A a;
+ __builtin_memset (&a, 0, sizeof a);
+ a.y = 26;
+ a.x = 12;
+ asm volatile ("" : : "r" (&a) : "memory");
+ foo (&a, &a.z[a.x]);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp
index d4ee6864ba4..49e2ac5a550 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.exp
+++ b/gcc/testsuite/gcc.dg/guality/guality.exp
@@ -43,6 +43,7 @@ if {[check_guality "
}
"]} {
gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
+ gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "-Wc++-compat"
}
if [info exists guality_gdb_name] {
diff --git a/gcc/testsuite/gcc.dg/guality/guality.h b/gcc/testsuite/gcc.dg/guality/guality.h
index e744d0d72ee..f6c662ce8f6 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.h
+++ b/gcc/testsuite/gcc.dg/guality/guality.h
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
+#include <unistd.h>
/* This is a first cut at checking that debug information matches
run-time. The idea is to annotate programs with GUALCHK* macros
@@ -61,6 +62,7 @@ typedef intmax_t gualchk_t;
/* Convert a pointer or integral type to the widest integral type,
as expected by guality_check. */
+#ifndef __cplusplus
#define GUALCVT(val) \
((gualchk_t)__builtin_choose_expr \
(__builtin_types_compatible_p (__typeof (val), gualchk_t), \
@@ -69,6 +71,30 @@ typedef intmax_t gualchk_t;
(__builtin_classify_type (val) \
== __builtin_classify_type (&guality_skip), \
(uintptr_t)(val),(intptr_t)(val))))
+#else
+template <typename T>
+inline __attribute__((always_inline)) gualchk_t
+gualcvt (T *val)
+{
+ return (uintptr_t) val;
+}
+
+template <typename T>
+inline __attribute__((always_inline)) gualchk_t
+gualcvt (T val)
+{
+ return (intptr_t) val;
+}
+
+template <>
+inline __attribute__((always_inline)) gualchk_t
+gualcvt<gualchk_t> (gualchk_t val)
+{
+ return val;
+}
+
+#define GUALCVT(val) gualcvt (val)
+#endif
/* Attach a debugger to the current process and verify that the string
EXPR, evaluated by the debugger, yields the gualchk_t number VAL.
@@ -195,7 +221,7 @@ main (int argc, char *argv[])
else
{
int len = strlen (guality_gdb_command) + sizeof (GUALITY_GDB_ARGS);
- char *buf = __builtin_alloca (len);
+ char *buf = (char *) __builtin_alloca (len);
strcpy (buf, guality_gdb_command);
strcat (buf, GUALITY_GDB_ARGS);
guality_gdb_command = buf;
diff --git a/gcc/testsuite/gcc.dg/guality/nrv-1.c b/gcc/testsuite/gcc.dg/guality/nrv-1.c
new file mode 100644
index 00000000000..6e70050ec4d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/nrv-1.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-g -fno-tree-sra" } */
+
+void abort (void);
+
+struct A
+{
+ int i[100];
+};
+
+struct A a1, a3;
+
+__attribute__((noinline)) struct A
+f ()
+{
+ struct A a2;
+ a2.i[0] = 42;
+ if (a3.i[0] != 0)
+ abort ();
+ a2.i[4] = 7; /* { dg-final { gdb-test 20 "a2.i\[0\]" "42" } } */
+ return a2;
+}
+
+int
+main ()
+{
+ a1 = f ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/pr43141.c b/gcc/testsuite/gcc.dg/guality/pr43141.c
deleted file mode 100644
index e6fe79a0efc..00000000000
--- a/gcc/testsuite/gcc.dg/guality/pr43141.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* { dg-do run } */
-/* { dg-options "-g" } */
-
-int i;
-static int f(int) __attribute ((noinline));
-static int f(int x)
-{
- return i;
-}
-
-int main()
-{
- return f(42);
-}
-
-/* { dg-final { gdb-test 8 "sizeof (x)" "sizeof (int)" } } */
diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-1.c b/gcc/testsuite/gcc.dg/guality/pr45003-1.c
new file mode 100644
index 00000000000..7cef8f6284c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/pr45003-1.c
@@ -0,0 +1,31 @@
+/* PR debug/45003 */
+/* { dg-do run { target { x86_64-*-* && lp64 } } } */
+/* { dg-options "-g" } */
+
+int __attribute__((noinline))
+foo (unsigned short *p)
+{
+ int a = *p;
+ asm volatile ("nop");
+ asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */
+ return 0;
+}
+
+int __attribute__((noinline))
+bar (short *p)
+{
+ unsigned int a = *p;
+ asm volatile ("nop");
+ asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */
+ return 0;
+}
+
+int
+main ()
+{
+ unsigned short us = 0x8078;
+ foo (&us);
+ short s = -32648;
+ bar (&s);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-2.c b/gcc/testsuite/gcc.dg/guality/pr45003-2.c
new file mode 100644
index 00000000000..dcdba237ff4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/pr45003-2.c
@@ -0,0 +1,31 @@
+/* PR debug/45003 */
+/* { dg-do run { target { x86_64-*-* && lp64 } } } */
+/* { dg-options "-g" } */
+
+int __attribute__((noinline))
+foo (unsigned short *p)
+{
+ int a = *p;
+ asm volatile ("nop" : : "D" ((int) *p));
+ asm volatile ("nop" : : "D" ((int) *p)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */
+ return 0;
+}
+
+int __attribute__((noinline))
+bar (short *p)
+{
+ unsigned int a = *p;
+ asm volatile ("nop" : : "D" ((unsigned int) *p));
+ asm volatile ("nop" : : "D" ((unsigned int) *p)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */
+ return 0;
+}
+
+int
+main ()
+{
+ unsigned short us = 0x8078;
+ foo (&us);
+ short s = -32648;
+ bar (&s);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-3.c b/gcc/testsuite/gcc.dg/guality/pr45003-3.c
new file mode 100644
index 00000000000..3adc4f2383e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/pr45003-3.c
@@ -0,0 +1,31 @@
+/* PR debug/45003 */
+/* { dg-do run { target { x86_64-*-* && lp64 } } } */
+/* { dg-options "-g" } */
+
+int __attribute__((noinline))
+foo (unsigned short *p)
+{
+ int a = (short) *p;
+ asm volatile ("nop" : : "D" ((int) *p));
+ asm volatile ("nop" : : "D" ((int) *p)); /* { dg-final { gdb-test 10 "a" "-32648" } } */
+ return 0;
+}
+
+int __attribute__((noinline))
+bar (short *p)
+{
+ unsigned int a = (unsigned short) *p;
+ asm volatile ("nop" : : "D" ((unsigned int) *p));
+ asm volatile ("nop" : : "D" ((unsigned int) *p)); /* { dg-final { gdb-test 19 "a" "0x8078" } } */
+ return 0;
+}
+
+int
+main ()
+{
+ unsigned short us = 0x8078;
+ foo (&us);
+ short s = -32648;
+ bar (&s);
+ return 0;
+}