I haven't found an existing error message for this in
clang/include/clang/Basic/DiagnosticSemaKinds.td so I have added a new
one. I'm not sure if it in the right place and the formulation might be
improved.
Fixes #48755
Differential D139400
[clang] Show error when a local variables is passed as default template parameter massberg on Dec 6 2022, 12:55 AM. Authored by
Details
I haven't found an existing error message for this in Fixes #48755
Diff Detail
Unit Tests Event TimelineComment Actions It looks like we have an existing message for the regular function case e.g.: void g() { int x; void f(int y = x); auto lambda1 = [] <auto y = x> {}; } The diagnostic is : error: default argument references local variable 'x' of enclosing function void f(int y = x); ^ see godbolt: https://godbolt.org/z/1vneM5b35 Comment Actions It looks like the existing diagnostic is issued by CheckDefaultArgumentVisitor. I think you can reuse it here but not 100% on that. Comment Actions Thanks! We can indeed reuse this error message. Thanks for the pointer! CheckDefaultArgumentVisitor is for default arguments of functions. As it does many additional checks we cannot reuse it for testing default arguments of templates.
|
Please remove.