summaryrefslogtreecommitdiff
path: root/pycparser/c_generator.py
diff options
context:
space:
mode:
authorVitaly Cheptsov <4348897+vit9696@users.noreply.github.com>2021-10-04 16:20:47 +0300
committerGitHub <noreply@github.com>2021-10-04 06:20:47 -0700
commit14ffe7bc486805c568403757d8634211f8458451 (patch)
tree991da5b6498df6bd37d1bc855dbf325c33f96ad4 /pycparser/c_generator.py
parent007e79e5ba45d3f3c4325578a91f7786a7b88cfb (diff)
downloadpycparser-14ffe7bc486805c568403757d8634211f8458451.tar.gz
Implement _Alignas and _Alignof support with tests (#435)
* Implement _Alignas and _Alignof support with tests * Improve testing and avoid unnecessary alignas for typedef * Add more tests * Drop legacy artifact * Remove extra _add_declaration_specifier call * Drop custom equality comparators for now Co-authored-by: vit9696 <vit9696@users.noreply.github.com>
Diffstat (limited to 'pycparser/c_generator.py')
-rw-r--r--pycparser/c_generator.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/pycparser/c_generator.py b/pycparser/c_generator.py
index ded8c65..fdfe589 100644
--- a/pycparser/c_generator.py
+++ b/pycparser/c_generator.py
@@ -180,6 +180,9 @@ class CGenerator(object):
def visit_Enum(self, n):
return self._generate_struct_union_enum(n, name='enum')
+ def visit_Alignas(self, n):
+ return '_Alignas({})'.format(self.visit(n.alignment))
+
def visit_Enumerator(self, n):
if not n.value:
return '{indent}{name},\n'.format(
@@ -418,6 +421,7 @@ class CGenerator(object):
s = ''
if n.funcspec: s = ' '.join(n.funcspec) + ' '
if n.storage: s += ' '.join(n.storage) + ' '
+ if n.align: s += self.visit(n.align[0]) + ' '
s += self._generate_type(n.type)
return s