[frama-clang] Cannot parse C++14 generic lambda
Steps to reproduce the issue
Please find attached two example sources that demonstrate the issue: fails.cpp works.cpp
> cat fails.cpp
int main(int argc, char *argv[]) {
auto lambda = [](auto argc) { return argc; };
return lambda(argc);
}
> clang++-11 -E -o fails.ii fails.cpp
> frama-c -deps -cpp-extra-args="-std=c++14" fails.ii
Expected output
[kernel] Parsing fails.ii (external front-end)
Now output intermediate result
<...>
[from] Computing for function main
[from] Done for function main
[from] ====== DEPENDENCIES COMPUTED ======
These dependencies hold at termination for the executions that terminate:
[from] Function UliEUcE__cons:
__fc_lam FROM __fc_closure; __fc_func
[from] Function __fc_lambda_def:
\result FROM argc
[from] Function main:
\result FROM argc
[from] ====== END OF DEPENDENCIES ======
Actual output
[kernel] Parsing fails.ii (external front-end)
framaCIRGen: /usr/lib/llvm-11/include/clang/AST/Type.h:671: const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
Aborted
[kernel] User Error: Failed to parse C++ file. See Clang messages for more information
[kernel] User Error: stopping on file "fails.ii" that has errors.
[kernel] Frama-C aborted: invalid user input.
Minimal working diff
It works if we write int
instead of auto
for the type of the lambda parameter:
> diff -u fails.cpp works.cpp
--- fails.cpp 2021-06-08 22:42:13 +0200
+++ works.cpp 2021-06-08 22:43:48 +0200
@@ -1,4 +1,4 @@
int main(int argc, char *argv[]) {
- auto lambda = [](auto argc) { return argc; };
+ auto lambda = [](int argc) { return argc; };
return lambda(argc);
}
Contextual information
- Frama-C: framac/frama-c:22.0 Docker Image ID e45780e160f1
- Plug-in used: frama-clang-0.0.10 built from official source drop
- Compiler: Debian clang version 11.1.0
- Target: x86_64-pc-linux-gnu
Additional information
Generic lambdas are a C++14 language feature: https://isocpp.org/wiki/faq/cpp14-language#generic-lambdas
Edited by Stefan Gränitz