From 2c7b8bf6d3e875772946d9c4dd10ecb6a8a8b883 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 11 Jun 2013 20:43:59 +0930 Subject: [PATCH] varasm.c (get_section): Don't die on !DECL_P decl. * varasm.c (get_section): Don't die on !DECL_P decl. Tidy error reporting. (get_named_section): Don't NULL !DECL_P decl. From-SVN: r199949 --- gcc/ChangeLog | 6 ++++++ gcc/varasm.c | 28 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 52f7e7cf537..f346780e5f2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-06-11 Alan Modra + + * varasm.c (get_section): Don't die on !DECL_P decl. Tidy error + reporting. + (get_named_section): Don't NULL !DECL_P decl. + 2013-06-11 Igor Zamyatin * doc/invoke.texi (core-avx2): Document. diff --git a/gcc/varasm.c b/gcc/varasm.c index 563953104aa..d2b9415477d 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -307,19 +307,22 @@ get_section (const char *name, unsigned int flags, tree decl) return sect; } /* Sanity check user variables for flag changes. */ - if (decl == 0) - decl = sect->named.decl; - gcc_assert (decl); - if (sect->named.decl == NULL) - error ("%+D causes a section type conflict", decl); - else + if (sect->named.decl != NULL + && DECL_P (sect->named.decl) + && decl != sect->named.decl) { - error ("%+D causes a section type conflict with %D", - decl, sect->named.decl); - if (decl != sect->named.decl) - inform (DECL_SOURCE_LOCATION (sect->named.decl), - "%qD was declared here", sect->named.decl); + if (decl != NULL && DECL_P (decl)) + error ("%+D causes a section type conflict with %D", + decl, sect->named.decl); + else + error ("section type conflict with %D", sect->named.decl); + inform (DECL_SOURCE_LOCATION (sect->named.decl), + "%qD was declared here", sect->named.decl); } + else if (decl != NULL && DECL_P (decl)) + error ("%+D causes a section type conflict", decl); + else + error ("section type conflict"); /* Make sure we don't error about one section multiple times. */ sect->common.flags |= SECTION_OVERRIDE; } @@ -409,9 +412,6 @@ get_named_section (tree decl, const char *name, int reloc) } flags = targetm.section_type_flags (decl, name, reloc); - - if (decl && !DECL_P (decl)) - decl = NULL_TREE; return get_section (name, flags, decl); } -- 2.30.2