Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bug with define _ #544

Merged
merged 1 commit into from
Jul 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void visitFile(AstNode astNode) {
String[] sub = line.split("^\\s*#define\\s+", 2);
if (sub.length>1) {
String name = sub[1].split("[\\s(]",2)[0];
if (name.startsWith("_") && Character.isUpperCase(name.charAt(1))) {
if (name.startsWith("_") && name.length() > 1 && Character.isUpperCase(name.charAt(1))) {
getContext().createLineViolation(this, "Reserved name used for macro (begins with underscore followed by a capital letter)", nr);
}
else if (name.contains("__")) {
Expand Down
3 changes: 2 additions & 1 deletion cxx-checks/src/test/resources/checks/ReservedNamesCheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class myData {
#define _test
#define TRUE_TEST
/*#define TRUE this is not an error...*/
#define _ ks._

int main()
{
}
}