From 65fb3b5bf8e71d885a26a5056b09aafea33a05a3 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 19 May 2017 19:31:52 +0000 Subject: [PATCH] * c-warn.c (match_case_to_enum_1): Don't warn about enums with no enumerators. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248303 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-warn.c | 4 ++++ gcc/testsuite/g++.dg/cpp1z/byte2.C | 13 +++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/byte2.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1db3c331948..4419f207e5c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2017-05-19 Jason Merrill + + * c-warn.c (match_case_to_enum_1): Don't warn about enums with no + enumerators. + 2017-05-19 Bernd Edlinger * c-format.c (locus): Move out of function scope, diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index e67ffb77bd9..897115612a0 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -1069,6 +1069,10 @@ warnings_for_convert_and_check (location_t loc, tree type, tree expr, static void match_case_to_enum_1 (tree key, tree type, tree label) { + /* Avoid warning about enums that have no enumerators. */ + if (TYPE_VALUES (type) == NULL_TREE) + return; + char buf[WIDE_INT_PRINT_BUFFER_SIZE]; if (tree_fits_uhwi_p (key)) diff --git a/gcc/testsuite/g++.dg/cpp1z/byte2.C b/gcc/testsuite/g++.dg/cpp1z/byte2.C new file mode 100644 index 00000000000..6a395c15530 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/byte2.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++17 -Wall" } + +#include + +bool white_space(std::byte x) { + switch (x) { + case std::byte{' '}: case std::byte{'\t'}: case std::byte{'\v'}: + case std::byte{'\f'}: case std::byte{'\n'}: + return true; + default: + return false; + } +} -- 2.11.4.GIT