13e66bd29SRaphael Isemann""" 23e66bd29SRaphael IsemannTests GCC's complex integer types. 33e66bd29SRaphael Isemann""" 43e66bd29SRaphael Isemann 53e66bd29SRaphael Isemannimport lldb 63e66bd29SRaphael Isemannfrom lldbsuite.test.decorators import * 73e66bd29SRaphael Isemannfrom lldbsuite.test.lldbtest import * 83e66bd29SRaphael Isemannfrom lldbsuite.test import lldbutil 93e66bd29SRaphael Isemann 103e66bd29SRaphael Isemannclass TestCase(TestBase): 113e66bd29SRaphael Isemann 123e66bd29SRaphael Isemann @no_debug_info_test 13*6331c7d0SRaphael Isemann @skipIfWindows 143e66bd29SRaphael Isemann def test(self): 153e66bd29SRaphael Isemann self.build() 163e66bd29SRaphael Isemann lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) 173e66bd29SRaphael Isemann 1885e7e3b1SRaphael Isemann long_size_eq_int = self.frame().EvaluateExpression("sizeof(long) == sizeof(int)") 1985e7e3b1SRaphael Isemann 203e66bd29SRaphael Isemann # FIXME: LLDB treats all complex ints as unsigned, so the value is wrong. 213e66bd29SRaphael Isemann self.expect_expr("complex_int", result_type="_Complex int", result_value="4294967295 + 4294967294i") 223e66bd29SRaphael Isemann self.expect_expr("complex_unsigned", result_type="_Complex int", result_value="1 + 2i") 2385e7e3b1SRaphael Isemann 2485e7e3b1SRaphael Isemann # FIXME: We get the type wrong if long has the same size as int. 2585e7e3b1SRaphael Isemann if long_size_eq_int.GetValue() == "true": 2685e7e3b1SRaphael Isemann self.expect_expr("complex_long", result_type="_Complex int") 2785e7e3b1SRaphael Isemann self.expect_expr("complex_unsigned_long", result_type="_Complex int", result_value="1 + 2i") 2885e7e3b1SRaphael Isemann else: 2985e7e3b1SRaphael Isemann self.expect_expr("complex_long", result_type="_Complex long") 303e66bd29SRaphael Isemann self.expect_expr("complex_unsigned_long", result_type="_Complex long", result_value="1 + 2i") 313e66bd29SRaphael Isemann 323e66bd29SRaphael Isemann @no_debug_info_test 33*6331c7d0SRaphael Isemann @skipIfWindows 343e66bd29SRaphael Isemann def test_long_long(self): 353e66bd29SRaphael Isemann self.build() 363e66bd29SRaphael Isemann lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.c")) 373e66bd29SRaphael Isemann 383e66bd29SRaphael Isemann # FIXME: We get the type wrong if long has the same size as long long. 393e66bd29SRaphael Isemann # FIXME: LLDB treats all complex ints as unsigned, so the value is wrong. 4085e7e3b1SRaphael Isemann long_size_eq_long_long = self.frame().EvaluateExpression("sizeof(long) == sizeof(long long)") 4185e7e3b1SRaphael Isemann if long_size_eq_long_long.GetValue() == "true": 423e66bd29SRaphael Isemann self.expect_expr("complex_long_long", result_type="_Complex long") 433e66bd29SRaphael Isemann self.expect_expr("complex_unsigned_long_long", result_type="_Complex long", result_value="1 + 2i") 4485e7e3b1SRaphael Isemann else: 4585e7e3b1SRaphael Isemann self.expect_expr("complex_long_long", result_type="_Complex long long") 4685e7e3b1SRaphael Isemann self.expect_expr("complex_unsigned_long_long", result_type="_Complex long long", result_value="1 + 2i") 47