Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast-print generates wrong output for braced-init-list constructor initializations #64061

Closed
strimo378 opened this issue Jul 24, 2023 · 4 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@strimo378
Copy link
Contributor

Hi all,

the AST printer (-Xclang -ast-print) generates wrong output for braced-init-list constructor initializations. E.g. field{} is always out field({}).

The following code (see https://godbolt.org/z/6cvG8bGje)

struct a {
};

struct c {
    int b;
    a a1,a2;
    c() : b{}, a1({}), a2{}     {
    }
};

is generates as

struct a {
};
struct c {
  int b;
  a a1;
  a a2;
  c() : b({}), a1({}), a2({}) {
  }
};

Especially, the output of b({}) is incorrect C++ code.

@strimo378
Copy link
Contributor Author

I already have a fix and will issues a merge request as soon as a dependent merge request is merged. It currently takes me several weeks to get a simple merge processed. Any tips are appreciated!

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Jul 24, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Jul 24, 2023

@llvm/issue-subscribers-clang-frontend

@strimo378
Copy link
Contributor Author

strimo378 added a commit that referenced this issue Jul 27, 2023
DeclPrinter::PrintConstructorInitializers did not consider curly constructor initializers. Any curly constructor initializers (e.g. `A() : Field{}`) was printed with round brackets (e.g. `A() : Field({})`).

#64061

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D156307
eymay pushed a commit to eymay/llvm-project that referenced this issue Jul 28, 2023
DeclPrinter::PrintConstructorInitializers did not consider curly constructor initializers. Any curly constructor initializers (e.g. `A() : Field{}`) was printed with round brackets (e.g. `A() : Field({})`).

llvm#64061

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D156307
@strimo378
Copy link
Contributor Author

fixed

razmser pushed a commit to razmser/llvm-project that referenced this issue Sep 8, 2023
DeclPrinter::PrintConstructorInitializers did not consider curly constructor initializers. Any curly constructor initializers (e.g. `A() : Field{}`) was printed with round brackets (e.g. `A() : Field({})`).

llvm#64061

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D156307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

3 participants