1

I am working on clang lib-tooling project using clang and front-end and RecursiveASTVisitor.

for the following code (from llvm-clang test)

// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic

foo() { // expected-warning {{type specifier missing, defaults to 'int'}}
  return 0;
}

y;  // expected-warning {{type specifier missing, defaults to 'int'}}

Sample sam;

// rdar://6131634
void f((x));  // expected-warning {{type specifier missing, defaults to 'int'}}


// PR3702
#define PAD(ms10) { \
    register i;     \
}

#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */

void
h19_insline(n)  // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}}
{
  ILPAD();  // expected-warning {{type specifier missing, defaults to 'int'}}
}

struct foo {
 __extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}}
};

AST for the above code is

enter image description here

as you can see, in AST variable sam is marked as invalid whereas variable y is not though both variables have defaulted to int. When I traverse the declaration using RecursiveASTVisitor I get both the declarations as invalid.

Now the question is how to distinguish between these two declarations because y is implicit int and sam is unresolved.

Did anybody encounter such issue?

Hemant
  • 767
  • 6
  • 20

0 Answers0