From ce94049b69f75b44c18584fe79cd238978b6b0d5 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 25 Sep 2009 04:25:58 +0000 Subject: 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++ . 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 --- .../value-dependent-null-pointer-constant.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/SemaTemplate/value-dependent-null-pointer-constant.cpp (limited to 'test/SemaTemplate/value-dependent-null-pointer-constant.cpp') 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 +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 int f0() { + return __builtin_choose_expr(I, 0, 1); +} + +// PR5041 +struct A { }; + +template void f(T *t) +{ + (void)static_cast(static_cast(t)); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2