Skip to content

Commit a8b5994

Browse files
committed
[clang][Interp][NFC] Add a broken test case
The LHS of the subtraction returns 16 right now, but should return 0.
1 parent 65ac8c1 commit a8b5994

File tree

1 file changed

+20
-0
lines changed
  • clang/test/AST/Interp

1 file changed

+20
-0
lines changed

clang/test/AST/Interp/c.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,23 @@ int somefunc(int i) {
110110
// pedantic-ref-warning {{overflow in expression; result is 131073}}
111111

112112
}
113+
114+
/// FIXME: The following test is incorrect in the new interpreter.
115+
/// The null pointer returns 16 from its getIntegerRepresentation().
116+
struct ArrayStruct {
117+
char n[1];
118+
};
119+
struct AA {
120+
char name2[(int)&((struct ArrayStruct*)0)->n - 1]; // expected-warning {{cast to smaller integer type}} \
121+
// expected-warning {{folded to constant array}} \
122+
// pedantic-expected-warning {{cast to smaller integer type}} \
123+
// pedantic-expected-warning {{folded to constant array}} \
124+
// ref-error {{array size is negative}} \
125+
// ref-warning {{cast to smaller integer type}} \
126+
// pedantic-ref-error {{array size is negative}} \
127+
// pedantic-ref-warning {{cast to smaller integer type}}
128+
};
129+
_Static_assert(sizeof(struct AA) == 15, ""); // ref-error {{failed}} \
130+
// ref-note {{1 == 15}} \
131+
// pedantic-ref-error {{failed}} \
132+
// pedantic-ref-note {{1 == 15}}

0 commit comments

Comments
 (0)