c-ppoutput.c (scan_translation_unit): Call account_for_newlines for all CPP_TOKEN_FLD_STR tokens, not just CPP_COMMENT.

* c-ppoutput.c (scan_translation_unit): Call account_for_newlines
	for all CPP_TOKEN_FLD_STR tokens, not just CPP_COMMENT.

	* include/cpplib.h (cpp_token_val_index): Change parameter type to
	const cpp_token *.
	* lex.c (cpp_token_val_index): Likewise.

	* c-c++-common/raw-string-18.c: New test.
	* c-c++-common/raw-string-19.c: New test.

From-SVN: r200878
This commit is contained in:
Jakub Jelinek 2013-07-10 18:49:24 +02:00 committed by Jakub Jelinek
parent dfeadaa00b
commit c26302d535
8 changed files with 62 additions and 3 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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.

View File

@ -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" } } */

View File

@ -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 } } */

View File

@ -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

View File

@ -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.

View File

@ -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))
{