Help with Sema code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help with Sema code

Renato Golin via cfe-dev
Hi all,

I'm new to the clang code base. I decided to take a look at bug https://bugs.llvm.org/show_bug.cgi?id=23029, as it is affecting one of my daily projects.

I came up with two different solutions for it, but I have no idea which one is the best.

The problem:
If I have a template declaration like:

template <typename... T>
void f(int i = 0, T ...args) {}

I cannot instantiate with `f(1, 1);` as clang will complain that there is no default value for `args`.

The first solution is to avoid calling the function `CheckCXXDefaultArguments(NewFD)` in file `SemaDecl.cpp`, in the function `Sema::CheckFunctionDeclaration()` when it is a template instantiation, assuming the check was already done in the template definition.

The second one is to modify the check in `Sema::CheckCXXDefaultArguments()` in file `SemaDeclCXX.cpp`, to check if a parameter is a template substitution, and if so, check if the original parameter is a parameter pack.

Can someone with more knowledge about this part of the code give me some advice? Is the assumption for solution one always valid? And which solution would be preferred?

Regards,
Mario

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev