From 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 13:06:31 +0000 Subject: Vendor import of clang trunk r126079: http://llvm.org/svn/llvm-project/cfe/trunk@126079 --- test/ASTMerge/Inputs/category1.m | 23 + test/ASTMerge/Inputs/category2.m | 22 + test/ASTMerge/Inputs/class-template1.cpp | 34 + test/ASTMerge/Inputs/class-template2.cpp | 35 + test/ASTMerge/Inputs/class1.cpp | 7 + test/ASTMerge/Inputs/class2.cpp | 1 + test/ASTMerge/Inputs/interface1.m | 22 + test/ASTMerge/Inputs/interface2.m | 20 + test/ASTMerge/Inputs/property1.m | 19 + test/ASTMerge/Inputs/property2.m | 20 + test/ASTMerge/category.m | 4 +- test/ASTMerge/class-template.cpp | 24 + test/ASTMerge/interface.m | 5 +- test/ASTMerge/property.m | 6 +- test/Analysis/CFNumber.c | 8 +- test/Analysis/MissingDealloc.m | 2 +- test/Analysis/NSString.m | 16 +- test/Analysis/NSWindow.m | 8 +- test/Analysis/ObjCRetSigs.m | 2 +- test/Analysis/PR2978.m | 2 +- test/Analysis/additive-folding.c | 8 +- test/Analysis/analyzer-stats.c | 14 + test/Analysis/array-struct-region.c | 4 +- test/Analysis/array-struct.c | 8 +- test/Analysis/auto-obj-dtors-cfg-output.cpp | 835 ++++++++ test/Analysis/base-init.cpp | 30 + test/Analysis/blocks.m | 4 +- test/Analysis/bstring.c | 8 +- test/Analysis/chroot.c | 24 + test/Analysis/complex.c | 8 +- test/Analysis/conditional-op-missing-lhs.c | 2 +- test/Analysis/constant-folding.c | 2 +- test/Analysis/cxx-crashes.cpp | 45 + test/Analysis/dead-stores.c | 68 +- test/Analysis/dead-stores.cpp | 28 +- test/Analysis/dead-stores.m | 37 +- test/Analysis/derived-to-base.cpp | 15 + test/Analysis/dtor.cpp | 13 + test/Analysis/dtors-in-dtor-cfg-output.cpp | 60 + test/Analysis/exercise-ps.c | 2 +- test/Analysis/fields.c | 10 + .../Analysis/idempotent-operations-limited-loops.c | 21 + test/Analysis/idempotent-operations.c | 49 +- test/Analysis/idempotent-operations.cpp | 2 +- test/Analysis/idempotent-operations.m | 42 + test/Analysis/initializer.cpp | 14 + test/Analysis/initializers-cfg-output.cpp | 94 + test/Analysis/inline.c | 16 +- test/Analysis/lvalue.cpp | 6 + test/Analysis/malloc.c | 2 +- test/Analysis/method-call.cpp | 25 +- test/Analysis/misc-ps-64.m | 2 +- test/Analysis/misc-ps-region-store.cpp | 81 + test/Analysis/misc-ps-region-store.m | 113 +- test/Analysis/misc-ps.m | 191 +- ...iver-undefined-larger-than-voidptr-ret-region.m | 38 + ...il-receiver-undefined-larger-than-voidptr-ret.m | 32 +- test/Analysis/null-deref-ps.c | 18 +- test/Analysis/operator-calls.cpp | 16 + test/Analysis/out-of-bounds.c | 148 ++ test/Analysis/outofbound.c | 2 +- test/Analysis/plist-output-alternate.m | 1014 +++++++++ test/Analysis/plist-output.m | 1 + test/Analysis/properties.m | 145 ++ test/Analysis/ptr-arith.c | 4 +- test/Analysis/rdar-6442306-1.m | 2 +- test/Analysis/rdar-6540084.m | 2 +- test/Analysis/refcnt_naming.m | 29 +- test/Analysis/reference.cpp | 3 +- test/Analysis/retain-release-gc-only.m | 4 +- test/Analysis/retain-release-region-store.m | 2 +- test/Analysis/retain-release.m | 106 +- test/Analysis/security-syntax-checks-no-emit.c | 2 +- test/Analysis/security-syntax-checks.m | 2 +- test/Analysis/self-init.m | 165 ++ test/Analysis/sizeofpointer.c | 2 +- test/Analysis/stack-addr-ps.c | 4 +- test/Analysis/stack-addr-ps.cpp | 86 + test/Analysis/stackaddrleak.c | 2 +- test/Analysis/stream.c | 8 +- test/Analysis/string.c | 8 +- test/Analysis/temp-obj-dtors-cfg-output.cpp | 591 +++++ test/Analysis/uninit-msg-expr.m | 4 +- test/Analysis/uninit-ps-rdar6145427.m | 2 +- test/Analysis/uninit-vals-ps-region.m | 2 +- test/Analysis/uninit-vals-ps.c | 2 +- test/Analysis/uninit-vals.c | 2 +- test/Analysis/unix-fns.c | 21 +- test/Analysis/unreachable-code-path.c | 26 +- test/Analysis/unused-ivars.m | 14 +- test/CMakeLists.txt | 70 +- .../basic/basic.lookup/basic.lookup.argdep/p4.cpp | 2 +- .../basic/basic.scope/basic.scope.hiding/p2.cpp | 24 + .../CXX/basic/basic.start/basic.start.main/p2h.cpp | 5 + test/CXX/class.access/class.friend/p1.cpp | 41 +- test/CXX/class.access/class.friend/p11.cpp | 19 + test/CXX/class.access/p4.cpp | 62 +- test/CXX/class.access/p6.cpp | 29 + test/CXX/class.derived/class.abstract/p4.cpp | 4 +- test/CXX/class.derived/class.abstract/p5.cpp | 10 +- test/CXX/class.derived/class.member.lookup/p9.cpp | 28 + test/CXX/class.derived/class.virtual/p3-0x.cpp | 53 + test/CXX/class.derived/p8-0x.cpp | 22 + test/CXX/class/class.friend/p1.cpp | 3 +- test/CXX/class/class.mem/p1.cpp | 27 + test/CXX/class/class.mem/p13.cpp | 40 + test/CXX/class/class.mem/p14.cpp | 19 + test/CXX/class/class.mem/p1b.cpp | 46 + test/CXX/class/class.mem/p8-0x-pedantic.cpp | 14 + test/CXX/class/class.mem/p8-0x.cpp | 55 + test/CXX/class/class.nest/p1-cxx0x.cpp | 14 + test/CXX/class/class.nest/p1.cpp | 6 +- test/CXX/class/class.union/p1.cpp | 8 + test/CXX/class/p1-0x.cpp | 10 + test/CXX/class/p2-0x.cpp | 28 + .../namespace.def/namespace.memdef/p3.cpp | 27 +- .../dcl.dcl/basic.namespace/namespace.def/p2.cpp | 24 + .../dcl.dcl/basic.namespace/namespace.udecl/p1.cpp | 1 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp | 31 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp | 35 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp | 73 +- .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp | 86 + .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp | 23 + test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 164 ++ .../dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp | 2 +- .../dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp | 24 +- test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp | 20 +- test/CXX/dcl.decl/dcl.init/p6.cpp | 4 +- .../dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp | 1 + test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp | 14 +- test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp | 48 + test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp | 31 + test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp | 5 + test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp | 28 + test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp | 14 + test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp | 10 + test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp | 26 + test/CXX/dcl.decl/p4-0x.cpp | 8 + test/CXX/except/except.handle/p16.cpp | 2 +- test/CXX/except/except.spec/p14-ir.cpp | 14 +- test/CXX/expr/expr.cast/p4-0x.cpp | 11 + test/CXX/expr/expr.cast/p4.cpp | 23 + test/CXX/expr/expr.mptr.oper/p5.cpp | 61 + test/CXX/expr/expr.mptr.oper/p6-0x.cpp | 34 + test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp | 17 + .../CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp | 14 + .../expr/expr.post/expr.reinterpret.cast/p1-0x.cpp | 16 + test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp | 24 + test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp | 29 + test/CXX/expr/expr.unary/expr.delete/p5.cpp | 22 +- test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp | 23 + test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp | 38 + .../CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp | 26 + .../expr/expr.unary/expr.unary.noexcept/sema.cpp | 172 ++ test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h | 8 + test/CXX/expr/expr.unary/expr.unary.op/p4.cpp | 6 +- test/CXX/expr/expr.unary/expr.unary.op/p6.cpp | 36 + test/CXX/over/over.built/p1.cpp | 16 + test/CXX/over/over.built/p25.cpp | 15 + test/CXX/over/over.load/p2-0x.cpp | 24 + .../over.match.best/over.ics.rank/p3-0x.cpp | 59 + .../CXX/over/over.match/over.match.funcs/p4-0x.cpp | 70 + .../over.over/p2-resolve-single-template-id.cpp | 95 + test/CXX/over/over.over/p2.cpp | 5 +- test/CXX/over/over.over/p4.cpp | 7 +- test/CXX/special/class.copy/p33-0x.cpp | 25 + test/CXX/special/class.copy/p9.cpp | 24 +- test/CXX/special/class.ctor/p4-0x.cpp | 7 + test/CXX/special/class.dtor/p2-0x.cpp | 10 + test/CXX/special/class.inhctor/elsewhere.cpp | 31 + test/CXX/special/class.inhctor/p3.cpp | 30 + test/CXX/special/class.inhctor/p7.cpp | 18 + test/CXX/stmt.stmt/stmt.label/p1.cpp | 25 + test/CXX/stmt.stmt/stmt.select/p3.cpp | 2 +- test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp | 16 +- test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp | 40 + test/CXX/temp/temp.arg/temp.arg.type/p2.cpp | 42 + test/CXX/temp/temp.decls/temp.class.spec/p6.cpp | 21 + test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp | 8 + test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp | 13 + test/CXX/temp/temp.decls/temp.class.spec/p9.cpp | 26 + .../temp.decls/temp.fct/temp.func.order/p3-0x.cpp | 17 + .../temp.decls/temp.fct/temp.func.order/p3.cpp | 16 + test/CXX/temp/temp.decls/temp.friend/p1.cpp | 39 + test/CXX/temp/temp.decls/temp.friend/p5.cpp | 106 +- test/CXX/temp/temp.decls/temp.friend/p8.cpp | 6 + test/CXX/temp/temp.decls/temp.mem/p3.cpp | 6 + test/CXX/temp/temp.decls/temp.mem/p5.cpp | 6 +- .../temp/temp.decls/temp.variadic/deduction.cpp | 50 + .../temp/temp.decls/temp.variadic/example-bind.cpp | 352 +++ .../temp.decls/temp.variadic/example-function.cpp | 86 + .../temp.decls/temp.variadic/example-tuple.cpp | 260 +++ .../temp/temp.decls/temp.variadic/ext-blocks.cpp | 39 + .../temp.variadic/injected-class-name.cpp | 75 + .../temp.decls/temp.variadic/metafunctions.cpp | 274 +++ .../temp.variadic/multi-level-substitution.cpp | 218 ++ test/CXX/temp/temp.decls/temp.variadic/p1.cpp | 9 + test/CXX/temp/temp.decls/temp.variadic/p2.cpp | 22 + test/CXX/temp/temp.decls/temp.variadic/p4.cpp | 135 ++ test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 393 ++++ .../temp.variadic/parameter-matching.cpp | 34 +- .../temp.decls/temp.variadic/partial-ordering.cpp | 61 + .../temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp | 27 + .../temp.arg.explicit/p3-nodeduct.cpp | 2 +- .../temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp | 68 + .../temp.deduct/temp.deduct.call/p1-0x.cpp | 88 + .../temp.deduct/temp.deduct.call/p3-0x.cpp | 46 + .../temp.deduct/temp.deduct.call/p3.cpp | 22 + .../temp.deduct/temp.deduct.partial/p11.cpp | 31 +- .../temp.deduct/temp.deduct.partial/p12.cpp | 27 + .../temp.deduct/temp.deduct.partial/p9-0x.cpp | 10 + .../temp.deduct/temp.deduct.type/p10-0x.cpp | 4 + .../temp.deduct/temp.deduct.type/p2-0x.cpp | 23 + .../temp.deduct/temp.deduct.type/p21.cpp | 31 + .../temp.deduct/temp.deduct.type/p22.cpp | 14 + .../temp.deduct/temp.deduct.type/p5-0x.cpp | 22 + .../temp.deduct/temp.deduct.type/p8-0x.cpp | 47 + .../temp.deduct/temp.deduct.type/p9-0x.cpp | 55 + test/CXX/temp/temp.param/p1.cpp | 12 +- test/CXX/temp/temp.param/p11-0x.cpp | 61 + test/CXX/temp/temp.param/p15-cxx0x.cpp | 2 + test/CXX/temp/temp.param/p9-0x.cpp | 52 + test/CXX/temp/temp.param/p9.cpp | 4 +- test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp | 239 +++ test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp | 14 +- test/CXX/temp/temp.spec/temp.explicit/p12.cpp | 2 +- test/CodeCompletion/ordinary-name.c | 3 + test/CodeCompletion/ordinary-name.cpp | 2 +- test/CodeCompletion/stdin.c | 7 + test/CodeGen/2008-07-17-no-emit-on-error.c | 1 + test/CodeGen/2008-07-29-override-alias-decl.c | 2 +- test/CodeGen/2010-03-09-DbgInfo.c | 2 +- test/CodeGen/annotate.c | 2 + test/CodeGen/arm-vector-arguments.c | 30 + test/CodeGen/asm-errors.c | 2 +- test/CodeGen/asm-inout.c | 12 + test/CodeGen/asm-variable.c | 59 + test/CodeGen/assign.c | 6 +- test/CodeGen/atomic.c | 130 +- test/CodeGen/attr-naked.c | 9 + test/CodeGen/blocks-1.c | 28 +- test/CodeGen/blocks.c | 7 + test/CodeGen/blocksignature.c | 12 +- test/CodeGen/blockstret.c | 2 +- test/CodeGen/blockwithlocalstatic.c | 19 + test/CodeGen/bool_test.c | 5 + test/CodeGen/builtins-ppc-altivec.c | 1029 ++++++++- test/CodeGen/builtins-x86.c | 1 + test/CodeGen/char-literal.c | 35 + test/CodeGen/conditional-gnu-ext.c | 24 + test/CodeGen/const-init.c | 2 +- test/CodeGen/darwin-string-literals.c | 12 +- test/CodeGen/debug-info-crash.c | 9 + test/CodeGen/debug-info-line.c | 15 + test/CodeGen/debug-info-var-location.c | 21 + test/CodeGen/designated-initializers.c | 33 + test/CodeGen/enum.c | 3 + test/CodeGen/exceptions.c | 19 + test/CodeGen/exprs.c | 26 +- test/CodeGen/ext-vector-shuffle.c | 17 - test/CodeGen/frame-pointer-elim.c | 29 +- test/CodeGen/func-in-block.c | 2 +- test/CodeGen/illegal-UTF8.m | 4 +- test/CodeGen/imaginary.c | 4 + test/CodeGen/init.c | 69 + test/CodeGen/integer-overflow.c | 7 + test/CodeGen/lineno-dbginfo.c | 2 +- test/CodeGen/mangle.c | 6 +- test/CodeGen/may-alias.c | 21 + test/CodeGen/mcount.c | 4 + test/CodeGen/mms-bitfields.c | 22 + test/CodeGen/mmx-builtins.c | 452 ++++ test/CodeGen/mmx-shift-with-immediate.c | 23 + test/CodeGen/ms-anonymous-struct.c | 99 + test/CodeGen/mult-alt-generic.c | 283 +++ test/CodeGen/mult-alt-x86.c | 374 ++++ test/CodeGen/no-common.c | 17 +- test/CodeGen/packed-structure.c | 13 + test/CodeGen/palignr.c | 6 +- test/CodeGen/pascal-wchar-string.c | 12 +- test/CodeGen/pointer-arithmetic.c | 3 + test/CodeGen/pointer-signext.c | 32 + test/CodeGen/pragma-weak.c | 2 +- test/CodeGen/predefined-expr.c | 16 +- test/CodeGen/regparm-flag.c | 15 + test/CodeGen/regparm.c | 5 +- test/CodeGen/sizeof-vla.c | 2 +- test/CodeGen/statements.c | 2 +- test/CodeGen/string-literal-short-wstring.c | 43 + test/CodeGen/string-literal.c | 11 +- test/CodeGen/struct-init.c | 13 +- test/CodeGen/struct-passing.c | 20 +- test/CodeGen/switch.c | 17 + test/CodeGen/thread-specifier.c | 10 +- test/CodeGen/transparent-union.c | 25 + test/CodeGen/va_list_test.c | 6 + test/CodeGen/visibility.c | 77 +- test/CodeGen/vla.c | 65 +- test/CodeGen/volatile-1.c | 216 +- test/CodeGen/volatile-2.c | 23 + test/CodeGen/x86_32-arguments-darwin.c | 278 +++ test/CodeGen/x86_32-arguments-linux.c | 51 + test/CodeGen/x86_32-arguments-realign.c | 11 + test/CodeGen/x86_32-arguments.c | 230 -- test/CodeGenCXX/PR5050-constructor-conversion.cpp | 2 +- test/CodeGenCXX/PR5863-unreachable-block.cpp | 2 +- test/CodeGenCXX/anonymous-namespaces.cpp | 2 +- .../anonymous-union-member-initializer.cpp | 35 +- test/CodeGenCXX/apple-kext-indirect-call-2.C | 77 + test/CodeGenCXX/apple-kext-indirect-call.C | 14 + .../apple-kext-indirect-virtual-dtor-call.cpp | 19 + test/CodeGenCXX/apple-kext-linkage.C | 25 + test/CodeGenCXX/apple-kext-no-staticinit-section.C | 20 + test/CodeGenCXX/arm.cpp | 79 +- test/CodeGenCXX/array-construction.cpp | 2 +- test/CodeGenCXX/array-operator-delete-call.cpp | 2 +- test/CodeGenCXX/array-value-initialize.cpp | 2 +- test/CodeGenCXX/asm.cpp | 14 + test/CodeGenCXX/attr-used.cpp | 9 + test/CodeGenCXX/attr.cpp | 2 +- test/CodeGenCXX/block-byref-cxx-objc.cpp | 25 + test/CodeGenCXX/blocks.cpp | 57 + test/CodeGenCXX/builtins.cpp | 9 + test/CodeGenCXX/c99-variable-length-array.cpp | 2 +- test/CodeGenCXX/call-arg-zero-temp.cpp | 2 +- test/CodeGenCXX/cast-conversion.cpp | 12 +- test/CodeGenCXX/class-layout.cpp | 24 +- test/CodeGenCXX/const-init.cpp | 12 + test/CodeGenCXX/constructor-attr.cpp | 12 + test/CodeGenCXX/constructor-conversion.cpp | 6 +- test/CodeGenCXX/constructor-convert.cpp | 2 +- test/CodeGenCXX/constructor-default-arg.cpp | 6 +- test/CodeGenCXX/constructor-direct-call.cpp | 60 + test/CodeGenCXX/constructor-for-array-members.cpp | 2 +- test/CodeGenCXX/constructor-init.cpp | 34 +- test/CodeGenCXX/constructors.cpp | 20 +- test/CodeGenCXX/convert-to-fptr.cpp | 4 +- test/CodeGenCXX/copy-constructor-elim-2.cpp | 24 +- test/CodeGenCXX/copy-constructor-synthesis-2.cpp | 2 +- test/CodeGenCXX/copy-constructor-synthesis.cpp | 4 +- test/CodeGenCXX/cxx-block-objects.cpp | 33 + test/CodeGenCXX/debug-info-ctor2.cpp | 15 + test/CodeGenCXX/debug-info-large-constant.cpp | 8 + test/CodeGenCXX/debug-info-member.cpp | 6 + test/CodeGenCXX/debug-info-method.cpp | 6 + test/CodeGenCXX/debug-info-namespace.cpp | 12 + test/CodeGenCXX/debug-info-template.cpp | 15 +- test/CodeGenCXX/decl-ref-init.cpp | 4 +- test/CodeGenCXX/default-arg-temps.cpp | 2 +- test/CodeGenCXX/default-arguments.cpp | 4 +- .../CodeGenCXX/default-constructor-for-members.cpp | 2 +- .../default-constructor-template-member.cpp | 2 +- test/CodeGenCXX/delete-two-arg.cpp | 70 +- test/CodeGenCXX/delete.cpp | 9 +- test/CodeGenCXX/derived-to-base-conv.cpp | 4 +- test/CodeGenCXX/derived-to-base.cpp | 11 + .../derived-to-virtual-base-class-calls-final.cpp | 16 + test/CodeGenCXX/destructors.cpp | 54 +- .../devirtualize-virtual-function-calls-final.cpp | 51 + test/CodeGenCXX/dyncast.cpp | 1 - test/CodeGenCXX/eh.cpp | 88 +- test/CodeGenCXX/empty-classes.cpp | 13 + test/CodeGenCXX/exceptions-no-rtti.cpp | 10 +- test/CodeGenCXX/exceptions.cpp | 303 ++- test/CodeGenCXX/friend-redecl.cpp | 18 + test/CodeGenCXX/global-init.cpp | 17 + test/CodeGenCXX/gnu-conditional-scalar-ext.cpp | 62 + test/CodeGenCXX/goto.cpp | 43 + test/CodeGenCXX/implicit-copy-constructor.cpp | 2 +- test/CodeGenCXX/inline-functions.cpp | 32 + test/CodeGenCXX/internal-linkage.cpp | 4 +- test/CodeGenCXX/key-function-vtable.cpp | 13 +- test/CodeGenCXX/mangle-abi-examples.cpp | 27 + test/CodeGenCXX/mangle-local-class-vtables.cpp | 61 + test/CodeGenCXX/mangle-local-classes-nested.cpp | 81 + test/CodeGenCXX/mangle-ms.cpp | 8 +- test/CodeGenCXX/mangle-neon-vectors.cpp | 32 + test/CodeGenCXX/mangle-ref-qualifiers.cpp | 16 + test/CodeGenCXX/mangle-subst-std.cpp | 16 +- test/CodeGenCXX/mangle-template.cpp | 2 +- test/CodeGenCXX/mangle-unnamed.cpp | 21 + test/CodeGenCXX/mangle-variadic-templates.cpp | 67 + test/CodeGenCXX/mangle.cpp | 23 + test/CodeGenCXX/member-functions.cpp | 4 +- test/CodeGenCXX/member-init-assignment.cpp | 2 +- test/CodeGenCXX/member-pointer-type-convert.cpp | 1 + test/CodeGenCXX/member-templates.cpp | 4 +- test/CodeGenCXX/nrvo-noreturn.cc | 17 + test/CodeGenCXX/nrvo.cpp | 15 + test/CodeGenCXX/nullptr.cpp | 9 +- test/CodeGenCXX/pointers-to-data-members.cpp | 59 +- test/CodeGenCXX/pr9130.cpp | 14 + test/CodeGenCXX/pragma-pack.cpp | 14 + test/CodeGenCXX/pragma-visibility.cpp | 4 +- test/CodeGenCXX/predefined-expr.cpp | 106 +- test/CodeGenCXX/ptr-to-member-function.cpp | 4 +- test/CodeGenCXX/rtti-fundamental.cpp | 157 +- test/CodeGenCXX/rtti-linkage.cpp | 102 +- test/CodeGenCXX/rtti-visibility.cpp | 35 + test/CodeGenCXX/rvalue-references.cpp | 85 + .../specialized-static-data-mem-init.cpp | 29 + test/CodeGenCXX/static-data-member.cpp | 70 +- test/CodeGenCXX/static-init.cpp | 2 +- test/CodeGenCXX/stmtexpr.cpp | 75 + test/CodeGenCXX/template-anonymous-types.cpp | 4 +- .../template-dependent-bind-temporary.cpp | 24 + .../template-inner-struct-visibility-hidden.cpp | 24 + test/CodeGenCXX/template-instantiation.cpp | 51 +- test/CodeGenCXX/template-linkage.cpp | 2 +- test/CodeGenCXX/temporaries.cpp | 185 ++ test/CodeGenCXX/threadsafe-statics-exceptions.cpp | 4 +- test/CodeGenCXX/throw-expressions.cpp | 7 +- test/CodeGenCXX/thunks-available-externally.cpp | 88 + test/CodeGenCXX/thunks.cpp | 63 +- test/CodeGenCXX/value-init.cpp | 15 +- test/CodeGenCXX/variadic-templates.cpp | 12 + test/CodeGenCXX/virt-dtor-gen.cpp | 2 +- test/CodeGenCXX/virt-dtor-key.cpp | 2 +- test/CodeGenCXX/virt-template-vtable.cpp | 8 +- test/CodeGenCXX/virtual-base-destructor-call.cpp | 12 +- test/CodeGenCXX/virtual-bases.cpp | 12 +- test/CodeGenCXX/virtual-destructor-calls.cpp | 6 +- test/CodeGenCXX/visibility-inlines-hidden.cpp | 46 +- test/CodeGenCXX/visibility.cpp | 331 ++- test/CodeGenCXX/volatile-1.cpp | 352 +++ test/CodeGenCXX/volatile.cpp | 2 - test/CodeGenCXX/vtable-available-externally.cpp | 171 ++ test/CodeGenCXX/vtable-debug-info.cpp | 318 +++ test/CodeGenCXX/vtable-key-function.cpp | 2 +- test/CodeGenCXX/vtable-layout.cpp | 2 +- test/CodeGenCXX/vtable-linkage.cpp | 95 +- test/CodeGenCXX/vtable-pointer-initialization.cpp | 10 +- test/CodeGenCXX/vtt-layout.cpp | 8 +- test/CodeGenCXX/warn-padded-packed.cpp | 76 + test/CodeGenObjC/arm-atomic-scalar-setter-getter.m | 13 + test/CodeGenObjC/bitfield-gnu.m | 5 + test/CodeGenObjC/block-6.m | 12 + test/CodeGenObjC/block-var-layout.m | 101 +- test/CodeGenObjC/blocks-1.m | 8 +- test/CodeGenObjC/blocks-2.m | 37 +- test/CodeGenObjC/blocks.m | 56 +- test/CodeGenObjC/constant-string-class.m | 35 + test/CodeGenObjC/debug-info-default-synth-ivar.m | 35 + test/CodeGenObjC/debug-info-fnname.m | 15 + test/CodeGenObjC/debug-info-foreach.m | 13 + test/CodeGenObjC/debug-info-getter-name.m | 50 + test/CodeGenObjC/debug-info-selector.m | 15 + test/CodeGenObjC/debug-info-self.m | 16 + test/CodeGenObjC/debug-info-static-var.m | 23 + test/CodeGenObjC/default-property-synthesis.m | 2 +- test/CodeGenObjC/encode-test-1.m | 36 - test/CodeGenObjC/encode-test.m | 61 +- test/CodeGenObjC/exceptions-nonfragile.m | 17 + test/CodeGenObjC/exceptions.m | 62 +- test/CodeGenObjC/implicit-objc_msgSend.m | 2 +- test/CodeGenObjC/interface-layout-64.m | 4 +- test/CodeGenObjC/ivar-layout-64-bitfields.m | 5 + test/CodeGenObjC/ivar-layout-array0-struct.m | 22 + test/CodeGenObjC/ivar-layout-nonfragile-abi2.m | 4 +- test/CodeGenObjC/ivars.m | 15 + test/CodeGenObjC/local-static-block.m | 57 + test/CodeGenObjC/ns-constant-strings.m | 6 + test/CodeGenObjC/objc-read-weak-byref.m | 4 +- test/CodeGenObjC/objc2-nonfragile-abi-impl.m | 2 +- test/CodeGenObjC/objc2-weak-block-call.m | 13 +- test/CodeGenObjC/predefined-expr.m | 20 +- test/CodeGenObjC/property-ref-cast-to-void.m | 18 + test/CodeGenObjC/property-type-mismatch.m | 17 + test/CodeGenObjC/property.m | 55 +- test/CodeGenObjCXX/block-var-layout.mm | 157 ++ test/CodeGenObjCXX/blocks.mm | 30 + test/CodeGenObjCXX/encode.mm | 12 + test/CodeGenObjCXX/implicit-copy-constructor.mm | 2 +- .../CodeGenObjCXX/property-derived-to-base-conv.mm | 10 +- test/CodeGenObjCXX/property-dot-copy.mm | 68 + test/CodeGenObjCXX/property-dot-reference.mm | 62 + .../property-object-conditional-exp.mm | 38 + test/CodeGenObjCXX/property-objects.mm | 19 + test/CodeGenObjCXX/refence-assign-write-barrier.mm | 20 + test/CodeGenObjCXX/rtti.mm | 14 +- test/CodeGenObjCXX/write-barrier-global-assign.mm | 29 + test/CodeGenOpenCL/ext-vector-shuffle.cl | 17 + test/CodeGenOpenCL/kernel-metadata.cl | 10 + test/CodeGenOpenCL/single-precision-constant.cl | 7 + test/Coverage/c-language-features.inc | 8 + test/Coverage/cxx-language-features.inc | 6 + test/Coverage/html-diagnostics.c | 5 +- test/Coverage/targets.c | 1 - test/Driver/apple-kext-mkernel.c | 6 + test/Driver/clang_f_opts.c | 6 +- test/Driver/darwin-ld.c | 22 +- test/Driver/darwin-xarch.c | 12 +- test/Driver/dragonfly.c | 1 - test/Driver/emit-llvm.c | 3 - test/Driver/freebsd.c | 6 +- test/Driver/m_and_mm.c | 3 + test/Driver/openbsd.c | 1 - test/Driver/sysroot-flags.c | 28 + test/FixIt/fixit-errors.c | 2 +- test/FixIt/fixit-objc-message.m | 38 + test/FixIt/fixit-objc.m | 32 +- test/FixIt/fixit-unrecoverable.cpp | 3 +- test/FixIt/fixit.c | 7 + test/FixIt/fixit.cpp | 27 + test/FixIt/typo.cpp | 1 + test/FixIt/typo.m | 25 +- test/Headers/arm-neon-header.c | 5 + test/Headers/stdbool.cpp | 14 + test/Headers/x86-intrinsics-headers.c | 10 +- test/Index/Inputs/a.h | 4 + test/Index/Inputs/b.h | 1 + test/Index/Inputs/get-cursor-includes-1.h | 6 + test/Index/Inputs/get-cursor-includes-2.h | 2 + test/Index/TestClassDecl.m | 6 +- test/Index/TestClassForwardDecl.m | 6 +- test/Index/annotate-tokens-cxx0x.cpp | 8 + test/Index/annotate-tokens-include.c | 5 +- test/Index/annotate-tokens-pp.c | 100 +- test/Index/annotate-tokens.c | 23 +- test/Index/annotate-tokens.cpp | 14 +- test/Index/annotate-tokens.m | 235 +- test/Index/blocks.c | 41 +- test/Index/c-index-api-loadTU-test.m | 5 - test/Index/c-index-getCursor-pp.c | 27 +- test/Index/c-index-getCursor-test.m | 10 +- test/Index/c-index-redecls.c | 107 + test/Index/cindex-on-invalid-usrs.m | 7 + test/Index/code-complete-errors.c | 16 - test/Index/code-completion.cpp | 20 +- test/Index/complete-at-directives.m | 14 +- test/Index/complete-at-exprstmt.m | 16 +- test/Index/complete-blocks.m | 37 +- test/Index/complete-ctor-inits.cpp | 26 +- test/Index/complete-declarators.cpp | 32 +- test/Index/complete-declarators.m | 55 +- test/Index/complete-driver-errors.c | 24 + test/Index/complete-enums.c | 23 +- test/Index/complete-exprs.c | 42 +- test/Index/complete-exprs.cpp | 53 + test/Index/complete-exprs.m | 29 + test/Index/complete-hiding.c | 19 +- test/Index/complete-kvc.m | 87 + test/Index/complete-macros.c | 4 +- test/Index/complete-member-access.m | 4 +- test/Index/complete-memfunc-cvquals.cpp | 40 +- test/Index/complete-method-decls.m | 163 +- test/Index/complete-objc-message-id.m | 30 +- test/Index/complete-objc-message.m | 113 +- test/Index/complete-preprocessor.m | 96 +- test/Index/complete-properties.m | 21 +- test/Index/complete-protocols.m | 4 +- test/Index/complete-recovery.m | 16 +- test/Index/complete-super.cpp | 10 +- test/Index/complete-super.m | 44 +- test/Index/complete-synthesized.m | 56 + test/Index/complete-templates.cpp | 2 +- test/Index/complete-type-factors.m | 146 +- test/Index/crash-recovery-code-complete.c | 3 +- test/Index/crash-recovery-reparse.c | 3 +- test/Index/fix-its.c | 18 + test/Index/get-cursor-includes.c | 7 + test/Index/get-cursor.cpp | 63 + test/Index/index-templates.cpp | 76 +- test/Index/load-decls.c | 1 - test/Index/load-exprs.c | 32 +- test/Index/load-namespaces.cpp | 2 +- test/Index/load-stmts.cpp | 99 +- test/Index/local-symbols.m | 2 +- test/Index/nested-binaryoperators.cpp | 1982 +++++++++++++++++ test/Index/overrides.cpp | 20 + test/Index/overrides.m | 35 + test/Index/preamble-reparse-chained.c | 10 + test/Index/preamble.c | 6 +- test/Index/print-display-names.cpp | 20 + test/Index/print-typekind.c | 10 +- test/Index/properties-class-extensions.m | 95 +- test/Index/recursive-cxx-member-calls.cpp | 2246 ++++++++++++++++++++ test/Index/recursive-member-access.c | 532 +++++ test/Index/remap-complete.c | 6 +- test/Index/remap-cursor-at.c | 1 - test/Index/remap-load.c | 4 - test/Index/retain-target-options.c | 8 + test/Index/usrs-cxx0x.cpp | 8 + test/Index/usrs.m | 154 +- test/Index/warning-flags.c | 16 + test/Lexer/11-27-2007-FloatLiterals.c | 2 + test/Lexer/c90.c | 5 + test/Lexer/char-escapes.c | 1 + test/Lexer/clang-keywords.cpp | 3 + test/Lexer/constants.c | 8 +- test/Lexer/cxx0x_keyword_as_cxx98.cpp | 3 +- test/Lexer/digraph.c | 2 +- test/Lexer/has_attribute.cpp | 12 + test/Lexer/has_feature_cxx0x.cpp | 58 +- test/Lexer/has_feature_type_traits.cpp | 91 + test/Lexer/ms-extensions.c | 1 + test/Lexer/pragma-message.c | 14 + test/Lexer/pragma-operators.cpp | 20 + test/Lexer/preamble.c | 1 - test/Lexer/rdar-8914293.c | 7 + test/Lexer/rdr-6096838-2.c | 2 +- test/Lexer/rdr-6096838.c | 4 +- test/Lexer/wchar.c | 12 + test/Makefile | 18 +- test/Misc/Inputs/working-directory.h | 1 + test/Misc/diag-aka-types.cpp | 8 +- test/Misc/predefines.c | 2 +- test/Misc/working-directory.c | 5 + test/PCH/Inputs/chain-cxx1.h | 19 - test/PCH/Inputs/chain-cxx2.h | 32 - test/PCH/Inputs/chain-macro-override1.h | 1 + test/PCH/Inputs/chain-macro-override2.h | 1 + test/PCH/Inputs/chain-remap-types1.h | 10 + test/PCH/Inputs/chain-remap-types2.h | 8 + test/PCH/Inputs/chain-selectors1.h | 4 + test/PCH/Inputs/chain-selectors2.h | 4 + test/PCH/Inputs/namespaces.h | 4 + test/PCH/Inputs/typo.h | 6 + test/PCH/Inputs/va_arg.h | 2 + test/PCH/attrs-PR8406.c | 23 + test/PCH/attrs.c | 15 +- test/PCH/attrs.h | 7 - test/PCH/chain-cxx.cpp | 80 +- test/PCH/chain-macro-override.c | 9 +- test/PCH/chain-macro.c | 4 +- test/PCH/chain-remap-types.m | 12 + test/PCH/chain-selectors.m | 16 + test/PCH/check-deserializations.cpp | 20 + test/PCH/cmdline-include.c | 6 + test/PCH/cmdline-include1.h | 1 + test/PCH/cmdline-include2.h | 1 + test/PCH/cuda-kernel-call.cu | 25 + test/PCH/cxx-templates.cpp | 22 +- test/PCH/cxx-templates.h | 58 + test/PCH/cxx-variadic-templates.cpp | 11 + test/PCH/cxx-variadic-templates.h | 18 + test/PCH/cxx_exprs.cpp | 6 +- test/PCH/headersearch.cpp | 44 + test/PCH/missing-file.cpp | 31 + test/PCH/namespaces.cpp | 3 + test/PCH/opencl-extensions.cl | 17 + test/PCH/pragma-diag-section.cpp | 26 + test/PCH/pragma-diag.c | 19 + test/PCH/rdar8852495.c | 25 + test/PCH/reinclude.cpp | 2 + test/PCH/reinclude1.h | 3 + test/PCH/reloc.c | 2 +- test/PCH/types.c | 3 +- test/PCH/typo.m | 6 + test/PCH/va_arg.cpp | 16 + test/Parser/MicrosoftExtensions.c | 28 +- test/Parser/MicrosoftExtensions.cpp | 113 + test/Parser/altivec.c | 10 + test/Parser/asm-constraints-pr7869.c | 2 +- test/Parser/cuda-kernel-call.cu | 9 + test/Parser/cxx-altivec.cpp | 43 +- test/Parser/cxx-class.cpp | 8 +- test/Parser/cxx-decl.cpp | 14 + test/Parser/cxx-in-c.c | 5 + test/Parser/cxx-reference.cpp | 2 +- test/Parser/cxx-stmt.cpp | 2 +- test/Parser/cxx-template-argument.cpp | 3 + test/Parser/cxx-template-decl.cpp | 4 +- test/Parser/cxx-throw.cpp | 2 +- test/Parser/cxx0x-attributes.cpp | 3 +- test/Parser/cxx0x-in-cxx98.cpp | 10 + test/Parser/cxx0x-override-control-keywords.cpp | 28 + test/Parser/encode.m | 4 +- test/Parser/expressions.c | 3 +- test/Parser/for.cpp | 20 + test/Parser/goto-ident.c | 6 - test/Parser/goto.c | 30 + test/Parser/missing-end-2.m | 19 + test/Parser/missing-end-3.m | 10 + test/Parser/objc-forcollection-neg-2.m | 2 +- test/Parser/objc-forcollection-neg.m | 1 + test/Parser/objc-foreach-syntax.m | 3 +- test/Parser/objc-interfaces.m | 2 +- test/Parser/objc-property-syntax.m | 7 +- test/Parser/objc-quirks.m | 8 +- test/Parser/opencl-kernel.cl | 9 + test/Parser/opencl-pragma.cl | 12 + test/Parser/opencl-storage-class.cl | 9 + test/Parser/placeholder-recovery.m | 12 + test/Parser/recovery.c | 6 + test/Parser/switch-recovery.cpp | 24 +- test/Preprocessor/assembler-with-cpp.c | 5 + test/Preprocessor/clang_headers.c | 2 +- test/Preprocessor/has_include.c | 32 +- test/Preprocessor/header_lookup1.c | 4 +- test/Preprocessor/include-directive2.c | 2 +- test/Preprocessor/init.c | 304 ++- test/Preprocessor/objc-pp.m | 2 +- test/Preprocessor/pragma-pushpop-macro.c | 8 + test/Preprocessor/pragma_diagnostic_sections.cpp | 80 + test/Preprocessor/pragma_unknown.c | 2 +- test/Preprocessor/predefined-macros.c | 12 + test/Preprocessor/print_line_empty_file.c | 12 + test/Preprocessor/pushable-diagnostics.c | 6 +- test/Preprocessor/stdint.c | 100 - test/Preprocessor/warn-macro-unused.c | 5 + test/Rewriter/blockstruct.m | 17 + test/Rewriter/dllimport-typedef.c | 2 +- test/Rewriter/finally.m | 2 +- test/Rewriter/properties.m | 7 +- test/Rewriter/property-dot-syntax.mm | 46 + test/Rewriter/rewrite-block-pointer.mm | 30 + test/Rewriter/rewrite-captured-nested-bvar.c | 35 + test/Rewriter/rewrite-nested-blocks-2.mm | 18 + test/Rewriter/rewrite-nested-property-in-blocks.mm | 52 + test/Rewriter/rewrite-property-set-cfstring.mm | 21 + test/Rewriter/rewrite-protocol-property.mm | 22 + test/Rewriter/rewrite-protocol-qualified.mm | 18 + test/Rewriter/rewrite-user-defined-accessors.mm | 30 + test/Sema/Inputs/conversion.h | 1 + test/Sema/MicrosoftExtensions.c | 69 + test/Sema/address_spaces.c | 8 +- test/Sema/altivec-init.c | 2 +- test/Sema/arm-neon-types.c | 13 + test/Sema/array-constraint.c | 4 +- test/Sema/asm.c | 28 +- test/Sema/attr-alias.c | 8 + test/Sema/attr-aligned.c | 23 +- test/Sema/attr-deprecated-message.c | 31 + test/Sema/attr-deprecated.c | 13 + test/Sema/attr-malloc.c | 5 +- test/Sema/attr-naked.c | 8 + test/Sema/attr-nodebug.c | 2 +- test/Sema/attr-noinline.c | 2 +- test/Sema/attr-unavailable-message.c | 18 + test/Sema/attr-unused.c | 22 +- test/Sema/attr-used.c | 2 +- test/Sema/attr-weak.c | 7 +- test/Sema/bitfield-promote-int-16bit.c | 25 - test/Sema/bitfield.c | 4 + test/Sema/block-args.c | 6 + test/Sema/block-call.c | 2 +- test/Sema/block-labels.c | 14 +- test/Sema/block-return.c | 11 +- test/Sema/builtin_objc_msgSend.c | 12 + test/Sema/builtins.c | 17 +- test/Sema/cast-to-union.c | 3 +- test/Sema/cast.c | 141 ++ test/Sema/compare.c | 24 + test/Sema/complex-int.c | 12 + test/Sema/compound-literal.c | 5 +- test/Sema/conditional-expr.c | 13 + test/Sema/const-eval.c | 8 +- test/Sema/const-ptr-int-ptr-cast.c | 2 +- test/Sema/constant-builtins-2.c | 4 + test/Sema/constant-conversion.c | 57 + test/Sema/constructor-attribute.c | 4 +- test/Sema/conversion.c | 45 +- test/Sema/designated-initializers.c | 28 + test/Sema/dllimport-dllexport.c | 8 +- test/Sema/enum.c | 15 + test/Sema/exprs.c | 16 + test/Sema/flexible-array-init.c | 26 +- test/Sema/format-strings.c | 41 +- test/Sema/i-c-e.c | 3 +- test/Sema/if-empty-body.c | 16 - test/Sema/implicit-builtin-decl.c | 7 +- test/Sema/init.c | 3 +- test/Sema/knr-def-call.c | 16 +- test/Sema/neon-vector-types.c | 33 + test/Sema/opencl-init.c | 15 - test/Sema/parentheses.c | 11 + test/Sema/pointer-addition.c | 1 + test/Sema/pragma-unused.c | 40 +- test/Sema/predef.c | 2 +- test/Sema/private-extern.c | 16 +- test/Sema/promote-int-16bit.c | 6 - test/Sema/rdr6094103-unordered-compare-promote.c | 2 +- test/Sema/redefinition.c | 4 + test/Sema/return.c | 15 +- test/Sema/scope-check.c | 35 +- test/Sema/self-comparison.c | 11 + test/Sema/sentinel-attribute.c | 2 +- test/Sema/shift.c | 2 +- test/Sema/short-enums.c | 5 + test/Sema/statements.c | 51 +- test/Sema/stdcall-fastcall.c | 12 +- test/Sema/struct-packed-align.c | 15 + test/Sema/switch.c | 2 +- test/Sema/transparent-union.c | 26 + test/Sema/typedef-retain.c | 12 - test/Sema/typeof-use-deprecated.c | 26 + test/Sema/uninit-variables.c | 262 +++ test/Sema/unused-expr.c | 5 +- test/Sema/varargs-x86-64.c | 2 +- test/Sema/vector-assign.c | 2 +- test/Sema/vector-init.c | 9 + test/Sema/warn-shadow.c | 11 + test/Sema/warn-unreachable.c | 24 +- test/Sema/warn-unused-function.c | 7 + test/Sema/warn-unused-label.c | 11 + test/Sema/warn-unused-value.c | 5 +- test/Sema/warn-write-strings.c | 2 +- test/Sema/x86-attr-force-align-arg-pointer.c | 2 +- test/Sema/x86-builtin-palignr.c | 14 +- test/SemaCUDA/config-type.cu | 3 + test/SemaCUDA/cuda.h | 19 + test/SemaCUDA/kernel-call.cu | 15 + test/SemaCUDA/qualifiers.cu | 8 + test/SemaCXX/MicrosoftExtensions.cpp | 69 +- test/SemaCXX/PR7944.cpp | 12 + test/SemaCXX/PR8012.cpp | 3 + test/SemaCXX/PR8755.cpp | 16 + test/SemaCXX/PR8884.cpp | 12 + test/SemaCXX/__null.cpp | 7 + test/SemaCXX/abstract.cpp | 26 +- .../addr-of-overloaded-function-casting.cpp | 57 + test/SemaCXX/addr-of-overloaded-function.cpp | 61 +- test/SemaCXX/address-of-temporary.cpp | 8 +- test/SemaCXX/alignof-sizeof-reference.cpp | 2 +- test/SemaCXX/altivec.cpp | 24 +- test/SemaCXX/ambig-user-defined-conversions.cpp | 10 +- test/SemaCXX/ambiguous-builtin-unary-operator.cpp | 4 +- test/SemaCXX/anonymous-union.cpp | 20 + test/SemaCXX/array-bounds.cpp | 93 + test/SemaCXX/arrow-operator.cpp | 13 + test/SemaCXX/attr-cxx0x.cpp | 24 +- test/SemaCXX/attr-deprecated.cpp | 43 + test/SemaCXX/attr-format.cpp | 29 +- test/SemaCXX/attr-nonnull.cpp | 29 + test/SemaCXX/attr-weak.cpp | 29 + test/SemaCXX/attr-weakref.cpp | 8 +- test/SemaCXX/block-call.cpp | 52 + test/SemaCXX/borland-extensions.cpp | 27 + test/SemaCXX/builtin-ptrtomember-ambig.cpp | 6 +- test/SemaCXX/builtin_objc_msgSend.cpp | 14 + test/SemaCXX/c99-variable-length-array.cpp | 7 + test/SemaCXX/c99.cpp | 8 +- test/SemaCXX/cast-conversion.cpp | 10 +- test/SemaCXX/class.cpp | 39 +- test/SemaCXX/compare.cpp | 6 + test/SemaCXX/composite-pointer-type.cpp | 4 +- test/SemaCXX/compound-literal.cpp | 14 + test/SemaCXX/condition.cpp | 9 + test/SemaCXX/conditional-expr.cpp | 25 +- test/SemaCXX/const-cast.cpp | 6 +- test/SemaCXX/constructor-initializer.cpp | 35 +- test/SemaCXX/constructor.cpp | 3 +- test/SemaCXX/conversion-function.cpp | 30 +- test/SemaCXX/conversion.cpp | 7 + test/SemaCXX/copy-assignment.cpp | 16 +- test/SemaCXX/copy-initialization.cpp | 10 +- test/SemaCXX/crash-8124080.cpp | 21 - test/SemaCXX/crash-PR7625.cpp | 6 - test/SemaCXX/crashes.cpp | 97 + test/SemaCXX/cstyle-cast.cpp | 2 +- test/SemaCXX/dcl_ambig_res.cpp | 3 + test/SemaCXX/dcl_init_aggr.cpp | 2 +- test/SemaCXX/decl-expr-ambiguity.cpp | 6 +- test/SemaCXX/decl-init-ref.cpp | 6 +- test/SemaCXX/decltype-overloaded-functions.cpp | 4 +- test/SemaCXX/default2.cpp | 3 + test/SemaCXX/delete.cpp | 9 + test/SemaCXX/deleted-function-extension.cpp | 8 + test/SemaCXX/dependent-auto.cpp | 34 + test/SemaCXX/destructor.cpp | 70 +- test/SemaCXX/direct-initializer.cpp | 2 +- test/SemaCXX/elaborated-type-specifier.cpp | 3 +- test/SemaCXX/enum-bitfield.cpp | 18 + test/SemaCXX/enum-scoped.cpp | 98 + test/SemaCXX/enum.cpp | 5 + test/SemaCXX/exceptions.cpp | 6 +- test/SemaCXX/expressions.cpp | 18 + test/SemaCXX/format-attribute.cpp | 8 - test/SemaCXX/friend.cpp | 68 + test/SemaCXX/functional-cast.cpp | 7 +- test/SemaCXX/gnu-case-ranges.cpp | 24 + test/SemaCXX/if-empty-body.cpp | 35 + test/SemaCXX/init-priority-attr.cpp | 6 +- test/SemaCXX/invalid-member-expr.cpp | 8 +- test/SemaCXX/issue547.cpp | 66 + test/SemaCXX/linkage-spec.cpp | 3 + test/SemaCXX/linkage.cpp | 68 + test/SemaCXX/lookup-member.cpp | 13 + test/SemaCXX/member-expr-anonymous-union.cpp | 2 +- test/SemaCXX/member-expr.cpp | 15 + test/SemaCXX/member-operator-expr.cpp | 4 +- test/SemaCXX/member-pointer.cpp | 5 +- test/SemaCXX/nested-name-spec.cpp | 19 + test/SemaCXX/new-delete.cpp | 41 +- test/SemaCXX/no-exceptions.cpp | 14 + test/SemaCXX/non-empty-class-size-zero.cpp | 18 + test/SemaCXX/nullptr-98.cpp | 3 + test/SemaCXX/nullptr.cpp | 47 +- test/SemaCXX/overload-call.cpp | 19 +- test/SemaCXX/overload-member-call.cpp | 12 +- test/SemaCXX/overloaded-builtin-operators-0x.cpp | 11 + test/SemaCXX/overloaded-builtin-operators.cpp | 37 + test/SemaCXX/overloaded-name.cpp | 14 + test/SemaCXX/overloaded-operator.cpp | 10 +- test/SemaCXX/pragma-pack.cpp | 34 + test/SemaCXX/pragma-unused.cpp | 8 + test/SemaCXX/ptrtomember-badcall.cpp | 13 - test/SemaCXX/ptrtomember.cpp | 32 + test/SemaCXX/qualified-id-lookup.cpp | 2 +- test/SemaCXX/redeclared-auto.cpp | 26 + test/SemaCXX/ref-init-ambiguous.cpp | 6 +- test/SemaCXX/references.cpp | 6 +- test/SemaCXX/reinterpret-cast.cpp | 12 +- test/SemaCXX/return-noreturn.cpp | 10 +- test/SemaCXX/return-stack-addr.cpp | 18 + test/SemaCXX/return.cpp | 2 +- test/SemaCXX/rval-references-examples.cpp | 112 + test/SemaCXX/rval-references-xfail.cpp | 14 - test/SemaCXX/rval-references.cpp | 10 +- test/SemaCXX/scope-check.cpp | 4 +- test/SemaCXX/sourceranges.cpp | 27 + test/SemaCXX/static-cast.cpp | 12 +- test/SemaCXX/trailing-return-0x.cpp | 61 + test/SemaCXX/type-convert-construct.cpp | 2 +- test/SemaCXX/type-dependent-exprs.cpp | 11 + test/SemaCXX/type-formatting.cpp | 10 + test/SemaCXX/type-traits-incomplete.cpp | 3 +- test/SemaCXX/type-traits.cpp | 166 +- test/SemaCXX/typeid-ref.cpp | 4 +- test/SemaCXX/undefined-internal.cpp | 86 + test/SemaCXX/uninit-variables.cpp | 51 + test/SemaCXX/uninitialized.cpp | 14 + test/SemaCXX/unreachable-catch-clauses.cpp | 2 +- test/SemaCXX/unreachable-code.cpp | 2 +- test/SemaCXX/unused-with-error.cpp | 8 + test/SemaCXX/using-decl-1.cpp | 23 + test/SemaCXX/using-decl-templates.cpp | 18 + test/SemaCXX/using-directive.cpp | 7 + test/SemaCXX/vector-casts.cpp | 6 +- test/SemaCXX/virtual-override.cpp | 20 +- test/SemaCXX/vtable-instantiation.cc | 20 + test/SemaCXX/warn-assignment-condition.cpp | 29 + test/SemaCXX/warn-enum-compare.cpp | 212 ++ test/SemaCXX/warn-global-constructors.cpp | 24 +- test/SemaCXX/warn-large-by-value-copy.cpp | 42 + test/SemaCXX/warn-literal-conversion.cpp | 41 + test/SemaCXX/warn-missing-noreturn.cpp | 55 +- test/SemaCXX/warn-overloaded-virtual.cpp | 54 + test/SemaCXX/warn-self-assign.cpp | 47 + test/SemaCXX/warn-shadow.cpp | 28 + test/SemaCXX/warn-unreachable.cpp | 8 +- test/SemaCXX/warn-unused-filescoped.cpp | 24 + test/SemaCXX/warn-unused-variables.cpp | 6 + test/SemaCXX/warn_false_to_pointer.cpp | 1 + test/SemaCXX/writable-strings-deprecated.cpp | 12 + test/SemaObjC/access-property-getter.m | 2 +- test/SemaObjC/attr-deprecated.m | 11 + test/SemaObjC/bad-receiver-1.m | 2 +- test/SemaObjC/block-attr.m | 2 + test/SemaObjC/block-return.m | 13 + test/SemaObjC/builtin_objc_lib_functions.m | 29 + test/SemaObjC/builtin_objc_msgSend.m | 3 + test/SemaObjC/call-super-2.m | 2 +- test/SemaObjC/category-1.m | 22 +- test/SemaObjC/class-conforming-protocol-2.m | 15 +- test/SemaObjC/class-method-lookup.m | 2 +- test/SemaObjC/compare-qualified-class.m | 2 +- test/SemaObjC/compare-qualified-id.m | 5 +- test/SemaObjC/comptypes-10.m | 34 + test/SemaObjC/comptypes-a.m | 7 +- test/SemaObjC/conditional-expr-4.m | 2 +- test/SemaObjC/conflict-nonfragile-abi2.m | 4 +- test/SemaObjC/continuation-class-err.m | 6 +- test/SemaObjC/crash-label.m | 2 +- test/SemaObjC/custom-atomic-property.m | 20 + test/SemaObjC/default-synthesize-1.m | 2 +- test/SemaObjC/default-synthesize.m | 4 +- test/SemaObjC/direct-synthesized-ivar-access.m | 14 + test/SemaObjC/duplicate-ivar-in-class-extension.m | 2 +- test/SemaObjC/duplicate-property-class-extension.m | 15 +- test/SemaObjC/error-missing-getter.m | 19 + test/SemaObjC/error-property-gc-attr.m | 4 +- test/SemaObjC/exprs.m | 10 + test/SemaObjC/format-arg-attribute.m | 6 +- test/SemaObjC/ibaction.m | 2 + test/SemaObjC/iboutletcollection-attr.m | 2 +- test/SemaObjC/incomplete-implementation.m | 26 + test/SemaObjC/ivar-in-class-extension-error.m | 2 +- test/SemaObjC/ivar-in-class-extension.m | 2 +- test/SemaObjC/ivar-in-implementations.m | 2 +- test/SemaObjC/method-arg-decay.m | 5 +- test/SemaObjC/method-arg-qualifier-warning.m | 4 +- test/SemaObjC/method-bad-param.m | 14 + test/SemaObjC/method-conflict-1.m | 83 + test/SemaObjC/method-conflict-2.m | 44 + test/SemaObjC/method-conflict.m | 6 +- test/SemaObjC/method-def-1.m | 2 +- test/SemaObjC/method-in-class-extension-impl.m | 20 + test/SemaObjC/method-lookup-5.m | 10 + test/SemaObjC/method-lookup.m | 2 +- test/SemaObjC/method-prototype-scope.m | 38 + test/SemaObjC/method-sentinel-attr.m | 4 +- test/SemaObjC/method-typecheck-3.m | 22 + test/SemaObjC/method-undef-category-warn-1.m | 12 +- test/SemaObjC/method-undef-extension-warn-1.m | 5 +- test/SemaObjC/method-undefined-warn-1.m | 14 + test/SemaObjC/no-objc-exceptions.m | 13 + test/SemaObjC/nonnull.h | 2 + test/SemaObjC/nonnull.m | 26 +- test/SemaObjC/property-9.m | 11 + test/SemaObjC/property-and-class-extension.m | 2 +- test/SemaObjC/property-and-ivar-use.m | 2 +- test/SemaObjC/property-dot-receiver.m | 22 + test/SemaObjC/property-impl-misuse.m | 20 + test/SemaObjC/property-in-class-extension.m | 37 +- test/SemaObjC/property-missing.m | 12 + test/SemaObjC/property-user-setter.m | 10 +- test/SemaObjC/provisional-ivar-lookup.m | 43 + test/SemaObjC/selector-1.m | 11 +- test/SemaObjC/selector-2.m | 14 + test/SemaObjC/selector-3.m | 29 + test/SemaObjC/self-assign.m | 14 + test/SemaObjC/setter-dotsyntax.m | 19 + test/SemaObjC/special-dep-unavail-warning.m | 47 + test/SemaObjC/super-class-protocol-conformance.m | 2 +- test/SemaObjC/super.m | 2 +- test/SemaObjC/synth-provisional-ivars-1.m | 28 + test/SemaObjC/synth-provisional-ivars.m | 4 +- test/SemaObjC/synthesized-ivar.m | 43 +- test/SemaObjC/undef-protocol-methods-1.m | 21 +- test/SemaObjC/undef-superclass-1.m | 2 +- test/SemaObjC/uninit-variables.m | 27 + test/SemaObjC/warn-deprecated-implementations.m | 45 + test/SemaObjC/warn-implicit-atomic-property.m | 13 + test/SemaObjC/warn-incompatible-builtin-types.m | 2 +- test/SemaObjC/warn-write-strings.m | 2 +- test/SemaObjCXX/blocks.mm | 72 +- test/SemaObjCXX/conversion-ranking.mm | 89 + test/SemaObjCXX/cstyle-cast.mm | 2 +- test/SemaObjCXX/exceptions-fragile.mm | 2 +- test/SemaObjCXX/message.mm | 35 +- test/SemaObjCXX/objc-pointer-conv.mm | 10 +- test/SemaObjCXX/overload.mm | 87 +- test/SemaObjCXX/propert-dot-error.mm | 41 + test/SemaObjCXX/properties.mm | 24 + test/SemaObjCXX/property-synthesis-error.mm | 32 + test/SemaObjCXX/protocol-lookup.mm | 5 + test/SemaObjCXX/reserved-keyword-methods.mm | 42 + test/SemaObjCXX/reserved-keyword-selectors.mm | 35 - test/SemaOpenCL/cond.cl | 5 + test/SemaOpenCL/extension-fp64.cl | 17 + test/SemaOpenCL/init.cl | 15 + test/SemaTemplate/anonymous-union.cpp | 21 + test/SemaTemplate/attributes.cpp | 2 +- test/SemaTemplate/class-template-decl.cpp | 18 + test/SemaTemplate/class-template-id.cpp | 2 +- test/SemaTemplate/class-template-spec.cpp | 2 +- test/SemaTemplate/constructor-template.cpp | 23 +- test/SemaTemplate/current-instantiation.cpp | 16 + test/SemaTemplate/deduction.cpp | 18 +- test/SemaTemplate/default-expr-arguments-2.cpp | 2 +- test/SemaTemplate/default-expr-arguments.cpp | 88 +- test/SemaTemplate/dependent-base-classes.cpp | 4 +- test/SemaTemplate/dependent-expr.cpp | 26 + test/SemaTemplate/dependent-names.cpp | 27 + test/SemaTemplate/elaborated-type-specifier.cpp | 4 + test/SemaTemplate/enum-forward.cpp | 8 + test/SemaTemplate/explicit-instantiation.cpp | 4 + .../explicit-specialization-member.cpp | 6 +- test/SemaTemplate/friend-template.cpp | 11 +- test/SemaTemplate/fun-template-def.cpp | 2 +- .../function-template-specialization.cpp | 5 + test/SemaTemplate/inject-templated-friend-post.cpp | 4 +- test/SemaTemplate/inject-templated-friend.cpp | 2 +- test/SemaTemplate/instantiate-anonymous-union.cpp | 21 + test/SemaTemplate/instantiate-cast.cpp | 8 +- test/SemaTemplate/instantiate-complete.cpp | 24 +- .../instantiate-default-assignment-operator.cpp | 2 +- test/SemaTemplate/instantiate-expr-4.cpp | 8 +- test/SemaTemplate/instantiate-field.cpp | 12 + test/SemaTemplate/instantiate-function-1.cpp | 2 +- test/SemaTemplate/instantiate-local-class.cpp | 15 + test/SemaTemplate/instantiate-member-expr.cpp | 25 +- test/SemaTemplate/instantiate-member-pointers.cpp | 2 +- test/SemaTemplate/instantiate-member-template.cpp | 12 + .../instantiate-non-type-template-parameter.cpp | 19 + test/SemaTemplate/instantiate-static-var.cpp | 4 +- .../instantiate-template-template-parm.cpp | 51 + test/SemaTemplate/instantiate-try-catch.cpp | 2 +- test/SemaTemplate/instantiate-using-decl.cpp | 19 + test/SemaTemplate/instantiation-default-1.cpp | 2 +- test/SemaTemplate/member-access-ambig.cpp | 35 + test/SemaTemplate/member-access-expr.cpp | 15 + test/SemaTemplate/temp_arg_nontype.cpp | 28 +- test/SemaTemplate/temp_class_spec_neg.cpp | 2 +- test/SemaTemplate/typename-specifier-4.cpp | 37 + test/SemaTemplate/variadic-class-template-1.cpp | 4 - test/SemaTemplate/variadic-class-template-2.cpp | 19 - test/SemaTemplate/variadic-parse.cpp | 6 - test/SemaTemplate/variadic-unsupported.cpp | 5 - test/Unit/lit.cfg | 86 + test/Unit/lit.site.cfg.in | 26 + test/lit.cfg | 20 +- test/lit.site.cfg.in | 1 + 1095 files changed, 34759 insertions(+), 3000 deletions(-) create mode 100644 test/ASTMerge/Inputs/class-template1.cpp create mode 100644 test/ASTMerge/Inputs/class-template2.cpp create mode 100644 test/ASTMerge/class-template.cpp create mode 100644 test/Analysis/analyzer-stats.c create mode 100644 test/Analysis/auto-obj-dtors-cfg-output.cpp create mode 100644 test/Analysis/base-init.cpp create mode 100644 test/Analysis/chroot.c create mode 100644 test/Analysis/cxx-crashes.cpp create mode 100644 test/Analysis/derived-to-base.cpp create mode 100644 test/Analysis/dtor.cpp create mode 100644 test/Analysis/dtors-in-dtor-cfg-output.cpp create mode 100644 test/Analysis/idempotent-operations-limited-loops.c create mode 100644 test/Analysis/idempotent-operations.m create mode 100644 test/Analysis/initializer.cpp create mode 100644 test/Analysis/initializers-cfg-output.cpp create mode 100644 test/Analysis/lvalue.cpp create mode 100644 test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m create mode 100644 test/Analysis/operator-calls.cpp create mode 100644 test/Analysis/out-of-bounds.c create mode 100644 test/Analysis/plist-output-alternate.m create mode 100644 test/Analysis/properties.m create mode 100644 test/Analysis/self-init.m create mode 100644 test/Analysis/temp-obj-dtors-cfg-output.cpp create mode 100644 test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp create mode 100644 test/CXX/basic/basic.start/basic.start.main/p2h.cpp create mode 100644 test/CXX/class.access/class.friend/p11.cpp create mode 100644 test/CXX/class.derived/class.member.lookup/p9.cpp create mode 100644 test/CXX/class.derived/class.virtual/p3-0x.cpp create mode 100644 test/CXX/class.derived/p8-0x.cpp create mode 100644 test/CXX/class/class.mem/p13.cpp create mode 100644 test/CXX/class/class.mem/p14.cpp create mode 100644 test/CXX/class/class.mem/p1b.cpp create mode 100644 test/CXX/class/class.mem/p8-0x-pedantic.cpp create mode 100644 test/CXX/class/class.mem/p8-0x.cpp create mode 100644 test/CXX/class/class.nest/p1-cxx0x.cpp create mode 100644 test/CXX/class/p1-0x.cpp create mode 100644 test/CXX/class/p2-0x.cpp create mode 100644 test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp create mode 100644 test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp create mode 100644 test/CXX/dcl.decl/p4-0x.cpp create mode 100644 test/CXX/expr/expr.cast/p4-0x.cpp create mode 100644 test/CXX/expr/expr.cast/p4.cpp create mode 100644 test/CXX/expr/expr.mptr.oper/p5.cpp create mode 100644 test/CXX/expr/expr.mptr.oper/p6-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp create mode 100644 test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp create mode 100644 test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp create mode 100644 test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp create mode 100644 test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp create mode 100644 test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h create mode 100644 test/CXX/expr/expr.unary/expr.unary.op/p6.cpp create mode 100644 test/CXX/over/over.built/p1.cpp create mode 100644 test/CXX/over/over.built/p25.cpp create mode 100644 test/CXX/over/over.load/p2-0x.cpp create mode 100644 test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp create mode 100644 test/CXX/over/over.match/over.match.funcs/p4-0x.cpp create mode 100644 test/CXX/over/over.over/p2-resolve-single-template-id.cpp create mode 100644 test/CXX/special/class.copy/p33-0x.cpp create mode 100644 test/CXX/special/class.ctor/p4-0x.cpp create mode 100644 test/CXX/special/class.dtor/p2-0x.cpp create mode 100644 test/CXX/special/class.inhctor/elsewhere.cpp create mode 100644 test/CXX/special/class.inhctor/p3.cpp create mode 100644 test/CXX/special/class.inhctor/p7.cpp create mode 100644 test/CXX/stmt.stmt/stmt.label/p1.cpp create mode 100644 test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp create mode 100644 test/CXX/temp/temp.arg/temp.arg.type/p2.cpp create mode 100644 test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp create mode 100644 test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp create mode 100644 test/CXX/temp/temp.decls/temp.class.spec/p9.cpp create mode 100644 test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp create mode 100644 test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp create mode 100644 test/CXX/temp/temp.decls/temp.friend/p8.cpp create mode 100644 test/CXX/temp/temp.decls/temp.mem/p3.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/deduction.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/example-function.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/p1.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/p2.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/p4.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/p5.cpp create mode 100644 test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp create mode 100644 test/CXX/temp/temp.param/p11-0x.cpp create mode 100644 test/CXX/temp/temp.param/p9-0x.cpp create mode 100644 test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp create mode 100644 test/CodeCompletion/stdin.c create mode 100644 test/CodeGen/arm-vector-arguments.c create mode 100644 test/CodeGen/asm-variable.c create mode 100644 test/CodeGen/attr-naked.c create mode 100644 test/CodeGen/blockwithlocalstatic.c create mode 100644 test/CodeGen/bool_test.c create mode 100644 test/CodeGen/char-literal.c create mode 100644 test/CodeGen/debug-info-line.c create mode 100644 test/CodeGen/debug-info-var-location.c create mode 100644 test/CodeGen/exceptions.c delete mode 100644 test/CodeGen/ext-vector-shuffle.c create mode 100644 test/CodeGen/imaginary.c create mode 100644 test/CodeGen/may-alias.c create mode 100644 test/CodeGen/mcount.c create mode 100644 test/CodeGen/mms-bitfields.c create mode 100644 test/CodeGen/mmx-builtins.c create mode 100644 test/CodeGen/mmx-shift-with-immediate.c create mode 100644 test/CodeGen/ms-anonymous-struct.c create mode 100644 test/CodeGen/mult-alt-generic.c create mode 100644 test/CodeGen/mult-alt-x86.c create mode 100644 test/CodeGen/pointer-signext.c create mode 100644 test/CodeGen/regparm-flag.c create mode 100644 test/CodeGen/string-literal-short-wstring.c create mode 100644 test/CodeGen/transparent-union.c create mode 100644 test/CodeGen/va_list_test.c create mode 100644 test/CodeGen/volatile-2.c create mode 100644 test/CodeGen/x86_32-arguments-darwin.c create mode 100644 test/CodeGen/x86_32-arguments-linux.c create mode 100644 test/CodeGen/x86_32-arguments-realign.c delete mode 100644 test/CodeGen/x86_32-arguments.c create mode 100644 test/CodeGenCXX/apple-kext-indirect-call-2.C create mode 100644 test/CodeGenCXX/apple-kext-indirect-call.C create mode 100644 test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp create mode 100644 test/CodeGenCXX/apple-kext-linkage.C create mode 100644 test/CodeGenCXX/apple-kext-no-staticinit-section.C create mode 100644 test/CodeGenCXX/asm.cpp create mode 100644 test/CodeGenCXX/attr-used.cpp create mode 100644 test/CodeGenCXX/block-byref-cxx-objc.cpp create mode 100644 test/CodeGenCXX/blocks.cpp create mode 100644 test/CodeGenCXX/builtins.cpp create mode 100644 test/CodeGenCXX/constructor-attr.cpp create mode 100644 test/CodeGenCXX/constructor-direct-call.cpp create mode 100644 test/CodeGenCXX/cxx-block-objects.cpp create mode 100644 test/CodeGenCXX/debug-info-ctor2.cpp create mode 100644 test/CodeGenCXX/debug-info-large-constant.cpp create mode 100644 test/CodeGenCXX/debug-info-member.cpp create mode 100644 test/CodeGenCXX/debug-info-method.cpp create mode 100644 test/CodeGenCXX/debug-info-namespace.cpp create mode 100644 test/CodeGenCXX/derived-to-virtual-base-class-calls-final.cpp create mode 100644 test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp create mode 100644 test/CodeGenCXX/friend-redecl.cpp create mode 100644 test/CodeGenCXX/gnu-conditional-scalar-ext.cpp create mode 100644 test/CodeGenCXX/goto.cpp create mode 100644 test/CodeGenCXX/mangle-abi-examples.cpp create mode 100644 test/CodeGenCXX/mangle-local-class-vtables.cpp create mode 100644 test/CodeGenCXX/mangle-local-classes-nested.cpp create mode 100644 test/CodeGenCXX/mangle-neon-vectors.cpp create mode 100644 test/CodeGenCXX/mangle-ref-qualifiers.cpp create mode 100644 test/CodeGenCXX/mangle-variadic-templates.cpp create mode 100644 test/CodeGenCXX/nrvo-noreturn.cc create mode 100644 test/CodeGenCXX/pr9130.cpp create mode 100644 test/CodeGenCXX/pragma-pack.cpp create mode 100644 test/CodeGenCXX/rtti-visibility.cpp create mode 100644 test/CodeGenCXX/rvalue-references.cpp create mode 100644 test/CodeGenCXX/specialized-static-data-mem-init.cpp create mode 100644 test/CodeGenCXX/stmtexpr.cpp create mode 100644 test/CodeGenCXX/template-dependent-bind-temporary.cpp create mode 100644 test/CodeGenCXX/template-inner-struct-visibility-hidden.cpp create mode 100644 test/CodeGenCXX/thunks-available-externally.cpp create mode 100644 test/CodeGenCXX/variadic-templates.cpp create mode 100644 test/CodeGenCXX/volatile-1.cpp create mode 100644 test/CodeGenCXX/vtable-available-externally.cpp create mode 100644 test/CodeGenCXX/vtable-debug-info.cpp create mode 100644 test/CodeGenCXX/warn-padded-packed.cpp create mode 100644 test/CodeGenObjC/arm-atomic-scalar-setter-getter.m create mode 100644 test/CodeGenObjC/bitfield-gnu.m create mode 100644 test/CodeGenObjC/block-6.m create mode 100644 test/CodeGenObjC/constant-string-class.m create mode 100644 test/CodeGenObjC/debug-info-default-synth-ivar.m create mode 100644 test/CodeGenObjC/debug-info-fnname.m create mode 100644 test/CodeGenObjC/debug-info-foreach.m create mode 100644 test/CodeGenObjC/debug-info-getter-name.m create mode 100644 test/CodeGenObjC/debug-info-selector.m create mode 100644 test/CodeGenObjC/debug-info-self.m create mode 100644 test/CodeGenObjC/debug-info-static-var.m delete mode 100644 test/CodeGenObjC/encode-test-1.m create mode 100644 test/CodeGenObjC/exceptions-nonfragile.m create mode 100644 test/CodeGenObjC/ivar-layout-array0-struct.m create mode 100644 test/CodeGenObjC/local-static-block.m create mode 100644 test/CodeGenObjC/property-ref-cast-to-void.m create mode 100644 test/CodeGenObjC/property-type-mismatch.m create mode 100644 test/CodeGenObjCXX/block-var-layout.mm create mode 100644 test/CodeGenObjCXX/blocks.mm create mode 100644 test/CodeGenObjCXX/property-dot-copy.mm create mode 100644 test/CodeGenObjCXX/property-dot-reference.mm create mode 100644 test/CodeGenObjCXX/property-object-conditional-exp.mm create mode 100644 test/CodeGenObjCXX/refence-assign-write-barrier.mm create mode 100644 test/CodeGenObjCXX/write-barrier-global-assign.mm create mode 100644 test/CodeGenOpenCL/ext-vector-shuffle.cl create mode 100644 test/CodeGenOpenCL/kernel-metadata.cl create mode 100644 test/CodeGenOpenCL/single-precision-constant.cl create mode 100644 test/Driver/apple-kext-mkernel.c create mode 100644 test/Driver/m_and_mm.c create mode 100644 test/Driver/sysroot-flags.c create mode 100644 test/FixIt/fixit-objc-message.m create mode 100644 test/Headers/arm-neon-header.c create mode 100644 test/Headers/stdbool.cpp create mode 100644 test/Index/Inputs/a.h create mode 100644 test/Index/Inputs/b.h create mode 100644 test/Index/Inputs/get-cursor-includes-1.h create mode 100644 test/Index/Inputs/get-cursor-includes-2.h create mode 100644 test/Index/annotate-tokens-cxx0x.cpp create mode 100644 test/Index/c-index-redecls.c create mode 100644 test/Index/cindex-on-invalid-usrs.m delete mode 100644 test/Index/code-complete-errors.c create mode 100644 test/Index/complete-driver-errors.c create mode 100644 test/Index/complete-exprs.cpp create mode 100644 test/Index/complete-exprs.m create mode 100644 test/Index/complete-kvc.m create mode 100644 test/Index/complete-synthesized.m create mode 100644 test/Index/fix-its.c create mode 100644 test/Index/get-cursor-includes.c create mode 100644 test/Index/get-cursor.cpp create mode 100644 test/Index/nested-binaryoperators.cpp create mode 100644 test/Index/overrides.cpp create mode 100644 test/Index/overrides.m create mode 100644 test/Index/preamble-reparse-chained.c create mode 100644 test/Index/print-display-names.cpp create mode 100644 test/Index/recursive-cxx-member-calls.cpp create mode 100644 test/Index/recursive-member-access.c create mode 100644 test/Index/retain-target-options.c create mode 100644 test/Index/usrs-cxx0x.cpp create mode 100644 test/Index/warning-flags.c create mode 100644 test/Lexer/clang-keywords.cpp create mode 100644 test/Lexer/has_attribute.cpp create mode 100644 test/Lexer/has_feature_type_traits.cpp create mode 100644 test/Lexer/pragma-message.c create mode 100644 test/Lexer/pragma-operators.cpp create mode 100644 test/Lexer/rdar-8914293.c create mode 100644 test/Lexer/wchar.c create mode 100644 test/Misc/Inputs/working-directory.h create mode 100644 test/Misc/working-directory.c delete mode 100644 test/PCH/Inputs/chain-cxx1.h delete mode 100644 test/PCH/Inputs/chain-cxx2.h create mode 100644 test/PCH/Inputs/chain-remap-types1.h create mode 100644 test/PCH/Inputs/chain-remap-types2.h create mode 100644 test/PCH/Inputs/typo.h create mode 100644 test/PCH/Inputs/va_arg.h create mode 100644 test/PCH/attrs-PR8406.c delete mode 100644 test/PCH/attrs.h create mode 100644 test/PCH/chain-remap-types.m create mode 100644 test/PCH/check-deserializations.cpp create mode 100644 test/PCH/cmdline-include.c create mode 100644 test/PCH/cmdline-include1.h create mode 100644 test/PCH/cmdline-include2.h create mode 100644 test/PCH/cuda-kernel-call.cu create mode 100644 test/PCH/cxx-variadic-templates.cpp create mode 100644 test/PCH/cxx-variadic-templates.h create mode 100644 test/PCH/headersearch.cpp create mode 100644 test/PCH/missing-file.cpp create mode 100644 test/PCH/opencl-extensions.cl create mode 100644 test/PCH/pragma-diag-section.cpp create mode 100644 test/PCH/pragma-diag.c create mode 100644 test/PCH/rdar8852495.c create mode 100644 test/PCH/typo.m create mode 100644 test/PCH/va_arg.cpp create mode 100644 test/Parser/MicrosoftExtensions.cpp create mode 100644 test/Parser/cuda-kernel-call.cu create mode 100644 test/Parser/cxx-in-c.c create mode 100644 test/Parser/cxx0x-in-cxx98.cpp create mode 100644 test/Parser/cxx0x-override-control-keywords.cpp create mode 100644 test/Parser/for.cpp delete mode 100644 test/Parser/goto-ident.c create mode 100644 test/Parser/goto.c create mode 100644 test/Parser/missing-end-2.m create mode 100644 test/Parser/missing-end-3.m create mode 100644 test/Parser/opencl-kernel.cl create mode 100644 test/Parser/opencl-pragma.cl create mode 100644 test/Parser/opencl-storage-class.cl create mode 100644 test/Parser/placeholder-recovery.m create mode 100644 test/Preprocessor/pragma_diagnostic_sections.cpp create mode 100644 test/Preprocessor/predefined-macros.c create mode 100644 test/Preprocessor/print_line_empty_file.c create mode 100644 test/Preprocessor/warn-macro-unused.c create mode 100644 test/Rewriter/blockstruct.m create mode 100644 test/Rewriter/property-dot-syntax.mm create mode 100644 test/Rewriter/rewrite-captured-nested-bvar.c create mode 100644 test/Rewriter/rewrite-nested-blocks-2.mm create mode 100755 test/Rewriter/rewrite-nested-property-in-blocks.mm create mode 100644 test/Rewriter/rewrite-property-set-cfstring.mm create mode 100644 test/Rewriter/rewrite-protocol-property.mm create mode 100644 test/Rewriter/rewrite-user-defined-accessors.mm create mode 100644 test/Sema/MicrosoftExtensions.c create mode 100644 test/Sema/arm-neon-types.c create mode 100644 test/Sema/attr-alias.c create mode 100644 test/Sema/attr-deprecated-message.c create mode 100644 test/Sema/attr-naked.c create mode 100644 test/Sema/attr-unavailable-message.c delete mode 100644 test/Sema/bitfield-promote-int-16bit.c create mode 100644 test/Sema/builtin_objc_msgSend.c create mode 100644 test/Sema/constant-conversion.c delete mode 100644 test/Sema/if-empty-body.c create mode 100644 test/Sema/neon-vector-types.c delete mode 100644 test/Sema/opencl-init.c delete mode 100644 test/Sema/promote-int-16bit.c create mode 100644 test/Sema/short-enums.c create mode 100644 test/Sema/typeof-use-deprecated.c create mode 100644 test/Sema/uninit-variables.c create mode 100644 test/Sema/warn-unused-label.c create mode 100644 test/SemaCUDA/config-type.cu create mode 100644 test/SemaCUDA/cuda.h create mode 100644 test/SemaCUDA/kernel-call.cu create mode 100644 test/SemaCUDA/qualifiers.cu create mode 100644 test/SemaCXX/PR7944.cpp create mode 100644 test/SemaCXX/PR8012.cpp create mode 100644 test/SemaCXX/PR8755.cpp create mode 100644 test/SemaCXX/PR8884.cpp create mode 100644 test/SemaCXX/addr-of-overloaded-function-casting.cpp create mode 100644 test/SemaCXX/array-bounds.cpp create mode 100644 test/SemaCXX/attr-nonnull.cpp create mode 100644 test/SemaCXX/attr-weak.cpp create mode 100644 test/SemaCXX/block-call.cpp create mode 100644 test/SemaCXX/builtin_objc_msgSend.cpp create mode 100644 test/SemaCXX/compound-literal.cpp delete mode 100644 test/SemaCXX/crash-8124080.cpp delete mode 100644 test/SemaCXX/crash-PR7625.cpp create mode 100644 test/SemaCXX/crashes.cpp create mode 100644 test/SemaCXX/delete.cpp create mode 100644 test/SemaCXX/deleted-function-extension.cpp create mode 100644 test/SemaCXX/dependent-auto.cpp create mode 100644 test/SemaCXX/enum-bitfield.cpp create mode 100644 test/SemaCXX/enum-scoped.cpp delete mode 100644 test/SemaCXX/format-attribute.cpp create mode 100644 test/SemaCXX/gnu-case-ranges.cpp create mode 100644 test/SemaCXX/if-empty-body.cpp create mode 100644 test/SemaCXX/issue547.cpp create mode 100644 test/SemaCXX/linkage.cpp create mode 100644 test/SemaCXX/lookup-member.cpp create mode 100644 test/SemaCXX/non-empty-class-size-zero.cpp create mode 100644 test/SemaCXX/nullptr-98.cpp create mode 100644 test/SemaCXX/overloaded-builtin-operators-0x.cpp create mode 100644 test/SemaCXX/overloaded-name.cpp create mode 100644 test/SemaCXX/pragma-pack.cpp create mode 100644 test/SemaCXX/pragma-unused.cpp delete mode 100644 test/SemaCXX/ptrtomember-badcall.cpp create mode 100644 test/SemaCXX/ptrtomember.cpp create mode 100644 test/SemaCXX/redeclared-auto.cpp create mode 100644 test/SemaCXX/rval-references-examples.cpp delete mode 100644 test/SemaCXX/rval-references-xfail.cpp create mode 100644 test/SemaCXX/sourceranges.cpp create mode 100644 test/SemaCXX/trailing-return-0x.cpp create mode 100644 test/SemaCXX/type-formatting.cpp create mode 100644 test/SemaCXX/undefined-internal.cpp create mode 100644 test/SemaCXX/uninit-variables.cpp create mode 100644 test/SemaCXX/uninitialized.cpp create mode 100644 test/SemaCXX/unused-with-error.cpp create mode 100644 test/SemaCXX/vtable-instantiation.cc create mode 100644 test/SemaCXX/warn-enum-compare.cpp create mode 100644 test/SemaCXX/warn-large-by-value-copy.cpp create mode 100644 test/SemaCXX/warn-literal-conversion.cpp create mode 100644 test/SemaCXX/warn-overloaded-virtual.cpp create mode 100644 test/SemaCXX/warn-self-assign.cpp create mode 100644 test/SemaCXX/writable-strings-deprecated.cpp create mode 100644 test/SemaObjC/block-return.m create mode 100644 test/SemaObjC/builtin_objc_lib_functions.m create mode 100644 test/SemaObjC/builtin_objc_msgSend.m create mode 100644 test/SemaObjC/comptypes-10.m create mode 100644 test/SemaObjC/custom-atomic-property.m create mode 100644 test/SemaObjC/direct-synthesized-ivar-access.m create mode 100644 test/SemaObjC/error-missing-getter.m create mode 100644 test/SemaObjC/incomplete-implementation.m create mode 100644 test/SemaObjC/method-conflict-1.m create mode 100644 test/SemaObjC/method-conflict-2.m create mode 100644 test/SemaObjC/method-in-class-extension-impl.m create mode 100644 test/SemaObjC/method-lookup-5.m create mode 100644 test/SemaObjC/method-prototype-scope.m create mode 100644 test/SemaObjC/method-typecheck-3.m create mode 100644 test/SemaObjC/no-objc-exceptions.m create mode 100644 test/SemaObjC/nonnull.h create mode 100644 test/SemaObjC/property-dot-receiver.m create mode 100644 test/SemaObjC/provisional-ivar-lookup.m create mode 100644 test/SemaObjC/selector-2.m create mode 100644 test/SemaObjC/selector-3.m create mode 100644 test/SemaObjC/self-assign.m create mode 100644 test/SemaObjC/setter-dotsyntax.m create mode 100644 test/SemaObjC/special-dep-unavail-warning.m create mode 100644 test/SemaObjC/synth-provisional-ivars-1.m create mode 100644 test/SemaObjC/uninit-variables.m create mode 100644 test/SemaObjC/warn-deprecated-implementations.m create mode 100644 test/SemaObjC/warn-implicit-atomic-property.m create mode 100644 test/SemaObjCXX/conversion-ranking.mm create mode 100644 test/SemaObjCXX/propert-dot-error.mm create mode 100644 test/SemaObjCXX/properties.mm create mode 100644 test/SemaObjCXX/property-synthesis-error.mm create mode 100644 test/SemaObjCXX/reserved-keyword-methods.mm delete mode 100644 test/SemaObjCXX/reserved-keyword-selectors.mm create mode 100644 test/SemaOpenCL/cond.cl create mode 100644 test/SemaOpenCL/extension-fp64.cl create mode 100644 test/SemaOpenCL/init.cl create mode 100644 test/SemaTemplate/enum-forward.cpp create mode 100644 test/SemaTemplate/member-access-ambig.cpp delete mode 100644 test/SemaTemplate/variadic-class-template-1.cpp delete mode 100644 test/SemaTemplate/variadic-class-template-2.cpp delete mode 100644 test/SemaTemplate/variadic-parse.cpp delete mode 100644 test/SemaTemplate/variadic-unsupported.cpp create mode 100644 test/Unit/lit.cfg create mode 100644 test/Unit/lit.site.cfg.in (limited to 'test') diff --git a/test/ASTMerge/Inputs/category1.m b/test/ASTMerge/Inputs/category1.m index ade1c6c..afcaab8 100644 --- a/test/ASTMerge/Inputs/category1.m +++ b/test/ASTMerge/Inputs/category1.m @@ -23,3 +23,26 @@ @interface I2 () - (int)method3; @end + +// Category with implementation +@interface I2 (Cat3) +@end + +@implementation I2 (Cat3) +@end + +// Category with implementation +@interface I2 (Cat4) +@end + +@implementation I2 (Cat4) +@end + +// Category with mismatched implementation +@interface I2 (Cat6) +@end + +@implementation I2 (Cat6) +- (float)blah { return 0; } +@end + diff --git a/test/ASTMerge/Inputs/category2.m b/test/ASTMerge/Inputs/category2.m index f66c208..49a3c27 100644 --- a/test/ASTMerge/Inputs/category2.m +++ b/test/ASTMerge/Inputs/category2.m @@ -25,3 +25,25 @@ typedef int Int; @interface I2 () - (float)method3; @end + +// Category with implementation +@interface I2 (Cat3) +@end + +@implementation I2 (Cat3) +@end + +// Category with implementation +@interface I2 (Cat5) +@end + +@implementation I2 (Cat5) +@end + +// Category with mismatched implementation +@interface I2 (Cat6) +@end + +@implementation I2 (Cat6) +- (int)blah { return 0; } +@end diff --git a/test/ASTMerge/Inputs/class-template1.cpp b/test/ASTMerge/Inputs/class-template1.cpp new file mode 100644 index 0000000..440b5abf --- /dev/null +++ b/test/ASTMerge/Inputs/class-template1.cpp @@ -0,0 +1,34 @@ +template +struct X0; + +template +struct X1; + +template +struct X2; + +template +struct X3; + +template class> +struct X4; + +template class> +struct X5; + +template +struct X6; + +extern X0 *x0i; +extern X0 *x0l; +extern X0 *x0r; + +template<> +struct X0 { + int member; +}; + +template<> +struct X0 { + int member; +}; diff --git a/test/ASTMerge/Inputs/class-template2.cpp b/test/ASTMerge/Inputs/class-template2.cpp new file mode 100644 index 0000000..6300301 --- /dev/null +++ b/test/ASTMerge/Inputs/class-template2.cpp @@ -0,0 +1,35 @@ +template +struct X0; + +template +struct X1; + +template +struct X2; + +template +struct X3; + +template class> +struct X4; + +template class> +struct X5; + +template class> +struct X6; + +typedef int Integer; +extern X0 *x0i; +extern X0 *x0f; +extern X0 *x0r; + +template<> +struct X0 { + int member; +}; + +template<> +struct X0 { + float member; +}; diff --git a/test/ASTMerge/Inputs/class1.cpp b/test/ASTMerge/Inputs/class1.cpp index e13faf0..b600cdb 100644 --- a/test/ASTMerge/Inputs/class1.cpp +++ b/test/ASTMerge/Inputs/class1.cpp @@ -6,3 +6,10 @@ struct B : A { float y; float foo(); }; + +struct C { + C(int i = 10); + C(const C&); + C &operator=(C&); + ~C(); +}; diff --git a/test/ASTMerge/Inputs/class2.cpp b/test/ASTMerge/Inputs/class2.cpp index 91b84dc..fa38916 100644 --- a/test/ASTMerge/Inputs/class2.cpp +++ b/test/ASTMerge/Inputs/class2.cpp @@ -6,3 +6,4 @@ struct B : A { int y; int foo(); }; + diff --git a/test/ASTMerge/Inputs/interface1.m b/test/ASTMerge/Inputs/interface1.m index 7e9935d..5865c0e 100644 --- a/test/ASTMerge/Inputs/interface1.m +++ b/test/ASTMerge/Inputs/interface1.m @@ -79,3 +79,25 @@ @protocol P4 - (double)honk:(int)a; @end + +// Interface with implementation +@interface I13 +@end + +@implementation I13 +@end + +@interface I13a +@end + +@implementation I13a +@end + +// Implementation by itself +@implementation I14 : I12 +@end + +@implementation I15 : I12 +@end + + diff --git a/test/ASTMerge/Inputs/interface2.m b/test/ASTMerge/Inputs/interface2.m index bef7fb8..3fb43f5 100644 --- a/test/ASTMerge/Inputs/interface2.m +++ b/test/ASTMerge/Inputs/interface2.m @@ -78,3 +78,23 @@ @protocol P5 - (double)honk:(int)a; @end + +// Interface with implementation +@interface I13 +@end + +@implementation I13 +@end + +@interface I13b +@end + +@implementation I13b +@end + +// Implementation by itself +@implementation I14 : I12 +@end + +@implementation I15 : I11 +@end diff --git a/test/ASTMerge/Inputs/property1.m b/test/ASTMerge/Inputs/property1.m index 37887a3..22fe0a0 100644 --- a/test/ASTMerge/Inputs/property1.m +++ b/test/ASTMerge/Inputs/property1.m @@ -10,3 +10,22 @@ @property (readonly) float Prop1; @end +// Properties with implementations +@interface I3 { + int ivar1; + int ivar2; + int ivar3; + int Prop4; +} +@property int Prop1; +@property int Prop2; +@property int Prop3; +@property int Prop4; +@end + +@implementation I3 +@synthesize Prop1 = ivar1; +@synthesize Prop2 = ivar3; +@dynamic Prop3; +@synthesize Prop4; +@end diff --git a/test/ASTMerge/Inputs/property2.m b/test/ASTMerge/Inputs/property2.m index 6039f10..64a03fb 100644 --- a/test/ASTMerge/Inputs/property2.m +++ b/test/ASTMerge/Inputs/property2.m @@ -11,3 +11,23 @@ @interface I2 @property (readonly) int Prop1; @end + +// Properties with implementations +@interface I3 { + int ivar1; + int ivar2; + int ivar3; + int Prop4; +} +@property int Prop1; +@property int Prop2; +@property int Prop3; +@property int Prop4; +@end + +@implementation I3 +@synthesize Prop2 = ivar2; +@synthesize Prop1 = ivar1; +@synthesize Prop3 = ivar3; +@synthesize Prop4 = Prop4; +@end diff --git a/test/ASTMerge/category.m b/test/ASTMerge/category.m index 6ba2292..54a1240 100644 --- a/test/ASTMerge/category.m +++ b/test/ASTMerge/category.m @@ -6,4 +6,6 @@ // CHECK: category1.m:16:1: note: instance method 'method2' also declared here // CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int') // CHECK: category1.m:24:1: note: instance method 'method3' also declared here -// CHECK: 2 errors generated. +// CHECK: category2.m:48:1: error: instance method 'blah' has incompatible result types in different translation units ('int' vs. 'float') +// CHECK: category1.m:46:1: note: instance method 'blah' also declared here +// CHECK: 3 errors generated. diff --git a/test/ASTMerge/class-template.cpp b/test/ASTMerge/class-template.cpp new file mode 100644 index 0000000..eea31b1 --- /dev/null +++ b/test/ASTMerge/class-template.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class-template1.cpp +// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class-template2.cpp +// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s + +// CHECK: class-template1.cpp:7:14: error: non-type template parameter declared with incompatible types in different translation units ('int' vs. 'long') +// CHECK: class-template2.cpp:7:15: note: declared here with type 'long' + +// CHECK: class-template1.cpp:10:14: error: template parameter has different kinds in different translation units +// CHECK: class-template2.cpp:10:10: note: template parameter declared here + +// CHECK: class-template1.cpp:16:23: error: non-type template parameter declared with incompatible types in different translation units ('long' vs. 'int') +// CHECK: class-template2.cpp:16:23: note: declared here with type 'int' + +// CHECK: class-template1.cpp:19:10: error: template parameter has different kinds in different translation units +// CHECK: class-template2.cpp:19:10: note: template parameter declared here + +// CHECK: class-template2.cpp:25:20: error: external variable 'x0r' declared with incompatible types in different translation units ('X0 *' vs. 'X0 *') +// CHECK: class-template1.cpp:24:19: note: declared here with type 'X0 *' + +// CHECK: class-template1.cpp:32:8: warning: type 'X0' has incompatible definitions in different translation units +// CHECK: class-template1.cpp:33:7: note: field 'member' has type 'int' here +// CHECK: class-template2.cpp:34:9: note: field 'member' has type 'float' here + +// CHECK: 1 warning and 5 errors generated. diff --git a/test/ASTMerge/interface.m b/test/ASTMerge/interface.m index 420ae38..e37e380 100644 --- a/test/ASTMerge/interface.m +++ b/test/ASTMerge/interface.m @@ -15,5 +15,8 @@ // CHECK: interface1.m:46:1: note: class method 'bar:' also declared here // CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float') // CHECK: interface1.m:58:19: note: declared here with type 'float' -// CHECK: 6 errors generated +// CHECK: interface1.m:100:1: error: class 'I15' has incompatible superclasses +// CHECK: interface1.m:100:1: note: inherits from superclass 'I12' here +// CHECK: interface2.m:99:1: note: inherits from superclass 'I11' here +// CHECK: 8 errors generated diff --git a/test/ASTMerge/property.m b/test/ASTMerge/property.m index 5f7a730..a8dd7c4 100644 --- a/test/ASTMerge/property.m +++ b/test/ASTMerge/property.m @@ -6,4 +6,8 @@ // CHECK: property1.m:10:28: note: declared here with type 'float' // CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float') // CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here -// CHECK: 2 errors generated. +// CHECK: property1.m:28:21: error: property 'Prop2' is synthesized to different ivars in different translation units ('ivar3' vs. 'ivar2') +// CHECK: property2.m:29:21: note: property is synthesized to ivar 'ivar2' here +// CHECK: property1.m:29:10: error: property 'Prop3' is implemented with @dynamic in one translation but @synthesize in another translation unit +// CHECK: property2.m:31:13: note: property 'Prop3' is implemented with @synthesize here +// CHECK: 4 errors generated. diff --git a/test/Analysis/CFNumber.c b/test/Analysis/CFNumber.c index 544644a..4725f90 100644 --- a/test/Analysis/CFNumber.c +++ b/test/Analysis/CFNumber.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s typedef signed long CFIndex; typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/MissingDealloc.m b/test/Analysis/MissingDealloc.m index bfd968a..d7aaa99 100644 --- a/test/Analysis/MissingDealloc.m +++ b/test/Analysis/MissingDealloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-missing-dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.experimental.Dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m index fa81b3d..c5f7a45 100644 --- a/test/Analysis/NSString.m +++ b/test/Analysis/NSString.m @@ -1,13 +1,13 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s -// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s // ==-- FIXME: -analyzer-store=basic fails on this file (false negatives). --== -// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s && -// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s && -// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s && -// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s +// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s && +// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s && +// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s && +// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/NSWindow.m b/test/Analysis/NSWindow.m index 34e6c68..c386adf 100644 --- a/test/Analysis/NSWindow.m +++ b/test/Analysis/NSWindow.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=basic -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=basic -analyzer-constraints=range -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=basic -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=basic -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=region -analyzer-constraints=range -verify %s // These declarations were reduced using Delta-Debugging from Foundation.h // on Mac OS X. The test cases are below. diff --git a/test/Analysis/ObjCRetSigs.m b/test/Analysis/ObjCRetSigs.m index a76d7b9..5a912a8 100644 --- a/test/Analysis/ObjCRetSigs.m +++ b/test/Analysis/ObjCRetSigs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-methodsigs -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.MethodSigs -verify %s int printf(const char *, ...); diff --git a/test/Analysis/PR2978.m b/test/Analysis/PR2978.m index 1ed138e..ac3ef79 100644 --- a/test/Analysis/PR2978.m +++ b/test/Analysis/PR2978.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-missing-dealloc %s -verify +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.experimental.Dealloc %s -verify // Tests for the checker which checks missing/extra ivar 'release' calls // in dealloc. diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c index e4a5651..096ffb9 100644 --- a/test/Analysis/additive-folding.c +++ b/test/Analysis/additive-folding.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -verify -analyzer-constraints=basic %s -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -verify -analyzer-constraints=range %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-checker=core.experimental.UnreachableCode -verify -analyzer-constraints=basic %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-checker=core.experimental.UnreachableCode -verify -analyzer-constraints=range %s // These are used to trigger warnings. typedef typeof(sizeof(int)) size_t; @@ -183,14 +183,14 @@ void tautologyGT (unsigned a) { void tautologyGE (unsigned a) { char* b = malloc(1); - if (a >= 0) + if (a >= 0) // expected-warning{{always true}} free(b); return; // no-warning } void tautologyLT (unsigned a) { char* b = malloc(1); - if (a < 0) + if (a < 0) // expected-warning{{always false}} return; // expected-warning{{never executed}} free(b); } diff --git a/test/Analysis/analyzer-stats.c b/test/Analysis/analyzer-stats.c new file mode 100644 index 0000000..d8dde23 --- /dev/null +++ b/test/Analysis/analyzer-stats.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks -analyzer-stats %s + +int foo(); + +int test() { // expected-warning{{Total CFGBlocks}} + int a = 1; + a = 34 / 12; + + if (foo()) + return a; + + a /= 4; + return a; +} diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c index dabd25b..8162200 100644 --- a/test/Analysis/array-struct-region.c +++ b/test/Analysis/array-struct-region.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s int string_literal_init() { char a[] = "abc"; diff --git a/test/Analysis/array-struct.c b/test/Analysis/array-struct.c index 3e46a0a..df9e978 100644 --- a/test/Analysis/array-struct.c +++ b/test/Analysis/array-struct.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CastToStruct -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CastToStruct -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CastToStruct -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CastToStruct -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s struct s { int data; diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp new file mode 100644 index 0000000..4bcfccd --- /dev/null +++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp @@ -0,0 +1,835 @@ +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s +// XPASS: * + +class A { +public: + A() {} + ~A() {} + operator int() const { return 1; } +}; + +extern const bool UV; + +void test_const_ref() { + A a; + const A& b = a; + const A& c = A(); +} + +void test_array() { + A a[2]; + A b[0]; +} + +void test_scope() { + A a; + { A c; + A d; + } + A b; +} + +void test_return() { + A a; + A b; + if (UV) return; + A c; +} + +void test_goto() { + A a; +l0: + A b; + { A a; + if (UV) goto l0; + if (UV) goto l1; + A b; + } +l1: + A c; +} + +void test_if_implicit_scope() { + A a; + if (A b = a) + A c; + else A c; +} + +void test_if_jumps() { + A a; + if (A b = a) { + A c; + if (UV) return; + A d; + } else { + A c; + if (UV) return; + A d; + } + A e; +} + +void test_while_implicit_scope() { + A a; + while (A b = a) + A c; +} + +void test_while_jumps() { + A a; + while (A b = a) { + A c; + if (UV) break; + if (UV) continue; + if (UV) return; + A d; + } + A e; +} + +void test_do_implicit_scope() { + do A a; + while (UV); +} + +void test_do_jumps() { + A a; + do { + A b; + if (UV) break; + if (UV) continue; + if (UV) return; + A c; + } while (UV); + A d; +} + +void test_switch_implicit_scope() { + A a; + switch (A b = a) + A c; +} + +void test_switch_jumps() { + A a; + switch (A b = a) { + case 0: { + A c; + if (UV) break; + if (UV) return; + A f; + } + case 1: + break; + } + A g; +} + +void test_for_implicit_scope() { + for (A a; A b = a; ) + A c; +} + +void test_for_jumps() { + A a; + for (A b; A c = b; ) { + A d; + if (UV) break; + if (UV) continue; + if (UV) return; + A e; + } + A f; +} + +void test_catch_const_ref() { + try { + } catch (const A& e) { + } +} + +void test_catch_copy() { + try { + } catch (A e) { + } +} + +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: const A &b = a; +// CHECK: 4: A() +// CHECK: 5: const A &c = A(); +// CHECK: 6: [B1.5].~A() (Implicit destructor) +// CHECK: 7: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A a[2]; +// CHECK: 3: +// CHECK: 4: A b[0]; +// CHECK: 5: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: +// CHECK: 4: A c; +// CHECK: 5: +// CHECK: 6: A d; +// CHECK: 7: [B1.6].~A() (Implicit destructor) +// CHECK: 8: [B1.4].~A() (Implicit destructor) +// CHECK: 9: +// CHECK: 10: A b; +// CHECK: 11: [B1.10].~A() (Implicit destructor) +// CHECK: 12: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B4 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B3 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B1.2].~A() (Implicit destructor) +// CHECK: 4: [B3.4].~A() (Implicit destructor) +// CHECK: 5: [B3.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: return; +// CHECK: 2: [B3.4].~A() (Implicit destructor) +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B3 +// CHECK: Successors (1): B0 +// CHECK: [ B3 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: +// CHECK: 4: A b; +// CHECK: 5: UV +// CHECK: T: if [B3.5] +// CHECK: Predecessors (1): B4 +// CHECK: Successors (2): B2 B1 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (2): B1 B2 +// CHECK: Successors (0): +// CHECK: [ B8 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B7 +// CHECK: [ B1 ] +// CHECK: l1: +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B1.2].~A() (Implicit destructor) +// CHECK: 4: [B6.2].~A() (Implicit destructor) +// CHECK: 5: [B7.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A b; +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: 4: [B6.4].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: [B6.4].~A() (Implicit destructor) +// CHECK: T: goto l1; +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: UV +// CHECK: T: if [B4.1] +// CHECK: Predecessors (1): B6 +// CHECK: Successors (2): B3 B2 +// CHECK: [ B5 ] +// CHECK: 1: [B6.4].~A() (Implicit destructor) +// CHECK: 2: [B6.2].~A() (Implicit destructor) +// CHECK: T: goto l0; +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B6 +// CHECK: [ B6 ] +// CHECK: l0: +// CHECK: 1: +// CHECK: 2: A b; +// CHECK: 3: +// CHECK: 4: A a; +// CHECK: 5: UV +// CHECK: T: if [B6.5] +// CHECK: Predecessors (2): B7 B5 +// CHECK: Successors (2): B5 B4 +// CHECK: [ B7 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B6 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B5 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B4 +// CHECK: [ B1 ] +// CHECK: 1: [B4.4].~A() (Implicit destructor) +// CHECK: 2: [B4.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: a +// CHECK: 4: if ([B4.6]) +// CHECK:[B3.2]else +// CHECK:[B2.2] 5: b.operator int() +// CHECK: 6: [B4.5] +// CHECK: T: if [B4.6] +// CHECK: Predecessors (1): B5 +// CHECK: Successors (2): B3 B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B9 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B8 +// CHECK: [ B1 ] +// CHECK: 1: [B8.4].~A() (Implicit destructor) +// CHECK: 2: +// CHECK: 3: A e; +// CHECK: 4: [B1.3].~A() (Implicit destructor) +// CHECK: 5: [B8.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B5 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A d; +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: 4: [B4.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: return; +// CHECK: 2: [B4.2].~A() (Implicit destructor) +// CHECK: 3: [B8.4].~A() (Implicit destructor) +// CHECK: 4: [B8.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B0 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: UV +// CHECK: T: if [B4.3] +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B3 B2 +// CHECK: [ B5 ] +// CHECK: 1: +// CHECK: 2: A d; +// CHECK: 3: [B5.2].~A() (Implicit destructor) +// CHECK: 4: [B7.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B1 +// CHECK: [ B6 ] +// CHECK: 1: return; +// CHECK: 2: [B7.2].~A() (Implicit destructor) +// CHECK: 3: [B8.4].~A() (Implicit destructor) +// CHECK: 4: [B8.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B0 +// CHECK: [ B7 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: UV +// CHECK: T: if [B7.3] +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B6 B5 +// CHECK: [ B8 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: a +// CHECK: 4: if ([B8.6]) { +// CHECK:[B7.2] if ([B7.3]) +// CHECK:[B6.1][B5.2]} else { +// CHECK:[B4.2] if ([B4.3]) +// CHECK:[B3.1][B2.2]} +// CHECK: 5: b.operator int() +// CHECK: 6: [B8.5] +// CHECK: T: if [B8.6] +// CHECK: Predecessors (1): B9 +// CHECK: Successors (2): B7 B4 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (3): B1 B3 B6 +// CHECK: Successors (0): +// CHECK: [ B6 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B5 +// CHECK: [ B1 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: 2: [B5.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: a +// CHECK: 2: while ([B2.4]) +// CHECK:[B4.2] 3: b.operator int() +// CHECK: 4: [B2.3] +// CHECK: T: while [B2.4] +// CHECK: Predecessors (2): B3 B5 +// CHECK: Successors (2): B4 B1 +// CHECK: [ B3 ] +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B2 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: 4: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B3 +// CHECK: [ B5 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B12 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B11 +// CHECK: [ B1 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: 2: +// CHECK: 3: A e; +// CHECK: 4: [B1.3].~A() (Implicit destructor) +// CHECK: 5: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B9 B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: a +// CHECK: 2: while ([B2.4]) +// CHECK: { +// CHECK:[B10.2] if ([B10.3]) +// CHECK: break; +// CHECK: if ([B8.1]) +// CHECK: continue; +// CHECK: if ([B6.1]) +// CHECK:[B5.1][B4.2] } +// CHECK: 3: b.operator int() +// CHECK: 4: [B2.3] +// CHECK: T: while [B2.4] +// CHECK: Predecessors (2): B3 B11 +// CHECK: Successors (2): B10 B1 +// CHECK: [ B3 ] +// CHECK: Predecessors (2): B4 B7 +// CHECK: Successors (1): B2 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A d; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: 4: [B10.2].~A() (Implicit destructor) +// CHECK: 5: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B3 +// CHECK: [ B5 ] +// CHECK: 1: return; +// CHECK: 2: [B10.2].~A() (Implicit destructor) +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: 4: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B0 +// CHECK: [ B6 ] +// CHECK: 1: UV +// CHECK: T: if [B6.1] +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B5 B4 +// CHECK: [ B7 ] +// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: 2: [B2.2].~A() (Implicit destructor) +// CHECK: T: continue; +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B3 +// CHECK: [ B8 ] +// CHECK: 1: UV +// CHECK: T: if [B8.1] +// CHECK: Predecessors (1): B10 +// CHECK: Successors (2): B7 B6 +// CHECK: [ B9 ] +// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: T: break; +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B1 +// CHECK: [ B10 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: UV +// CHECK: T: if [B10.3] +// CHECK: Predecessors (1): B2 +// CHECK: Successors (2): B9 B8 +// CHECK: [ B11 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: Predecessors (1): B12 +// CHECK: Successors (1): B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (2): B1 B5 +// CHECK: Successors (0): +// CHECK: [ B4 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B2 +// CHECK: [ B1 ] +// CHECK: 1: UV +// CHECK: T: do ... while [B1.1] +// CHECK: Predecessors (1): B2 +// CHECK: Successors (2): B3 B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B3 B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (1): B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B12 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B11 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A d; +// CHECK: 3: [B1.2].~A() (Implicit destructor) +// CHECK: 4: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B8 B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: UV +// CHECK: T: do ... while [B2.1] +// CHECK: Predecessors (2): B3 B6 +// CHECK: Successors (2): B10 B1 +// CHECK: [ B3 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B9.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B5 +// CHECK: Successors (1): B2 +// CHECK: [ B4 ] +// CHECK: 1: return; +// CHECK: 2: [B9.2].~A() (Implicit destructor) +// CHECK: 3: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B5 +// CHECK: Successors (1): B0 +// CHECK: [ B5 ] +// CHECK: 1: UV +// CHECK: T: if [B5.1] +// CHECK: Predecessors (1): B7 +// CHECK: Successors (2): B4 B3 +// CHECK: [ B6 ] +// CHECK: 1: [B9.2].~A() (Implicit destructor) +// CHECK: T: continue; +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B2 +// CHECK: [ B7 ] +// CHECK: 1: UV +// CHECK: T: if [B7.1] +// CHECK: Predecessors (1): B9 +// CHECK: Successors (2): B6 B5 +// CHECK: [ B8 ] +// CHECK: 1: [B9.2].~A() (Implicit destructor) +// CHECK: T: break; +// CHECK: Predecessors (1): B9 +// CHECK: Successors (1): B1 +// CHECK: [ B9 ] +// CHECK: 1: +// CHECK: 2: A b; +// CHECK: 3: UV +// CHECK: T: if [B9.3] +// CHECK: Predecessors (2): B10 B11 +// CHECK: Successors (2): B8 B7 +// CHECK: [ B10 ] +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B9 +// CHECK: [ B11 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: Predecessors (1): B12 +// CHECK: Successors (1): B9 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (2): B1 B4 +// CHECK: Successors (0): +// CHECK: [ B4 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B2 +// CHECK: [ B1 ] +// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B3 B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: a +// CHECK: 4: switch ([B2.5]) +// CHECK:[B3.2] 5: b.operator int() +// CHECK: T: switch [B2.5] +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B9 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B2 +// CHECK: [ B1 ] +// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 2: +// CHECK: 3: A g; +// CHECK: 4: [B1.3].~A() (Implicit destructor) +// CHECK: 5: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (3): B3 B7 B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: a +// CHECK: 4: switch ([B2.5]) { +// CHECK: case 0: +// CHECK: { +// CHECK:[B8.2] if ([B8.3]) +// CHECK: break; +// CHECK: if ([B6.1]) +// CHECK:[B5.1][B4.2] } +// CHECK: case 1: +// CHECK: break; +// CHECK:} +// CHECK: 5: b.operator int() +// CHECK: T: switch [B2.5] +// CHECK: Predecessors (1): B9 +// CHECK: Successors (3): B3 B8 +// CHECK: B1 +// CHECK: [ B3 ] +// CHECK: case 1: +// CHECK: T: break; +// CHECK: Predecessors (2): B2 B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A f; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: 4: [B8.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B3 +// CHECK: [ B5 ] +// CHECK: 1: return; +// CHECK: 2: [B8.2].~A() (Implicit destructor) +// CHECK: 3: [B2.4].~A() (Implicit destructor) +// CHECK: 4: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B0 +// CHECK: [ B6 ] +// CHECK: 1: UV +// CHECK: T: if [B6.1] +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B5 B4 +// CHECK: [ B7 ] +// CHECK: 1: [B8.2].~A() (Implicit destructor) +// CHECK: T: break; +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B1 +// CHECK: [ B8 ] +// CHECK: case 0: +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: UV +// CHECK: T: if [B8.3] +// CHECK: Predecessors (1): B2 +// CHECK: Successors (2): B7 B6 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (2): B1 B5 +// CHECK: Successors (0): +// CHECK: [ B6 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B5 +// CHECK: [ B1 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: 2: [B5.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: a +// CHECK: 2: for (A a; [B2.4];) +// CHECK:[B4.2] 3: b.operator int() +// CHECK: 4: [B2.3] +// CHECK: T: for (...; [B2.4]; ) +// CHECK: Predecessors (2): B3 B5 +// CHECK: Successors (2): B4 B1 +// CHECK: [ B3 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B2 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A c; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B3 +// CHECK: [ B5 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B12 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B11 +// CHECK: [ B1 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: 2: [B11.4].~A() (Implicit destructor) +// CHECK: 3: +// CHECK: 4: A f; +// CHECK: 5: [B1.4].~A() (Implicit destructor) +// CHECK: 6: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B9 B2 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: b +// CHECK: 2: for (A b; [B2.4];) { +// CHECK:[B10.2] if ([B10.3]) +// CHECK: break; +// CHECK: if ([B8.1]) +// CHECK: continue; +// CHECK: if ([B6.1]) +// CHECK:[B5.1][B4.2]} +// CHECK: 3: c.operator int() +// CHECK: 4: [B2.3] +// CHECK: T: for (...; [B2.4]; ) +// CHECK: Predecessors (2): B3 B11 +// CHECK: Successors (2): B10 B1 +// CHECK: [ B3 ] +// CHECK: 1: [B2.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B4 B7 +// CHECK: Successors (1): B2 +// CHECK: [ B4 ] +// CHECK: 1: +// CHECK: 2: A e; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: 4: [B10.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B3 +// CHECK: [ B5 ] +// CHECK: 1: return; +// CHECK: 2: [B10.2].~A() (Implicit destructor) +// CHECK: 3: [B2.2].~A() (Implicit destructor) +// CHECK: 4: [B11.4].~A() (Implicit destructor) +// CHECK: 5: [B11.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B6 +// CHECK: Successors (1): B0 +// CHECK: [ B6 ] +// CHECK: 1: UV +// CHECK: T: if [B6.1] +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B5 B4 +// CHECK: [ B7 ] +// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: T: continue; +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B3 +// CHECK: [ B8 ] +// CHECK: 1: UV +// CHECK: T: if [B8.1] +// CHECK: Predecessors (1): B10 +// CHECK: Successors (2): B7 B6 +// CHECK: [ B9 ] +// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: T: break; +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B1 +// CHECK: [ B10 ] +// CHECK: 1: +// CHECK: 2: A d; +// CHECK: 3: UV +// CHECK: T: if [B10.3] +// CHECK: Predecessors (1): B2 +// CHECK: Successors (2): B9 B8 +// CHECK: [ B11 ] +// CHECK: 1: +// CHECK: 2: A a; +// CHECK: 3: +// CHECK: 4: A b; +// CHECK: Predecessors (1): B12 +// CHECK: Successors (1): B2 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (2): B1 B5 +// CHECK: Successors (0): +// CHECK: [ B3 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B0 +// CHECK: [ B1 ] +// CHECK: T: try ... +// CHECK: Predecessors (0): +// CHECK: Successors (2): B2 B0 +// CHECK: [ B2 ] +// CHECK: catch (const A &e): +// CHECK: Predecessors (1): B1 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (3): B2 B1 B3 +// CHECK: Successors (0): +// CHECK: [ B3 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B0 +// CHECK: [ B1 ] +// CHECK: T: try ... +// CHECK: Predecessors (0): +// CHECK: Successors (2): B2 B0 +// CHECK: [ B2 ] +// CHECK: catch (A e): +// CHECK: 1: .~A() (Implicit destructor) +// CHECK: Predecessors (1): B1 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (3): B2 B1 B3 +// CHECK: Successors (0): diff --git a/test/Analysis/base-init.cpp b/test/Analysis/base-init.cpp new file mode 100644 index 0000000..800763b --- /dev/null +++ b/test/Analysis/base-init.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -analyzer-inline-call -cfg-add-initializers -verify %s + +class A { + int x; +public: + A(); + int getx() const { + return x; + } +}; + +A::A() : x(0) { +} + +class B : public A { + int y; +public: + B(); +}; + +B::B() { +} + +void f() { + B b; + if (b.getx() != 0) { + int *p = 0; + *p = 0; // no-warning + } +} diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index b05b198..e18d7cf 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -73,7 +73,7 @@ void test1(NSString *format, ...) { void test2() { static int y = 0; int x; - ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is captured by block with a garbage value}} + ^{ y = x + 1; }(); // expected-warning{{Variable 'x' is uninitialized when captured by block}} } void test2_b() { @@ -86,5 +86,5 @@ void test2_b() { void test2_c() { typedef void (^myblock)(void); - myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is captured by block with a garbage value}} + myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}} } \ No newline at end of file diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c index ffe420f..eb23543 100644 --- a/test/Analysis/bstring.c +++ b/test/Analysis/bstring.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CString -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core.experimental.CString -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core.experimental.CString -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core.experimental.CString -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s //===----------------------------------------------------------------------=== // Declarations diff --git a/test/Analysis/chroot.c b/test/Analysis/chroot.c new file mode 100644 index 0000000..5b98a71 --- /dev/null +++ b/test/Analysis/chroot.c @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=unix.experimental.Chroot -analyzer-store region -verify %s + +extern int chroot(const char* path); +extern int chdir(const char* path); + +void foo(void) { +} + +void f1(void) { + chroot("/usr/local"); // root changed. + foo(); // expected-warning {{No call of chdir("/") immediately after chroot}} +} + +void f2(void) { + chroot("/usr/local"); // root changed. + chdir("/"); // enter the jail. + foo(); // no-warning +} + +void f3(void) { + chroot("/usr/local"); // root changed. + chdir("../"); // change working directory, still out of jail. + foo(); // expected-warning {{No call of chdir("/") immediately after chroot}} +} diff --git a/test/Analysis/complex.c b/test/Analysis/complex.c index bb2b2fe..1a33349 100644 --- a/test/Analysis/complex.c +++ b/test/Analysis/complex.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -Wno-unreachable-code -ffreestanding %s #include diff --git a/test/Analysis/conditional-op-missing-lhs.c b/test/Analysis/conditional-op-missing-lhs.c index 86882a5..e738964 100644 --- a/test/Analysis/conditional-op-missing-lhs.c +++ b/test/Analysis/conditional-op-missing-lhs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -warn-uninit-values -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -warn-uninit-values -verify %s void f1() { diff --git a/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index 9191a9e..bb339f6 100644 --- a/test/Analysis/constant-folding.c +++ b/test/Analysis/constant-folding.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-experimental-checks -verify %s // Trigger a warning if the analyzer reaches this point in the control flow. #define WARN ((void)*(char*)0) diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp new file mode 100644 index 0000000..c9775df --- /dev/null +++ b/test/Analysis/cxx-crashes.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -verify %s + +int f1(char *dst) { + char *p = dst + 4; + char *q = dst + 3; + return !(q >= p); +} + +long f2(char *c) { + return long(c) & 1; +} + +bool f3() { + return !false; +} + +void *f4(int* w) { + return reinterpret_cast(w); +} + +namespace { + +struct A { }; +struct B { + operator A() { return A(); } +}; + +A f(char *dst) { + B b; + return b; +} + +} + +namespace { + +struct S { + void *p; +}; + +void *f(S* w) { + return &reinterpret_cast(*w); +} + +} diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index 57d5d11..7fc0f04 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s void f1() { int k, y; // expected-warning{{unused variable 'k'}} expected-warning{{unused variable 'y'}} @@ -13,7 +13,7 @@ void f1() { void f2(void *b) { char *c = (char*)b; // no-warning char *d = b+1; // expected-warning {{never read}} expected-warning{{unused variable 'd'}} - printf("%s", c); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \ + printf("%s", c); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \ // expected-note{{please include the header or explicitly provide a declaration for 'printf'}} } @@ -44,10 +44,11 @@ void f5() { } +// int f6() { int x = 4; - ++x; // expected-warning{{never read}} + ++x; // no-warning return 1; } @@ -75,9 +76,11 @@ int f7d(int *p) { return 1; } +// Don't warn for dead stores in nested expressions. We have yet +// to see a real bug in this scenario. int f8(int *p) { extern int *baz(); - if ((p = baz())) // expected-warning{{Although the value}} + if ((p = baz())) // no-warning return 1; return 0; } @@ -148,9 +151,11 @@ void f15(unsigned x, unsigned y) { int z[count]; // expected-warning{{unused variable 'z'}} } +// Don't warn for dead stores in nested expressions. We have yet +// to see a real bug in this scenario. int f16(int x) { x = x * 2; - x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{Although the value stored to 'x' is used}} expected-warning{{The left operand to '*' is always 1}} + x = sizeof(int [x = (x || x + 1) * 2]) // expected-warning{{The left operand to '+' is always 0}} expected-warning{{The left operand to '*' is always 1}} ? 5 : 8; return x; } @@ -171,11 +176,35 @@ int f18() { x = 10; // expected-warning{{Value stored to 'x' is never read}} while (1) x = 10; // expected-warning{{Value stored to 'x' is never read}} + // unreachable. do - x = 10; // expected-warning{{Value stored to 'x' is never read}} + x = 10; // no-warning while (1); + return (x = 10); // no-warning +} + +int f18_a() { + int x = 0; // no-warning + return (x = 10); // no-warning +} + +void f18_b() { + int x = 0; // no-warning + if (1) + x = 10; // expected-warning{{Value stored to 'x' is never read}} +} + +void f18_c() { + int x = 0; + while (1) + x = 10; // expected-warning{{Value stored to 'x' is never read}} +} - return (x = 10); // expected-warning{{Although the value stored to 'x' is used in the enclosing expression, the value is never actually read from 'x'}} +void f18_d() { + int x = 0; // no-warning + do + x = 10; // expected-warning{{Value stored to 'x' is never read}} + while (1); } // PR 3514: false positive `dead initialization` warning for init to global @@ -203,7 +232,7 @@ void halt() __attribute__((noreturn)); int f21() { int x = 4; - ++x; // expected-warning{{never read}} + x = x + 1; // expected-warning{{never read}} if (1) { halt(); (void)x; @@ -235,7 +264,7 @@ void f22() { int y19 = 4; int y20 = 4; - ++x; // expected-warning{{never read}} + x = x + 1; // expected-warning{{never read}} ++y1; ++y2; ++y3; @@ -486,3 +515,16 @@ void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m) }while (--m); } +// Avoid dead stores resulting from an assignment (and use) being unreachable. +void rdar8405222_aux(int i); +void rdar8405222() { + const int show = 0; + int i = 0; + + if (show) + i = 5; // no-warning + + if (show) + rdar8405222_aux(i); +} + diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index b21ffad..59a48ba 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-check-dead-stores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -fexceptions -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s //===----------------------------------------------------------------------===// // Basic dead store checking (but in C++ mode). @@ -12,7 +12,7 @@ int j; void test1() { int x = 4; - ++x; // expected-warning{{never read}} + x = x + 1; // expected-warning{{never read}} switch (j) { case 1: @@ -69,11 +69,11 @@ void test2_b() { //===----------------------------------------------------------------------===// void test3_a(int x) { - ++x; // expected-warning{{never read}} + x = x + 1; // expected-warning{{never read}} } void test3_b(int &x) { - ++x; // no-warninge + x = x + 1; // no-warninge } void test3_c(int x) { @@ -100,3 +100,15 @@ static void test_new(unsigned n) { char **p = new char* [n]; // expected-warning{{never read}} } +//===----------------------------------------------------------------------===// +// Dead stores in namespaces. +//===----------------------------------------------------------------------===// + +namespace foo { + int test_4(int x) { + x = 2; // expected-warning{{Value stored to 'x' is never read}} + x = 2; + return x; + } +} + diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 701e580..00c9e53 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify %s typedef signed char BOOL; typedef unsigned int NSUInteger; @@ -41,3 +41,38 @@ void DeadStoreTest(NSObject *anObject) { void rdar_7631278(NSObject *x) { x = ((void*)0); } + +// This test case issuing a bogus warning for the declaration of 'isExec' +// because the compound statement for the @synchronized was being visited +// twice by the LiveVariables analysis. +BOOL baz_rdar8527823(); +void foo_rdar8527823(); +@interface RDar8527823 +- (void) bar_rbar8527823; +@end +@implementation RDar8527823 +- (void) bar_rbar8527823 +{ + @synchronized(self) { + BOOL isExec = baz_rdar8527823(); // no-warning + if (isExec) foo_rdar8527823(); + } +} +@end + +// Don't flag dead stores to assignments to self within a nested assignment. +@interface Rdar7947686 +- (id) init; +@end + +@interface Rdar7947686_B : Rdar7947686 +- (id) init; +@end + +@implementation Rdar7947686_B +- (id) init { + id x = (self = [super init]); // no-warning + return x; +} +@end + diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp new file mode 100644 index 0000000..2a9244e --- /dev/null +++ b/test/Analysis/derived-to-base.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region %s + +class A { +protected: + int x; +}; + +class B : public A { +public: + void f(); +}; + +void B::f() { + x = 3; +} diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp new file mode 100644 index 0000000..ea5b046 --- /dev/null +++ b/test/Analysis/dtor.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -analyzer-inline-call -cfg-add-implicit-dtors -verify %s + +class A { +public: + ~A() { + int *x = 0; + *x = 3; // expected-warning{{Dereference of null pointer}} + } +}; + +int main() { + A a; +} diff --git a/test/Analysis/dtors-in-dtor-cfg-output.cpp b/test/Analysis/dtors-in-dtor-cfg-output.cpp new file mode 100644 index 0000000..7765483 --- /dev/null +++ b/test/Analysis/dtors-in-dtor-cfg-output.cpp @@ -0,0 +1,60 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s +// XPASS: * + +class A { +public: + ~A() {} +}; + +class B : public virtual A { +public: + ~B() {} +}; + +class C : public virtual A { +public: + ~C() {} +}; + +class TestOrder : public C, public B, public virtual A { + A a; + int i; + A *p; +public: + ~TestOrder(); +}; + +TestOrder::~TestOrder() {} + +class TestArray { + A a[2]; + A b[0]; +public: + ~TestArray(); +}; + +TestArray::~TestArray() {} + +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: this->a.~A() (Member object destructor) +// CHECK: 2: ~B() (Base object destructor) +// CHECK: 3: ~C() (Base object destructor) +// CHECK: 4: ~A() (Base object destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: this->a.~A() (Member object destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c index 0a95b70..196b679 100644 --- a/test/Analysis/exercise-ps.c +++ b/test/Analysis/exercise-ps.c @@ -19,6 +19,6 @@ void_typedef f2_helper(); static void f2(void *buf) { F12_typedef* x; x = f2_helper(); - memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, void const *}} \ + memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring C library function 'memcpy' with type 'void *(void *, const void *}} \ // expected-note{{please include the header or explicitly provide a declaration for 'memcpy'}} } diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c index c97d4f8..0827f3d 100644 --- a/test/Analysis/fields.c +++ b/test/Analysis/fields.c @@ -17,3 +17,13 @@ void f() { struct s a; int *p = &(a.n) + 1; } + +typedef struct { + int x,y; +} Point; + +Point getit(void); +void test() { + Point p; + (void)(p = getit()).x; +} diff --git a/test/Analysis/idempotent-operations-limited-loops.c b/test/Analysis/idempotent-operations-limited-loops.c new file mode 100644 index 0000000..e4c34cd --- /dev/null +++ b/test/Analysis/idempotent-operations-limited-loops.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-max-loop 3 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-max-loop 4 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps %s -verify + +void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} + +// This test case previously caused a bogus idempotent operation warning +// due to us not properly culling warnings due to incomplete analysis of loops. +int pr8403() +{ + int i; + for(i=0; i<10; i++) + { + int j; + for(j=0; j+1RDar8431728_E[n]; + wrap = s->RDar8431728_A; + + a = s->RDar8431728_B[xy - 1]; + b = s->RDar8431728_B[xy - 1 - wrap]; + c = s->RDar8431728_B[xy - wrap]; + + if (b == c) { // no-warning + pred = a; + } else { + pred = c; + } + + *RDar8431728_B_ptr = &s->RDar8431728_B[xy]; + + return pred; +} + +// - Don't warn on pointer arithmetic. This +// is often idiomatic. +unsigned rdar8601243_aux(unsigned n); +void rdar8601243() { + char arr[100]; + char *start = arr; + start = start + rdar8601243_aux(sizeof(arr) - (arr - start)); // no-warning + (void) start; +} + diff --git a/test/Analysis/idempotent-operations.cpp b/test/Analysis/idempotent-operations.cpp index c5d1ceb..c213dc6 100644 --- a/test/Analysis/idempotent-operations.cpp +++ b/test/Analysis/idempotent-operations.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -verify %s // C++ specific false positives diff --git a/test/Analysis/idempotent-operations.m b/test/Analysis/idempotent-operations.m new file mode 100644 index 0000000..a77e2cb --- /dev/null +++ b/test/Analysis/idempotent-operations.m @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -verify %s + +typedef signed char BOOL; +typedef unsigned long NSUInteger; +typedef struct _NSZone NSZone; +@protocol NSObject - (BOOL)isEqual:(id)object; +@end + +@interface NSObject {} + @property int locked; + @property(nonatomic, readonly) NSObject *media; +@end + +// - Don't flag idempotent operation warnings when +// a method may invalidate an instance variable. +@interface Rdar8725041 : NSObject { + id _attribute; +} + - (void) method2; +@end + +@implementation Rdar8725041 +- (BOOL) method1 { + BOOL needsUpdate = (BOOL)0; + id oldAttribute = _attribute; + [self method2]; + needsUpdate |= (_attribute != oldAttribute); // no-warning + return needsUpdate; +} + +- (void) method2 +{ + _attribute = ((void*)0); +} +@end + +// Test that the idempotent operations checker works in the prescence +// of property expressions. +void pr9116(NSObject *placeholder) { + int x = placeholder.media.locked = placeholder ? 1 : 0; +} + diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp new file mode 100644 index 0000000..2fa3a9e --- /dev/null +++ b/test/Analysis/initializer.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -cfg-add-initializers -verify %s + +class A { + int x; +public: + A(); +}; + +A::A() : x(0) { + if (x != 0) { + int *p = 0; + *p = 0; // no-warning + } +} diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp new file mode 100644 index 0000000..5c5d514 --- /dev/null +++ b/test/Analysis/initializers-cfg-output.cpp @@ -0,0 +1,94 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-initializers %s 2>&1 | FileCheck %s +// XPASS: * + +class A { +public: + A() {} + A(int i) {} +}; + +class B : public virtual A { +public: + B() {} + B(int i) : A(i) {} +}; + +class C : public virtual A { +public: + C() {} + C(int i) : A(i) {} +}; + +class TestOrder : public C, public B, public A { + int i; + int& r; +public: + TestOrder(); +}; + +TestOrder::TestOrder() + : r(i), B(), i(), C() { + A a; +} + +class TestControlFlow { + int x, y, z; +public: + TestControlFlow(bool b); +}; + +TestControlFlow::TestControlFlow(bool b) + : y(b ? 0 : 1) + , x(0) + , z(y) { + int v; +} + +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: +// CHECK: 2: A([B1.1]) (Base initializer) +// CHECK: 3: +// CHECK: 4: C([B1.3]) (Base initializer) +// CHECK: 5: +// CHECK: 6: B([B1.5]) (Base initializer) +// CHECK: 7: +// CHECK: 8: A([B1.7]) (Base initializer) +// CHECK: 9: i(/*implicit*/int()) (Member initializer) +// CHECK: 10: r(this->i) (Member initializer) +// CHECK: 11: +// CHECK: 12: A a; +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B5 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B4 +// CHECK: [ B1 ] +// CHECK: 1: [B4.2] ? [B2.1] : [B3.1] +// CHECK: 2: y([B1.1]) (Member initializer) +// CHECK: 3: z(this->y) (Member initializer) +// CHECK: 4: int v; +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: 0 +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: 1 +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: x(0) (Member initializer) +// CHECK: 2: b +// CHECK: T: [B4.2] ? ... : ... +// CHECK: Predecessors (1): B5 +// CHECK: Successors (2): B2 B3 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 50c1a54..d7a599a 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -1,14 +1,14 @@ // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s -int f1() { +int test1_f1() { int y = 1; y++; return y; } -void f2() { +void test1_f2() { int x = 1; - x = f1(); + x = test1_f1(); if (x == 1) { int *p = 0; *p = 3; // no-warning @@ -18,3 +18,13 @@ void f2() { *p = 3; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} } } + +// Test that inlining works when the declared function has less arguments +// than the actual number in the declaration. +void test2_f1() {} +int test2_f2(); + +void test2_f3() { + test2_f1(test2_f2()); // expected-warning{{too many arguments in call to 'test2_f1'}} +} + diff --git a/test/Analysis/lvalue.cpp b/test/Analysis/lvalue.cpp new file mode 100644 index 0000000..f19c59d --- /dev/null +++ b/test/Analysis/lvalue.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s + +int f1() { + int x = 0, y = 1; + return x += y; // Should bind a location to 'x += y'. No crash. +} diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index e443150..fdfccab 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-store=region -verify %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void free(void *); diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp index 47f1444..b5b81e3 100644 --- a/test/Analysis/method-call.cpp +++ b/test/Analysis/method-call.cpp @@ -1,8 +1,10 @@ // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s +// XFAIL: * + struct A { int x; A(int a) { x = a; } - int getx() { return x; } + int getx() const { return x; } }; void f1() { @@ -16,3 +18,24 @@ void f1() { } } +void f2() { + const A &x = A(3); + if (x.getx() == 3) { + int *p = 0; + *p = 3; // expected-warning{{Dereference of null pointer}} + } else { + int *p = 0; + *p = 3; // no-warning + } +} + +void f3() { + const A &x = (A)3; + if (x.getx() == 3) { + int *p = 0; + *p = 3; // expected-warning{{Dereference of null pointer}} + } else { + int *p = 0; + *p = 3; // no-warning + } +} diff --git a/test/Analysis/misc-ps-64.m b/test/Analysis/misc-ps-64.m index 0dbd6cb..f65673e 100644 --- a/test/Analysis/misc-ps-64.m +++ b/test/Analysis/misc-ps-64.m @@ -14,7 +14,7 @@ typedef unsigned char Boolean; typedef const struct __CFDictionary * CFDictionaryRef; extern Boolean CFDictionaryGetValueIfPresent(CFDictionaryRef theDict, const void *key, const void **value); -static void shazam(NSUInteger i, unsigned char **out); +void shazam(NSUInteger i, unsigned char **out); void rdar_6440393_1(NSDictionary *dict) { NSInteger x = 0; diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index bfa5e5c..1dba09d 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -159,3 +159,84 @@ int r8375510(R8375510 x, R8375510 y) { for (; ; x++) { } } +// PR8419 -- this used to crash. + +class String8419 { + public: + char& get(int n); + char& operator[](int n); +}; + +char& get8419(); + +void Test8419() { + String8419 s; + ++(s.get(0)); + get8419()--; // used to crash + --s[0]; // used to crash + s[0] &= 1; // used to crash + s[0]++; // used to crash +} + +// PR8426 -- this used to crash. + +void Use(void* to); + +template class Foo { + ~Foo(); + struct Bar; + Bar* bar_; +}; + +template Foo::~Foo() { + Use(bar_); + T::DoSomething(); + bar_->Work(); +} + +// PR8427 -- this used to crash. + +class Dummy {}; + +bool operator==(Dummy, int); + +template +class Foo2 { + bool Bar(); +}; + +template +bool Foo2::Bar() { + return 0 == T(); +} + +// PR8433 -- this used to crash. + +template +class Foo3 { + public: + void Bar(); + void Baz(); + T value_; +}; + +template +void Foo3::Bar() { + Baz(); + value_(); +} + +//===---------------------------------------------------------------------===// +// Handle misc. C++ constructs. +//===---------------------------------------------------------------------===// + +namespace fum { + int i = 3; +}; + +void test_namespace() { + // Previously triggered a crash. + using namespace fum; + int x = i; +} + diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index a4e0d0b..b35a834 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s typedef long unsigned int size_t; void *memcpy(void *, const void *, size_t); @@ -394,7 +394,7 @@ void rdar_7332673_test1() { int rdar_7332673_test2_aux(char *x); void rdar_7332673_test2() { char *value; - if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{Pass-by-value argument in function call is undefined}} + if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{Function call argument is an uninitialized value}} } //===----------------------------------------------------------------------===// @@ -671,7 +671,7 @@ typedef void (^RDar_7462324_Callback)(id obj); builder = ^(id object) { id x; if (object) { - builder(x); // expected-warning{{Pass-by-value argument in function call is undefined}} + builder(x); // expected-warning{{Function call argument is an uninitialized value}} } }; builder(target); @@ -1103,16 +1103,18 @@ void pr8015_C() { } } -// FIXME: This is a false positive due to not reasoning about symbolic -// array indices correctly. Discussion in PR 8015. +// Tests that we correctly handle that 'number' is perfectly constrained +// after 'if (nunber == 0)', allowing us to resolve that +// numbers[number] == numbers[0]. void pr8015_D_FIXME() { int number = pr8015_A(); const char *numbers[] = { "zero" }; if (number == 0) { - if (numbers[number] == numbers[0]) + if (numbers[number] == numbers[0]) // expected-warning{{Both operands to '==' always have the same value}} return; + // Unreachable. int *p = 0; - *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}} + *p = 0xDEADBEEF; // no-warnng } } @@ -1140,3 +1142,98 @@ void pr8015_F_FIXME() { } } +// PR 8141. Previously the statement expression in the for loop caused +// the CFG builder to crash. +struct list_pr8141 +{ + struct list_pr8141 *tail; +}; + +struct list_pr8141 * +pr8141 (void) { + struct list_pr8141 *items; + for (;; items = ({ do { } while (0); items->tail; })) // expected-warning{{Dereference of undefined pointer value}} + { + } +} + +// Don't crash when building the CFG. +void do_not_crash(int x) { + while (x - ({do {} while (0); x; })) { + } +} + +// - Handle looking at the size of a VLA in +// ArrayBoundChecker. Nothing intelligent (yet); just don't crash. +typedef struct RDar8424269_A { + int RDar8424269_C; +} RDar8424269_A; +static void RDar8424269_B(RDar8424269_A *p, unsigned char *RDar8424269_D, + const unsigned char *RDar8424269_E, int RDar8424269_F, + int b_w, int b_h, int dx, int dy) { + int x, y, b, r, l; + unsigned char tmp2t[3][RDar8424269_F * (32 + 8)]; + unsigned char *tmp2 = tmp2t[0]; + if (p && !p->RDar8424269_C) + b = 15; + tmp2 = tmp2t[1]; + if (b & 2) { // expected-warning{{The left operand of '&' is a garbage value}} + for (y = 0; y < b_h; y++) { + for (x = 0; x < b_w + 1; x++) { + int am = 0; + tmp2[x] = am; + } + } + } + tmp2 = tmp2t[2]; +} + +// - Handle transparent unions with the AttrNonNullChecker. +typedef union { + struct rdar_8642434_typeA *_dq; +} +rdar_8642434_typeB __attribute__((transparent_union)); + +__attribute__((visibility("default"))) __attribute__((__nonnull__)) __attribute__((__nothrow__)) +void rdar_8642434_funcA(rdar_8642434_typeB object); + +void rdar_8642434_funcB(struct rdar_8642434_typeA *x, struct rdar_8642434_typeA *y) { + rdar_8642434_funcA(x); + if (!y) + rdar_8642434_funcA(y); // expected-warning{{Null pointer passed as an argument to a 'nonnull' parameter}} +} + +// - Handle loads and stores from a symbolic index +// into array without warning about an uninitialized value being returned. +// While RegionStore can't fully reason about this example, it shouldn't +// warn here either. +typedef struct s_test_rdar8848957 { + int x, y, z; +} s_test_rdar8848957; + +s_test_rdar8848957 foo_rdar8848957(); +int rdar8848957(int index) { + s_test_rdar8848957 vals[10]; + vals[index] = foo_rdar8848957(); + return vals[index].x; // no-warning +} + +// PR 9049 - crash on symbolicating unions. This test exists solely to +// test that the analyzer doesn't crash. +typedef struct pr9048_cdev *pr9048_cdev_t; +typedef union pr9048_abstracted_disklabel { void *opaque; } pr9048_disklabel_t; +struct pr9048_diskslice { pr9048_disklabel_t ds_label; }; +struct pr9048_diskslices { + int dss_secmult; + struct pr9048_diskslice dss_slices[16]; +}; +void pr9048(pr9048_cdev_t dev, struct pr9048_diskslices * ssp, unsigned int slice) +{ + pr9048_disklabel_t lp; + struct pr9048_diskslice *sp; + sp = &ssp->dss_slices[slice]; + if (ssp->dss_secmult == 1) { + } else if ((lp = sp->ds_label).opaque != ((void *) 0)) { + } +} + diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 4fbaa49..45b44b7 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1,12 +1,12 @@ // NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued. -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -fobjc-gc -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -fobjc-gc -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=basic -fobjc-gc -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=basic -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=basic -fobjc-gc -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=basic -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.experimental.IdempotentOps -analyzer-checker=core.experimental.CastToStruct -analyzer-checker=cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code %s #ifndef __clang_analyzer__ #error __clang__analyzer__ not defined @@ -794,7 +794,7 @@ int test_uninit_branch_c(void) { void test_bad_call_aux(int x); void test_bad_call(void) { int y; - test_bad_call_aux(y); // expected-warning{{Pass-by-value argument in function call is undefined}} + test_bad_call_aux(y); // expected-warning{{Function call argument is an uninitialized value}} } @interface TestBadArg {} @@ -803,7 +803,7 @@ void test_bad_call(void) { void test_bad_msg(TestBadArg *p) { int y; - [p testBadArg:y]; // expected-warning{{Pass-by-value argument in message expression is undefined}} + [p testBadArg:y]; // expected-warning{{Argument in message expression is an uninitialized value}} } //===----------------------------------------------------------------------===// @@ -822,7 +822,7 @@ struct trie { struct kwset { struct trie *trie; - unsigned char delta[10]; + unsigned char y[10]; struct trie* next[10]; int d; }; @@ -837,9 +837,9 @@ void f(kwset_t *kws, char const *p, char const *q) { register char const *end = p; register char const *lim = q; register int d = 1; - register unsigned char const *delta = kws->delta; + register unsigned char const *y = kws->y; - d = delta[c = (end+=d)[-1]]; // no-warning + d = y[c = (end+=d)[-1]]; // no-warning trie = next[c]; } @@ -1068,3 +1068,168 @@ void pr8050(struct PR8050 **arg) *arg = malloc(1); } +// Switch on enum should not consider default case live +// if all enum values are covered +enum Cases { C1, C2, C3, C4 }; +void test_enum_cases(enum Cases C) { + switch (C) { + case C1: + case C2: + case C4: + case C3: + return; + } + int *p = 0; + *p = 0xDEADBEEF; // no-warning +} + +void test_enum_cases_positive(enum Cases C) { + switch (C) { // expected-warning{{enumeration value 'C4' not handled in switch}} + case C1: + case C2: + case C3: + return; + } + int *p = 0; + *p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer}} +} + +// rule request: warn if synchronization mutex can be nil +void rdar6351970() { + id x = 0; + @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}} +} + +void rdar6351970_b(id x) { + if (!x) + @synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}} +} + +void rdar6351970_c() { + id x; + @synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}} +} + +@interface Rdar8578650 +- (id) foo8578650; +@end + +void rdar8578650(id x) { + @synchronized (x) { + [x foo8578650]; + } + // At this point we should assume that 'x' is not nil, not + // the inverse. + @synchronized (x) { // no-warning + } +} + +// rule request: direct structure member access null pointer dereference +@interface RDar6352035 { + int c; +} +- (void)foo; +- (void)bar; +@end + +@implementation RDar6352035 +- (void)foo { + RDar6352035 *friend = 0; + friend->c = 7; // expected-warning{{Instance variable access (via 'friend') results in a null pointer dereference}} +} +- (void)bar { + self = 0; + c = 7; // expected-warning{{Instance variable access (via 'self') results in a null pointer dereference}} +} +@end + +// PR 8149 - GNU statement expression in condition of ForStmt. +// This previously triggered an assertion failure in CFGBuilder. +void pr8149(void) { + for (; ({ do { } while (0); 0; });) { } +} + +// PR 8458 - Make sure @synchronized doesn't crash with properties. +@interface PR8458 {} +@property(readonly) id lock; +@end + +static +void __PR8458(PR8458 *x) { + @synchronized(x.lock) {} // no-warning +} + +// PR 8440 - False null dereference during store to array-in-field-in-global. +// This test case previously resulted in a bogus null deref warning from +// incorrect lazy symbolication logic in RegionStore. +static struct { + int num; + char **data; +} saved_pr8440; + +char *foo_pr8440(); +char **bar_pr8440(); +void baz_pr8440(int n) +{ + saved_pr8440.num = n; + if (saved_pr8440.data) + return; + saved_pr8440.data = bar_pr8440(); + for (int i = 0 ; i < n ; i ++) + saved_pr8440.data[i] = foo_pr8440(); // no-warning +} + +// Support direct accesses to non-null memory. Reported in: +// PR 5272 +// +int test_direct_address_load() { + int *p = (int*) 0x4000; + return *p; // no-warning +} + +void pr5272_test() { + struct pr5272 { int var2; }; + (*(struct pr5272*)0xBC000000).var2 = 0; // no-warning + (*(struct pr5272*)0xBC000000).var2 += 2; // no-warning +} + +// Support casting the return value of function to another different type +// This previously caused a crash, although we likely need more precise +// reasoning here. +void* rdar8663544(); +typedef struct {} Val8663544; +Val8663544 bazR8663544() { + Val8663544(*func) () = (Val8663544(*) ()) rdar8663544; + return func(); +} + +// PR 8619 - Handle ternary expressions with a call to a noreturn function. +// This previously resulted in a crash. +void pr8619_noreturn(int x) __attribute__((noreturn)); + +void pr8619(int a, int b, int c) { + a ?: pr8619_noreturn(b || c); +} + + +// PR 8646 - crash in the analyzer when handling unions. +union pr8648_union { + signed long long pr8648_union_field; +}; +void pr8648() { + long long y; + union pr8648_union x = { .pr8648_union_field = 0LL }; + y = x.pr8648_union_field; + + union pr8648_union z; + z = (union pr8648_union) { .pr8648_union_field = 0LL }; + + union pr8648_union w; + w = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }); + + // crash, no assignment + (void) ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field; + + // crash with assignment + y = ({ (union pr8648_union) { .pr8648_union_field = 0LL }; }).pr8648_union_field; +} diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m new file mode 100644 index 0000000..4c754fb --- /dev/null +++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=range -analyzer-store=region -verify %s + +// - This test case shows that a nil instance +// variable can possibly be initialized by a method. +typedef struct RDar6888289_data { + long data[100]; +} RDar6888289_data; + +@interface RDar6888289 +{ + RDar6888289 *x; +} +- (RDar6888289_data) test; +- (RDar6888289_data) test2; +- (void) invalidate; +- (RDar6888289_data) getData; +@end + +@implementation RDar6888289 +- (RDar6888289_data) test { + if (!x) + [self invalidate]; + return [x getData]; +} +- (RDar6888289_data) test2 { + if (!x) {} + return [x getData]; // expected-warning{{The receiver of message 'getData' is nil and returns a value of type 'RDar6888289_data' that will be garbage}} +} + +- (void) invalidate { + x = self; +} + +- (RDar6888289_data) getData { + return (RDar6888289_data) { 0 }; +} +@end + diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m index 5f51871..6c8f525 100644 --- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m +++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m @@ -2,11 +2,14 @@ // RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=basic %s 2>&1 | FileCheck -check-prefix=darwin9 %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s +// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=basic %s 2>&1 | FileCheck -check-prefix=darwin9 %s +// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s @interface MyClass {} - (void *)voidPtrM; - (int)intM; - (long long)longlongM; +- (unsigned long long)unsignedLongLongM; - (double)doubleM; - (long double)longDoubleM; - (void)voidM; @@ -15,6 +18,7 @@ - (void *)voidPtrM { return (void *)0; } - (int)intM { return 0; } - (long long)longlongM { return 0; } +- (unsigned long long)unsignedLongLongM { return 0; } - (double)doubleM { return 0.0; } - (long double)longDoubleM { return 0.0; } - (void)voidM {} @@ -30,20 +34,20 @@ void createFoo() { void createFoo2() { MyClass *obj = 0; - long double ld = [obj longDoubleM]; // expected-warning{{The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage}} + long double ld = [obj longDoubleM]; } void createFoo3() { MyClass *obj; obj = 0; - long long ll = [obj longlongM]; // expected-warning{{The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage}} + long long ll = [obj longlongM]; } void createFoo4() { MyClass *obj = 0; - double d = [obj doubleM]; // expected-warning{{The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage}} + double d = [obj doubleM]; } void createFoo5() { @@ -52,16 +56,23 @@ void createFoo5() { double d = [obj doubleM]; // no-warning } +void createFoo6() { + MyClass *obj; + obj = 0; + + unsigned long long ull = [obj unsignedLongLongM]; +} + void handleNilPruneLoop(MyClass *obj) { if (!!obj) return; // Test if [obj intM] evaluates to 0, thus pruning the entire loop. for (int i = 0; i < [obj intM]; i++) { - long long j = [obj longlongM]; // no-warning + long long j = [obj longlongM]; } - long long j = [obj longlongM]; // expected-warning{{The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage}} + long long j = [obj longlongM]; } int handleVoidInComma() { @@ -72,11 +83,16 @@ int handleVoidInComma() { int marker(void) { // control reaches end of non-void function } -// CHECK-darwin8: control reaches end of non-void function + // CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage // CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage // CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage +// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage // CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage -// CHECK-darwin8: 5 warnings generated -// CHECK-darwin9: control reaches end of non-void function +// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage +// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage +// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage +// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage +// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage // CHECK-darwin9: 1 warning generated + diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 8daa845..5db4923 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=basic -analyzer-store=basic -Wreturn-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=range -analyzer-store=basic -Wreturn-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-no-purge-dead -verify %s -Wreturn-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=basic -analyzer-store=basic -Wreturn-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -verify %s -analyzer-constraints=range -analyzer-store=basic -Wreturn-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-no-purge-dead -verify %s -Wreturn-type +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -std=gnu99 -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type typedef unsigned uintptr_t; @@ -26,7 +26,7 @@ int f2(struct foo_struct* p) { if (p) p->x = 1; - return p->x++; // expected-warning{{Field access results in a dereference of a null pointer (loaded from variable 'p')}} + return p->x++; // expected-warning{{Access to field 'x' results in a dereference of a null pointer (loaded from variable 'p')}} } int f3(char* x) { @@ -36,7 +36,7 @@ int f3(char* x) { if (x) return x[i - 1]; - return x[i+1]; // expected-warning{{Dereference of null pointer}} + return x[i+1]; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}} } int f3_b(char* x) { @@ -46,7 +46,7 @@ int f3_b(char* x) { if (x) return x[i - 1]; - return x[i+1]++; // expected-warning{{Dereference of null pointer}} + return x[i+1]++; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}} } int f4(int *p) { @@ -237,7 +237,7 @@ int* f10(int* p, signed char x, int y) { // Test case from void f11(unsigned i) { int *x = 0; - if (i >= 0) { + if (i >= 0) { // expected-warning{{always true}} // always true } else { *x = 42; // no-warning @@ -288,7 +288,7 @@ void pr4759_aux(int *p) __attribute__((nonnull)); void pr4759() { int *p; - pr4759_aux(p); // expected-warning{{undefined}} + pr4759_aux(p); // expected-warning{{Function call argument is an uninitialized value}} } diff --git a/test/Analysis/operator-calls.cpp b/test/Analysis/operator-calls.cpp new file mode 100644 index 0000000..892a1ab --- /dev/null +++ b/test/Analysis/operator-calls.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-experimental-checks -verify %s +struct X0 { }; +bool operator==(const X0&, const X0&); + +// PR7287 +struct test { int a[2]; }; + +void t2() { + test p = {{1,2}}; + test q; + q = p; +} + +bool PR7287(X0 a, X0 b) { + return operator==(a, b); +} diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c new file mode 100644 index 0000000..b8d6e44 --- /dev/null +++ b/test/Analysis/out-of-bounds.c @@ -0,0 +1,148 @@ +// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-check-objc-mem -analyzer-check-buffer-overflows -verify %s + +// Tests doing an out-of-bounds access after the end of an array using: +// - constant integer index +// - constant integer size for buffer +void test1(int x) { + int buf[100]; + buf[100] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ok(int x) { + int buf[100]; + buf[99] = 1; // no-warning +} + +const char test1_strings_underrun(int x) { + const char *mystr = "mary had a little lamb"; + return mystr[-1]; // expected-warning{{Out of bound memory access}} +} + +const char test1_strings_overrun(int x) { + const char *mystr = "mary had a little lamb"; + return mystr[1000]; // expected-warning{{Out of bound memory access}} +} + +const char test1_strings_ok(int x) { + const char *mystr = "mary had a little lamb"; + return mystr[5]; // no-warning +} + +// Tests doing an out-of-bounds access after the end of an array using: +// - indirect pointer to buffer +// - constant integer index +// - constant integer size for buffer +void test1_ptr(int x) { + int buf[100]; + int *p = buf; + p[101] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_ok(int x) { + int buf[100]; + int *p = buf; + p[99] = 1; // no-warning +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer, manipulated using simple pointer arithmetic +// - constant integer index +// - constant integer size for buffer +void test1_ptr_arith(int x) { + int buf[100]; + int *p = buf; + p = p + 100; + p[0] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_arith_ok(int x) { + int buf[100]; + int *p = buf; + p = p + 99; + p[0] = 1; // no-warning +} + +void test1_ptr_arith_bad(int x) { + int buf[100]; + int *p = buf; + p = p + 99; + p[1] = 1; // expected-warning{{Out of bound memory access}} +} + +void test1_ptr_arith_ok2(int x) { + int buf[100]; + int *p = buf; + p = p + 99; + p[-1] = 1; // no-warning +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - constant integer index +// - constant integer size for buffer +void test2(int x) { + int buf[100]; + buf[-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer +// - constant integer index +// - constant integer size for buffer +void test2_ptr(int x) { + int buf[100]; + int *p = buf; + p[-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// ** FIXME ** Doesn't work yet because we don't support pointer arithmetic. +// Tests doing an out-of-bounds access before the start of an array using: +// - indirect pointer to buffer, manipulated using simple pointer arithmetic +// - constant integer index +// - constant integer size for buffer +void test2_ptr_arith(int x) { + int buf[100]; + int *p = buf; + --p; + p[0] = 1; // no-warning +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes for the array +void test2_multi(int x) { + int buf[100][100]; + buf[0][-1] = 1; // expected-warning{{Out of bound memory access}} +} + +// Tests doing an out-of-bounds access before the start of a multi-dimensional +// array using: +// - constant integer indices +// - constant integer sizes for the array +void test2_multi_b(int x) { + int buf[100][100]; + buf[-1][0] = 1; // expected-warning{{Out of bound memory access}} +} + +void test2_multi_ok(int x) { + int buf[100][100]; + buf[0][0] = 1; // no-warning +} + +// *** FIXME *** +// We don't get a warning here yet because our symbolic constraint solving +// doesn't handle: (symbol * constant) < constant +void test3(int x) { + int buf[100]; + if (x < 0) + buf[x] = 1; +} + +// *** FIXME *** +// We don't get a warning here yet because our symbolic constraint solving +// doesn't handle: (symbol * constant) < constant +void test4(int x) { + int buf[100]; + if (x > 99) + buf[x] = 1; +} diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index ed51dc6..3b261bb 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-experimental-checks -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-experimental-internal-checks -analyzer-experimental-checks -analyzer-check-objc-mem -analyzer-store=region -verify %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m new file mode 100644 index 0000000..12697b4 --- /dev/null +++ b/test/Analysis/plist-output-alternate.m @@ -0,0 +1,1014 @@ +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s + +void test_null_init(void) { + int *p = 0; + *p = 0xDEADBEEF; +} + +void test_null_assign(void) { + int *p; + p = 0; + *p = 0xDEADBEEF; +} + +void test_null_assign_transitive(void) { + int *p; + p = 0; + int *q = p; + *q = 0xDEADBEEF; +} + +void test_null_cond(int *p) { + if (!p) { + *p = 0xDEADBEEF; + } +} + +void test_null_cond_transitive(int *q) { + if (!q) { + int *p = q; + *p = 0xDEADBEEF; + } +} + +void test_null_field(void) { + struct s { int *p; } x; + x.p = 0; + *(x.p) = 0xDEADBEEF; +} + +// leak reports should not show paths that end with exit() (but ones that don't end with exit()) +void panic() __attribute__((noreturn)); +enum { kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; +typedef const struct __CFAllocator * CFAllocatorRef; +extern const CFAllocatorRef kCFAllocatorDefault; +typedef signed long CFIndex; +typedef CFIndex CFNumberType; +typedef const struct __CFNumber * CFNumberRef; + +extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); + +void rdar8331641(int x) { + signed z = 1; + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} + if (x) + panic(); + (void) value; +} + +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: files +// CHECK: +// CHECK: +// CHECK: diagnostics +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line4 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line4 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line5 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line5 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line9 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Null pointer value stored to 'p' +// CHECK: message +// CHECK: Null pointer value stored to 'p' +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line10 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line11 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line11 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line15 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line15 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Variable 'q' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'q' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line17 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line18 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'q') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'q') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line18 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line22 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line23 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line23 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line23 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line28 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: message +// CHECK: Variable 'p' initialized to a null pointer value +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line29 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line30 +// CHECK: col6 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from variable 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from variable 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line30 +// CHECK: col5 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line35 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col8 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line37 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: message +// CHECK: Dereference of null pointer (loaded from field 'p') +// CHECK: +// CHECK: +// CHECK: descriptionDereference of null pointer (loaded from field 'p') +// CHECK: categoryLogic error +// CHECK: typeDereference of null pointer +// CHECK: location +// CHECK: +// CHECK: line37 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line52 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line53 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference) +// CHECK: message +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference) +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col23 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line53 +// CHECK: col82 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line54 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line56 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: extended_message +// CHECK: Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked) +// CHECK: message +// CHECK: Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked) +// CHECK: +// CHECK: +// CHECK: descriptionPotential leak of an object allocated on line 53 and stored into 'value' +// CHECK: categoryMemory (Core Foundation/Objective-C) +// CHECK: typeLeak of returned object +// CHECK: location +// CHECK: +// CHECK: line57 +// CHECK: col1 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index 95faa06..ec4f770 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s +// XFAIL: * void test_null_init(void) { int *p = 0; diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m new file mode 100644 index 0000000..ce8faf5 --- /dev/null +++ b/test/Analysis/properties.m @@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s + +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end +@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end +@interface NSObject {} ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +-(id)retain; +@end +@interface NSString : NSObject +- (NSUInteger)length; +-(id)initWithFormat:(NSString *)f,...; +-(BOOL)isEqualToString:(NSString *)s; ++ (id)string; +@end +@interface NSNumber : NSObject {} ++(id)alloc; +-(id)initWithInteger:(int)i; +@end + +// rdar://6946338 + +@interface Test1 : NSObject { + NSString *text; +} +-(id)myMethod; +@property (nonatomic, assign) NSString *text; +@end + + +@implementation Test1 + +@synthesize text; + +-(id)myMethod { + Test1 *cell = [[[Test1 alloc] init] autorelease]; + + NSString *string1 = [[NSString alloc] initWithFormat:@"test %f", 0.0]; // expected-warning {{Potential leak}} + cell.text = string1; + + return cell; +} + +@end + + +// rdar://8824416 + +@interface MyNumber : NSObject +{ + NSNumber* _myNumber; +} + +- (id)initWithNumber:(NSNumber *)number; + +@property (nonatomic, readonly) NSNumber* myNumber; +@property (nonatomic, readonly) NSNumber* newMyNumber; + +@end + +@implementation MyNumber +@synthesize myNumber=_myNumber; + +- (id)initWithNumber:(NSNumber *)number +{ + self = [super init]; + + if ( self ) + { + _myNumber = [number copy]; + } + + return self; +} + +- (NSNumber*)newMyNumber +{ + if ( _myNumber ) + return [_myNumber retain]; + + return [[NSNumber alloc] initWithInteger:1]; +} + +- (id)valueForUndefinedKey:(NSString*)key +{ + id value = 0; + + if ([key isEqualToString:@"MyIvarNumberAsPropertyOverReleased"]) + value = self.myNumber; // _myNumber will be over released, since the value returned from self.myNumber is not retained. + else if ([key isEqualToString:@"MyIvarNumberAsPropertyOk"]) + value = [self.myNumber retain]; // this line fixes the over release + else if ([key isEqualToString:@"MyIvarNumberAsNewMyNumber"]) + value = self.newMyNumber; // this one is ok, since value is returned retained + else + value = [[NSNumber alloc] initWithInteger:0]; + + return [value autorelease]; // expected-warning {{Object sent -autorelease too many times}} +} + +@end + +NSNumber* numberFromMyNumberProperty(MyNumber* aMyNumber) +{ + NSNumber* result = aMyNumber.myNumber; + + return [result autorelease]; // expected-warning {{Object sent -autorelease too many times}} +} + + +// rdar://6611873 + +@interface Person : NSObject { + NSString *_name; +} +@property (retain) NSString * name; +@end + +@implementation Person +@synthesize name = _name; +@end + +void rdar6611873() { + Person *p = [[[Person alloc] init] autorelease]; + + p.name = [[NSString string] retain]; // expected-warning {{leak}} + p.name = [[NSString alloc] init]; // expected-warning {{leak}} +} + +@interface SubPerson : Person +-(NSString *)foo; +@end + +@implementation SubPerson +-(NSString *)foo { + return super.name; +} +@end diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index 0c2e221..044d72a 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -verify -triple i686-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.FixedAddr -analyzer-checker=core.experimental.PointerArithm -analyzer-checker=core.experimental.PointerSub -analyzer-check-objc-mem -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.FixedAddr -analyzer-checker=core.experimental.PointerArithm -analyzer-checker=core.experimental.PointerSub -analyzer-check-objc-mem -analyzer-store=region -verify -triple i686-apple-darwin9 %s // Used to trigger warnings for unreachable paths. #define WARN do { int a, b; int c = &b-&a; } while (0) diff --git a/test/Analysis/rdar-6442306-1.m b/test/Analysis/rdar-6442306-1.m index dfe9b72..0d35f23 100644 --- a/test/Analysis/rdar-6442306-1.m +++ b/test/Analysis/rdar-6442306-1.m @@ -16,7 +16,7 @@ typedef struct { double __Foo_READSWAP__double(double*); static __inline__ bar_return_t -__Beeble_check__Request__SetPortalSize_t(__attribute__((__unused__)) __Request__SetPortalSize_t *In0P) { +__Beeble_check__Request__SetPortalSize_t(__Request__SetPortalSize_t *In0P) { if (In0P->Foo.int_rep != Foo_record.int_rep) { do { int __i__, __C__ = (2); diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m index dd01810..d6a03b6 100644 --- a/test/Analysis/rdar-6540084.m +++ b/test/Analysis/rdar-6540084.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify %s // // This test exercises the live variables analysis (LiveVariables.cpp). // The case originally identified a non-termination bug. diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m index 9defce2..7299001 100644 --- a/test/Analysis/refcnt_naming.m +++ b/test/Analysis/refcnt_naming.m @@ -11,6 +11,10 @@ typedef signed char BOOL; @class NSArray, NSString, NSURL; @interface NamingTest : NSObject {} +-(NSObject*)copyPhoto; +-(NSObject*)mutableCopyPhoto; +-(NSObject*)mutable; +-(NSObject*)mutableCopying; -(NSObject*)photocopy; // read as "photocopy" -(NSObject*)photoCopy; // read as "photo Copy" -(NSObject*)__blebPRCopy; // read as "bleb PRCopy" @@ -26,7 +30,9 @@ typedef signed char BOOL; } - (NSURL *)myMethod:(NSString *)inString; - (NSURL *)getMethod:(NSString*)inString; -- (void)addObject:(id)X; +- (NSURL *)getMethod2:(NSString*)inString; +- (void)addObject:(id) __attribute__((ns_consumed)) X; +- (void)addObject2:(id) X; @end @implementation MyClass @@ -44,10 +50,21 @@ typedef signed char BOOL; return url; // no-warning } +- (NSURL *)getMethod2:(NSString *)inString +{ + NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}} + [self addObject2:url]; + return url; +} + void testNames(NamingTest* x) { + [x copyPhoto]; // expected-warning{{leak}} + [x mutableCopyPhoto]; // expected-warning{{leak}} + [x mutable]; // no-warning + [x mutableCopying]; // no-warning [x photocopy]; // no-warning - [x photoCopy]; // expected-warning{{leak}} - [x __blebPRCopy]; // expected-warning{{leak}} + [x photoCopy]; // no-warning + [x __blebPRCopy]; // no-warning [x __blebPRcopy]; // no-warning [x new_theprefixdoescount]; // expected-warning{{leak}} [x newestAwesomeStuff]; // no-warning @@ -59,4 +76,10 @@ void testNames(NamingTest* x) { myObject = X; } +- (void)addObject2:(id)X +{ + myObject = X; +} + @end + diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp index f169416..51c8aae 100644 --- a/test/Analysis/reference.cpp +++ b/test/Analysis/reference.cpp @@ -1,9 +1,10 @@ // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s + typedef typeof(sizeof(int)) size_t; void malloc (size_t); void f1() { - int const &i = 3; + int const &i = 3; // <--- **FIXME** This is currently not being modeled correctly. int b = i; int *p = 0; diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 8995d5f..6f1dd92 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=basic -verify -fobjc-gc-only -fblocks %s -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -fobjc-gc-only -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=cocoa.NSAutoreleasePool -analyzer-check-objc-mem -analyzer-store=basic -verify -fobjc-gc-only -fblocks %s +// RUN: %clang_cc1 -analyze -analyzer-checker=cocoa.NSAutoreleasePool -analyzer-check-objc-mem -analyzer-store=region -fobjc-gc-only -fblocks -verify %s //===----------------------------------------------------------------------===// // Header stuff. diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m index 7b98554..05b91fc 100644 --- a/test/Analysis/retain-release-region-store.m +++ b/test/Analysis/retain-release-region-store.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-max-loop 6 -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 064165a..81e015f 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-store=basic -fblocks -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=macosx.CFRetainRelease -analyzer-checker=cocoa.ClassRelease -analyzer-check-objc-mem -analyzer-store=basic -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=macosx.CFRetainRelease -analyzer-checker=cocoa.ClassRelease -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s #if __has_feature(attribute_ns_returns_retained) #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) @@ -13,6 +13,15 @@ #if __has_feature(attribute_cf_returns_not_retained) #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) #endif +#if __has_feature(attribute_ns_consumes_self) +#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) +#endif +#if __has_feature(attribute_ns_consumed) +#define NS_CONSUMED __attribute__((ns_consumed)) +#endif +#if __has_feature(attribute_cf_consumed) +#define CF_CONSUMED __attribute__((cf_consumed)) +#endif //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from Mac OS X headers: @@ -703,7 +712,7 @@ typedef CFTypeRef OtherRef; NSString *_foo; } - (id)initReturningNewClass; -- (id)initReturningNewClassBad; +- (id)_initReturningNewClassBad; - (id)initReturningNewClassBad2; @end @@ -716,7 +725,7 @@ typedef CFTypeRef OtherRef; self = [[RDar6320065Subclass alloc] init]; // no-warning return self; } -- (id)initReturningNewClassBad { +- (id)_initReturningNewClassBad { [self release]; [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} return self; @@ -762,13 +771,13 @@ int RDar6320065_test() { @end @implementation RDar6859457 -- (NSString*) NoCopyString { return [[NSString alloc] init]; } // no-warning -- (NSString*) noCopyString { return [[NSString alloc] init]; } // no-warning +- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} +- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} @end void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { - [x NoCopyString]; // expected-warning{{leak}} - [x noCopyString]; // expected-warning{{leak}} + [x NoCopyString]; // no-warning + [x noCopyString]; // no-warning [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning } @@ -1210,10 +1219,13 @@ typedef NSString* MyStringTy; - (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning - (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning - (NSString*) newStringNoAttr; -- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions or methods that return a pointer or Objective-C object}} +- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} +- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED; ++ (void) consume:(id) NS_CONSUMED x; ++ (void) consume2:(id) CF_CONSUMED x; @end -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to function or method types}} +static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} void test_attr_1(TestOwnershipAttr *X) { NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} @@ -1228,6 +1240,37 @@ void test_attr1c(TestOwnershipAttr *X) { NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}} } +void testattr2_a() { + TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}} +} + +void testattr2_b() { + TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} +} + +void testattr2_c() { + TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning + [x release]; +} + +void testattr3() { + TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning + [TestOwnershipAttr consume:x]; + TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning + [TestOwnershipAttr consume2:y]; +} + +void consume_ns(id NS_CONSUMED x); +void consume_cf(id CF_CONSUMED x); + +void testattr4() { + TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning + consume_ns(x); + TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning + consume_cf(y); +} + + @interface MyClassTestCFAttr : NSObject {} - (NSDate*) returnsCFRetained CF_RETURNS_RETAINED; - (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED; @@ -1367,3 +1410,46 @@ void r8272168() { GetAClassThatImplementsProt_R8272168(); } +// Test case for , which in the past triggered +// a false positive. +@interface RDar8356342 +- (NSDate*) rdar8356342:(NSDate *)inValue; +@end + +@implementation RDar8356342 +- (NSDate*) rdar8356342:(NSDate*)inValue { + NSDate *outValue = inValue; + if (outValue == 0) + outValue = [[NSDate alloc] init]; // no-warning + + if (outValue != inValue) + [outValue autorelease]; + + return outValue; +} +@end + +// - This test case previously crashed because +// of a bug in BugReporter. +extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); +typedef struct __CFError * CFErrorRef; +extern const CFStringRef kCFErrorUnderlyingErrorKey; +extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err); + +static void rdar_8724287(CFErrorRef error) +{ + CFErrorRef error_to_dump; + + error_to_dump = error; + while (error_to_dump != ((void*)0)) { + CFDictionaryRef info; + + info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object allocated on line 1447 and stored into 'info'}} + + if (info != ((void*)0)) { + } + + error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); + } +} + diff --git a/test/Analysis/security-syntax-checks-no-emit.c b/test/Analysis/security-syntax-checks-no-emit.c index 7a71235..f129e8a 100644 --- a/test/Analysis/security-syntax-checks-no-emit.c +++ b/test/Analysis/security-syntax-checks-no-emit.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-check-security-syntactic %s -verify +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=core.experimental.SecuritySyntactic %s -verify // This file complements 'security-syntax-checks.m', but tests that we omit // specific checks on platforms where they don't make sense. diff --git a/test/Analysis/security-syntax-checks.m b/test/Analysis/security-syntax-checks.m index 8dd859a..bac6ee8 100644 --- a/test/Analysis/security-syntax-checks.m +++ b/test/Analysis/security-syntax-checks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-check-security-syntactic %s -verify +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.SecuritySyntactic %s -verify // rule request: floating point used as loop // condition (FLP30-C, FLP-30-CPP) diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m new file mode 100644 index 0000000..b8c2c3e --- /dev/null +++ b/test/Analysis/self-init.m @@ -0,0 +1,165 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=cocoa.SelfInit %s -verify + +@class NSZone, NSCoder; +@protocol NSObject +@end +@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; +@end +@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; +@end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; +@end +@interface NSObject {} ++ (id)allocWithZone:(NSZone *)zone; ++ (id)alloc; +- (void)dealloc; +-(id)class; +-(id)init; +-(id)release; +@end +@interface NSProxy {} +@end + +//#import "Foundation/NSObject.h" +typedef unsigned NSUInteger; +typedef int NSInteger; + +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@interface NSString : NSObject +- (NSUInteger)length; ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end extern NSString * const NSBundleDidLoadNotification; +@interface NSAssertionHandler : NSObject {} ++ (NSAssertionHandler *)currentHandler; +- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...; +@end +extern NSString * const NSConnectionReplyMode; + +@interface NSBundle : NSObject ++(id)loadNibNamed:(NSString*)s owner:(id)o; +@end + +void log(void *obj); +extern void *somePtr; + +@class MyObj; +static id _commonInit(MyObj *self) { + return self; +} + +@interface MyObj : NSObject { + id myivar; + int myint; +} +-(id)_init; +-(id)initWithSomething:(int)x; +-(void)doSomething; +@end + +@interface MyProxyObj : NSProxy {} +-(id)init; +@end + +@implementation MyObj + +-(id)init { + do { if (!((somePtr != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"init.m"] lineNumber:21 description:(@"Invalid parameter not satisfying: %s"), ("x != 0"), (0), (0), (0), (0)]; } } while(0); + return [self initWithSomething:0]; +} + +-(id)init2 { + self = [self initWithSomething:0]; + return self; +} + +-(id)init3 { + log([self class]); + return [self initWithSomething:0]; +} + +-(id)init4 { + self = [super init]; + if (self) { + log(&self); + } + return self; +} + +- (id)initWithSomething:(int)x { + if ((self = [super init])) + myint = x; + return self; +} + +-(id)_init { + myivar = 0; + return self; +} + +-(id)init5 { + [NSBundle loadNibNamed:@"Window" owner:self]; + return [self initWithSomething:0]; +} + +-(id)init6 { + [NSBundle loadNibNamed:@"Window" owner:myivar]; // no-warning + return [self initWithSomething:0]; +} + +-(id)init7 { + if (0 != (self = [self _init])) + myivar = 0; + return self; +} + +-(id)init8 { + if ((self = [super init])) { + log(&self); + myivar = 0; + } + return self; +} + +-(id)init9 { + [self doSomething]; + return self; // no-warning +} + +-(id)init10 { + myivar = 0; // no-warning + return self; +} + +-(id)init11 { + return self; // no-warning +} + +-(id)init12 { + [super init]; + return self; // expected-warning {{Returning 'self'}} +} + +-(id)init13 { + if (self == [super init]) { + myivar = 0; // expected-warning {{Instance variable used}} + } + return self; // expected-warning {{Returning 'self'}} +} + +-(id)init14 { + if (!(self = [super init])) + return 0; + if (!(self = _commonInit(self))) + return 0; + return self; +} + +-(void)doSomething {} + +@end + +@implementation MyProxyObj + +- (id)init { return self; } + +@end diff --git a/test/Analysis/sizeofpointer.c b/test/Analysis/sizeofpointer.c index 82fda04..6d0a2c4 100644 --- a/test/Analysis/sizeofpointer.c +++ b/test/Analysis/sizeofpointer.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -warn-sizeof-pointer -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.SizeofPtr -verify %s struct s { }; diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c index 342b3b1..0ee8434 100644 --- a/test/Analysis/stack-addr-ps.c +++ b/test/Analysis/stack-addr-ps.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=basic -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrLeak -analyzer-store=basic -fblocks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrLeak -analyzer-store=region -fblocks -verify %s int* f1() { int x = 0; diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index 593ba1d..0c1ffba 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -6,3 +6,89 @@ const int& g() { int s; return s; // expected-warning{{reference to stack memory associated with local variable 's' returned}} } + +const int& g2() { + int s1; + int &s2 = s1; // expected-note {{binding reference variable 's2' here}} + return s2; // expected-warning {{reference to stack memory associated with local variable 's1' returned}} +} + +const int& g3() { + int s1; + int &s2 = s1; // expected-note {{binding reference variable 's2' here}} + int &s3 = s2; // expected-note {{binding reference variable 's3' here}} + return s3; // expected-warning {{reference to stack memory associated with local variable 's1' returned}} +} + +int get_value(); + +const int &get_reference1() { return get_value(); } // expected-warning {{returning reference to local temporary}} + +const int &get_reference2() { + const int &x = get_value(); // expected-note {{binding reference variable 'x' here}} + return x; // expected-warning {{returning reference to local temporary}} +} + +const int &get_reference3() { + const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}} + const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} + return x2; // expected-warning {{returning reference to local temporary}} +} + +int global_var; +int *f1() { + int &y = global_var; + return &y; +} + +int *f2() { + int x1; + int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} + return &x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} +} + +int *f3() { + int x1; + int *const &x2 = &x1; // expected-note {{binding reference variable 'x2' here}} + return x2; // expected-warning {{address of stack memory associated with local variable 'x1' returned}} +} + +const int *f4() { + const int &x1 = get_value(); // expected-note {{binding reference variable 'x1' here}} + const int &x2 = x1; // expected-note {{binding reference variable 'x2' here}} + return &x2; // expected-warning {{returning address of local temporary}} +} + +struct S { + int x; +}; + +int *mf() { + S s1; + S &s2 = s1; // expected-note {{binding reference variable 's2' here}} + int &x = s2.x; // expected-note {{binding reference variable 'x' here}} + return &x; // expected-warning {{address of stack memory associated with local variable 's1' returned}} +} + +void *lf() { + label: + void *const &x = &&label; // expected-note {{binding reference variable 'x' here}} + return x; // expected-warning {{returning address of label, which is local}} +} + +typedef void (^bptr)(void); + +bptr bf(int j) { + __block int i; + const bptr &qq = ^{ i=0; }; // expected-note {{binding reference variable 'qq' here}} + return qq; // expected-error {{returning block that lives on the local stack}} +} + +template +struct TS { + int *get(); + int *m() { + int *&x = get(); + return x; + } +}; diff --git a/test/Analysis/stackaddrleak.c b/test/Analysis/stackaddrleak.c index 39808ed..359e482c 100644 --- a/test/Analysis/stackaddrleak.c +++ b/test/Analysis/stackaddrleak.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=core.StackAddrLeak -analyzer-store region -verify %s char const *p; diff --git a/test/Analysis/stream.c b/test/Analysis/stream.c index 73bbc13..7dfd49b 100644 --- a/test/Analysis/stream.c +++ b/test/Analysis/stream.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-checker=unix.experimental.Stream -analyzer-store region -verify %s typedef __typeof__(sizeof(int)) size_t; typedef struct _IO_FILE FILE; @@ -77,3 +77,9 @@ FILE *f9(void) { void pr7831(FILE *fp) { fclose(fp); // no-warning } + +// PR 8081 - null pointer crash when 'whence' is not an integer constant +void pr8081(FILE *stream, long offset, int whence) { + fseek(stream, offset, whence); +} + diff --git a/test/Analysis/string.c b/test/Analysis/string.c index 35ed710..baf4893 100644 --- a/test/Analysis/string.c +++ b/test/Analysis/string.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-experimental-checks -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.CString -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core.experimental.CString -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core.experimental.CString -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core.experimental.CString -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-store=region -verify %s //===----------------------------------------------------------------------=== // Declarations diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp new file mode 100644 index 0000000..5ed782c --- /dev/null +++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp @@ -0,0 +1,591 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s +// XPASS: * + +class A { +public: + A() {} + ~A() {} + + static A make() { return A(); } + + operator bool() { return false; } + operator int() { return 0; } +}; + +class B { +public: + B() {} + ~B() {} + + operator bool() { return true; } + operator int() { return 1; } + operator A() { return A(); } +}; + +void foo(int); +void foo(bool); +void foo(const A&); + +void test_binary() { + int a = int(A()) + int(B()); + foo(int(A()) + int(B())); + int b; +} + +void test_and() { + bool a = A() && B(); + foo(A() && B()); + int b; +} + +void test_or() { + bool a = A() || B(); + foo(A() || B()); + int b; +} + +void test_cond() { + A a = B() ? A() : A(B()); + if (B()) { foo(0); } else { foo(0); } + int b; +} + +void test_cond_cref() { + const A& a = B() ? A() : A(B()); + foo(B() ? A() : A(B())); + int b; +} + +void test_cond_implicit() { + A a = A() ?: A(); + int b; +} + +void test_cond_implicit_cref() { + const A& a = A() ?: A(); + foo(A() ?: A()); + int b; +} + +void test_copy_init() { + A a = A(); + int b; +} + +void test_cref_init() { + const A& a = A(); + foo(A()); + int b; +} + +void test_call_copy_init() { + A a = A::make(); + int b; +} + +void test_call_cref_init() { + const A& a = A::make(); + foo(A::make()); + int b; +} + +void test_assign() { + int a; + a = A(); + int b; +} + +class TestCtorInits { + int a; + int b; +public: + TestCtorInits(); +}; + +TestCtorInits::TestCtorInits() + : a(int(A()) + int(B())) + , b() {} + +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A() +// CHECK: 2: [B1.1].operator int() +// CHECK: 3: B() +// CHECK: 4: [B1.3].operator int() +// CHECK: 5: int a = int(A().operator int()) + int(B().operator int()); +// CHECK: 6: ~B() (Temporary object destructor) +// CHECK: 7: ~A() (Temporary object destructor) +// CHECK: 8: A() +// CHECK: 9: [B1.8].operator int() +// CHECK: 10: B() +// CHECK: 11: [B1.10].operator int() +// CHECK: 12: foo(int([B1.9]) + int([B1.11])) +// CHECK: 13: ~B() (Temporary object destructor) +// CHECK: 14: ~A() (Temporary object destructor) +// CHECK: 15: int b; +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B10 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B8 +// CHECK: [ B1 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: int b; +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B3 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: [B4.3] && [B5.2] +// CHECK: 2: foo([B3.1]) +// CHECK: T: [B4.3] && ... +// CHECK: Predecessors (2): B5 B4 +// CHECK: Successors (2): B2 B1 +// CHECK: [ B4 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: A() +// CHECK: 3: [B4.2].operator _Bool() +// CHECK: T: [B4.3] && ... +// CHECK: Predecessors (2): B6 B7 +// CHECK: Successors (2): B5 B3 +// CHECK: [ B5 ] +// CHECK: 1: B() +// CHECK: 2: [B5.1].operator _Bool() +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B3 +// CHECK: [ B6 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: [B8.2] && [B9.2] +// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool(); +// CHECK: T: [B8.2] && ... +// CHECK: Predecessors (2): B9 B8 +// CHECK: Successors (2): B6 B4 +// CHECK: [ B8 ] +// CHECK: 1: A() +// CHECK: 2: [B8.1].operator _Bool() +// CHECK: T: [B8.2] && ... +// CHECK: Predecessors (1): B10 +// CHECK: Successors (2): B9 B7 +// CHECK: [ B9 ] +// CHECK: 1: B() +// CHECK: 2: [B9.1].operator _Bool() +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B7 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B10 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B8 +// CHECK: [ B1 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: int b; +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B3 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: [B4.3] || [B5.2] +// CHECK: 2: foo([B3.1]) +// CHECK: T: [B4.3] || ... +// CHECK: Predecessors (2): B5 B4 +// CHECK: Successors (2): B1 B2 +// CHECK: [ B4 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: A() +// CHECK: 3: [B4.2].operator _Bool() +// CHECK: T: [B4.3] || ... +// CHECK: Predecessors (2): B6 B7 +// CHECK: Successors (2): B3 B5 +// CHECK: [ B5 ] +// CHECK: 1: B() +// CHECK: 2: [B5.1].operator _Bool() +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B3 +// CHECK: [ B6 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: [B8.2] || [B9.2] +// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool(); +// CHECK: T: [B8.2] || ... +// CHECK: Predecessors (2): B9 B8 +// CHECK: Successors (2): B4 B6 +// CHECK: [ B8 ] +// CHECK: 1: A() +// CHECK: 2: [B8.1].operator _Bool() +// CHECK: T: [B8.2] || ... +// CHECK: Predecessors (1): B10 +// CHECK: Successors (2): B7 B9 +// CHECK: [ B9 ] +// CHECK: 1: B() +// CHECK: 2: [B9.1].operator _Bool() +// CHECK: Predecessors (1): B8 +// CHECK: Successors (1): B7 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B11 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B10 +// CHECK: [ B1 ] +// CHECK: 1: int b; +// CHECK: 2: [B7.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: foo(0) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: foo(0) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: 2: B() +// CHECK: 3: [B4.2].operator _Bool() +// CHECK: 4: ~B() (Temporary object destructor) +// CHECK: T: if [B4.3] +// CHECK: Predecessors (2): B5 B6 +// CHECK: Successors (2): B3 B2 +// CHECK: [ B5 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B6 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: 3: ~A() (Temporary object destructor) +// CHECK: 4: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: [B10.2] ? [B8.2] : [B9.3] +// CHECK: 2: A a = B().operator _Bool() ? A() : A(B().operator A()); +// CHECK: T: [B10.2] ? ... : ... +// CHECK: Predecessors (2): B8 B9 +// CHECK: Successors (2): B5 B6 +// CHECK: [ B8 ] +// CHECK: 1: A() +// CHECK: 2: [B8.1] (BindTemporary) +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B7 +// CHECK: [ B9 ] +// CHECK: 1: B() +// CHECK: 2: [B9.1].operator A() +// CHECK: 3: A([B9.2]) (BindTemporary) +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B7 +// CHECK: [ B10 ] +// CHECK: 1: B() +// CHECK: 2: [B10.1].operator _Bool() +// CHECK: T: [B10.2] ? ... : ... +// CHECK: Predecessors (1): B11 +// CHECK: Successors (2): B8 B9 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B14 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B13 +// CHECK: [ B1 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: 2: int b; +// CHECK: 3: [B10.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: 3: ~A() (Temporary object destructor) +// CHECK: 4: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: [B7.3] ? [B5.2] : [B6.3] +// CHECK: 2: foo([B4.1]) +// CHECK: T: [B7.3] ? ... : ... +// CHECK: Predecessors (2): B5 B6 +// CHECK: Successors (2): B2 B3 +// CHECK: [ B5 ] +// CHECK: 1: A() +// CHECK: 2: [B5.1] (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B6 ] +// CHECK: 1: B() +// CHECK: 2: [B6.1].operator A() +// CHECK: 3: A([B6.2]) (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: ~B() (Temporary object destructor) +// CHECK: 2: B() +// CHECK: 3: [B7.2].operator _Bool() +// CHECK: T: [B7.3] ? ... : ... +// CHECK: Predecessors (2): B8 B9 +// CHECK: Successors (2): B5 B6 +// CHECK: [ B8 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B7 +// CHECK: [ B9 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: 3: ~B() (Temporary object destructor) +// CHECK: Predecessors (1): B10 +// CHECK: Successors (1): B7 +// CHECK: [ B10 ] +// CHECK: 1: [B13.2] ? [B11.2] : [B12.3] +// CHECK: 2: const A &a = B().operator _Bool() ? A() : A(B().operator A()); +// CHECK: T: [B13.2] ? ... : ... +// CHECK: Predecessors (2): B11 B12 +// CHECK: Successors (2): B8 B9 +// CHECK: [ B11 ] +// CHECK: 1: A() +// CHECK: 2: [B11.1] (BindTemporary) +// CHECK: Predecessors (1): B13 +// CHECK: Successors (1): B10 +// CHECK: [ B12 ] +// CHECK: 1: B() +// CHECK: 2: [B12.1].operator A() +// CHECK: 3: A([B12.2]) (BindTemporary) +// CHECK: Predecessors (1): B13 +// CHECK: Successors (1): B10 +// CHECK: [ B13 ] +// CHECK: 1: B() +// CHECK: 2: [B13.1].operator _Bool() +// CHECK: T: [B13.2] ? ... : ... +// CHECK: Predecessors (1): B14 +// CHECK: Successors (2): B11 B12 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B8 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B7 +// CHECK: [ B1 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: int b; +// CHECK: 3: [B4.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: [B7.2] ?: [B6.2] +// CHECK: 2: A a = A() ?: A(); +// CHECK: T: [B7.3] ? ... : ... +// CHECK: Predecessors (2): B5 B6 +// CHECK: Successors (2): B2 B3 +// CHECK: [ B5 ] +// CHECK: 1: +// CHECK: 2: [B5.1] (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B6 ] +// CHECK: 1: A() +// CHECK: 2: [B6.1] (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: A() +// CHECK: 2: [B7.1] (BindTemporary) +// CHECK: 3: .operator _Bool() +// CHECK: T: [B7.3] ? ... : ... +// CHECK: Predecessors (1): B8 +// CHECK: Successors (2): B5 B6 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B13 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B12 +// CHECK: [ B1 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: int b; +// CHECK: 3: [B9.2].~A() (Implicit destructor) +// CHECK: Predecessors (2): B2 B3 +// CHECK: Successors (1): B0 +// CHECK: [ B2 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B3 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B4 +// CHECK: Successors (1): B1 +// CHECK: [ B4 ] +// CHECK: 1: [B7.3] ?: [B6.2] +// CHECK: 2: foo([B4.1]) +// CHECK: T: [B7.4] ? ... : ... +// CHECK: Predecessors (2): B5 B6 +// CHECK: Successors (2): B2 B3 +// CHECK: [ B5 ] +// CHECK: 1: +// CHECK: 2: [B5.1] (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B6 ] +// CHECK: 1: A() +// CHECK: 2: [B6.1] (BindTemporary) +// CHECK: Predecessors (1): B7 +// CHECK: Successors (1): B4 +// CHECK: [ B7 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: 2: A() +// CHECK: 3: [B7.2] (BindTemporary) +// CHECK: 4: .operator _Bool() +// CHECK: T: [B7.4] ? ... : ... +// CHECK: Predecessors (2): B9 B8 +// CHECK: Successors (2): B5 B6 +// CHECK: [ B8 ] +// CHECK: 1: ~A() (Temporary object destructor) +// CHECK: Predecessors (1): B9 +// CHECK: Successors (1): B7 +// CHECK: [ B9 ] +// CHECK: 1: [B12.2] ?: [B11.2] +// CHECK: 2: const A &a = A() ?: A(); +// CHECK: T: [B12.3] ? ... : ... +// CHECK: Predecessors (2): B10 B11 +// CHECK: Successors (2): B7 B8 +// CHECK: [ B10 ] +// CHECK: 1: +// CHECK: 2: [B10.1] (BindTemporary) +// CHECK: Predecessors (1): B12 +// CHECK: Successors (1): B9 +// CHECK: [ B11 ] +// CHECK: 1: A() +// CHECK: 2: [B11.1] (BindTemporary) +// CHECK: Predecessors (1): B12 +// CHECK: Successors (1): B9 +// CHECK: [ B12 ] +// CHECK: 1: A() +// CHECK: 2: [B12.1] (BindTemporary) +// CHECK: 3: .operator _Bool() +// CHECK: T: [B12.3] ? ... : ... +// CHECK: Predecessors (1): B13 +// CHECK: Successors (2): B10 B11 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A() +// CHECK: 2: A a = A(); +// CHECK: 3: ~A() (Temporary object destructor) +// CHECK: 4: int b; +// CHECK: 5: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A() +// CHECK: 2: const A &a = A(); +// CHECK: 3: A() +// CHECK: 4: foo([B1.3]) +// CHECK: 5: ~A() (Temporary object destructor) +// CHECK: 6: int b; +// CHECK: 7: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A::make() +// CHECK: 2: A a = A::make(); +// CHECK: 3: ~A() (Temporary object destructor) +// CHECK: 4: int b; +// CHECK: 5: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A::make() +// CHECK: 2: const A &a = A::make(); +// CHECK: 3: A::make() +// CHECK: 4: foo([B1.3]) +// CHECK: 5: ~A() (Temporary object destructor) +// CHECK: 6: int b; +// CHECK: 7: [B1.2].~A() (Implicit destructor) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: int a; +// CHECK: 2: A() +// CHECK: 3: [B1.2].operator int() +// CHECK: 4: a = [B1.3] +// CHECK: 5: ~A() (Temporary object destructor) +// CHECK: 6: int b; +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): +// CHECK: [ B2 (ENTRY) ] +// CHECK: Predecessors (0): +// CHECK: Successors (1): B1 +// CHECK: [ B1 ] +// CHECK: 1: A() +// CHECK: 2: [B1.1].operator int() +// CHECK: 3: B() +// CHECK: 4: [B1.3].operator int() +// CHECK: 5: a(int([B1.2]) + int([B1.4])) (Member initializer) +// CHECK: 6: ~B() (Temporary object destructor) +// CHECK: 7: ~A() (Temporary object destructor) +// CHECK: 8: b(/*implicit*/int()) (Member initializer) +// CHECK: Predecessors (1): B2 +// CHECK: Successors (1): B0 +// CHECK: [ B0 (EXIT) ] +// CHECK: Predecessors (1): B1 +// CHECK: Successors (0): diff --git a/test/Analysis/uninit-msg-expr.m b/test/Analysis/uninit-msg-expr.m index 4061150..a8e2f1b 100644 --- a/test/Analysis/uninit-msg-expr.m +++ b/test/Analysis/uninit-msg-expr.m @@ -42,7 +42,7 @@ extern NSString * const NSUndoManagerCheckpointNotification; unsigned f1() { NSString *aString; - return [aString length]; // expected-warning {{Receiver in message expression is a garbage value}} + return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value}} } unsigned f2() { @@ -53,5 +53,5 @@ unsigned f2() { void f3() { NSMutableArray *aArray = [NSArray array]; NSString *aString; - [aArray addObject:aString]; // expected-warning {{Pass-by-value argument in message expression is undefined.}} + [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}} } diff --git a/test/Analysis/uninit-ps-rdar6145427.m b/test/Analysis/uninit-ps-rdar6145427.m index 1409dbd..ccaf2e8 100644 --- a/test/Analysis/uninit-ps-rdar6145427.m +++ b/test/Analysis/uninit-ps-rdar6145427.m @@ -30,7 +30,7 @@ extern NSString * const NSUndoManagerCheckpointNotification; int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - id someUnintializedPointer = [someUnintializedPointer objectAtIndex:0]; // expected-warning{{Receiver in message expression is a garbage value}} + id someUnintializedPointer = [someUnintializedPointer objectAtIndex:0]; // expected-warning{{Receiver in message expression is an uninitialized value}} NSLog(@"%@", someUnintializedPointer); [pool drain]; return 0; diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m index 751e91b..2b3b027 100644 --- a/test/Analysis/uninit-vals-ps-region.m +++ b/test/Analysis/uninit-vals-ps-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-check-idempotent-operations -verify %s +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -analyzer-checker=core.experimental.IdempotentOps -verify %s struct s { int data; diff --git a/test/Analysis/uninit-vals-ps.c b/test/Analysis/uninit-vals-ps.c index 4abd413..9e53fbc 100644 --- a/test/Analysis/uninit-vals-ps.c +++ b/test/Analysis/uninit-vals-ps.c @@ -15,7 +15,7 @@ int f1_a(struct FPRec* foo) { int f1_b() { int x; - return bar(x)+1; // expected-warning{{Pass-by-value argument in function call is undefined.}} + return bar(x)+1; // expected-warning{{Function call argument is an uninitialized value}} } int f2() { diff --git a/test/Analysis/uninit-vals.c b/test/Analysis/uninit-vals.c index b0769ba..e4395e8 100644 --- a/test/Analysis/uninit-vals.c +++ b/test/Analysis/uninit-vals.c @@ -32,7 +32,7 @@ void f6(int i) { int x; for (i = 0 ; i < 10; i++) printf("%d",x++); // expected-warning {{use of uninitialized variable}} \ - // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \ + // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \ // expected-note{{please include the header or explicitly provide a declaration for 'printf'}} } diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c index 9d036ac..9f5362d 100644 --- a/test/Analysis/unix-fns.c +++ b/test/Analysis/unix-fns.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem %s -analyzer-store=region -fblocks -verify -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic -fblocks -verify +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-checker=unix.API -analyzer-checker=macosx.API %s -analyzer-store=region -fblocks -verify +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-checker=unix.API -analyzer-checker=macosx.API %s -analyzer-store=basic -fblocks -verify struct _opaque_pthread_once_t { long __sig; @@ -8,6 +8,9 @@ struct _opaque_pthread_once_t { typedef struct _opaque_pthread_once_t __darwin_pthread_once_t; typedef __darwin_pthread_once_t pthread_once_t; int pthread_once(pthread_once_t *, void (*)(void)); +typedef long unsigned int __darwin_size_t; +typedef __darwin_size_t size_t; +void *malloc(size_t); typedef void (^dispatch_block_t)(void); typedef long dispatch_once_t; @@ -50,3 +53,17 @@ void test_pthread_once_neg() { static pthread_once_t pred = {0x30B1BCBA, {0}}; pthread_once(&pred, test_pthread_once_aux); // no-warning } + +// PR 2899 - warn of zero-sized allocations to malloc(). +void pr2899() { + char* foo = malloc(0); // expected-warning{{Call to 'malloc' has an allocation size of 0 bytes}} + for (unsigned i = 0; i < 100; i++) { + foo[i] = 0; + } +} +void pr2899_nowarn(size_t size) { + char* foo = malloc(size); // no-warning + for (unsigned i = 0; i < 100; i++) { + foo[i] = 0; + } +} diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c index 0715327..52e6d3d 100644 --- a/test/Analysis/unreachable-code-path.c +++ b/test/Analysis/unreachable-code-path.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -verify -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s extern void foo(int a); @@ -93,8 +93,8 @@ void test9(unsigned a) { switch (a) { if (a) // expected-warning{{never executed}} foo(a + 5); // no-warning - else // no-warning - foo(a); // no-warning + else // no-warning + foo(a); // no-warning case 1: case 2: break; @@ -102,3 +102,23 @@ void test9(unsigned a) { break; } } + +// Tests from flow-sensitive version +void test10() { + goto c; + d: + goto e; // expected-warning {{never executed}} + c: ; + int i; + return; + goto b; // expected-warning {{never executed}} + goto a; // expected-warning {{never executed}} + b: + i = 1; // no-warning + a: + i = 2; // no-warning + goto f; + e: + goto d; + f: ; +} diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index 14c43a8..b43ae18 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-check-objc-unused-ivars %s -verify +// RUN: %clang_cc1 -fobjc-nonfragile-abi -fblocks -analyze -analyzer-checker=cocoa.UnusedIvars %s -verify //===--- BEGIN: Delta-debugging reduced headers. --------------------------===// @@ -95,4 +95,16 @@ int radar_7254495(RDar7254495 *a) { @implementation RDar7353683 @end +//===----------------------------------------------------------------------===// +// Unused bitfield ivars trigger cause weird +// diagnostic: "Instance variable '' in class…" +//===----------------------------------------------------------------------===// +@interface RDar8481311 { +@private + unsigned bitfield:1; // expected-warning {{Instance variable 'bitfield' in class 'RDar8481311' is never used}} +} +@end + +@implementation RDar8481311 +@end diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 611867f..a32b994 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,7 @@ set(CLANG_TEST_DIRECTORIES "CodeGen" "CodeGenCXX" "CodeGenObjC" + "CodeGenOpenCL" "Coverage" "CXX" "Driver" @@ -18,27 +19,45 @@ set(CLANG_TEST_DIRECTORIES "Preprocessor" "Rewriter" "Sema" + "SemaCUDA" "SemaCXX" "SemaObjC" "SemaObjCXX" + "SemaOpenCL" "SemaTemplate") set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}") set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") +set(LLVM_BUILD_MODE "%(build_mode)s") set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s") set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") +if(BUILD_SHARED_LIBS) + set(ENABLE_SHARED 1) +else() + set(ENABLE_SHARED 0) +endif(BUILD_SHARED_LIBS) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + @ONLY) + include(FindPythonInterp) if(PYTHONINTERP_FOUND) - set(CLANG_TEST_EXTRA_ARGS) - if (MSVC OR XCODE) - set(CLANG_TEST_EXTRA_ARGS "--no-progress-bar") + if( LLVM_MAIN_SRC_DIR ) + set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py") + else() + set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") + endif() + + if( PATH_TO_LLVM_BUILD ) + set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") endif() option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) @@ -46,13 +65,18 @@ if(PYTHONINTERP_FOUND) set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") endif () + set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") + separate_arguments(LIT_ARGS) + + add_custom_target(clang-test.deps) + foreach(testdir ${CLANG_TEST_DIRECTORIES}) add_custom_target(clang-test-${testdir} COMMAND ${PYTHON_EXECUTABLE} - ${LLVM_SOURCE_DIR}/utils/lit/lit.py + ${LIT} --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg --param build_config=${CMAKE_CFG_INTDIR} - -sv ${CLANG_TEST_EXTRA_ARGS} + ${LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR}/${testdir} DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests in ${testdir}") @@ -60,21 +84,47 @@ if(PYTHONINTERP_FOUND) add_custom_target(clang-test COMMAND ${PYTHON_EXECUTABLE} - ${LLVM_SOURCE_DIR}/utils/lit/lit.py + ${LIT} --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg --param build_config=${CMAKE_CFG_INTDIR} - -sv ${CLANG_TEST_EXTRA_ARGS} + --param build_mode=${RUNTIME_BUILD_MODE} + ${LIT_ARGS} ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests") add_custom_target(clang-c++tests COMMAND ${PYTHON_EXECUTABLE} - ${LLVM_SOURCE_DIR}/utils/lit/lit.py + ${LIT} --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg --param build_config=${CMAKE_CFG_INTDIR} - -sv ${CLANG_TEST_EXTRA_ARGS} + ${LIT_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests DEPENDS clang c-index-test FileCheck not count COMMENT "Running Clang regression tests") + + if( NOT CLANG_BUILT_STANDALONE ) + add_custom_target(check-all + COMMAND ${PYTHON_EXECUTABLE} + ${LIT} + --param build_config=${CMAKE_CFG_INTDIR} + --param build_mode=${RUNTIME_BUILD_MODE} + ${LIT_ARGS} + ${LLVM_BINARY_DIR}/test + ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running Clang and LLVM regression tests") + add_dependencies(check-all check.deps clang-test.deps) + add_dependencies(clang-test.deps + ClangUnitTests + llvm-dis opt + FileCheck count not + ) + + endif() + + add_dependencies(clang-test clang-test.deps) + add_dependencies(clang-test.deps + clang clang-headers c-index-test + ) + endif() diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp index df3429e..1e5a823 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp @@ -44,7 +44,7 @@ namespace Test { // PR6716 namespace test1 { template class A { - template friend void foo(A &, U); // expected-note {{not viable: 1st argument ('A const') would lose const qualifier}} + template friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A') would lose const qualifier}} }; void test() { diff --git a/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp b/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp new file mode 100644 index 0000000..911df98 --- /dev/null +++ b/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar4641403 +namespace N { + struct X { // expected-note{{candidate found by name lookup}} + float b; + }; +} + +using namespace N; + +typedef struct { + int a; +} X; // expected-note{{candidate found by name lookup}} + + +struct Y { }; +void Y(int) { } + +void f() { + X *x; // expected-error{{reference to 'X' is ambiguous}} + Y(1); // okay +} + diff --git a/test/CXX/basic/basic.start/basic.start.main/p2h.cpp b/test/CXX/basic/basic.start/basic.start.main/p2h.cpp new file mode 100644 index 0000000..abf8faa --- /dev/null +++ b/test/CXX/basic/basic.start/basic.start.main/p2h.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +int main() { } // expected-error{{'main' cannot be a template}} + diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 277b70b..1668155 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -258,13 +258,12 @@ namespace test7 { namespace test8 { class A { typedef int I; // expected-note 4 {{declared private here}} - static const I x = 0; + static const I x = 0; // expected-note {{implicitly declared private here}} friend I f(I i); template friend I g(I i); }; - // FIXME: This should be on line 264. - const A::I A::x; // expected-note {{declared private here}} + const A::I A::x; A::I f(A::I i = A::x) {} template A::I g(A::I i) { T t; @@ -306,3 +305,39 @@ namespace test10 { NS::bar->foo(); // expected-error {{private member}} } } + +// PR8705 +namespace test11 { + class A { + void test0(int); + void test1(int); + void test2(int); + void test3(int); + }; + + class B { + typedef int private_type; // expected-note 2 {{implicitly declared private here}} + friend void A::test0(int); + friend void A::test1(int); + }; + + void A::test0(B::private_type x) {} + void A::test1(int x = B::private_type()) {} + void A::test2(B::private_type x) {} // expected-error {{'private_type' is a private member of 'test11::B'}} + void A::test3(int x = B::private_type()) {} // expected-error {{'private_type' is a private member of 'test11::B'}} +} + + +// PR9221 +namespace test12 { + struct A { + void foo(); + }; + class B : private A { + friend void A::foo(); + void *mem; + }; + void A::foo() { + void *var = static_cast(this)->mem; + } +} diff --git a/test/CXX/class.access/class.friend/p11.cpp b/test/CXX/class.access/class.friend/p11.cpp new file mode 100644 index 0000000..a05b2d2 --- /dev/null +++ b/test/CXX/class.access/class.friend/p11.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// rdar://problem/8540720 +namespace test0 { + void foo() { + void bar(); + class A { + friend void bar(); + }; + } +} + +namespace test1 { + void foo() { + class A { + friend void bar(); // expected-error {{no matching function found in local scope}} + }; + } +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 115a22a..84b7b19 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s // C++0x [class.access]p4: @@ -201,7 +201,7 @@ namespace test4 { // Implicit copy assignment operator uses. namespace test5 { class A { - void operator=(const A &); // expected-note 2 {{declared private here}} + void operator=(const A &); // expected-note 2 {{implicitly declared private here}} }; class Test1 { A a; }; // expected-error {{private member}} @@ -450,3 +450,61 @@ namespace test18 { A member; }; } + +// PR8325 +namespace test19 { + class A { ~A(); }; + // The destructor is not implicitly referenced here. Contrast to test16, + // testing PR7281, earlier in this file. + void b(A* x) { throw x; } +} + +// PR7930 +namespace test20 { + class Foo { + Foo(); // expected-note {{implicitly declared private here}} + }; + Foo::Foo() {} + + void test() { + Foo a; // expected-error {{calling a private constructor}} + } +} + +namespace test21 { + template class A { + void foo(); + void bar(); + class Inner; // expected-note {{implicitly declared private here}} + public: + void baz(); + }; + template class A::Inner {}; + class B { + template class A::Inner; + }; + + void test() { + A::Inner i; // expected-error {{'Inner' is a private member}} + } +} + +namespace rdar8876150 { + struct A { operator bool(); }; + struct B : private A { using A::operator bool; }; + + bool f() { + B b; + return !b; + } +} + +namespace test23 { + template class A { + A(); + static A instance; + }; + + template A A::instance; + template class A; +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index 8795708..fe3304a 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -139,3 +139,32 @@ namespace test5 { template class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} }; } + +namespace test6 { + class A { + public: class public_inner {}; + protected: class protected_inner {}; + private: class private_inner {}; // expected-note {{declared private here}} + }; + + class B : A { + public_inner a; + protected_inner b; + private_inner c; // expected-error {{ 'private_inner' is a private member of 'test6::A'}} + }; +} + +// PR9229 +namespace test7 { + void foo(int arg[1]); + class A { + void check(); + }; + class B { + friend class A; + A ins; + }; + void A::check() { + void foo(int arg[__builtin_offsetof(B, ins)]); + } +} diff --git a/test/CXX/class.derived/class.abstract/p4.cpp b/test/CXX/class.derived/class.abstract/p4.cpp index ca99bf7..b04de21 100644 --- a/test/CXX/class.derived/class.abstract/p4.cpp +++ b/test/CXX/class.derived/class.abstract/p4.cpp @@ -24,7 +24,7 @@ namespace PR6631 { // subobject but not pure in another subobject. namespace PartlyPure { struct A { - virtual void f() = 0; // expected-note{{pure virtual function}} + virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} }; struct B : A { @@ -36,7 +36,7 @@ namespace PartlyPure { struct D : B, C { }; void f() { - (void) new D; // expected-error{{abstract type}} + (void) new D; // expected-error{{abstract class}} } } diff --git a/test/CXX/class.derived/class.abstract/p5.cpp b/test/CXX/class.derived/class.abstract/p5.cpp index 207519d..cdff931 100644 --- a/test/CXX/class.derived/class.abstract/p5.cpp +++ b/test/CXX/class.derived/class.abstract/p5.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s struct A { - virtual void f() = 0; // expected-note{{pure virtual function}} + virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} }; struct B : A { @@ -9,15 +9,15 @@ struct B : A { }; struct C : B { - virtual void f() = 0; // expected-note 2{{pure virtual function}} + virtual void f() = 0; // expected-note 2{{unimplemented pure virtual method}} }; struct D : C { }; void test() { - (void)new A; // expected-error{{object of abstract type}} + (void)new A; // expected-error{{abstract class}} (void)new B; - (void)new C; // expected-error{{object of abstract type}} - (void)new D; // expected-error{{object of abstract type}} + (void)new C; // expected-error{{abstract class}} + (void)new D; // expected-error{{abstract class}} } diff --git a/test/CXX/class.derived/class.member.lookup/p9.cpp b/test/CXX/class.derived/class.member.lookup/p9.cpp new file mode 100644 index 0000000..ba7bd21 --- /dev/null +++ b/test/CXX/class.derived/class.member.lookup/p9.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace rdar8436162 { + class ClsA { + public: + static void f(); + void g(); + }; + + class ClsB : virtual private ClsA { + public: + using ClsA::f; + using ClsA::g; // expected-note{{member found by ambiguous name lookup}} + }; + + class ClsF : virtual private ClsA { + public: + using ClsA::f; + using ClsA::g; // expected-note{{member found by ambiguous name lookup}} + }; + + class ClsE : public ClsB, public ClsF { + void test() { + f(); + g(); // expected-error{{member 'g' found in multiple base classes of different types}} + } + }; +} diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp new file mode 100644 index 0000000..4bd9efd --- /dev/null +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +namespace Test1 { + +struct B { + virtual void f(int); +}; + +struct D : B { + virtual void f(long) override; // expected-error {{'f' marked 'override' but does not override any member functions}} + void f(int) override; +}; +} + +namespace Test2 { + +struct A { + virtual void f(int, char, int); +}; + +template +struct B : A { + virtual void f(T) override; +}; + +} + +namespace Test3 { + +struct A { + virtual void f(int, char, int); +}; + +template +struct B : A { + virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} +}; + +template struct B; +template struct B; // expected-note {{in instantiation of template class 'Test3::B' requested here}} + +} + +namespace Test4 { +struct B { + virtual void f() const final; // expected-note {{overridden virtual function is here}} +}; + +struct D : B { + void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}} +}; + +} diff --git a/test/CXX/class.derived/p8-0x.cpp b/test/CXX/class.derived/p8-0x.cpp new file mode 100644 index 0000000..6a667f7 --- /dev/null +++ b/test/CXX/class.derived/p8-0x.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++0x + +namespace Test1 { + +struct A { + virtual void f(); // expected-note {{overridden virtual function is here}} +}; + +struct B explicit : A { + virtual void f(); // expected-error {{overrides function without being marked 'override'}} +}; + +struct C { + virtual ~C(); +}; + +struct D explicit : C { + virtual ~D(); +}; + +} + diff --git a/test/CXX/class/class.friend/p1.cpp b/test/CXX/class/class.friend/p1.cpp index 3ad4a5f..bb1af10 100644 --- a/test/CXX/class/class.friend/p1.cpp +++ b/test/CXX/class/class.friend/p1.cpp @@ -57,7 +57,8 @@ class A { friend A operator|(const A& l, const A& r); // okay friend A operator|(const A& r); // expected-error {{ overloaded 'operator|' must be a binary operator (has 1 parameter) }} - friend operator bool() const; // expected-error {{ must use a qualified name when declaring a conversion operator as a friend }} + friend operator bool() const; // expected-error {{ must use a qualified name when declaring a conversion operator as a friend }} \ + // expected-error{{type qualifier is not allowed on this function}} typedef void ftypedef(); friend ftypedef typedeffed_function; // okay (because it's not declared as a member) diff --git a/test/CXX/class/class.mem/p1.cpp b/test/CXX/class/class.mem/p1.cpp index 55507d4..a41f1db 100644 --- a/test/CXX/class/class.mem/p1.cpp +++ b/test/CXX/class/class.mem/p1.cpp @@ -62,3 +62,30 @@ struct S5 }; + +namespace PR8245 { + class X { + public: + template + class Inner { + public: + void foo(bool bar = true); + int bam; + }; + + Inner _foo; + }; + + void f() { + X::Inner c2i; + X::Inner c2f; + c2i.foo(); + c2f.foo(); + } + + class Y { + class Inner { + void foo(int = sizeof(Y)); + }; + }; +} diff --git a/test/CXX/class/class.mem/p13.cpp b/test/CXX/class/class.mem/p13.cpp new file mode 100644 index 0000000..7cded23 --- /dev/null +++ b/test/CXX/class/class.mem/p13.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// If T is the name of a class, then each of the following shall have +// a name different from T: + +// - every static data member of class T; +struct X0 { + static int X0; // expected-error{{member 'X0' has the same name as its class}} +}; + +// - every member function of class T +// (Cannot be tested) + +// - every member of class T that is itself a type; +struct X1 { // expected-note{{previous use is here}} + enum X1 { }; // expected-error{{use of 'X1' with tag type that does not match previous declaration}} +}; + +struct X2 { + typedef int X2; // expected-error{{member 'X2' has the same name as its class)}} +}; + +// - every enumerator of every member of class T that is an enumerated type; and +struct X3 { + enum E { + X3 // expected-error{{member 'X3' has the same name as its class}} + }; +}; + +// - every member of every anonymous union that is a member of class T. +struct X4 { + union { + int X; + union { + float Y; + unsigned X4; // expected-error{{member 'X4' has the same name as its class}} + }; + }; +}; + diff --git a/test/CXX/class/class.mem/p14.cpp b/test/CXX/class/class.mem/p14.cpp new file mode 100644 index 0000000..72b232e --- /dev/null +++ b/test/CXX/class/class.mem/p14.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// In addition, if class T has a user-declared constructor (12.1), +// every non-static data member of class T shall have a name different +// from T. + +struct X0 { + int X0; // okay +}; + +struct X1 { + int X1; + X1(); // expected-error{{declarator requires an identifier}} +}; + +struct X2 { + X2(); + float X2; // expected-error{{member 'X2' has the same name as its class}} +}; diff --git a/test/CXX/class/class.mem/p1b.cpp b/test/CXX/class/class.mem/p1b.cpp new file mode 100644 index 0000000..d3493f6 --- /dev/null +++ b/test/CXX/class/class.mem/p1b.cpp @@ -0,0 +1,46 @@ +// The first run checks that the correct errors are generated, +// implicitly checking the order of default argument parsing: +// RUN: %clang_cc1 -fsyntax-only -verify %s +// The second run checks the order of inline method definitions: +// RUN: not %clang_cc1 -fsyntax-only %s 2> %t +// RUN: FileCheck %s < %t + +class A { +public: + void a1() { + B b = B(); + } + + class B; + void a2(B b = B()); // expected-error{{use of default argument to function 'B' that is declared later in class 'B'}} + + void a3(int a = 42); + + // CHEKC: error: use of undeclared identifier 'first' + void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}} + + class B { + public: + B(int b = 42) { // expected-note{{default argument declared here}} + A a; + a.a3(); + a.a6(); + } + + void b1(A a = A()); // expected-error{{use of default argument to function 'A' that is declared later in class 'A'}} + + // CHECK: error: use of undeclared identifier 'second' + void b2(int a = second); // expected-error{{use of undeclared identifier 'second'}} + }; + + void a5() { + B b = B(); + } + + void a6(B b = B()); + + A(int a = 42); // expected-note{{default argument declared here}} + + // CHECK: error: use of undeclared identifier 'third' + void a7(int a = third); // expected-error{{use of undeclared identifier 'third'}} +}; diff --git a/test/CXX/class/class.mem/p8-0x-pedantic.cpp b/test/CXX/class/class.mem/p8-0x-pedantic.cpp new file mode 100644 index 0000000..a4b775c --- /dev/null +++ b/test/CXX/class/class.mem/p8-0x-pedantic.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -pedantic -verify %s + +namespace inline_extension { + struct Base1 { + virtual void f() {} + }; + + struct B : Base1 { + virtual void f() override {} // expected-warning {{'override' keyword only allowed in declarations, allowed as an extension}} + virtual void g() final {} // expected-warning {{'final' keyword only allowed in declarations, allowed as an extension}} + virtual void h() new {} // expected-warning {{'new' keyword only allowed in declarations, allowed as an extension}} + }; +} + diff --git a/test/CXX/class/class.mem/p8-0x.cpp b/test/CXX/class/class.mem/p8-0x.cpp new file mode 100644 index 0000000..bf1b4c1 --- /dev/null +++ b/test/CXX/class/class.mem/p8-0x.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +struct Base1 { + virtual void g(); +}; + +struct A : Base1 { + virtual void f() new new; // expected-error {{class member already marked 'new'}} + virtual void g() override override; // expected-error {{class member already marked 'override'}} + virtual void h() final final; // expected-error {{class member already marked 'final'}} +}; + +struct Base2 { + virtual void e1(), e2(); + virtual void f(); +}; + +struct B : Base2 { + virtual void e1() override, e2(int); // No error. + virtual void f() override; + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + int h override; // expected-error {{only virtual member functions can be marked 'override'}} +}; + +struct C { + virtual void f() final; + void g() final; // expected-error {{only virtual member functions can be marked 'final'}} + int h final; // expected-error {{only virtual member functions can be marked 'final'}} +}; + +namespace inline_extension { + struct Base1 { + virtual void g() {} + }; + + struct A : Base1 { + virtual void f() new new {} // expected-error {{class member already marked 'new'}} + virtual void g() override override {} // expected-error {{class member already marked 'override'}} + virtual void h() final final {} // expected-error {{class member already marked 'final'}} + }; + + struct Base2 { + virtual void f(); + }; + + struct B : Base2 { + virtual void f() override {} + void g() override {} // expected-error {{only virtual member functions can be marked 'override'}} + }; + + struct C { + virtual void f() final {} + void g() final {} // expected-error {{only virtual member functions can be marked 'final'}} + }; +} diff --git a/test/CXX/class/class.nest/p1-cxx0x.cpp b/test/CXX/class/class.nest/p1-cxx0x.cpp new file mode 100644 index 0000000..f8b06ac --- /dev/null +++ b/test/CXX/class/class.nest/p1-cxx0x.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +class Outer { + int x; + static int sx; + int f(); + + // The first case is invalid in the C++03 mode but valid in C++0x (see 5.1.1.10). + class Inner { + static char a[sizeof(x)]; // okay + static char b[sizeof(sx)]; // okay + static char c[sizeof(f)]; // expected-error {{ call to non-static member function without an object argument }} + }; +}; diff --git a/test/CXX/class/class.nest/p1.cpp b/test/CXX/class/class.nest/p1.cpp index f1f5496..350cc81 100644 --- a/test/CXX/class/class.nest/p1.cpp +++ b/test/CXX/class/class.nest/p1.cpp @@ -3,12 +3,12 @@ class Outer { int x; static int sx; + int f(); - // C++0x will likely relax this rule in this specific case, but - // we'll still need to enforce it in C++03 mode. See N2253 (or - // successor). + // C++0x does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode. class Inner { static char a[sizeof(x)]; // expected-error {{ invalid use of nonstatic data member 'x' }} static char b[sizeof(sx)]; // okay + static char c[sizeof(f)]; // expected-error {{ call to non-static member function without an object argument }} }; }; diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp index e974d82..b5dd4df 100644 --- a/test/CXX/class/class.union/p1.cpp +++ b/test/CXX/class/class.union/p1.cpp @@ -90,6 +90,14 @@ union U3 { } m7; }; +union U4 { + static int i1; // expected-error {{static data member 'i1' not allowed in union}} +}; + +union U5 { + int& i1; // expected-error {{union member 'i1' has reference type 'int &'}} +}; + template struct Either { bool tag; union { diff --git a/test/CXX/class/p1-0x.cpp b/test/CXX/class/p1-0x.cpp new file mode 100644 index 0000000..5851de6 --- /dev/null +++ b/test/CXX/class/p1-0x.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +namespace Test1 { + +class A final { }; +class B explicit { }; +class C final explicit { }; +class D final final { }; // expected-error {{class already marked 'final'}} +class E explicit explicit { }; // expected-error {{class already marked 'explicit'}} + +} diff --git a/test/CXX/class/p2-0x.cpp b/test/CXX/class/p2-0x.cpp new file mode 100644 index 0000000..630aa7e --- /dev/null +++ b/test/CXX/class/p2-0x.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +namespace Test1 { + +class A final { }; // expected-note {{'A' declared here}} +class B : A { }; // expected-error {{base 'A' is marked 'final'}} + +} + +namespace Test2 { + +template struct A final { }; // expected-note 2 {{'A' declared here}} +struct B : A { }; // expected-error {{base 'A' is marked 'final'}} + +template struct C : A { }; // expected-error {{base 'A' is marked 'final'}} +struct D : C { }; // expected-note {{in instantiation of template class 'Test2::C' requested here}} + +} + +namespace Test3 { + +template struct A { }; +template<> struct A final { }; // expected-note {{'A' declared here}} + +struct B : A { }; +struct C : A { }; // expected-error {{base 'A' is marked 'final'}} + +} + diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp index ddcbe78..069ca0a 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only %s -verify // C++'0x [namespace.memdef] p3: // Every name first declared in a namespace is a member of that namespace. If @@ -66,3 +66,28 @@ namespace N3 { } // FIXME: Woefully inadequate for testing + +// Friends declared as template-ids aren't subject to the restriction +// on innermost namespaces. +// rdar://problem/8552377 +namespace test5 { + template void f(T); + namespace ns { + class A { + friend void f(int); + static void foo(); // expected-note 2 {{declared private here}} + }; + + // Note that this happens without instantiation. + template void f(T) { + A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} + } + } + + template void f(T) { + ns::A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} + } + + template void f(int); + template void f(long); //expected-note {{instantiation}} +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp new file mode 100644 index 0000000..411c16c --- /dev/null +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// PR8430 +namespace N { + class A { }; +} + +namespace M { } + +using namespace M; + +namespace N { + namespace M { + } +} + +namespace M { + namespace N { + } +} + +namespace N { + A *getA(); +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp index bb1d67f..634369d 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp @@ -89,6 +89,7 @@ namespace test2 { namespace test3 { class A { + public: ~A(); }; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index 082a32d..24780c6 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x void f() { auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}} + auto *b = b; // expected-error{{variable 'b' declared with 'auto' type cannot appear in its own initializer}} + const auto c = c; // expected-error{{variable 'c' declared with 'auto' type cannot appear in its own initializer}} } void g() { @@ -8,3 +10,32 @@ void g() { auto *b; // expected-error{{declaration of variable 'b' with type 'auto *' requires an initializer}} } + +auto n(1,2,3); // expected-error{{initializer for variable 'n' with type 'auto' contains multiple expressions}} + +namespace N +{ + auto a = "const char [16]", *p = &a; +} + +void h() { + auto b = 42ULL; + + for (auto c = 0; c < 100; ++c) { + } +} + +template struct same; +template struct same {}; + +void p3example() { + auto x = 5; + const auto *v = &x, u = 6; + static auto y = 0.0; + auto int r; // expected-error{{cannot combine with previous}} expected-error{{requires an initializer}} + + same xHasTypeInt; + same vHasTypeConstIntPtr; + same uHasTypeConstInt; + same yHasTypeDouble; +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp new file mode 100644 index 0000000..34a1784 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x + +template +struct only { + only(T); + template only(U) = delete; +}; + +void f() { + if (auto a = true) { + } + + switch (auto a = 0) { + } + + while (auto a = false) { + } + + for (; auto a = false; ) { + } + + new const auto (0); + new (auto) (0.0); + +#if 0 + // When clang supports for-range: + for (auto i : {1,2,3}) { + } + + // When clang supports inline initialization of members. + class X { + static const auto &n = 'x'; + }; +#endif +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp index e739254..836ccda 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp @@ -1,13 +1,72 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x -void f() { - auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}} +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s -std=c++0x + +struct S { + virtual ~S(); + + auto a; // expected-error{{'auto' not allowed in struct member}} + auto *b; // expected-error{{'auto' not allowed in struct member}} + const auto c; // expected-error{{'auto' not allowed in struct member}} + + void f() throw (auto); // expected-error{{'auto' not allowed here}} + + friend auto; // expected-error{{'auto' not allowed in struct member}} + + operator auto(); // expected-error{{'auto' not allowed here}} +}; + +void g(auto a) { // expected-error{{'auto' not allowed in function prototype}} + try { } + catch (auto &a) { } // expected-error{{'auto' not allowed in exception declaration}} + catch (const auto a) { } // expected-error{{'auto' not allowed in exception declaration}} + try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}} +} + +void h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}} } -struct S { auto a; }; // expected-error{{'auto' not allowed in struct member}} +void i(const auto a) { // expected-error{{'auto' not allowed in function prototype}} +} -void f(auto a) // expected-error{{'auto' not allowed in function prototype}} -{ - try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}} +namespace std { + class type_info; +} + +template struct U {}; + +void j() { + (void)typeid(auto); // expected-error{{'auto' not allowed here}} + (void)sizeof(auto); // expected-error{{'auto' not allowed here}} + (void)__alignof(auto); // expected-error{{'auto' not allowed here}} + + // FIXME: don't issue the second diagnostic for this error. + U v; // expected-error{{'auto' not allowed in template argument}} unexpected-error{{C++ requires a type specifier}} + + int n; + (void)dynamic_cast(S()); // expected-error{{'auto' not allowed here}} + (void)static_cast(&n); // expected-error{{'auto' not allowed here}} + (void)reinterpret_cast(&n); // expected-error{{'auto' not allowed here}} + (void)const_cast(n); // expected-error{{'auto' not allowed here}} + (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}} + (void)auto(n); // expected-error{{expected expression}} + (void)auto{n}; // expected-error{{expected expression}} } template class C { }; // expected-error{{'auto' not allowed in template parameter}} +int ints[] = {1, 2, 3}; +template class D { }; // expected-error{{'auto' not allowed in template parameter}} +enum E : auto {}; // expected-error{{'auto' not allowed here}} +struct F : auto {}; // expected-error{{expected class name}} +template struct G { }; // expected-error{{'auto' not allowed here}} + +using A = auto; // expected-error{{expected ';'}} expected-error{{requires a qualified name}} + +// Whether this is illegal depends on the interpretation of [decl.spec.auto]p2 and p3, +// and in particular the "Otherwise, ..." at the start of p3. +namespace TrailingReturnType { + // FIXME: don't issue the second diagnostic for this error. + auto f() -> auto; // expected-error{{'auto' not allowed here}} unexpected-error{{without trailing return type}} + int g(); + auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed here}} + auto (*i)() = &g; // ok; auto deduced as int. + auto (*j)() -> int = i; // ok; no deduction. +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp new file mode 100644 index 0000000..06aeaa6 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp @@ -0,0 +1,86 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x + +template +struct only { + only(T); + template only(U) = delete; +}; + +namespace N +{ + auto a = "const char [16]", *p = &a; + + only testA = a; + only testP = p; +} + +void h() { + auto b = 42ULL; + only testB = b; + + for (auto c = 0; c < 100; ++c) { + only testC = c; + } +} + +void p3example() { + auto x = 5; + const auto *v = &x, u = 6; + static auto y = 0.0; + + only testX = x; + only testV = v; + only testU = u; + only testY = y; +} + +void f() { + if (auto a = true) { + only testA = a; + } + + switch (auto a = 0) { + case 0: + only testA = a; + } + + while (auto a = false) { + only testA = a; + } + + for (; auto a = "test"; ) { + only testA = a; + } + + auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}} + int **p; + // FIXME: due to PR9233, we get the wrong diagnostic here. + const auto **fail2(p); // desired-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}} expected-error {{cannot initialize}} +} + +struct S { + void f(); + char g(int); + float g(double); + int m; + + void test() { + auto p1 = &S::f; + auto S::*p2 = &S::f; + auto (S::*p3)() = &S::f; + auto p4 = &S::g; // expected-error {{incompatible initializer of type ''}} + auto S::*p5 = &S::g; // expected-error {{incompatible initializer of type ''}} + auto (S::*p6)(int) = &S::g; + auto p7 = &S::m; + auto S::*p8 = &S::m; + + only test1 = p1; + only test2 = p2; + only test3 = p3; + only test6 = p6; + only test7 = p7; + only test8 = p8; + } +}; + +// TODO: if the initializer is a braced-init-list, deduce auto as std::initializer_list. diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp new file mode 100644 index 0000000..de87a93 --- /dev/null +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +void f() { + auto a = 0, b = 0, c = 0; + auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}} + + auto v1 = 0, *p1 = &v1; + auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}} + + const int k = 0; + auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}} + + typedef int I; + I x; + auto xa = x, xb = 0; + + auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}} + auto &&ra2 = +a, rb2 = b; +} + +void g() { + auto a = 0, (*b)() -> void, c = 0; + auto d = 0, (*e)() -> void, f = 0.0; // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}} +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp new file mode 100644 index 0000000..7b0fb9c --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp @@ -0,0 +1,164 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -pedantic %s + +// Test the C++0x-specific reference initialization rules, e.g., the +// rules for rvalue references. +template T prvalue(); +template T&& xvalue(); +template T& lvalue(); + +struct Base { }; +struct Derived : Base { }; + +struct HasArray { + int array[5]; +}; + +int f(int); + +template +struct ConvertsTo { + operator T(); // expected-note 4{{candidate function}} +}; + +void test_rvalue_refs() { + // If the initializer expression... + // - is an xvalue, class prvalue, array prvalue or function lvalue + // and "cv1 T1" is reference-compatible with "cv2 T2", or + + // xvalue case + Base&& base0 = xvalue(); + Base&& base1 = xvalue(); + int&& int0 = xvalue(); + + // class prvalue case + Base&& base2 = prvalue(); + Base&& base3 = prvalue(); + + // array prvalue case + int (&&array0)[5] = HasArray().array; + + // function lvalue case + int (&&function0)(int) = f; + + // - has a class type (i.e., T2 is a class type), where T1 is not + // reference-related to T2, and can be implicitly converted to + // an xvalue, class prvalue, or function lvalue of type "cv3 + // T3", where "cv1 T1" is reference-compatible with "cv3 T3", + + // xvalue + Base&& base4 = ConvertsTo(); + Base&& base5 = ConvertsTo(); + int && int1 = ConvertsTo(); + + // class prvalue + Base&& base6 = ConvertsTo(); + Base&& base7 = ConvertsTo(); + + // function lvalue + int (&&function1)(int) = ConvertsTo(); + + // In the second case, if the reference is an rvalue reference and + // the second standard conversion sequence of the user-defined + // conversion sequence includes an lvalue-to-rvalue conversion, the + // program is ill-formed. + int &&int2 = ConvertsTo(); // expected-error{{no viable conversion from 'ConvertsTo' to 'int'}} + int &&int3 = ConvertsTo(); // expected-error{{no viable conversion from 'ConvertsTo' to 'int'}} +} + +class NonCopyable { + NonCopyable(const NonCopyable&); +}; + +class NonCopyableDerived : public NonCopyable { + NonCopyableDerived(const NonCopyableDerived&); +}; + +// Make sure we get direct bindings with no copies. +void test_direct_binding() { + NonCopyable &&nc0 = prvalue(); + NonCopyable &&nc1 = prvalue(); + NonCopyable &&nc2 = xvalue(); + NonCopyable &&nc3 = xvalue(); + const NonCopyable &nc4 = prvalue(); + const NonCopyable &nc5 = prvalue(); + const NonCopyable &nc6 = xvalue(); + const NonCopyable &nc7 = xvalue(); + NonCopyable &&nc8 = ConvertsTo(); + NonCopyable &&nc9 = ConvertsTo(); + const NonCopyable &nc10 = ConvertsTo(); + const NonCopyable &nc11 = ConvertsTo(); +} + +namespace std_example_1 { + double d = 2.0; + double& rd = d; + const double& rcd = d; + struct A { }; + struct B : A { + operator int&(); + } b; + A& ra = b; + const A& rca = b; + int& ir = B(); +} + +namespace std_example_2 { + double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}} + int i = 2; + double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}} + struct A { }; + struct B : A { } b; + extern B f(); + const A& rca = f(); + A&& rra = f(); + struct X { + operator B(); // expected-note{{candidate function}} + operator int&(); // expected-note{{candidate function}} + } x; + const A& r = x; + int&& rri = static_cast(i); + B&& rrb = x; + int&& rri2 = X(); // expected-error{{no viable conversion from 'std_example_2::X' to 'int'}} + + const double& rcd2 = 2; + double&& rrd = 2; + const volatile int cvi = 1; + const int& r2 = cvi; // expected-error{{binding of reference to type 'const int' to a value of type 'const volatile int' drops qualifiers}} + + double d; + double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}} + double&& rrd3 = i; +} + +namespace argument_passing { + void base_rvalue_ref(Base&&); + void int_rvalue_ref(int&&); // expected-note 2{{passing argument to parameter here}} + void array_rvalue_ref(int (&&)[5]); + void function_rvalue_ref(int (&&)(int)); + + void test() { + base_rvalue_ref(xvalue()); + base_rvalue_ref(xvalue()); + int_rvalue_ref(xvalue()); + + base_rvalue_ref(prvalue()); + base_rvalue_ref(prvalue()); + + array_rvalue_ref(HasArray().array); + + function_rvalue_ref(f); + + base_rvalue_ref(ConvertsTo()); + base_rvalue_ref(ConvertsTo()); + int_rvalue_ref(ConvertsTo()); + + base_rvalue_ref(ConvertsTo()); + base_rvalue_ref(ConvertsTo()); + + function_rvalue_ref(ConvertsTo()); + + int_rvalue_ref(ConvertsTo()); // expected-error{{no viable conversion from 'ConvertsTo' to 'int'}} + int_rvalue_ref(ConvertsTo()); // expected-error{{no viable conversion from 'ConvertsTo' to 'int'}} + } + +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp index ae59598..8c65411 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -53,7 +53,7 @@ void g4(const X4&); void g5(const X5&); void test() { - g1(X1()); // expected-warning{{no viable constructor copying parameter of type 'X1'; C++98 requires a copy constructor when binding a reference to a temporary [-Wbind-to-temporary-copy]}} + g1(X1()); g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private [-Wbind-to-temporary-copy]}} g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}} g4(X4()); diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp index 9b39259..08d9639 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp @@ -6,8 +6,8 @@ void example0() { // CHECK: double &rd = // CHECK-NEXT: DeclRefExpr double &rd = d; - // CHECK: double const &rcd = - // CHECK-NEXT: ImplicitCastExpr{{.*}}'double const' + // CHECK: const double &rcd = + // CHECK-NEXT: ImplicitCastExpr{{.*}}'const double' lvalue const double &rcd = d; } @@ -17,11 +17,11 @@ struct B : A { } b; // CHECK: example1 void example1() { // CHECK: A &ra = - // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue + // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue A &ra = b; - // CHECK: A const &rca = - // CHECK: ImplicitCastExpr{{.*}}'struct A const' - // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: const A &rca = + // CHECK: ImplicitCastExpr{{.*}}'const struct A' lvalue + // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue const A& rca = b; } @@ -33,13 +33,13 @@ struct X { // CHECK: example2 void example2() { - // CHECK: A const &rca = - // CHECK: ImplicitCastExpr{{.*}}'struct A const' + // CHECK: const A &rca = + // CHECK: ImplicitCastExpr{{.*}}'const struct A' // CHECK: ImplicitCastExpr{{.*}}'struct A' // CHECK: CallExpr{{.*}}B const A &rca = f(); - // CHECK: A const &r = - // CHECK: ImplicitCastExpr{{.*}}'struct A const' + // CHECK: const A &r = + // CHECK: ImplicitCastExpr{{.*}}'const struct A' // CHECK: ImplicitCastExpr{{.*}}'struct A' // CHECK: CXXMemberCallExpr{{.*}}'struct B' const A& r = x; @@ -47,7 +47,7 @@ void example2() { // CHECK: example3 void example3() { - // CHECK: double const &rcd2 = - // CHECK: ImplicitCastExpr{{.*}} + // CHECK: const double &rcd2 = + // CHECK: ImplicitCastExpr{{.*}} const double& rcd2 = 2; } diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp index 6a039b9..fee5f96 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -struct Base { }; // expected-note{{candidate is the implicit copy constructor}} +struct Base { }; struct Derived : Base { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} struct Unrelated { }; struct Derived2 : Base { }; @@ -64,10 +64,10 @@ void bind_lvalue_quals(volatile Base b, volatile Derived d, volatile const int ivc) { volatile Base &bvr1 = b; volatile Base &bvr2 = d; - volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'Base volatile' to a value of type 'Base const volatile' drops qualifiers}} - volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'Base volatile' to a value of type 'Derived const volatile' drops qualifiers}} + volatile Base &bvr3 = bvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Base' drops qualifiers}} + volatile Base &bvr4 = dvc; // expected-error{{binding of reference to type 'volatile Base' to a value of type 'const volatile Derived' drops qualifiers}} - volatile int &ir = ivc; // expected-error{{binding of reference to type 'int volatile' to a value of type 'int const volatile' drops qualifiers}} + volatile int &ir = ivc; // expected-error{{binding of reference to type 'volatile int' to a value of type 'const volatile int' drops qualifiers}} const volatile Base &bcvr1 = b; const volatile Base &bcvr2 = d; @@ -76,15 +76,15 @@ void bind_lvalue_quals(volatile Base b, volatile Derived d, void bind_lvalue_to_rvalue() { Base &br1 = Base(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Base'}} Base &br2 = Derived(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Derived'}} - const volatile Base &br3 = Base(); // expected-error{{volatile lvalue reference to type 'Base const volatile' cannot bind to a temporary of type 'Base'}} - const volatile Base &br4 = Derived(); // expected-error{{volatile lvalue reference to type 'Base const volatile' cannot bind to a temporary of type 'Derived'}} + const volatile Base &br3 = Base(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Base'}} + const volatile Base &br4 = Derived(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Derived'}} int &ir = 17; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}} } void bind_lvalue_to_unrelated(Unrelated ur) { Base &br1 = ur; // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a value of unrelated type 'Unrelated'}} - const volatile Base &br2 = ur; // expected-error{{volatile lvalue reference to type 'Base const volatile' cannot bind to a value of unrelated type 'Unrelated'}} + const volatile Base &br2 = ur; // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a value of unrelated type 'Unrelated'}} } void bind_lvalue_to_conv_lvalue() { @@ -118,8 +118,8 @@ void bind_const_lvalue_to_rvalue() { const Base &br3 = create(); const Base &br4 = create(); - const Base &br5 = create(); // expected-error{{binding of reference to type 'Base const' to a value of type 'Base const volatile' drops qualifiers}} - const Base &br6 = create(); // expected-error{{binding of reference to type 'Base const' to a value of type 'Derived const volatile' drops qualifiers}} + const Base &br5 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Base' drops qualifiers}} + const Base &br6 = create(); // expected-error{{binding of reference to type 'const Base' to a value of type 'const volatile Derived' drops qualifiers}} const int &ir = create(); } @@ -131,5 +131,5 @@ void bind_const_lvalue_to_class_conv_temporary() { } void bind_lvalue_to_conv_rvalue_ambig(ConvertibleToBothDerived both) { const Derived &dr1 = both; - const Base &br1 = both; // expected-error{{reference initialization of type 'Base const &' with initializer of type 'ConvertibleToBothDerived' is ambiguous}} + const Base &br1 = both; // expected-error{{reference initialization of type 'const Base &' with initializer of type 'ConvertibleToBothDerived' is ambiguous}} } diff --git a/test/CXX/dcl.decl/dcl.init/p6.cpp b/test/CXX/dcl.decl/dcl.init/p6.cpp index c542dac..da6f5b5 100644 --- a/test/CXX/dcl.decl/dcl.init/p6.cpp +++ b/test/CXX/dcl.decl/dcl.init/p6.cpp @@ -10,7 +10,7 @@ struct NoUserDefault : public MakeNonPOD { }; struct HasUserDefault { HasUserDefault(); }; void test_const_default_init() { - const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'NoUserDefault const' requires a user-provided default constructor}} + const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' requires a user-provided default constructor}} const HasUserDefault x2; - const int x3; // expected-error{{default initialization of an object of const type 'int const'}} + const int x3; // expected-error{{default initialization of an object of const type 'const int'}} } diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp index 00e59e0..b0575b8 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp @@ -3,4 +3,5 @@ void f() { int b[5]; auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}} + auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}} } diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp index ac0ec85..bb4a48e 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp @@ -5,7 +5,7 @@ int ar1[10]; // Element type cannot be: // - (cv) void -volatile void ar2[10]; // expected-error {{incomplete element type 'void volatile'}} +volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}} // - a reference int& ar3[10]; // expected-error {{array of references}} // - a function type @@ -16,7 +16,7 @@ struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}} Abstract ar5[10]; // expected-error {{abstract class}} // If we have a size, it must be greater than zero. -int ar6[-1]; // expected-error {{array size is negative}} +int ar6[-1]; // expected-error {{array with a negative size}} int ar7[0u]; // expected-warning {{zero size arrays are an extension}} // An array with unknown bound is incomplete. @@ -42,3 +42,13 @@ template struct S { typename T::type x; // expected-error {{has no members}} }; S ar10[10]; // expected-note {{requested here}} + +// Ensure that negative array size errors include the name of the declared +// array as this is often used to simulate static_assert with template +// instantiations, placing the 'error message' in the declarator name. +int +user_error_message +[-1]; // expected-error {{user_error_message}} +typedef int +another_user_error_message +[-1]; // expected-error {{another_user_error_message}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp new file mode 100644 index 0000000..5fb35ba --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -fexceptions -verify %s + +// When it is part of a parameter-declaration-clause, the parameter +// pack is a function parameter pack. +template +void f0(Types ...args); + +template +void f1(const Types &...args); + +// [ Note: Otherwise, the parameter-declaration is part of a +// template-parameter-list and the parameter pack is a template +// parameter pack; see 14.1. -- end note ] +template +struct X0 { }; + +template +struct X1 { + template struct Inner; +}; + +// A declarator-id or abstract-declarator containing an ellipsis shall +// only be used in a parameter-declaration. +int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}} + +void f3() { + int ...x; // expected-error{{only function and template parameters can be parameter packs}} + if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}} + + for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}} + + try { + } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}} + } +} + +template +struct X2 { + Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \ + // expected-error{{data member type contains unexpanded parameter pack}} +}; + +// The type T of the declarator-id of the function parameter pack +// shall contain a template parameter pack; each template parameter +// pack in T is expanded by the function parameter pack. +template +void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}} + diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp new file mode 100644 index 0000000..1293a06 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template struct identity; +template struct tuple; + +template struct is_same { + static const bool value = false; +}; + +template struct is_same { + static const bool value = true; +}; + +// There is a syntactic ambiguity when an ellipsis occurs at the end +// of a parameter-declaration-clause without a preceding comma. In +// this case, the ellipsis is parsed as part of the +// abstract-declarator if the type of the parameter names a template +// parameter pack that has not been expanded; otherwise, it is parsed +// as part of the parameter-declaration-clause. + +template +struct X0 { + typedef identity function_pack_1; + typedef identity variadic_function_pack_1; + typedef identity variadic_1; + typedef tuple template_arg_expansion_1; +}; + + + +// FIXME: Once function parameter packs are implemented, we can test all of the disambiguation diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp new file mode 100644 index 0000000..4dc393d --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +auto a() -> int; // ok +const auto b() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto const'}} +auto *c() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto *'}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp new file mode 100644 index 0000000..c81c844 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +void f0() &; // expected-error{{ref-qualifier '&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}} +void f1() &&; // expected-error{{ref-qualifier '&&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}} + +struct X { + void f0() &; + void f1() &&; + static void f2() &; // expected-error{{ref-qualifier '&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}} + static void f3() &&; // expected-error{{ref-qualifier '&&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}} +}; + +typedef void func_type_lvalue() &; +typedef void func_type_rvalue() &&; + +func_type_lvalue f2; // expected-error{{nonmember function cannot have a ref-qualifier '&'}} +func_type_rvalue f3; // expected-error{{nonmember function cannot have a ref-qualifier '&&'}} + +struct Y { + func_type_lvalue f0; + func_type_rvalue f1; +}; + +void (X::*mpf1)() & = &X::f0; +void (X::*mpf2)() && = &X::f1; + + +void (f() &&); // expected-error{{ref-qualifier '&&' is only allowed on non-static member functions, member function pointers, and typedefs of function types}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp new file mode 100644 index 0000000..4873c09 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void f() const; // expected-error{{type qualifier is not allowed on this function}} + +struct X { + void f() const; + friend void g() const; // expected-error{{type qualifier is not allowed on this function}} + static void h() const; // expected-error{{type qualifier is not allowed on this function}} +}; + +struct Y { + friend void X::f() const; + friend void ::f() const; // expected-error{{type qualifier is not allowed on this function}} +}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp new file mode 100644 index 0000000..34a8c85 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct A { }; +A::A (enum { e1 }) {} // expected-error{{can not be defined in a parameter}} \ +// expected-error{{out-of-line definition}} +void A::f(enum { e2 }) {} // expected-error{{can not be defined in a parameter}} \ +// expected-error{{out-of-line definition}} + +enum { e3 } A::g() { } // expected-error{{can not be defined in the result type}} \ +// expected-error{{out-of-line definition}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp new file mode 100644 index 0000000..789cde7 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template +struct is_same { + static const bool value = false; +}; + +template +struct is_same { + static const bool value = true; +}; +#define JOIN2(X,Y) X##Y +#define JOIN(X,Y) JOIN2(X,Y) +#define CHECK_EQUAL_TYPES(T1, T2) \ + int JOIN(array,__LINE__)[is_same::value? 1 : -1] + +int i; +typedef int& LRI; +typedef int&& RRI; + +typedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&); +typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&); +typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&); + +typedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&); +typedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&); diff --git a/test/CXX/dcl.decl/p4-0x.cpp b/test/CXX/dcl.decl/p4-0x.cpp new file mode 100644 index 0000000..9fa2ea1 --- /dev/null +++ b/test/CXX/dcl.decl/p4-0x.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +struct X { + void f() &; + void g() &&; +}; + +void (X::*pmf)() & = &X::f; diff --git a/test/CXX/except/except.handle/p16.cpp b/test/CXX/except/except.handle/p16.cpp index 4950a2f..24f0db0 100644 --- a/test/CXX/except/except.handle/p16.cpp +++ b/test/CXX/except/except.handle/p16.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s // The object declared in an exception-declaration or, if the // exception-declaration does not specify a name, a temporary (12.2) diff --git a/test/CXX/except/except.spec/p14-ir.cpp b/test/CXX/except/except.spec/p14-ir.cpp index 4d8d1f7..c681727 100644 --- a/test/CXX/except/except.spec/p14-ir.cpp +++ b/test/CXX/except/except.spec/p14-ir.cpp @@ -26,17 +26,17 @@ struct X4 { struct X5 : X0, X4 { }; void test(X2 x2, X3 x3, X5 x5) { - // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_ + // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X0* %this, %struct.X0*) unnamed_addr // CHECK: call void @_ZN2X2C2ERKS_({{.*}}) nounwind // CHECK-NEXT: ret void // CHECK-NEXT: } X2 x2a(x2); - // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_ + // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X0* %this, %struct.X0*) unnamed_addr // CHECK: call void @_ZN2X3C2ERKS_({{.*}}) nounwind // CHECK-NEXT: ret void // CHECK-NEXT: } X3 x3a(x3); - // CHECK: define linkonce_odr void @_ZN2X5C1ERS_ + // CHECK: define linkonce_odr void @_ZN2X5C1ERS_({{.*}}) unnamed_addr // CHECK-NOT: call void @__cxa_call_unexpected // CHECK: ret void X5 x5a(x5); @@ -55,24 +55,24 @@ struct X8 : X6 { }; struct X9 : X6, X7 { }; void test() { - // CHECK: define linkonce_odr void @_ZN2X8C1Ev + // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X0* %this) unnamed_addr // CHECK: call void @_ZN2X8C2Ev({{.*}}) nounwind // CHECK-NEXT: ret void X8(); - // CHECK: define linkonce_odr void @_ZN2X9C1Ev + // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X0* %this) unnamed_addr // FIXME: check that this is the end of the line here: // CHECK: call void @_ZN2X9C2Ev({{.*}}) // CHECK-NEXT: ret void X9(); - // CHECK: define linkonce_odr void @_ZN2X9C2Ev + // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X0* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind // FIXME: and here: // CHECK-NEXT: call void @_ZN2X7C2Ev({{.*}}) // CHECK: ret void - // CHECK: define linkonce_odr void @_ZN2X8C2Ev + // CHECK: define linkonce_odr void @_ZN2X8C2Ev(%struct.X0* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind // CHECK-NEXT: ret void } diff --git a/test/CXX/expr/expr.cast/p4-0x.cpp b/test/CXX/expr/expr.cast/p4-0x.cpp new file mode 100644 index 0000000..5824cd2 --- /dev/null +++ b/test/CXX/expr/expr.cast/p4-0x.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +struct X { }; +struct Y : X { }; + +void test_lvalue_to_rvalue_drop_cvquals(const X &x, const Y &y, const int &i) { + (void)(X&&)x; + (void)(int&&)i; + (void)(X&&)y; + (void)(Y&&)x; +} diff --git a/test/CXX/expr/expr.cast/p4.cpp b/test/CXX/expr/expr.cast/p4.cpp new file mode 100644 index 0000000..907e008 --- /dev/null +++ b/test/CXX/expr/expr.cast/p4.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -ast-dump %s | FileCheck %s + +struct A { int x; }; +struct B { int y; }; +struct C : A, B { }; + +// CHECK: casting_away_constness +void casting_away_constness(const B &b, const C &c, const B *bp, const C *cp) { + // CHECK: DerivedToBase (B) + // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'c' + (void)(B&)c; + // CHECK: BaseToDerived (B) + // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'b' + (void)(C&)b; + // CHECK: DerivedToBase (B) + // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'cp' + (void)(B*)cp; + // CHECK: BaseToDerived (B) + // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'bp' + (void)(C*)bp; + // CHECK: ReturnStmt + return; +} diff --git a/test/CXX/expr/expr.mptr.oper/p5.cpp b/test/CXX/expr/expr.mptr.oper/p5.cpp new file mode 100644 index 0000000..7380b5d --- /dev/null +++ b/test/CXX/expr/expr.mptr.oper/p5.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct X0 { + void f0(); + void f1() const; + void f2() volatile; + void f3() const volatile; +}; + +void test_object_cvquals(void (X0::*pm)(), + void (X0::*pmc)() const, + void (X0::*pmv)() volatile, + void (X0::*pmcv)() const volatile, + X0 *p, + const X0 *pc, + volatile X0 *pv, + const volatile X0 *pcv, + X0 &o, + const X0 &oc, + volatile X0 &ov, + const volatile X0 &ocv) { + (p->*pm)(); + (p->*pmc)(); + (p->*pmv)(); + (p->*pmcv)(); + + (pc->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const' qualifier}} + (pc->*pmc)(); + (pc->*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}} + (pc->*pmcv)(); + + (pv->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'volatile' qualifier}} + (pv->*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}} + (pv->*pmv)(); + (pv->*pmcv)(); + + (pcv->*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const volatile' qualifiers}} + (pcv->*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}} + (pcv->*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}} + (pcv->*pmcv)(); + + (o.*pm)(); + (o.*pmc)(); + (o.*pmv)(); + (o.*pmcv)(); + + (oc.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const' qualifier}} + (oc.*pmc)(); + (oc.*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}} + (oc.*pmcv)(); + + (ov.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'volatile' qualifier}} + (ov.*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}} + (ov.*pmv)(); + (ov.*pmcv)(); + + (ocv.*pm)(); // expected-error{{call to pointer to member function of type 'void ()' drops 'const volatile' qualifiers}} + (ocv.*pmc)(); // expected-error{{call to pointer to member function of type 'void () const' drops 'volatile' qualifier}} + (ocv.*pmv)(); // expected-error{{call to pointer to member function of type 'void () volatile' drops 'const' qualifier}} + (ocv.*pmcv)(); +} diff --git a/test/CXX/expr/expr.mptr.oper/p6-0x.cpp b/test/CXX/expr/expr.mptr.oper/p6-0x.cpp new file mode 100644 index 0000000..d5dc7d2 --- /dev/null +++ b/test/CXX/expr/expr.mptr.oper/p6-0x.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +struct X { }; + +template T& lvalue(); +template T&& xvalue(); +template T prvalue(); + +// In a .* expression whose object expression is an rvalue, the +// program is ill-formed if the second operand is a pointer to member +// function with ref-qualifier &. In a ->* expression or in a .* +// expression whose object expression is an lvalue, the program is +// ill-formed if the second operand is a pointer to member function +// with ref-qualifier &&. +void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &, + int (X::*r_pmf)(int) &&) { + // No ref-qualifier. + (lvalue().*pmf)(17); + (xvalue().*pmf)(17); + (prvalue().*pmf)(17); + (xp->*pmf)(17); + + // Lvalue ref-qualifier. + (lvalue().*l_pmf)(17); + (xvalue().*l_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &' can only be called on an lvalue}} + (prvalue().*l_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &' can only be called on an lvalue}} + (xp->*l_pmf)(17); + + // Rvalue ref-qualifier. + (lvalue().*r_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &&' can only be called on an rvalue}} + (xvalue().*r_pmf)(17); + (prvalue().*r_pmf)(17); + (xp->*r_pmf)(17); // expected-error{{pointer-to-member function type 'int (X::*)(int) &&' can only be called on an rvalue}} +} diff --git a/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp new file mode 100644 index 0000000..d464881 --- /dev/null +++ b/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// The result of the expression const_cast(v) is of type T. If T is +// an lvalue reference to object type, the result is an lvalue; if T +// is an rvalue reference to object type, the result is an xvalue;. + +unsigned int f(int); + +template T& lvalue(); +template T&& xvalue(); +template T prvalue(); + +void test_classification(const int *ptr) { + int *ptr0 = const_cast(ptr); + int *ptr1 = const_cast(xvalue()); + int *ptr2 = const_cast(prvalue()); +} diff --git a/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp new file mode 100644 index 0000000..3b448a8 --- /dev/null +++ b/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +struct X { virtual ~X(); }; +struct Y : public X { }; +struct Z; // expected-note{{forward declaration of 'Z'}} + +void test(X &x, Y &y, Z &z) { + // If T is an rvalue reference type, v shall be an expression having + // a complete class type, and the result is an xvalue of the type + // referred to by T. + Y &&yr0 = dynamic_cast(x); + Y &&yr1 = dynamic_cast(static_cast(x)); + Y &&yr2 = dynamic_cast(z); // expected-error{{'Z' is an incomplete type}} +} diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp new file mode 100644 index 0000000..e80082a --- /dev/null +++ b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// If T is an lvalue reference type or an rvalue reference to function +// type, the result is an lvalue; if T is an rvalue reference to +// object type, the result is an xvalue; + +unsigned int f(int); + +template T&& xvalue(); +void test_classification(char *ptr) { + int (&fr0)(int) = reinterpret_cast(f); + int &&ir0 = reinterpret_cast(*ptr); + int &&ir1 = reinterpret_cast(0); + int &&ir2 = reinterpret_cast('a'); + int &&ir3 = reinterpret_cast(xvalue()); +} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp new file mode 100644 index 0000000..c103351 --- /dev/null +++ b/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to +// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). +struct A { }; +struct B : A { }; + +template T& lvalue(); +template T&& xvalue(); + +void test(A &a, B &b) { + A &&ar0 = static_cast(a); + A &&ar1 = static_cast(b); + A &&ar2 = static_cast(lvalue()); + A &&ar3 = static_cast(lvalue()); + A &&ar4 = static_cast(xvalue()); + A &&ar5 = static_cast(xvalue()); + const A &&ar6 = static_cast(a); + const A &&ar7 = static_cast(b); + const A &&ar8 = static_cast(lvalue()); + const A &&ar9 = static_cast(lvalue()); + const A &&ar10 = static_cast(xvalue()); + const A &&ar11 = static_cast(xvalue()); +} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp new file mode 100644 index 0000000..4acafb8 --- /dev/null +++ b/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +enum class EC { ec1 }; + +void test0(EC ec) { + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); + (void)static_cast(ec); + (void)static_cast(EC::ec1); +} + +namespace PR9107 { + enum E {}; + template inline _Tp* addressof(_Tp& __x) { + return (_Tp*)&(char&)__x; + } + void test() { + E a; + addressof(a); + } +} diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp index 2fa30e5..ecb2918 100644 --- a/test/CXX/expr/expr.unary/expr.delete/p5.cpp +++ b/test/CXX/expr/expr.unary/expr.delete/p5.cpp @@ -24,11 +24,23 @@ void f0(T2_A *a) { T2_C x; x.f0(a); } class T2_A { }; // An alternate version of the same. -// -// FIXME: Revisit this case when we have access control. class T3_A; template -struct T3_B { void f0(T *a) { delete a; } }; -struct T3_C { T3_B x; void f0(T3_A *a) { x.f0(a); } }; +struct T3_B { + void f0(T *a) { + delete a; // expected-error{{calling a private destructor of class 'T3_A'}} + } +}; + +struct T3_C { + T3_B x; + void f0(T3_A *a) { + x.f0(a); // expected-note{{in instantiation of member function 'T3_B::f0' requested here}} + } +}; + void f0(T3_A *a) { T3_C x; x.f0(a); } -class T3_A { private: ~T3_A(); }; +class T3_A { +private: + ~T3_A(); // expected-note{{declared private here}} +}; diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp new file mode 100644 index 0000000..c9a8887 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x + +template +struct only { + only(T); + template only(U) = delete; +}; + +void f() { + only p = new const auto (0); + only q = new (auto) (0.0); + + new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}} + new (const auto)(); // expected-error{{new expression for type 'auto const' requires a constructor argument}} + new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} +} + +void p2example() { + only r = new auto(1); + auto x = new auto('a'); + + only testX = x; +} diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp new file mode 100644 index 0000000..3824615 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// Test parsing + semantic analysis +template struct count_types { + static const unsigned value = sizeof...(Types); +}; + +template struct count_ints { + static const unsigned value = sizeof...(Values); +}; + +// Test instantiation +int check_types[count_types::value == 3? 1 : -1]; +int check_ints[count_ints<1, 2, 3, 4, 5>::value == 5? 1 : -1]; + +// Test instantiation involving function parameter packs. +struct any { + template any(T); +}; + +template +void init_me(Inits ...inits) { + any array[sizeof...(inits)] = { inits... }; +} + +template void init_me(int, float, double*); + +// Test parser and semantic recovery. +template struct count_ints_2 { + static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}} +}; + +template // expected-note{{parameter pack 'Types' declared here}} +struct count_types_2 { + static const unsigned value = sizeof... Type; // expected-error{{missing parentheses around the size of parameter pack 'Type'}} \ + // expected-error{{Type' does not refer to the name of a parameter pack; did you mean 'Types'?}} +}; + diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp new file mode 100644 index 0000000..6aec3a2 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++0x -include %S/ser.h %s -o - | FileCheck %s +// RUN: %clang_cc1 -fexceptions -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++0x -x c++ %S/ser.h +// RUN: %clang_cc1 -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++0x -include-pch %t-ser.pch %s -o - | FileCheck %s + +struct D { + ~D() throw(); +}; +struct E { + ~E() throw(); +}; + +void test() { + bool b; + // CHECK: store i8 1 + b = noexcept(0); + // CHECK: store i8 0 + b = noexcept(throw 0); + b = f1(); + b = f2(); + + // CHECK-NOT: call void @_ZN1ED1Ev + // CHECK: call void @_ZN1DD1Ev + D(), noexcept(E()); +} +// CHECK: ret i1 true +// CHECK: ret i1 false diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp new file mode 100644 index 0000000..98c6f4e --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp @@ -0,0 +1,172 @@ +// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x -fms-extensions %s + +#define P(e) static_assert(noexcept(e), "expected nothrow") +#define N(e) static_assert(!noexcept(e), "expected throw") +#define B(b, e) static_assert(b == noexcept(e), "expectation failed") + +void simple() { + P(0); + P(0 + 0); + int i; + P(i); + P(sizeof(0)); + P(static_cast(0)); + N(throw 0); + N((throw 0, 0)); +} + +void nospec(); +void allspec() throw(...); +void intspec() throw(int); +void emptyspec() throw(); +void nothrowattr() __attribute__((nothrow)); + +void call() { + N(nospec()); + N(allspec()); + N(intspec()); + P(emptyspec()); + P(nothrowattr()); +} + +void (*pnospec)(); +void (*pallspec)() throw(...); +void (*pintspec)() throw(int); +void (*pemptyspec)() throw(); + +void callptr() { + N(pnospec()); + N((*pnospec)()); + N(pallspec()); + N((*pallspec)()); + N(pintspec()); + N((*pintspec)()); + P(pemptyspec()); + P((*pemptyspec)()); +} + +struct S1 { + void nospec(); + void allspec() throw(...); + void intspec() throw(int); + void emptyspec() throw(); +}; + +void callmem() { + S1 s; + N(s.nospec()); + N(s.allspec()); + N(s.intspec()); + P(s.emptyspec()); +} + +void (S1::*mpnospec)(); +void (S1::*mpallspec)() throw(...); +void (S1::*mpintspec)() throw(int); +void (S1::*mpemptyspec)() throw(); + +void callmemptr() { + S1 s; + N((s.*mpnospec)()); + N((s.*mpallspec)()); + N((s.*mpintspec)()); + P((s.*mpemptyspec)()); +} + +struct S2 { + S2(); + S2(int, int) throw(); + void operator +(); + void operator -() throw(); + void operator +(int); + void operator -(int) throw(); + operator int(); + operator float() throw(); +}; + +void *operator new(__typeof__(sizeof(int)) sz, int) throw(); + +struct Bad1 { + ~Bad1() throw(int); +}; +struct Bad2 { + void operator delete(void*) throw(int); +}; + +void implicits() { + N(new int); + P(new (0) int); + P(delete (int*)0); + N(delete (Bad1*)0); + N(delete (Bad2*)0); + N(S2()); + P(S2(0, 0)); + S2 s; + N(+s); + P(-s); + N(s + 0); + P(s - 0); + N(static_cast(s)); + P(static_cast(s)); + N(Bad1()); +} + +struct V { + virtual ~V() throw(); +}; +struct D : V {}; + +void dyncast() { + V *pv = 0; + D *pd = 0; + P(dynamic_cast(*pd)); + P(dynamic_cast(pd)); + N(dynamic_cast(*pv)); + P(dynamic_cast(pv)); +} + +namespace std { + struct type_info {}; +} + +void idtype() { + P(typeid(V)); + P(typeid((V*)0)); + P(typeid(*(S1*)0)); + N(typeid(*(V*)0)); +} + +void uneval() { + P(sizeof(typeid(*(V*)0))); + P(typeid(typeid(*(V*)0))); +} + +struct G1 {}; +struct G2 { int i; }; +struct G3 { S2 s; }; + +void gencon() { + P(G1()); + P(G2()); + N(G3()); +} + +template +void late() { + B(b, typeid(*(T*)0)); + B(b, T(1)); + B(b, static_cast(S2(0, 0))); + B(b, S1() + T()); +} +struct S3 { + virtual ~S3() throw(); + S3() throw(); + explicit S3(int); + S3(const S2&); +}; +void operator +(const S1&, float) throw(); +void operator +(const S1&, const S3&); +void tlate() { + late(); + late(); +} diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h b/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h new file mode 100644 index 0000000..e6e7b79 --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h @@ -0,0 +1,8 @@ +// Serialization testing helper for noexcept, included by cg.cpp. + +inline bool f1() { + return noexcept(0); +} +inline bool f2() { + return noexcept(throw 0); +} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp index 170c734..06cc610 100644 --- a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp @@ -7,8 +7,7 @@ namespace test0 { template void g(T); void test() { - // FIXME: this diagnostic is terrible - foo(&g); // expected-error {{cannot initialize a parameter of type 'void (test0::A::*)(int)' with an rvalue of type ''}} + foo(&g); // expected-error {{can't form member pointer of type 'void (test0::A::*)(int)' without '&' and class name}} } }; } @@ -39,7 +38,6 @@ namespace test2 { }; void A::test() { - // FIXME: This diagnostic is terrible. - int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot initialize a variable of type 'int (test2::A::*)(int)' with an rvalue of type ''}} + int (A::*ptr)(int) = &(A::foo); // expected-error {{can't form member pointer of type 'int (test2::A::*)(int)' without '&' and class name}} } } diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp new file mode 100644 index 0000000..543a86d --- /dev/null +++ b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// -- prvalue of arithmetic + +bool b = !0; + +bool b2 = !1.2; + +bool b3 = !4; + +// -- unscoped enumeration +enum { E, F }; + +bool b4 = !E; +bool b5 = !F; + +// -- pointer, +bool b6 = !&b4; +void f(); +bool b61 = !&f; + +// -- or pointer to member type can be converted to a prvalue of type bool. +struct S { void f() { } }; + +bool b7 = !&S::f; + + +bool b8 = !S(); //expected-error {{invalid argument type 'S'}} + +namespace PR8181 +{ + void f() { } + void f(char) { } + bool b = !&f; //expected-error {{cannot resolve overloaded function from context}} + +} diff --git a/test/CXX/over/over.built/p1.cpp b/test/CXX/over/over.built/p1.cpp new file mode 100644 index 0000000..6000f5b --- /dev/null +++ b/test/CXX/over/over.built/p1.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +enum E1 { one }; +enum E2 { two }; + +bool operator >= (E1, E1) { + return false; +} + +bool operator >= (E1, const E2) { + return false; +} + +bool test(E1 a, E1 b, E2 c) { + return a >= b || a >= c; +} diff --git a/test/CXX/over/over.built/p25.cpp b/test/CXX/over/over.built/p25.cpp new file mode 100644 index 0000000..c185fb4 --- /dev/null +++ b/test/CXX/over/over.built/p25.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +enum class Color { Red, Green, Blue }; + +struct ConvertsToColorA { + operator Color(); +}; + +struct ConvertsToColorB { + operator Color(); +}; + +Color foo(bool cond, ConvertsToColorA ca, ConvertsToColorB cb) { + return cond? ca : cb; +} diff --git a/test/CXX/over/over.load/p2-0x.cpp b/test/CXX/over/over.load/p2-0x.cpp new file mode 100644 index 0000000..f0ace90 --- /dev/null +++ b/test/CXX/over/over.load/p2-0x.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// Member function declarations with the same name and the same +// parameter-type-list as well as mem- ber function template +// declarations with the same name, the same parameter-type-list, and +// the same template parameter lists cannot be overloaded if any of +// them, but not all, have a ref-qualifier (8.3.5). + +class Y { + void h() &; + void h() const &; + void h() &&; + void i() &; // expected-note{{previous declaration}} + void i() const; // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}} + + template void f(T*) &; + template void f(T*) &&; + + template void g(T*) &; // expected-note{{previous declaration}} + template void g(T*); // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}} + + void k(); // expected-note{{previous declaration}} + void k() &&; // expected-error{{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}} +}; diff --git a/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp new file mode 100644 index 0000000..ab171bc --- /dev/null +++ b/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s +namespace std_example { + int i; + int f1(); + int&& f2(); + int &g(const int &); + float &g(const int &&); + int &j = g(i); + float &k = g(f1()); + float &l = g(f2()); + + int &g2(const int &); + float &g2(int &&); + int &j2 = g2(i); + float &k2 = g2(f1()); + float &l2 = g2(f2()); + + // FIXME: We don't support ref-qualifiers yet. +#if 0 + struct A { + A& operator<<(int); + void p() &; + void p() &&; + }; + + A& operator<<(A&&, char); + A() << 1; + A() << 'c'; + A a; + a << 1; + a << 'c'; + A().p(); + a.p(); +#endif +} + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +template +struct remove_reference { + typedef T type; +}; + +namespace FunctionReferencesOverloading { + template int &f(typename remove_reference::type&); + template float &f(typename remove_reference::type&&); + + void test_f(int (&func_ref)(int)) { + int &ir = f(func_ref); + } +} diff --git a/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp b/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp new file mode 100644 index 0000000..8ccc5b6 --- /dev/null +++ b/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp @@ -0,0 +1,70 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template T &lvalue(); +template T &&xvalue(); +template T prvalue(); + +struct X0 { + int &f() &; + float &f() &&; + + template int &ft(T) &; + template float &ft(T) &&; + + typedef int &(*func_int_ref)(); + typedef float &(*func_float_ref)(); + + operator func_int_ref() &; + operator func_float_ref() &&; + + void g(); + + int &operator+(const X0&) &; + float &operator+(const X0&) &&; + + template int &operator+(const T&) &; + template float &operator+(const T&) &&; + + int &h() const&; + float &h() &&; + int &h2() const&; + float &h2() const&&; +}; + +void X0::g() { + int &ir1 = f(); + int &ir2 = X0::f(); +} + +void test_ref_qualifier_binding() { + int &ir1 = lvalue().f(); + float &fr1 = xvalue().f(); + float &fr2 = prvalue().f(); + int &ir2 = lvalue().ft(1); + float &fr3 = xvalue().ft(2); + float &fr4 = prvalue().ft(3); +} + +void test_ref_qualifier_binding_with_surrogates() { + int &ir1 = lvalue()(); + float &fr1 = xvalue()(); + float &fr2 = prvalue()(); +} + +void test_ref_qualifier_binding_operators() { + int &ir1 = lvalue() + prvalue(); + float &fr1 = xvalue() + prvalue(); + float &fr2 = prvalue() + prvalue(); + int &ir2 = lvalue() + 1; + float &fr3 = xvalue() + 2; + float &fr4 = prvalue() + 3; +} + +void test_ref_qualifier_overloading() { + int &ir1 = lvalue().h(); + float &fr1 = xvalue().h(); + float &fr2 = prvalue().h(); + int &ir2 = lvalue().h2(); + float &fr3 = xvalue().h2(); + float &fr4 = prvalue().h2(); +} diff --git a/test/CXX/over/over.over/p2-resolve-single-template-id.cpp b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp new file mode 100644 index 0000000..f38a74e --- /dev/null +++ b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t; + +namespace DontResolveTooEarly_WaitForOverloadResolution +{ + template T* f(int); // #1 + template T& f(U); // #2 + + void g() { + int *ip = f(1); // calls #1 + } + + template + T* f2(int); + template + T& f2(U); + + void g2() { + int*ip = (f2)(1); // ok + } + +} // End namespace + + template + void twoT() { } + template + void twoT(T) { } + + + void two() { }; //expected-note 5{{candidate}} + void two(int) { }; //expected-note 5{{candidate}} + + + + void one() { } + template + void oneT() { } + + template + void cant_resolve() { } //expected-note 3{{candidate}} + + template void cant_resolve(T) { }//expected-note 3{{candidate}} + + +int main() +{ + { static_cast(one); } + { (void)(one); } + { static_cast(oneT); } + { (void)(oneT); } + + { static_cast(two); } // expected-error {{address of overloaded}} + { (void)(two); } // expected-error {{address of overloaded}} + { static_cast(twoT); } + { (void)(twoT); } + + + { ptrdiff_t x = reinterpret_cast(oneT); } + { (void) reinterpret_cast(oneT); } + { (void) reinterpret_cast(one); } + { (void) reinterpret_cast(one); } + + { ptrdiff_t x = reinterpret_cast(twoT); } + { (void) reinterpret_cast(twoT); } + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + { (void) static_cast(two); } //ok + + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + { (void) reinterpret_cast(two); } //expected-error {{reinterpret_cast}} + + { bool b = (twoT); } // ok + { bool b = (twoT); } //ok + + { bool b = &twoT; //&foo; } + b = &(twoT); } + + { ptrdiff_t x = (ptrdiff_t) &twoT; + x = (ptrdiff_t) &twoT; } + + { ptrdiff_t x = (ptrdiff_t) twoT; + x = (ptrdiff_t) twoT; } + + + { ptrdiff_t x = (ptrdiff_t) &twoT; + x = (ptrdiff_t) &twoT; } + + { oneT; &oneT; } //expected-warning 2{{ expression result unused }} + { static_cast(cant_resolve); } // expected-error {{address of overload}} + { bool b = cant_resolve; } // expected-error {{address of overload}} + { (void) cant_resolve; } // expected-error {{address of overload}} + +} + + diff --git a/test/CXX/over/over.over/p2.cpp b/test/CXX/over/over.over/p2.cpp index e8840d2..3e8d0f1 100644 --- a/test/CXX/over/over.over/p2.cpp +++ b/test/CXX/over/over.over/p2.cpp @@ -1,10 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template T f0(T, T); +template T f0(T, T); //expected-note{{candidate}} void test_f0() { int (*f0a)(int, int) = f0; int (*f0b)(int, int) = &f0; - int (*f0c)(int, float) = f0; // expected-error{{cannot initialize}} - // FIXME: poor error message above! + int (*f0c)(int, float) = f0; // expected-error{{address of overloaded function 'f0' does not match required type 'int (int, float)'}} } diff --git a/test/CXX/over/over.over/p4.cpp b/test/CXX/over/over.over/p4.cpp index 4189218..27d070e 100644 --- a/test/CXX/over/over.over/p4.cpp +++ b/test/CXX/over/over.over/p4.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template T f0(T); +template T f0(T); // expected-note{{candidate function}} int f0(int); // expected-note{{candidate function}} void test_f0() { @@ -13,11 +13,8 @@ namespace N { int f0(int); // expected-note{{candidate function}} } -int f0(int); - void test_f0_2() { using namespace N; - int (*fp0)(int) = f0; // expected-error{{ambiguous}} \ - // expected-error{{cannot initialize}} + int (*fp0)(int) = f0; // expected-error{{address of overloaded function 'f0' is ambiguous}} float (*fp1)(float) = f0; } diff --git a/test/CXX/special/class.copy/p33-0x.cpp b/test/CXX/special/class.copy/p33-0x.cpp new file mode 100644 index 0000000..262809e --- /dev/null +++ b/test/CXX/special/class.copy/p33-0x.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fexceptions -std=c++0x -fsyntax-only -verify %s +class X { + X(const X&); + +public: + X(); + X(X&&); +}; + +X return_by_move(int i, X x) { + X x2; + if (i == 0) + return x; + else if (i == 1) + return x2; + else + return x; +} + +void throw_move_only(X x) { + X x2; + throw x; + throw x2; +} + diff --git a/test/CXX/special/class.copy/p9.cpp b/test/CXX/special/class.copy/p9.cpp index d037944..77ab19e 100644 --- a/test/CXX/special/class.copy/p9.cpp +++ b/test/CXX/special/class.copy/p9.cpp @@ -15,30 +15,30 @@ struct VirtualInheritsNonConstCopy : virtual NonConstCopy { VirtualInheritsNonConstCopy(const VirtualInheritsNonConstCopy&); }; -struct ImplicitNonConstCopy1 : NonConstCopy { - ImplicitNonConstCopy1(); +struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note {{candidate constructor}} + ImplicitNonConstCopy1(); // expected-note {{candidate constructor}} }; -struct ImplicitNonConstCopy2 { - ImplicitNonConstCopy2(); +struct ImplicitNonConstCopy2 { // expected-note {{candidate constructor}} + ImplicitNonConstCopy2(); // expected-note {{candidate constructor}} NonConstCopy ncc; }; -struct ImplicitNonConstCopy3 { - ImplicitNonConstCopy3(); +struct ImplicitNonConstCopy3 { // expected-note {{candidate constructor}} + ImplicitNonConstCopy3(); // expected-note {{candidate constructor}} NonConstCopy ncc_array[2][3]; }; -struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { - ImplicitNonConstCopy4(); +struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { // expected-note {{candidate constructor}} + ImplicitNonConstCopy4(); // expected-note {{candidate constructor}} }; void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1, const ImplicitNonConstCopy2 &cincc2, const ImplicitNonConstCopy3 &cincc3, const ImplicitNonConstCopy4 &cincc4) { - (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{functional-style cast from 'ImplicitNonConstCopy1 const' to 'ImplicitNonConstCopy1' is not allowed}} - (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{functional-style cast from 'ImplicitNonConstCopy2 const' to 'ImplicitNonConstCopy2' is not allowed}} - (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{functional-style cast from 'ImplicitNonConstCopy3 const' to 'ImplicitNonConstCopy3' is not allowed}} - (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{functional-style cast from 'ImplicitNonConstCopy4 const' to 'ImplicitNonConstCopy4' is not allowed}} + (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy1' to 'ImplicitNonConstCopy1'}} + (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy2' to 'ImplicitNonConstCopy2'}} + (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy3' to 'ImplicitNonConstCopy3'}} + (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy4' to 'ImplicitNonConstCopy4'}} } diff --git a/test/CXX/special/class.ctor/p4-0x.cpp b/test/CXX/special/class.ctor/p4-0x.cpp new file mode 100644 index 0000000..e3508e2 --- /dev/null +++ b/test/CXX/special/class.ctor/p4-0x.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// A constructor shall not be declared with a ref-qualifier. +struct X { + X() &; // expected-error{{ref-qualifier '&' is not allowed on a constructor}} + X(int) &&; // expected-error{{ref-qualifier '&&' is not allowed on a constructor}} +}; diff --git a/test/CXX/special/class.dtor/p2-0x.cpp b/test/CXX/special/class.dtor/p2-0x.cpp new file mode 100644 index 0000000..53a2e03 --- /dev/null +++ b/test/CXX/special/class.dtor/p2-0x.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// A destructor shall not be declared with a ref-qualifier. +struct X { + ~X() &; // expected-error{{ref-qualifier '&' is not allowed on a destructor}} +}; + +struct Y { + ~Y() &&; // expected-error{{ref-qualifier '&&' is not allowed on a destructor}} +}; diff --git a/test/CXX/special/class.inhctor/elsewhere.cpp b/test/CXX/special/class.inhctor/elsewhere.cpp new file mode 100644 index 0000000..82944d6 --- /dev/null +++ b/test/CXX/special/class.inhctor/elsewhere.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// Tests related to constructor inheriting, but not specified in [class.inhctor] + +// [namespace.udecl]p8: +// A using-declaration for a class member shall be a member-declaration. + +struct B1 { + B1(int); +}; + +using B1::B1; // expected-error {{using declaration can not refer to class member}} + +// C++0x [namespace.udecl]p10: +// A using-declaration is a declaration and can therefore be used repeatedly +// where (and only where) multiple declarations are allowed. + +struct I1 : B1 { + using B1::B1; // expected-note {{previous using declaration}} + using B1::B1; // expected-error {{redeclaration of using decl}} +}; + +// C++0x [namespace.udecl]p3: +// In a using declaration used as a member-declaration, the nested-name- +// specifier shall name a base class of the class being defined. +// If such a using-declaration names a constructor, the nested-name-specifier +// shall name a direct base class of the class being defined. + +struct D1 : I1 { + using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}} +}; diff --git a/test/CXX/special/class.inhctor/p3.cpp b/test/CXX/special/class.inhctor/p3.cpp new file mode 100644 index 0000000..021f701 --- /dev/null +++ b/test/CXX/special/class.inhctor/p3.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +struct B1 { + B1(int); + B1(int, int); +}; +struct D1 : B1 { + using B1::B1; +}; +D1 d1a(1), d1b(1, 1); + +D1 fd1() { return 1; } + +struct B2 { + explicit B2(int, int = 0, int = 0); +}; +struct D2 : B2 { // expected-note {{candidate constructor}} + using B2::B2; +}; +D2 d2a(1), d2b(1, 1), d2c(1, 1, 1); + +D2 fd2() { return 1; } // expected-error {{no viable conversion}} + +struct B3 { + B3(void*); // expected-note {{inherited from here}} +}; +struct D3 : B3 { // expected-note {{candidate constructor}} + using B3::B3; // expected-note {{candidate constructor (inherited)}} +}; +D3 fd3() { return 1; } // expected-error {{no viable conversion}} diff --git a/test/CXX/special/class.inhctor/p7.cpp b/test/CXX/special/class.inhctor/p7.cpp new file mode 100644 index 0000000..3ad761f --- /dev/null +++ b/test/CXX/special/class.inhctor/p7.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +// Straight from the standard +struct B1 { + B1(int); // expected-note {{previous constructor}} +}; +struct B2 { + B2(int); // expected-note {{conflicting constructor}} +}; +struct D1 : B1, B2 { + using B1::B1; // expected-note {{inherited here}} + using B2::B2; // expected-error {{already inherited constructor with the same signature}} +}; +struct D2 : B1, B2 { + using B1::B1; + using B2::B2; + D2(int); +}; diff --git a/test/CXX/stmt.stmt/stmt.label/p1.cpp b/test/CXX/stmt.stmt/stmt.label/p1.cpp new file mode 100644 index 0000000..90367f8 --- /dev/null +++ b/test/CXX/stmt.stmt/stmt.label/p1.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void f() +{ + int x = 0; + goto label1; + +label1: // expected-note{{previous definition is here}} + x = 1; + goto label2; // expected-error{{use of undeclared label 'label2'}} + +label1: // expected-error{{redefinition of label 'label1'}} + x = 2; +} + +void h() +{ + int x = 0; + switch (x) + { + case 1:; + default:; // expected-error{{multiple default labels in one switch}} + default:; // expected-note{{previous case defined here}} + } +} diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp index 31de685..35e5c91 100644 --- a/test/CXX/stmt.stmt/stmt.select/p3.cpp +++ b/test/CXX/stmt.stmt/stmt.select/p3.cpp @@ -16,4 +16,4 @@ void h() { int x; // expected-error{{redefinition of 'x'}} else int x; // expected-error{{redefinition of 'x'}} -} \ No newline at end of file +} diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp index b0f1c46..9b9b532 100644 --- a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp +++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp @@ -53,7 +53,7 @@ namespace pointer_to_object_parameters { A2 *a12; // expected-error{{must have its address taken}} A2 *a13; A2<&an_X> *a13_2; - A2<(&an_X)> *a13_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}} + A2<(&an_X)> *a13_3; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}} // PR6244 struct X1 {} X1v; @@ -88,19 +88,19 @@ namespace reference_parameters { extern const volatile int cvi; void test() { S0 s0; - S0 s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int const' ignores qualifiers}} - S0 s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int volatile' ignores qualifiers}} - S0 s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'int const volatile' ignores qualifiers}} + S0 s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const int' ignores qualifiers}} + S0 s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'volatile int' ignores qualifiers}} + S0 s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const volatile int' ignores qualifiers}} S1 s1; S1 s1c; - S1 s1v; // expected-error{{reference binding of non-type template parameter of type 'int const &' to template argument of type 'int volatile' ignores qualifiers}} - S1 s1cv; // expected-error{{reference binding of non-type template parameter of type 'int const &' to template argument of type 'int const volatile' ignores qualifiers}} + S1 s1v; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'volatile int' ignores qualifiers}} + S1 s1cv; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'const volatile int' ignores qualifiers}} S2 s2; - S2 s2c; // expected-error{{reference binding of non-type template parameter of type 'int volatile &' to template argument of type 'int const' ignores qualifiers}} + S2 s2c; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const int' ignores qualifiers}} S2 s2v; - S2 s2cv; // expected-error{{reference binding of non-type template parameter of type 'int volatile &' to template argument of type 'int const volatile' ignores qualifiers}} + S2 s2cv; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const volatile int' ignores qualifiers}} S3 s3; S3 s3c; diff --git a/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp new file mode 100644 index 0000000..794a050 --- /dev/null +++ b/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +template struct eval; // expected-note 3{{template is declared here}} + +template