aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-28 22:39:59 +0000
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-28 22:39:59 +0000
commit99347f932bdf7d9b0bf8a4f36737ed128813c1a9 (patch)
tree50231e63221d6723ba5f8ac333c15ce65cda6626 /libcpp
parent5d622f64eff4e9fa78356c24290aed131b5c519c (diff)
Backport 4.7 patchtes to 4.6
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173137 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog11
-rw-r--r--libcpp/directives.c14
-rw-r--r--libcpp/expr.c7
3 files changed, 29 insertions, 3 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 47efbe63d7e..4ae02d6a2e7 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,14 @@
+2011-04-28 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2011-03-18 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ PR preprocessor/48192
+ * directives.c (do_ifdef): Do not consider conditional macros as
+ being defined.
+ (do_ifndef): Ditto.
+ * expr.c (parse_defined): Ditto.
+
2011-04-24 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/48740
diff --git a/libcpp/directives.c b/libcpp/directives.c
index 85a17b146c2..f244ae5b5b2 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1819,7 +1819,12 @@ do_ifdef (cpp_reader *pfile)
if (node)
{
- skip = node->type != NT_MACRO;
+ /* Do not treat conditional macros as being defined. This is due to
+ the powerpc and spu ports using conditional macros for 'vector',
+ 'bool', and 'pixel' to act as conditional keywords. This messes
+ up tests like #ifndef bool. */
+ skip = (node->type != NT_MACRO
+ || ((node->flags & NODE_CONDITIONAL) != 0));
_cpp_mark_macro_used (node);
if (!(node->flags & NODE_USED))
{
@@ -1860,7 +1865,12 @@ do_ifndef (cpp_reader *pfile)
if (node)
{
- skip = node->type == NT_MACRO;
+ /* Do not treat conditional macros as being defined. This is due to
+ the powerpc and spu ports using conditional macros for 'vector',
+ 'bool', and 'pixel' to act as conditional keywords. This messes
+ up tests like #ifndef bool. */
+ skip = (node->type == NT_MACRO
+ && ((node->flags & NODE_CONDITIONAL) == 0));
_cpp_mark_macro_used (node);
if (!(node->flags & NODE_USED))
{
diff --git a/libcpp/expr.c b/libcpp/expr.c
index d2fec2a56a6..3c36127b54f 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -720,10 +720,15 @@ parse_defined (cpp_reader *pfile)
pfile->state.prevent_expansion--;
+ /* Do not treat conditional macros as being defined. This is due to the
+ powerpc and spu ports using conditional macros for 'vector', 'bool', and
+ 'pixel' to act as conditional keywords. This messes up tests like #ifndef
+ bool. */
result.unsignedp = false;
result.high = 0;
result.overflow = false;
- result.low = node && node->type == NT_MACRO;
+ result.low = (node && node->type == NT_MACRO
+ && (node->flags & NODE_CONDITIONAL) == 0);
return result;
}