From d57fa94148963517a365e5bebdd9c72ab255c3b8 Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Thu, 30 Aug 2007 22:35:45 +0000 Subject: Final phase of array cleanup (for now), removing a FIXME from yesterday. Moved several array constraints checks from Sema::VerifyConstantArrayType() to Sema::GetTypeForDeclarator(). VerifyConstantArrayType() is now very simple, and could be removed eventually. Now, we get the following (correct) messages for BlockVarDecls:-) [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c -pedantic x.c:4:20: error: size of array has non-integer type 'float' int size_not_int[f]; ^ x.c:5:21: error: array size is negative int negative_size[1-2]; ^~~ x.c:6:17: warning: zero size arrays are an extension int zero_size[0]; ^ 3 diagnostics generated. llvm-svn: 41624 --- clang/test/Sema/array-constraint.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/test/Sema/array-constraint.c') diff --git a/clang/test/Sema/array-constraint.c b/clang/test/Sema/array-constraint.c index 4d1c2f16007..1ca3cd7aec9 100644 --- a/clang/test/Sema/array-constraint.c +++ b/clang/test/Sema/array-constraint.c @@ -31,3 +31,11 @@ typedef int (*pfunc)(void); pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}} return f; } + +void check_size() { + float f; + int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}} + int negative_size[1-2]; // expected-error{{array size is negative}} + int zero_size[0]; // expected-warning{{zero size arrays are an extension}} +} + -- cgit v1.2.3