Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -1820,6 +1820,9 @@ void Clang::AddWebAssemblyTargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { + // WebAssembly doesn't fully support code without prototypes. + CmdArgs.push_back("-Werror=strict-prototypes"); + // Default to "hidden" visibility. if (!Args.hasArg(options::OPT_fvisibility_EQ, options::OPT_fvisibility_ms_compat)) { Index: test/Driver/wasm-toolchain.c =================================================================== --- test/Driver/wasm-toolchain.c +++ test/Driver/wasm-toolchain.c @@ -1,8 +1,8 @@ // A basic clang -cc1 command-line. WebAssembly is somewhat special in -// enabling -fvisibility=hidden by default. +// enabling -fvisibility=hidden and -Werror-strict-prototypes by default. // RUN: %clang %s -### -no-canonical-prefixes -target wasm32-unknown-unknown 2>&1 | FileCheck -check-prefix=CC1 %s -// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-fvisibility" "hidden" {{.*}} +// CC1: clang{{.*}} "-cc1" "-triple" "wasm32-unknown-unknown" {{.*}} "-Werror=strict-prototypes" "-fvisibility" "hidden" {{.*}} // Ditto, but ensure that a user -fvisibility=default disables the default // -fvisibility=hidden. @@ -10,6 +10,12 @@ // RUN: %clang %s -### -target wasm32-unknown-unknown -fvisibility=default 2>&1 | FileCheck -check-prefix=FVISIBILITY_DEFAULT %s // FVISIBILITY_DEFAULT-NOT: hidden +// Ensure that a user -Wno-strict-prototypes disabled the default +// -Werror=strict-prototypes. + +// RUN: %clang %s -### -target wasm32-unknown-unknown -Wno-strict-prototypes 2>&1 | FileCheck -check-prefix=WNO_STRICT_PROTOTYPES %s +// WNO_STRICT_PROTOTYPES: "-Werror=strict-prototypes" {{.*}} "-Wno-strict-prototypes" + // A basic C link command-line. // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown --sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s