Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Just exit instead.
Fixes https://github.com/llvm/llvm-project/issues/42535
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156244
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCXX/overloaded-operator-decl.cpp
Index: clang/test/SemaCXX/overloaded-operator-decl.cpp
===================================================================
--- clang/test/SemaCXX/overloaded-operator-decl.cpp
+++ clang/test/SemaCXX/overloaded-operator-decl.cpp
@@ -58,3 +58,9 @@
A()(i);
}
}
+
+namespace GH42535 {
+class E {};
+void operator+(E, ...) {} // expected-error{{overloaded 'operator+' cannot be
variadic}}
+void d() { E() + E(); }
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -13997,6 +13997,10 @@
std::swap(Args[0], Args[1]);
if (FnDecl) {
+
+ if (FnDecl->isInvalidDecl())
+ return ExprError();
+
Expr *Base = nullptr;
// We matched an overloaded operator. Build a call to that
// operator.
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -685,6 +685,8 @@
(`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`)
- Fix crash on nested templated class with template function call.
(`#61159 <https://github.com/llvm/llvm-project/issues/61159>_`)
+- Fix crash on use of a variadic overloaded operator.
+ (`#42535 <https://github.com/llvm/llvm-project/issues/42535>_`)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Index: clang/test/SemaCXX/overloaded-operator-decl.cpp
===================================================================
--- clang/test/SemaCXX/overloaded-operator-decl.cpp
+++ clang/test/SemaCXX/overloaded-operator-decl.cpp
@@ -58,3 +58,9 @@
A()(i);
}
}
+
+namespace GH42535 {
+class E {};
+void operator+(E, ...) {} // expected-error{{overloaded 'operator+' cannot be variadic}}
+void d() { E() + E(); }
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -13997,6 +13997,10 @@
std::swap(Args[0], Args[1]);
if (FnDecl) {
+
+ if (FnDecl->isInvalidDecl())
+ return ExprError();
+
Expr *Base = nullptr;
// We matched an overloaded operator. Build a call to that
// operator.
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -685,6 +685,8 @@
(`#64005 <https://github.com/llvm/llvm-project/issues/64005>_`)
- Fix crash on nested templated class with template function call.
(`#61159 <https://github.com/llvm/llvm-project/issues/61159>_`)
+- Fix crash on use of a variadic overloaded operator.
+ (`#42535 <https://github.com/llvm/llvm-project/issues/42535>_`)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits