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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [c1x-align-2.c] - Blame information for rev 706

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test C1X alignment support.  Test valid code using stdalign.h.  */
2
/* { dg-do run } */
3
/* { dg-options "-std=c1x -pedantic-errors" } */
4
 
5
#include <stdalign.h>
6
#include <stddef.h>
7
 
8
extern int strcmp (const char *, const char *);
9
 
10
extern void exit (int);
11
extern void abort (void);
12
 
13
alignas (alignof (max_align_t)) char c;
14
extern alignas (max_align_t) char c;
15
extern char c;
16
 
17
extern alignas (max_align_t) short s;
18
alignas (max_align_t) short s;
19
 
20
alignas (int) int i;
21
extern int i;
22
 
23
alignas (max_align_t) long l;
24
 
25
alignas (max_align_t) long long ll;
26
 
27
alignas (max_align_t) float f;
28
 
29
alignas (max_align_t) double d;
30
 
31
alignas (max_align_t) _Complex long double cld;
32
 
33
alignas (0) alignas (int) alignas (char) char ca[10];
34
 
35
alignas ((int) alignof (max_align_t) + 0) int x;
36
 
37
enum e { E = alignof (max_align_t) };
38
alignas (E) int y;
39
 
40
void
41
func (void)
42
{
43
  alignas (max_align_t) long long auto_ll;
44
}
45
 
46
/* Valid, but useless.  */
47
alignas (0) struct s; /* { dg-warning "useless" } */
48
 
49
#ifndef alignas
50
#error "alignas not defined"
51
#endif
52
 
53
#ifndef alignof
54
#error "alignof not defined"
55
#endif
56
 
57
#ifndef __alignas_is_defined
58
#error "__alignas_is_defined not defined"
59
#endif
60
 
61
#if __alignas_is_defined != 1
62
#error "__alignas_is_defined not 1"
63
#endif
64
 
65
#ifndef __alignof_is_defined
66
#error "__alignof_is_defined not defined"
67
#endif
68
 
69
#if __alignof_is_defined != 1
70
#error "__alignof_is_defined not 1"
71
#endif
72
 
73
#define str(x) #x
74
#define xstr(x) str(x)
75
 
76
const char *s1 = xstr(alignas);
77
const char *s2 = xstr(alignof);
78
const char *s3 = xstr(__alignas_is_defined);
79
const char *s4 = xstr(__alignof_is_defined);
80
 
81
int
82
main (void)
83
{
84
  if (strcmp (s1, "_Alignas") != 0)
85
    abort ();
86
  if (strcmp (s2, "_Alignof") != 0)
87
    abort ();
88
  if (strcmp (s3, "1") != 0)
89
    abort ();
90
  if (strcmp (s4, "1") != 0)
91
    abort ();
92
}

powered by: WebSVN 2.1.0

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