<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AST dumping a function misbehaves with esoteric return or parameter types"
   href="https://bugs.llvm.org/show_bug.cgi?id=41127">41127</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AST dumping a function misbehaves with esoteric return or parameter types
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aaron@aaronballman.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following snippet of legal C code:

struct S { int x, y; } f(int i) {
  return (struct S){1, 2};
}

The AST dump generated for that is:

TranslationUnitDecl
|-RecordDecl <line:1:1, col:22> col:8 struct S definition
| |-FieldDecl <col:12, col:16> col:16 referenced x 'int'
| `-FieldDecl <col:12, col:19> col:19 y 'int'

Note that the FunctionDecl is entirely missing. We have similarly bad behavior
when defining the type within the function parameter list in that it neglects
to print the structure.

void g(struct T { int x, y; } t) {
}

void h(struct { int x, y; } t) {
}

Results in:

TranslationUnitDecl
|-FunctionDecl <line:1:1, line:2:1> line:1:6 g 'void (struct T)'
| |-ParmVarDecl <col:8, col:31> col:31 t 'struct T':'struct T'
| `-CompoundStmt <col:34, line:2:1>
|-RecordDecl <line:4:8, col:27> col:8 struct definition
| |-FieldDecl <col:17, col:21> col:21 x 'int'
| `-FieldDecl <col:17, col:24> col:24 y 'int'
`-FunctionDecl <col:1, line:5:1> line:4:6 h 'void (struct (anonymous struct at
line:4:8))'
  |-ParmVarDecl <col:8, col:29> col:29 t 'struct (anonymous struct at
line:4:8)':'struct (anonymous at line:4:8)'
  `-CompoundStmt <col:32, line:5:1>

g() does not have the structure definition printed for it, and the anonymous
struct defined in h() looks like it's at TU scope (which may be okay given that
the anonymous struct cannot be named elsewhere anyway).</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>