diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-20 07:22:00 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-09-20 07:22:00 +0000 |
| commit | 405e2dbf3767586ab06a8506a6f5754aeb5a613d (patch) | |
| tree | 7cd5b3ac40b4dd5c57236b1e89445fdec4dc5352 /clang/test/Analysis/reference.cpp | |
| parent | 8a65209d0ba5f4553fa1eba89e2e2fcf43c9c01d (diff) | |
| download | bcm5719-llvm-405e2dbf3767586ab06a8506a6f5754aeb5a613d.tar.gz bcm5719-llvm-405e2dbf3767586ab06a8506a6f5754aeb5a613d.zip | |
Implement C++ [basic.link]p8.
If a function or variable has a type with no linkage (and is not extern "C"),
any use of it requires a definition within the same translation unit; the idea
is that it is not possible to define the entity elsewhere, so any such use is
necessarily an error.
There is an exception, though: some types formally have no linkage but
nonetheless can be referenced from other translation units (for example, this
happens to anonymous structures defined within inline functions). For entities
with those types, we suppress the diagnostic except under -pedantic.
llvm-svn: 313729
Diffstat (limited to 'clang/test/Analysis/reference.cpp')
| -rw-r--r-- | clang/test/Analysis/reference.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/test/Analysis/reference.cpp b/clang/test/Analysis/reference.cpp index b323b966610..c269dd7bad1 100644 --- a/clang/test/Analysis/reference.cpp +++ b/clang/test/Analysis/reference.cpp @@ -117,6 +117,11 @@ void testRetroactiveNullReference(int *x) { y = 5; // expected-warning{{Dereference of null pointer}} } +namespace TestReferenceAddress { +struct S { int &x; }; +S getS(); +S *getSP(); + void testReferenceAddress(int &x) { // FIXME: Move non-zero reference assumption out of RangeConstraintManager.cpp:422 #ifdef ANALYZER_CM_Z3 @@ -127,23 +132,19 @@ void testReferenceAddress(int &x) { clang_analyzer_eval(&ref() != 0); // expected-warning{{TRUE}} #endif - struct S { int &x; }; - - extern S getS(); #ifdef ANALYZER_CM_Z3 clang_analyzer_eval(&getS().x != 0); // expected-warning{{UNKNOWN}} #else clang_analyzer_eval(&getS().x != 0); // expected-warning{{TRUE}} #endif - extern S *getSP(); #ifdef ANALYZER_CM_Z3 clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{UNKNOWN}} #else clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{TRUE}} #endif } - +} void testFunctionPointerReturn(void *opaque) { typedef int &(*RefFn)(); |

