OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.dg/] [cast-3.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
/* Test diagnostics for bad or doubtful casts.  Test with
2
   -pedantic-errors.  */
3
/* Origin: Joseph Myers <joseph@codesourcery.com> */
4
/* { dg-do compile } */
5
/* { dg-options "-std=gnu99 -pedantic-errors" } */
6
 
7
struct s { int a; } sv;
8
union u { int a; } uv;
9
int i;
10
long l;
11
char c;
12
void *p;
13
float fv;
14
 
15
void
16
f (void)
17
{
18
  (int []) p; /* { dg-error "error: cast specifies array type" } */
19
  (int ()) p; /* { dg-error "error: cast specifies function type" } */
20
  (struct s) sv; /* { dg-error "error: ISO C forbids casting nonscalar to the same type" } */
21
  (union u) uv; /* { dg-error "error: ISO C forbids casting nonscalar to the same type" } */
22
  (struct s) i; /* { dg-error "error: conversion to non-scalar type requested" } */
23
  (union u) i; /* { dg-error "error: ISO C forbids casts to union type" } */
24
  (union u) l; /* { dg-error "error: cast to union type from type not present in union" } */
25
  (int) sv; /* { dg-error "error: aggregate value used where an integer was expected" } */
26
  (int) uv; /* { dg-error "error: aggregate value used where an integer was expected" } */
27
  (float) sv; /* { dg-error "error: aggregate value used where a float was expected" } */
28
  (float) uv; /* { dg-error "error: aggregate value used where a float was expected" } */
29
  (_Complex double) sv; /* { dg-error "error: aggregate value used where a complex was expected" } */
30
  (_Complex double) uv; /* { dg-error "error: aggregate value used where a complex was expected" } */
31
  (void *) sv; /* { dg-error "error: cannot convert to a pointer type" } */
32
  (void *) uv; /* { dg-error "error: cannot convert to a pointer type" } */
33
  (_Bool) sv; /* { dg-error "error: used struct type value where scalar is required" } */
34
  (_Bool) uv; /* { dg-error "error: used union type value where scalar is required" } */
35
  (void) sv;
36
  (const void) uv;
37
  (void *) c; /* { dg-warning "warning: cast to pointer from integer of different size" } */
38
  (void *) (char) 1;
39
  (char) p; /* { dg-warning "warning: cast from pointer to integer of different size" } */
40
  (char) (void *) 1;
41
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.