diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -2153,11 +2153,13 @@ OS << ")"; CXXNewExpr::InitializationStyle InitStyle = E->getInitializationStyle(); - if (InitStyle) { - if (InitStyle == CXXNewExpr::CallInit) + if (InitStyle != CXXNewExpr::NoInit) { + bool Bare = InitStyle == CXXNewExpr::CallInit && + !isa(E->getInitializer()); + if (Bare) OS << "("; PrintExpr(E->getInitializer()); - if (InitStyle == CXXNewExpr::CallInit) + if (Bare) OS << ")"; } } @@ -2219,19 +2221,19 @@ PrintExpr(E->getSubExpr()); } -void -StmtPrinter::VisitCXXUnresolvedConstructExpr( - CXXUnresolvedConstructExpr *Node) { +void StmtPrinter::VisitCXXUnresolvedConstructExpr( + CXXUnresolvedConstructExpr *Node) { Node->getTypeAsWritten().print(OS, Policy); - OS << "("; - for (CXXUnresolvedConstructExpr::arg_iterator Arg = Node->arg_begin(), - ArgEnd = Node->arg_end(); - Arg != ArgEnd; ++Arg) { + if (!Node->isListInitialization()) + OS << '('; + for (auto Arg = Node->arg_begin(), ArgEnd = Node->arg_end(); Arg != ArgEnd; + ++Arg) { if (Arg != Node->arg_begin()) OS << ", "; PrintExpr(*Arg); } - OS << ")"; + if (!Node->isListInitialization()) + OS << ')'; } void StmtPrinter::VisitCXXDependentScopeMemberExpr( diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp @@ -72,7 +72,7 @@ }; template requires requires(T t) { typename E::non_default_constructible{}; } -// expected-note@-1 {{because 'typename E::non_default_constructible({})' would be invalid: no matching constructor for initialization of 'typename E::non_default_constructible'}} +// expected-note@-1 {{because 'typename E::non_default_constructible{}' would be invalid: no matching constructor for initialization of 'typename E::non_default_constructible'}} struct r6 {}; using r6i1 = r6; diff --git a/clang/test/SemaCXX/cxx2b-ast-print.cpp b/clang/test/SemaCXX/cxx2b-ast-print.cpp --- a/clang/test/SemaCXX/cxx2b-ast-print.cpp +++ b/clang/test/SemaCXX/cxx2b-ast-print.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++2b -fsyntax-only -ast-print %s | FileCheck %s +template