Previously, invalid parameters in a literal operator function were diagnosed with an uninformative catch all. This commit breaks the catch all into a couple of more informative cases.
Details
Diff Detail
Event Timeline
Thanks for tackling this!
include/clang/Basic/DiagnosticSemaKinds.td | ||
---|---|---|
6889 | Maybe "parameter of literal operator must have type 'unsigned long long', 'long double', 'char', 'wchar_t', 'char16_t', or 'char32_t'"? | |
6895 | on -> for ? | |
6897 | It'd be nice to say what the valid ones are here. "template parameter list for literal operator must be either 'char...' or 'typename T, T...'" maybe? | |
lib/Sema/SemaDeclCXX.cpp | ||
11798–11825 | Factor out an isValidLiteralOperatorTemplateParameterList function to avoid the somewhat-unclear control flow via goto here. | |
11827–11831 | Please invert the sense of the param_size() == 0 test and move this up to the top, so it's right next to the condition that the diagnostic is diagnosing. | |
11846–11847 | Replace these two with ParamType->isSpecificBuiltinType(BuiltinType::ULongLong) and ParamType->isSpecificBuiltinType(BuiltinType::LongDouble). | |
11871–11874 | I don't think this special case is worthwhile. Merge it with the _invalid_param case. |
Thanks, this looks good. I think we can make the control flow a little more obvious by moving the return true;s right after we emit each diagnostic, and that also lets us remove the goto.
lib/Sema/SemaDeclCXX.cpp | ||
---|---|---|
11769 | If you're going to issue diagnostics from here, it'd be clearer to name this checkLiteralOperator[...]. | |
11846 | Drop this goto, we fall through to the same place. | |
11886 | Move the return true; up into the individual cases that bail out, and remove the goto from the success cases. |
Maybe "parameter of literal operator must have type 'unsigned long long', 'long double', 'char', 'wchar_t', 'char16_t', or 'char32_t'"?