summaryrefslogtreecommitdiffstats
path: root/main/autoconf/0002-Fix-regression-of-AC_CHECK_SIZEOF-on-pointer-types.patch
blob: c19783933c473107c984268f40679ddff46793c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
From dfda4402552ac26ce91399e2a812aee4772a512e Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Tue, 6 Jul 2010 22:00:44 +0200
Subject: [PATCH 2/5] Fix regression of AC_CHECK_SIZEOF on pointer types.

* lib/autoconf/types.m4 (AC_CHECK_SIZEOF): Translate `*' to `p'
when checking literal-ness of the type, for pointer types.
* lib/m4sugar/m4sh.m4 (_AS_TR_SH): Also consider `*' as literal.
(_AS_TR_CPP): Likewise.
* tests/semantics.at (AC_CHECK_ALIGNOF struct): When checking
for numeric answer, be sure to not allow variable references.
(AC_CHECK_SIZEOF struct): Likewise.  Also, test the
`AC_CHECK_SIZEOF([int *])' example from the manual.
* doc/autoconf.texi (Generic Compiler Characteristics): Add
example marker.
* NEWS: Update.
Reports by Nishio Futoshi and Roberto Bagnara.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
---
 ChangeLog             |   17 +++++++++++++++++
 NEWS                  |    3 +++
 doc/autoconf.texi     |    1 +
 lib/autoconf/types.m4 |    2 +-
 lib/m4sugar/m4sh.m4   |    4 ++--
 tests/semantics.at    |   10 +++++++---
 6 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 39c2ba6..76b01c9 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -6957,6 +6957,7 @@ argument was used when cross-compiling.
 For example, the call
 
 @example
+@c If you change this example, adjust tests/semantics.at:AC_F77_DUMMY_MAIN usage.
 AC_CHECK_SIZEOF([int *])
 @end example
 
diff --git a/lib/autoconf/types.m4 b/lib/autoconf/types.m4
index ee07148..9f482da 100644
--- a/lib/autoconf/types.m4
+++ b/lib/autoconf/types.m4
@@ -763,7 +763,7 @@ Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])
 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
 # ---------------------------------------------------------------
 AC_DEFUN([AC_CHECK_SIZEOF],
-[AS_LITERAL_IF([$1], [],
+[AS_LITERAL_IF(m4_translit([[$1]], [*], [p]), [],
 	       [m4_fatal([$0: requires literal arguments])])]dnl
 [# The cast to long int works around a bug in the HP C Compiler
 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index e1d03d9..6fbc9e1 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -1779,7 +1779,7 @@ m4_defun_init([AS_TR_SH],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_SH],
-[_AS_LITERAL_IF([$1], [	 ][
+[_AS_LITERAL_IF([$1], [*][	 ][
 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_SH_LITERAL],
@@ -1812,7 +1812,7 @@ m4_defun_init([AS_TR_CPP],
 [_$0(m4_expand([$1]))])
 
 m4_define([_AS_TR_CPP],
-[_AS_LITERAL_IF([$1], [	 ][
+[_AS_LITERAL_IF([$1], [*][	 ][
 ])([], [$0_INDIR], [$0_LITERAL])([$1])])
 
 m4_define([_AS_TR_CPP_LITERAL],
diff --git a/tests/semantics.at b/tests/semantics.at
index b703fd4..48136cd 100644
--- a/tests/semantics.at
+++ b/tests/semantics.at
@@ -350,7 +350,7 @@ AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
 [[AC_CHECK_ALIGNOF([struct { char c; }])
 AC_CHECK_ALIGNOF([struct nosuchstruct])
 ]],
-[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [^0]" config.h]],
+[AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
 	 0, ignore)
 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
 	 0, ignore)
@@ -379,13 +379,17 @@ AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
 AC_CHECK_SIZEOF([struct nosuchstruct])
+# Taken from autoconf.texi:Generic Compiler Characteristics.
+AC_CHECK_SIZEOF([int *])
 ]],
-[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [^0]" config.h]],
+[AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
 	 0, ignore)
-AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [^0]" config.h]],
+AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
 	 0, ignore)
 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
 	 0, ignore)
+AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
+	 0, ignore)
 ])
 
 
-- 
1.7.1.1