On Jan 19, 2008 10:15 AM, Steve Naroff <[EMAIL PROTECTED]> wrote:
> Thanks for sending this out.
>
> If you believe it implements C99 correctly, what test cases are you
> using to verify this?
>
> The test cases I added to test/Sema are useful, but minimal. If you
> believe this implements C99 rules correctly, I'm sure you've used/
> developed additional test cases.
>
> Since this is a particularly tricky area, it would be great if you
> could include the test cases this patch implements correctly.
>
Okay, I've attached some stuff. I think this covers most of the
interesting stuff I tested, although I didn't save everything.
-Eli
// Pure array tests
// Expected warning: braces around scalar initializer
float r1[10] = {{7}};
// Expected warning: braces around scalar initializer
float r2[] = {{8}};
char r3[][5] = {1,2,3,4,5,6};
char r3_2[sizeof r3 == 10 ? 1 : -1];
// Expected warning: braces around scalar initializer
// Expected warning/error: extra elements
float r4[1][2] = {1,{2},3,4};
char r5[][5] = {"aa", "bbb", "ccccc"};
char r6[sizeof r5 == 15 ? 1 : -1];
const char r7[] = "zxcv";
char r8[5] = "5char";
// Expected warning/error: extra elements
char r9[5] = "6chars";
#include <stddef.h>
wchar_t r10[] = L"asdf";
int r11[0] = {}; // GCC extension
// Some struct tests
void autoStructTest() {
struct s1 {char a; char b;} t1;
struct s2 {struct s1 c;} t2 = { t1 };
struct s1 t3[] = {t1, t1, 0, 0};
int t4[sizeof t3 == 6 ? 1 : -1];
}
struct s3 {void (*a)(void);} t5 = {autoStructTest};
// GCC extension; flexible array init.
// Note that clang objc implementation depends on this extension.
struct {int a; int b[];} t6 = {1, {1, 2, 3}};
union {char a; int b;} t7[] = {1, 2, 3};
int t8[sizeof t7 == (3*sizeof(int)) ? 1 : -1];
struct bittest{int : 31, a, :21, :12, b;};
// Expected warning/error: extra elements
struct bittest bittestvar = {1, 2, 3, 4};
// Just an experiment; clang currently throws out designators
char designator[][5] = {[5]={"ad"}, {"aww"}, {"fwqa"}};
float designator_2[sizeof designator == 40 ? 1 : -1];
// Not completely sure what should happen here...
int u1 = {};
int u2 = {{3}};
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev