[llvm-bugs] [Bug 41127] New: AST dumping a function misbehaves with esoteric return or parameter types

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 18 10:39:26 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41127

            Bug ID: 41127
           Summary: AST dumping a function misbehaves with esoteric return
                    or parameter types
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaron at aaronballman.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190318/a152ac28/attachment.html>


More information about the llvm-bugs mailing list