puts $outfile "DEF_WITH_1_STATIC ($utype, $uinner);"
set joined "static_${utype}_x_${uinner}"
puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "$utype align_pair_${joined}::one = 0;"
puts $outfile "unsigned a_${joined}"
puts $outfile " = ${align_func} (struct align_pair_${joined});"
puts $outfile "DEF_WITH_2_STATIC ($utype, $uinner);"
set joined "static_${utype}_x_static_${uinner}"
puts $outfile "struct align_pair_$joined item_${joined};"
+ puts $outfile "$utype align_pair_${joined}::one = 0;"
+ puts $outfile "$uinner align_pair_${joined}::two = 0;"
puts $outfile "unsigned a_${joined}"
puts $outfile " = ${align_func} (struct align_pair_${joined});"
}
}
# Epilogue.
- puts $outfile {
+ puts $outfile "
int main() {
- return 0;
+ "
+
+ # Clang with LTO garbage collects unused global variables, even at
+ # -O0. Likewise AIX GCC. Add uses to all global variables to
+ # prevent it.
+
+ if { $lang == "c" } {
+ puts $outfile "a_void++;"
+ }
+
+ # First, add uses for single items.
+ foreach type $typelist {
+ set utype [join [split $type] _]
+ puts $outfile "item_$utype++;"
+ if { $lang == "c" } {
+ puts $outfile "a_$utype++;"
+ }
+ }
+
+ # Now add uses for all pairs.
+ foreach type $typelist {
+ set utype [join [split $type] _]
+ foreach inner $typelist {
+ set uinner [join [split $inner] _]
+ set joined "${utype}_x_${uinner}"
+ puts $outfile "item_${joined}.one++;"
+ puts $outfile "a_${joined}++;"
+
+ if { $lang == "c++" } {
+ set joined "static_${utype}_x_${uinner}"
+ puts $outfile "item_${joined}.one++;"
+ puts $outfile "a_${joined}++;"
+
+ set joined "static_${utype}_x_static_${uinner}"
+ puts $outfile "item_${joined}.one++;"
+ puts $outfile "a_${joined}++;"
+ }
}
}
+ puts $outfile "
+ return 0;
+ }
+ "
+
close $outfile
return $filename
set flags {debug}
if { "$lang" == "c++" } {
+ lappend flags "c++"
lappend flags "additional_flags=-std=c++11"
}
standard_testfile $filename