aboutsummaryrefslogtreecommitdiff
path: root/src/translate_c.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-11-05 10:56:42 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-11-05 10:56:42 -0500
commitf8d6f5daff5ac9b9f69319b9bd827ccc34ea9d72 (patch)
treefc0da10e6a69eb167e7d994f348148917c8ef98b /src/translate_c.cpp
parentce912e29640e0a3b39a5c304c86bdbb5fff67169 (diff)
parent973e0abe79abf33cb5e9f4550fe323cb93eb6ee1 (diff)
downloadzig-f8d6f5daff5ac9b9f69319b9bd827ccc34ea9d72.tar.gz
zig-f8d6f5daff5ac9b9f69319b9bd827ccc34ea9d72.zip
Merge remote-tracking branch 'origin/master' into llvm8
Diffstat (limited to 'src/translate_c.cpp')
-rw-r--r--src/translate_c.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/translate_c.cpp b/src/translate_c.cpp
index df48c9e4a2..37d5b722c3 100644
--- a/src/translate_c.cpp
+++ b/src/translate_c.cpp
@@ -15,10 +15,19 @@
#include "parser.hpp"
+#if __GNUC__ >= 8
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wclass-memaccess"
+#endif
+
#include <clang/Frontend/ASTUnit.h>
#include <clang/Frontend/CompilerInstance.h>
#include <clang/AST/Expr.h>
+#if __GNUC__ >= 8
+#pragma GCC diagnostic pop
+#endif
+
#include <string.h>
using namespace clang;
@@ -458,7 +467,13 @@ static const char *decl_name(const Decl *decl) {
static AstNode *trans_create_node_apint(Context *c, const llvm::APSInt &aps_int) {
AstNode *node = trans_create_node(c, NodeTypeIntLiteral);
node->data.int_literal.bigint = allocate<BigInt>(1);
- bigint_init_data(node->data.int_literal.bigint, aps_int.getRawData(), aps_int.getNumWords(), aps_int.isNegative());
+ bool is_negative = aps_int.isNegative();
+ if (!is_negative) {
+ bigint_init_data(node->data.int_literal.bigint, aps_int.getRawData(), aps_int.getNumWords(), false);
+ return node;
+ }
+ llvm::APSInt negated = -aps_int;
+ bigint_init_data(node->data.int_literal.bigint, negated.getRawData(), negated.getNumWords(), true);
return node;
}