diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-25 04:25:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-25 04:25:58 +0000 |
commit | ce94049b69f75b44c18584fe79cd238978b6b0d5 (patch) | |
tree | e7075c52e30004d24fb813d4847b32e6a1d9f76d /test/SemaTemplate/value-dependent-null-pointer-constant.cpp | |
parent | d52025366666647e3f876e3615200dcf8c80279c (diff) |
Fix checking for a null pointer constant when the expression itself is
value-dependent. Audit (and fixed) all calls to
Expr::isNullPointerConstant() to provide the correct behavior with
value-dependent expressions. Fixes PR5041 and a crash in libstdc++
<locale>.
In the same vein, properly compute value- and type-dependence for
ChooseExpr. Fixes PR4996.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82748 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaTemplate/value-dependent-null-pointer-constant.cpp')
-rw-r--r-- | test/SemaTemplate/value-dependent-null-pointer-constant.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/SemaTemplate/value-dependent-null-pointer-constant.cpp b/test/SemaTemplate/value-dependent-null-pointer-constant.cpp new file mode 100644 index 0000000000..8bde1277ed --- /dev/null +++ b/test/SemaTemplate/value-dependent-null-pointer-constant.cpp @@ -0,0 +1,29 @@ +// RUN: clang-cc -fsyntax-only %s + +template<typename T, int N> +struct X0 { + const char *f0(bool Cond) { + return Cond? "honk" : N; + } + + const char *f1(bool Cond) { + return Cond? N : "honk"; + } + + bool f2(const char *str) { + return str == N; + } +}; + +// PR4996 +template<unsigned I> int f0() { + return __builtin_choose_expr(I, 0, 1); +} + +// PR5041 +struct A { }; + +template <typename T> void f(T *t) +{ + (void)static_cast<void*>(static_cast<A*>(t)); +}
\ No newline at end of file |