Fixes #173826
---
This patch resolves an issue where Clang could crash while parsing the
`enable_if` attribute on C function declarators with identifier-list
parameters.
In C, identifier-list function declarators use parameter identifiers
rather than full parameter declarations, as specified by the C spec.
Since `enable_if` is parsed early to participate in redeclaration checks
0f3a9f658a/clang/lib/Parse/ParseDecl.cpp (L674-L675)
the parser could encounter such identifiers before their parameter
declarations exist and incorrectly assume they were already formed,
leading to an assertion failure.
This change makes the early `enable_if` parsing path handle parameters
that have not yet been declared, preventing the crash while preserving
existing behavior for well-formed function prototypes.
5 lines
336 B
C++
5 lines
336 B
C++
// RUN: %clang_cc1 -x c -fsyntax-only -verify %s
|
|
|
|
void f1(x) __attribute__((enable_if(1, ""))); // expected-error {{a parameter list without types is only allowed in a function definition}}
|
|
void f2(x, y) __attribute__((enable_if(1, ""))); // expected-error {{a parameter list without types is only allowed in a function definition}}
|