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 { let Spellings = [GCC<"alias">]; let Args = [StringArgument<"Aliasee">]; let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag>; 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: 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}}