summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-ppoutput.c6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-18.c21
-rw-r--r--gcc/testsuite/c-c++-common/raw-string-19.c22
-rw-r--r--libcpp/ChangeLog4
-rw-r--r--libcpp/include/cpplib.h2
-rw-r--r--libcpp/lex.c2
8 files changed, 62 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 0506e55dd47..1211fcc6727 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-10 Jakub Jelinek <jakub@redhat.com>
+
+ * c-ppoutput.c (scan_translation_unit): Call account_for_newlines
+ for all CPP_TOKEN_FLD_STR tokens, not just CPP_COMMENT.
+
2013-07-10 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/57869
diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c
index 4a1534667f6..03b88170520 100644
--- a/gcc/c-family/c-ppoutput.c
+++ b/gcc/c-family/c-ppoutput.c
@@ -251,7 +251,11 @@ scan_translation_unit (cpp_reader *pfile)
cpp_output_token (token, print.outf);
}
- if (token->type == CPP_COMMENT)
+ /* CPP_COMMENT tokens and raw-string literal tokens can
+ have embedded new-line characters. Rather than enumerating
+ all the possible token types just check if token uses
+ val.str union member. */
+ if (cpp_token_val_index (token) == CPP_TOKEN_FLD_STR)
account_for_newlines (token->val.str.text, token->val.str.len);
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 520818f0199..c32ac8452b2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -8,6 +8,9 @@
2013-07-10 Jakub Jelinek <jakub@redhat.com>
+ * c-c++-common/raw-string-18.c: New test.
+ * c-c++-common/raw-string-19.c: New test.
+
PR preprocessor/57757
* g++.dg/cpp/paste1.C: New test.
* g++.dg/cpp/paste2.C: New test.
diff --git a/gcc/testsuite/c-c++-common/raw-string-18.c b/gcc/testsuite/c-c++-common/raw-string-18.c
new file mode 100644
index 00000000000..8d4381d1310
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/raw-string-18.c
@@ -0,0 +1,21 @@
+/* PR preprocessor/57824 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -fdump-tree-optimized-lineno" { target c } } */
+/* { dg-options "-std=c++11 -fdump-tree-optimized-lineno" { target c++ } } */
+
+const char x[] = R"(
+abc
+def
+ghi
+)";
+
+int
+main ()
+{
+ extern void foo (); foo ();
+ return 0;
+}
+
+/* Verify call to foo is on line 15. */
+/* { dg-final { scan-tree-dump ": 15\[]:]\[^\n\r]*foo" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/c-c++-common/raw-string-19.c b/gcc/testsuite/c-c++-common/raw-string-19.c
new file mode 100644
index 00000000000..08121a89f84
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/raw-string-19.c
@@ -0,0 +1,22 @@
+/* PR preprocessor/57824 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -fdump-tree-optimized-lineno -save-temps" { target c } } */
+/* { dg-options "-std=c++11 -fdump-tree-optimized-lineno -save-temps" { target c++ } } */
+
+const char x[] = R"(
+abc
+def
+ghi
+)";
+
+int
+main ()
+{
+ extern void foo (); foo ();
+ return 0;
+}
+
+/* Verify call to foo is on line 15. */
+/* { dg-final { scan-tree-dump ": 15\[]:]\[^\n\r]*foo" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index d0c583d8691..195d728440c 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,9 @@
2013-07-10 Jakub Jelinek <jakub@redhat.com>
+ * include/cpplib.h (cpp_token_val_index): Change parameter type to
+ const cpp_token *.
+ * lex.c (cpp_token_val_index): Likewise.
+
PR preprocessor/57757
* lex.c (cpp_avoid_paste): Avoid pasting CPP_{,W,UTF8}STRING
or CPP_STRING{16,32} with CPP_NAME or SPELL_LITERAL token that
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index 76c297acdcb..6c4225c8be7 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -248,7 +248,7 @@ struct GTY(()) cpp_token {
};
/* Say which field is in use. */
-extern enum cpp_token_fld_kind cpp_token_val_index (cpp_token *tok);
+extern enum cpp_token_fld_kind cpp_token_val_index (const cpp_token *tok);
/* A type wide enough to hold any multibyte source character.
cpplib's character constant interpreter requires an unsigned type.
diff --git a/libcpp/lex.c b/libcpp/lex.c
index dc7b9c17ddc..84e2af695d1 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -3029,7 +3029,7 @@ _cpp_aligned_alloc (cpp_reader *pfile, size_t len)
/* Say which field of TOK is in use. */
enum cpp_token_fld_kind
-cpp_token_val_index (cpp_token *tok)
+cpp_token_val_index (const cpp_token *tok)
{
switch (TOKEN_SPELL (tok))
{