* c-family PATCH to tidy switch diagnostics (PR c/78285)
@ 2016-11-16 22:04 Marek Polacek
2016-11-17 0:59 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2016-11-16 22:04 UTC (permalink / raw)
To: GCC Patches, Jason Merrill, Joseph Myers
As pointed out in Bug 78285, some error calls should actually be inform calls.
I'm not adding any new test; existing switch-5.c covers all the cases so I didn't
see much value in duplicating that part of the test.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2016-11-16 Marek Polacek <polacek@redhat.com>
PR c/78285
* c-common.c (c_add_case_label): Turn error_at calls into inform.
* gcc.dg/switch-5.c: Turn several dg-errors into dg-messages.
* g++.dg/ext/case-range2.C: Likewise.
diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 2997c83..3eb7f45 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -4968,19 +4968,19 @@ c_add_case_label (location_t loc, splay_tree cases, tree cond, tree orig_type,
if (high_value)
{
error_at (loc, "duplicate (or overlapping) case value");
- error_at (DECL_SOURCE_LOCATION (duplicate),
- "this is the first entry overlapping that value");
+ inform (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first entry overlapping that value");
}
else if (low_value)
{
error_at (loc, "duplicate case value") ;
- error_at (DECL_SOURCE_LOCATION (duplicate), "previously used here");
+ inform (DECL_SOURCE_LOCATION (duplicate), "previously used here");
}
else
{
error_at (loc, "multiple default labels in one switch");
- error_at (DECL_SOURCE_LOCATION (duplicate),
- "this is the first default label");
+ inform (DECL_SOURCE_LOCATION (duplicate),
+ "this is the first default label");
}
goto error_out;
}
diff --git gcc/testsuite/g++.dg/ext/case-range2.C gcc/testsuite/g++.dg/ext/case-range2.C
index 985ded3..f1165ad 100644
--- gcc/testsuite/g++.dg/ext/case-range2.C
+++ gcc/testsuite/g++.dg/ext/case-range2.C
@@ -11,7 +11,7 @@ T f2 (T i)
{
switch (i)
{
- case low ... high : return i + 1; // { dg-error "previously" }
+ case low ... high : return i + 1; // { dg-message "previously" }
case 5 : return i + 2; // { dg-error "duplicate" }
default : return 0;
}
@@ -20,7 +20,7 @@ T f2 (T i)
int f (int i)
{
switch (i) {
- case 1 ... 10: return i + 1; // { dg-error "first entry" }
+ case 1 ... 10: return i + 1; // { dg-message "first entry" }
case 3 ... 5 : return i + 3; // { dg-error "duplicate" }
default: return f2 (i); // { dg-message "required" }
}
diff --git gcc/testsuite/gcc.dg/switch-5.c gcc/testsuite/gcc.dg/switch-5.c
index 5a58490..a097d44 100644
--- gcc/testsuite/gcc.dg/switch-5.c
+++ gcc/testsuite/gcc.dg/switch-5.c
@@ -40,13 +40,13 @@ f (int a, double d, void *p)
switch (a)
{
case 0:
- default: /* { dg-error "this is the first default label" } */
+ default: /* { dg-message "this is the first default label" } */
case 1:
default: ; /* { dg-error "multiple default labels in one switch" } */
}
switch (a)
{
- case 0: /* { dg-error "previously used here" } */
+ case 0: /* { dg-message "previously used here" } */
case 1:
case 0: ; /* { dg-error "duplicate case value" } */
}
@@ -60,11 +60,11 @@ f (int a, double d, void *p)
}
switch (a)
{
- case 0: /* { dg-error "this is the first entry overlapping that value" } */
+ case 0: /* { dg-message "this is the first entry overlapping that value" } */
case -1 ... 1: /* { dg-error "duplicate \\(or overlapping\\) case value" } */
- case 2 ... 3: /* { dg-error "previously used here" } */
+ case 2 ... 3: /* { dg-message "previously used here" } */
case 2: /* { dg-error "duplicate case value" } */
- case 4 ... 7: /* { dg-error "this is the first entry overlapping that value" } */
+ case 4 ... 7: /* { dg-message "this is the first entry overlapping that value" } */
case 6 ... 9: ; /* { dg-error "duplicate \\(or overlapping\\) case value" } */
}
switch (a)
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c-family PATCH to tidy switch diagnostics (PR c/78285)
2016-11-16 22:04 c-family PATCH to tidy switch diagnostics (PR c/78285) Marek Polacek
@ 2016-11-17 0:59 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2016-11-17 0:59 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches, Jason Merrill
On Wed, 16 Nov 2016, Marek Polacek wrote:
> As pointed out in Bug 78285, some error calls should actually be inform calls.
> I'm not adding any new test; existing switch-5.c covers all the cases so I didn't
> see much value in duplicating that part of the test.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-17 0:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-16 22:04 c-family PATCH to tidy switch diagnostics (PR c/78285) Marek Polacek
2016-11-17 0:59 ` Joseph Myers
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).