[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaTemplate / value-dependent-null-pointer-constant.cpp
blob29fd15e39576d25a81e8101726e6feeefb0485dc
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 template<typename T, int N>
6 struct X0 {
7 const char *f0(bool Cond) {
8 return Cond? "honk" : N;
9 #if __cplusplus >= 201103L
10 // expected-error@-2 {{incompatible operand types ('const char *' and 'int')}}
11 #else
12 // expected-no-diagnostics
13 #endif
16 const char *f1(bool Cond) {
17 return Cond? N : "honk";
18 #if __cplusplus >= 201103L
19 // expected-error@-2 {{incompatible operand types ('int' and 'const char *')}}
20 #endif
23 bool f2(const char *str) {
24 return str == N;
25 #if __cplusplus >= 201103L
26 // expected-error@-2 {{comparison between pointer and integer ('const char *' and 'int')}}
27 #endif
31 // PR4996
32 template<unsigned I> int f0() {
33 return __builtin_choose_expr(I, 0, 1);
36 // PR5041
37 struct A { };
39 template <typename T> void f(T *t)
41 (void)static_cast<void*>(static_cast<A*>(t));