diff options
author | Sam Weinig <sam.weinig@gmail.com> | 2009-09-14 18:17:16 +0000 |
---|---|---|
committer | Sam Weinig <sam.weinig@gmail.com> | 2009-09-14 18:17:16 +0000 |
commit | b0a22903c3c45065c03ce2c904802d01fd67e170 (patch) | |
tree | 6f7312e6290c1764835889c069dc9fc62c872f30 /test/Sema/warn-char-subscripts.c | |
parent | f6412c6479e2027a35d74bd37869b50adc49b620 (diff) |
-Wchar-subscripts should not warn for unsigned char subscripts. Fixes PR4978.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/warn-char-subscripts.c')
-rw-r--r-- | test/Sema/warn-char-subscripts.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Sema/warn-char-subscripts.c b/test/Sema/warn-char-subscripts.c index 65a34e8fc2..972393cd6c 100644 --- a/test/Sema/warn-char-subscripts.c +++ b/test/Sema/warn-char-subscripts.c @@ -29,3 +29,36 @@ void t5() { int *array = 0; int val = array[returnsChar()]; // expected-warning{{array subscript is of type 'char'}} } + +void t6() { + int array[1] = { 0 }; + signed char subscript = 0; + int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}} +} + +void t7() { + int array[1] = { 0 }; + unsigned char subscript = 0; + int val = array[subscript]; // no warning for unsigned char +} + +typedef char CharTy; +void t8() { + int array[1] = { 0 }; + CharTy subscript = 0; + int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}} +} + +typedef signed char SignedCharTy; +void t9() { + int array[1] = { 0 }; + SignedCharTy subscript = 0; + int val = array[subscript]; // expected-warning{{array subscript is of type 'char'}} +} + +typedef unsigned char UnsignedCharTy; +void t10() { + int array[1] = { 0 }; + UnsignedCharTy subscript = 0; + int val = array[subscript]; // no warning for unsigned char +} |