forked from OSchip/llvm-project
Diagnose use of _Noreturn on a struct/union field
C99 6.7.4p2 clarifies that a function specifier can only be used in the declaration of a function. _Noreturn is a function specifier, so it is a constraint violation to write it on a structure or union field, but we missed that case. Fixes #56800
This commit is contained in:
parent
b9a6629193
commit
d8352abd3a
|
@ -52,7 +52,9 @@ Bug Fixes
|
|||
- ``-Wtautological-compare`` missed warnings for tautological comparisons
|
||||
involving a negative integer literal. This fixes
|
||||
`Issue 42918 <https://github.com/llvm/llvm-project/issues/42918>`_.
|
||||
|
||||
- Fixes an accepts-invalid bug in C when using a ``_Noreturn`` function
|
||||
specifier on something other than a function declaration. This fixes
|
||||
`Issue 56800 <https://github.com/llvm/llvm-project/issues/56800>`_.
|
||||
|
||||
Improvements to Clang's diagnostics
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -2599,6 +2599,8 @@ void Parser::ParseSpecifierQualifierList(DeclSpec &DS, AccessSpecifier AS,
|
|||
Diag(DS.getVirtualSpecLoc(), diag::err_typename_invalid_functionspec);
|
||||
if (DS.hasExplicitSpecifier())
|
||||
Diag(DS.getExplicitSpecLoc(), diag::err_typename_invalid_functionspec);
|
||||
if (DS.isNoreturnSpecified())
|
||||
Diag(DS.getNoreturnSpecLoc(), diag::err_typename_invalid_functionspec);
|
||||
DS.ClearFunctionSpecs();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,4 +15,15 @@ _Noreturn int; // expected-error {{'_Noreturn' can only appear on functions}} ex
|
|||
_Noreturn struct S; // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
_Noreturn enum E { e }; // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
|
||||
struct GH56800 {
|
||||
_Noreturn int f1; // expected-error {{type name does not allow function specifier to be specified}}
|
||||
};
|
||||
|
||||
_Noreturn int AlsoBad; // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
void func(_Noreturn int ThisToo) { // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
for (_Noreturn int i = 0; i < 10; ++i) // expected-error {{'_Noreturn' can only appear on functions}}
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
// CHECK-EXT: '_Noreturn' is a C11 extension
|
||||
|
|
Loading…
Reference in New Issue