diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2013-12-05 22:52:07 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2013-12-05 22:52:07 +0000 |
commit | 8840fa855077e6be0897260d355c29e52bcbf27d (patch) | |
tree | e3981dfc35119aa8aed12d92bd830e63092cd091 /test/Sema | |
parent | c3ed6328a2332dd84a476a2a1ba2fcafd741ed76 (diff) | |
download | clang-8840fa855077e6be0897260d355c29e52bcbf27d.tar.gz |
Allow the warning 'case value not in enumerated type' to be silenced with
the following pattern.
If 'case' expression refers to a static const variable of the correct enum
type, then we count this as a sufficient declaration of intent by the user,
so we silence the warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/switch.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Sema/switch.c b/test/Sema/switch.c index e37d5da259..a2f87b9d0a 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -349,3 +349,29 @@ void test19(int i) { break; } } + +// Allow the warning 'case value not in enumerated type' to be silenced with +// the following pattern. +// +// If 'case' expression refers to a static const variable of the correct enum +// type, then we count this as a sufficient declaration of intent by the user, +// so we silence the warning. +enum ExtendedEnum1 { + EE1_a, + EE1_b +}; + +enum ExtendedEnum1_unrelated { EE1_misc }; + +static const enum ExtendedEnum1 EE1_c = 100; +static const enum ExtendedEnum1_unrelated EE1_d = 101; + +void switch_on_ExtendedEnum1(enum ExtendedEnum1 e) { + switch(e) { + case EE1_a: break; + case EE1_b: break; + case EE1_c: break; // no-warning + case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}} + } +} + |