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

            Bug ID: 88546
           Summary: Copy attribute unusable for weakrefs
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

I've tried following patch to quiet the hundreds of warnings we get during
bootstrap due to -Wmissing-attributes:
2018-12-18  Jakub Jelinek  <ja...@redhat.com>

        * gthr-posix.h (__gthrw2): Add __copy__ argument.

--- libgcc/gthr-posix.h.jj      2018-01-03 10:42:56.133763484 +0100
+++ libgcc/gthr-posix.h 2018-12-18 15:16:03.720109264 +0100
@@ -87,7 +87,8 @@ typedef struct timespec __gthread_time_t
 #  define __gthrw_pragma(pragma)
 # endif
 # define __gthrw2(name,name2,type) \
-  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
+  static __typeof(type) name \
+  __attribute__ ((__weakref__(#name2), __copy__(type))); \
   __gthrw_pragma(weak type)
 # define __gthrw_(name) __gthrw_ ## name
 #else

but unfortunately that patch just trades one set of warnings like:
../../libgcc/gthr-default.h:99:32: warning: ‘__gthrw_pthread_equal’ specifies
less restrictive attributes than its target ‘pthread_equal’: ‘const’, ‘leaf’,
‘nothrow’ [-Wmissing-attributes]
   99 | #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
      |                                ^~~~~~~~
etc. for:
../../libgcc/gthr-default.h:237:1: warning: ‘leaf’ attribute has no effect on
unit local functions [-Wattributes]
  237 | __gthrw2(__gthrw_(__pthread_key_create),
      | ^~~~~~~~
../../libgcc/gthr-default.h:100:32: warning: ‘__gthrw_pthread_equal’ specifies
less restrictive attribute than its target ‘pthread_equal’: ‘leaf’
[-Wmissing-attributes]
  100 | #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
      |                                ^~~~~~~~

So, probably leaf attribute shouldn't be copied if the decl on which it is is
unit local (weakrefs are) and -Wmissing-attributes needs to be fixed not to
emit the bogus diagnostics about leaf.

Reply via email to