diff --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c index 58c4386b3fe3b..10497f90c2db9 100644 --- a/clang/test/C/drs/dr1xx.c +++ b/clang/test/C/drs/dr1xx.c @@ -13,6 +13,24 @@ * * WG14 DR104: dup 084 * Incomplete tag types in a parameter list + * + * WG14 DR109: yes + * Are undefined values and undefined behavior the same? + * + * WG14 DR110: dup 047 + * Formal parameters having array-of-non-object types + * + * WG14 DR117: yes + * Abstract semantics, sequence points, and expression evaluation + * + * WG14 DR121: yes + * Conversions of pointer values to integral types + * + * WG14 DR122: dup 015 + * Conversion/widening of bit-fields + * + * WG14 DR125: yes + * Using things declared as 'extern (qualified) void' */ @@ -71,3 +89,137 @@ void dr105(void) { extern int i; /* expected-note {{previous declaration is here}} */ extern float i; /* expected-error {{redeclaration of 'i' with a different type: 'float' vs 'int'}} */ } + +/* WG14 DR106: yes + * When can you dereference a void pointer? + * + * NB: This is a partial duplicate of DR012. + */ +void dr106(void *p, int i) { + /* The behavior changed between C89 and C99. */ + (void)&*p; /* c89only-warning {{ISO C forbids taking the address of an expression of type 'void'}} */ + /* The behavior of all three of these is undefined. */ + (void)*p; + (void)(i ? *p : *p); + (void)(*p, *p); /* expected-warning {{left operand of comma operator has no effect}} */ +} + +/* WG14 DR108: yes + * Can a macro identifier hide a keyword? + */ +void dr108(void) { +#define const + const int i = 12; +#undef const + const int j = 12; /* expected-note {{variable 'j' declared const here}} */ + + i = 100; /* Okay, the keyword was hidden by the macro. */ + j = 100; /* expected-error {{cannot assign to variable 'j' with const-qualified type 'const int'}} */ +} + +/* WG14 DR111: yes + * Conversion of pointer-to-qualified type values to type (void*) values + */ +void dr111(const char *ccp, void *vp) { + vp = ccp; /* expected-warning {{assigning to 'void *' from 'const char *' discards qualifiers}} */ +} + +/* WG14 DR112: yes + * Null pointer constants and relational comparisons + */ +void dr112(void *vp) { + /* The behavior of this expression is pedantically undefined. + * FIXME: should we diagnose under -pedantic? + */ + (void)(vp > (void*)0); +} + +/* WG14 DR113: yes + * Return expressions in functions declared to return qualified void + */ +volatile void dr113_v(volatile void *vvp) { /* expected-warning {{function cannot return qualified void type 'volatile void'}} */ + return *vvp; /* expected-warning {{void function 'dr113_v' should not return void expression}} */ +} +const void dr113_c(const void *cvp) { /* expected-warning {{function cannot return qualified void type 'const void'}} */ + return *cvp; /* expected-warning {{void function 'dr113_c' should not return void expression}} */ +} + +/* WG14 DR114: yes + * Initialization of multi-dimensional char array objects + */ +void dr114(void) { + char array[2][5] = { "defghi" }; /* expected-warning {{initializer-string for char array is too long}} */ +} + +/* WG14 DR115: yes + * Member declarators as declarators + */ +void dr115(void) { + struct { int mbr; }; /* expected-warning {{declaration does not declare anything}} */ + union { int mbr; }; /* expected-warning {{declaration does not declare anything}} */ +} + +/* WG14 DR116: yes + * Implicit unary & applied to register arrays + */ +void dr116(void) { + register int array[5] = { 0, 1, 2, 3, 4 }; + (void)array; /* expected-error {{address of register variable requested}} */ + (void)array[3]; /* expected-error {{address of register variable requested}} */ + (void)(array + 3); /* expected-error {{address of register variable requested}} */ +} + +/* WG14 DR118: yes + * Completion point for enumerated types + */ +void dr118(void) { + enum E { + /* The enum isn't a complete type until the closing }, but an + * implementation may complete the type earlier if it has sufficient type + * information to calculate size or alignment, etc. + */ + Val = sizeof(enum E) + }; +} + +/* WG14 DR119: yes + * Initialization of multi-dimensional array objects + */ +void dr119(void) { + static int array[][] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; /* expected-error {{array has incomplete element type 'int[]'}} */ +} + +/* WG14 DR120: yes + * Semantics of assignment to (and initialization of) bit-fields + */ +void dr120(void) { + /* We could verify this one with a codegen test to ensure that the proper + * value is stored into bit, but the diagnostic tells us what the value is + * after conversion, so we can lean on that for verification. + */ + struct S { unsigned bit:1; }; + struct S object1 = { 3 }; /* expected-warning {{implicit truncation from 'int' to bit-field changes value from 3 to 1}} */ + struct S object2; + object2.bit = 3; /* expected-warning {{implicit truncation from 'int' to bit-field changes value from 3 to 1}} */ +} + +/* WG14 DR123: yes + * 'Type categories' and qualified types + */ +void dr123(void) { + /* Both of these examples are strictly conforming. */ + enum E1 { + enumerator1 = (const int) 9 + }; + enum E2 { + enumerator2 = (volatile int) 9 + }; +} + +/* WG14 DR124: yes + * Casts to 'a void type' versus casts to 'the void type' + */ +void dr124(void) { + /* A cast can cast to void or any qualified version of void. */ + (const volatile void)0; +} diff --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html index aa2b21d7f604e..ff3387b7caf7e 100644 --- a/clang/www/c_dr_status.html +++ b/clang/www/c_dr_status.html @@ -690,122 +690,122 @@

C defect report implementation status

106 NAD - ANSI/ISO C Defect report #rfg13 - Unknown + When can you dereference a void pointer? + Yes 107 NAD - ANSI/ISO C Defect report #rfg14 + Type requirements of the assert macro parameter N/A 108 NAD - ANSI/ISO C Defect report #rfg15 - Unknown + Can a macro identifier hide a keyword? + Yes 109 NAD - ANSI/ISO C Defect report #rfg16 - Unknown + Are undefined values and undefined behavior the same? + Yes 110 Dup Formal parameters having array-of-non-object types - Duplicate of 47 + Duplicate of 47 111 NAD Conversion of pointer-to-qualified type values to type (void*) values - Unknown + Yes 112 NAD Null pointer constants and relational comparisons - Unknown + Yes 113 NAD Return expressions in functions declared to return qualified void - Unknown + Yes 114 NAD Initialization of multi-dimensional char array objects - Unknown + Yes 115 NAD Member declarators as declarators - Unknown + Yes 116 NAD Implicit unary & applied to register arrays - Unknown + Yes 117 NAD Abstract semantics, sequence points, and expression evaluation - Unknown + Yes 118 C89 Completion point for enumerated types - Unknown + Yes 119 NAD Initialization of multi-dimensional array objects - Unknown + Yes 120 NAD Semantics of assignment to (and initialization of) bit-fields - Unknown + Yes 121 NAD Conversions of pointer values to integral types - Unknown + Yes 122 Dup Conversion/widening of bit-fields - Duplicate of 15 + Duplicate of 15 123 NAD 'Type categories' and qualified types - Unknown + Yes 124 C89 Casts to 'a void type' versus casts to 'the void type' - Unknown + Yes 125 NAD Using things declared as 'extern (qualified) void' - Unknown + Yes 126