On Thu, Aug 27, 2015 at 12:04 PM, Pedro Giffuni <p...@freebsd.org> wrote:
> Hello kan; > > On 08/27/15 09:00, Alexander Kabaev wrote: > >> Author: kan >> Date: Thu Aug 27 14:00:23 2015 >> New Revision: 287206 >> URL: https://svnweb.freebsd.org/changeset/base/287206 >> >> Log: >> Repair sys/cdefs.h enough to be usable with GCC 5.x >> >> The __alloc_size and __alloc_align need to be defined to >> nothingness for lint, but the existing check is deficient >> and allows attributes with working __has_attrubute() to >> slip through. >> >> > AFAICT GCC hasn't added __has_attribute(), but if they did recently > that is great news. > > Actually I do not know if they did and I do not think it even matters that much. The existing conditional is not working for lint and I had to shuffle it under bigger '#ifdef lint' protection. Nor is the condition even well formed enough to work with any recent GCC and using __has_attribute in naked form is a mistake: % cat t.c #if __has_attribute(alloc_size) # error Has attribute #endif % mips-portbld-freebsd11.0-gcc --version mips-portbld-freebsd11.0-gcc (FreeBSD Ports Collection for mips) 5.2.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % mips-portbld-freebsd11.0-gcc -E t.c # 1 "t.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "t.c" t.c:2:3: error: #error Has attribute # error Has attribute ^ % gcc48 --version gcc48 (FreeBSD Ports Collection) 4.8.5 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % gcc48 -E t.c # 1 "t.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "t.c" t.c:1:20: error: missing binary operator before token "(" #if __has_attribute(alloc_size) > Modified: >> head/sys/sys/cdefs.h >> >> .. > > > #if !__GNUC_PREREQ__(2, 95) >> @@ -371,24 +382,12 @@ >> #define __returns_twice >> #endif >> >> -#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3) >> -#define __alloc_size(x) __attribute__((__alloc_size__(x))) >> -#else >> -#define __alloc_size(x) >> -#endif >> - >> > > This surely got through in GCC's case through the __GNUC_PREREQ__. > Of course gcc 4.2 has neither attribute but clang has alloc_size > so I wonder why it hasn't affected the lint builds. > > Just curiosity, the change is OK but it will be getting ugly if we > have to add all the new attributes in the !lint section. > > Regards, > > Pedro. > clang in tree does not have the slightest idea about the alloc_size attribute, and that is why it worked, as demonstrated by the test below: % cc --version FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525 Target: x86_64-unknown-freebsd11.0 Thread model: posix % cc -E t.c # 1 "t.c" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 311 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "t.c" 2 The original change to cdefs.h appears to be plain wrong. -- Alexander Kabaev _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"