summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-29 04:57:11 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-29 04:57:11 +0000
commit1f7d02fb6df4852573bc292b88a3b344ecab08c9 (patch)
treea011263bc10dc7ee38ed8cb8c276ecd64287b557
parent52e60208830e04c4f7b5e258fd9afc45fa505890 (diff)
downloadbcm5719-llvm-1f7d02fb6df4852573bc292b88a3b344ecab08c9.tar.gz
bcm5719-llvm-1f7d02fb6df4852573bc292b88a3b344ecab08c9.zip
Define _Bool, bool, true, and false macros in <stdbool.h> when we're
in a GNU-compatible C++ dialect. Fixes <rdar://problem/8477819>. llvm-svn: 115028
-rw-r--r--clang/lib/Headers/stdbool.h8
-rw-r--r--clang/test/Headers/stdbool.cpp14
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Headers/stdbool.h b/clang/lib/Headers/stdbool.h
index e44a1f9a979..0467893f340 100644
--- a/clang/lib/Headers/stdbool.h
+++ b/clang/lib/Headers/stdbool.h
@@ -26,11 +26,17 @@
#ifndef __STDBOOL_H
#define __STDBOOL_H
-/* Don't define bool, true, and false in C++ */
+/* Don't define bool, true, and false in C++, except as a GNU extension. */
#ifndef __cplusplus
#define bool _Bool
#define true 1
#define false 0
+#elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
+/* Define _Bool, bool, false, true as a GNU extension. */
+#define _Bool bool
+#define bool bool
+#define false false
+#define true true
#endif
#define __bool_true_false_are_defined 1
diff --git a/clang/test/Headers/stdbool.cpp b/clang/test/Headers/stdbool.cpp
new file mode 100644
index 00000000000..a252cca1a6a
--- /dev/null
+++ b/clang/test/Headers/stdbool.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -E -dM %s | FileCheck --check-prefix=CHECK-GNU-COMPAT %s
+// RUN: %clang_cc1 -std=c++98 -E -dM %s | FileCheck --check-prefix=CHECK-CONFORMING %s
+#include <stdbool.h>
+#define zzz
+
+// CHECK-GNU-COMPAT: #define _Bool bool
+// CHECK-GNU-COMPAT: #define bool bool
+// CHECK-GNU-COMPAT: #define false false
+// CHECK-GNU-COMPAT: #define true true
+
+// CHECK-CONFORMING-NOT: #define _Bool
+// CHECK-CONFORMING: #define __CHAR_BIT__
+// CHECK-CONFORMING-NOT: #define false false
+// CHECK-CONFORMING: #define zzz
OpenPOWER on IntegriCloud