This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Clang: Replacing __attribute((__warning__())) by __attribute__((deprecated()))


Sorry, I forgot to mention but the issue is related to these invocations in newlib/libc/include/stdlib.h such as: char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));

The Clang warning message is:
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));

/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4/arm-none-eabi/include/stdlib.h:114:44: warning: unknown attribute '__warning__' ignored
      [-Wunknown-attributes]
char * _EXFUN(mktemp,(char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
                                            ^
/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4/arm-none-eabi/include/_ansi.h:101:42: note: expanded from macro '_ATTRIBUTE'
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
                                         ^
/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4/arm-none-eabi/include/_ansi.h:65:35: note: expanded from macro '_EXFUN'
#define _EXFUN(name, proto)             name proto
                                             ^


On 25.10.2015 18:31, Olivier MARTIN wrote:
Clang does not support the function attribute __warning__(), it raises
the warning message: "warning: unknown attribute '__warning__'
ignored"
A solution would be to replace the attribute __warning__() by deprecated().

Here is the GCC & Clang behaviour with some function attributes:

# The source code:
----------------------------
void func1(void) __attribute__((__warning__ ("the use of `func1' is
dangerous; use `funcN' instead")));
void func2(void) __attribute__((deprecated("Deprecated func2; use
`funcN` instead")));
void func3(void) __attribute__((warning("the use of `func3' is
dangerous; use `funcN' instead")));

int main(void) {
  func1();
  func2();
  func3();
  return 0;
}
---------------------------

# With GCC:
---------------------------
mytest.c: In function âmainâ:
mytest.c:7:3: warning: âfunc2â is deprecated (declared at mytest.c:2):
Deprecated func2; use `funcN` instead [-Wdeprecated-declarations]
   func2();
   ^
mytest.c:6:8: warning: call to âfunc1â declared with attribute
warning: the use of `func1' is dangerous; use `funcN' instead [enabled
by default]
   func1();
        ^
mytest.c:8:8: warning: call to âfunc3â declared with attribute
warning: the use of `func3' is dangerous; use `funcN' instead [enabled
by default]
   func3();
---------------------------

# With Clang:
---------------------------
mytest.c:1:33: warning: unknown attribute '__warning__' ignored
[-Wunknown-attributes]
void func1(void) __attribute__((__warning__ ("the use of `func1' is
dangerous; use `funcN' instead")));
                                ^
mytest.c:3:33: warning: unknown attribute 'warning' ignored
[-Wunknown-attributes]
void func3(void) __attribute__((warning("the use of `func3' is
dangerous; use `funcN' instead")));
                                ^
mytest.c:7:3: warning: 'func2' is deprecated: Deprecated func2; use
`funcN` instead [-Wdeprecated-declarations]
  func2();
  ^
mytest.c:2:6: note: 'func2' has been explicitly marked deprecated here
void func2(void) __attribute__((deprecated("Deprecated func2; use
`funcN` instead")));
     ^
3 warnings generated.
---------------------------

Here is the list of the function attributes supported by clang:
- http://clang.llvm.org/docs/LanguageExtensions.html
- http://clang.llvm.org/docs/AttributeReference.html

Are you happy by my suggestion of replacing
__attribute((__warning__())) by __attribute__((deprecated()))?
I am happy to send a patch if needed.
Thanks,

--
Olivier MARTIN
http://labapart.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]