From: Marek Polacek Date: Thu, 17 Nov 2016 01:23:19 +0000 (+0000) Subject: re PR c/78285 (error on duplicate switch label where a note should be) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0d939c95759f393cd4eb6b88c04e443a55fe6ddb;p=gcc.git re PR c/78285 (error on duplicate switch label where a note should be) 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. From-SVN: r242532 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 382606fa72c..acbe46154ec 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2016-11-16 Marek Polacek + + PR c/78285 + * c-common.c (c_add_case_label): Turn error_at calls into inform. + 2016-11-14 Jakub Jelinek * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_structured_bindings. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2997c83925f..3eb7f45aba4 100644 --- a/gcc/c-family/c-common.c +++ b/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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9b616e6d7a4..4d4679418a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-16 Marek Polacek + + PR c/78285 + * gcc.dg/switch-5.c: Turn several dg-errors into dg-messages. + * g++.dg/ext/case-range2.C: Likewise. + 2016-11-16 Steven G. Kargl PR fortran/58001 diff --git a/gcc/testsuite/g++.dg/ext/case-range2.C b/gcc/testsuite/g++.dg/ext/case-range2.C index 985ded3362e..f1165adfad9 100644 --- a/gcc/testsuite/g++.dg/ext/case-range2.C +++ b/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 a/gcc/testsuite/gcc.dg/switch-5.c b/gcc/testsuite/gcc.dg/switch-5.c index 5a584906988..a097d446c13 100644 --- a/gcc/testsuite/gcc.dg/switch-5.c +++ b/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)