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

            Bug ID: 41531
           Summary: Wrong InitializationStyle for auto x(10);
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

Created attachment 21796
  --> https://bugs.llvm.org/attachment.cgi?id=21796&action=edit
Minimal example file to reproduce the issue

It looks like the clang-8 AST holds the wrong InitializationStyle for
declarations with call-style initialization and type auto, i.e. auto x(10);
gets the initialization style 'listinit' instead of 'callinit'.
This seems to be a regression introduced with clang 8 and affects at least the
AST dump and any user of libclang relying on VarDecl::getInitStyle(). See
below:

Minimal example (attached):
===========================
int main(){
    auto callinit(0);
    auto listinit{0};
}

clang-8 -Xclang -ast-dump -fsyntax-only:
========================================
TranslationUnitDecl 0x632bdc8 <<invalid sloc>> <invalid sloc>
| [...]
`-FunctionDecl 0x6367e40 </tmp/test.cpp:1:1, line:4:1> line:1:5 main 'int ()'
  `-CompoundStmt 0x6368270 <col:11, line:4:1>
    |-DeclStmt 0x63680f0 <line:2:5, col:21>
    | `-VarDecl 0x6367f80 <col:5, col:19> col:10 callinit 'int':'int' listinit
    |   `-IntegerLiteral 0x6367fe0 <col:19> 'int' 0
    `-DeclStmt 0x6368258 <line:3:5, col:21>
      `-VarDecl 0x6368118 <col:5, col:19> col:10 listinit 'int':'int' listinit
        `-IntegerLiteral 0x6368178 <col:19> 'int' 0


clang-7 -Xclang -ast-dump -fsyntax-only:
========================================
TranslationUnitDecl 0x20e10e8 <<invalid sloc>> <invalid sloc>
| [...]
`-FunctionDecl 0x211ba28 </tmp/test.cpp:1:1, line:4:1> line:1:5 main 'int ()'
  `-CompoundStmt 0x211beb8 <col:11, line:4:1>
    |-DeclStmt 0x211bcf0 <line:2:5, col:21>
    | `-VarDecl 0x211bb70 <col:5, col:19> col:10 callinit 'int':'int' callinit
    |   `-IntegerLiteral 0x211bbd0 <col:19> 'int' 0
    `-DeclStmt 0x211bea0 <line:3:5, col:21>
      `-VarDecl 0x211bd18 <col:5, col:20> col:10 listinit 'int':'int' listinit
        `-InitListExpr 0x211be58 <col:18, col:20> 'int':'int'
          `-IntegerLiteral 0x211bd78 <col:19> 'int' 0

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to