mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 13:50:11 +00:00
588bd9b7f8
the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B, C))) attribute, since that does the wrong thing for function templates and varargs functions. In passing, fix a grammar error in the diagnostic, a crash if __attribute__((nonnull(N))) is applied to a varargs function, a bug where the same null argument could be diagnosed multiple times if there were multiple nonnull attributes referring to it, and a bug where nonnull attributes would not be accumulated correctly across redeclarations. llvm-svn: 216520
21 lines
569 B
C++
21 lines
569 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
template<int I>
|
|
struct TS {
|
|
__attribute__((returns_nonnull))
|
|
void *value_dependent(void) {
|
|
return I; // no-warning
|
|
}
|
|
|
|
__attribute__((returns_nonnull))
|
|
void *value_independent(void) {
|
|
return 0; // expected-warning {{null returned from function that requires a non-null return value}}
|
|
}
|
|
};
|
|
|
|
namespace Template {
|
|
template<typename T> __attribute__((nonnull)) void f(T t);
|
|
void g() { f((void*)0); } // expected-warning {{null passed to a callee that requires a non-null argument}}
|
|
void h() { f(0); }
|
|
}
|