Index: lib/Sema/SemaDeclAttr.cpp =================================================================== --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -5754,17 +5754,7 @@ } static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (!isFunctionOrMethod(D)) { - S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) - << "'import_module'" << ExpectedFunction; - return; - } - auto *FD = cast(D); - if (FD->isThisDeclarationADefinition()) { - S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0; - return; - } StringRef Str; SourceLocation ArgLoc; @@ -5777,17 +5767,7 @@ } static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - if (!isFunctionOrMethod(D)) { - S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) - << "'import_name'" << ExpectedFunction; - return; - } - auto *FD = cast(D); - if (FD->isThisDeclarationADefinition()) { - S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0; - return; - } StringRef Str; SourceLocation ArgLoc; Index: test/Sema/attr-wasm.c =================================================================== --- test/Sema/attr-wasm.c +++ test/Sema/attr-wasm.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fsyntax-only -verify %s + +void name_a() {} + +void name_b() __attribute__((import_name)); //expected-error {{'import_name' attribute takes one argument}} + +int name_c __attribute__((import_name("foo"))); //expected-error {{'import_name' attribute only applies to functions}} + +void name_d() __attribute__((import_name("foo", "bar"))); //expected-error {{'import_name' attribute takes one argument}} + +void name_e() __attribute__((import_name("foo", "bar", "qux"))); //expected-error {{'import_name' attribute takes one argument}} + +void name_z() __attribute__((import_name("foo"))); + +void module_a() {} + +void module_b() __attribute__((import_module)); //expected-error {{'import_module' attribute takes one argument}} + +int module_c __attribute__((import_module("foo"))); //expected-error {{'import_module' attribute only applies to functions}} + +void module_d() __attribute__((import_module("foo", "bar"))); //expected-error {{'import_module' attribute takes one argument}} + +void module_e() __attribute__((import_module("foo", "bar", "qux"))); //expected-error {{'import_module' attribute takes one argument}} + +void module_z() __attribute__((import_module("foo"))); + +void both() __attribute__((import_name("foo"), import_module("bar")));