[clang] [clang][bytecode] Handle invalid function in CXXInheritedCtorInitExpr (PR #209138)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 13 04:04:54 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/209138.diff
2 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2-1)
- (modified) clang/test/AST/ByteCode/invalid.cpp (+14)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index a50980d23d3b2..908e9a81c19ca 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4140,7 +4140,8 @@ bool Compiler<Emitter>::VisitCXXInheritedCtorInitExpr(
assert(!Ctor->isTrivial() &&
"Trivial CXXInheritedCtorInitExpr, implement. (possible?)");
const Function *F = this->getFunction(Ctor);
- assert(F);
+ if (!F)
+ return false;
assert(!F->hasRVO());
assert(F->hasThisPointer());
diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp
index 930565181b202..0e6d2d4b508b8 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -227,3 +227,17 @@ namespace DefinitionInBody {
return 5;
}
}
+
+namespace InheritedCtor {
+ struct S {
+ constexpr S(int = ; // both-note {{to match this}} \
+ // both-error {{expected ';' at end of declaration list}} \
+ // both-error {{expected expression}}
+ }; // both-error {{expected ')'}}
+
+ struct SS : S {
+ using S::S;
+ };
+
+ SS ss{42};
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/209138
More information about the cfe-commits
mailing list