Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
lint: handle __attribute__((__unused__)) for functions and variables Previously, lint ignored the '__unused' marker, requiring its own /* ARGSUSED */ marker instead. Previously, attributes were interpreted as soon as the closing parenthesis was parsed. For a function definition such as '__unused static void f(void) {}', this was too early, as the attribute was not connected to the function, as the function was not parsed yet. Now, the 'unused' attribute is passed around by the parser, until it is merged into the declarator where it belongs. Due to an inaccuracy in the grammar, the 'used' attribute has to be passed through a parameter_list, even though a parameter list is not related to attributes. Still, it's better than before.
lint: reduce shift/reduce conflicts in grammar In an anonymous member declaration, the type attributes are already parsed by the type specifier.
lint: each member declarator may have attributes, not only the last one
tests/lint: test GCC attributes in member declarations
lint: only skip 'unused' warnings after errors, not other warnings Previously, in -w mode, any warning suppressed further 'unused' warnings, even though there was no need to do that. This can be seen in the test gcc_attribute_var.c, where only the last unused variable from a function was marked as unused, the others slipped through. Fixed by counting the errors and the warnings separately and only combining them if actually desired.
lint: warn about extern declarations outside headers https://mail-index.netbsd.org/tech-userlevel/2023/03/15/msg013727.html
tests/lint: clean up The .exp files are no longer kept under version control, so there's no reason anymore to forcefully trigger a warning or an error.
lint: remove explicit list of known GCC attributes Most GCC attributes consist of a single identifier. Up to now, it was necessary to list each of these identifiers in the grammar, even those that only apply to a single target architecture. Instead, parse the general form of attributes, matching the few attributes that lint handles by name instead. While here, rename the grammar rules to use the GCC terms. To avoid conflicts between the global function 'printf' and the GCC attribute of the same name, do not add GCC attributes to the symbol table, and don't make these symbols 'extern' either. ok christos@.
lint: allow GCC __attribute__ after array brackets GCC accepts this, so should lint. Seen in pam_lastlog.c:115.
tests/lint: demonstrate wrong 'syntax error' for unused argument Seen in pam_chroot.c:60.
lint: fix bug when parsing unused variable (since 2021-07-10) Partially revert to cgram.y 1.248 from 2021-06-29. This fixes the parse error for variables whose declaration starts with __attribute__((unused)). In the many refactorings of the last days this bug has slipped in, and since there were several refactorings in that area, there may be have been further bugs that are not caught by the current test suite. Revert for now and maybe apply them later again when there are more tests. Things kept from the current version are: The names of most of the rules, as they correspond more closely to C99 and do not affect the behavior in any way. In type_direct_decl, the replacement of type_attribute_list with type_attribute since that nonterminal is already part of a repetition (saves 4 conflicts). In block_item, the order of the rules corresponds to C99. This has no influence on the generated parser, except for the rule numbers, which are informative. The merge of the duplicate code for struct_tag, enum_tag and enum_constant, as they all contained exactly the same code.
tests/lint: analyze yesterday's bug for parsing declarations
tests/lint: add tests for GCC __attribute__ Before fixing the wrong handling of __attribute__ that is demonstrated at the end of gcc_attribute.c, ensure that the attribute handling works in the most basic cases. Lint currently accepts __attribute__ in more places than it should. This leads to some ambiguities in the grammar.