Finding pointer arguments with GnuCParser?
<p>I'm trying to parse this fragment of C code:</p>

<pre><code>void foo(const int *bar, int * const baz);
</code></pre>

<p>using <code>GnuCParser</code>, part of <a href="https://github.com/inducer/pycparserext" rel="nofollow">pycparserext</a>.</p>

<p>Based on <a href="http://stackoverflow.com/a/21872138/28169">this answer</a> I expected to see some <code>PtrDecl</code>s, but here's what I get from <code>ast.show()</code> on the resulting parse tree:</p>

<pre><code>FileAST:
  Decl: foo, [], [], []
    FuncDecl:
      ParamList:
        Decl: bar, ['const'], [], []
          TypeDeclExt: bar, ['const']
            IdentifierType: ['int']
        Decl: baz, [], [], []
          TypeDeclExt: baz, []
            IdentifierType: ['int']
      TypeDecl: foo, []
        IdentifierType: ['void']
</code></pre>

<p>Notice how <code>baz</code>, a "const pointer to <code>int</code>", doesn't have a trace of <code>const</code> (or "pointeryness") in the data printed by <code>ast.show()</code>. Is this difference because of <code>GnuCParser</code>?</p>

<p>How do I figure out the type of <code>baz</code> from the AST? My actual C code needs the GNU parser. I'm using pycparserext version 2016.1.</p>

<p><em>UPDATE</em>: I've created a <a href="https://github.com/inducer/pycparserext/issues/21" rel="nofollow">pycparserext issue on GitHub</a>.</p>

<p>I'm not sure what the issue with pycparserext here, but if I run it through the vanilla <a href="https://github.com/eliben/pycparser" rel="nofollow">pycparser</a> I get:</p>

<pre><code>FileAST: 
  Decl: foo, [], [], []
    FuncDecl: 
      ParamList: 
        Decl: bar, ['const'], [], []
          PtrDecl: []
            TypeDecl: bar, ['const']
              IdentifierType: ['int']
        Decl: baz, [], [], []
          PtrDecl: ['const']
            TypeDecl: baz, []
              IdentifierType: ['int']
      TypeDecl: foo, []
        IdentifierType: ['void']
</code></pre>

<p>Which looks entirely reasonable for this input.</p>

python gcc pycparser