Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3253,7 +3253,7 @@ class Parser : public CodeCompletionHandler {

void ParseTypeQualifierListOpt(
DeclSpec &DS, unsigned AttrReqs = AR_AllAttributesParsed,
bool AtomicAllowed = true, bool IdentifierRequired = false,
bool AtomicOrPtrauthAllowed = true, bool IdentifierRequired = false,
std::optional<llvm::function_ref<void()>> CodeCompletionHandler =
std::nullopt);
void ParseDirectDeclarator(Declarator &D);
Expand Down
11 changes: 7 additions & 4 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6511,7 +6511,7 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide,
/// Note: vendor can be GNU, MS, etc and can be explicitly controlled via
/// AttrRequirements bitmask values.
void Parser::ParseTypeQualifierListOpt(
DeclSpec &DS, unsigned AttrReqs, bool AtomicAllowed,
DeclSpec &DS, unsigned AttrReqs, bool AtomicOrPtrauthAllowed,
bool IdentifierRequired,
std::optional<llvm::function_ref<void()>> CodeCompletionHandler) {
if ((AttrReqs & AR_CXX11AttributesParsed) &&
Expand Down Expand Up @@ -6551,7 +6551,7 @@ void Parser::ParseTypeQualifierListOpt(
getLangOpts());
break;
case tok::kw__Atomic:
if (!AtomicAllowed)
if (!AtomicOrPtrauthAllowed)
goto DoneWithTypeQuals;
diagnoseUseOfC11Keyword(Tok);
isInvalid = DS.SetTypeQual(DeclSpec::TQ_atomic, Loc, PrevSpec, DiagID,
Expand Down Expand Up @@ -6584,6 +6584,8 @@ void Parser::ParseTypeQualifierListOpt(

// __ptrauth qualifier.
case tok::kw___ptrauth:
if (!AtomicOrPtrauthAllowed)
goto DoneWithTypeQuals;
ParsePtrauthQualifier(DS.getAttributes());
EndLoc = PrevTokLocation;
continue;
Expand Down Expand Up @@ -6860,7 +6862,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
((D.getContext() != DeclaratorContext::CXXNew)
? AR_GNUAttributesParsed
: AR_GNUAttributesParsedAndRejected);
ParseTypeQualifierListOpt(DS, Reqs, true, !D.mayOmitIdentifier());
ParseTypeQualifierListOpt(DS, Reqs, /*AtomicOrPtrauthAllowed=*/true,
!D.mayOmitIdentifier());
D.ExtendWithDeclSpec(DS);

// Recursively parse the declarator.
Expand Down Expand Up @@ -7725,7 +7728,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
// Parse cv-qualifier-seq[opt].
ParseTypeQualifierListOpt(
DS, AR_NoAttributesParsed,
/*AtomicAllowed*/ false,
/*AtomicOrPtrauthAllowed=*/false,
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
}));
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
// GNU-style and C++11 attributes are not allowed here, but they will be
// handled by the caller. Diagnose everything else.
ParseTypeQualifierListOpt(
DS, AR_NoAttributesParsed, false,
DS, AR_NoAttributesParsed, /*AtomicOrPtrauthAllowed=*/false,
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
}));
Expand Down
7 changes: 7 additions & 0 deletions clang/test/Sema/ptrauth-struct-function-ptr-field.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: %clang_cc1 -triple arm64-apple-ios -x c -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -triple arm64-apple-ios -x c++ -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter

struct Foo {
void (*f)(int) __ptrauth(1,1,1);
// expected-error@-1 {{expected ';' at end of declaration list}}
};