From 7273331429916a0c203b1064e0414c741c06a78f Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Wed, 15 Aug 2018 11:45:44 +0000 Subject: [PATCH] Don't make unsized objects into extern. 2018-08-15 Iain Sandoe gcc/c: PR c/19315 * c-decl.c (finish_decl): Don't add the 'extern' storage class to objects of unknown size. gcc/testsuite: PR c/19315 gcc.dg/graphite/pr82451.c: Make array 'a' an extern. gcc.dg/redecl-10.c: Expect warnings for the static vars with unknown size. From-SVN: r263556 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 8 -------- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.dg/graphite/pr82451.c | 2 +- gcc/testsuite/gcc.dg/redecl-10.c | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index be2ffbd2ade..59312062d96 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2018-08-15 Iain Sandoe + + PR c/19315 + * c-decl.c (finish_decl): Don't add the 'extern' storage class to + objects of unknown size. + 2018-08-13 Martin Sebor PR tree-optimization/71625 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index ed1dd28cac6..da42add0732 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4969,14 +4969,6 @@ finish_decl (tree decl, location_t init_loc, tree init, case 2: if (do_default) error ("array size missing in %q+D", decl); - /* If a `static' var's size isn't known, - make it extern as well as static, so it does not get - allocated. - If it is not `static', then do not mark extern; - finish_incomplete_decl will give it a default size - and it will get allocated. */ - else if (!pedantic && TREE_STATIC (decl) && !TREE_PUBLIC (decl)) - DECL_EXTERNAL (decl) = 1; break; case 3: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 46a16279fe0..18bb966ca42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-08-15 Iain Sandoe + + PR c/19315 + * gcc.dg/graphite/pr82451.c: Make array 'a' an extern. + * gcc.dg/redecl-10.c: Expect warnings for the static vars with + unknown size. + 2018-08-15 Martin Liska PR tree-optimization/86925 diff --git a/gcc/testsuite/gcc.dg/graphite/pr82451.c b/gcc/testsuite/gcc.dg/graphite/pr82451.c index 802b931fddd..b2c439bb563 100644 --- a/gcc/testsuite/gcc.dg/graphite/pr82451.c +++ b/gcc/testsuite/gcc.dg/graphite/pr82451.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-O -floop-parallelize-all" } */ -static int a[]; +extern int a[]; int b[1]; int c; static void diff --git a/gcc/testsuite/gcc.dg/redecl-10.c b/gcc/testsuite/gcc.dg/redecl-10.c index 525961e7e3a..0864311f64e 100644 --- a/gcc/testsuite/gcc.dg/redecl-10.c +++ b/gcc/testsuite/gcc.dg/redecl-10.c @@ -5,7 +5,7 @@ /* { dg-do compile } */ /* { dg-options "-g" } */ -static int w[]; +static int w[]; /* { dg-warning "array 'w' assumed to have one element" } */ void f (void) { @@ -19,7 +19,7 @@ g (void) extern int x[] = { 3, 4, 5 }; /* { dg-error "has both" } */ } -static int y[]; +static int y[]; /* { dg-warning "array 'y' assumed to have one element" } */ void h (void) { -- 2.30.2