[clang] [Clang] Fix crash when ill-formed code is treated as a deduction guide (PR #67373)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 25 16:27:35 PDT 2023
================
@@ -171,3 +171,12 @@ namespace CtorTemplateBeatsNonTemplateConversionFn {
Foo f(Derived d) { return d; } // expected-error {{invokes a deleted function}}
Foo g(Derived d) { return Foo(d); } // ok, calls constructor
}
+
+namespace GH65522 {
+template<typename A3>
+class B3 : A3 {
+ template<bool = C3<B3>()> // expected-warning 2{{use of function template name with no prior declaration in function call with explicit}}
+ B3();
+}; B3(); // expected-error {{deduction guide declaration without trailing return type}} \
+ // expected-note {{while building deduction guide here}}
----------------
shafik wrote:
Yes, your modifications IIUC does trigger the crash: https://godbolt.org/z/a8e9WrM37
but it generates a lot more diagnostics, running the test with the modified code generates three additional diagnostics:
```console
error: 'expected-error' diagnostics seen but not expected:
File /Users/shafik/llvm_org_6/llvm-project/clang/test/SemaCXX/cxx1z-copy-omission.cpp Line 182: no viable constructor or deduction guide for deduction of template arguments of 'B3'
error: 'expected-note' diagnostics seen but not expected:
File /Users/shafik/llvm_org_6/llvm-project/clang/test/SemaCXX/cxx1z-copy-omission.cpp Line 179: candidate template ignored: couldn't infer template argument ''
File /Users/shafik/llvm_org_6/llvm-project/clang/test/SemaCXX/cxx1z-copy-omission.cpp Line 177: candidate function template not viable: requires 1 argument, but 0 were provided
3 errors generated.
```
When I first found the issue I spent some time trying to reduce it down but w/o success.
https://github.com/llvm/llvm-project/pull/67373
More information about the cfe-commits
mailing list