diff options
author | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-06-10 20:45:12 +0000 |
commit | ea266cad53e3d49771fa38103913d3ec7a166694 (patch) | |
tree | 8f7776b7310bebaf415ac5b69e46e9f928c37144 /test/Analysis/derived-to-base.cpp | |
parent | c72c57c9e9b69944e3e009cd5e209634839581d3 (diff) | |
download | FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.zip FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.tar.gz |
Vendor import of clang tags/RELEASE_33/final r183502 (effectively, 3.3
release):
http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_33/final@183502
Diffstat (limited to 'test/Analysis/derived-to-base.cpp')
-rw-r--r-- | test/Analysis/derived-to-base.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp index b846d2c..0664189 100644 --- a/test/Analysis/derived-to-base.cpp +++ b/test/Analysis/derived-to-base.cpp @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -DCONSTRUCTORS=1 -analyzer-config c++-inlining=constructors -verify %s void clang_analyzer_eval(bool); +void clang_analyzer_checkInlined(bool); class A { protected: @@ -363,3 +364,89 @@ namespace Redeclaration { } }; +namespace PR15394 { + namespace Original { + class Base { + public: + virtual int f() = 0; + int i; + }; + + class Derived1 : public Base { + public: + int j; + }; + + class Derived2 : public Derived1 { + public: + virtual int f() { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return i + j; + } + }; + + void testXXX() { + Derived1 *d1p = reinterpret_cast<Derived1*>(new Derived2); + d1p->i = 1; + d1p->j = 2; + clang_analyzer_eval(d1p->f() == 3); // expected-warning{{TRUE}} + } + } + + namespace VirtualInDerived { + class Base { + public: + int i; + }; + + class Derived1 : public Base { + public: + virtual int f() = 0; + int j; + }; + + class Derived2 : public Derived1 { + public: + virtual int f() { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return i + j; + } + }; + + void test() { + Derived1 *d1p = reinterpret_cast<Derived1*>(new Derived2); + d1p->i = 1; + d1p->j = 2; + clang_analyzer_eval(d1p->f() == 3); // expected-warning{{TRUE}} + } + } + + namespace NoCast { + class Base { + public: + int i; + }; + + class Derived1 : public Base { + public: + virtual int f() = 0; + int j; + }; + + class Derived2 : public Derived1 { + public: + virtual int f() { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return i + j; + } + }; + + void test() { + Derived1 *d1p = new Derived2; + d1p->i = 1; + d1p->j = 2; + clang_analyzer_eval(d1p->f() == 3); // expected-warning{{TRUE}} + } + } +}; + |