From 2c4ad502ce12259160be6c73ebdd6e73a5d27c6f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 8 Jan 2013 12:46:05 -0800 Subject: [PATCH] i965: Fix build error with clang. Technically, variable sized arrays are a required feature of C99, redacted to be optional in C11, and not actually part of C++ whatsoever. Gcc allows using them in C++ unless you specify -pedantic, and Clang appears to allow them for simple/POD types. exec_list is arguably POD, since it doesn't have virtual methods, but I can see why Clang would be like "meh, it's a C++ struct, say no", seeing as it's meant to support C99. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=58970 Reviewed-by: Matt Turner --- src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp index c9c90284eac..c4ec1d97c13 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp @@ -70,7 +70,7 @@ class fs_copy_prop_dataflow { public: fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg, - exec_list out_acp[][ACP_HASH_SIZE]); + exec_list *out_acp[ACP_HASH_SIZE]); void setup_kills(); void run(); @@ -86,7 +86,7 @@ public: } /* anonymous namespace */ fs_copy_prop_dataflow::fs_copy_prop_dataflow(void *mem_ctx, cfg_t *cfg, - exec_list out_acp[][ACP_HASH_SIZE]) + exec_list *out_acp[ACP_HASH_SIZE]) : mem_ctx(mem_ctx), cfg(cfg) { bd = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks); @@ -429,7 +429,9 @@ fs_visitor::opt_copy_propagate() bool progress = false; void *mem_ctx = ralloc_context(this->mem_ctx); cfg_t cfg(this); - exec_list out_acp[cfg.num_blocks][ACP_HASH_SIZE]; + exec_list *out_acp[cfg.num_blocks]; + for (int i = 0; i < cfg.num_blocks; i++) + out_acp[i] = new exec_list [ACP_HASH_SIZE]; /* First, walk through each block doing local copy propagation and getting * the set of copies available at the end of the block. @@ -461,6 +463,8 @@ fs_visitor::opt_copy_propagate() progress = opt_copy_propagate_local(mem_ctx, block, in_acp) || progress; } + for (int i = 0; i < cfg.num_blocks; i++) + delete [] out_acp[i]; ralloc_free(mem_ctx); if (progress) -- 2.30.2