public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96126] New: conflicting attribute section accepted on redeclaration
@ 2020-07-08 22:01 msebor at gcc dot gnu.org
  2020-07-08 22:01 ` [Bug c/96126] " msebor at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-07-08 22:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96126

            Bug ID: 96126
           Summary: conflicting attribute section accepted on
                    redeclaration
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

GCC rejects conflicting attribute section on same declaration but fails to
detect the far more likely and difficult to debug problem where the conflict is
on two declaration of the same function or variable:

$ cat z.c && gcc -O2 -S -Wall z.c
__attribute__ ((section ("s1"), section ("s2")))  // error (good)
void f1 (void);

__attribute__ ((section ("s2"))) __attribute ((section ("s3")))
void f2 (void);                                   // error (good)

__attribute__ ((section ("s4"))) void f3 (void);
__attribute__ ((section ("s5"))) void f3 (void);  // missing diagnosic

z.c:2:6: error: section of ‘f1’ conflicts with previous declaration
    2 | void f1 (void);
      |      ^~
z.c:5:6: error: section of ‘f2’ conflicts with previous declaration
    5 | void f2 (void);                                   // error (good)
      |      ^~

In addition, referring to a previous declaration in the first declaration of a
symbol is misleading.

Clang diagnoses all instances of the problem as expected (although it too
suffers from the "previous declaration" problem):

z.c:1:33: warning: section does not match previous declaration [-Wsection]
__attribute__ ((section ("s1"), section ("s2")))  // error (good)
                                ^
z.c:1:17: note: previous attribute is here
__attribute__ ((section ("s1"), section ("s2")))  // error (good)
                ^
z.c:4:48: warning: section does not match previous declaration [-Wsection]
__attribute__ ((section ("s2"))) __attribute ((section ("s3")))
                                               ^
z.c:4:17: note: previous attribute is here
__attribute__ ((section ("s2"))) __attribute ((section ("s3")))
                ^
z.c:8:17: warning: section does not match previous declaration [-Wsection]
__attribute__ ((section ("s5"))) void f3 (void);  // missing diagnosic
                ^
z.c:7:17: note: previous attribute is here
__attribute__ ((section ("s4"))) void f3 (void);
                ^
3 warnings generated.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/96126] conflicting attribute section accepted on redeclaration
  2020-07-08 22:01 [Bug c/96126] New: conflicting attribute section accepted on redeclaration msebor at gcc dot gnu.org
@ 2020-07-08 22:01 ` msebor at gcc dot gnu.org
  2020-07-09  0:05 ` msebor at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-07-08 22:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96126

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot gnu.org
   Last reconfirmed|                            |2020-07-08
           Keywords|                            |diagnostic
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I'm testing a fix.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/96126] conflicting attribute section accepted on redeclaration
  2020-07-08 22:01 [Bug c/96126] New: conflicting attribute section accepted on redeclaration msebor at gcc dot gnu.org
  2020-07-08 22:01 ` [Bug c/96126] " msebor at gcc dot gnu.org
@ 2020-07-09  0:05 ` msebor at gcc dot gnu.org
  2020-09-16 20:06 ` cvs-commit at gcc dot gnu.org
  2020-09-16 20:07 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-07-09  0:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96126

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=78666

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
See also pr78666.

Patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549686.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/96126] conflicting attribute section accepted on redeclaration
  2020-07-08 22:01 [Bug c/96126] New: conflicting attribute section accepted on redeclaration msebor at gcc dot gnu.org
  2020-07-08 22:01 ` [Bug c/96126] " msebor at gcc dot gnu.org
  2020-07-09  0:05 ` msebor at gcc dot gnu.org
@ 2020-09-16 20:06 ` cvs-commit at gcc dot gnu.org
  2020-09-16 20:07 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-16 20:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96126

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:71ad0b5dde449ee1f6b755a99f5c52152e375835

commit r11-3239-g71ad0b5dde449ee1f6b755a99f5c52152e375835
Author: Martin Sebor <msebor@redhat.com>
Date:   Wed Sep 16 14:04:01 2020 -0600

    Detect conflicts between incompatible uses of the same attribute (PR
c/78666).

    Resolves:
    PR c/78666 - conflicting attribute alloc_size accepted
    PR c/96126 - conflicting attribute section accepted on redeclaration

    gcc/c-family/ChangeLog:

            PR c/78666
            PR c/96126
            * c-attribs.c (validate_attr_args): New function.
            (validate_attr_arg): Same.
            (handle_section_attribute): Call it.  Introduce a local variable.
            (handle_alloc_size_attribute):  Same.
            (handle_alloc_align_attribute): Same.

    gcc/testsuite/ChangeLog:

            PR c/78666
            PR c/96126
            * gcc.dg/attr-alloc_align-5.c: New test.
            * gcc.dg/attr-alloc_size-13.c: New test.
            * gcc.dg/attr-section.c: New test.
            * c-c++-common/builtin-has-attribute-3.c: Add xfails due to
expected
            warnings to be cleaned up.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/96126] conflicting attribute section accepted on redeclaration
  2020-07-08 22:01 [Bug c/96126] New: conflicting attribute section accepted on redeclaration msebor at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-09-16 20:06 ` cvs-commit at gcc dot gnu.org
@ 2020-09-16 20:07 ` msebor at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-09-16 20:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96126

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch committed in r11-3239.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-16 20:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 22:01 [Bug c/96126] New: conflicting attribute section accepted on redeclaration msebor at gcc dot gnu.org
2020-07-08 22:01 ` [Bug c/96126] " msebor at gcc dot gnu.org
2020-07-09  0:05 ` msebor at gcc dot gnu.org
2020-09-16 20:06 ` cvs-commit at gcc dot gnu.org
2020-09-16 20:07 ` msebor at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).