summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-23 18:55:27 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2002-05-23 18:55:27 +0000
commitdf64d85ee58f6385c06511417a9a8a2f60a17261 (patch)
treeae57a5c0b975e00e24a2e69297727c26a4bc0aae /gcc
parent314bd4cf6a6176d326128efbe4b829073305b81e (diff)
downloadgcc-df64d85ee58f6385c06511417a9a8a2f60a17261.tar.gz
* cppinit.c (mark_named_operators): Split out from init_builtins.
(cpp_finish_options): Call it from here instead. testsuite: * gcc.dg/cpp/named_ops.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53803 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cppinit.c32
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/named_ops.c11
4 files changed, 42 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 83b976dd547..5e67ce273d3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-23 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * cppinit.c (mark_named_operators): Split out from init_builtins.
+ (cpp_finish_options): Call it from here instead.
+
2002-05-23 Jason Thorpe <thorpej@wasabisystems.com>
* builtin-attrs.def: Update copyright years.
diff --git a/gcc/cppinit.c b/gcc/cppinit.c
index 55451b57895..98782416e96 100644
--- a/gcc/cppinit.c
+++ b/gcc/cppinit.c
@@ -98,6 +98,7 @@ static void path_include PARAMS ((cpp_reader *,
char *, int));
static void init_library PARAMS ((void));
static void init_builtins PARAMS ((cpp_reader *));
+static void mark_named_operators PARAMS ((cpp_reader *));
static void append_include_chain PARAMS ((cpp_reader *,
char *, int, int));
static struct search_path * remove_dup_dir PARAMS ((cpp_reader *,
@@ -664,6 +665,23 @@ static const struct builtin operator_array[] =
};
#undef B
+/* Mark the C++ named operators in the hash table. */
+static void
+mark_named_operators (pfile)
+ cpp_reader *pfile;
+{
+ const struct builtin *b;
+
+ for (b = operator_array;
+ b < (operator_array + ARRAY_SIZE (operator_array));
+ b++)
+ {
+ cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
+ hp->flags |= NODE_OPERATOR;
+ hp->value.operator = b->value;
+ }
+}
+
/* Subroutine of cpp_read_main_file; reads the builtins table above and
enters them, and language-specific macros, into the hash table. */
static void
@@ -682,16 +700,6 @@ init_builtins (pfile)
hp->value.builtin = b->value;
}
- if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
- for (b = operator_array;
- b < (operator_array + ARRAY_SIZE (operator_array));
- b++)
- {
- cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
- hp->flags |= NODE_OPERATOR;
- hp->value.operator = b->value;
- }
-
if (CPP_OPTION (pfile, cplusplus))
_cpp_define_builtin (pfile, "__cplusplus 1");
else if (CPP_OPTION (pfile, objc))
@@ -976,6 +984,10 @@ void
cpp_finish_options (pfile)
cpp_reader *pfile;
{
+ /* Mark named operators before handling command line macros. */
+ if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
+ mark_named_operators (pfile);
+
/* Install builtins and process command line macros etc. in the order
they appeared, but only if not already preprocessed. */
if (! CPP_OPTION (pfile, preprocessed))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fb0340638ac..4ae2f82f3b9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-05-23 Neil Booth <neil@daikokuya.demon.co.uk>
+
+ * gcc.dg/cpp/named_ops.c: New test.
+
2002-05-23 Mark Mitchell <mark@codesourcery.com>
* gcc/testsuite/gcc.dg/weak-8.c: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/named_ops.c b/gcc/testsuite/gcc.dg/cpp/named_ops.c
new file mode 100644
index 00000000000..d03684a5f10
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/named_ops.c
@@ -0,0 +1,11 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options -fpreprocessed } */
+
+/* Tests that C++ named ops are still there with -fpreprocessed. */
+
+/* Source: Neil Booth, 23 May 2002. */
+
+#if 2 xor 2
+#endif