(self)
| 5777 | ) |
| 5778 | |
| 5779 | def testBuildStorageClass(self): |
| 5780 | qualifiers = [None, "const", "volatile"] |
| 5781 | signs = [None, "signed", "unsigned"] |
| 5782 | types = [ |
| 5783 | "void", |
| 5784 | "char", |
| 5785 | "int", |
| 5786 | "float", |
| 5787 | "double", |
| 5788 | "schar", |
| 5789 | "int8_t", |
| 5790 | "uint8_t", |
| 5791 | "int16_t", |
| 5792 | "uint16_t", |
| 5793 | "int32_t", |
| 5794 | "uint32_t", |
| 5795 | "int64_t", |
| 5796 | "uint64_t", |
| 5797 | ] |
| 5798 | storage_classes = ["extern", "register", "static", "typedef"] |
| 5799 | |
| 5800 | build_storage_class_error_message = ( |
| 5801 | "Storage-class specifier (static, extern, typedef, etc) should be " |
| 5802 | "at the beginning of the declaration. [build/storage_class] [5]" |
| 5803 | ) |
| 5804 | |
| 5805 | # Some explicit cases. Legal in C++, deprecated in C99. |
| 5806 | self.TestLint("const int static foo = 5;", build_storage_class_error_message) |
| 5807 | |
| 5808 | self.TestLint("char static foo;", build_storage_class_error_message) |
| 5809 | |
| 5810 | self.TestLint("double const static foo = 2.0;", build_storage_class_error_message) |
| 5811 | |
| 5812 | self.TestLint("uint64_t typedef unsigned_long_long;", build_storage_class_error_message) |
| 5813 | |
| 5814 | self.TestLint("int register foo = 0;", build_storage_class_error_message) |
| 5815 | |
| 5816 | # Since there are a very large number of possibilities, randomly |
| 5817 | # construct declarations. |
| 5818 | # Make sure that the declaration is logged if there's an error. |
| 5819 | # Seed generator with an integer for absolute reproducibility. |
| 5820 | random.seed(25) |
| 5821 | for _i in range(10): |
| 5822 | # Build up random list of non-storage-class declaration specs. |
| 5823 | other_decl_specs = [ |
| 5824 | random.choice(qualifiers), |
| 5825 | random.choice(signs), |
| 5826 | random.choice(types), |
| 5827 | ] |
| 5828 | # remove None |
| 5829 | other_decl_specs = [x for x in other_decl_specs if x is not None] |
| 5830 | |
| 5831 | # shuffle |
| 5832 | random.shuffle(other_decl_specs) |
| 5833 | |
| 5834 | # insert storage class after the first |
| 5835 | storage_class = random.choice(storage_classes) |
| 5836 | insertion_point = random.randint(1, len(other_decl_specs)) |
nothing calls this directly
no test coverage detected