summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unreachable.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-09-20 07:22:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-09-20 07:22:00 +0000
commit405e2dbf3767586ab06a8506a6f5754aeb5a613d (patch)
tree7cd5b3ac40b4dd5c57236b1e89445fdec4dc5352 /clang/test/SemaCXX/warn-unreachable.cpp
parent8a65209d0ba5f4553fa1eba89e2e2fcf43c9c01d (diff)
downloadbcm5719-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/SemaCXX/warn-unreachable.cpp')
-rw-r--r--clang/test/SemaCXX/warn-unreachable.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp
index b08467ab51e..08118147b75 100644
--- a/clang/test/SemaCXX/warn-unreachable.cpp
+++ b/clang/test/SemaCXX/warn-unreachable.cpp
@@ -49,22 +49,26 @@ void test3() {
(halt()); // expected-warning {{will never be executed}}
}
-void test4() {
+namespace Test4 {
struct S {
int mem;
} s;
S &foor();
- halt(), foor()// expected-warning {{will never be executed}}
- .mem;
+ void test4() {
+ halt(), foor()// expected-warning {{will never be executed}}
+ .mem;
+ }
}
-void test5() {
+namespace Test5 {
struct S {
int mem;
} s;
S &foonr() __attribute__((noreturn));
- foonr()
- .mem; // expected-warning {{will never be executed}}
+ void test5() {
+ foonr()
+ .mem; // expected-warning {{will never be executed}}
+ }
}
void test6() {
OpenPOWER on IntegriCloud