init.c revision f8f873deef78de611dd793a1e1201bef0d5a54a3
14ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattner// RUN: clang %s -verify -fsyntax-only
24ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattner
34ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattnertypedef void (* fp)(void);
44ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattnervoid foo(void);
54ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattnerfp a[1] = { foo };
64ef8dd6e8736097bf9e3c387139c668565d89dcaChris Lattner
74cc627111453b75519d5130b57e06256da7b00e8Chris Lattnerint myArray[5] = {1, 2, 3, 4, 5};
84cc627111453b75519d5130b57e06256da7b00e8Chris Lattnerint *myPointer2 = myArray;
94cc627111453b75519d5130b57e06256da7b00e8Chris Lattnerint *myPointer = &(myArray[2]);
104cc627111453b75519d5130b57e06256da7b00e8Chris Lattner
11d411e04db18f7d07a889d51086861b23cbe05518Chris Lattner
12d411e04db18f7d07a889d51086861b23cbe05518Chris Lattnerextern int x;
13d411e04db18f7d07a889d51086861b23cbe05518Chris Lattnervoid *g = &x;
14d411e04db18f7d07a889d51086861b23cbe05518Chris Lattnerint *h = &x;
15d411e04db18f7d07a889d51086861b23cbe05518Chris Lattner
16a312ce2bdaaff62f21d560bad6cb0519f613d334Eli Friedmanint test() {
17a312ce2bdaaff62f21d560bad6cb0519f613d334Eli Friedmanint a[10];
18a312ce2bdaaff62f21d560bad6cb0519f613d334Eli Friedmanint b[10] = a; // expected-error {{initialization with "{...}" expected}}
19a312ce2bdaaff62f21d560bad6cb0519f613d334Eli Friedman}
20be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner
21be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner
22be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner// PR2050
23be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattnerstruct cdiff_cmd {
24be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner          const char *name;
25be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner          unsigned short argc;
26be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner          int (*handler)();
27be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner};
28be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattnerint cdiff_cmd_open();
29be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattnerstruct cdiff_cmd commands[] = {
30be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner        {"OPEN", 1, &cdiff_cmd_open }
31be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner};
32be34ac67225fc4af6134c7f3507c777cceeec867Chris Lattner
3397c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman// PR2348
3497c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedmanstatic struct { int z; } s[2];
3597c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedmanint *t = &(*s).z;
3697c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman
3797c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman// PR2349
3897c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedmanshort *a2(void)
3997c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman{
4097c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman  short int b;
4197c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman  static short *bp = &b; // expected-error {{initializer element is not constant}}
4297c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman
4397c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman  return bp;
4497c0a391138d20e1066174a9cfa92860fb06e5a1Eli Friedman}
45f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman
46f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedmanint pbool(void) {
47f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman  typedef const _Bool cbool;
48f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman  _Bool pbool1 = (void *) 0;
49f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman  cbool pbool2 = &pbool;
50f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman  return pbool2;
51f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman}
52f8f873deef78de611dd793a1e1201bef0d5a54a3Eli Friedman
53