[clang] 9d02770 - [clang] Parse attribute [[gnu::no_stack_protector]] (#75289)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 19:31:20 PST 2023
Author: Sirui Mu
Date: 2023-12-14T11:31:17+08:00
New Revision: 9d02770832ea6b32235865e9ac03fb177d8daba1
URL: https://github.com/llvm/llvm-project/commit/9d02770832ea6b32235865e9ac03fb177d8daba1
DIFF: https://github.com/llvm/llvm-project/commit/9d02770832ea6b32235865e9ac03fb177d8daba1.diff
LOG: [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.
Added:
clang/test/Sema/no_stack_protector.cpp
Modified:
clang/include/clang/Basic/Attr.td
clang/test/Sema/no_stack_protector.c
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index d47a59b3f7ca4f..5943583d92773a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -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;
diff --git a/clang/test/Sema/no_stack_protector.c b/clang/test/Sema/no_stack_protector.c
index 0007435901e840..1ecd46bc624ceb 100644
--- a/clang/test/Sema/no_stack_protector.c
+++ b/clang/test/Sema/no_stack_protector.c
@@ -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}}
diff --git a/clang/test/Sema/no_stack_protector.cpp b/clang/test/Sema/no_stack_protector.cpp
new file mode 100644
index 00000000000000..160e3d32a9389a
--- /dev/null
+++ b/clang/test/Sema/no_stack_protector.cpp
@@ -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() {}
More information about the cfe-commits
mailing list