Skip to content

Commit 9d02770

Browse files
authored
[clang] Parse attribute [[gnu::no_stack_protector]] (#75289)
This commit adds relative TableGen definitions to parse the `[[gnu::no_stack_protector]]` attribute. This PR addresses issue #75235.
1 parent b07aaf8 commit 9d02770

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,8 @@ def NotTailCalled : InheritableAttr {
22122212
def : MutualExclusions<[AlwaysInline, NotTailCalled]>;
22132213

22142214
def NoStackProtector : InheritableAttr {
2215-
let Spellings = [Clang<"no_stack_protector">, Declspec<"safebuffers">];
2215+
let Spellings = [Clang<"no_stack_protector">, CXX11<"gnu", "no_stack_protector">,
2216+
C23<"gnu", "no_stack_protector">, Declspec<"safebuffers">];
22162217
let Subjects = SubjectList<[Function]>;
22172218
let Documentation = [NoStackProtectorDocs];
22182219
let SimpleHandler = 1;

clang/test/Sema/no_stack_protector.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s
2+
3+
[[gnu::no_stack_protector]] void test1(void) {}
4+
[[clang::no_stack_protector]] void test2(void) {}
25

36
void __attribute__((no_stack_protector)) foo(void) {}
47
int __attribute__((no_stack_protector)) var; // expected-warning {{'no_stack_protector' attribute only applies to functions}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2+
// expected-no-diagnostics
3+
4+
[[gnu::no_stack_protector]] void test1() {}
5+
[[clang::no_stack_protector]] void test2() {}

0 commit comments

Comments
 (0)