mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:16:05 +00:00

This patch adds the noderef attribute in clang and checks for dereferences of types that have this attribute. This attribute is currently used by sparse and would like to be ported to clang. Differential Revision: https://reviews.llvm.org/D49511 llvm-svn: 348442
16 lines
543 B
C++
16 lines
543 B
C++
// RUN: %clang_cc1 -verify %s
|
|
|
|
#define NODEREF __attribute__((noderef))
|
|
|
|
template <typename T>
|
|
int func(T NODEREF *a) { // expected-note 2 {{a declared here}}
|
|
return *a + 1; // expected-warning 2 {{dereferencing a; was declared with a 'noderef' type}}
|
|
}
|
|
|
|
void func() {
|
|
float NODEREF *f;
|
|
int NODEREF *i;
|
|
func(f); // expected-note{{in instantiation of function template specialization 'func<float>' requested here}}
|
|
func(i); // expected-note{{in instantiation of function template specialization 'func<int>' requested here}}
|
|
}
|