URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 154 |
Rev 816 |
/* Test for new block scopes in C99. Inspired by C99 Rationale (N897). */
|
/* Test for new block scopes in C99. Inspired by C99 Rationale (N897). */
|
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
|
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
|
/* { dg-do run } */
|
/* { dg-do run } */
|
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
|
|
|
struct foo {
|
struct foo {
|
char a;
|
char a;
|
};
|
};
|
|
|
extern void abort (void);
|
extern void abort (void);
|
extern void exit (int);
|
extern void exit (int);
|
|
|
int
|
int
|
sfoo (void)
|
sfoo (void)
|
{
|
{
|
if (sizeof (struct foo { int a; double b; char *c; void *d; }))
|
if (sizeof (struct foo { int a; double b; char *c; void *d; }))
|
(void) 0;
|
(void) 0;
|
return sizeof (struct foo);
|
return sizeof (struct foo);
|
}
|
}
|
|
|
int
|
int
|
main (void)
|
main (void)
|
{
|
{
|
int t, u;
|
int t, u;
|
t = sfoo ();
|
t = sfoo ();
|
u = sizeof (struct foo);
|
u = sizeof (struct foo);
|
/* With C90 scoping rules the new declaration of struct foo is in scope
|
/* With C90 scoping rules the new declaration of struct foo is in scope
|
above; with C99 it is local to the if.
|
above; with C99 it is local to the if.
|
*/
|
*/
|
if (t == u)
|
if (t == u)
|
exit (0); /* C99 rules apply. */
|
exit (0); /* C99 rules apply. */
|
else
|
else
|
abort (); /* C90 rules apply. */
|
abort (); /* C90 rules apply. */
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.