Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions driver/cpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ FileName runCPreprocessor(FileName csrcfile, Loc loc, OutBuffer &defines) {
std::vector<std::string> args;
const std::string &cc = getCC(isMSVC, args);

args.push_back(isMSVC ? "/std:c11" : "-std=c11");

if (!isMSVC)
appendTargetArgsForGcc(args);

Expand Down
9 changes: 7 additions & 2 deletions runtime/druntime/src/importc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions runtime/druntime/test/importc_compare/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/dmd/compilable/fix24187.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
Expand Down
13 changes: 7 additions & 6 deletions tests/dmd/compilable/stdcheaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
#include <limits.h>
#include <locale.h>

#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t`
#include <math.h>
#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 <setjmp.h>
Expand Down Expand Up @@ -71,16 +73,15 @@ float x = NAN;
#include <string.h>

#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 <tgmath.h>
#endif
#endif
#endif
#endif
#endif

#ifndef __linux__
#ifndef __APPLE__
Expand Down
2 changes: 2 additions & 0 deletions tests/dmd/compilable/testcstuff1.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ void test2()

inline int f();
_Noreturn void g();
__declspec(noreturn) void g2();
__declspec(_Noreturn) void g3();

_Static_assert(1, "ok");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/dmd/runnable/test23889.c
Original file line number Diff line number Diff line change
@@ -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 <stdlib.h>
#include <alloca.h>

int main()
{
Expand Down