sepavloff marked 5 inline comments as done. sepavloff added inline comments.
================ Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1762 def err_init_incomplete_type : Error<"initialization of incomplete type %0">; +def err_list_init_in_parens : Error<"list-initializer for non-class type " + "must not be parenthesized">; ---------------- arphaman wrote: > Wouldn't it be better if we had a diagnostic with the type information? So, > instead of showing `list-initializer for non-class type must not be > parenthesized` clang would show `list-initializer for non-class type 'int' > must not be parenthesized`. What do you think? > > As well as that, it seems that GCC issues a warning instead of an error for > this diagnostic, so should this be a warning in clang as well? Putting type name into the diagnostic message is a good idea, implemented. As for making this message a warning instead of an error, I am in doubt. Pros: - it enhances GCC compatibility, - wrong code may be easily fixed by compiler, Cons: - this is a violation of the standard, - this extension does not add any benefits, - wrong code can be easily fixed by user. I chose to retain current clang behavior and reject questionable code. GCC [[ https://gcc.gnu.org/ml/gcc-patches/2011-08/msg00644.html | patch]] that introduced this message explains using warning by some uncertainty, 5 years passed, I think the standard is stable in viewpoint on such usage. ================ Comment at: lib/Sema/SemaExprCXX.cpp:1229 + Diag(TInfo->getTypeLoc().getLocStart(), diag::err_list_init_in_parens) + << IList->getSourceRange() + << FixItHint::CreateRemoval(LParenLoc) ---------------- arphaman wrote: > Formatting issue: clang-format replaces > > ``` > << IList->getSourceRange() > << FixItHint::CreateRemoval(LParenLoc) > ``` > with > ``` > << IList->getSourceRange() << FixItHint::CreateRemoval(LParenLoc) > ``` After insertion of type `Ty` this is no more the case. https://reviews.llvm.org/D25816 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits