blob: a2ed55197bcb8f543be02f4a82691b50614faa7a [file] [log] [blame]
Richard Trieu3bb8b562014-02-26 02:36:06 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
Eli Friedman7bfab362009-02-22 06:45:27 +00002
Daniel Dunbard95638d2010-02-17 19:26:59 +00003typedef __typeof((int*) 0 - (int*) 0) intptr_t;
Eli Friedman7bfab362009-02-22 06:45:27 +00004
Anders Carlssonf94cd1f2007-10-17 00:52:43 +00005static int f = 10;
Chris Lattner28b42942008-08-10 01:58:45 +00006static int b = f; // expected-error {{initializer element is not a compile-time constant}}
Eli Friedman66572af2008-05-30 18:14:48 +00007
Eli Friedmanf4e3ad62009-05-01 02:23:58 +00008float r = (float) (intptr_t) &r; // expected-error {{initializer element is not a compile-time constant}}
Eli Friedman7bfab362009-02-22 06:45:27 +00009intptr_t s = (intptr_t) &s;
Eli Friedman66572af2008-05-30 18:14:48 +000010_Bool t = &t;
Nuno Lopes598afdc2009-02-02 16:07:41 +000011
12
13union bar {
Mike Stump11289f42009-09-09 15:08:12 +000014 int i;
Nuno Lopes598afdc2009-02-02 16:07:41 +000015};
16
17struct foo {
Eli Friedmanb9ccd552011-12-21 01:57:31 +000018 short ptr;
Nuno Lopes598afdc2009-02-02 16:07:41 +000019};
20
21union bar u[1];
Eli Friedman13ec75b2011-12-21 00:43:02 +000022struct foo x = {(intptr_t) u}; // expected-error {{initializer element is not a compile-time constant}}
Nuno Lopes7cffb632009-02-02 22:57:15 +000023struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
Eli Friedman13ec75b2011-12-21 00:43:02 +000024intptr_t z = (intptr_t) u; // no-error