llvm-capstone/clang/test/SemaCXX/GH61441.cpp
Ilya Biryukov 282cae0b9a [Sema] Fix crash on __fp16 parameters in template instantiations
Fixes #61441.

Currently, Clang stores `nullptr` in the parameter lists inside
`FunctionProtoTypeLoc` if `__fp16` is used without pointer qualifiers.

Any code path that calls `Declarator::setInvalidType()` before
`GetFullTypeForDeclarator` will lead to the same problem downstream.

The relevant code is:
```cpp
if (D.isInvalidType())
  return Context.getTrivialTypeSourceInfo(T);

return GetTypeSourceInfoForDeclarator(state, T, TInfo);
```

`GetTypeSourceInfoForDeclarator` sets the parameter `Decl`, but we can't
call it when `isInvalidType() == true` as this causes other assertion
failures that seem harder to fix.

Reviewed By: kadircet

Differential Revision: https://reviews.llvm.org/D146426
2023-03-21 14:06:46 +01:00

13 lines
437 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify -cl-std=clc++ -fblocks %s
// Checks Clang does not crash. We run in OpenCL mode to trigger block pointer
// crash. The __fp16 crash happens in standard mode too.
template <bool>
int foo() {
auto x = [&](__fp16) { return 0; }; // expected-error {{not allowed}}
auto y = [&](void(^)(int)) { return 0; }; // expected-error {{not allowed}}
return 0;
}
int bar() { return foo<true>(); }