+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
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);
/* 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
+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
--- /dev/null
+/* { 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;
+}
--- /dev/null
+/* { dg-skip-if "" { *-*-* } } */
+
+int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };