HerrCai0907 updated this revision to Diff 505105. HerrCai0907 added a comment.
add release note CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145892/new/ https://reviews.llvm.org/D145892 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplateVariadic.cpp clang/test/SemaCXX/fold_expr_typo.cpp Index: clang/test/SemaCXX/fold_expr_typo.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/fold_expr_typo.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s + +template <typename... T> +void foo(T &&...Params) { + foo<T>(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\ + expected-error {{use of undeclared identifier 'Unknown'}} + ((foo<T>(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}} +} + +template <typename... U> struct A { + template <typename... T> void foo(T &&...Params) { + foo<T>((... + static_cast<U>(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}} + } +}; Index: clang/lib/Sema/SemaTemplateVariadic.cpp =================================================================== --- clang/lib/Sema/SemaTemplateVariadic.cpp +++ clang/lib/Sema/SemaTemplateVariadic.cpp @@ -1220,10 +1220,11 @@ if (!LHS || !RHS) { Expr *Pack = LHS ? LHS : RHS; assert(Pack && "fold expression with neither LHS nor RHS"); - DiscardOperands(); - if (!Pack->containsUnexpandedParameterPack()) + if (!Pack->containsUnexpandedParameterPack()) { + DiscardOperands(); return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs) << Pack->getSourceRange(); + } } BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -170,6 +170,7 @@ - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough`` by prioritizing ``-Wunreachable-code-fallthrough``. +- Clang won't crash when fold expression contains a delayed typos correction. Bug Fixes in This Version -------------------------
Index: clang/test/SemaCXX/fold_expr_typo.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/fold_expr_typo.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s + +template <typename... T> +void foo(T &&...Params) { + foo<T>(Unknown); // expected-error {{expression contains unexpanded parameter pack 'T'}}\ + expected-error {{use of undeclared identifier 'Unknown'}} + ((foo<T>(Unknown)), ...); // expected-error {{use of undeclared identifier 'Unknown'}} +} + +template <typename... U> struct A { + template <typename... T> void foo(T &&...Params) { + foo<T>((... + static_cast<U>(1))); // expected-error {{expression contains unexpanded parameter pack 'T'}} + } +}; Index: clang/lib/Sema/SemaTemplateVariadic.cpp =================================================================== --- clang/lib/Sema/SemaTemplateVariadic.cpp +++ clang/lib/Sema/SemaTemplateVariadic.cpp @@ -1220,10 +1220,11 @@ if (!LHS || !RHS) { Expr *Pack = LHS ? LHS : RHS; assert(Pack && "fold expression with neither LHS nor RHS"); - DiscardOperands(); - if (!Pack->containsUnexpandedParameterPack()) + if (!Pack->containsUnexpandedParameterPack()) { + DiscardOperands(); return Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs) << Pack->getSourceRange(); + } } BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Operator); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -170,6 +170,7 @@ - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough`` by prioritizing ``-Wunreachable-code-fallthrough``. +- Clang won't crash when fold expression contains a delayed typos correction. Bug Fixes in This Version -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits