Skip to content

Commit

Permalink
[clang] Parse attribute [[gnu::no_stack_protector]] (#75289)
Browse files Browse the repository at this point in the history
This commit adds relative TableGen definitions to parse the
`[[gnu::no_stack_protector]]` attribute.

This PR addresses issue #75235.
  • Loading branch information
Lancern committed Dec 14, 2023
1 parent b07aaf8 commit 9d02770
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,8 @@ def NotTailCalled : InheritableAttr {
def : MutualExclusions<[AlwaysInline, NotTailCalled]>;

def NoStackProtector : InheritableAttr {
let Spellings = [Clang<"no_stack_protector">, Declspec<"safebuffers">];
let Spellings = [Clang<"no_stack_protector">, CXX11<"gnu", "no_stack_protector">,
C23<"gnu", "no_stack_protector">, Declspec<"safebuffers">];
let Subjects = SubjectList<[Function]>;
let Documentation = [NoStackProtectorDocs];
let SimpleHandler = 1;
Expand Down
5 changes: 4 additions & 1 deletion clang/test/Sema/no_stack_protector.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s

[[gnu::no_stack_protector]] void test1(void) {}
[[clang::no_stack_protector]] void test2(void) {}

void __attribute__((no_stack_protector)) foo(void) {}
int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Sema/no_stack_protector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// expected-no-diagnostics

[[gnu::no_stack_protector]] void test1() {}
[[clang::no_stack_protector]] void test2() {}

0 comments on commit 9d02770

Please sign in to comment.