compatibility. This allows some applications developed with MSVC to
compile with clang without any extra changes.
Fixes: llvm.org/PR40789
Differential Revision: https://reviews.llvm.org/D61646
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360271
91177308-0d34-0410-b5e6-
96231b3b80d8
#ifndef __STDARG_H
#define __STDARG_H
+#if defined(_MSC_VER)
+/* Include otherwise unneeded header for MSVC compatibility. */
+#include <vcruntime.h>
+#endif
+
#ifndef _VA_LIST
typedef __builtin_va_list va_list;
#define _VA_LIST
#if !__has_feature(modules)
#define __STDDEF_H
#endif
+
+#if defined(_MSC_VER)
+/* Include otherwise unneeded header for MSVC compatibility. */
+#include <corecrt.h>
+#endif
+
#define __need_ptrdiff_t
#define __need_size_t
#define __need_wchar_t
--- /dev/null
+#pragma once
--- /dev/null
+#pragma once
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -fmodules -fmodules-cache-path=%t %s -D__STDC_WANT_LIB_EXT1__=1
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 -fms-compatibility-version=17.00 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -triple i686-pc-win32 \
+// RUN: -fms-compatibility-version=17.00 -isystem %S/Inputs/ms-crt %s
noreturn int f(); // expected-error 1+{{}}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only --show-includes -triple i686-pc-win32 \
+// RUN: -isystem %S/Inputs/ms-crt -fms-compatibility-version=17.00 %s \
+// RUN: | FileCheck %s
+
+#include <stddef.h>
+// CHECK: including file:{{.*}}stddef.h
+// CHECK: including file:{{.*}}corecrt.h
+#include <stdarg.h>
+// CHECK: including file:{{.*}}stdarg.h
+// CHECK: including file:{{.*}}vcruntime.h
-// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -fms-compatibility -fms-compatibility-version=17.00 %s
+// RUN: %clang_cc1 -fsyntax-only -triple i686-pc-win32 -fms-compatibility \
+// RUN: -isystem %S/Inputs/ms-crt -fms-compatibility-version=17.00 %s
// RUN: %clang_cc1 -fsyntax-only -triple i386-mingw32 %s
// Something in MSVC's headers (pulled in e.g. by <crtdefs.h>) defines __null