From 7bfab3687782a3e6a706f9a4966d81c55672b0cf Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Sun, 22 Feb 2009 06:45:27 +0000 Subject: Throw the switch to exclusively use Evaluate (along with the small helper isConstantInitializer) to check whether an initializer is constant. This passes tests, but it's possible that it'll cause regressions with real-world code. Future work: 1. The diagnostics obtained this way are lower quality at the moment; some work both here and in Evaluate is needed for accurate diagnostics. 2. We probably need some extra code when we're in -pedantic mode so we can strictly enforce the rules in C99 6.6p7. 3. Dead code cleanup (this should wait until after 2, because we might want to re-use some of the code). llvm-svn: 65265 --- clang/test/Sema/static-init.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'clang/test/Sema/static-init.c') diff --git a/clang/test/Sema/static-init.c b/clang/test/Sema/static-init.c index f7648a6d358..9ab3146ee76 100644 --- a/clang/test/Sema/static-init.c +++ b/clang/test/Sema/static-init.c @@ -1,9 +1,12 @@ // RUN: clang -arch i386 -fsyntax-only -verify %s + +#include + static int f = 10; static int b = f; // expected-error {{initializer element is not a compile-time constant}} -float r = (float) &r; // FIXME: should give an error: ptr value used where a float was expected -long long s = (long long) &s; +float r = (float) &r; // expected-error {{initializer element is not a compile-time constant}} +intptr_t s = (intptr_t) &s; _Bool t = &t; @@ -16,5 +19,5 @@ struct foo { }; union bar u[1]; -struct foo x = {(long) u}; // no-error +struct foo x = {(intptr_t) u}; // no-error struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}} -- cgit v1.2.3