Bug 169243

Summary: Fix -Wattributes warning spam
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebKit2Assignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, benjamin, cdumez, cmarcelo, commit-queue, darin, dbates, mcatanzaro, thorton
Priority: P2    
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch
none
Patch none

Description Michael Catanzaro 2017-03-06 18:41:26 PST
-Wattributes warning spam caused by r213198:

../../Source/WebKit2/UIProcess/API/C/WKPageGroup.h:55:102: warning: ‘unavailable’ attribute directive ignored [-Wattributes]
 WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup) __attribute__((unavailable));
                                                                                                      ^
../../Source/WebKit2/UIProcess/API/C/WKPageGroup.h:56:143: warning: ‘unavailable’ attribute directive ignored [-Wattributes]
 WK_EXPORT void WKPageGroupAddUserContentFilter(WKPageGroupRef pageGroup, WKUserContentFilterRef userContentFilter) __attribute__((unavailable));
                                                                                                                                               ^
../../Source/WebKit2/UIProcess/API/C/WKPageGroup.h:57:139: warning: ‘unavailable’ attribute directive ignored [-Wattributes]
 WK_EXPORT void WKPageGroupRemoveUserContentFilter(WKPageGroupRef pageGroup, WKStringRef userContentFilterName) __attribute__((unavailable));

It prints hundreds of times, since it's in a header file.
Comment 1 Michael Catanzaro 2017-03-06 18:43:47 PST
Created attachment 303600 [details]
Patch
Comment 2 mitz 2017-03-06 18:59:23 PST
Comment on attachment 303600 [details]
Patch

Don’t import wtf headers from WebKit2 framework headers. Instead, you can define WK_UNAVAILABLE in WKDeclarationSpecifiers.h.
Comment 3 Michael Catanzaro 2017-03-06 19:36:28 PST
(In reply to comment #2)
> Comment on attachment 303600 [details]
> Patch
> 
> Don’t import wtf headers from WebKit2 framework headers.

Umm yeah, that was dumb, oops.
Comment 4 Alexey Proskuryakov 2017-03-06 22:32:40 PST
This failure is surprising, given that NS_UNAVAILAbLE is defined in macOS like this:

/*
 * only certain compilers support __attribute__((unavailable))
 */
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
    #define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable))
#else
    #define UNAVAILABLE_ATTRIBUTE
#endif

#if !defined(NS_UNAVAILABLE)
#define NS_UNAVAILABLE UNAVAILABLE_ATTRIBUTE
#endif
Comment 5 Michael Catanzaro 2017-03-07 07:02:26 PST
Weird. I have absolutely no clue; maybe it used to exist but was removed (very unlikely), maybe Apple has its own fork of GCC where it added that attribute (seems unlikely too), maybe you don't care about GCC and the check is really just there for Clang (also seems unlikely)... I don't know! It's not documented anywhere and it definitely does not work.
Comment 6 Michael Catanzaro 2017-03-07 12:43:46 PST
Created attachment 303703 [details]
Patch
Comment 7 Michael Catanzaro 2017-03-07 12:44:40 PST
Let's see if EWS likes this.

Note: __has_extension is guaranteed to be defined where I removed the check for it; that's a drive-by cleanup.
Comment 8 Michael Catanzaro 2017-03-08 18:05:35 PST
Comment on attachment 303703 [details]
Patch

Thanks!
Comment 9 WebKit Commit Bot 2017-03-08 18:40:58 PST
Comment on attachment 303703 [details]
Patch

Clearing flags on attachment: 303703

Committed r213620: <http://trac.webkit.org/changeset/213620>
Comment 10 WebKit Commit Bot 2017-03-08 18:41:04 PST
All reviewed patches have been landed.  Closing bug.