summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/cpp
diff options
context:
space:
mode:
authorthorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-07 03:12:23 +0000
committerthorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-07 03:12:23 +0000
commitd3f7919d2a630945daba61dc8cf51ed5cde46ed1 (patch)
treea89c2d17b9489b6bd19288f037013b3eaa28a891 /gcc/testsuite/gcc.dg/cpp
parenta09b9b19f2afb1554c1f642a77147684d467ab8f (diff)
downloadgcc-d3f7919d2a630945daba61dc8cf51ed5cde46ed1.tar.gz
* cppinit.c (cpp_create_reader): Initialize
discard_comments_in_macro_exp. (COMMAND_LINE_OPTIONS): Add "-CC" option. (cpp_handle_option): Handle "-CC" option. * cpplex.c (save_comment): If saving a C++ comment in a directive, convert it to a C comment. (_cpp_lex_direct): Pass second comment start character to save_comment to indicate comment type. * cpplib.c (_cpp_handle_directive): If processing a "#define" directive and discard_comments_in_macro_exp is false, re-enable saving of comments. (lex_macro_node): If discard_comments_in_macro_exp is false, discard any comments before the macro identifier. * cpplib.h (struct cpp_options): Add discard_comments_in_macro_exp member. * cppmacro.c (cpp_get_token): If expanding a macro while processing a directive, discard any comments we might encounter. (parse_params): If discard_comments_in_macro_exp is false, ignore comments in the macro parameter list. * gcc.c (cpp_unique_options): Add "-CC" option. (option_map): Map "--comments-in-macros" to "-CC". * doc/cppopts.texi: Document "-CC" option. * f/lang-specs.h: Add "-CC" option. * testsuite/gcc.dg/cpp/maccom1.c: New test. * testsuite/gcc.dg/cpp/maccom2.c: New test. * testsuite/gcc.dg/cpp/maccom3.c: New test. * testsuite/gcc.dg/cpp/maccom4.c: New test. * testsuite/gcc.dg/cpp/maccom5.c: New test. * testsuite/gcc.dg/cpp/maccom6.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51975 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom1.c17
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom2.c18
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom3.c17
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom4.c19
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom5.c21
-rw-r--r--gcc/testsuite/gcc.dg/cpp/maccom6.c24
6 files changed, 116 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom1.c b/gcc/testsuite/gcc.dg/cpp/maccom1.c
new file mode 100644
index 00000000000..7660dff2acb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom1.c
@@ -0,0 +1,17 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure that comments are ignored between # and the
+ directive name when the -CC option is used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#/**/define def passed
+
+def
+
+/*
+ { dg-final { if ![file exists maccom1.i] { return } } }
+ { dg-final { if { [grep maccom1.i "^passed"] != "" } { return } } }
+ { dg-final { fail "maccom1.c: comment between # and directive name with -CC" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom2.c b/gcc/testsuite/gcc.dg/cpp/maccom2.c
new file mode 100644
index 00000000000..dcaf37aaf8e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom2.c
@@ -0,0 +1,18 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure that comments between the #define directive
+ and the macro identifier are ignored (i.e. treated like whitespace)
+ when the -CC option is used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#define/**/def passed
+
+def
+
+/*
+ { dg-final { if ![file exists maccom2.i] { return } } }
+ { dg-final { if { [grep maccom2.i "^passed"] != "" } { return } } }
+ { dg-final { fail "maccom2.c: comment between #define and identifier with -CC" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom3.c b/gcc/testsuite/gcc.dg/cpp/maccom3.c
new file mode 100644
index 00000000000..198453575b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom3.c
@@ -0,0 +1,17 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure that comments in the definition of a macro
+ parameter list are ignored when the -CC option is used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#define def(x /**/, y) passed
+
+def(x,y)
+
+/*
+ { dg-final { if ![file exists maccom3.i] { return } } }
+ { dg-final { if { [grep maccom3.i "^passed"] != "" } { return } } }
+ { dg-final { fail "maccom3.c: comment in macro parameter list with -CC" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom4.c b/gcc/testsuite/gcc.dg/cpp/maccom4.c
new file mode 100644
index 00000000000..b8a136ff02e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom4.c
@@ -0,0 +1,19 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure the comment is saved in the macro and copied
+ to the output file when the macro is expanded when the -CC option is
+ used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#define def /* passed */
+
+def
+
+/*
+ /* The + in the regexp prevents it from matching itself. */
+ { dg-final { if ![file exists maccom4.i] { return } } }
+ { dg-final { if { [grep maccom4.i "p+assed"] != "" } { return } } }
+ { dg-final { fail "maccom4.c: comment in macro expansion with -CC" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom5.c b/gcc/testsuite/gcc.dg/cpp/maccom5.c
new file mode 100644
index 00000000000..f92f8bfe0f8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom5.c
@@ -0,0 +1,21 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure that C++ comments are converted to C comments
+ when saved in the macro and copied to the output file when the macro
+ is expanded when the -CC option is used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#define def // passed
+
+def:
+
+/*
+ /* The + in the regexp prevents it from matching itself. */
+ { dg-final { if ![file exists maccom5.i] { return } } }
+ { dg-final { if \{ [grep maccom5.i "p+assed"] != "" \} \{ } }
+ { dg-final { if \{ [grep maccom5.i "p+assed:"] == "" \} \{ } }
+ { dg-final { return \} \} } }
+ { dg-final { fail "maccom5.c: C++ comment in macro expansion with -CC" } }
+*/
diff --git a/gcc/testsuite/gcc.dg/cpp/maccom6.c b/gcc/testsuite/gcc.dg/cpp/maccom6.c
new file mode 100644
index 00000000000..0b86c05c6d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/maccom6.c
@@ -0,0 +1,24 @@
+/* { dg-do preprocess } */
+/* { dg-options "-CC" } */
+
+/* This tests to make sure that expressions function properly
+ when used with macros containing comments and the -CC option
+ is being used.
+
+ Jason R. Thorpe, 6 Apr 2002 */
+
+#define ONE 1 /* one */
+#define TWO 2 /* two */
+#define THREE 3 /* three */
+
+#if (ONE + TWO) != THREE
+failed
+#else
+passed
+#endif
+
+/*
+ { dg-final { if ![file exists maccom6.i] { return } } }
+ { dg-final { if { [grep maccom6.i "^passed"] != "" } { return } } }
+ { dg-final { fail "maccom6.c: comments in macro expressions with -CC" } }
+*/