Commit 0c86a39d by Jakub Jelinek

lex.c (_cpp_lex_direct): Use CPP_DL_NOTE instead of CPP_DL_PEDWARN...

	* lex.c (_cpp_lex_direct): Use CPP_DL_NOTE instead of CPP_DL_PEDWARN,
	CPP_DL_WARNING or CPP_DL_ERROR for note that diagnostics for C++ style
	comments is reported only once per file and guard those calls on the
	preceding cpp_error returning true.

	* gcc.dg/cpp/pr61854-c90.c (foo): Expect a note, rather than error.
	* gcc.dg/cpp/pr61854-c94.c (foo): Likewise.
	* gcc.dg/cpp/pr61854-4.c (foo): Likewise.
	* gcc.dg/cpp/pr61854-8.c: New test.

From-SVN: r262832
parent 0ef03fe3
2018-07-17 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/cpp/pr61854-c90.c (foo): Expect a note, rather than error.
* gcc.dg/cpp/pr61854-c94.c (foo): Likewise.
* gcc.dg/cpp/pr61854-4.c (foo): Likewise.
* gcc.dg/cpp/pr61854-8.c: New test.
2018-07-17 David Edelsohn <dje.gcc@gmail.com> 2018-07-17 David Edelsohn <dje.gcc@gmail.com>
* gcc.target/powerpc/pr85456.c: Require longdouble128. * gcc.target/powerpc/pr85456.c: Require longdouble128.
......
...@@ -12,5 +12,5 @@ foo (void) ...@@ -12,5 +12,5 @@ foo (void)
// But error here. // But error here.
#endif #endif
/* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} 12 } */ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} 12 } */
/* { dg-error "reported only once" "" { target *-*-*} 12 } */ /* { dg-message "note: \[^\n\r]*reported only once" "" { target *-*-*} 12 } */
} }
/* PR c/61854 */
/* { dg-do compile } */
/* { dg-options "-std=gnu89 -pedantic -w" } */
int
main (void)
{
// Comment.
/* { dg-bogus "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} .-1 } */
/* { dg-bogus "note: \[^\n\r]*reported only once" "" { target *-*-*} .-2 } */
return 0;
}
...@@ -7,7 +7,7 @@ foo (void) ...@@ -7,7 +7,7 @@ foo (void)
{ {
// 1st // 1st
/* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} .-1 } */ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} .-1 } */
/* { dg-error "reported only once" "" { target *-*-*} .-2 } */ /* { dg-message "note: \[^\n\r]*reported only once" "" { target *-*-*} .-2 } */
// 2nd // 2nd
// 3rd // 3rd
} }
...@@ -7,7 +7,7 @@ foo (void) ...@@ -7,7 +7,7 @@ foo (void)
{ {
// 1st // 1st
/* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} .-1 } */ /* { dg-error "C\\+\\+ style comments are not allowed in ISO C90" "comments" { target *-*-*} .-1 } */
/* { dg-error "reported only once" "" { target *-*-*} .-2 } */ /* { dg-message "note: \[^\n\r]*reported only once" "" { target *-*-*} .-2 } */
// 2nd // 2nd
// 3rd // 3rd
} }
2018-07-17 Jason Franklin <j_fra@fastmail.us>
Jakub Jelinek <jakub@redhat.com>
* lex.c (_cpp_lex_direct): Use CPP_DL_NOTE instead of CPP_DL_PEDWARN,
CPP_DL_WARNING or CPP_DL_ERROR for note that diagnostics for C++ style
comments is reported only once per file and guard those calls on the
preceding cpp_error returning true.
2018-07-03 Nathan Sidwell <nathan@acm.org> 2018-07-03 Nathan Sidwell <nathan@acm.org>
Reorg line_map data structures for better packing. Reorg line_map data structures for better packing.
......
...@@ -2872,10 +2872,10 @@ _cpp_lex_direct (cpp_reader *pfile) ...@@ -2872,10 +2872,10 @@ _cpp_lex_direct (cpp_reader *pfile)
&& CPP_PEDANTIC (pfile) && CPP_PEDANTIC (pfile)
&& ! buffer->warned_cplusplus_comments) && ! buffer->warned_cplusplus_comments)
{ {
cpp_error (pfile, CPP_DL_PEDWARN, if (cpp_error (pfile, CPP_DL_PEDWARN,
"C++ style comments are not allowed in ISO C90"); "C++ style comments are not allowed in ISO C90"))
cpp_error (pfile, CPP_DL_PEDWARN, cpp_error (pfile, CPP_DL_NOTE,
"(this will be reported only once per input file)"); "(this will be reported only once per input file)");
buffer->warned_cplusplus_comments = 1; buffer->warned_cplusplus_comments = 1;
} }
/* Or if specifically desired via -Wc90-c99-compat. */ /* Or if specifically desired via -Wc90-c99-compat. */
...@@ -2883,10 +2883,10 @@ _cpp_lex_direct (cpp_reader *pfile) ...@@ -2883,10 +2883,10 @@ _cpp_lex_direct (cpp_reader *pfile)
&& ! CPP_OPTION (pfile, cplusplus) && ! CPP_OPTION (pfile, cplusplus)
&& ! buffer->warned_cplusplus_comments) && ! buffer->warned_cplusplus_comments)
{ {
cpp_error (pfile, CPP_DL_WARNING, if (cpp_error (pfile, CPP_DL_WARNING,
"C++ style comments are incompatible with C90"); "C++ style comments are incompatible with C90"))
cpp_error (pfile, CPP_DL_WARNING, cpp_error (pfile, CPP_DL_NOTE,
"(this will be reported only once per input file)"); "(this will be reported only once per input file)");
buffer->warned_cplusplus_comments = 1; buffer->warned_cplusplus_comments = 1;
} }
/* In C89/C94, C++ style comments are forbidden. */ /* In C89/C94, C++ style comments are forbidden. */
...@@ -2906,11 +2906,12 @@ _cpp_lex_direct (cpp_reader *pfile) ...@@ -2906,11 +2906,12 @@ _cpp_lex_direct (cpp_reader *pfile)
} }
else if (! buffer->warned_cplusplus_comments) else if (! buffer->warned_cplusplus_comments)
{ {
cpp_error (pfile, CPP_DL_ERROR, if (cpp_error (pfile, CPP_DL_ERROR,
"C++ style comments are not allowed in ISO C90"); "C++ style comments are not allowed in "
cpp_error (pfile, CPP_DL_ERROR, "ISO C90"))
"(this will be reported only once per input " cpp_error (pfile, CPP_DL_NOTE,
"file)"); "(this will be reported only once per input "
"file)");
buffer->warned_cplusplus_comments = 1; buffer->warned_cplusplus_comments = 1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment