[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
Mon May 21 05:43:49 PDT 2018


HLJ2009 updated this revision to Diff 147773.
HLJ2009 added a comment.
Herald added a subscriber: aheejin.

listing the object formats that *do* support aliases seems reasonable


Repository:
  rC Clang

https://reviews.llvm.org/D46805

Files:
  include/clang/Basic/Attr.td
  test/Sema/attr-alias-has.c


Index: test/Sema/attr-alias-has.c
===================================================================
--- /dev/null
+++ test/Sema/attr-alias-has.c
@@ -0,0 +1,17 @@
+// 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
+
+#if __has_attribute(alias)
+
+void g() {}
+
+void f() __attribute__((alias("g"))); //expected-no-diagnostics 
+
+#else
+
+//expected-no-diagnostics
+
+#endif
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.147773.patch
Type: text/x-patch
Size: 1417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180521/7b0d2b4b/attachment-0001.bin>


More information about the cfe-commits mailing list