]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi: avoid reserved keywords
authorBlue Swirl <blauwirbel@gmail.com>
Mon, 30 Jul 2012 15:46:55 +0000 (15:46 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Thu, 9 Aug 2012 18:34:57 +0000 (18:34 +0000)
Clang compiler complained about use of reserved word 'restrict' in SLIRP
and QAPI.

Prefix C keywords with "q_", adjust SLIRP accordingly.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
net/slirp.c
scripts/qapi.py

index 08adb97da59b7ff37697993cebfd7b7a81d2b8b9..8db66ea53906112769dedfd36b80bbdbfcff0d80 100644 (file)
@@ -718,9 +718,9 @@ int net_init_slirp(const NetClientOptions *opts, const char *name,
     net_init_slirp_configs(user->hostfwd, SLIRP_CFG_HOSTFWD);
     net_init_slirp_configs(user->guestfwd, 0);
 
-    ret = net_slirp_init(peer, "user", name, user->restrict, vnet, user->host,
-                         user->hostname, user->tftp, user->bootfile,
-                         user->dhcpstart, user->dns, user->smb,
+    ret = net_slirp_init(peer, "user", name, user->q_restrict, vnet,
+                         user->host, user->hostname, user->tftp,
+                         user->bootfile, user->dhcpstart, user->dns, user->smb,
                          user->smbserver);
 
     while (slirp_configs) {
index d3b8b4d851f3d383aad8764bffe0fb1d9eceb89d..122b4cb6d13a5bb856faa9c00984902aadd8f47e 100644 (file)
@@ -142,6 +142,22 @@ def camel_case(name):
     return new_name
 
 def c_var(name):
+    # ANSI X3J11/88-090, 3.1.1
+    c89_words = set(['auto', 'break', 'case', 'char', 'const', 'continue',
+                     'default', 'do', 'double', 'else', 'enum', 'extern', 'float',
+                     'for', 'goto', 'if', 'int', 'long', 'register', 'return',
+                     'short', 'signed', 'sizeof', 'static', 'struct', 'switch',
+                     'typedef', 'union', 'unsigned', 'void', 'volatile', 'while'])
+    # ISO/IEC 9899:1999, 6.4.1
+    c99_words = set(['inline', 'restrict', '_Bool', '_Complex', '_Imaginary'])
+    # ISO/IEC 9899:2011, 6.4.1
+    c11_words = set(['_Alignas', '_Alignof', '_Atomic', '_Generic', '_Noreturn',
+                     '_Static_assert', '_Thread_local'])
+    # GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html
+    # excluding _.*
+    gcc_words = set(['asm', 'typeof'])
+    if name in c89_words | c99_words | c11_words | gcc_words:
+        return "q_" + name
     return name.replace('-', '_').lstrip("*")
 
 def c_fun(name):