[cfe-dev] Odd diagnostics

Robert Ankeney rrankene at gmail.com
Sun Mar 22 17:12:51 PDT 2015


I'm seeing some strange results using a RecursiveASTVisitor on some C code.
The following code compiles fine with clang:

static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
  return __builtin_bswap32 (__bsx);
}

But I get the following diagnostic when calling ParseAST:

C:/BUG/builtin.c:4:10: error: use of unknown builtin '__builtin_bswap32'

return __builtin_bswap32 (__bsx);

         ^

It seems odd that I should get this error, as __builtin_bswap32() is
supported. Any idea why?

Another interesting thing - I get the following results for each of the
getDiagnostics() calls:
hasUncompilableErrorOccurred() = True

hasUnrecoverableErrorOccurred() = False

hasFatalErrorOccurred() = False

hasErrorOccurred() = True


As a point of comparison, for the following code:

int foo()
{
  retrun 42;  // Typo on return
}


I get:

C:/Src/cp.PP/BUG/bug.c:3:3: error: use of undeclared identifier 'retrun'

   retrun 42;

   ^


hasUncompilableErrorOccurred() = True

hasUnrecoverableErrorOccurred() = True

hasFatalErrorOccurred() = False

hasErrorOccurred() = True


For code that generates only a warning, the above 4 calls all return False.

I guess I'm not sure what the difference is between
hasUncompilableErrorOccurred()
and
hasErrorOccurred(), or what exactly the other 2 functions do. Any
enlightenment there?


This is with:

clang version 3.7.0 (trunk 230884)
Target: i686-pc-windows-gnu
Thread model: posix


Thanks,

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150322/0498ed57/attachment.html>


More information about the cfe-dev mailing list