* Re: [PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files
@ 2014-07-11 14:03 Dominique Dhumieres
0 siblings, 0 replies; 4+ messages in thread
From: Dominique Dhumieres @ 2014-07-11 14:03 UTC (permalink / raw)
To: gcc-patches; +Cc: jwakely.gcc, jason, 3dw4rd
> Here is a preprocessor patch to make error messages show C++11
> and other relevant C++ language instead of C99.
>
> Built and tested on x86_64-linux.
This caused
FAIL: gcc.dg/cpp/macsyntx.c (test for excess errors)
FAIL: gcc.dg/cpp/macsyntx.c (test for excess errors)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 54)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 54)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 55)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 55)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 62)
FAIL: gcc.dg/cpp/macsyntx.c (test for warnings, line 62)
FAIL: gcc.dg/cpp/sysmac1.c (test for excess errors)
FAIL: gcc.dg/cpp/sysmac1.c (test for excess errors)
FAIL: gcc.dg/cpp/sysmac1.c (test for warnings, line 25)
FAIL: gcc.dg/cpp/sysmac1.c (test for warnings, line 25)
(see https://gcc.gnu.org/ml/gcc-regression/2014-07/msg00162.html).
The warnings have to be adjusted as in
--- ../_clean/gcc/testsuite/gcc.dg/cpp/macsyntx.c 2014-05-10 23:17:13.000000000 +0200
+++ gcc/testsuite/gcc.dg/cpp/macsyntx.c 2014-07-11 15:57:33.000000000 +0200
@@ -51,15 +51,15 @@ one(ichi\
two(ichi) /* { dg-error "requires 2" } */
var0() /* OK. */
var0(ichi) /* OK. */
-var1() /* { dg-warning "rest arguments to be used" } */
-var1(ichi) /* { dg-warning "rest arguments to be used" } */
+var1() /* { dg-warning "ISO C99 requires at least one argument" } */
+var1(ichi) /* { dg-warning "ISO C99 requires at least one argument" } */
var1(ichi, ni) /* OK. */
/* This tests two oddities of GNU rest args - omitting a comma is OK,
and backtracking a token on pasting an empty rest args. */
#define rest(x, y...) x ## y /* { dg-warning "ISO C" } */
rest(ichi,) /* OK. */
-rest(ichi) /* { dg-warning "rest arguments to be used" } */
+rest(ichi) /* { dg-warning "ISO C99 requires at least one argument" } */
#if 23 != rest(2, 3) /* OK, no warning. */
#error 23 != 23 !!
#endif
--- ../_clean/gcc/testsuite/gcc.dg/cpp/sysmac1.c 2014-05-10 23:17:12.000000000 +0200
+++ gcc/testsuite/gcc.dg/cpp/sysmac1.c 2014-07-11 15:59:18.000000000 +0200
@@ -22,5 +22,5 @@
(str); /* { dg-warning "used with arguments" } */
(sys_str); /* { dg-bogus "used with arguments" } */
-foo (one_arg); /* { dg-warning "requires rest arguments" } */
+foo (one_arg); /* { dg-warning "ISO C99 requires at least one argument" } */
sys_foo (one_arg); /* { dg-bogus "requires rest arguments" } */
Dominique
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files
2014-07-10 13:53 Ed Smith-Rowland
2014-07-10 17:29 ` Jason Merrill
@ 2014-07-11 14:50 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2014-07-11 14:50 UTC (permalink / raw)
To: Ed Smith-Rowland; +Cc: gcc-patches, Jonathan Wakely, Jason Merrill
Tested on x86_64-suse-linux and installed as obvious.
Andreas.
PR preprocessor/61389
* gcc.dg/cpp/macsyntx.c: Update expected warnings.
* gcc.dg/cpp/sysmac1.c: Likewise.
diff --git a/gcc/testsuite/gcc.dg/cpp/macsyntx.c b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
index 495921e..146dced 100644
--- a/gcc/testsuite/gcc.dg/cpp/macsyntx.c
+++ b/gcc/testsuite/gcc.dg/cpp/macsyntx.c
@@ -51,15 +51,15 @@ one(ichi\
two(ichi) /* { dg-error "requires 2" } */
var0() /* OK. */
var0(ichi) /* OK. */
-var1() /* { dg-warning "rest arguments to be used" } */
-var1(ichi) /* { dg-warning "rest arguments to be used" } */
+var1() /* { dg-warning "requires at least one" } */
+var1(ichi) /* { dg-warning "requires at least one" } */
var1(ichi, ni) /* OK. */
/* This tests two oddities of GNU rest args - omitting a comma is OK,
and backtracking a token on pasting an empty rest args. */
#define rest(x, y...) x ## y /* { dg-warning "ISO C" } */
rest(ichi,) /* OK. */
-rest(ichi) /* { dg-warning "rest arguments to be used" } */
+rest(ichi) /* { dg-warning "requires at least one" } */
#if 23 != rest(2, 3) /* OK, no warning. */
#error 23 != 23 !!
#endif
diff --git a/gcc/testsuite/gcc.dg/cpp/sysmac1.c b/gcc/testsuite/gcc.dg/cpp/sysmac1.c
index cc8469e..54f161e 100644
--- a/gcc/testsuite/gcc.dg/cpp/sysmac1.c
+++ b/gcc/testsuite/gcc.dg/cpp/sysmac1.c
@@ -22,5 +22,5 @@
(str); /* { dg-warning "used with arguments" } */
(sys_str); /* { dg-bogus "used with arguments" } */
-foo (one_arg); /* { dg-warning "requires rest arguments" } */
-sys_foo (one_arg); /* { dg-bogus "requires rest arguments" } */
+foo (one_arg); /* { dg-warning "requires at least one" } */
+sys_foo (one_arg); /* { dg-bogus "requires at least one" } */
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files
2014-07-10 13:53 Ed Smith-Rowland
@ 2014-07-10 17:29 ` Jason Merrill
2014-07-11 14:50 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2014-07-10 17:29 UTC (permalink / raw)
To: Ed Smith-Rowland, gcc-patches, Jonathan Wakely
OK.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files
@ 2014-07-10 13:53 Ed Smith-Rowland
2014-07-10 17:29 ` Jason Merrill
2014-07-11 14:50 ` Andreas Schwab
0 siblings, 2 replies; 4+ messages in thread
From: Ed Smith-Rowland @ 2014-07-10 13:53 UTC (permalink / raw)
To: gcc-patches, Jonathan Wakely, Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 153 bytes --]
Here is a preprocessor patch to make error messages show C++11 and other
relevant C++ language instead of C99.
Built and tested on x86_64-linux.
OK?
[-- Attachment #2: CL_pr61389 --]
[-- Type: text/plain, Size: 268 bytes --]
libcpp/
2014-07-09 Edward Smith-Rowland <3dw4rd@verizon.net>
PR CPP/61389
* macro.c (_cpp_arguments_ok, parse_params, create_iso_definition):
Warning messages mention C++11 in c++ mode and C99 in c mode.
* lex.c (lex_identifier_intern, lex_identifier): Ditto
[-- Attachment #3: patch_pr61389_2 --]
[-- Type: text/plain, Size: 6355 bytes --]
Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c (revision 212423)
+++ libcpp/macro.c (working copy)
@@ -713,19 +713,27 @@
if (argc < macro->paramc)
{
- /* As an extension, a rest argument is allowed to not appear in
+ /* As an extension, variadic arguments are allowed to not appear in
the invocation at all.
e.g. #define debug(format, args...) something
debug("string");
- This is exactly the same as if there had been an empty rest
- argument - debug("string", ). */
+ This is exactly the same as if an empty variadic list had been
+ supplied - debug("string", ). */
if (argc + 1 == macro->paramc && macro->variadic)
{
if (CPP_PEDANTIC (pfile) && ! macro->syshdr)
- cpp_error (pfile, CPP_DL_PEDWARN,
- "ISO C99 requires rest arguments to be used");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C++11 requires at least one argument "
+ "for the \"...\" in a variadic macro");
+ else
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C99 requires at least one argument "
+ "for the \"...\" in a variadic macro");
+ }
return true;
}
@@ -1748,12 +1756,20 @@
&& ! CPP_OPTION (pfile, c99)
&& ! cpp_in_system_header (pfile))
{
- cpp_error (pfile, CPP_DL_PEDWARN,
- "invoking macro %s argument %d: "
- "empty macro arguments are undefined"
- " in ISO C90 and ISO C++98",
- NODE_NAME (node),
- src->val.macro_arg.arg_no);
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "invoking macro %s argument %d: "
+ "empty macro arguments are undefined"
+ " in ISO C++98",
+ NODE_NAME (node),
+ src->val.macro_arg.arg_no);
+ else
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "invoking macro %s argument %d: "
+ "empty macro arguments are undefined"
+ " in ISO C90",
+ NODE_NAME (node),
+ src->val.macro_arg.arg_no);
}
/* Avoid paste on RHS (even case count == 0). */
@@ -2798,14 +2814,27 @@
if (! CPP_OPTION (pfile, c99)
&& CPP_OPTION (pfile, cpp_pedantic)
&& CPP_OPTION (pfile, warn_variadic_macros))
- cpp_pedwarning
- (pfile, CPP_W_VARIADIC_MACROS,
- "anonymous variadic macros were introduced in C99");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_pedwarning
+ (pfile, CPP_W_VARIADIC_MACROS,
+ "anonymous variadic macros were introduced in C++11");
+ else
+ cpp_pedwarning
+ (pfile, CPP_W_VARIADIC_MACROS,
+ "anonymous variadic macros were introduced in C99");
+ }
}
else if (CPP_OPTION (pfile, cpp_pedantic)
&& CPP_OPTION (pfile, warn_variadic_macros))
- cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
+ "ISO C++ does not permit named variadic macros");
+ else
+ cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
"ISO C does not permit named variadic macros");
+ }
/* We're at the end, and just expect a closing parenthesis. */
token = _cpp_lex_token (pfile);
@@ -2894,11 +2923,17 @@
else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
{
/* While ISO C99 requires whitespace before replacement text
- in a macro definition, ISO C90 with TC1 allows there characters
- from the basic source character set. */
+ in a macro definition, ISO C90 with TC1 allows characters
+ from the basic source character set there. */
if (CPP_OPTION (pfile, c99))
- cpp_error (pfile, CPP_DL_PEDWARN,
- "ISO C99 requires whitespace after the macro name");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C++11 requires whitespace after the macro name");
+ else
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "ISO C99 requires whitespace after the macro name");
+ }
else
{
int warntype = CPP_DL_WARNING;
@@ -3134,8 +3169,8 @@
&& ustrcmp (NODE_NAME (node), (const uchar *) "__STDC_FORMAT_MACROS")
/* __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are mentioned
in the C standard, as something that one must use in C++.
- However DR#593 indicates that these aren't actually mentioned
- in the C++ standard. We special-case them anyway. */
+ However DR#593 and C++11 indicate that they play no role in C++.
+ We special-case them anyway. */
&& ustrcmp (NODE_NAME (node), (const uchar *) "__STDC_LIMIT_MACROS")
&& ustrcmp (NODE_NAME (node), (const uchar *) "__STDC_CONSTANT_MACROS"))
node->flags |= NODE_WARN;
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c (revision 212423)
+++ libcpp/lex.c (working copy)
@@ -1175,9 +1175,16 @@
replacement list of a variadic macro. */
if (result == pfile->spec_nodes.n__VA_ARGS__
&& !pfile->state.va_args_ok)
- cpp_error (pfile, CPP_DL_PEDWARN,
- "__VA_ARGS__ can only appear in the expansion"
- " of a C99 variadic macro");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "__VA_ARGS__ can only appear in the expansion"
+ " of a C++11 variadic macro");
+ else
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "__VA_ARGS__ can only appear in the expansion"
+ " of a C99 variadic macro");
+ }
/* For -Wc++-compat, warn about use of C++ named operators. */
if (result->flags & NODE_WARN_OPERATOR)
@@ -1255,9 +1262,16 @@
replacement list of a variadic macro. */
if (result == pfile->spec_nodes.n__VA_ARGS__
&& !pfile->state.va_args_ok)
- cpp_error (pfile, CPP_DL_PEDWARN,
- "__VA_ARGS__ can only appear in the expansion"
- " of a C99 variadic macro");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "__VA_ARGS__ can only appear in the expansion"
+ " of a C++11 variadic macro");
+ else
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "__VA_ARGS__ can only appear in the expansion"
+ " of a C99 variadic macro");
+ }
/* For -Wc++-compat, warn about use of C++ named operators. */
if (result->flags & NODE_WARN_OPERATOR)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-11 14:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-11 14:03 [PATCH preprocessor/61389] - libcpp diagnostics shouldn't talk about ISO C99 for C++ input files Dominique Dhumieres
-- strict thread matches above, loose matches on Subject: below --
2014-07-10 13:53 Ed Smith-Rowland
2014-07-10 17:29 ` Jason Merrill
2014-07-11 14:50 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).