On 06/25/2014 05:56 PM, Joseph S. Myers wrote:
On Wed, 25 Jun 2014, Sebastian Huber wrote:
2014-06-25 Sebastian Huber <sebastian.hu...@embedded-brains.de>
* c-parser.c (c_parser_declaration_or_fndef): Discard all type
qualifiers in __auto_type for atomic types.
(c_parser_typeof_specifier): Discard all type qualifiers in
__typeof__ for atomic types.
This patch should include a testcase that typeof is discarding volatile
(you can e.g. declare an extern variable twice, once as int and once as
typeof (*p) where p is volatile _Atomic int *, so the type compatibility
check fails unless volatile is discarded).
Would be something like this all right for the check?
#define CHECK_CORRESPONDING(TYPE1, TYPE2) \
do { TYPE1 a; TYPE2 *b = &a; TYPE2 c; TYPE1 *d = &c; } while (0)
void f(void)
{
const int *ci;
volatile int *vi;
CHECK_CORRESPONDING(int *, __typeof__(ci));
CHECK_CORRESPONDING(int *, __typeof__(vi));
}
It generates warnings:
test.c: In function ‘f’:
test.c:8:2: warning: initialization from incompatible pointer type
[enabled by default]
test.c:8:2: warning: initialization from incompatible pointer type
[enabled by default]
test.c:9:2: warning: initialization from incompatible pointer type
[enabled by default]
test.c:9:2: warning: initialization from incompatible pointer type
[enabled by default]
It is similar to:
gcc/testsuite/gcc.dg/c99-stdint-3.c
I think its not possible to write a test for the restrict, since it
cannot be part of a type?
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.