diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-01 23:36:03 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-01 23:36:03 +0000 |
commit | 677e4feebe4b3485504860d991d700cc3b933961 (patch) | |
tree | 2922eed5d8af67722b41aca16cb82b116fc234aa /test/Sema/enum.c | |
parent | 4581581881d3f7349bf5a4b39d761bce688f9164 (diff) |
Improve handling of enumerator values for C and C++, including:
- In C++, prior to the closing '}', set the type of enumerators
based on the type of their initializer. Don't perform unary
conversions on the enumerator values.
- In C++, handle overflow when an enumerator has no initializer and
its value cannot be represented in the type of the previous
enumerator.
- In C, handle overflow more gracefully, by complaining and then
falling back to the C++ rules.
- In C, if the enumerator value is representable in an int, convert the
expression to the type 'int'.
Fixes PR5854 and PR4515.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/enum.c')
-rw-r--r-- | test/Sema/enum.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/Sema/enum.c b/test/Sema/enum.c index 916de41176..9b4650091e 100644 --- a/test/Sema/enum.c +++ b/test/Sema/enum.c @@ -92,3 +92,7 @@ typedef enum { } an_enum; // FIXME: why is this only a warning? char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'an_enum', expected 'char *'}} + +// PR4515 +enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2}; +int CheckPR4515[PR4515b==0?1:-1]; |