I’m having some trouble getting clang to work with LLVM_ATTRIBUTE_NORETURN defined in Support/Compiler.h. There are several problems:
First there’s a problem with the macros themselves - AFAIK __declspec(noreturn) has to come at the front of the declaration, while attribute((noreturn)) has to come after it. The usual way of dealing with this is to define a macro which surrounds the declaration like so:
LLVM_ATTRIBUTE_NORETURN(void myfunc());
That way the macro can decide whether to put the noreturn attribute either before or after the declaration. But the definitions in Compiler.h aren’t written that way:
So my first question is - has anyone ever tried using these macros under Windows?
However, there’s a more fundamental problem, which is that clang seems to be ignoring the attribute((noreturn)) altogether. That is, instead of relying on the above macros, if I just paste the noreturn attribute after my function, I still get “error: control reaches end of non-void function” in many places - errors which I wasn’t getting with gcc.
I'm having some trouble getting clang to work with LLVM_ATTRIBUTE_NORETURN defined in Support/Compiler.h. There are several problems:
First there's a problem with the macros themselves - AFAIK __declspec(noreturn) has to come at the *front* of the declaration, while __attribute__((noreturn)) has to come *after* it. The usual way of dealing with this is to define a macro which surrounds the declaration like so:
You can certainly put __attribute__((noreturn)) in the declaration-specifiers of a function. In fact, I think this is the only supported way of putting an attribute on a function definition (rather than just a declaration). And it works in GCC, too.
So my first question is - has anyone ever tried using these macros under Windows?
There are public buildbots which compile LLVM and Clang under MSVC. Also, these macros are used in ErrorHandling.h, which is probably included in a solid 75% of the files in LLVM.
However, there's a more fundamental problem, which is that clang seems to be ignoring the __attribute__((noreturn)) altogether. That is, instead of relying on the above macros, if I just paste the noreturn attribute after my function, I still get "error: control reaches end of non-void function" in many places - errors which I wasn't getting with gcc.
You'll need to provide a bit more detail than that, because it's certainly working in the test cases I've seen.
I’m having some trouble getting clang to work with LLVM_ATTRIBUTE_NORETURN defined in Support/Compiler.h. There are several problems:
First there’s a problem with the macros themselves - AFAIK __declspec(noreturn) has to come at the front of the declaration, while attribute((noreturn)) has to come after it. The usual way of dealing with this is to define a macro which surrounds the declaration like so:
You can certainly put attribute((noreturn)) in the declaration-specifiers of a function. In fact, I think this is the only supported way of putting an attribute on a function definition (rather than just a declaration). And it works in GCC, too.
So my first question is - has anyone ever tried using these macros under Windows?
There are public buildbots which compile LLVM and Clang under MSVC. Also, these macros are used in ErrorHandling.h, which is probably included in a solid 75% of the files in LLVM.
OK - sorry for going hyperbolic there…
However, there’s a more fundamental problem, which is that clang seems to be ignoring the attribute((noreturn)) altogether. That is, instead of relying on the above macros, if I just paste the noreturn attribute after my function, I still get “error: control reaches end of non-void function” in many places - errors which I wasn’t getting with gcc.
You’ll need to provide a bit more detail than that, because it’s certainly working in the test cases I’ve seen.
All right - here’s what I have (with much detail omitted):