@@ -14731,7 +14731,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
even if its underlying type is not. */
TYPE_DEPENDENT_P_VALID (TREE_TYPE (r)) = false;
}
-
+ /* We should verify static local variable's type
+ since vector type does not have a fixed size. */
+ if (TREE_STATIC (t)
+ &&!verify_type_context (input_location, TCTX_STATIC_STORAGE, type))
+ {
+ RETURN (error_mark_node);
+ }
layout_decl (r, 0);
}
break;
new file mode 100644
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+#include <arm_sve.h>
+
+template <int N>
+void f()
+{
+ int i = 0;
+ static svbool_t pg = svwhilelt_b64(0, N);
+}
+
+int main(int argc, char **argv)
+{
+ f<2>();
+ return 0;
+}
+
+/* { dg-error {SVE type 'svbool_t' does not have a fixed size} } */
From: wangpc <wpc337719@alibaba-inc.com> --- gcc/cp/pt.c | 8 +++++++- .../aarch64/sve/static-var-in-template.C | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.target/aarch64/sve/static-var-in-template.C