@@ -594,6 +594,8 @@ const char* variable_attribute_to_string (gcc_jit_variable_attribute attr)
594
594
{
595
595
case GCC_JIT_VARIABLE_ATTRIBUTE_VISIBILITY:
596
596
return " visibility" ;
597
+ case GCC_JIT_VARIABLE_ATTRIBUTE_WEAK:
598
+ return " weak" ;
597
599
case GCC_JIT_VARIABLE_ATTRIBUTE_MAX:
598
600
return NULL ;
599
601
}
@@ -779,7 +781,8 @@ global_new_decl (location *loc,
779
781
const char *name,
780
782
enum global_var_flags flags,
781
783
const std::vector<std::pair<gcc_jit_variable_attribute,
782
- std::string>> &attributes,
784
+ std::string>> &string_attributes,
785
+ const std::vector<gcc_jit_variable_attribute> &attributes,
783
786
bool readonly,
784
787
bool removed)
785
788
{
@@ -835,7 +838,19 @@ global_new_decl (location *loc,
835
838
if (loc)
836
839
set_tree_location (inner, loc);
837
840
838
- set_variable_string_attribute (attributes, inner);
841
+ set_variable_string_attribute (string_attributes, inner);
842
+
843
+ tree var_attributes = NULL_TREE;
844
+ for (auto attr: attributes)
845
+ {
846
+ const char * attribute = variable_attribute_to_string (attr);
847
+ if (attribute)
848
+ {
849
+ tree ident = get_identifier (attribute);
850
+ var_attributes = tree_cons (ident, NULL_TREE, var_attributes);
851
+ }
852
+ }
853
+ decl_attributes (&inner, var_attributes, 0 );
839
854
840
855
return inner;
841
856
}
@@ -883,12 +898,14 @@ new_global (location *loc,
883
898
const char *name,
884
899
enum global_var_flags flags,
885
900
const std::vector<std::pair<gcc_jit_variable_attribute,
886
- std::string>> &attributes,
901
+ std::string>> &string_attributes,
902
+ const std::vector<gcc_jit_variable_attribute> &attributes,
887
903
bool readonly,
888
904
bool removed)
889
905
{
890
906
tree inner =
891
- global_new_decl (loc, kind, type, name, flags, attributes, readonly, removed);
907
+ global_new_decl (loc, kind, type, name, flags, string_attributes,
908
+ attributes, readonly, removed);
892
909
893
910
return global_finalize_lvalue (inner, removed);
894
911
}
@@ -1035,11 +1052,14 @@ new_global_initialized (location *loc,
1035
1052
const char *name,
1036
1053
enum global_var_flags flags,
1037
1054
const std::vector<std::pair<gcc_jit_variable_attribute,
1038
- std::string>> &attributes,
1055
+ std::string>> &string_attributes,
1056
+ const std::vector<gcc_jit_variable_attribute>
1057
+ &attributes,
1039
1058
bool readonly,
1040
1059
bool removed)
1041
1060
{
1042
- tree inner = global_new_decl (loc, kind, type, name, flags, attributes, readonly, removed);
1061
+ tree inner = global_new_decl (loc, kind, type, name, flags,
1062
+ string_attributes, attributes, readonly, removed);
1043
1063
1044
1064
vec<constructor_elt, va_gc> *constructor_elements = NULL ;
1045
1065
0 commit comments