diff --git a/dmd/cparse.d b/dmd/cparse.d index 100cf6bf65..f5e914868e 100644 --- a/dmd/cparse.d +++ b/dmd/cparse.d @@ -3437,6 +3437,11 @@ final class CParser(AST) : Parser!AST cparseParens(); } } + else if (token.value == TOK._Noreturn) + { + specifier.noreturn = true; + nextToken(); + } else if (token.value == TOK.restrict) // ImportC assigns no semantics to `restrict`, so just ignore the keyword. nextToken(); else diff --git a/driver/cpreprocessor.cpp b/driver/cpreprocessor.cpp index 2991221823..e5f6c5c7e7 100644 --- a/driver/cpreprocessor.cpp +++ b/driver/cpreprocessor.cpp @@ -98,6 +98,8 @@ FileName runCPreprocessor(FileName csrcfile, Loc loc, OutBuffer &defines) { std::vector args; const std::string &cc = getCC(isMSVC, args); + args.push_back(isMSVC ? "/std:c11" : "-std=c11"); + if (!isMSVC) appendTargetArgsForGcc(args); diff --git a/runtime/druntime/src/importc.h b/runtime/druntime/src/importc.h index 810e13387b..2fd756418d 100644 --- a/runtime/druntime/src/importc.h +++ b/runtime/druntime/src/importc.h @@ -167,14 +167,19 @@ typedef unsigned long long __uint64_t; /*************************** * C11 6.10.8.3 Conditional feature macros */ +#if !(defined(_MSC_VER) && defined(__STDC_NO_VLA__)) // pre-defined to 1 by MS when using /std:cXX and causing warning C4117 #define __STDC_NO_VLA__ 1 +#endif #define _Float16 float -#if linux // Microsoft won't allow the following macro +#ifdef __linux__ // Microsoft won't allow the following macro // Ubuntu's assert.h uses this #define __PRETTY_FUNCTION__ __func__ -#ifndef __aarch64__ +#ifndef __clang__ +// Glibc with clang gets upset when some _Float* is defined: +// /usr/include/bits/floatn-common.h(214): Error: illegal combination of type specifiers +// typedef float float; #define _Float32 float #define _Float32x double #define _Float64 double diff --git a/runtime/druntime/test/importc_compare/Makefile b/runtime/druntime/test/importc_compare/Makefile index 1f4ce37b0c..26765f8357 100644 --- a/runtime/druntime/test/importc_compare/Makefile +++ b/runtime/druntime/test/importc_compare/Makefile @@ -23,8 +23,6 @@ include ../common.mak extra_dflags += -d ifeq ($(OS),windows) - extra_dflags += -P=/std:c11 - ifdef IN_LDC # use Microsoft's cl.exe as preprocessor; clang-cl leads to unsupported `_Float16` etc. extra_dflags += -gcc=cl diff --git a/tests/dmd/compilable/fix24187.c b/tests/dmd/compilable/fix24187.c index 46fcb0b26f..a16eb22d06 100644 --- a/tests/dmd/compilable/fix24187.c +++ b/tests/dmd/compilable/fix24187.c @@ -2,8 +2,8 @@ // https://issues.dlang.org/show_bug.cgi?id=24187 -#ifdef linux -#ifndef __aarch64__ +#ifdef __linux__ +#ifndef __clang__ extern _Complex _Float32 cacosf32 (_Complex _Float32 __z) __attribute__ ((__nothrow__ , __leaf__)); extern _Complex _Float32x __cacosf32x (_Complex _Float32x __z) __attribute__ ((__nothrow__ , __leaf__)); diff --git a/tests/dmd/compilable/stdcheaders.c b/tests/dmd/compilable/stdcheaders.c index 8e9f3126d0..ca5cc971d3 100644 --- a/tests/dmd/compilable/stdcheaders.c +++ b/tests/dmd/compilable/stdcheaders.c @@ -32,10 +32,12 @@ #include #include +#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t` #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE float x = NAN; #endif +#endif #ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct #include @@ -71,16 +73,15 @@ float x = NAN; #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\tgmath.h(33): Error: no type for declarator before `)` -#ifndef __APPLE__ // /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...` -#ifndef __OpenBSD__ // /usr/lib/clang/13.0.0/include/tgmath.h(34): Error: named parameter required before `...` -#if !(defined(__linux__) && defined(__aarch64__)) // /tmp/clang/lib/clang/15.0.3/include/tgmath.h(34): Error: named parameter required before `...` -#ifndef __FreeBSD__ // /usr/local/llvm15/lib/clang/15.0.7/include/tgmath.h(34): Error: named parameter required before `...` +#ifndef __clang__ +// Apple: /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...` +// OpenBSD: /usr/lib/clang/13.0.0/include/tgmath.h(34): Error: named parameter required before `...` +// Linux: /tmp/clang/lib/clang/15.0.3/include/tgmath.h(34): Error: named parameter required before `...` +#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t` #include #endif #endif #endif -#endif -#endif #ifndef __linux__ #ifndef __APPLE__ diff --git a/tests/dmd/compilable/testcstuff1.c b/tests/dmd/compilable/testcstuff1.c index 379f4a7a7e..a05c986fbb 100644 --- a/tests/dmd/compilable/testcstuff1.c +++ b/tests/dmd/compilable/testcstuff1.c @@ -295,6 +295,8 @@ void test2() inline int f(); _Noreturn void g(); + __declspec(noreturn) void g2(); + __declspec(_Noreturn) void g3(); _Static_assert(1, "ok"); } diff --git a/tests/dmd/runnable/test23889.c b/tests/dmd/runnable/test23889.c index 2648286d3d..3dd71133b5 100644 --- a/tests/dmd/runnable/test23889.c +++ b/tests/dmd/runnable/test23889.c @@ -1,8 +1,8 @@ // DISABLED: win freebsd openbsd -// https://issues.dlang.org/show_bug.cgi?id=23886 +// https://issues.dlang.org/show_bug.cgi?id=23889 -#include +#include int main() {