1 ?RCS: $Id: d_attribut.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
13 ?RCS: $Log: d_attribut.U,v $
14 ?RCS: Revision 3.0.1.3 1995/01/30 14:33:45 ram
15 ?RCS: patch49: test C program now includes <stdio.h> (WED)
17 ?RCS: Revision 3.0.1.2 1995/01/11 15:25:47 ram
18 ?RCS: patch45: fixed typo in the d_attribut variable (ADO)
20 ?RCS: Revision 3.0.1.1 1994/10/29 16:08:55 ram
21 ?RCS: patch36: created by ADO
23 ?MAKE:d_attribute_deprecated d_attribute_format d_attribute_malloc \
24 d_attribute_nonnull d_attribute_noreturn d_attribute_pure \
25 d_attribute_unused d_attribute_warn_unused_result \
26 d_printf_format_null: \
27 Myread Oldconfig cat cc ccflags rm Setvar contains i_stdlib run
28 ?MAKE: -pick add $@ %<
29 ?S:d_attribute_format:
30 ?S: This variable conditionally defines HASATTRIBUTE_FORMAT, which
31 ?S: indicates the C compiler can check for printf-like formats.
33 ?S:d_attribute_deprecated:
34 ?S: This variable conditionally defines HASATTRIBUTE_DEPRECATED, which
35 ?S: indicates that GCC can handle the attribute for marking deprecated
38 ?S:d_printf_format_null:
39 ?S: This variable conditionally defines PRINTF_FORMAT_NULL_OK, which
40 ?S: indicates the C compiler allows printf-like formats to be null.
42 ?S:d_attribute_malloc:
43 ?S: This variable conditionally defines HASATTRIBUTE_MALLOC, which
44 ?S: indicates the C compiler can understand functions as having
45 ?S: malloc-like semantics.
47 ?S:d_attribute_nonnull:
48 ?S: This variable conditionally defines HASATTRIBUTE_NONNULL, which
49 ?S: indicates that the C compiler can know that certain arguments
50 ?S: must not be NULL, and will check accordingly at compile time.
52 ?S:d_attribute_noreturn:
53 ?S: This variable conditionally defines HASATTRIBUTE_NORETURN, which
54 ?S: indicates that the C compiler can know that certain functions
55 ?S: are guaranteed never to return.
58 ?S: This variable conditionally defines HASATTRIBUTE_PURE, which
59 ?S: indicates that the C compiler can know that certain functions
60 ?S: are "pure" functions, meaning that they have no side effects, and
61 ?S: only rely on function input and/or global data for their results.
63 ?S:d_attribute_unused:
64 ?S: This variable conditionally defines HASATTRIBUTE_UNUSED, which
65 ?S: indicates that the C compiler can know that certain variables
66 ?S: and arguments may not always be used, and to not throw warnings
67 ?S: if they don't get used.
69 ?S:d_attribute_warn_unused_result:
70 ?S: This variable conditionally defines
71 ?S: HASATTRIBUTE_WARN_UNUSED_RESULT, which indicates that the C
72 ?S: compiler can know that certain functions have a return values
73 ?S: that must not be ignored, such as malloc() or open().
75 ?C:HASATTRIBUTE_FORMAT ~ %< (GNUC_ATTRIBUTE_CHECK):
76 ?C: Can we handle GCC attribute for checking printf-style formats
78 ?C:PRINTF_FORMAT_NULL_OK:
79 ?C: Allows __printf__ format to be null when checking printf-style
81 ?C:HASATTRIBUTE_MALLOC:
82 ?C: Can we handle GCC attribute for malloc-style functions.
84 ?C:HASATTRIBUTE_NONNULL:
85 ?C: Can we handle GCC attribute for nonnull function parms.
87 ?C:HASATTRIBUTE_NORETURN:
88 ?C: Can we handle GCC attribute for functions that do not return
91 ?C: Can we handle GCC attribute for pure functions
93 ?C:HASATTRIBUTE_UNUSED:
94 ?C: Can we handle GCC attribute for unused variables and arguments
96 ?C:HASATTRIBUTE_DEPRECATED:
97 ?C: Can we handle GCC attribute for marking deprecated APIs
99 ?C:HASATTRIBUTE_WARN_UNUSED_RESULT ~ %< (HASATTRIBUTE):
100 ?C: Can we handle GCC attribute for warning on unused results
102 ?H:?%<:#$d_attribute_deprecated HASATTRIBUTE_DEPRECATED /**/
103 ?H:?%<:#$d_attribute_format HASATTRIBUTE_FORMAT /**/
104 ?H:?%<:#$d_printf_format_null PRINTF_FORMAT_NULL_OK /**/
105 ?H:?%<:#$d_attribute_noreturn HASATTRIBUTE_NORETURN /**/
106 ?H:?%<:#$d_attribute_malloc HASATTRIBUTE_MALLOC /**/
107 ?H:?%<:#$d_attribute_nonnull HASATTRIBUTE_NONNULL /**/
108 ?H:?%<:#$d_attribute_pure HASATTRIBUTE_PURE /**/
109 ?H:?%<:#$d_attribute_unused HASATTRIBUTE_UNUSED /**/
110 ?H:?%<:#$d_attribute_warn_unused_result HASATTRIBUTE_WARN_UNUSED_RESULT /**/
112 ?F:!attrib !attrib.out !attrib.c
113 ?LINT:set d_attribute_deprecated
114 ?LINT:set d_attribute_format
115 ?LINT:set d_printf_format_null
116 ?LINT:set d_attribute_malloc
117 ?LINT:set d_attribute_nonnull
118 ?LINT:set d_attribute_noreturn
119 ?LINT:set d_attribute_pure
120 ?LINT:set d_attribute_unused
121 ?LINT:set d_attribute_warn_unused_result
122 : Look for GCC-style attribute format
123 case "$d_attribute_format" in
126 echo "Checking whether your compiler can handle __attribute__((format)) ..." >&4
127 $cat >attrib.c <<'EOCP'
129 void my_special_printf(char* pat,...) __attribute__((__format__(__printf__,1,2)));
131 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
132 if $contains 'warning' attrib.out >/dev/null 2>&1; then
133 echo "Your C compiler doesn't support __attribute__((format))."
136 echo "Your C compiler supports __attribute__((format))."
140 echo "Your C compiler doesn't seem to understand __attribute__ at all."
144 *) val="$d_attribute_format" ;;
146 set d_attribute_format
150 : Look for GCC-style attribute format with null format allowed
151 case "$d_printf_format_null" in
152 '') case "$d_attribute_format" in
155 echo "Checking whether your compiler allows __printf__ format to be null ..." >&4
156 $cat >attrib.c <<EOCP
162 int null_printf (char* pat,...) __attribute__((__format__(__printf__,1,2)));
163 int null_printf (char* pat,...) { return (int)pat; }
164 int main () { exit(null_printf(NULL)); }
166 if $cc $ccflags -o attrib attrib.c >attrib.out 2>&1 ; then
167 : run the executable in case it produces a run-time warning
168 if $run ./attrib >>attrib.out 2>&1; then
169 if $contains 'warning' attrib.out >/dev/null 2>&1; then
170 echo "Your C compiler doesn't allow __printf__ format to be null."
173 echo "Your C compiler allows __printf__ format to be null."
177 echo "Your C compiler executable failed with __printf__ format null."
181 echo "Your C compiler fails with __printf__ format null."
188 *) val="$d_printf_format_null" ;;
190 set d_printf_format_null
194 : Look for GCC-style attribute malloc
195 case "$d_attribute_malloc" in
198 echo "Checking whether your compiler can handle __attribute__((malloc)) ..." >&4
199 $cat >attrib.c <<'EOCP'
201 char *go_get_some_memory( int how_many_bytes ) __attribute__((malloc));
203 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
204 if $contains 'warning' attrib.out >/dev/null 2>&1; then
205 echo "Your C compiler doesn't support __attribute__((malloc))."
208 echo "Your C compiler supports __attribute__((malloc))."
212 echo "Your C compiler doesn't seem to understand __attribute__ at all."
216 *) val="$d_attribute_malloc" ;;
218 set d_attribute_malloc
222 : Look for GCC-style attribute nonnull
223 case "$d_attribute_nonnull" in
226 echo "Checking whether your compiler can handle __attribute__((nonnull(1))) ..." >&4
227 $cat >attrib.c <<'EOCP'
229 void do_something (char *some_pointer,...) __attribute__((nonnull(1)));
231 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
232 if $contains 'warning' attrib.out >/dev/null 2>&1; then
233 echo "Your C compiler doesn't support __attribute__((nonnull))."
236 echo "Your C compiler supports __attribute__((nonnull))."
240 echo "Your C compiler doesn't seem to understand __attribute__ at all."
244 *) val="$d_attribute_nonnull" ;;
246 set d_attribute_nonnull
250 : Look for GCC-style attribute noreturn
251 case "$d_attribute_noreturn" in
254 echo "Checking whether your compiler can handle __attribute__((noreturn)) ..." >&4
255 $cat >attrib.c <<'EOCP'
257 void fall_over_dead( void ) __attribute__((noreturn));
259 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
260 if $contains 'warning' attrib.out >/dev/null 2>&1; then
261 echo "Your C compiler doesn't support __attribute__((noreturn))."
264 echo "Your C compiler supports __attribute__((noreturn))."
268 echo "Your C compiler doesn't seem to understand __attribute__ at all."
272 *) val="$d_attribute_noreturn" ;;
274 set d_attribute_noreturn
278 : Look for GCC-style attribute pure
279 case "$d_attribute_pure" in
282 echo "Checking whether your compiler can handle __attribute__((pure)) ..." >&4
283 $cat >attrib.c <<'EOCP'
285 int square( int n ) __attribute__((pure));
287 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
288 if $contains 'warning' attrib.out >/dev/null 2>&1; then
289 echo "Your C compiler doesn't support __attribute__((pure))."
292 echo "Your C compiler supports __attribute__((pure))."
296 echo "Your C compiler doesn't seem to understand __attribute__ at all."
300 *) val="$d_attribute_pure" ;;
306 : Look for GCC-style attribute unused
307 case "$d_attribute_unused" in
310 echo "Checking whether your compiler can handle __attribute__((unused)) ..." >&4
311 $cat >attrib.c <<'EOCP'
313 int do_something( int dummy __attribute__((unused)), int n );
315 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
316 if $contains 'warning' attrib.out >/dev/null 2>&1; then
317 echo "Your C compiler doesn't support __attribute__((unused))."
320 echo "Your C compiler supports __attribute__((unused))."
324 echo "Your C compiler doesn't seem to understand __attribute__ at all."
328 *) val="$d_attribute_unused" ;;
330 set d_attribute_unused
334 : Look for GCC-style attribute deprecated
335 case "$d_attribute_deprecated" in
338 echo "Checking whether your compiler can handle __attribute__((deprecated)) ..." >&4
339 $cat >attrib.c <<'EOCP'
341 int I_am_deprecated(void) __attribute__((deprecated));
343 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
344 if $contains 'warning' attrib.out >/dev/null 2>&1; then
345 echo "Your C compiler doesn't support __attribute__((deprecated))."
348 echo "Your C compiler supports __attribute__((deprecated))."
352 echo "Your C compiler doesn't seem to understand __attribute__ at all."
356 *) val="$d_attribute_deprecated" ;;
358 set d_attribute_deprecated
362 : Look for GCC-style attribute warn_unused_result
363 case "$d_attribute_warn_unused_result" in
366 echo "Checking whether your compiler can handle __attribute__((warn_unused_result)) ..." >&4
367 $cat >attrib.c <<'EOCP'
369 int I_will_not_be_ignored(void) __attribute__((warn_unused_result));
371 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
372 if $contains 'warning' attrib.out >/dev/null 2>&1; then
373 echo "Your C compiler doesn't support __attribute__((warn_unused_result))."
376 echo "Your C compiler supports __attribute__((warn_unused_result))."
380 echo "Your C compiler doesn't seem to understand __attribute__ at all."
384 *) val="$d_attribute_warn_unused_result" ;;
386 set d_attribute_warn_unused_result