diff options
author | Ted Kremenek <kremenek@apple.com> | 2014-03-20 06:07:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2014-03-20 06:07:35 +0000 |
commit | 2766ad27e867c40378f2e5c18094594aa112b7b4 (patch) | |
tree | bda98c5b5110b2c195cea12cd10945618777303b /clang/test/SemaCXX/warn-unreachable.cpp | |
parent | f3c93bb61b486d3b01de8d0b071688a35388474d (diff) | |
download | bcm5719-llvm-2766ad27e867c40378f2e5c18094594aa112b7b4.tar.gz bcm5719-llvm-2766ad27e867c40378f2e5c18094594aa112b7b4.zip |
[-Wunreachable-code] constexpr functions can be used as configuration values.
llvm-svn: 204308
Diffstat (limited to 'clang/test/SemaCXX/warn-unreachable.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-unreachable.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/warn-unreachable.cpp b/clang/test/SemaCXX/warn-unreachable.cpp index abab966c660..9db75926d23 100644 --- a/clang/test/SemaCXX/warn-unreachable.cpp +++ b/clang/test/SemaCXX/warn-unreachable.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -verify -fblocks -Wunreachable-code-aggressive -Wno-unused-value +// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -verify -fblocks -std=c++11 -Wunreachable-code-aggressive -Wno-unused-value int &halt() __attribute__((noreturn)); int &live(); @@ -234,3 +234,24 @@ Frobozz test_return_object_control_flow(int flag) { return Frobozz(flag ? 42 : 24); // expected-warning {{code will never be executed}} } +void somethingToCall(); + + static constexpr bool isConstExprConfigValue() { return true; } + + int test_const_expr_config_value() { + if (isConstExprConfigValue()) { + somethingToCall(); + return 0; + } + somethingToCall(); // no-warning + return 1; + } + int test_const_expr_config_value_2() { + if (!isConstExprConfigValue()) { + somethingToCall(); // no-warning + return 0; + } + somethingToCall(); + return 1; + } + |