aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCesar Philippidis <cesar@codesourcery.com>2018-03-27 06:54:03 -0700
committerCesar Philippidis <cesar@gcc.gnu.org>2018-03-27 06:54:03 -0700
commit59d2d2383485fb0febdcab9f06bbb3526eeab106 (patch)
treed39392e4fb207df80a67c4babc2179f58edb8f1e
parentb36306e9bc664cdbc2f65ecc33867cb7b6e896b3 (diff)
downloadgcc-59d2d2383485fb0febdcab9f06bbb3526eeab106.zip
gcc-59d2d2383485fb0febdcab9f06bbb3526eeab106.tar.gz
gcc-59d2d2383485fb0febdcab9f06bbb3526eeab106.tar.bz2
re PR target/85056 ([nvptx] wrong declaration of external arrays)
PR target/85056 gcc/ * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Add '[]' to extern array declarations. gcc/testsuite/ * testsuite/gcc.target/nvptx/pr85056.c: New test. * testsuite/gcc.target/nvptx/pr85056a.c: New test. From-SVN: r258885
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/nvptx/nvptx.c5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.target/nvptx/pr85056.c20
-rw-r--r--gcc/testsuite/gcc.target/nvptx/pr85056a.c3
5 files changed, 40 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b670c5d..6799fdf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-27 Cesar Philippidis <cesar@codesourcery.com>
+
+ PR target/85056
+ * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Add '[]' to
+ extern array declarations.
+
2018-03-27 Richard Biener <rguenther@suse.de>
PR middle-ed/84067
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 1ba27e3..b2b150f 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -2033,6 +2033,9 @@ static void
nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section,
const_tree type, HOST_WIDE_INT size, unsigned align)
{
+ bool atype = (TREE_CODE (type) == ARRAY_TYPE)
+ && (TYPE_DOMAIN (type) == NULL_TREE);
+
while (TREE_CODE (type) == ARRAY_TYPE)
type = TREE_TYPE (type);
@@ -2072,6 +2075,8 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section,
/* We make everything an array, to simplify any initialization
emission. */
fprintf (file, "[" HOST_WIDE_INT_PRINT_DEC "]", init_frag.remaining);
+ else if (atype)
+ fprintf (file, "[]");
}
/* Called when the initializer for a decl has been completely output through
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 00f1653..dd1a7bc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-27 Cesar Philippidis <cesar@codesourcery.com>
+
+ PR target/85056
+ * testsuite/gcc.target/nvptx/pr85056.c: New test.
+ * testsuite/gcc.target/nvptx/pr85056a.c: New test.
+
2018-03-27 Richard Biener <rguenther@suse.de>
PR testsuite/82847
diff --git a/gcc/testsuite/gcc.target/nvptx/pr85056.c b/gcc/testsuite/gcc.target/nvptx/pr85056.c
new file mode 100644
index 0000000..fe7f8af
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/pr85056.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr85056a.c" } */
+
+extern void abort ();
+
+extern int a[];
+
+int
+main ()
+{
+ int i, sum;
+
+ for (i = 0; i < 10; i++)
+ sum += a[i];
+
+ if (sum != 55)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/nvptx/pr85056a.c b/gcc/testsuite/gcc.target/nvptx/pr85056a.c
new file mode 100644
index 0000000..a45a5f2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/pr85056a.c
@@ -0,0 +1,3 @@
+/* { dg-skip-if "" { *-*-* } } */
+
+int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };