llvm-project/clang/test/Parser/cxx-declarator-attribute-crash.cpp
Erich Keane bd7bce2c84
Fix null-deref thanks to an attribute on a global declarator chunk (#83611)
This was reported (sort of) in a PR: #77703. The problem is that a
declarator 'owns' an attributes allocation via an `AttributePool`.
However, this example tries to copy a DeclaratorChunk from one
Declarator to another, so when the temporary Declarator goes out of
scope, it deletes the attribute it has tried to pass on via the chunk.

This patch ensures that we copy the 'ownership' of the attribute
correctly, and adds an assert to catch any other casess where this
happens.

Additionally, this was put in as a bug report, so this
Fixes #83611
2024-03-04 09:25:29 -08:00

9 lines
338 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-error@+5{{brackets are not allowed here}}
// expected-error@+4{{a type specifier is required for all declarations}}
// expected-warning@+3{{unknown attribute 'h' ignored}}
// expected-error@+2{{definition of variable with array type}}
// expected-error@+1{{expected ';'}}
[][[h]]l