[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform
Li Jia He via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 3 19:06:33 PDT 2018
HLJ2009 updated this revision to Diff 149665.
HLJ2009 added a comment.
update test case.
Repository:
rC Clang
https://reviews.llvm.org/D46805
Files:
include/clang/Basic/Attr.td
test/Sema/attr-alias-has.c
test/Sema/attr-alias.c
Index: test/Sema/attr-alias.c
===================================================================
--- test/Sema/attr-alias.c
+++ test/Sema/attr-alias.c
@@ -2,4 +2,4 @@
void g() {}
-void f() __attribute__((alias("g"))); //expected-error {{aliases are not supported on darwin}}
+void f() __attribute__((alias("g"))); //expected-warning {{unknown attribute 'alias' ignored}}
Index: test/Sema/attr-alias-has.c
===================================================================
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fsyntax-only -verify %s
+
+void g() {}
+#if !__has_attribute(alias)
+void f() __attribute__((alias("g"))); // expected-warning {{unknown attribute 'alias' ignored}}
+#else
+void f() __attribute__((alias("g"))); // expected-no-diagnostics
+#endif
\ No newline at end of file
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -318,6 +318,9 @@
def TargetELF : TargetSpec {
let ObjectFormats = ["ELF"];
}
+def TargetSupportsAlias : TargetSpec {
+ let ObjectFormats = ["COFF", "ELF", "Wasm"];
+}
// Attribute subject match rules that are used for #pragma clang attribute.
//
@@ -554,7 +557,7 @@
let Documentation = [Undocumented];
}
-def Alias : Attr {
+def Alias : Attr, TargetSpecificAttr<TargetSupportsAlias> {
let Spellings = [GCC<"alias">];
let Args = [StringArgument<"Aliasee">];
let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46805.149665.patch
Type: text/x-patch
Size: 1884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180604/5e592435/attachment.bin>
More information about the cfe-commits
mailing list