summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ARCMT/Common.h5
-rw-r--r--test/ARCMT/GC-check-warn-nsalloc.m12
-rw-r--r--test/ARCMT/GC-check.m20
-rw-r--r--test/ARCMT/GC-no-arc-runtime.m78
-rw-r--r--test/ARCMT/GC-no-arc-runtime.m.result73
-rw-r--r--test/ARCMT/GC-no-finalize-removal.m90
-rw-r--r--test/ARCMT/GC-no-finalize-removal.m.result98
-rw-r--r--test/ARCMT/GC.h6
-rw-r--r--test/ARCMT/GC.m95
-rw-r--r--test/ARCMT/GC.m.result90
-rw-r--r--test/ARCMT/api.m1
-rw-r--r--test/ARCMT/api.m.result1
-rw-r--r--test/ARCMT/assign-prop-with-arc-runtime.m22
-rw-r--r--test/ARCMT/assign-prop-with-arc-runtime.m.result28
-rw-r--r--test/ARCMT/atautorelease-2.m1
-rw-r--r--test/ARCMT/atautorelease-2.m.result1
-rw-r--r--test/ARCMT/atautorelease-3.m1
-rw-r--r--test/ARCMT/atautorelease-3.m.result1
-rw-r--r--test/ARCMT/atautorelease-check.m1
-rw-r--r--test/ARCMT/atautorelease.m1
-rw-r--r--test/ARCMT/atautorelease.m.result1
-rw-r--r--test/ARCMT/autoreleases.m1
-rw-r--r--test/ARCMT/autoreleases.m.result1
-rw-r--r--test/ARCMT/check-with-serialized-diag.m55
-rw-r--r--test/ARCMT/checking.m44
-rw-r--r--test/ARCMT/cxx-checking.mm1
-rw-r--r--test/ARCMT/cxx-rewrite.mm1
-rw-r--r--test/ARCMT/cxx-rewrite.mm.result1
-rw-r--r--test/ARCMT/dealloc.m1
-rw-r--r--test/ARCMT/dealloc.m.result1
-rw-r--r--test/ARCMT/dispatch.m29
-rw-r--r--test/ARCMT/dispatch.m.result25
-rw-r--r--test/ARCMT/driver-migrate.m6
-rw-r--r--test/ARCMT/init.m3
-rw-r--r--test/ARCMT/init.m.result7
-rw-r--r--test/ARCMT/migrate-emit-errors.m2
-rw-r--r--test/ARCMT/migrate-plist-output.m6
-rw-r--r--test/ARCMT/migrate-space-in-path.m7
-rw-r--r--test/ARCMT/migrate.m7
-rw-r--r--test/ARCMT/no-canceling-bridge-to-bridge-cast.m43
-rw-r--r--test/ARCMT/nonobjc-to-objc-cast-2.m12
-rw-r--r--test/ARCMT/nonobjc-to-objc-cast.m1
-rw-r--r--test/ARCMT/nonobjc-to-objc-cast.m.result1
-rw-r--r--test/ARCMT/objcmt-numeric-literals.m501
-rw-r--r--test/ARCMT/objcmt-numeric-literals.m.result501
-rw-r--r--test/ARCMT/objcmt-subscripting-literals.m137
-rw-r--r--test/ARCMT/objcmt-subscripting-literals.m.result137
-rw-r--r--test/ARCMT/rewrite-block-var.m20
-rw-r--r--test/ARCMT/rewrite-block-var.m.result20
-rw-r--r--test/ARCMT/with-arc-mode-migrate.m4
-rw-r--r--test/ARCMT/with-arc-mode-migrate.m.result4
-rw-r--r--test/ASTMerge/Inputs/interface2.m2
-rw-r--r--test/Analysis/CFContainers.mm204
-rw-r--r--test/Analysis/CFDateGC.m4
-rw-r--r--test/Analysis/CheckNSError.m4
-rw-r--r--test/Analysis/NSPanel.m4
-rw-r--r--test/Analysis/NSString.m22
-rw-r--r--test/Analysis/ObjCProperties.m4
-rw-r--r--test/Analysis/ObjCRetSigs.m2
-rw-r--r--test/Analysis/additive-folding.c4
-rw-r--r--test/Analysis/array-struct-region.c4
-rw-r--r--test/Analysis/auto-obj-dtors-cfg-output.cpp1422
-rw-r--r--test/Analysis/bool-assignment.cpp87
-rw-r--r--test/Analysis/bool-assignment2.c35
-rw-r--r--test/Analysis/bstring.c8
-rw-r--r--test/Analysis/casts.m3
-rw-r--r--test/Analysis/check-deserialization.cpp20
-rw-r--r--test/Analysis/coverage.c94
-rw-r--r--test/Analysis/cstring-syntax-cxx.cpp16
-rw-r--r--test/Analysis/cstring-syntax.c13
-rw-r--r--test/Analysis/dead-stores.c30
-rw-r--r--test/Analysis/dead-stores.m14
-rw-r--r--test/Analysis/debug-CallGraph.c21
-rw-r--r--test/Analysis/default-analyze.m63
-rw-r--r--test/Analysis/domtest.c165
-rw-r--r--test/Analysis/dtor.cpp2
-rw-r--r--test/Analysis/dtors-in-dtor-cfg-output.cpp42
-rw-r--r--test/Analysis/dynamic-cast.cpp230
-rw-r--r--test/Analysis/exercise-ps.c2
-rw-r--r--test/Analysis/free.c3
-rw-r--r--test/Analysis/global-region-invalidation.c75
-rw-r--r--test/Analysis/html-diags-multifile.c17
-rw-r--r--test/Analysis/html-diags-multifile.h4
-rw-r--r--test/Analysis/html-diags.c20
-rw-r--r--test/Analysis/idempotent-operations-limited-loops.c6
-rw-r--r--test/Analysis/idempotent-operations.c3
-rw-r--r--test/Analysis/idempotent-operations.cpp2
-rw-r--r--test/Analysis/idempotent-operations.m2
-rw-r--r--test/Analysis/initializers-cfg-output.cpp109
-rw-r--r--test/Analysis/inline-not-supported.c29
-rw-r--r--test/Analysis/inline-plist.c369
-rw-r--r--test/Analysis/inline-unique-reports.c184
-rw-r--r--test/Analysis/inline.c65
-rw-r--r--test/Analysis/inline2.c2
-rw-r--r--test/Analysis/inline3.c4
-rw-r--r--test/Analysis/inline4.c2
-rw-r--r--test/Analysis/keychainAPI.m94
-rw-r--r--test/Analysis/lambdas.cpp20
-rw-r--r--test/Analysis/malloc-annotations.c271
-rw-r--r--test/Analysis/malloc-interprocedural.c98
-rw-r--r--test/Analysis/malloc-plist.c2814
-rw-r--r--test/Analysis/malloc-sizeof.c27
-rw-r--r--test/Analysis/malloc.c722
-rw-r--r--test/Analysis/malloc.cpp16
-rw-r--r--test/Analysis/malloc.m37
-rw-r--r--test/Analysis/malloc.mm156
-rw-r--r--test/Analysis/method-arg-decay.m5
-rw-r--r--test/Analysis/method-call-intra-p.cpp32
-rw-r--r--test/Analysis/misc-ps-cxx0x.cpp5
-rw-r--r--test/Analysis/misc-ps-region-store.cpp115
-rw-r--r--test/Analysis/misc-ps-region-store.m26
-rw-r--r--test/Analysis/misc-ps-region-store.mm17
-rw-r--r--test/Analysis/misc-ps.c81
-rw-r--r--test/Analysis/misc-ps.m36
-rw-r--r--test/Analysis/new.cpp1
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m28
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m18
-rw-r--r--test/Analysis/null-deref-ps.c29
-rw-r--r--test/Analysis/nullptr.cpp38
-rw-r--r--test/Analysis/objc-arc.m67
-rw-r--r--test/Analysis/objc-bool.m22
-rw-r--r--test/Analysis/objc-method-coverage.m17
-rw-r--r--test/Analysis/out-of-bounds.c6
-rw-r--r--test/Analysis/plist-output-alternate.m289
-rw-r--r--test/Analysis/plist-output.m845
-rw-r--r--test/Analysis/pr_2542_rdar_6793404.m2
-rw-r--r--test/Analysis/properties.m25
-rw-r--r--test/Analysis/ptr-arith.c2
-rw-r--r--test/Analysis/rdar-6540084.m2
-rw-r--r--test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m6
-rw-r--r--test/Analysis/redefined_system.c17
-rw-r--r--test/Analysis/reference.cpp2
-rw-r--r--test/Analysis/retain-release-gc-only.m4
-rw-r--r--test/Analysis/retain-release-inline.m347
-rw-r--r--test/Analysis/retain-release-path-notes-gc.m8
-rw-r--r--test/Analysis/retain-release-path-notes.m16
-rw-r--r--test/Analysis/retain-release-region-store.m7
-rw-r--r--test/Analysis/retain-release.m159
-rw-r--r--test/Analysis/retain-release.mm51
-rw-r--r--test/Analysis/security-syntax-checks-no-emit.c2
-rw-r--r--test/Analysis/security-syntax-checks.m34
-rw-r--r--test/Analysis/self-init.m52
-rw-r--r--test/Analysis/stack-addr-ps.c18
-rw-r--r--test/Analysis/stats.c8
-rw-r--r--test/Analysis/string.c32
-rw-r--r--test/Analysis/system-header-simulator-objc.h114
-rw-r--r--test/Analysis/system-header-simulator.h38
-rw-r--r--test/Analysis/taint-generic.c185
-rw-r--r--test/Analysis/taint-tester.c204
-rw-r--r--test/Analysis/taint-tester.cpp26
-rw-r--r--test/Analysis/taint-tester.m20
-rw-r--r--test/Analysis/temp-obj-dtors-cfg-output.cpp1315
-rw-r--r--test/Analysis/uninit-vals-ps-region.m2
-rw-r--r--test/Analysis/unix-fns.c70
-rw-r--r--test/Analysis/unreachable-code-path.c17
-rw-r--r--test/Analysis/unused-ivars.m2
-rw-r--r--test/Analysis/variadic-method-types.m8
-rw-r--r--test/Analysis/virtualcall.cpp53
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/CXX/basic/basic.link/p9.cpp3
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp2
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp2
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp27
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2f.cpp4
-rw-r--r--test/CXX/basic/basic.start/basic.start.main/p2i.cpp6
-rw-r--r--test/CXX/basic/basic.types/p10.cpp87
-rw-r--r--test/CXX/class.access/class.protected/p1-cxx11.cpp20
-rw-r--r--test/CXX/class.access/class.protected/p1.cpp102
-rw-r--r--test/CXX/class.access/p4.cpp4
-rw-r--r--test/CXX/class.access/p6.cpp2
-rw-r--r--test/CXX/class.derived/class.member.lookup/p6.cpp2
-rw-r--r--test/CXX/class.derived/p1.cpp40
-rw-r--r--test/CXX/class/class.base/class.base.init/p5-0x.cpp26
-rw-r--r--test/CXX/class/class.friend/p1-cxx11.cpp12
-rw-r--r--test/CXX/class/class.friend/p1.cpp20
-rw-r--r--test/CXX/class/class.friend/p6.cpp2
-rw-r--r--test/CXX/class/class.local/p1-0x.cpp18
-rw-r--r--test/CXX/class/class.local/p1.cpp2
-rw-r--r--test/CXX/class/class.local/p3.cpp2
-rw-r--r--test/CXX/class/class.mem/p13.cpp2
-rw-r--r--test/CXX/class/class.nest/p1-cxx0x.cpp2
-rw-r--r--test/CXX/class/class.nest/p1.cpp6
-rw-r--r--test/CXX/class/class.static/class.static.data/p3.cpp22
-rw-r--r--test/CXX/class/class.union/p1.cpp7
-rw-r--r--test/CXX/class/class.union/p2-0x.cpp48
-rw-r--r--test/CXX/class/p6-0x.cpp15
-rw-r--r--test/CXX/conv/conv.prom/p2.cpp16
-rw-r--r--test/CXX/conv/conv.prom/p4.cpp9
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp4
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp27
-rw-r--r--test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp13
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp31
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp40
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp47
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp112
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp42
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp14
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp26
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp26
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp8
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp4
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp7
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp7
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp6
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp108
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp14
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp11
-rw-r--r--test/CXX/dcl.dcl/p4-0x.cpp21
-rw-r--r--test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp56
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp48
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp14
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp40
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp210
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp4
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp12
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp41
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp14
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp2
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp24
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/p1.cpp37
-rw-r--r--test/CXX/dcl.decl/dcl.name/p1.cpp6
-rw-r--r--test/CXX/except/except.spec/p1.cpp2
-rw-r--r--test/CXX/expr/expr.ass/p9-cxx11.cpp34
-rw-r--r--test/CXX/expr/expr.const/p2-0x.cpp575
-rw-r--r--test/CXX/expr/expr.const/p3-0x-nowarn.cpp8
-rw-r--r--test/CXX/expr/expr.const/p3-0x.cpp110
-rw-r--r--test/CXX/expr/expr.const/p5-0x.cpp85
-rw-r--r--test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp12
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp38
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp20
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp78
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm88
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp50
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp40
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp16
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp77
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp16
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp75
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp12
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp40
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp45
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp28
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp42
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp12
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp9
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp58
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp6
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp51
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm8
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp64
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp22
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp56
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp29
-rw-r--r--test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp149
-rw-r--r--test/CXX/expr/expr.prim/p12-0x.cpp12
-rw-r--r--test/CXX/expr/expr.prim/p4-0x.cpp10
-rw-r--r--test/CXX/expr/expr.unary/expr.new/p17-crash.cpp14
-rw-r--r--test/CXX/expr/expr.unary/expr.new/p17.cpp16
-rw-r--r--test/CXX/expr/expr.unary/expr.unary.op/p3.cpp28
-rw-r--r--test/CXX/lex/lex.charset/p2-cxx11.cpp42
-rw-r--r--test/CXX/lex/lex.charset/p2-cxx98.cpp55
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p1.cpp6
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p10.cpp14
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p2.cpp16
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p3.cpp18
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p4.cpp18
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p5.cpp13
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p6.cpp14
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p7.cpp27
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p8.cpp18
-rw-r--r--test/CXX/lex/lex.literal/lex.ext/p9.cpp13
-rw-r--r--test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp15
-rw-r--r--test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp37
-rw-r--r--test/CXX/over/over.oper/over.literal/p2.cpp35
-rw-r--r--test/CXX/over/over.oper/over.literal/p3.cpp40
-rw-r--r--test/CXX/over/over.oper/over.literal/p5.cpp22
-rw-r--r--test/CXX/over/over.oper/over.literal/p6.cpp13
-rw-r--r--test/CXX/over/over.oper/over.literal/p7.cpp16
-rw-r--r--test/CXX/over/over.oper/over.literal/p8.cpp19
-rw-r--r--test/CXX/over/over.over/p2-resolve-single-template-id.cpp12
-rw-r--r--test/CXX/special/class.copy/implicit-move-def.cpp19
-rw-r--r--test/CXX/special/class.copy/implicit-move.cpp88
-rw-r--r--test/CXX/special/class.copy/p11.0x.copy.cpp73
-rw-r--r--test/CXX/special/class.copy/p11.0x.move.cpp83
-rw-r--r--test/CXX/special/class.copy/p13-0x.cpp60
-rw-r--r--test/CXX/special/class.copy/p15-0x.cpp23
-rw-r--r--test/CXX/special/class.copy/p15-inclass.cpp42
-rw-r--r--test/CXX/special/class.ctor/p5-0x.cpp143
-rw-r--r--test/CXX/special/class.ctor/p6-0x.cpp57
-rw-r--r--test/CXX/special/class.dtor/p10-0x.cpp39
-rw-r--r--test/CXX/special/class.dtor/p5-0x.cpp104
-rw-r--r--test/CXX/special/class.free/p1.cpp4
-rw-r--r--test/CXX/special/class.free/p6.cpp4
-rw-r--r--test/CXX/special/class.inhctor/elsewhere.cpp26
-rw-r--r--test/CXX/special/class.inhctor/p3.cpp18
-rw-r--r--test/CXX/special/class.inhctor/p7.cpp13
-rw-r--r--test/CXX/special/class.init/class.base.init/p8-0x.cpp13
-rw-r--r--test/CXX/special/class.temporary/p1.cpp3
-rw-r--r--test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp40
-rw-r--r--test/CXX/stmt.stmt/stmt.dcl/p3.cpp4
-rw-r--r--test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp2
-rw-r--r--test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp39
-rw-r--r--test/CXX/temp/p3.cpp4
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp60
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp66
-rw-r--r--test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp152
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp127
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/p4.cpp59
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/p5.cpp12
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp8
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp17
-rw-r--r--test/CXX/temp/temp.param/p11-0x.cpp3
-rw-r--r--test/CXX/temp/temp.param/p5.cpp13
-rw-r--r--test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp27
-rw-r--r--test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp21
-rw-r--r--test/CXX/temp/temp.spec/p5.cpp5
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp125
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp6
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp15
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp9
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p2.cpp2
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p3.cpp9
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p4.cpp2
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p5.cpp2
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p8.cpp23
-rw-r--r--test/CXX/temp/temp.spec/temp.inst/p1.cpp104
-rw-r--r--test/CodeCompletion/enum-switch-case.c2
-rw-r--r--test/CodeCompletion/ordinary-name.cpp38
-rw-r--r--test/CodeGen/2005-05-06-CountBuiltins.c17
-rw-r--r--test/CodeGen/2007-09-28-PackedUnionMember.c2
-rw-r--r--test/CodeGen/2009-02-13-zerosize-union-field-ppc.c3
-rw-r--r--test/CodeGen/2009-10-20-GlobalDebug.c7
-rw-r--r--test/CodeGen/3dnow-builtins.c156
-rw-r--r--test/CodeGen/Inputs/stdio.h9
-rw-r--r--test/CodeGen/address-safety-attr.cpp35
-rw-r--r--test/CodeGen/align-param.c18
-rw-r--r--test/CodeGen/alignment.c59
-rw-r--r--test/CodeGen/altivec.c9
-rw-r--r--test/CodeGen/arm-aapcs-vfp.c8
-rw-r--r--test/CodeGen/arm-aapcs-zerolength-bitfield.c236
-rw-r--r--test/CodeGen/arm-arguments.c12
-rw-r--r--test/CodeGen/arm-vector-align.c10
-rw-r--r--test/CodeGen/asm-inout.c23
-rw-r--r--test/CodeGen/asm-label.c13
-rw-r--r--test/CodeGen/asm-variable.c6
-rw-r--r--test/CodeGen/asm.c16
-rw-r--r--test/CodeGen/atomic-ops.c267
-rw-r--r--test/CodeGen/atomic.c8
-rw-r--r--test/CodeGen/atomic_ops.c14
-rw-r--r--test/CodeGen/avx-builtins.c25
-rw-r--r--test/CodeGen/avx-shuffle-builtins.c49
-rw-r--r--test/CodeGen/avx2-builtins.c782
-rw-r--r--test/CodeGen/bmi-builtins.c79
-rw-r--r--test/CodeGen/bmi2-builtins.c36
-rw-r--r--test/CodeGen/builtin-count-zeros.c8
-rw-r--r--test/CodeGen/builtin-memfns.c15
-rw-r--r--test/CodeGen/builtin-recursive.cc10
-rw-r--r--test/CodeGen/builtins-x86.c21
-rw-r--r--test/CodeGen/builtinshufflevector2.c35
-rw-r--r--test/CodeGen/cfstring.c10
-rw-r--r--test/CodeGen/char-literal.c63
-rw-r--r--test/CodeGen/complex-indirect.c10
-rw-r--r--test/CodeGen/complex-init-list.c8
-rw-r--r--test/CodeGen/compound-literal.c5
-rw-r--r--test/CodeGen/conditional.c6
-rw-r--r--test/CodeGen/const-init.c12
-rw-r--r--test/CodeGen/count-builtins.c33
-rw-r--r--test/CodeGen/darwin-string-literals.c7
-rw-r--r--test/CodeGen/debug-info-args.c9
-rw-r--r--test/CodeGen/debug-info-block.c11
-rw-r--r--test/CodeGen/debug-info-compilation-dir.c6
-rw-r--r--test/CodeGen/debug-info-iv.c3
-rw-r--r--test/CodeGen/debug-info-static.c8
-rw-r--r--test/CodeGen/debug-line-1.c20
-rw-r--r--test/CodeGen/decl-in-prototype.c21
-rw-r--r--test/CodeGen/ext-vector-member-alignment.c27
-rw-r--r--test/CodeGen/ext-vector.c24
-rw-r--r--test/CodeGen/fma4-builtins.c166
-rw-r--r--test/CodeGen/frame-pointer-elim.c8
-rw-r--r--test/CodeGen/global-init.c2
-rw-r--r--test/CodeGen/init.c7
-rw-r--r--test/CodeGen/inline.c31
-rw-r--r--test/CodeGen/kr-call.c12
-rw-r--r--test/CodeGen/libcalls-fno-builtin.c28
-rw-r--r--test/CodeGen/lifetime.c23
-rw-r--r--test/CodeGen/link-bitcode-file.c24
-rw-r--r--test/CodeGen/lzcnt-builtins.c24
-rw-r--r--test/CodeGen/mips-clobber-reg.c80
-rw-r--r--test/CodeGen/mips-constraint-regs.c44
-rw-r--r--test/CodeGen/mips64-class-return.cpp46
-rw-r--r--test/CodeGen/mips64-f128-literal.c9
-rw-r--r--test/CodeGen/mips64-nontrivial-return.cpp17
-rw-r--r--test/CodeGen/mips64-padding-arg.c43
-rw-r--r--test/CodeGen/mmx-inline-asm.c2
-rw-r--r--test/CodeGen/mmx-shift-with-immediate.c2
-rw-r--r--test/CodeGen/ms-declspecs.c16
-rw-r--r--test/CodeGen/mult-alt-generic.c2
-rw-r--r--test/CodeGen/noinline.c14
-rw-r--r--test/CodeGen/object-size.c3
-rw-r--r--test/CodeGen/override-layout.c174
-rw-r--r--test/CodeGen/packed-nest-unpacked.c31
-rw-r--r--test/CodeGen/pascal-wchar-string.c4
-rw-r--r--test/CodeGen/popcnt-builtins.c16
-rw-r--r--test/CodeGen/powerpc_types.c (renamed from test/CodeGen/va_list_test.c)4
-rw-r--r--test/CodeGen/pr12251.c11
-rw-r--r--test/CodeGen/pr9614.c9
-rw-r--r--test/CodeGen/redefine_extname.c15
-rw-r--r--test/CodeGen/sse-builtins.c49
-rw-r--r--test/CodeGen/statements.c2
-rw-r--r--test/CodeGen/string-literal-short-wstring.c15
-rw-r--r--test/CodeGen/string-literal-unicode-conversion.c63
-rw-r--r--test/CodeGen/string-literal.c30
-rw-r--r--test/CodeGen/switch-dce.c31
-rw-r--r--test/CodeGen/tbaa-for-vptr.cpp19
-rw-r--r--test/CodeGen/utf16-cfstrings.c10
-rw-r--r--test/CodeGen/var-align.c4
-rw-r--r--test/CodeGen/vla-4.c24
-rw-r--r--test/CodeGen/vla.c3
-rw-r--r--test/CodeGen/vld_dup.c49
-rw-r--r--test/CodeGen/wchar-const.c4
-rw-r--r--test/CodeGen/x86_32-arguments-darwin.c51
-rw-r--r--test/CodeGen/x86_32-arguments-win32.c48
-rw-r--r--test/CodeGen/x86_64-arguments.c54
-rw-r--r--test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp2
-rw-r--r--test/CodeGenCXX/2011-12-19-init-list-ctor.cpp26
-rw-r--r--test/CodeGenCXX/2012-02-06-VecInitialization.cpp8
-rw-r--r--test/CodeGenCXX/2012-03-16-StoreAlign.cpp36
-rw-r--r--test/CodeGenCXX/apple-kext-guard-variable.cpp2
-rw-r--r--test/CodeGenCXX/apple-kext.cpp22
-rw-r--r--test/CodeGenCXX/arm.cpp26
-rw-r--r--test/CodeGenCXX/assign-operator.cpp11
-rw-r--r--test/CodeGenCXX/atomic.cpp17
-rw-r--r--test/CodeGenCXX/atomicinit.cpp48
-rw-r--r--test/CodeGenCXX/block.cpp19
-rw-r--r--test/CodeGenCXX/blocks-cxx11.cpp84
-rw-r--r--test/CodeGenCXX/blocks.cpp98
-rw-r--r--test/CodeGenCXX/c99-variable-length-array.cpp10
-rw-r--r--test/CodeGenCXX/compound-literals.cpp17
-rw-r--r--test/CodeGenCXX/conditional-gnu-ext.cpp8
-rw-r--r--test/CodeGenCXX/const-base-cast.cpp5
-rw-r--r--test/CodeGenCXX/const-init-cxx11.cpp425
-rw-r--r--test/CodeGenCXX/const-init.cpp42
-rw-r--r--test/CodeGenCXX/constructor-init.cpp3
-rw-r--r--test/CodeGenCXX/constructors.cpp2
-rw-r--r--test/CodeGenCXX/copy-constructor-elim-2.cpp22
-rw-r--r--test/CodeGenCXX/cxx-apple-kext.cpp4
-rw-r--r--test/CodeGenCXX/cxx0x-initializer-array.cpp10
-rw-r--r--test/CodeGenCXX/cxx0x-initializer-references.cpp69
-rw-r--r--test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp37
-rw-r--r--test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp85
-rw-r--r--test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp252
-rw-r--r--test/CodeGenCXX/cxx11-unrestricted-union.cpp76
-rw-r--r--test/CodeGenCXX/cxx11-user-defined-literal.cpp69
-rw-r--r--test/CodeGenCXX/debug-info-artificial-arg.cpp30
-rw-r--r--test/CodeGenCXX/debug-info-byval.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-char16.cpp7
-rw-r--r--test/CodeGenCXX/debug-info-context.cpp17
-rw-r--r--test/CodeGenCXX/debug-info-dup-fwd-decl.cpp24
-rw-r--r--test/CodeGenCXX/debug-info-fn-template.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-fwd-ref.cpp26
-rw-r--r--test/CodeGenCXX/debug-info-limit-type.cpp24
-rw-r--r--test/CodeGenCXX/debug-info-limit.cpp4
-rw-r--r--test/CodeGenCXX/debug-info-member.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-method-spec.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-method.cpp2
-rw-r--r--test/CodeGenCXX/debug-info-method2.cpp19
-rw-r--r--test/CodeGenCXX/debug-info-nullptr.cpp9
-rw-r--r--test/CodeGenCXX/debug-info-pubtypes.cpp4
-rw-r--r--test/CodeGenCXX/debug-info-static-fns.cpp10
-rw-r--r--test/CodeGenCXX/debug-info-template-limit.cpp15
-rw-r--r--test/CodeGenCXX/debug-info-template-member.cpp21
-rw-r--r--test/CodeGenCXX/debug-info-template-recursive.cpp13
-rw-r--r--test/CodeGenCXX/debug-info-use-after-free.cpp312
-rw-r--r--test/CodeGenCXX/debug-lambda-expressions.cpp71
-rw-r--r--test/CodeGenCXX/default-arguments.cpp11
-rw-r--r--test/CodeGenCXX/empty-union.cpp9
-rw-r--r--test/CodeGenCXX/exceptions.cpp33
-rw-r--r--test/CodeGenCXX/field-access-debug-info.cpp7
-rw-r--r--test/CodeGenCXX/for-range-temporaries.cpp7
-rw-r--r--test/CodeGenCXX/forward-enum.cpp11
-rw-r--r--test/CodeGenCXX/global-dtor-no-atexit.cpp35
-rw-r--r--test/CodeGenCXX/global-init.cpp8
-rw-r--r--test/CodeGenCXX/goto.cpp2
-rw-r--r--test/CodeGenCXX/inheriting-constructor.cpp9
-rw-r--r--test/CodeGenCXX/init-invariant.cpp60
-rw-r--r--test/CodeGenCXX/instantiate-temporaries.cpp37
-rw-r--r--test/CodeGenCXX/lambda-expressions.cpp78
-rw-r--r--test/CodeGenCXX/mangle-98.cpp12
-rw-r--r--test/CodeGenCXX/mangle-address-space.cpp6
-rw-r--r--test/CodeGenCXX/mangle-alias-template.cpp7
-rw-r--r--test/CodeGenCXX/mangle-exprs.cpp66
-rw-r--r--test/CodeGenCXX/mangle-lambdas.cpp202
-rw-r--r--test/CodeGenCXX/mangle-ms.cpp13
-rw-r--r--test/CodeGenCXX/mangle-nullptr-arg.cpp13
-rw-r--r--test/CodeGenCXX/mangle-std-externc.cpp27
-rw-r--r--test/CodeGenCXX/mangle-template.cpp26
-rw-r--r--test/CodeGenCXX/mangle.cpp11
-rw-r--r--test/CodeGenCXX/member-function-pointer-calls.cpp6
-rw-r--r--test/CodeGenCXX/member-function-pointers.cpp40
-rw-r--r--test/CodeGenCXX/new-array-init-exceptions.cpp41
-rw-r--r--test/CodeGenCXX/new-array-init.cpp33
-rw-r--r--test/CodeGenCXX/new.cpp19
-rw-r--r--test/CodeGenCXX/nrvo.cpp12
-rw-r--r--test/CodeGenCXX/override-layout.cpp64
-rw-r--r--test/CodeGenCXX/pointers-to-data-members.cpp10
-rw-r--r--test/CodeGenCXX/pr11676.cpp17
-rw-r--r--test/CodeGenCXX/pr11797.cpp8
-rw-r--r--test/CodeGenCXX/pr12104.cpp7
-rw-r--r--test/CodeGenCXX/pr12104.h9
-rw-r--r--test/CodeGenCXX/pr12251.cpp146
-rw-r--r--test/CodeGenCXX/pr9965.cpp4
-rw-r--r--test/CodeGenCXX/pragma-pack-2.cpp17
-rw-r--r--test/CodeGenCXX/pragma-visibility.cpp12
-rw-r--r--test/CodeGenCXX/predefined-expr-sizeof.cpp8
-rw-r--r--test/CodeGenCXX/predefined-expr.cpp180
-rw-r--r--test/CodeGenCXX/references.cpp14
-rw-r--r--test/CodeGenCXX/regparm.cpp6
-rw-r--r--test/CodeGenCXX/static-data-member.cpp38
-rw-r--r--test/CodeGenCXX/static-init.cpp93
-rw-r--r--test/CodeGenCXX/static-mutable.cpp12
-rw-r--r--test/CodeGenCXX/switch-case-folding-1.cpp22
-rw-r--r--test/CodeGenCXX/switch-case-folding-2.cpp21
-rw-r--r--test/CodeGenCXX/switch-case-folding.cpp18
-rw-r--r--test/CodeGenCXX/temporaries.cpp18
-rw-r--r--test/CodeGenCXX/thiscall-struct-return.cpp41
-rw-r--r--test/CodeGenCXX/throw-expressions.cpp5
-rw-r--r--test/CodeGenCXX/thunk-use-after-free.cpp42
-rw-r--r--test/CodeGenCXX/thunks.cpp4
-rw-r--r--test/CodeGenCXX/typeid-cxx11.cpp30
-rw-r--r--test/CodeGenCXX/typeid.cpp21
-rw-r--r--test/CodeGenCXX/uncode-string.cpp2
-rw-r--r--test/CodeGenCXX/value-init.cpp3
-rw-r--r--test/CodeGenCXX/virtual-implicit-move-assignment.cpp12
-rw-r--r--test/CodeGenCXX/visibility-inlines-hidden.cpp11
-rw-r--r--test/CodeGenCXX/visibility.cpp161
-rw-r--r--test/CodeGenCXX/vla.cpp15
-rw-r--r--test/CodeGenCXX/vtable-layout.cpp26
-rw-r--r--test/CodeGenCXX/weak-extern-typeinfo.cpp47
-rw-r--r--test/CodeGenCXX/x86_32-arguments.cpp2
-rw-r--r--test/CodeGenObjC/2009-08-05-utf16.m2
-rw-r--r--test/CodeGenObjC/Inputs/literal-support.h35
-rw-r--r--test/CodeGenObjC/arc-blocks.m523
-rw-r--r--test/CodeGenObjC/arc-cond-stmt.m48
-rw-r--r--test/CodeGenObjC/arc-exceptions.m45
-rw-r--r--test/CodeGenObjC/arc-foreach.m6
-rw-r--r--test/CodeGenObjC/arc-ivar-layout.m11
-rw-r--r--test/CodeGenObjC/arc-literals.m121
-rw-r--r--test/CodeGenObjC/arc-no-arc-exceptions.m78
-rw-r--r--test/CodeGenObjC/arc-property.m15
-rw-r--r--test/CodeGenObjC/arc.m537
-rw-r--r--test/CodeGenObjC/auto-property-synthesize-protocol.m37
-rw-r--r--test/CodeGenObjC/catch-lexical-block.m16
-rw-r--r--test/CodeGenObjC/complex-double-abi.m16
-rw-r--r--test/CodeGenObjC/constant-strings.m2
-rw-r--r--test/CodeGenObjC/debug-info-block-helper.m4
-rw-r--r--test/CodeGenObjC/debug-info-fwddecl.m5
-rw-r--r--test/CodeGenObjC/debug-info-getter-name.m8
-rw-r--r--test/CodeGenObjC/debug-info-impl.m16
-rw-r--r--test/CodeGenObjC/debug-info-property.m2
-rw-r--r--test/CodeGenObjC/debug-info-property3.m12
-rw-r--r--test/CodeGenObjC/debug-info-property4.m17
-rw-r--r--test/CodeGenObjC/debug-info-property5.m32
-rw-r--r--test/CodeGenObjC/debug-info-pubtypes.m9
-rw-r--r--test/CodeGenObjC/debug-info-static-var.m5
-rw-r--r--test/CodeGenObjC/debug-info-synthesis.m34
-rw-r--r--test/CodeGenObjC/debug-property-synth.m3
-rw-r--r--test/CodeGenObjC/exceptions.m6
-rw-r--r--test/CodeGenObjC/forward-class-impl-metadata.m6
-rw-r--r--test/CodeGenObjC/fp2ret.m28
-rw-r--r--test/CodeGenObjC/image-info.m13
-rw-r--r--test/CodeGenObjC/ivar-base-as-invariant-load.m29
-rw-r--r--test/CodeGenObjC/ns_consume_null_check.m32
-rw-r--r--test/CodeGenObjC/objc-align.m2
-rw-r--r--test/CodeGenObjC/objc-arc-container-subscripting.m21
-rw-r--r--test/CodeGenObjC/objc-container-subscripting-1.m56
-rw-r--r--test/CodeGenObjC/objc-container-subscripting.m45
-rw-r--r--test/CodeGenObjC/objc-dictionary-literal.m25
-rw-r--r--test/CodeGenObjC/objc-literal-debugger-test.m16
-rw-r--r--test/CodeGenObjC/objc-literal-tests.m95
-rw-r--r--test/CodeGenObjC/optimized-setter.m33
-rw-r--r--test/CodeGenObjC/property.m54
-rw-r--r--test/CodeGenObjC/selector-ref-invariance.m9
-rw-r--r--test/CodeGenObjC/variadic-sends.m8
-rw-r--r--test/CodeGenObjCXX/Inputs/literal-support.h35
-rw-r--r--test/CodeGenObjCXX/address-safety-attr.mm20
-rw-r--r--test/CodeGenObjCXX/arc-exceptions.mm85
-rw-r--r--test/CodeGenObjCXX/arc.mm69
-rw-r--r--test/CodeGenObjCXX/copy.mm2
-rw-r--r--test/CodeGenObjCXX/debug-info.mm41
-rw-r--r--test/CodeGenObjCXX/lambda-expressions.mm39
-rw-r--r--test/CodeGenObjCXX/literals.mm111
-rw-r--r--test/CodeGenObjCXX/lvalue-reference-getter.mm28
-rw-r--r--test/CodeGenObjCXX/objc-container-subscripting-1.mm50
-rw-r--r--test/CodeGenObjCXX/objc-container-subscripting.mm57
-rw-r--r--test/CodeGenObjCXX/property-object-reference-1.mm31
-rw-r--r--test/CodeGenObjCXX/property-object-reference-2.mm56
-rw-r--r--test/CodeGenObjCXX/property-object-reference.mm12
-rw-r--r--test/CodeGenObjCXX/property-reference.mm44
-rw-r--r--test/CodeGenOpenCL/fpaccuracy.cl25
-rw-r--r--test/CodeGenOpenCL/vector_literals_nested.cl23
-rw-r--r--test/CodeGenOpenCL/vector_logops.cl19
-rw-r--r--test/Coverage/targets.c3
-rw-r--r--test/Driver/Inputs/basic_freebsd64_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep0
-rw-r--r--test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o0
-rw-r--r--test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep0
-rw-r--r--test/Driver/Inputs/basic_freebsd_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep0
-rw-r--r--test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o0
-rw-r--r--test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep0
-rw-r--r--test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o0
-rw-r--r--test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep0
-rw-r--r--test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o0
-rwxr-xr-xtest/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as2
-rwxr-xr-xtest/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld2
-rw-r--r--test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep0
-rw-r--r--test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o0
-rw-r--r--test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o0
-rw-r--r--test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o0
-rw-r--r--test/Driver/Wp-args.c2
-rw-r--r--test/Driver/Xarch.c6
-rw-r--r--test/Driver/Xlinker-args.c2
-rw-r--r--test/Driver/altivec.cpp14
-rw-r--r--test/Driver/analyze.c2
-rw-r--r--test/Driver/apple-kext-i386.cpp20
-rw-r--r--test/Driver/apple-kext-mkernel.c8
-rw-r--r--test/Driver/arc.c13
-rw-r--r--test/Driver/arch.c2
-rw-r--r--test/Driver/arclite-link.c8
-rw-r--r--test/Driver/arm-darwin-builtin.c6
-rw-r--r--test/Driver/arm-mfpmath.c29
-rw-r--r--test/Driver/arm-mfpu.c48
-rw-r--r--test/Driver/asan.c8
-rw-r--r--test/Driver/ast.c4
-rw-r--r--test/Driver/bindings.c28
-rw-r--r--test/Driver/cc-log-diagnostics.c4
-rw-r--r--test/Driver/ccc-host-triple-no-integrated-as.c8
-rw-r--r--test/Driver/cfi.c5
-rw-r--r--test/Driver/clang-translation.c12
-rw-r--r--test/Driver/cpath.c18
-rw-r--r--test/Driver/cpp-precomp.c5
-rw-r--r--test/Driver/darwin-as.c11
-rw-r--r--test/Driver/darwin-cc.c2
-rw-r--r--test/Driver/darwin-debug-flags.c6
-rw-r--r--test/Driver/darwin-dsymutil.c10
-rw-r--r--test/Driver/darwin-iphone-defaults.m6
-rw-r--r--test/Driver/darwin-ld.c71
-rw-r--r--test/Driver/darwin-objc-defaults.m18
-rw-r--r--test/Driver/darwin-objc-gc.m2
-rw-r--r--test/Driver/darwin-objc-options.m4
-rw-r--r--test/Driver/darwin-verify-debug.c8
-rw-r--r--test/Driver/darwin-version.c8
-rw-r--r--test/Driver/darwin-xarch.c6
-rw-r--r--test/Driver/debug-options-as.c18
-rw-r--r--test/Driver/debug-options.c27
-rw-r--r--test/Driver/debug.c11
-rw-r--r--test/Driver/default-toolchain.c6
-rw-r--r--test/Driver/diagnostics.c9
-rw-r--r--test/Driver/dragonfly.c2
-rw-r--r--test/Driver/dwarf2-cfi-asm.c35
-rw-r--r--test/Driver/exceptions.m2
-rw-r--r--test/Driver/fast-math.c119
-rw-r--r--test/Driver/flags.c6
-rw-r--r--test/Driver/frame-pointer.c24
-rw-r--r--test/Driver/freebsd.c35
-rw-r--r--test/Driver/gcc-toolchain.cpp23
-rw-r--r--test/Driver/gcc_forward.c2
-rw-r--r--test/Driver/gnu-runtime.m4
-rw-r--r--test/Driver/gold-lto.c6
-rw-r--r--test/Driver/invalid-o-level.c4
-rw-r--r--test/Driver/ios-simulator-arcruntime.c4
-rw-r--r--test/Driver/le32-unknown-nacl.cpp11
-rw-r--r--test/Driver/linker-opts.c5
-rw-r--r--test/Driver/linux-as.c31
-rw-r--r--test/Driver/linux-header-search.cpp75
-rw-r--r--test/Driver/linux-ld.c147
-rw-r--r--test/Driver/mips-as.c31
-rw-r--r--test/Driver/mips-float.c42
-rw-r--r--test/Driver/mno-global-merge.c4
-rw-r--r--test/Driver/modules.m6
-rw-r--r--test/Driver/modules.mm6
-rw-r--r--test/Driver/no-objc-arr.m2
-rw-r--r--test/Driver/no-objc-default-synthesize-properties.m10
-rw-r--r--test/Driver/no-sibling-calls.c8
-rw-r--r--test/Driver/noinline.c10
-rw-r--r--test/Driver/nostdlib.c2
-rw-r--r--test/Driver/nostdlibinc.c2
-rw-r--r--test/Driver/openbsd.c2
-rw-r--r--test/Driver/output-file-cleanup.c25
-rw-r--r--test/Driver/parsing.c3
-rw-r--r--test/Driver/phases.c22
-rw-r--r--test/Driver/pic.c81
-rw-r--r--test/Driver/prefixed-tools.c12
-rw-r--r--test/Driver/pth.c4
-rw-r--r--test/Driver/redundant-args.c2
-rw-r--r--test/Driver/redzone.c4
-rw-r--r--test/Driver/rewrite-legacy-objc.m15
-rw-r--r--test/Driver/rewrite-objc.m8
-rw-r--r--test/Driver/stackrealign.c12
-rw-r--r--test/Driver/sysroot-flags.c6
-rw-r--r--test/Driver/sysroot.c6
-rw-r--r--test/Driver/target.c11
-rw-r--r--test/Driver/tsan.c8
-rw-r--r--test/Driver/unknown-arg.c4
-rw-r--r--test/Driver/unknown-gcc-arch.c8
-rw-r--r--test/Driver/working-directory.c4
-rw-r--r--test/Driver/x86_features.c2
-rw-r--r--test/FixIt/atomic-property.m29
-rw-r--r--test/FixIt/fixit-cxx0x.cpp108
-rw-r--r--test/FixIt/fixit-cxx11-compat.cpp11
-rw-r--r--test/FixIt/fixit-missing-method-return-type.m8
-rw-r--r--test/FixIt/fixit-recompile.c6
-rw-r--r--test/FixIt/fixit-recursive-block.c12
-rw-r--r--test/FixIt/fixit-vexing-parse-cxx0x.cpp21
-rw-r--r--test/FixIt/fixit-vexing-parse.cpp89
-rw-r--r--test/FixIt/fixit.c62
-rw-r--r--test/FixIt/fixit.cpp118
-rw-r--r--test/FixIt/no-fixit.cpp7
-rw-r--r--test/FixIt/objc-literals.m44
-rw-r--r--test/FixIt/typo-crash.cpp17
-rw-r--r--test/FixIt/typo.c2
-rw-r--r--test/FixIt/typo.m6
-rw-r--r--test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h1
-rw-r--r--test/Frontend/Wno-everything.c7
-rw-r--r--test/Frontend/darwin-version.c20
-rw-r--r--test/Frontend/dependency-gen.c8
-rw-r--r--test/Frontend/diagnostic-name.c5
-rw-r--r--test/Frontend/iframework.c3
-rw-r--r--test/Frontend/ir-support-errors.ll4
-rw-r--r--test/Frontend/rewrite-macros.c2
-rw-r--r--test/Headers/c89.c2
-rw-r--r--test/Headers/wmmintrin.c4
-rw-r--r--test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h2
-rw-r--r--test/Index/Inputs/Headers/a.h2
-rw-r--r--test/Index/Inputs/Headers/a_extensions.h1
-rw-r--r--test/Index/Inputs/Headers/crash.h6
-rw-r--r--test/Index/Inputs/Headers/module.map10
-rw-r--r--test/Index/Inputs/Headers/nested/module.map4
-rw-r--r--test/Index/Inputs/Headers/nested/nested.h1
-rw-r--r--test/Index/Inputs/pragma_disable_warning.h1
-rw-r--r--test/Index/Inputs/redeclarations.h21
-rw-r--r--test/Index/Inputs/reparse-instantiate.h14
-rw-r--r--test/Index/TestClassDecl.m2
-rw-r--r--test/Index/TestClassForwardDecl.m2
-rw-r--r--test/Index/annotate-attribute.cpp28
-rw-r--r--test/Index/annotate-literals.m72
-rw-r--r--test/Index/annotate-macro-args.m8
-rw-r--r--test/Index/annotate-subscripting.m92
-rw-r--r--test/Index/annotate-tokens-cxx0x.cpp11
-rw-r--r--test/Index/annotate-tokens-pp.c7
-rw-r--r--test/Index/annotate-tokens.cpp6
-rw-r--r--test/Index/annotate-tokens.m200
-rw-r--r--test/Index/annotate-toplevel-in-objccontainer.m33
-rw-r--r--test/Index/annotate-toplevel-in-objccontainer.m.h9
-rw-r--r--test/Index/asm-attribute.c6
-rw-r--r--test/Index/c-index-api-loadTU-test.m30
-rw-r--r--test/Index/c-index-getCursor-test.m32
-rw-r--r--test/Index/cindex-on-invalid-usrs.m2
-rw-r--r--test/Index/complete-at-exprstmt.m6
-rw-r--r--test/Index/complete-blocks.m15
-rw-r--r--test/Index/complete-cxx-inline-methods.cpp24
-rw-r--r--test/Index/complete-declarators.m4
-rw-r--r--test/Index/complete-enums.c12
-rw-r--r--test/Index/complete-enums.cpp25
-rw-r--r--test/Index/complete-exprs.c6
-rw-r--r--test/Index/complete-exprs.cpp35
-rw-r--r--test/Index/complete-exprs.m19
-rw-r--r--test/Index/complete-in-invalid-method.m19
-rw-r--r--test/Index/complete-ivar-access.m69
-rw-r--r--test/Index/complete-lambdas.cpp43
-rw-r--r--test/Index/complete-macros.c6
-rw-r--r--test/Index/complete-member-access.m17
-rw-r--r--test/Index/complete-method-decls.m36
-rw-r--r--test/Index/complete-modules.m14
-rw-r--r--test/Index/complete-objc-message.m14
-rw-r--r--test/Index/complete-qualified.cpp8
-rw-r--r--test/Index/complete-recovery.m11
-rw-r--r--test/Index/complete-stmt.c6
-rw-r--r--test/Index/complete-super.cpp9
-rw-r--r--test/Index/complete-synthesized.m8
-rw-r--r--test/Index/complete-type-factors.m10
-rw-r--r--test/Index/crash-recovery-code-complete.c3
-rw-r--r--test/Index/crash-recovery-modules.m20
-rw-r--r--test/Index/crash-recovery-reparse.c3
-rw-r--r--test/Index/cxx11-lambdas.cpp33
-rw-r--r--test/Index/error-on-deserialized.c13
-rw-r--r--test/Index/file-macro-refs.c12
-rw-r--r--test/Index/file-refs-subscripting.m65
-rw-r--r--test/Index/file-refs.m48
-rw-r--r--test/Index/fix-its.c11
-rw-r--r--test/Index/get-cursor-macro-args.m4
-rw-r--r--test/Index/get-cursor.cpp13
-rw-r--r--test/Index/get-cursor.m54
-rw-r--r--test/Index/index-attrs.m17
-rw-r--r--test/Index/index-decls.m30
-rw-r--r--test/Index/index-invalid-code.m8
-rw-r--r--test/Index/index-many-logical-ops.c2011
-rw-r--r--test/Index/index-refs.cpp121
-rw-r--r--test/Index/index-subscripting-literals.m66
-rw-r--r--test/Index/index-suppress-refs.cpp12
-rw-r--r--test/Index/index-suppress-refs.h9
-rw-r--r--test/Index/index-suppress-refs.hpp3
-rw-r--r--test/Index/index-suppress-refs.m44
-rw-r--r--test/Index/invalid-code-rdar10451854.m15
-rw-r--r--test/Index/invalid-rdar-8236270.cpp2
-rw-r--r--test/Index/linkage.c8
-rw-r--r--test/Index/local-symbols.m4
-rw-r--r--test/Index/ms-if-exists.cpp24
-rw-r--r--test/Index/nested-macro-instantiations.cpp20
-rw-r--r--test/Index/overrides.m36
-rw-r--r--test/Index/pch-opaque-value.cpp16
-rw-r--r--test/Index/pch-with-errors.c42
-rw-r--r--test/Index/pch-with-errors.m28
-rw-r--r--test/Index/pragma-diag-reparse.c15
-rw-r--r--test/Index/preamble-reparse-import.m12
-rw-r--r--test/Index/preamble-reparse-import.m-1.h5
-rw-r--r--test/Index/preamble-reparse-import.m-2.h5
-rw-r--r--test/Index/preamble-reparse-import.m-3.h1
-rw-r--r--test/Index/print-typekind.c2
-rw-r--r--test/Index/print-typekind.m6
-rw-r--r--test/Index/properties-class-extensions.m4
-rw-r--r--test/Index/recursive-cxx-member-calls.cpp2
-rw-r--r--test/Index/redeclarations.cpp21
-rw-r--r--test/Index/reparse-instantiate.cpp7
-rw-r--r--test/Index/retain-target-options.c8
-rw-r--r--test/Index/targeted-annotation.c99
-rw-r--r--test/Index/targeted-cursor.c65
-rw-r--r--test/Index/targeted-cursor.m6
-rw-r--r--test/Index/targeted-cursor.m.h7
-rw-r--r--test/Index/targeted-fields.h3
-rw-r--r--test/Index/targeted-file-refs.c59
-rw-r--r--test/Index/targeted-nested1.h2
-rw-r--r--test/Index/targeted-preamble.h2
-rw-r--r--test/Index/targeted-top.h24
-rw-r--r--test/Index/unmatched-braces.c9
-rw-r--r--test/Index/unmatched-braces.m11
-rw-r--r--test/Index/usrs.m43
-rw-r--r--test/Index/vector-types.c6
-rw-r--r--test/Index/werror.c5
-rw-r--r--test/Lexer/char-literal-encoding-error.c15
-rw-r--r--test/Lexer/char-literal.cpp24
-rw-r--r--test/Lexer/constants.c2
-rw-r--r--test/Lexer/cxx0x_keyword_as_cxx98.cpp2
-rw-r--r--test/Lexer/cxx0x_raw_string_delim_length.cpp8
-rw-r--r--test/Lexer/escape_newline.c4
-rw-r--r--test/Lexer/has_attribute.cpp12
-rw-r--r--test/Lexer/has_extension.c6
-rw-r--r--test/Lexer/has_extension_cxx.cpp8
-rw-r--r--test/Lexer/has_feature_address_sanitizer.cpp11
-rw-r--r--test/Lexer/has_feature_c1x.c18
-rw-r--r--test/Lexer/has_feature_cxx0x.cpp92
-rw-r--r--test/Lexer/has_feature_modules.m25
-rw-r--r--test/Lexer/has_feature_type_traits.cpp5
-rw-r--r--test/Lexer/hexfloat.cpp5
-rw-r--r--test/Lexer/ms-extensions.c1
-rw-r--r--test/Lexer/ms-extensions.cpp6
-rw-r--r--test/Lexer/newline-eof-c++11.cpp4
-rw-r--r--test/Lexer/newline-eof-c++98-compat.cpp4
-rw-r--r--test/Lexer/newline-eof.c4
-rw-r--r--test/Lexer/rdr-6096838-2.c2
-rw-r--r--test/Lexer/string-literal-encoding.c33
-rw-r--r--test/Lexer/string_concat.cpp48
-rw-r--r--test/Lexer/token-concat.cpp19
-rw-r--r--test/Lexer/utf8-char-literal.cpp5
-rw-r--r--test/Lexer/wchar.c4
-rw-r--r--test/Misc/caret-diags-macros.c58
-rw-r--r--test/Misc/diag-aka-types.cpp18
-rw-r--r--test/Misc/diag-format.c6
-rw-r--r--test/Misc/diag-macro-backtrace.c53
-rw-r--r--test/Misc/diag-verify.cpp48
-rw-r--r--test/Misc/include-stack-for-note-flag.cpp4
-rw-r--r--test/Misc/integer-literal-printing.cpp13
-rw-r--r--test/Misc/macro-backtrace-limit.c32
-rw-r--r--test/Misc/macro-backtrace.c57
-rw-r--r--test/Misc/pubnames.c19
-rw-r--r--test/Misc/serialized-diags-no-category.c12
-rw-r--r--test/Misc/serialized-diags-no-issue.c10
-rw-r--r--test/Misc/serialized-diags-single-issue.c36
-rw-r--r--test/Misc/serialized-diags.c67
-rw-r--r--test/Misc/serialized-diags.h5
-rw-r--r--test/Misc/warn-in-system-header.c2
-rw-r--r--test/Misc/warning-flags.c46
-rw-r--r--test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h1
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h4
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h5
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/Headers/other.h1
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h2
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/module.map19
-rw-r--r--test/Modules/Inputs/DependsOnModule.framework/module_private.map6
-rw-r--r--test/Modules/Inputs/MethodPoolA.h8
-rw-r--r--test/Modules/Inputs/MethodPoolB.h13
-rw-r--r--test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h5
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h1
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Module.h10
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/NotInModule.h1
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Sub.h3
-rw-r--r--test/Modules/Inputs/Module.framework/Headers/Sub2.h1
-rw-r--r--test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h1
-rw-r--r--test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h2
-rw-r--r--test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h2
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/A.h8
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/B.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h1
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/module.map9
-rw-r--r--test/Modules/Inputs/NoUmbrella.framework/module_private.map4
-rw-r--r--test/Modules/Inputs/System/usr/include/module.map21
-rw-r--r--test/Modules/Inputs/System/usr/include/stdbool.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdint.h1
-rw-r--r--test/Modules/Inputs/System/usr/include/stdio.h3
-rw-r--r--test/Modules/Inputs/category_bottom.h11
-rw-r--r--test/Modules/Inputs/category_left.h15
-rw-r--r--test/Modules/Inputs/category_other.h6
-rw-r--r--test/Modules/Inputs/category_right.h12
-rw-r--r--test/Modules/Inputs/category_top.h14
-rw-r--r--test/Modules/Inputs/decl.h2
-rw-r--r--test/Modules/Inputs/decl2.h1
-rw-r--r--test/Modules/Inputs/def-include.h13
-rw-r--r--test/Modules/Inputs/def.h11
-rw-r--r--test/Modules/Inputs/diamond.h1
-rw-r--r--test/Modules/Inputs/diamond_bottom.h4
-rw-r--r--test/Modules/Inputs/diamond_left.h2
-rw-r--r--test/Modules/Inputs/diamond_right.h2
-rw-r--r--test/Modules/Inputs/irgen.h1
-rw-r--r--test/Modules/Inputs/macros.h10
-rw-r--r--test/Modules/Inputs/module.map86
-rw-r--r--test/Modules/Inputs/module_private_left.h26
-rw-r--r--test/Modules/Inputs/module_private_right.h13
-rw-r--r--test/Modules/Inputs/namespaces-left.h53
-rw-r--r--test/Modules/Inputs/namespaces-right.h61
-rw-r--r--test/Modules/Inputs/namespaces-top.h14
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h4
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/module.map3
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/Umbrella2/module.map3
-rw-r--r--test/Modules/Inputs/normal-module-map/a1.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/a2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/b1.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/module.map13
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/module.map4
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/nested1.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/nested/nested2.h1
-rw-r--r--test/Modules/Inputs/normal-module-map/nested_umbrella/a.h2
-rw-r--r--test/Modules/Inputs/normal-module-map/nested_umbrella/b.h2
-rw-r--r--test/Modules/Inputs/redecl-merge-bottom.h28
-rw-r--r--test/Modules/Inputs/redecl-merge-left-left.h7
-rw-r--r--test/Modules/Inputs/redecl-merge-left.h90
-rw-r--r--test/Modules/Inputs/redecl-merge-right.h94
-rw-r--r--test/Modules/Inputs/redecl-merge-top-explicit.h9
-rw-r--r--test/Modules/Inputs/redecl-merge-top.h20
-rw-r--r--test/Modules/Inputs/redecl_namespaces_left.h3
-rw-r--r--test/Modules/Inputs/redecl_namespaces_right.h3
-rw-r--r--test/Modules/Inputs/redeclarations_left.h2
-rw-r--r--test/Modules/Inputs/redeclarations_right.h2
-rw-r--r--test/Modules/Inputs/subdir/module.map3
-rw-r--r--test/Modules/Inputs/subdir/subdir.h1
-rw-r--r--test/Modules/Inputs/submodules/hash_map.h4
-rw-r--r--test/Modules/Inputs/submodules/module.map5
-rw-r--r--test/Modules/Inputs/submodules/type_traits.h12
-rw-r--r--test/Modules/Inputs/submodules/vector.h3
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/A_one.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/A_two.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/B_one.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/B_two.h1
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/C_one.h4
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/C_two.h4
-rw-r--r--test/Modules/Inputs/wildcard-submodule-exports/module.map20
-rw-r--r--test/Modules/auto-module-import.c13
-rw-r--r--test/Modules/auto-module-import.m73
-rw-r--r--test/Modules/compiler_builtins.m10
-rw-r--r--test/Modules/cstd.m29
-rw-r--r--test/Modules/cycles.c12
-rw-r--r--test/Modules/decldef.mm28
-rw-r--r--test/Modules/diamond-pch.c28
-rw-r--r--test/Modules/diamond.c14
-rw-r--r--test/Modules/header-import.m4
-rw-r--r--test/Modules/inferred-submodules.m15
-rw-r--r--test/Modules/irgen.c12
-rw-r--r--test/Modules/load_failure.c16
-rw-r--r--test/Modules/lookup.cpp21
-rw-r--r--test/Modules/lookup.m13
-rw-r--r--test/Modules/macros.c25
-rw-r--r--test/Modules/method_pool.m30
-rw-r--r--test/Modules/module-private.cpp82
-rw-r--r--test/Modules/namespaces.cpp64
-rw-r--r--test/Modules/normal-module-map.cpp35
-rw-r--r--test/Modules/objc-categories.m87
-rw-r--r--test/Modules/on-demand-build-warnings.m4
-rw-r--r--test/Modules/on-demand-build.m18
-rw-r--r--test/Modules/on-demand-macros.m6
-rw-r--r--test/Modules/redecl-merge.m158
-rw-r--r--test/Modules/redecl-namespaces.mm13
-rw-r--r--test/Modules/redeclarations.m11
-rw-r--r--test/Modules/requires.m5
-rw-r--r--test/Modules/subframeworks.m22
-rw-r--r--test/Modules/submodules-preprocess.cpp61
-rw-r--r--test/Modules/submodules.cpp29
-rw-r--r--test/Modules/submodules.m11
-rw-r--r--test/Modules/wildcard-submodule-exports.cpp26
-rw-r--r--test/PCH/Inputs/arc.h10
-rw-r--r--test/PCH/chain-categories2.m57
-rw-r--r--test/PCH/chain-class-extension.m42
-rw-r--r--test/PCH/chain-cxx.cpp13
-rw-r--r--test/PCH/chain-selectors.m8
-rw-r--r--test/PCH/cocoa.m7
-rw-r--r--test/PCH/cxx-constexpr.cpp19
-rw-r--r--test/PCH/cxx-exprs.cpp27
-rw-r--r--test/PCH/cxx-functions.cpp10
-rw-r--r--test/PCH/cxx-functions.h1
-rw-r--r--test/PCH/cxx-templates.cpp6
-rw-r--r--test/PCH/cxx-templates.h10
-rw-r--r--test/PCH/cxx-trailing-return.cpp15
-rw-r--r--test/PCH/cxx-traits.cpp9
-rw-r--r--test/PCH/cxx-traits.h5
-rw-r--r--test/PCH/cxx0x-default-delete.cpp11
-rw-r--r--test/PCH/cxx11-constexpr.cpp29
-rw-r--r--test/PCH/cxx11-enum-template.cpp26
-rw-r--r--test/PCH/cxx11-lambdas.mm48
-rw-r--r--test/PCH/cxx11-user-defined-literals.cpp21
-rw-r--r--test/PCH/designated-init.c7
-rw-r--r--test/PCH/designated-init.c.h42
-rw-r--r--test/PCH/exprs.h4
-rw-r--r--test/PCH/method-redecls.m4
-rw-r--r--test/PCH/method_pool.m6
-rw-r--r--test/PCH/modified-header-error.c3
-rw-r--r--test/PCH/ms-if-exists.cpp29
-rw-r--r--test/PCH/objc_container.h26
-rw-r--r--test/PCH/objc_container.m20
-rw-r--r--test/PCH/objc_exprs.h8
-rw-r--r--test/PCH/objc_exprs.m2
-rw-r--r--test/PCH/objc_literals.m66
-rw-r--r--test/PCH/objc_literals.mm65
-rw-r--r--test/PCH/pending-ids.m33
-rw-r--r--test/PCH/rdar10830559.cpp35
-rw-r--r--test/PCH/reloc.c6
-rw-r--r--test/PCH/replaced-decl.m22
-rw-r--r--test/PCH/single-token-macro.c24
-rw-r--r--test/PCH/subscripting-literals.m47
-rw-r--r--test/PCH/typo.cpp4
-rw-r--r--test/Parser/DelayedTemplateParsing.cpp31
-rw-r--r--test/Parser/MicrosoftExtensions.c11
-rw-r--r--test/Parser/MicrosoftExtensions.cpp34
-rw-r--r--test/Parser/asm.c3
-rw-r--r--test/Parser/asm.cpp8
-rw-r--r--test/Parser/attr-availability.c10
-rw-r--r--test/Parser/attributes.c40
-rw-r--r--test/Parser/bracket-crash.cpp4
-rw-r--r--test/Parser/check-syntax-1.m2
-rw-r--r--test/Parser/cxx-altivec.cpp2
-rw-r--r--test/Parser/cxx-class.cpp30
-rw-r--r--test/Parser/cxx-condition.cpp8
-rw-r--r--test/Parser/cxx-decl.cpp32
-rw-r--r--test/Parser/cxx-default-delete.cpp12
-rw-r--r--test/Parser/cxx-ext-delete-default.cpp10
-rw-r--r--test/Parser/cxx-template-decl.cpp15
-rw-r--r--test/Parser/cxx-typeid.cpp2
-rw-r--r--test/Parser/cxx-typeof.cpp2
-rw-r--r--test/Parser/cxx-using-directive.cpp6
-rw-r--r--test/Parser/cxx0x-ambig.cpp127
-rw-r--r--test/Parser/cxx0x-attributes.cpp32
-rw-r--r--test/Parser/cxx0x-condition.cpp37
-rw-r--r--test/Parser/cxx0x-decl.cpp18
-rw-r--r--test/Parser/cxx0x-for-range.cpp30
-rw-r--r--test/Parser/cxx0x-in-cxx98.cpp13
-rw-r--r--test/Parser/cxx0x-lambda-expressions.cpp38
-rw-r--r--test/Parser/cxx0x-literal-operators.cpp8
-rw-r--r--test/Parser/cxx11-type-specifier.cpp20
-rw-r--r--test/Parser/cxx11-user-defined-literals.cpp112
-rw-r--r--test/Parser/declarators.c3
-rw-r--r--test/Parser/enhanced-proto-1.m2
-rw-r--r--test/Parser/method-def-in-class.m11
-rw-r--r--test/Parser/missing-end-2.m12
-rw-r--r--test/Parser/missing-end-3.m4
-rw-r--r--test/Parser/missing-end-4.m51
-rw-r--r--test/Parser/missing-end.m4
-rw-r--r--test/Parser/objc-category-neg-1.m2
-rw-r--r--test/Parser/objc-forcollection-neg-2.m4
-rw-r--r--test/Parser/objc-forcollection-neg.m2
-rw-r--r--test/Parser/objc-foreach-syntax.m2
-rw-r--r--test/Parser/objc-init.m6
-rw-r--r--test/Parser/objc-missing-impl.m2
-rw-r--r--test/Parser/objc-property-syntax.m2
-rw-r--r--test/Parser/objc-quirks.m6
-rw-r--r--test/Parser/objc-synthesized-recover.m2
-rw-r--r--test/Parser/objcxx-lambda-expressions-neg.mm2
-rw-r--r--test/Parser/objcxx0x-lambda-expressions.mm17
-rw-r--r--test/Parser/objcxx11-attributes.mm55
-rw-r--r--test/Parser/objcxx11-user-defined-literal.mm3
-rw-r--r--test/Parser/recovery.c4
-rw-r--r--test/Parser/recovery.cpp42
-rw-r--r--test/Parser/skip-function-bodies.mm45
-rw-r--r--test/Parser/statements.c8
-rw-r--r--test/Parser/warn-dangling-else.cpp55
-rw-r--r--test/Preprocessor/Inputs/TestFramework.framework/.system_framework0
-rw-r--r--test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h3
-rw-r--r--test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h6
-rw-r--r--test/Preprocessor/_Pragma-in-macro-arg.c35
-rw-r--r--test/Preprocessor/cxx_oper_keyword_ms_compat.cpp179
-rw-r--r--test/Preprocessor/feature_tests.c5
-rw-r--r--test/Preprocessor/has_attribute.c26
-rw-r--r--test/Preprocessor/init.c896
-rw-r--r--test/Preprocessor/line-directive.c8
-rw-r--r--test/Preprocessor/macro_arg_directive.c20
-rw-r--r--test/Preprocessor/macro_arg_directive.h9
-rw-r--r--test/Preprocessor/macro_paste_c_block_comment.c6
-rw-r--r--test/Preprocessor/microsoft-import.c17
-rw-r--r--test/Preprocessor/mmx.c13
-rw-r--r--test/Preprocessor/optimize.c2
-rw-r--r--test/Preprocessor/pic.c43
-rw-r--r--test/Preprocessor/pp-record.c11
-rw-r--r--test/Preprocessor/pp-record.h2
-rw-r--r--test/Preprocessor/pragma_microsoft.c43
-rw-r--r--test/Preprocessor/predefined-macros.c27
-rw-r--r--test/Preprocessor/stdint.c219
-rw-r--r--test/Preprocessor/user_defined_system_framework.c8
-rw-r--r--test/Preprocessor/warn-disabled-macro-expansion.c27
-rw-r--r--test/Preprocessor/x86_target_features.c8
-rw-r--r--test/Rewriter/blockcast3.mm2
-rw-r--r--test/Rewriter/blockstruct.m2
-rw-r--r--test/Rewriter/crash.m2
-rw-r--r--test/Rewriter/finally.m4
-rw-r--r--test/Rewriter/func-in-impl.m30
-rw-r--r--test/Rewriter/id-test-3.m2
-rw-r--r--test/Rewriter/inner-block-helper-funcs.mm2
-rw-r--r--test/Rewriter/instancetype-test.mm2
-rw-r--r--test/Rewriter/ivar-encoding-1.m2
-rw-r--r--test/Rewriter/ivar-encoding-2.m2
-rw-r--r--test/Rewriter/metadata-test-1.m2
-rw-r--r--test/Rewriter/metadata-test-2.m2
-rw-r--r--test/Rewriter/method-encoding-1.m2
-rw-r--r--test/Rewriter/objc-bool-literal-check-modern.mm29
-rw-r--r--test/Rewriter/objc-bool-literal-modern-1.mm31
-rw-r--r--test/Rewriter/objc-bool-literal-modern.mm23
-rw-r--r--test/Rewriter/objc-encoding-bug-1.m2
-rw-r--r--test/Rewriter/objc-ivar-receiver-1.m4
-rw-r--r--test/Rewriter/objc-modern-class-init-hooks.mm36
-rw-r--r--test/Rewriter/objc-modern-class-init.mm23
-rw-r--r--test/Rewriter/objc-modern-container-subscript.mm48
-rw-r--r--test/Rewriter/objc-modern-implicit-cast.mm33
-rw-r--r--test/Rewriter/objc-modern-ivar-receiver-1.mm31
-rw-r--r--test/Rewriter/objc-modern-linkage-spec.mm21
-rw-r--r--test/Rewriter/objc-modern-metadata-visibility.mm40
-rw-r--r--test/Rewriter/objc-modern-numeric-literal.mm69
-rw-r--r--test/Rewriter/objc-modern-property-attributes.mm35
-rw-r--r--test/Rewriter/objc-string-concat-1.m2
-rw-r--r--test/Rewriter/objc-super-test.m2
-rw-r--r--test/Rewriter/objc-synchronized-1.m2
-rw-r--r--test/Rewriter/properties.m2
-rw-r--r--test/Rewriter/property-dot-syntax.mm2
-rw-r--r--test/Rewriter/protocol-rewrite-1.m2
-rw-r--r--test/Rewriter/protocol-rewrite-2.m2
-rw-r--r--test/Rewriter/rewrite-anonymous-union.m2
-rw-r--r--test/Rewriter/rewrite-api-bug.m2
-rw-r--r--test/Rewriter/rewrite-block-argument.m2
-rw-r--r--test/Rewriter/rewrite-block-consts.mm2
-rw-r--r--test/Rewriter/rewrite-block-ivar-call.mm2
-rw-r--r--test/Rewriter/rewrite-block-literal-1.mm2
-rw-r--r--test/Rewriter/rewrite-block-literal.mm (renamed from test/Rewriter/rewrite-block-literal.c)24
-rw-r--r--test/Rewriter/rewrite-block-pointer.mm2
-rw-r--r--test/Rewriter/rewrite-block-property.m2
-rw-r--r--test/Rewriter/rewrite-byref-in-nested-blocks.mm2
-rw-r--r--test/Rewriter/rewrite-byref-vars.mm4
-rw-r--r--test/Rewriter/rewrite-cast-ivar-access.mm2
-rw-r--r--test/Rewriter/rewrite-cast-ivar-modern-access.mm46
-rw-r--r--test/Rewriter/rewrite-cast-to-bool.mm2
-rw-r--r--test/Rewriter/rewrite-category-property.mm2
-rw-r--r--test/Rewriter/rewrite-constructor-init.mm2
-rw-r--r--test/Rewriter/rewrite-eh.m2
-rw-r--r--test/Rewriter/rewrite-elaborated-type.mm2
-rw-r--r--test/Rewriter/rewrite-extern-c.mm2
-rw-r--r--test/Rewriter/rewrite-foreach-1.m2
-rw-r--r--test/Rewriter/rewrite-foreach-2.m2
-rw-r--r--test/Rewriter/rewrite-foreach-3.m2
-rw-r--r--test/Rewriter/rewrite-foreach-4.m2
-rw-r--r--test/Rewriter/rewrite-foreach-5.m2
-rw-r--r--test/Rewriter/rewrite-foreach-6.m2
-rw-r--r--test/Rewriter/rewrite-foreach-7.m2
-rw-r--r--test/Rewriter/rewrite-foreach-in-block.mm2
-rw-r--r--test/Rewriter/rewrite-foreach-protocol-id.m2
-rw-r--r--test/Rewriter/rewrite-forward-class.m2
-rw-r--r--test/Rewriter/rewrite-forward-class.mm2
-rw-r--r--test/Rewriter/rewrite-function-decl.mm2
-rw-r--r--test/Rewriter/rewrite-implementation.mm5
-rw-r--r--test/Rewriter/rewrite-ivar-use.m5
-rw-r--r--test/Rewriter/rewrite-local-externs-in-block.mm2
-rw-r--r--test/Rewriter/rewrite-local-static-id.mm2
-rw-r--r--test/Rewriter/rewrite-message-expr.mm2
-rw-r--r--test/Rewriter/rewrite-modern-array-literal.mm27
-rw-r--r--test/Rewriter/rewrite-modern-block-ivar-call.mm17
-rw-r--r--test/Rewriter/rewrite-modern-block.mm23
-rw-r--r--test/Rewriter/rewrite-modern-catch.m31
-rw-r--r--test/Rewriter/rewrite-modern-class.mm70
-rw-r--r--test/Rewriter/rewrite-modern-container-literal.mm55
-rw-r--r--test/Rewriter/rewrite-modern-ivar-use.mm26
-rw-r--r--test/Rewriter/rewrite-modern-ivars-1.mm89
-rw-r--r--test/Rewriter/rewrite-modern-ivars-2.mm101
-rw-r--r--test/Rewriter/rewrite-modern-ivars.mm64
-rw-r--r--test/Rewriter/rewrite-modern-nested-ivar.mm33
-rw-r--r--test/Rewriter/rewrite-modern-protocol.mm31
-rw-r--r--test/Rewriter/rewrite-modern-struct-ivar.mm24
-rw-r--r--test/Rewriter/rewrite-modern-synchronized.m35
-rw-r--r--test/Rewriter/rewrite-modern-throw.m67
-rw-r--r--test/Rewriter/rewrite-modern-try-catch-finally.m63
-rw-r--r--test/Rewriter/rewrite-modern-try-finally.m40
-rw-r--r--test/Rewriter/rewrite-nest.m2
-rw-r--r--test/Rewriter/rewrite-nested-blocks-1.mm2
-rw-r--r--test/Rewriter/rewrite-nested-blocks-2.mm2
-rw-r--r--test/Rewriter/rewrite-nested-blocks.mm2
-rw-r--r--test/Rewriter/rewrite-nested-ivar.mm4
-rwxr-xr-xtest/Rewriter/rewrite-nested-property-in-blocks.mm2
-rw-r--r--test/Rewriter/rewrite-no-nextline.mm2
-rw-r--r--test/Rewriter/rewrite-property-attributes.mm2
-rw-r--r--test/Rewriter/rewrite-property-set-cfstring.mm2
-rw-r--r--test/Rewriter/rewrite-protocol-property.mm2
-rw-r--r--test/Rewriter/rewrite-protocol-qualified.mm2
-rw-r--r--test/Rewriter/rewrite-protocol-type-1.m2
-rw-r--r--test/Rewriter/rewrite-qualified-id.mm2
-rw-r--r--test/Rewriter/rewrite-rewritten-initializer.mm2
-rw-r--r--test/Rewriter/rewrite-static-block.mm2
-rw-r--r--test/Rewriter/rewrite-super-message.mm33
-rw-r--r--test/Rewriter/rewrite-trivial-constructor.mm2
-rw-r--r--test/Rewriter/rewrite-try-catch.m2
-rw-r--r--test/Rewriter/rewrite-typeof.mm2
-rw-r--r--test/Rewriter/rewrite-unique-block-api.mm2
-rw-r--r--test/Rewriter/rewrite-user-defined-accessors.mm2
-rw-r--r--test/Rewriter/rewrite-vararg.m2
-rw-r--r--test/Rewriter/rewrite-weak-attr.m2
-rw-r--r--test/Rewriter/static-type-protocol-1.m2
-rw-r--r--test/Rewriter/undecl-objc-h.m2
-rw-r--r--test/Rewriter/undeclared-method-1.m2
-rw-r--r--test/Rewriter/undef-field-reference-1.m2
-rw-r--r--test/Rewriter/unnamed-bf-modern-write.mm23
-rw-r--r--test/Rewriter/va-method.m2
-rw-r--r--test/Rewriter/weak_byref_objects.m2
-rw-r--r--test/Sema/128bitint.c4
-rw-r--r--test/Sema/Inputs/unused-expr-system-header.h23
-rw-r--r--test/Sema/MicrosoftCompatibility.c16
-rw-r--r--test/Sema/MicrosoftExtensions.c35
-rw-r--r--test/Sema/PR2963-enum-constant.c2
-rw-r--r--test/Sema/__try.c5
-rw-r--r--test/Sema/align-x86.c4
-rw-r--r--test/Sema/anonymous-struct-union-c11.c19
-rw-r--r--test/Sema/anonymous-struct-union.c6
-rw-r--r--test/Sema/arm-neon-types.c10
-rw-r--r--test/Sema/array-bounds-ptr-arith.c7
-rw-r--r--test/Sema/array-init.c19
-rw-r--r--test/Sema/asm.c2
-rw-r--r--test/Sema/atomic-ops.c176
-rw-r--r--test/Sema/atomic-type.c2
-rw-r--r--test/Sema/attr-availability-ios.c2
-rw-r--r--test/Sema/attr-availability-macosx.c14
-rw-r--r--test/Sema/attr-availability.c21
-rw-r--r--test/Sema/attr-declspec-ignored.c12
-rw-r--r--test/Sema/attr-deprecated.c6
-rw-r--r--test/Sema/attr-unavailable-message.c10
-rw-r--r--test/Sema/attr-visibility.c9
-rw-r--r--test/Sema/block-explicit-noreturn-type.c15
-rw-r--r--test/Sema/block-misc.c2
-rw-r--r--test/Sema/block-printf-attribute-1.c12
-rw-r--r--test/Sema/block-return.c19
-rw-r--r--test/Sema/block-sentinel-attribute.c3
-rw-r--r--test/Sema/builtins.c66
-rw-r--r--test/Sema/c11-typedef-redef.c18
-rw-r--r--test/Sema/c89.c38
-rw-r--r--test/Sema/compare.c6
-rw-r--r--test/Sema/complex-imag.c29
-rw-r--r--test/Sema/complex-init-list.c3
-rw-r--r--test/Sema/compound-literal.c2
-rw-r--r--test/Sema/conditional-expr.c17
-rw-r--r--test/Sema/const-eval.c43
-rw-r--r--test/Sema/constant-conversion.c29
-rw-r--r--test/Sema/conversion-64-32.c4
-rw-r--r--test/Sema/conversion.c72
-rw-r--r--test/Sema/decl-in-prototype.c33
-rw-r--r--test/Sema/default.c2
-rw-r--r--test/Sema/enum.c2
-rw-r--r--test/Sema/fn-ptr-as-fn-prototype.c15
-rw-r--r--test/Sema/format-strings-c90.c30
-rw-r--r--test/Sema/format-strings-fixit-ssize_t.c18
-rw-r--r--test/Sema/format-strings-fixit.c148
-rw-r--r--test/Sema/format-strings-int-typedefs.c37
-rw-r--r--test/Sema/format-strings-no-fixit.c65
-rw-r--r--test/Sema/format-strings-non-iso.c29
-rw-r--r--test/Sema/format-strings-scanf.c93
-rw-r--r--test/Sema/format-strings-size_t.c15
-rw-r--r--test/Sema/format-strings.c188
-rw-r--r--test/Sema/function.c9
-rw-r--r--test/Sema/gnu89.c2
-rw-r--r--test/Sema/i-c-e.c24
-rw-r--r--test/Sema/implicit-builtin-decl.c2
-rw-r--r--test/Sema/implicit-builtin-redecl.c2
-rw-r--r--test/Sema/implicit-decl.c19
-rw-r--r--test/Sema/init.c15
-rw-r--r--test/Sema/invalid-struct-init.c2
-rw-r--r--test/Sema/many-logical-ops.c2010
-rw-r--r--test/Sema/ms_class_layout.cpp199
-rw-r--r--test/Sema/no-format-y2k-turnsoff-format.c2
-rw-r--r--test/Sema/offsetof.c4
-rw-r--r--test/Sema/overloadable-complex.c4
-rw-r--r--test/Sema/overloadable.c2
-rw-r--r--test/Sema/paren-list-expr-type.cpp17
-rw-r--r--test/Sema/pragma-ms_struct.c21
-rw-r--r--test/Sema/pragma-pack-2.c58
-rw-r--r--test/Sema/pragma-pack-5.c45
-rw-r--r--test/Sema/pragma-pack-apple.c10
-rw-r--r--test/Sema/return.c11
-rw-r--r--test/Sema/statements.c2
-rw-r--r--test/Sema/static-array.c31
-rw-r--r--test/Sema/static-init.c5
-rw-r--r--test/Sema/switch.c74
-rw-r--r--test/Sema/thread-specifier.c4
-rw-r--r--test/Sema/types.c14
-rw-r--r--test/Sema/ucn-cstring.c3
-rw-r--r--test/Sema/uninit-variables.c10
-rw-r--r--test/Sema/unused-expr-system-header.c10
-rw-r--r--test/Sema/variadic-incomplete-arg-type.c13
-rw-r--r--test/Sema/vector-assign.c2
-rw-r--r--test/Sema/vector-cast.c2
-rw-r--r--test/Sema/vector-ops.c7
-rw-r--r--test/Sema/vla-2.c17
-rw-r--r--test/Sema/vla.c5
-rw-r--r--test/Sema/warn-cast-align.c2
-rw-r--r--test/Sema/warn-strncat-size.c71
-rw-r--r--test/Sema/warn-unreachable.c8
-rw-r--r--test/Sema/weak-import-on-enum.c8
-rw-r--r--test/Sema/x86-builtin-palignr.c4
-rw-r--r--test/SemaCXX/Inputs/array-bounds-system-header.h11
-rw-r--r--test/SemaCXX/Inputs/warn-new-overaligned-3.h19
-rw-r--r--test/SemaCXX/MicrosoftCompatibility-cxx98.cpp8
-rw-r--r--test/SemaCXX/MicrosoftCompatibility.cpp198
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp20
-rw-r--r--test/SemaCXX/PR10177.cpp40
-rw-r--r--test/SemaCXX/PR10447.cpp22
-rw-r--r--test/SemaCXX/PR11358.cpp51
-rw-r--r--test/SemaCXX/PR12481.cpp17
-rw-r--r--test/SemaCXX/PR8385.cpp7
-rw-r--r--test/SemaCXX/PR9460.cpp6
-rw-r--r--test/SemaCXX/PR9461.cpp6
-rw-r--r--test/SemaCXX/PR9572.cpp2
-rw-r--r--test/SemaCXX/__null.cpp4
-rw-r--r--test/SemaCXX/access.cpp2
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp76
-rw-r--r--test/SemaCXX/aggregate-initialization.cpp22
-rw-r--r--test/SemaCXX/alias-template.cpp8
-rw-r--r--test/SemaCXX/altivec.cpp10
-rw-r--r--test/SemaCXX/anonymous-struct.cpp5
-rw-r--r--test/SemaCXX/array-bounds-ptr-arith.cpp2
-rw-r--r--test/SemaCXX/array-bounds-system-header.cpp9
-rw-r--r--test/SemaCXX/array-bounds.cpp92
-rw-r--r--test/SemaCXX/atomic-type.cxx35
-rw-r--r--test/SemaCXX/attr-cxx0x.cpp11
-rw-r--r--test/SemaCXX/attr-declspec-ignored.cpp19
-rw-r--r--test/SemaCXX/attr-deprecated.cpp4
-rw-r--r--test/SemaCXX/attr-sentinel.cpp17
-rw-r--r--test/SemaCXX/auto-cxx98.cpp2
-rw-r--r--test/SemaCXX/blocks-1.cpp15
-rw-r--r--test/SemaCXX/c99-variable-length-array.cpp35
-rw-r--r--test/SemaCXX/c99.cpp4
-rw-r--r--test/SemaCXX/class-base-member-init.cpp24
-rw-r--r--test/SemaCXX/class.cpp44
-rw-r--r--test/SemaCXX/complex-overload.cpp2
-rw-r--r--test/SemaCXX/condition.cpp12
-rw-r--r--test/SemaCXX/conditional-expr.cpp4
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp1246
-rw-r--r--test/SemaCXX/constant-expression.cpp34
-rw-r--r--test/SemaCXX/constexpr-ackermann.cpp8
-rw-r--r--test/SemaCXX/constexpr-backtrace-limit.cpp34
-rw-r--r--test/SemaCXX/constexpr-depth.cpp8
-rw-r--r--test/SemaCXX/constexpr-factorial.cpp9
-rw-r--r--test/SemaCXX/constexpr-nqueens.cpp73
-rw-r--r--test/SemaCXX/constexpr-printing.cpp102
-rw-r--r--test/SemaCXX/constexpr-strlen.cpp15
-rw-r--r--test/SemaCXX/constexpr-turing.cpp55
-rw-r--r--test/SemaCXX/constexpr-value-init.cpp37
-rw-r--r--test/SemaCXX/constructor-initializer.cpp14
-rw-r--r--test/SemaCXX/conversion.cpp28
-rw-r--r--test/SemaCXX/copy-assignment.cpp9
-rw-r--r--test/SemaCXX/copy-initialization.cpp23
-rw-r--r--test/SemaCXX/cxx0x-class.cpp19
-rw-r--r--test/SemaCXX/cxx0x-compat.cpp27
-rw-r--r--test/SemaCXX/cxx0x-cursory-default-delete.cpp6
-rw-r--r--test/SemaCXX/cxx0x-defaulted-functions.cpp10
-rw-r--r--test/SemaCXX/cxx0x-deleted-default-ctor.cpp75
-rw-r--r--test/SemaCXX/cxx0x-initializer-aggregates.cpp89
-rw-r--r--test/SemaCXX/cxx0x-initializer-constructor.cpp283
-rw-r--r--test/SemaCXX/cxx0x-initializer-references.cpp87
-rw-r--r--test/SemaCXX/cxx0x-initializer-scalars.cpp84
-rw-r--r--test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp177
-rw-r--r--test/SemaCXX/cxx0x-nontrivial-union.cpp104
-rw-r--r--test/SemaCXX/cxx0x-return-init-list.cpp10
-rw-r--r--test/SemaCXX/cxx11-ast-print.cpp41
-rw-r--r--test/SemaCXX/cxx11-user-defined-literals.cpp137
-rw-r--r--test/SemaCXX/cxx98-compat-flags.cpp35
-rw-r--r--test/SemaCXX/cxx98-compat-pedantic.cpp23
-rw-r--r--test/SemaCXX/cxx98-compat.cpp273
-rw-r--r--test/SemaCXX/dcl_init_aggr.cpp2
-rw-r--r--test/SemaCXX/decl-expr-ambiguity.cpp33
-rw-r--r--test/SemaCXX/decltype-crash.cpp2
-rw-r--r--test/SemaCXX/decltype.cpp9
-rw-r--r--test/SemaCXX/default1.cpp18
-rw-r--r--test/SemaCXX/default2.cpp10
-rw-r--r--test/SemaCXX/defaulted-private-dtor.cpp56
-rw-r--r--test/SemaCXX/deleted-function.cpp24
-rw-r--r--test/SemaCXX/deleted-operator.cpp5
-rw-r--r--test/SemaCXX/dependent-auto.cpp2
-rw-r--r--test/SemaCXX/destructor.cpp2
-rw-r--r--test/SemaCXX/discrim-union.cpp118
-rw-r--r--test/SemaCXX/dr1301.cpp67
-rw-r--r--test/SemaCXX/empty-class-layout.cpp11
-rw-r--r--test/SemaCXX/enum-bitfield.cpp2
-rw-r--r--test/SemaCXX/enum-scoped.cpp107
-rw-r--r--test/SemaCXX/enum-unscoped-nonexistent.cpp39
-rw-r--r--test/SemaCXX/enum.cpp2
-rw-r--r--test/SemaCXX/exceptions.cpp28
-rw-r--r--test/SemaCXX/explicit.cpp19
-rw-r--r--test/SemaCXX/expression-traits.cpp4
-rw-r--r--test/SemaCXX/for-range-examples.cpp32
-rw-r--r--test/SemaCXX/for-range-no-std.cpp7
-rw-r--r--test/SemaCXX/format-strings-0x.cpp15
-rw-r--r--test/SemaCXX/format-strings.cpp77
-rw-r--r--test/SemaCXX/friend-out-of-line.cpp12
-rw-r--r--test/SemaCXX/friend.cpp8
-rw-r--r--test/SemaCXX/function-extern-c.cpp38
-rw-r--r--test/SemaCXX/function-redecl.cpp7
-rw-r--r--test/SemaCXX/function-type-qual.cpp14
-rw-r--r--test/SemaCXX/generalized-initializers.cpp207
-rw-r--r--test/SemaCXX/gnu-case-ranges.cpp2
-rw-r--r--test/SemaCXX/goto.cpp22
-rw-r--r--test/SemaCXX/i-c-e-cxx.cpp17
-rw-r--r--test/SemaCXX/if-empty-body.cpp35
-rw-r--r--test/SemaCXX/implicit-exception-spec.cpp7
-rw-r--r--test/SemaCXX/incomplete-call.cpp2
-rw-r--r--test/SemaCXX/indirect-goto.cpp7
-rw-r--r--test/SemaCXX/instantiate-blocks.cpp13
-rw-r--r--test/SemaCXX/invalid-member-expr.cpp4
-rw-r--r--test/SemaCXX/issue547.cpp16
-rw-r--r--test/SemaCXX/lambda-expressions.cpp150
-rw-r--r--test/SemaCXX/literal-operators.cpp8
-rw-r--r--test/SemaCXX/literal-type.cpp28
-rw-r--r--test/SemaCXX/member-class-11.cpp8
-rw-r--r--test/SemaCXX/member-expr.cpp14
-rw-r--r--test/SemaCXX/member-init.cpp3
-rw-r--r--test/SemaCXX/member-pointer.cpp2
-rw-r--r--test/SemaCXX/microsoft-cxx0x.cpp4
-rw-r--r--test/SemaCXX/missing-header.cpp4
-rw-r--r--test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp59
-rw-r--r--test/SemaCXX/namespace-alias.cpp8
-rw-r--r--test/SemaCXX/nested-name-spec.cpp7
-rw-r--r--test/SemaCXX/new-delete-0x.cpp32
-rw-r--r--test/SemaCXX/new-delete-cxx0x.cpp26
-rw-r--r--test/SemaCXX/new-delete.cpp101
-rw-r--r--test/SemaCXX/null_in_arithmetic_ops.cpp2
-rw-r--r--test/SemaCXX/nullptr.cpp48
-rw-r--r--test/SemaCXX/offsetof.cpp7
-rw-r--r--test/SemaCXX/overload-call.cpp62
-rw-r--r--test/SemaCXX/overload-member-call.cpp8
-rw-r--r--test/SemaCXX/overloaded-name.cpp5
-rw-r--r--test/SemaCXX/overloaded-operator.cpp11
-rw-r--r--test/SemaCXX/pragma-visibility.cpp23
-rw-r--r--test/SemaCXX/pseudo-destructors.cpp14
-rw-r--r--test/SemaCXX/qual-id-test.cpp4
-rw-r--r--test/SemaCXX/qualified-id-lookup.cpp5
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp22
-rw-r--r--test/SemaCXX/reinterpret-fn-obj-pedantic.cpp4
-rw-r--r--test/SemaCXX/return-noreturn.cpp4
-rw-r--r--test/SemaCXX/runtimediag-ppe.cpp18
-rw-r--r--test/SemaCXX/scope-check.cpp2
-rw-r--r--test/SemaCXX/statements.cpp2
-rw-r--r--test/SemaCXX/static-assert.cpp12
-rw-r--r--test/SemaCXX/string-plus-int.cpp66
-rw-r--r--test/SemaCXX/switch.cpp23
-rw-r--r--test/SemaCXX/this.cpp4
-rw-r--r--test/SemaCXX/trailing-return-0x.cpp10
-rw-r--r--test/SemaCXX/type-traits.cpp218
-rw-r--r--test/SemaCXX/typedef-redecl.cpp39
-rw-r--r--test/SemaCXX/typeid.cpp2
-rw-r--r--test/SemaCXX/typo-correction.cpp163
-rw-r--r--test/SemaCXX/undefined-internal.cpp59
-rw-r--r--test/SemaCXX/underlying_type.cpp6
-rw-r--r--test/SemaCXX/uninit-variables.cpp2
-rw-r--r--test/SemaCXX/uninitialized.cpp52
-rw-r--r--test/SemaCXX/unknown-anytype-blocks.cpp11
-rw-r--r--test/SemaCXX/unknown-anytype.cpp4
-rw-r--r--test/SemaCXX/value-initialization.cpp7
-rw-r--r--test/SemaCXX/vararg-non-pod.cpp7
-rw-r--r--test/SemaCXX/vector.cpp49
-rw-r--r--test/SemaCXX/vla.cpp5
-rw-r--r--test/SemaCXX/warn-bool-conversion.cpp12
-rw-r--r--test/SemaCXX/warn-empty-body.cpp271
-rw-r--r--test/SemaCXX/warn-everthing.cpp13
-rw-r--r--test/SemaCXX/warn-func-as-bool.cpp40
-rw-r--r--test/SemaCXX/warn-large-by-value-copy.cpp5
-rw-r--r--test/SemaCXX/warn-memset-bad-sizeof.cpp10
-rw-r--r--test/SemaCXX/warn-new-overaligned-2.cpp22
-rw-r--r--test/SemaCXX/warn-new-overaligned-3.cpp33
-rw-r--r--test/SemaCXX/warn-new-overaligned.cpp73
-rw-r--r--test/SemaCXX/warn-thread-safety-analysis.cpp959
-rw-r--r--test/SemaCXX/warn-thread-safety-parsing.cpp196
-rw-r--r--test/SemaCXX/warn-unreachable.cpp31
-rw-r--r--test/SemaCXX/warn-unused-parameters.cpp10
-rw-r--r--test/SemaCXX/warn-unused-value.cpp19
-rw-r--r--test/SemaCXX/warn-unused-variables.cpp42
-rw-r--r--test/SemaCXX/warn-weak-vtables.cpp22
-rw-r--r--test/SemaCXX/zero-length-arrays.cpp26
-rw-r--r--test/SemaObjC/ClassPropertyNotObject.m15
-rw-r--r--test/SemaObjC/ContClassPropertyLookup.m22
-rw-r--r--test/SemaObjC/DoubleMethod.m6
-rw-r--r--test/SemaObjC/NSString-type.m10
-rw-r--r--test/SemaObjC/alias-test-2.m6
-rw-r--r--test/SemaObjC/arc-bridged-cast.m7
-rw-r--r--test/SemaObjC/arc-cf.m31
-rw-r--r--test/SemaObjC/arc-decls.m18
-rw-r--r--test/SemaObjC/arc-invalid.m18
-rw-r--r--test/SemaObjC/arc-jump-block.m15
-rw-r--r--test/SemaObjC/arc-no-runtime.m3
-rw-r--r--test/SemaObjC/arc-objc-lifetime.m42
-rw-r--r--test/SemaObjC/arc-peformselector.m8
-rw-r--r--test/SemaObjC/arc-property-lifetime.m45
-rw-r--r--test/SemaObjC/arc-property.m11
-rw-r--r--test/SemaObjC/arc-readonly-property-ivar-1.m29
-rw-r--r--test/SemaObjC/arc-readonly-property-ivar.m16
-rw-r--r--test/SemaObjC/arc-retain-block-property.m2
-rw-r--r--test/SemaObjC/arc-setter-property-match.m2
-rw-r--r--test/SemaObjC/arc-type-conversion.m29
-rw-r--r--test/SemaObjC/arc-unavailable-for-weakref.m25
-rw-r--r--test/SemaObjC/arc-unbridged-cast.m67
-rw-r--r--test/SemaObjC/arc-unsafe-assigns.m2
-rw-r--r--test/SemaObjC/arc.m51
-rw-r--r--test/SemaObjC/assign-rvalue-message.m4
-rw-r--r--test/SemaObjC/atomoic-property-synnthesis-rules.m50
-rw-r--r--test/SemaObjC/attr-deprecated.m12
-rw-r--r--test/SemaObjC/attr-root-class.m16
-rw-r--r--test/SemaObjC/autoreleasepool.m2
-rw-r--r--test/SemaObjC/bad-property-synthesis-crash.m2
-rw-r--r--test/SemaObjC/block-id-as-block-argtype.m27
-rw-r--r--test/SemaObjC/block-on-method-param.m12
-rw-r--r--test/SemaObjC/block-type-safety.m19
-rw-r--r--test/SemaObjC/blocks.m8
-rw-r--r--test/SemaObjC/builtin_objc_lib_functions.m18
-rw-r--r--test/SemaObjC/builtin_objc_nslog.m13
-rw-r--r--test/SemaObjC/call-super-2.m4
-rw-r--r--test/SemaObjC/category-1.m14
-rw-r--r--test/SemaObjC/category-method-lookup.m2
-rw-r--r--test/SemaObjC/check-dup-decl-methods-1.m6
-rw-r--r--test/SemaObjC/check-dup-objc-decls-1.m2
-rw-r--r--test/SemaObjC/class-conforming-protocol-1.m7
-rw-r--r--test/SemaObjC/class-def-test-1.m4
-rw-r--r--test/SemaObjC/class-extension-after-implementation.m2
-rw-r--r--test/SemaObjC/class-extension-dup-methods.m4
-rw-r--r--test/SemaObjC/class-getter-using-dotsyntax.m2
-rw-r--r--test/SemaObjC/class-impl-1.m4
-rw-r--r--test/SemaObjC/class-message-protocol-lookup.m4
-rw-r--r--test/SemaObjC/class-method-self.m2
-rw-r--r--test/SemaObjC/class-proto-1.m2
-rw-r--r--test/SemaObjC/class-protocol-method-match.m2
-rw-r--r--test/SemaObjC/cocoa-api-usage.m88
-rw-r--r--test/SemaObjC/cocoa-api-usage.m.fixed88
-rw-r--r--test/SemaObjC/compare-qualified-id.m4
-rw-r--r--test/SemaObjC/compatible-protocol-qualified-types.m2
-rw-r--r--test/SemaObjC/comptypes-1.m2
-rw-r--r--test/SemaObjC/comptypes-10.m2
-rw-r--r--test/SemaObjC/comptypes-7.m4
-rw-r--r--test/SemaObjC/comptypes-a.m2
-rw-r--r--test/SemaObjC/conditional-expr-3.m2
-rw-r--r--test/SemaObjC/conditional-expr-5.m2
-rw-r--r--test/SemaObjC/conditional-expr.m6
-rw-r--r--test/SemaObjC/conflict-nonfragile-abi2.m2
-rw-r--r--test/SemaObjC/conflicting-ivar-test-1.m2
-rw-r--r--test/SemaObjC/continuation-class-err.m11
-rw-r--r--test/SemaObjC/continuation-class-property.m24
-rw-r--r--test/SemaObjC/custom-atomic-property.m2
-rw-r--r--test/SemaObjC/debugger-cast-result-to-id.m16
-rw-r--r--test/SemaObjC/default-synthesize-1.m2
-rw-r--r--test/SemaObjC/default-synthesize-2.m4
-rw-r--r--test/SemaObjC/default-synthesize-3.m41
-rw-r--r--test/SemaObjC/default-synthesize.m33
-rw-r--r--test/SemaObjC/deref-interface.m4
-rw-r--r--test/SemaObjC/direct-synthesized-ivar-access.m2
-rw-r--r--test/SemaObjC/dist-object-modifiers.m2
-rw-r--r--test/SemaObjC/enhanced-proto-2.m4
-rw-r--r--test/SemaObjC/enum-fixed-type.m10
-rw-r--r--test/SemaObjC/err-ivar-access-in-class-method.m26
-rw-r--r--test/SemaObjC/error-property-gc-attr.m4
-rw-r--r--test/SemaObjC/exprs.m2
-rw-r--r--test/SemaObjC/foreach.m9
-rw-r--r--test/SemaObjC/format-strings-objc.m131
-rw-r--r--test/SemaObjC/forward-class-1.m12
-rw-r--r--test/SemaObjC/forward-class-receiver.m2
-rw-r--r--test/SemaObjC/forward-class-redeclare.m29
-rw-r--r--test/SemaObjC/gcc-cast-ext.m6
-rw-r--r--test/SemaObjC/ibaction.m2
-rw-r--r--test/SemaObjC/iboutletcollection-attr.m18
-rw-r--r--test/SemaObjC/id-isa-ref.m5
-rw-r--r--test/SemaObjC/idiomatic-parentheses.m2
-rw-r--r--test/SemaObjC/ignore-qualifier-on-qualified-id.m21
-rw-r--r--test/SemaObjC/illegal-nonarc-bridged-cast.m44
-rw-r--r--test/SemaObjC/incomplete-implementation.m19
-rw-r--r--test/SemaObjC/instancetype.m6
-rw-r--r--test/SemaObjC/interface-scope-2.m2
-rw-r--r--test/SemaObjC/invalid-code.m37
-rw-r--r--test/SemaObjC/invalid-objc-decls-1.m4
-rw-r--r--test/SemaObjC/ivar-access-tests.m2
-rw-r--r--test/SemaObjC/ivar-in-class-extension.m2
-rw-r--r--test/SemaObjC/ivar-in-implementations.m2
-rw-r--r--test/SemaObjC/ivar-lookup-resolution-builtin.m4
-rw-r--r--test/SemaObjC/ivar-lookup.m37
-rw-r--r--test/SemaObjC/ivar-ref-misuse.m2
-rw-r--r--test/SemaObjC/legacy-implementation-1.m2
-rw-r--r--test/SemaObjC/message.m2
-rw-r--r--test/SemaObjC/method-attributes.m35
-rw-r--r--test/SemaObjC/method-bad-param.m14
-rw-r--r--test/SemaObjC/method-conflict-1.m2
-rw-r--r--test/SemaObjC/method-conflict-2.m2
-rw-r--r--test/SemaObjC/method-conflict.m2
-rw-r--r--test/SemaObjC/method-def-1.m2
-rw-r--r--test/SemaObjC/method-lookup.m2
-rw-r--r--test/SemaObjC/method-not-defined.m2
-rw-r--r--test/SemaObjC/method-prototype-scope.m2
-rw-r--r--test/SemaObjC/method-typecheck-1.m2
-rw-r--r--test/SemaObjC/method-undef-category-warn-1.m52
-rw-r--r--test/SemaObjC/method-undef-extension-warn-1.m6
-rw-r--r--test/SemaObjC/method-undefined-warn-1.m2
-rw-r--r--test/SemaObjC/method-unused-attribute.m2
-rw-r--r--test/SemaObjC/missing-atend-metadata.m16
-rw-r--r--test/SemaObjC/missing-method-return-type.m6
-rw-r--r--test/SemaObjC/narrow-property-type-in-cont-class.m19
-rw-r--r--test/SemaObjC/nested-typedef-decl.m4
-rw-r--r--test/SemaObjC/newproperty-class-method-1.m2
-rw-r--r--test/SemaObjC/no-gc-weak-test.m2
-rw-r--r--test/SemaObjC/no-ivar-access-control.m70
-rw-r--r--test/SemaObjC/no-protocol-option-tests.m4
-rw-r--r--test/SemaObjC/no-warn-qual-mismatch.m2
-rw-r--r--test/SemaObjC/no-warn-synth-protocol-meth.m2
-rw-r--r--test/SemaObjC/no-warning-unavail-unimp.m2
-rw-r--r--test/SemaObjC/nonnull.m2
-rw-r--r--test/SemaObjC/nsobject-attribute-1.m2
-rw-r--r--test/SemaObjC/nsobject-attribute.m18
-rw-r--r--test/SemaObjC/objc-array-literal.m41
-rw-r--r--test/SemaObjC/objc-buffered-methods.m2
-rw-r--r--test/SemaObjC/objc-container-subscripting-1.m23
-rw-r--r--test/SemaObjC/objc-container-subscripting-2.m30
-rw-r--r--test/SemaObjC/objc-container-subscripting-3.m25
-rw-r--r--test/SemaObjC/objc-container-subscripting.m42
-rw-r--r--test/SemaObjC/objc-cstyle-args-in-methods.m2
-rw-r--r--test/SemaObjC/objc-dictionary-literal.m34
-rw-r--r--test/SemaObjC/objc-literal-nsnumber.m85
-rw-r--r--test/SemaObjC/objc-literal-sig.m40
-rw-r--r--test/SemaObjC/objc-qualified-property-lookup.m2
-rw-r--r--test/SemaObjC/pedantic-dynamic-test.m2
-rw-r--r--test/SemaObjC/pragma-pack.m16
-rw-r--r--test/SemaObjC/property-10.m9
-rw-r--r--test/SemaObjC/property-2.m2
-rw-r--r--test/SemaObjC/property-9.m13
-rw-r--r--test/SemaObjC/property-and-ivar-use.m2
-rw-r--r--test/SemaObjC/property-category-1.m4
-rw-r--r--test/SemaObjC/property-category-3.m2
-rw-r--r--test/SemaObjC/property-category-4.m2
-rw-r--r--test/SemaObjC/property-category-impl.m2
-rw-r--r--test/SemaObjC/property-dot-receiver.m4
-rw-r--r--test/SemaObjC/property-error-readonly-assign.m6
-rw-r--r--test/SemaObjC/property-expression-error.m2
-rw-r--r--test/SemaObjC/property-impl-misuse.m2
-rw-r--r--test/SemaObjC/property-in-class-extension.m4
-rw-r--r--test/SemaObjC/property-ivar-mismatch.m2
-rw-r--r--test/SemaObjC/property-lookup-in-id.m4
-rw-r--r--test/SemaObjC/property-method-lookup-impl.m2
-rw-r--r--test/SemaObjC/property-missing.m2
-rw-r--r--test/SemaObjC/property-not-lvalue.m2
-rw-r--r--test/SemaObjC/property-ns-returns-not-retained-attr.m2
-rw-r--r--test/SemaObjC/property-redundant-decl-accessor.m2
-rw-r--r--test/SemaObjC/property-typecheck-1.m2
-rw-r--r--test/SemaObjC/property-user-setter.m6
-rw-r--r--test/SemaObjC/property.m18
-rw-r--r--test/SemaObjC/protocol-archane.m2
-rw-r--r--test/SemaObjC/protocol-id-test-1.m2
-rw-r--r--test/SemaObjC/protocol-id-test-2.m2
-rw-r--r--test/SemaObjC/protocol-implementing-class-methods.m6
-rw-r--r--test/SemaObjC/provisional-ivar-lookup.m2
-rw-r--r--test/SemaObjC/qualified-protocol-method-conflicts.m2
-rw-r--r--test/SemaObjC/receiver-forward-class.m19
-rw-r--r--test/SemaObjC/related-result-type-inference.m13
-rw-r--r--test/SemaObjC/return.m2
-rw-r--r--test/SemaObjC/scope-check.m30
-rw-r--r--test/SemaObjC/selector-3.m2
-rw-r--r--test/SemaObjC/selector-error.m2
-rw-r--r--test/SemaObjC/self-assign.m2
-rw-r--r--test/SemaObjC/self-declared-in-block.m4
-rw-r--r--test/SemaObjC/severe-syntax-error.m23
-rw-r--r--test/SemaObjC/sizeof-interface.m8
-rw-r--r--test/SemaObjC/special-dep-unavail-warning.m12
-rw-r--r--test/SemaObjC/stand-alone-implementation.m2
-rw-r--r--test/SemaObjC/super.m2
-rw-r--r--test/SemaObjC/synchronized.m2
-rw-r--r--test/SemaObjC/synth-provisional-ivars-1.m2
-rw-r--r--test/SemaObjC/synth-provisional-ivars.m2
-rw-r--r--test/SemaObjC/synthesize-setter-contclass.m2
-rw-r--r--test/SemaObjC/synthesized-ivar.m2
-rw-r--r--test/SemaObjC/transparent-union.m2
-rw-r--r--test/SemaObjC/try-catch.m2
-rw-r--r--test/SemaObjC/typedef-class.m4
-rw-r--r--test/SemaObjC/undeclared-selector.m2
-rw-r--r--test/SemaObjC/undef-protocol-methods-1.m22
-rw-r--r--test/SemaObjC/undef-superclass-1.m4
-rw-r--r--test/SemaObjC/undefined-protocol-type-1.m2
-rw-r--r--test/SemaObjC/unimplemented-protocol-prop.m2
-rw-r--r--test/SemaObjC/unknown-anytype.m29
-rw-r--r--test/SemaObjC/unused.m2
-rw-r--r--test/SemaObjC/warn-deprecated-implementations.m10
-rw-r--r--test/SemaObjC/warn-forward-class-attr-deprecated.m24
-rw-r--r--test/SemaObjC/warn-implicit-atomic-property.m6
-rw-r--r--test/SemaObjC/warn-missing-super.m11
-rw-r--r--test/SemaObjC/warn-retain-cycle.m36
-rw-r--r--test/SemaObjC/warn-strict-selector-match.m6
-rw-r--r--test/SemaObjC/warn-unreachable.m17
-rw-r--r--test/SemaObjC/warn-weak-field.m4
-rw-r--r--test/SemaObjC/weak-property.m2
-rw-r--r--test/SemaObjC/weak-receiver-warn.m19
-rw-r--r--test/SemaObjCXX/NSString-type.mm10
-rw-r--r--test/SemaObjCXX/arc-0x.mm21
-rw-r--r--test/SemaObjCXX/arc-overloading.mm2
-rw-r--r--test/SemaObjCXX/arc-ppe.mm16
-rw-r--r--test/SemaObjCXX/arc-templates.mm4
-rw-r--r--test/SemaObjCXX/arc-type-conversion.mm5
-rw-r--r--test/SemaObjCXX/arc-type-traits.mm16
-rw-r--r--test/SemaObjCXX/arc-unavailable-for-weakref.mm9
-rw-r--r--test/SemaObjCXX/arc-unbridged-cast.mm110
-rw-r--r--test/SemaObjCXX/blocks.mm2
-rw-r--r--test/SemaObjCXX/composite-objc-pointertype.mm2
-rw-r--r--test/SemaObjCXX/cstyle-block-pointer-cast.mm2
-rw-r--r--test/SemaObjCXX/cxxoperator-selector.mm2
-rw-r--r--test/SemaObjCXX/debugger-cast-result-to-id.mm17
-rw-r--r--test/SemaObjCXX/fragile-abi-object-assign.m13
-rw-r--r--test/SemaObjCXX/goto.mm2
-rw-r--r--test/SemaObjCXX/instantiate-expr.mm10
-rw-r--r--test/SemaObjCXX/instantiate-method-return.mm2
-rw-r--r--test/SemaObjCXX/ivar-construct.mm2
-rw-r--r--test/SemaObjCXX/ivar-lookup.mm2
-rw-r--r--test/SemaObjCXX/literals.mm187
-rw-r--r--test/SemaObjCXX/message.mm2
-rw-r--r--test/SemaObjCXX/objc-container-subscripting.mm138
-rw-r--r--test/SemaObjCXX/objc-decls-inside-namespace.mm2
-rw-r--r--test/SemaObjCXX/objc-extern-c.mm30
-rw-r--r--test/SemaObjCXX/objc-pointer-conv.mm2
-rw-r--r--test/SemaObjCXX/overload.mm8
-rw-r--r--test/SemaObjCXX/propert-dot-error.mm4
-rw-r--r--test/SemaObjCXX/properties.mm88
-rw-r--r--test/SemaObjCXX/property-reference.mm6
-rw-r--r--test/SemaObjCXX/property-synthesis-error.mm6
-rw-r--r--test/SemaObjCXX/unknown-anytype.mm1
-rw-r--r--test/SemaObjCXX/vararg-non-pod.mm2
-rw-r--r--test/SemaObjCXX/void_to_obj.mm2
-rw-r--r--test/SemaObjCXX/warn-strict-selector-match.mm4
-rw-r--r--test/SemaOpenCL/address-spaces.cl13
-rw-r--r--test/SemaOpenCL/local.cl6
-rw-r--r--test/SemaOpenCL/vec_compare.cl11
-rw-r--r--test/SemaOpenCL/vector_literals_const.cl26
-rw-r--r--test/SemaTemplate/alias-templates.cpp32
-rw-r--r--test/SemaTemplate/atomics.cpp8
-rw-r--r--test/SemaTemplate/canonical-expr-type-0x.cpp21
-rw-r--r--test/SemaTemplate/class-template-ctor-initializer.cpp2
-rw-r--r--test/SemaTemplate/class-template-decl.cpp21
-rw-r--r--test/SemaTemplate/class-template-spec.cpp12
-rw-r--r--test/SemaTemplate/constexpr-instantiate.cpp77
-rw-r--r--test/SemaTemplate/crash-10438657.cpp15
-rw-r--r--test/SemaTemplate/deduction-crash.cpp2
-rw-r--r--test/SemaTemplate/delegating-constructors.cpp13
-rw-r--r--test/SemaTemplate/enum-forward.cpp2
-rw-r--r--test/SemaTemplate/explicit-instantiation.cpp10
-rw-r--r--test/SemaTemplate/friend-template.cpp19
-rw-r--r--test/SemaTemplate/friend.cpp2
-rw-r--r--test/SemaTemplate/instantiate-complete.cpp2
-rw-r--r--test/SemaTemplate/instantiate-declref-ice.cpp2
-rw-r--r--test/SemaTemplate/instantiate-expr-1.cpp11
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp10
-rw-r--r--test/SemaTemplate/instantiate-expr-5.cpp2
-rw-r--r--test/SemaTemplate/instantiate-function-1.cpp2
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp22
-rw-r--r--test/SemaTemplate/instantiate-self.cpp89
-rw-r--r--test/SemaTemplate/instantiate-sizeof.cpp10
-rw-r--r--test/SemaTemplate/instantiate-static-var.cpp3
-rw-r--r--test/SemaTemplate/instantiate-typeof.cpp10
-rw-r--r--test/SemaTemplate/instantiation-depth.cpp4
-rw-r--r--test/SemaTemplate/instantiation-order.cpp15
-rw-r--r--test/SemaTemplate/member-access-ambig.cpp10
-rw-r--r--test/SemaTemplate/member-template-access-expr.cpp2
-rw-r--r--test/SemaTemplate/ms-if-exists.cpp68
-rw-r--r--test/SemaTemplate/ms-lookup-template-base-classes.cpp116
-rw-r--r--test/SemaTemplate/nested-incomplete-class.cpp21
-rw-r--r--test/SemaTemplate/nested-template.cpp13
-rw-r--r--test/SemaTemplate/pragma-ms_struct.cpp10
-rw-r--r--test/SemaTemplate/qualified-id.cpp9
-rw-r--r--test/SemaTemplate/resolve-single-template-id.cpp4
-rw-r--r--test/SemaTemplate/temp_arg_template.cpp6
-rw-r--r--test/SemaTemplate/temp_class_spec_neg.cpp2
-rw-r--r--test/SemaTemplate/temp_explicit.cpp8
-rw-r--r--test/SemaTemplate/temp_explicit_cxx0x.cpp2
-rw-r--r--test/SemaTemplate/template-id-expr.cpp14
-rw-r--r--test/SemaTemplate/template-id-printing.cpp128
-rw-r--r--test/Tooling/clang-check-pwd.cpp13
-rw-r--r--test/Tooling/clang-check.cpp13
-rw-r--r--test/lit.cfg49
1850 files changed, 54968 insertions, 6723 deletions
diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h
index 2603730..16856ed 100644
--- a/test/ARCMT/Common.h
+++ b/test/ARCMT/Common.h
@@ -4,8 +4,10 @@
#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
#endif
+#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
#define CF_CONSUMED __attribute__((cf_consumed))
+#define NS_INLINE static __inline__ __attribute__((always_inline))
#define nil ((void*) 0)
typedef int BOOL;
@@ -19,6 +21,9 @@ typedef struct _NSZone NSZone;
typedef const void * CFTypeRef;
CFTypeRef CFRetain(CFTypeRef cf);
+id CFBridgingRelease(CFTypeRef CF_CONSUMED X);
+
+NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
@protocol NSObject
- (BOOL)isEqual:(id)object;
diff --git a/test/ARCMT/GC-check-warn-nsalloc.m b/test/ARCMT/GC-check-warn-nsalloc.m
new file mode 100644
index 0000000..5ce36c4
--- /dev/null
+++ b/test/ARCMT/GC-check-warn-nsalloc.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s
+// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
+// DISABLE: mingw32
+// rdar://10532541
+// XFAIL: *
+
+typedef unsigned NSUInteger;
+void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
+
+void test1() {
+ NSAllocateCollectable(100, 0); // expected-warning {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
+}
diff --git a/test/ARCMT/GC-check.m b/test/ARCMT/GC-check.m
new file mode 100644
index 0000000..3a1b67c
--- /dev/null
+++ b/test/ARCMT/GC-check.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s
+// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s
+// DISABLE: mingw32
+
+#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
+typedef unsigned NSUInteger;
+typedef const void * CFTypeRef;
+CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable}}
+void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options);
+
+void test1(CFTypeRef *cft) {
+ CFTypeRef c = CFMakeCollectable(cft); // expected-error {{CFMakeCollectable will leak the object that it receives in ARC}} \
+ // expected-error {{unavailable}}
+ NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}}
+}
+
+@interface I1 {
+ __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}}
+}
+@end;
diff --git a/test/ARCMT/GC-no-arc-runtime.m b/test/ARCMT/GC-no-arc-runtime.m
new file mode 100644
index 0000000..f069992
--- /dev/null
+++ b/test/ARCMT/GC-no-arc-runtime.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+@interface I5 {
+ __weak id prop;
+}
+@property (readonly) __weak id prop;
+@end
diff --git a/test/ARCMT/GC-no-arc-runtime.m.result b/test/ARCMT/GC-no-arc-runtime.m.result
new file mode 100644
index 0000000..f55ca38
--- /dev/null
+++ b/test/ARCMT/GC-no-arc-runtime.m.result
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __unsafe_unretained id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (unsafe_unretained) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+}
+@property (unsafe_unretained) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, ps, pds, pds2;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+@interface I5 {
+ __unsafe_unretained id prop;
+}
+@property (unsafe_unretained, readonly) id prop;
+@end
diff --git a/test/ARCMT/GC-no-finalize-removal.m b/test/ARCMT/GC-no-finalize-removal.m
new file mode 100644
index 0000000..14e8602
--- /dev/null
+++ b/test/ARCMT/GC-no-finalize-removal.m
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (readonly) __weak I4Impl *pw3;
+@property (assign) __weak I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
diff --git a/test/ARCMT/GC-no-finalize-removal.m.result b/test/ARCMT/GC-no-finalize-removal.m.result
new file mode 100644
index 0000000..ea14873
--- /dev/null
+++ b/test/ARCMT/GC-no-finalize-removal.m.result
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+#if !__has_feature(objc_arc)
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+#endif
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+#if !__has_feature(objc_arc)
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+#endif
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (weak) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (weak) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (weak, readonly) I4Impl *pw3;
+@property (weak) I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id strong_readonly_prop;
+@property (weak) id weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
diff --git a/test/ARCMT/GC.h b/test/ARCMT/GC.h
new file mode 100644
index 0000000..4301baf
--- /dev/null
+++ b/test/ARCMT/GC.h
@@ -0,0 +1,6 @@
+
+@interface ExtInterface {
+ __strong ExtInterface *myivar;
+ __strong void *gcVar;
+}
+@end
diff --git a/test/ARCMT/GC.m b/test/ARCMT/GC.m
new file mode 100644
index 0000000..eebbaf6
--- /dev/null
+++ b/test/ARCMT/GC.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = NSMakeCollectable(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+-(void)finalize {
+ // finalize
+ test1(0);
+}
+@end
+
+@interface I2
+@property (retain) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)finalize {
+ self.prop = 0;
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __weak QQ *q;
+}
+@end
+
+@interface I3
+@property (assign) I3 *__weak pw1, *__weak pw2;
+@property (assign) I3 *__strong ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (assign) I4Impl *__weak pw1, *__weak pw2;
+@property (assign) I4Impl *__strong ps;
+@property (assign) I4Impl * pds;
+@property (assign) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (readonly) __weak I4Impl *pw3;
+@property (assign) __weak I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = NSMakeCollectable(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (assign) id assign_prop;
+@property (assign, readonly) id __strong strong_readonly_prop;
+@property (assign) id __weak weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
+
+void test2(id p, __strong I1 *ap[]) {
+ for (__strong I1 *specRule in p) {
+ }
+}
diff --git a/test/ARCMT/GC.m.result b/test/ARCMT/GC.m.result
new file mode 100644
index 0000000..c2c523f
--- /dev/null
+++ b/test/ARCMT/GC.m.result
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t
+// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#include "Common.h"
+#include "GC.h"
+
+void test1(CFTypeRef *cft) {
+ id x = CFBridgingRelease(cft);
+}
+
+@interface I1
+@end
+
+@implementation I1
+-(void)dealloc {
+ // dealloc
+ test1(0);
+}
+
+@end
+
+@interface I2
+@property (strong) id prop;
+@end
+
+@implementation I2
+@synthesize prop;
+
+-(void)dealloc {
+ // finalize
+ test1(0);
+}
+@end
+
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface QQ {
+ __weak id s;
+ __unsafe_unretained QQ *q;
+}
+@end
+
+@interface I3
+@property (weak) I3 * pw1, * pw2;
+@property (strong) I3 * ps;
+@property (assign) I3 * pds;
+@end
+
+@interface I4Impl {
+ I4Impl *__strong pds2;
+ I4Impl *pds3;
+ __weak I4Impl *pw3;
+ __weak I4Impl *pw4;
+}
+@property (weak) I4Impl * pw1, * pw2;
+@property (strong) I4Impl * ps;
+@property (strong) I4Impl * pds;
+@property (strong) I4Impl * pds2;
+@property (readwrite) I4Impl * pds3;
+@property (readonly) I4Impl * pds4;
+@property (weak, readonly) I4Impl *pw3;
+@property (weak) I4Impl *pw4;
+@end
+
+@implementation I4Impl
+@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4;
+
+-(void)test1:(CFTypeRef *)cft {
+ id x = CFBridgingRelease(cft);
+}
+@end
+
+// rdar://10532449
+@interface rdar10532449
+@property (strong) id assign_prop;
+@property (strong, readonly) id strong_readonly_prop;
+@property (weak) id weak_prop;
+@end
+
+@implementation rdar10532449
+@synthesize assign_prop, strong_readonly_prop, weak_prop;
+@end
+
+void test2(id p, __strong I1 *ap[]) {
+ for (__strong I1 *specRule in p) {
+ }
+}
diff --git a/test/ARCMT/api.m b/test/ARCMT/api.m
index b186ec7..ba122c4 100644
--- a/test/ARCMT/api.m
+++ b/test/ARCMT/api.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/api.m.result b/test/ARCMT/api.m.result
index e309375..7e04e7d 100644
--- a/test/ARCMT/api.m.result
+++ b/test/ARCMT/api.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m b/test/ARCMT/assign-prop-with-arc-runtime.m
index 9e10b58..c357eeb 100644
--- a/test/ARCMT/assign-prop-with-arc-runtime.m
+++ b/test/ARCMT/assign-prop-with-arc-runtime.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
@@ -36,12 +37,18 @@ typedef _NSCachedAttributedString *BadClassForWeak;
@property (assign) Foo *no_user_ivar1;
@property (readonly) Foo *no_user_ivar2;
+
+@property (retain) id def1;
+@property (atomic,retain) id def2;
+@property (retain,atomic) id def3;
+
@end
@implementation Foo
@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
@synthesize no_user_ivar1, no_user_ivar2;
@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
-(void)test:(Foo *)parm {
assign_plus1 = [[Foo alloc] init];
@@ -49,3 +56,18 @@ typedef _NSCachedAttributedString *BadClassForWeak;
assign_plus3 = [parm retain];
}
@end
+
+@interface TestExt
+@property (retain,readonly) TestExt *x1;
+@property (readonly) TestExt *x2;
+@end
+
+@interface TestExt()
+@property (retain,readwrite) TestExt *x1;
+@property (readwrite) TestExt *x2;
+@property (retain) TestExt *x3;
+@end
+
+@implementation TestExt
+@synthesize x1, x2, x3;
+@end
diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m.result b/test/ARCMT/assign-prop-with-arc-runtime.m.result
index 8a3a0f7..a255a36 100644
--- a/test/ARCMT/assign-prop-with-arc-runtime.m.result
+++ b/test/ARCMT/assign-prop-with-arc-runtime.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
@@ -22,7 +23,7 @@ typedef _NSCachedAttributedString *BadClassForWeak;
Forw *__unsafe_unretained not_safe3;
Foo *assign_plus1;
}
-@property (readonly) Foo *x;
+@property (weak, readonly) Foo *x;
@property (weak) Foo *w;
@property (weak) Foo *q1, *q2;
@property (unsafe_unretained) WeakOptOut *oo;
@@ -31,17 +32,23 @@ typedef _NSCachedAttributedString *BadClassForWeak;
@property (unsafe_unretained) NSObject *not_safe2;
@property (unsafe_unretained) Forw *not_safe3;
@property (readonly) Foo *assign_plus1;
-@property (strong, readonly) Foo *assign_plus2;
-@property (strong, readonly) Foo *assign_plus3;
+@property (readonly) Foo *assign_plus2;
+@property (readonly) Foo *assign_plus3;
@property (weak) Foo *no_user_ivar1;
@property (weak, readonly) Foo *no_user_ivar2;
+
+@property (strong) id def1;
+@property (atomic,strong) id def2;
+@property (strong,atomic) id def3;
+
@end
@implementation Foo
@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3;
@synthesize no_user_ivar1, no_user_ivar2;
@synthesize assign_plus1, assign_plus2, assign_plus3;
+@synthesize def1, def2, def3;
-(void)test:(Foo *)parm {
assign_plus1 = [[Foo alloc] init];
@@ -49,3 +56,18 @@ typedef _NSCachedAttributedString *BadClassForWeak;
assign_plus3 = parm;
}
@end
+
+@interface TestExt
+@property (strong,readonly) TestExt *x1;
+@property (weak, readonly) TestExt *x2;
+@end
+
+@interface TestExt()
+@property (strong,readwrite) TestExt *x1;
+@property (weak, readwrite) TestExt *x2;
+@property (strong) TestExt *x3;
+@end
+
+@implementation TestExt
+@synthesize x1, x2, x3;
+@end
diff --git a/test/ARCMT/atautorelease-2.m b/test/ARCMT/atautorelease-2.m
index b9bc106..5c2cd6b 100644
--- a/test/ARCMT/atautorelease-2.m
+++ b/test/ARCMT/atautorelease-2.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface NSAutoreleasePool
- drain;
diff --git a/test/ARCMT/atautorelease-2.m.result b/test/ARCMT/atautorelease-2.m.result
index 2054733..06bf0d5 100644
--- a/test/ARCMT/atautorelease-2.m.result
+++ b/test/ARCMT/atautorelease-2.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface NSAutoreleasePool
- drain;
diff --git a/test/ARCMT/atautorelease-3.m b/test/ARCMT/atautorelease-3.m
index 87b80af..0b6abdf 100644
--- a/test/ARCMT/atautorelease-3.m
+++ b/test/ARCMT/atautorelease-3.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface NSAutoreleasePool
- drain;
diff --git a/test/ARCMT/atautorelease-3.m.result b/test/ARCMT/atautorelease-3.m.result
index 801376a..9103de4 100644
--- a/test/ARCMT/atautorelease-3.m.result
+++ b/test/ARCMT/atautorelease-3.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface NSAutoreleasePool
- drain;
diff --git a/test/ARCMT/atautorelease-check.m b/test/ARCMT/atautorelease-check.m
index d74ef3b..8daf9d6 100644
--- a/test/ARCMT/atautorelease-check.m
+++ b/test/ARCMT/atautorelease-check.m
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
#if __has_feature(objc_arr)
#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
diff --git a/test/ARCMT/atautorelease.m b/test/ARCMT/atautorelease.m
index a6aed14..132553b 100644
--- a/test/ARCMT/atautorelease.m
+++ b/test/ARCMT/atautorelease.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/atautorelease.m.result b/test/ARCMT/atautorelease.m.result
index e24339a..5191f47 100644
--- a/test/ARCMT/atautorelease.m.result
+++ b/test/ARCMT/atautorelease.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/autoreleases.m b/test/ARCMT/autoreleases.m
index ed78cb4..3acddb7 100644
--- a/test/ARCMT/autoreleases.m
+++ b/test/ARCMT/autoreleases.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
typedef unsigned char BOOL;
diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result
index acb81b5..49bc321 100644
--- a/test/ARCMT/autoreleases.m.result
+++ b/test/ARCMT/autoreleases.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
typedef unsigned char BOOL;
diff --git a/test/ARCMT/check-with-serialized-diag.m b/test/ARCMT/check-with-serialized-diag.m
new file mode 100644
index 0000000..d8073d0
--- /dev/null
+++ b/test/ARCMT/check-with-serialized-diag.m
@@ -0,0 +1,55 @@
+
+@protocol NSObject
+- (id)retain;
+- (unsigned)retainCount;
+- (oneway void)release;
+- (id)autorelease;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
+
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
+
+@interface A : NSObject
+@end
+
+struct UnsafeS {
+ A *__unsafe_unretained unsafeObj;
+};
+
+id global_foo;
+
+void test1(A *a, struct UnsafeS *unsafeS) {
+ [unsafeS->unsafeObj retain];
+ id foo = [unsafeS->unsafeObj retain]; // no warning.
+ [global_foo retain];
+ [a retainCount];
+}
+
+// RUN: not %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag
+// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+// CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:4: error: ARC forbids explicit message send of 'retain'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:23 {{.*}}check-with-serialized-diag.m:32:29
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: ARC forbids explicit message send of 'retain'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:15 {{.*}}check-with-serialized-diag.m:34:21
+// CHECK-NEXT: Number FIXITs = 0
+// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:4: error: ARC forbids explicit message send of 'retainCount'
+// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:6 {{.*}}check-with-serialized-diag.m:35:17
+// CHECK-NEXT: Number FIXITs = 0
+
diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m
index 7c24dc4..cf71611 100644
--- a/test/ARCMT/checking.m
+++ b/test/ARCMT/checking.m
@@ -1,6 +1,38 @@
// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
+
+#if __has_feature(objc_arc)
+#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
+#else
+#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
+#endif
+
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+typedef int BOOL;
+typedef unsigned NSUInteger;
+
+@protocol NSObject
+- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
+@end
+
+@interface NSObject <NSObject> {}
+- (id)init;
-#include "Common.h"
++ (id)new;
++ (id)alloc;
+- (void)dealloc;
+
+- (void)finalize;
+
+- (id)copy;
+- (id)mutableCopy;
+@end
typedef const struct __CFString * CFStringRef;
extern const CFStringRef kUTTypePlainText;
@@ -62,8 +94,8 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {
CFStringRef cfstr;
NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \
str = (NSString *)kUTTypePlainText;
str = b ? kUTTypeRTF : kUTTypePlainText;
str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText);
@@ -120,11 +152,11 @@ void * cvt(id arg)
(void)(__autoreleasing id**)voidp_val;
(void)(void*)voidp_val;
(void)(void**)arg; // expected-error {{disallowed}}
- cvt((void*)arg); // expected-error {{requires a bridged cast}} expected-error {{disallowed}} \
- // expected-note {{use __bridge}} expected-note {{use __bridge_retained}}
+ cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \
+ // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}}
cvt(0);
(void)(__strong id**)(0);
- return arg; // expected-error {{disallowed}}
+ return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
}
diff --git a/test/ARCMT/cxx-checking.mm b/test/ARCMT/cxx-checking.mm
index ab6b29b..9f9e3d8 100644
--- a/test/ARCMT/cxx-checking.mm
+++ b/test/ARCMT/cxx-checking.mm
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks -Warc-abi %s
+// DISABLE: mingw32
// Classes that have an Objective-C object pointer.
struct HasObjectMember0 { // expected-warning{{'HasObjectMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}}
diff --git a/test/ARCMT/cxx-rewrite.mm b/test/ARCMT/cxx-rewrite.mm
index 4a9c50c..92bb718 100644
--- a/test/ARCMT/cxx-rewrite.mm
+++ b/test/ARCMT/cxx-rewrite.mm
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result
index 0dd67e8..a2dc9a5 100644
--- a/test/ARCMT/cxx-rewrite.mm.result
+++ b/test/ARCMT/cxx-rewrite.mm.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/dealloc.m b/test/ARCMT/dealloc.m
index d7a72af4..34df1a4 100644
--- a/test/ARCMT/dealloc.m
+++ b/test/ARCMT/dealloc.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface A
- (id)retain;
diff --git a/test/ARCMT/dealloc.m.result b/test/ARCMT/dealloc.m.result
index fbd9e44..3ff2885 100644
--- a/test/ARCMT/dealloc.m.result
+++ b/test/ARCMT/dealloc.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
@interface A
- (id)retain;
diff --git a/test/ARCMT/dispatch.m b/test/ARCMT/dispatch.m
new file mode 100644
index 0000000..75c4a83
--- /dev/null
+++ b/test/ARCMT/dispatch.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+
+#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
+#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
+#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
+#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
+
+typedef id dispatch_object_t;
+typedef id xpc_object_t;
+
+void _dispatch_object_validate(dispatch_object_t object);
+void _xpc_object_validate(xpc_object_t object);
+
+dispatch_object_t getme(void);
+
+void func(dispatch_object_t o) {
+ dispatch_retain(o);
+ dispatch_release(o);
+ dispatch_retain(getme());
+}
+
+void func2(xpc_object_t o) {
+ xpc_retain(o);
+ xpc_release(o);
+}
diff --git a/test/ARCMT/dispatch.m.result b/test/ARCMT/dispatch.m.result
new file mode 100644
index 0000000..e897672
--- /dev/null
+++ b/test/ARCMT/dispatch.m.result
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
+// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t
+// RUN: diff %t %s.result
+
+#include "Common.h"
+
+#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
+#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
+#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
+#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
+
+typedef id dispatch_object_t;
+typedef id xpc_object_t;
+
+void _dispatch_object_validate(dispatch_object_t object);
+void _xpc_object_validate(xpc_object_t object);
+
+dispatch_object_t getme(void);
+
+void func(dispatch_object_t o) {
+ getme();
+}
+
+void func2(xpc_object_t o) {
+}
diff --git a/test/ARCMT/driver-migrate.m b/test/ARCMT/driver-migrate.m
index 32e84d7..a912ad9 100644
--- a/test/ARCMT/driver-migrate.m
+++ b/test/ARCMT/driver-migrate.m
@@ -1,11 +1,11 @@
// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s
-// CHECK: "-arcmt-migrate" "-arcmt-migrate-directory" "{{[^"]*}}/foo/bar"
+// CHECK: "-arcmt-migrate" "-mt-migrate-directory" "{{[^"]*}}/foo/bar"
// RUN: touch %t.o
-// RUN: %clang -ccc-arcmt-check -ccc-host-triple i386-apple-darwin9 -### %t.o 2> %t.log
+// RUN: %clang -ccc-arcmt-check -target i386-apple-darwin9 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK %s < %t.log
-// RUN: %clang -ccc-arcmt-migrate /foo/bar -ccc-host-triple i386-apple-darwin9 -### %t.o 2> %t.log
+// RUN: %clang -ccc-arcmt-migrate /foo/bar -target i386-apple-darwin9 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK %s < %t.log
// LINK-NOT: {{ld(.exe)?"}}
diff --git a/test/ARCMT/init.m b/test/ARCMT/init.m
index 8636e37..9dbb1f8 100644
--- a/test/ARCMT/init.m
+++ b/test/ARCMT/init.m
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#define nil (void *)0
@interface NSObject
-init;
diff --git a/test/ARCMT/init.m.result b/test/ARCMT/init.m.result
index 0140bb9..d7f7300 100644
--- a/test/ARCMT/init.m.result
+++ b/test/ARCMT/init.m.result
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
+
+#define nil (void *)0
@interface NSObject
-init;
@@ -15,7 +18,7 @@
@implementation A
-(id) init {
- self = [self init];
+ if (!(self = [self init])) return nil;
id a;
[a init];
a = [[A alloc] init];
@@ -24,7 +27,7 @@
}
-(id) init2 {
- self = [super init];
+ if (!(self = [super init])) return nil;
return self;
}
diff --git a/test/ARCMT/migrate-emit-errors.m b/test/ARCMT/migrate-emit-errors.m
index 6a4a396..95c0d2f 100644
--- a/test/ARCMT/migrate-emit-errors.m
+++ b/test/ARCMT/migrate-emit-errors.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s
// RUN: rm -rf %t
@protocol NSObject
diff --git a/test/ARCMT/migrate-plist-output.m b/test/ARCMT/migrate-plist-output.m
index e5b74e9..12efa93 100644
--- a/test/ARCMT/migrate-plist-output.m
+++ b/test/ARCMT/migrate-plist-output.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s
// RUN: FileCheck %s -input-file=%t.plist
// RUN: rm -rf %t.dir
@@ -21,7 +21,7 @@ void test(id p) {
// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>description</key><string>ARC forbids explicit message send of &apos;release&apos;</string>
-// CHECK: <key>category</key><string>Automatic Reference Counting Issue</string>
+// CHECK: <key>category</key><string>ARC Restrictions</string>
// CHECK: <key>type</key><string>error</string>
// CHECK: <key>location</key>
// CHECK: <dict>
@@ -48,3 +48,5 @@ void test(id p) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
+
+// DISABLE: mingw32
diff --git a/test/ARCMT/migrate-space-in-path.m b/test/ARCMT/migrate-space-in-path.m
index 3261766..89dfe14 100644
--- a/test/ARCMT/migrate-space-in-path.m
+++ b/test/ARCMT/migrate-space-in-path.m
@@ -1,5 +1,6 @@
// RUN: rm -rf %t.migrate
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.migrate %S/"with space"/test1.m.in -x objective-c
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.migrate %S/"with space"/test2.m.in -x objective-c
-// RUN: c-arcmt-test -arcmt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/"with space"/test1.m.in.result %S/"with space"/test2.m.in.result %S/"with space"/test.h.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test1.m.in -x objective-c
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test2.m.in -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/"with space"/test1.m.in.result %S/"with space"/test2.m.in.result %S/"with space"/test.h.result
// RUN: rm -rf %t.migrate
+// DISABLE: mingw32
diff --git a/test/ARCMT/migrate.m b/test/ARCMT/migrate.m
index cfd7115..6f41258 100644
--- a/test/ARCMT/migrate.m
+++ b/test/ARCMT/migrate.m
@@ -1,5 +1,6 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c
-// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result
// RUN: rm -rf %t
+// DISABLE: mingw32
diff --git a/test/ARCMT/no-canceling-bridge-to-bridge-cast.m b/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
new file mode 100644
index 0000000..81841fb
--- /dev/null
+++ b/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s
+// DISABLE: mingw32
+// rdar://10387088
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
+extern
+CFTypeRef CFRetain(CFTypeRef cf);
+
+@interface INTF
+{
+ void *cf_format;
+ id objc_format;
+}
+@end
+
+@interface NSString
++ (id)stringWithFormat:(NSString *)format;
+@end
+
+@implementation INTF
+- (void) Meth {
+ NSString *result;
+
+ result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+
+ result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+
+ result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+
+ result = (id) CFRetain((CFTypeRef)((objc_format)));
+
+ result = (id) CFRetain(cf_format); // OK
+}
+@end
+
diff --git a/test/ARCMT/nonobjc-to-objc-cast-2.m b/test/ARCMT/nonobjc-to-objc-cast-2.m
index 5dba61f..1ec0089 100644
--- a/test/ARCMT/nonobjc-to-objc-cast-2.m
+++ b/test/ARCMT/nonobjc-to-objc-cast-2.m
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s
+// DISABLE: mingw32
#include "Common.h"
@@ -8,21 +9,24 @@
@end
typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
void f(BOOL b) {
CFStringRef cfstr;
NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
- void *vp = str; // expected-error {{disallowed}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}}
+ void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}}
}
void f2(NSString *s) {
CFStringRef ref;
ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \
- // expected-error {{ bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \
+ // expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
+ // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}}
}
CFStringRef f3() {
diff --git a/test/ARCMT/nonobjc-to-objc-cast.m b/test/ARCMT/nonobjc-to-objc-cast.m
index 4fa1109..fcdcd89 100644
--- a/test/ARCMT/nonobjc-to-objc-cast.m
+++ b/test/ARCMT/nonobjc-to-objc-cast.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result
index bf6aad9..b50a948 100644
--- a/test/ARCMT/nonobjc-to-objc-cast.m.result
+++ b/test/ARCMT/nonobjc-to-objc-cast.m.result
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
// RUN: diff %t %s.result
+// DISABLE: mingw32
#include "Common.h"
diff --git a/test/ARCMT/objcmt-numeric-literals.m b/test/ARCMT/objcmt-numeric-literals.m
new file mode 100644
index 0000000..b86af4d
--- /dev/null
+++ b/test/ARCMT/objcmt-numeric-literals.m
@@ -0,0 +1,501 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
+- (id)initWithChar:(char)value;
+- (id)initWithUnsignedChar:(unsigned char)value;
+- (id)initWithShort:(short)value;
+- (id)initWithUnsignedShort:(unsigned short)value;
+- (id)initWithInt:(int)value;
+- (id)initWithUnsignedInt:(unsigned int)value;
+- (id)initWithLong:(long)value;
+- (id)initWithUnsignedLong:(unsigned long)value;
+- (id)initWithLongLong:(long long)value;
+- (id)initWithUnsignedLongLong:(unsigned long long)value;
+- (id)initWithFloat:(float)value;
+- (id)initWithDouble:(double)value;
+- (id)initWithBool:(BOOL)value;
+- (id)initWithInteger:(NSInteger)value;
+- (id)initWithUnsignedInteger:(NSUInteger)value;
+
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
+@end
+
+#define VAL_INT 2
+#define VAL_UINT 2U
+#define VAL_CHAR 'a'
+
+void foo() {
+ [NSNumber numberWithChar:'a'];
+ [NSNumber numberWithChar:L'a'];
+ [NSNumber numberWithChar:2];
+ [NSNumber numberWithChar:2U];
+ [NSNumber numberWithChar:2u];
+ [NSNumber numberWithChar:2L];
+ [NSNumber numberWithChar:2l];
+ [NSNumber numberWithChar:2LL];
+ [NSNumber numberWithChar:2ll];
+ [NSNumber numberWithChar:2ul];
+ [NSNumber numberWithChar:2lu];
+ [NSNumber numberWithChar:2ull];
+ [NSNumber numberWithChar:2llu];
+ [NSNumber numberWithChar:2.0];
+ [NSNumber numberWithChar:2.0f];
+ [NSNumber numberWithChar:2.0F];
+ [NSNumber numberWithChar:2.0l];
+ [NSNumber numberWithChar:2.0L];
+ [NSNumber numberWithChar:0x2f];
+ [NSNumber numberWithChar:04];
+ [NSNumber numberWithChar:0];
+ [NSNumber numberWithChar:0.0];
+ [NSNumber numberWithChar:YES];
+ [NSNumber numberWithChar:NO];
+ [NSNumber numberWithChar:true];
+ [NSNumber numberWithChar:false];
+ [NSNumber numberWithChar:VAL_INT];
+ [NSNumber numberWithChar:VAL_UINT];
+ [NSNumber numberWithChar:VAL_CHAR];
+
+ [NSNumber numberWithUnsignedChar:'a'];
+ [NSNumber numberWithUnsignedChar:L'a'];
+ [NSNumber numberWithUnsignedChar:2];
+ [NSNumber numberWithUnsignedChar:2U];
+ [NSNumber numberWithUnsignedChar:2u];
+ [NSNumber numberWithUnsignedChar:2L];
+ [NSNumber numberWithUnsignedChar:2l];
+ [NSNumber numberWithUnsignedChar:2LL];
+ [NSNumber numberWithUnsignedChar:2ll];
+ [NSNumber numberWithUnsignedChar:2ul];
+ [NSNumber numberWithUnsignedChar:2lu];
+ [NSNumber numberWithUnsignedChar:2ull];
+ [NSNumber numberWithUnsignedChar:2llu];
+ [NSNumber numberWithUnsignedChar:2.0];
+ [NSNumber numberWithUnsignedChar:2.0f];
+ [NSNumber numberWithUnsignedChar:2.0F];
+ [NSNumber numberWithUnsignedChar:2.0l];
+ [NSNumber numberWithUnsignedChar:2.0L];
+ [NSNumber numberWithUnsignedChar:0x2f];
+ [NSNumber numberWithUnsignedChar:04];
+ [NSNumber numberWithUnsignedChar:0];
+ [NSNumber numberWithUnsignedChar:0.0];
+ [NSNumber numberWithUnsignedChar:YES];
+ [NSNumber numberWithUnsignedChar:NO];
+ [NSNumber numberWithUnsignedChar:true];
+ [NSNumber numberWithUnsignedChar:false];
+ [NSNumber numberWithUnsignedChar:VAL_INT];
+ [NSNumber numberWithUnsignedChar:VAL_UINT];
+ [NSNumber numberWithUnsignedChar:VAL_CHAR];
+
+ [NSNumber numberWithShort:'a'];
+ [NSNumber numberWithShort:L'a'];
+ [NSNumber numberWithShort:2];
+ [NSNumber numberWithShort:2U];
+ [NSNumber numberWithShort:2u];
+ [NSNumber numberWithShort:2L];
+ [NSNumber numberWithShort:2l];
+ [NSNumber numberWithShort:2LL];
+ [NSNumber numberWithShort:2ll];
+ [NSNumber numberWithShort:2ul];
+ [NSNumber numberWithShort:2lu];
+ [NSNumber numberWithShort:2ull];
+ [NSNumber numberWithShort:2llu];
+ [NSNumber numberWithShort:2.0];
+ [NSNumber numberWithShort:2.0f];
+ [NSNumber numberWithShort:2.0F];
+ [NSNumber numberWithShort:2.0l];
+ [NSNumber numberWithShort:2.0L];
+ [NSNumber numberWithShort:0x2f];
+ [NSNumber numberWithShort:04];
+ [NSNumber numberWithShort:0];
+ [NSNumber numberWithShort:0.0];
+ [NSNumber numberWithShort:YES];
+ [NSNumber numberWithShort:NO];
+ [NSNumber numberWithShort:true];
+ [NSNumber numberWithShort:false];
+ [NSNumber numberWithShort:VAL_INT];
+ [NSNumber numberWithShort:VAL_UINT];
+
+ [NSNumber numberWithUnsignedShort:'a'];
+ [NSNumber numberWithUnsignedShort:L'a'];
+ [NSNumber numberWithUnsignedShort:2];
+ [NSNumber numberWithUnsignedShort:2U];
+ [NSNumber numberWithUnsignedShort:2u];
+ [NSNumber numberWithUnsignedShort:2L];
+ [NSNumber numberWithUnsignedShort:2l];
+ [NSNumber numberWithUnsignedShort:2LL];
+ [NSNumber numberWithUnsignedShort:2ll];
+ [NSNumber numberWithUnsignedShort:2ul];
+ [NSNumber numberWithUnsignedShort:2lu];
+ [NSNumber numberWithUnsignedShort:2ull];
+ [NSNumber numberWithUnsignedShort:2llu];
+ [NSNumber numberWithUnsignedShort:2.0];
+ [NSNumber numberWithUnsignedShort:2.0f];
+ [NSNumber numberWithUnsignedShort:2.0F];
+ [NSNumber numberWithUnsignedShort:2.0l];
+ [NSNumber numberWithUnsignedShort:2.0L];
+ [NSNumber numberWithUnsignedShort:0x2f];
+ [NSNumber numberWithUnsignedShort:04];
+ [NSNumber numberWithUnsignedShort:0];
+ [NSNumber numberWithUnsignedShort:0.0];
+ [NSNumber numberWithUnsignedShort:YES];
+ [NSNumber numberWithUnsignedShort:NO];
+ [NSNumber numberWithUnsignedShort:true];
+ [NSNumber numberWithUnsignedShort:false];
+ [NSNumber numberWithUnsignedShort:VAL_INT];
+ [NSNumber numberWithUnsignedShort:VAL_UINT];
+
+ [NSNumber numberWithInt:'a'];
+ [NSNumber numberWithInt:L'a'];
+ [NSNumber numberWithInt:2];
+ [NSNumber numberWithInt:2U];
+ [NSNumber numberWithInt:2u];
+ [NSNumber numberWithInt:2L];
+ [NSNumber numberWithInt:2l];
+ [NSNumber numberWithInt:2LL];
+ [NSNumber numberWithInt:2ll];
+ [NSNumber numberWithInt:2ul];
+ [NSNumber numberWithInt:2lu];
+ [NSNumber numberWithInt:2ull];
+ [NSNumber numberWithInt:2llu];
+ [NSNumber numberWithInt:2.0];
+ [NSNumber numberWithInt:2.0f];
+ [NSNumber numberWithInt:2.0F];
+ [NSNumber numberWithInt:2.0l];
+ [NSNumber numberWithInt:2.0L];
+ [NSNumber numberWithInt:0x2f];
+ [NSNumber numberWithInt:04];
+ [NSNumber numberWithInt:0];
+ [NSNumber numberWithInt:0.0];
+ [NSNumber numberWithInt:YES];
+ [NSNumber numberWithInt:NO];
+ [NSNumber numberWithInt:true];
+ [NSNumber numberWithInt:false];
+ [NSNumber numberWithInt:VAL_INT];
+ [NSNumber numberWithInt:VAL_UINT];
+
+ (void)[[NSNumber alloc] initWithInt:2];
+ (void)[[NSNumber alloc] initWithInt:2U];
+
+ [NSNumber numberWithInt:+2];
+ [NSNumber numberWithInt:-2];
+
+ [NSNumber numberWithUnsignedInt:'a'];
+ [NSNumber numberWithUnsignedInt:L'a'];
+ [NSNumber numberWithUnsignedInt:2];
+ [NSNumber numberWithUnsignedInt:2U];
+ [NSNumber numberWithUnsignedInt:2u];
+ [NSNumber numberWithUnsignedInt:2L];
+ [NSNumber numberWithUnsignedInt:2l];
+ [NSNumber numberWithUnsignedInt:2LL];
+ [NSNumber numberWithUnsignedInt:2ll];
+ [NSNumber numberWithUnsignedInt:2ul];
+ [NSNumber numberWithUnsignedInt:2lu];
+ [NSNumber numberWithUnsignedInt:2ull];
+ [NSNumber numberWithUnsignedInt:2llu];
+ [NSNumber numberWithUnsignedInt:2.0];
+ [NSNumber numberWithUnsignedInt:2.0f];
+ [NSNumber numberWithUnsignedInt:2.0F];
+ [NSNumber numberWithUnsignedInt:2.0l];
+ [NSNumber numberWithUnsignedInt:2.0L];
+ [NSNumber numberWithUnsignedInt:0x2f];
+ [NSNumber numberWithUnsignedInt:04];
+ [NSNumber numberWithUnsignedInt:0];
+ [NSNumber numberWithUnsignedInt:0.0];
+ [NSNumber numberWithUnsignedInt:YES];
+ [NSNumber numberWithUnsignedInt:NO];
+ [NSNumber numberWithUnsignedInt:true];
+ [NSNumber numberWithUnsignedInt:false];
+ [NSNumber numberWithUnsignedInt:VAL_INT];
+ [NSNumber numberWithUnsignedInt:VAL_UINT];
+
+ [NSNumber numberWithLong:'a'];
+ [NSNumber numberWithLong:L'a'];
+ [NSNumber numberWithLong:2];
+ [NSNumber numberWithLong:2U];
+ [NSNumber numberWithLong:2u];
+ [NSNumber numberWithLong:2L];
+ [NSNumber numberWithLong:2l];
+ [NSNumber numberWithLong:2LL];
+ [NSNumber numberWithLong:2ll];
+ [NSNumber numberWithLong:2ul];
+ [NSNumber numberWithLong:2lu];
+ [NSNumber numberWithLong:2ull];
+ [NSNumber numberWithLong:2llu];
+ [NSNumber numberWithLong:2.0];
+ [NSNumber numberWithLong:2.0f];
+ [NSNumber numberWithLong:2.0F];
+ [NSNumber numberWithLong:2.0l];
+ [NSNumber numberWithLong:2.0L];
+ [NSNumber numberWithLong:0x2f];
+ [NSNumber numberWithLong:04];
+ [NSNumber numberWithLong:0];
+ [NSNumber numberWithLong:0.0];
+ [NSNumber numberWithLong:YES];
+ [NSNumber numberWithLong:NO];
+ [NSNumber numberWithLong:true];
+ [NSNumber numberWithLong:false];
+ [NSNumber numberWithLong:VAL_INT];
+ [NSNumber numberWithLong:VAL_UINT];
+
+ [NSNumber numberWithUnsignedLong:'a'];
+ [NSNumber numberWithUnsignedLong:L'a'];
+ [NSNumber numberWithUnsignedLong:2];
+ [NSNumber numberWithUnsignedLong:2U];
+ [NSNumber numberWithUnsignedLong:2u];
+ [NSNumber numberWithUnsignedLong:2L];
+ [NSNumber numberWithUnsignedLong:2l];
+ [NSNumber numberWithUnsignedLong:2LL];
+ [NSNumber numberWithUnsignedLong:2ll];
+ [NSNumber numberWithUnsignedLong:2ul];
+ [NSNumber numberWithUnsignedLong:2lu];
+ [NSNumber numberWithUnsignedLong:2ull];
+ [NSNumber numberWithUnsignedLong:2llu];
+ [NSNumber numberWithUnsignedLong:2.0];
+ [NSNumber numberWithUnsignedLong:2.0f];
+ [NSNumber numberWithUnsignedLong:2.0F];
+ [NSNumber numberWithUnsignedLong:2.0l];
+ [NSNumber numberWithUnsignedLong:2.0L];
+ [NSNumber numberWithUnsignedLong:0x2f];
+ [NSNumber numberWithUnsignedLong:04];
+ [NSNumber numberWithUnsignedLong:0];
+ [NSNumber numberWithUnsignedLong:0.0];
+ [NSNumber numberWithUnsignedLong:YES];
+ [NSNumber numberWithUnsignedLong:NO];
+ [NSNumber numberWithUnsignedLong:true];
+ [NSNumber numberWithUnsignedLong:false];
+ [NSNumber numberWithUnsignedLong:VAL_INT];
+ [NSNumber numberWithUnsignedLong:VAL_UINT];
+
+ [NSNumber numberWithLongLong:'a'];
+ [NSNumber numberWithLongLong:L'a'];
+ [NSNumber numberWithLongLong:2];
+ [NSNumber numberWithLongLong:2U];
+ [NSNumber numberWithLongLong:2u];
+ [NSNumber numberWithLongLong:2L];
+ [NSNumber numberWithLongLong:2l];
+ [NSNumber numberWithLongLong:2LL];
+ [NSNumber numberWithLongLong:2ll];
+ [NSNumber numberWithLongLong:2ul];
+ [NSNumber numberWithLongLong:2lu];
+ [NSNumber numberWithLongLong:2ull];
+ [NSNumber numberWithLongLong:2llu];
+ [NSNumber numberWithLongLong:2.0];
+ [NSNumber numberWithLongLong:2.0f];
+ [NSNumber numberWithLongLong:2.0F];
+ [NSNumber numberWithLongLong:2.0l];
+ [NSNumber numberWithLongLong:2.0L];
+ [NSNumber numberWithLongLong:0x2f];
+ [NSNumber numberWithLongLong:04];
+ [NSNumber numberWithLongLong:0];
+ [NSNumber numberWithLongLong:0.0];
+ [NSNumber numberWithLongLong:YES];
+ [NSNumber numberWithLongLong:NO];
+ [NSNumber numberWithLongLong:true];
+ [NSNumber numberWithLongLong:false];
+ [NSNumber numberWithLongLong:VAL_INT];
+ [NSNumber numberWithLongLong:VAL_UINT];
+
+ [NSNumber numberWithUnsignedLongLong:'a'];
+ [NSNumber numberWithUnsignedLongLong:L'a'];
+ [NSNumber numberWithUnsignedLongLong:2];
+ [NSNumber numberWithUnsignedLongLong:2U];
+ [NSNumber numberWithUnsignedLongLong:2u];
+ [NSNumber numberWithUnsignedLongLong:2L];
+ [NSNumber numberWithUnsignedLongLong:2l];
+ [NSNumber numberWithUnsignedLongLong:2LL];
+ [NSNumber numberWithUnsignedLongLong:2ll];
+ [NSNumber numberWithUnsignedLongLong:2ul];
+ [NSNumber numberWithUnsignedLongLong:2lu];
+ [NSNumber numberWithUnsignedLongLong:2ull];
+ [NSNumber numberWithUnsignedLongLong:2llu];
+ [NSNumber numberWithUnsignedLongLong:2.0];
+ [NSNumber numberWithUnsignedLongLong:2.0f];
+ [NSNumber numberWithUnsignedLongLong:2.0F];
+ [NSNumber numberWithUnsignedLongLong:2.0l];
+ [NSNumber numberWithUnsignedLongLong:2.0L];
+ [NSNumber numberWithUnsignedLongLong:0x2f];
+ [NSNumber numberWithUnsignedLongLong:04];
+ [NSNumber numberWithUnsignedLongLong:0];
+ [NSNumber numberWithUnsignedLongLong:0.0];
+ [NSNumber numberWithUnsignedLongLong:YES];
+ [NSNumber numberWithUnsignedLongLong:NO];
+ [NSNumber numberWithUnsignedLongLong:true];
+ [NSNumber numberWithUnsignedLongLong:false];
+ [NSNumber numberWithUnsignedLongLong:VAL_INT];
+ [NSNumber numberWithUnsignedLongLong:VAL_UINT];
+
+ [NSNumber numberWithFloat:'a'];
+ [NSNumber numberWithFloat:L'a'];
+ [NSNumber numberWithFloat:2];
+ [NSNumber numberWithFloat:2U];
+ [NSNumber numberWithFloat:2u];
+ [NSNumber numberWithFloat:2L];
+ [NSNumber numberWithFloat:2l];
+ [NSNumber numberWithFloat:2LL];
+ [NSNumber numberWithFloat:2ll];
+ [NSNumber numberWithFloat:2ul];
+ [NSNumber numberWithFloat:2lu];
+ [NSNumber numberWithFloat:2ull];
+ [NSNumber numberWithFloat:2llu];
+ [NSNumber numberWithFloat:2.0];
+ [NSNumber numberWithFloat:2.0f];
+ [NSNumber numberWithFloat:2.0F];
+ [NSNumber numberWithFloat:2.0l];
+ [NSNumber numberWithFloat:2.0L];
+ [NSNumber numberWithFloat:0x2f];
+ [NSNumber numberWithFloat:04];
+ [NSNumber numberWithFloat:0];
+ [NSNumber numberWithFloat:0.0];
+ [NSNumber numberWithFloat:YES];
+ [NSNumber numberWithFloat:NO];
+ [NSNumber numberWithFloat:true];
+ [NSNumber numberWithFloat:false];
+ [NSNumber numberWithFloat:VAL_INT];
+ [NSNumber numberWithFloat:VAL_UINT];
+
+ [NSNumber numberWithDouble:'a'];
+ [NSNumber numberWithDouble:L'a'];
+ [NSNumber numberWithDouble:2];
+ [NSNumber numberWithDouble:2U];
+ [NSNumber numberWithDouble:2u];
+ [NSNumber numberWithDouble:2L];
+ [NSNumber numberWithDouble:2l];
+ [NSNumber numberWithDouble:2LL];
+ [NSNumber numberWithDouble:2ll];
+ [NSNumber numberWithDouble:2ul];
+ [NSNumber numberWithDouble:2lu];
+ [NSNumber numberWithDouble:2ull];
+ [NSNumber numberWithDouble:2llu];
+ [NSNumber numberWithDouble:2.0];
+ [NSNumber numberWithDouble:2.0f];
+ [NSNumber numberWithDouble:2.0F];
+ [NSNumber numberWithDouble:2.0l];
+ [NSNumber numberWithDouble:2.0L];
+ [NSNumber numberWithDouble:0x2f];
+ [NSNumber numberWithDouble:04];
+ [NSNumber numberWithDouble:0];
+ [NSNumber numberWithDouble:0.0];
+ [NSNumber numberWithDouble:YES];
+ [NSNumber numberWithDouble:NO];
+ [NSNumber numberWithDouble:true];
+ [NSNumber numberWithDouble:false];
+ [NSNumber numberWithDouble:VAL_INT];
+ [NSNumber numberWithDouble:VAL_UINT];
+
+ [NSNumber numberWithBool:'a'];
+ [NSNumber numberWithBool:L'a'];
+ [NSNumber numberWithBool:2];
+ [NSNumber numberWithBool:2U];
+ [NSNumber numberWithBool:2u];
+ [NSNumber numberWithBool:2L];
+ [NSNumber numberWithBool:2l];
+ [NSNumber numberWithBool:2LL];
+ [NSNumber numberWithBool:2ll];
+ [NSNumber numberWithBool:2ul];
+ [NSNumber numberWithBool:2lu];
+ [NSNumber numberWithBool:2ull];
+ [NSNumber numberWithBool:2llu];
+ [NSNumber numberWithBool:2.0];
+ [NSNumber numberWithBool:2.0f];
+ [NSNumber numberWithBool:2.0F];
+ [NSNumber numberWithBool:2.0l];
+ [NSNumber numberWithBool:2.0L];
+ [NSNumber numberWithBool:0x2f];
+ [NSNumber numberWithBool:04];
+ [NSNumber numberWithBool:0];
+ [NSNumber numberWithBool:0.0];
+ [NSNumber numberWithBool:YES];
+ [NSNumber numberWithBool:NO];
+ [NSNumber numberWithBool:true];
+ [NSNumber numberWithBool:false];
+ [NSNumber numberWithBool:VAL_INT];
+ [NSNumber numberWithBool:VAL_UINT];
+
+ [NSNumber numberWithInteger:'a'];
+ [NSNumber numberWithInteger:L'a'];
+ [NSNumber numberWithInteger:2];
+ [NSNumber numberWithInteger:2U];
+ [NSNumber numberWithInteger:2u];
+ [NSNumber numberWithInteger:2L];
+ [NSNumber numberWithInteger:2l];
+ [NSNumber numberWithInteger:2LL];
+ [NSNumber numberWithInteger:2ll];
+ [NSNumber numberWithInteger:2ul];
+ [NSNumber numberWithInteger:2lu];
+ [NSNumber numberWithInteger:2ull];
+ [NSNumber numberWithInteger:2llu];
+ [NSNumber numberWithInteger:2.0];
+ [NSNumber numberWithInteger:2.0f];
+ [NSNumber numberWithInteger:2.0F];
+ [NSNumber numberWithInteger:2.0l];
+ [NSNumber numberWithInteger:2.0L];
+ [NSNumber numberWithInteger:0x2f];
+ [NSNumber numberWithInteger:04];
+ [NSNumber numberWithInteger:0];
+ [NSNumber numberWithInteger:0.0];
+ [NSNumber numberWithInteger:YES];
+ [NSNumber numberWithInteger:NO];
+ [NSNumber numberWithInteger:true];
+ [NSNumber numberWithInteger:false];
+ [NSNumber numberWithInteger:VAL_INT];
+ [NSNumber numberWithInteger:VAL_UINT];
+
+ [NSNumber numberWithUnsignedInteger:'a'];
+ [NSNumber numberWithUnsignedInteger:L'a'];
+ [NSNumber numberWithUnsignedInteger:2];
+ [NSNumber numberWithUnsignedInteger:2U];
+ [NSNumber numberWithUnsignedInteger:2u];
+ [NSNumber numberWithUnsignedInteger:2L];
+ [NSNumber numberWithUnsignedInteger:2l];
+ [NSNumber numberWithUnsignedInteger:2LL];
+ [NSNumber numberWithUnsignedInteger:2ll];
+ [NSNumber numberWithUnsignedInteger:2ul];
+ [NSNumber numberWithUnsignedInteger:2lu];
+ [NSNumber numberWithUnsignedInteger:2ull];
+ [NSNumber numberWithUnsignedInteger:2llu];
+ [NSNumber numberWithUnsignedInteger:2.0];
+ [NSNumber numberWithUnsignedInteger:2.0f];
+ [NSNumber numberWithUnsignedInteger:2.0F];
+ [NSNumber numberWithUnsignedInteger:2.0l];
+ [NSNumber numberWithUnsignedInteger:2.0L];
+ [NSNumber numberWithUnsignedInteger:0x2f];
+ [NSNumber numberWithUnsignedInteger:04];
+ [NSNumber numberWithUnsignedInteger:0];
+ [NSNumber numberWithUnsignedInteger:0.0];
+ [NSNumber numberWithUnsignedInteger:YES];
+ [NSNumber numberWithUnsignedInteger:NO];
+ [NSNumber numberWithUnsignedInteger:true];
+ [NSNumber numberWithUnsignedInteger:false];
+ [NSNumber numberWithUnsignedInteger:VAL_INT];
+ [NSNumber numberWithUnsignedInteger:VAL_UINT];
+}
diff --git a/test/ARCMT/objcmt-numeric-literals.m.result b/test/ARCMT/objcmt-numeric-literals.m.result
new file mode 100644
index 0000000..1c4187a
--- /dev/null
+++ b/test/ARCMT/objcmt-numeric-literals.m.result
@@ -0,0 +1,501 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+#define YES __objc_yes
+#define NO __objc_no
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
+- (id)initWithChar:(char)value;
+- (id)initWithUnsignedChar:(unsigned char)value;
+- (id)initWithShort:(short)value;
+- (id)initWithUnsignedShort:(unsigned short)value;
+- (id)initWithInt:(int)value;
+- (id)initWithUnsignedInt:(unsigned int)value;
+- (id)initWithLong:(long)value;
+- (id)initWithUnsignedLong:(unsigned long)value;
+- (id)initWithLongLong:(long long)value;
+- (id)initWithUnsignedLongLong:(unsigned long long)value;
+- (id)initWithFloat:(float)value;
+- (id)initWithDouble:(double)value;
+- (id)initWithBool:(BOOL)value;
+- (id)initWithInteger:(NSInteger)value;
+- (id)initWithUnsignedInteger:(NSUInteger)value;
+
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
+@end
+
+#define VAL_INT 2
+#define VAL_UINT 2U
+#define VAL_CHAR 'a'
+
+void foo() {
+ @'a';
+ [NSNumber numberWithChar:L'a'];
+ [NSNumber numberWithChar:2];
+ [NSNumber numberWithChar:2U];
+ [NSNumber numberWithChar:2u];
+ [NSNumber numberWithChar:2L];
+ [NSNumber numberWithChar:2l];
+ [NSNumber numberWithChar:2LL];
+ [NSNumber numberWithChar:2ll];
+ [NSNumber numberWithChar:2ul];
+ [NSNumber numberWithChar:2lu];
+ [NSNumber numberWithChar:2ull];
+ [NSNumber numberWithChar:2llu];
+ [NSNumber numberWithChar:2.0];
+ [NSNumber numberWithChar:2.0f];
+ [NSNumber numberWithChar:2.0F];
+ [NSNumber numberWithChar:2.0l];
+ [NSNumber numberWithChar:2.0L];
+ [NSNumber numberWithChar:0x2f];
+ [NSNumber numberWithChar:04];
+ [NSNumber numberWithChar:0];
+ [NSNumber numberWithChar:0.0];
+ [NSNumber numberWithChar:YES];
+ [NSNumber numberWithChar:NO];
+ [NSNumber numberWithChar:true];
+ [NSNumber numberWithChar:false];
+ [NSNumber numberWithChar:VAL_INT];
+ [NSNumber numberWithChar:VAL_UINT];
+ @VAL_CHAR;
+
+ [NSNumber numberWithUnsignedChar:'a'];
+ [NSNumber numberWithUnsignedChar:L'a'];
+ [NSNumber numberWithUnsignedChar:2];
+ [NSNumber numberWithUnsignedChar:2U];
+ [NSNumber numberWithUnsignedChar:2u];
+ [NSNumber numberWithUnsignedChar:2L];
+ [NSNumber numberWithUnsignedChar:2l];
+ [NSNumber numberWithUnsignedChar:2LL];
+ [NSNumber numberWithUnsignedChar:2ll];
+ [NSNumber numberWithUnsignedChar:2ul];
+ [NSNumber numberWithUnsignedChar:2lu];
+ [NSNumber numberWithUnsignedChar:2ull];
+ [NSNumber numberWithUnsignedChar:2llu];
+ [NSNumber numberWithUnsignedChar:2.0];
+ [NSNumber numberWithUnsignedChar:2.0f];
+ [NSNumber numberWithUnsignedChar:2.0F];
+ [NSNumber numberWithUnsignedChar:2.0l];
+ [NSNumber numberWithUnsignedChar:2.0L];
+ [NSNumber numberWithUnsignedChar:0x2f];
+ [NSNumber numberWithUnsignedChar:04];
+ [NSNumber numberWithUnsignedChar:0];
+ [NSNumber numberWithUnsignedChar:0.0];
+ [NSNumber numberWithUnsignedChar:YES];
+ [NSNumber numberWithUnsignedChar:NO];
+ [NSNumber numberWithUnsignedChar:true];
+ [NSNumber numberWithUnsignedChar:false];
+ [NSNumber numberWithUnsignedChar:VAL_INT];
+ [NSNumber numberWithUnsignedChar:VAL_UINT];
+ [NSNumber numberWithUnsignedChar:VAL_CHAR];
+
+ [NSNumber numberWithShort:'a'];
+ [NSNumber numberWithShort:L'a'];
+ [NSNumber numberWithShort:2];
+ [NSNumber numberWithShort:2U];
+ [NSNumber numberWithShort:2u];
+ [NSNumber numberWithShort:2L];
+ [NSNumber numberWithShort:2l];
+ [NSNumber numberWithShort:2LL];
+ [NSNumber numberWithShort:2ll];
+ [NSNumber numberWithShort:2ul];
+ [NSNumber numberWithShort:2lu];
+ [NSNumber numberWithShort:2ull];
+ [NSNumber numberWithShort:2llu];
+ [NSNumber numberWithShort:2.0];
+ [NSNumber numberWithShort:2.0f];
+ [NSNumber numberWithShort:2.0F];
+ [NSNumber numberWithShort:2.0l];
+ [NSNumber numberWithShort:2.0L];
+ [NSNumber numberWithShort:0x2f];
+ [NSNumber numberWithShort:04];
+ [NSNumber numberWithShort:0];
+ [NSNumber numberWithShort:0.0];
+ [NSNumber numberWithShort:YES];
+ [NSNumber numberWithShort:NO];
+ [NSNumber numberWithShort:true];
+ [NSNumber numberWithShort:false];
+ [NSNumber numberWithShort:VAL_INT];
+ [NSNumber numberWithShort:VAL_UINT];
+
+ [NSNumber numberWithUnsignedShort:'a'];
+ [NSNumber numberWithUnsignedShort:L'a'];
+ [NSNumber numberWithUnsignedShort:2];
+ [NSNumber numberWithUnsignedShort:2U];
+ [NSNumber numberWithUnsignedShort:2u];
+ [NSNumber numberWithUnsignedShort:2L];
+ [NSNumber numberWithUnsignedShort:2l];
+ [NSNumber numberWithUnsignedShort:2LL];
+ [NSNumber numberWithUnsignedShort:2ll];
+ [NSNumber numberWithUnsignedShort:2ul];
+ [NSNumber numberWithUnsignedShort:2lu];
+ [NSNumber numberWithUnsignedShort:2ull];
+ [NSNumber numberWithUnsignedShort:2llu];
+ [NSNumber numberWithUnsignedShort:2.0];
+ [NSNumber numberWithUnsignedShort:2.0f];
+ [NSNumber numberWithUnsignedShort:2.0F];
+ [NSNumber numberWithUnsignedShort:2.0l];
+ [NSNumber numberWithUnsignedShort:2.0L];
+ [NSNumber numberWithUnsignedShort:0x2f];
+ [NSNumber numberWithUnsignedShort:04];
+ [NSNumber numberWithUnsignedShort:0];
+ [NSNumber numberWithUnsignedShort:0.0];
+ [NSNumber numberWithUnsignedShort:YES];
+ [NSNumber numberWithUnsignedShort:NO];
+ [NSNumber numberWithUnsignedShort:true];
+ [NSNumber numberWithUnsignedShort:false];
+ [NSNumber numberWithUnsignedShort:VAL_INT];
+ [NSNumber numberWithUnsignedShort:VAL_UINT];
+
+ [NSNumber numberWithInt:'a'];
+ [NSNumber numberWithInt:L'a'];
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ [NSNumber numberWithInt:2.0];
+ [NSNumber numberWithInt:2.0f];
+ [NSNumber numberWithInt:2.0F];
+ [NSNumber numberWithInt:2.0l];
+ [NSNumber numberWithInt:2.0L];
+ @0x2f;
+ @04;
+ @0;
+ [NSNumber numberWithInt:0.0];
+ [NSNumber numberWithInt:YES];
+ [NSNumber numberWithInt:NO];
+ [NSNumber numberWithInt:true];
+ [NSNumber numberWithInt:false];
+ @VAL_INT;
+ [NSNumber numberWithInt:VAL_UINT];
+
+ (void)[[NSNumber alloc] initWithInt:2];
+ (void)[[NSNumber alloc] initWithInt:2U];
+
+ @+2;
+ @-2;
+
+ [NSNumber numberWithUnsignedInt:'a'];
+ [NSNumber numberWithUnsignedInt:L'a'];
+ @2U;
+ @2U;
+ @2u;
+ @2U;
+ @2u;
+ @2U;
+ @2u;
+ @2u;
+ @2u;
+ @2u;
+ @2u;
+ [NSNumber numberWithUnsignedInt:2.0];
+ [NSNumber numberWithUnsignedInt:2.0f];
+ [NSNumber numberWithUnsignedInt:2.0F];
+ [NSNumber numberWithUnsignedInt:2.0l];
+ [NSNumber numberWithUnsignedInt:2.0L];
+ @0x2fU;
+ @04U;
+ @0U;
+ [NSNumber numberWithUnsignedInt:0.0];
+ [NSNumber numberWithUnsignedInt:YES];
+ [NSNumber numberWithUnsignedInt:NO];
+ [NSNumber numberWithUnsignedInt:true];
+ [NSNumber numberWithUnsignedInt:false];
+ [NSNumber numberWithUnsignedInt:VAL_INT];
+ @VAL_UINT;
+
+ [NSNumber numberWithLong:'a'];
+ [NSNumber numberWithLong:L'a'];
+ @2L;
+ @2L;
+ @2l;
+ @2L;
+ @2l;
+ @2L;
+ @2l;
+ @2l;
+ @2l;
+ @2l;
+ @2l;
+ [NSNumber numberWithLong:2.0];
+ [NSNumber numberWithLong:2.0f];
+ [NSNumber numberWithLong:2.0F];
+ [NSNumber numberWithLong:2.0l];
+ [NSNumber numberWithLong:2.0L];
+ @0x2fL;
+ @04L;
+ @0L;
+ [NSNumber numberWithLong:0.0];
+ [NSNumber numberWithLong:YES];
+ [NSNumber numberWithLong:NO];
+ [NSNumber numberWithLong:true];
+ [NSNumber numberWithLong:false];
+ [NSNumber numberWithLong:VAL_INT];
+ [NSNumber numberWithLong:VAL_UINT];
+
+ [NSNumber numberWithUnsignedLong:'a'];
+ [NSNumber numberWithUnsignedLong:L'a'];
+ @2UL;
+ @2UL;
+ @2ul;
+ @2UL;
+ @2ul;
+ @2UL;
+ @2ul;
+ @2ul;
+ @2lu;
+ @2ul;
+ @2ul;
+ [NSNumber numberWithUnsignedLong:2.0];
+ [NSNumber numberWithUnsignedLong:2.0f];
+ [NSNumber numberWithUnsignedLong:2.0F];
+ [NSNumber numberWithUnsignedLong:2.0l];
+ [NSNumber numberWithUnsignedLong:2.0L];
+ @0x2fUL;
+ @04UL;
+ @0UL;
+ [NSNumber numberWithUnsignedLong:0.0];
+ [NSNumber numberWithUnsignedLong:YES];
+ [NSNumber numberWithUnsignedLong:NO];
+ [NSNumber numberWithUnsignedLong:true];
+ [NSNumber numberWithUnsignedLong:false];
+ [NSNumber numberWithUnsignedLong:VAL_INT];
+ [NSNumber numberWithUnsignedLong:VAL_UINT];
+
+ [NSNumber numberWithLongLong:'a'];
+ [NSNumber numberWithLongLong:L'a'];
+ @2LL;
+ @2LL;
+ @2ll;
+ @2LL;
+ @2ll;
+ @2LL;
+ @2ll;
+ @2ll;
+ @2ll;
+ @2ll;
+ @2ll;
+ [NSNumber numberWithLongLong:2.0];
+ [NSNumber numberWithLongLong:2.0f];
+ [NSNumber numberWithLongLong:2.0F];
+ [NSNumber numberWithLongLong:2.0l];
+ [NSNumber numberWithLongLong:2.0L];
+ @0x2fLL;
+ @04LL;
+ @0LL;
+ [NSNumber numberWithLongLong:0.0];
+ [NSNumber numberWithLongLong:YES];
+ [NSNumber numberWithLongLong:NO];
+ [NSNumber numberWithLongLong:true];
+ [NSNumber numberWithLongLong:false];
+ [NSNumber numberWithLongLong:VAL_INT];
+ [NSNumber numberWithLongLong:VAL_UINT];
+
+ [NSNumber numberWithUnsignedLongLong:'a'];
+ [NSNumber numberWithUnsignedLongLong:L'a'];
+ @2ULL;
+ @2ULL;
+ @2ull;
+ @2ULL;
+ @2ull;
+ @2ULL;
+ @2ull;
+ @2ull;
+ @2ull;
+ @2ull;
+ @2llu;
+ [NSNumber numberWithUnsignedLongLong:2.0];
+ [NSNumber numberWithUnsignedLongLong:2.0f];
+ [NSNumber numberWithUnsignedLongLong:2.0F];
+ [NSNumber numberWithUnsignedLongLong:2.0l];
+ [NSNumber numberWithUnsignedLongLong:2.0L];
+ @0x2fULL;
+ @04ULL;
+ @0ULL;
+ [NSNumber numberWithUnsignedLongLong:0.0];
+ [NSNumber numberWithUnsignedLongLong:YES];
+ [NSNumber numberWithUnsignedLongLong:NO];
+ [NSNumber numberWithUnsignedLongLong:true];
+ [NSNumber numberWithUnsignedLongLong:false];
+ [NSNumber numberWithUnsignedLongLong:VAL_INT];
+ [NSNumber numberWithUnsignedLongLong:VAL_UINT];
+
+ [NSNumber numberWithFloat:'a'];
+ [NSNumber numberWithFloat:L'a'];
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0f;
+ @2.0F;
+ @2.0f;
+ @2.0f;
+ [NSNumber numberWithFloat:0x2f];
+ [NSNumber numberWithFloat:04];
+ @0.0f;
+ @0.0f;
+ [NSNumber numberWithFloat:YES];
+ [NSNumber numberWithFloat:NO];
+ [NSNumber numberWithFloat:true];
+ [NSNumber numberWithFloat:false];
+ [NSNumber numberWithFloat:VAL_INT];
+ [NSNumber numberWithFloat:VAL_UINT];
+
+ [NSNumber numberWithDouble:'a'];
+ [NSNumber numberWithDouble:L'a'];
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ @2.0;
+ [NSNumber numberWithDouble:0x2f];
+ [NSNumber numberWithDouble:04];
+ @0.0;
+ @0.0;
+ [NSNumber numberWithDouble:YES];
+ [NSNumber numberWithDouble:NO];
+ [NSNumber numberWithDouble:true];
+ [NSNumber numberWithDouble:false];
+ [NSNumber numberWithDouble:VAL_INT];
+ [NSNumber numberWithDouble:VAL_UINT];
+
+ [NSNumber numberWithBool:'a'];
+ [NSNumber numberWithBool:L'a'];
+ [NSNumber numberWithBool:2];
+ [NSNumber numberWithBool:2U];
+ [NSNumber numberWithBool:2u];
+ [NSNumber numberWithBool:2L];
+ [NSNumber numberWithBool:2l];
+ [NSNumber numberWithBool:2LL];
+ [NSNumber numberWithBool:2ll];
+ [NSNumber numberWithBool:2ul];
+ [NSNumber numberWithBool:2lu];
+ [NSNumber numberWithBool:2ull];
+ [NSNumber numberWithBool:2llu];
+ [NSNumber numberWithBool:2.0];
+ [NSNumber numberWithBool:2.0f];
+ [NSNumber numberWithBool:2.0F];
+ [NSNumber numberWithBool:2.0l];
+ [NSNumber numberWithBool:2.0L];
+ [NSNumber numberWithBool:0x2f];
+ [NSNumber numberWithBool:04];
+ [NSNumber numberWithBool:0];
+ [NSNumber numberWithBool:0.0];
+ @YES;
+ @NO;
+ @true;
+ @false;
+ [NSNumber numberWithBool:VAL_INT];
+ [NSNumber numberWithBool:VAL_UINT];
+
+ [NSNumber numberWithInteger:'a'];
+ [NSNumber numberWithInteger:L'a'];
+ @2;
+ @2;
+ @2;
+ @2L;
+ @2l;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ @2;
+ [NSNumber numberWithInteger:2.0];
+ [NSNumber numberWithInteger:2.0f];
+ [NSNumber numberWithInteger:2.0F];
+ [NSNumber numberWithInteger:2.0l];
+ [NSNumber numberWithInteger:2.0L];
+ @0x2f;
+ @04;
+ @0;
+ [NSNumber numberWithInteger:0.0];
+ [NSNumber numberWithInteger:YES];
+ [NSNumber numberWithInteger:NO];
+ [NSNumber numberWithInteger:true];
+ [NSNumber numberWithInteger:false];
+ [NSNumber numberWithInteger:VAL_INT];
+ [NSNumber numberWithInteger:VAL_UINT];
+
+ [NSNumber numberWithUnsignedInteger:'a'];
+ [NSNumber numberWithUnsignedInteger:L'a'];
+ @2U;
+ @2U;
+ @2u;
+ @2U;
+ @2u;
+ @2U;
+ @2u;
+ @2ul;
+ @2lu;
+ @2u;
+ @2u;
+ [NSNumber numberWithUnsignedInteger:2.0];
+ [NSNumber numberWithUnsignedInteger:2.0f];
+ [NSNumber numberWithUnsignedInteger:2.0F];
+ [NSNumber numberWithUnsignedInteger:2.0l];
+ [NSNumber numberWithUnsignedInteger:2.0L];
+ @0x2fU;
+ @04U;
+ @0U;
+ [NSNumber numberWithUnsignedInteger:0.0];
+ [NSNumber numberWithUnsignedInteger:YES];
+ [NSNumber numberWithUnsignedInteger:NO];
+ [NSNumber numberWithUnsignedInteger:true];
+ [NSNumber numberWithUnsignedInteger:false];
+ [NSNumber numberWithUnsignedInteger:VAL_INT];
+ [NSNumber numberWithUnsignedInteger:VAL_UINT];
+}
diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m
new file mode 100644
index 0000000..3d26efe
--- /dev/null
+++ b/test/ARCMT/objcmt-subscripting-literals.m
@@ -0,0 +1,137 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)array;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
++ (id)arrayWithObjects:(id)firstObj, ...;
++ (id)arrayWithArray:(NSArray *)array;
+
+- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
+- (id)initWithObjects:(id)firstObj, ...;
+- (id)initWithArray:(NSArray *)array;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@interface NSDictionary (NSDictionaryCreation)
++ (id)dictionary;
++ (id)dictionaryWithObject:(id)object forKey:(id)key;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ (id)dictionaryWithDictionary:(NSDictionary *)dict;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+- (id)initWithObjectsAndKeys:(id)firstObject, ...;
+- (id)initWithDictionary:(NSDictionary *)otherDictionary;
+- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+@interface I
+@end
+@implementation I
+-(void) foo {
+ NSString *str;
+ NSArray *arr;
+ NSDictionary *dict;
+
+ arr = [NSArray array];
+ arr = [NSArray arrayWithObject:str];
+ arr = [NSArray arrayWithObjects:str, str, nil];
+ dict = [NSDictionary dictionary];
+ dict = [NSDictionary dictionaryWithObject:arr forKey:str];
+ dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil];
+ dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil];
+ dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ @"value1", @"key1",
+#ifdef BLAH
+ @"value2", @"key2",
+#else
+ @"value3", @"key3",
+#endif
+ nil ];
+
+ id o = [arr objectAtIndex:2];
+ o = [dict objectForKey:@"key"];
+ o = TWO([dict objectForKey:@"key"]);
+ o = [NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"key"];
+ NSMutableArray *marr = 0;
+ NSMutableDictionary *mdict = 0;
+ [marr replaceObjectAtIndex:2 withObject:@"val"];
+ [mdict setObject:@"value" forKey:@"key"];
+ [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]];
+ [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"];
+ [mdict setObject:[dict objectForKey:@"key2"] forKey:
+#if 1
+ @"key1"
+#else
+ @"key2"
+#endif
+ ];
+ [mdict setObject:[dict objectForKey:
+#if 2
+ @"key3"
+#else
+ @"key4"
+#endif
+ ] forKey:@"key"];
+ [mdict setObject:@"value" forKey:[dict objectForKey:
+#if 3
+ @"key5"
+#else
+ @"key6"
+#endif
+ ] ];
+ [mdict setObject:@"val" forKey:[dict objectForKey:@"key2"]];
+ [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]];
+ __strong NSArray **parr = 0;
+ o = [*parr objectAtIndex:2];
+}
+@end
diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result
new file mode 100644
index 0000000..8ac6dcc
--- /dev/null
+++ b/test/ARCMT/objcmt-subscripting-literals.m.result
@@ -0,0 +1,137 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)array;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
++ (id)arrayWithObjects:(id)firstObj, ...;
++ (id)arrayWithArray:(NSArray *)array;
+
+- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
+- (id)initWithObjects:(id)firstObj, ...;
+- (id)initWithArray:(NSArray *)array;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@interface NSDictionary (NSDictionaryCreation)
++ (id)dictionary;
++ (id)dictionaryWithObject:(id)object forKey:(id)key;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ (id)dictionaryWithDictionary:(NSDictionary *)dict;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+- (id)initWithObjectsAndKeys:(id)firstObject, ...;
+- (id)initWithDictionary:(NSDictionary *)otherDictionary;
+- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+@interface I
+@end
+@implementation I
+-(void) foo {
+ NSString *str;
+ NSArray *arr;
+ NSDictionary *dict;
+
+ arr = @[];
+ arr = @[str];
+ arr = @[str, str];
+ dict = @{};
+ dict = @{str: arr};
+ dict = @{@"key1": @"value1", @"key2": @"value2"};
+ dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil];
+ dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ @"value1", @"key1",
+#ifdef BLAH
+ @"value2", @"key2",
+#else
+ @"value3", @"key3",
+#endif
+ nil ];
+
+ id o = arr[2];
+ o = dict[@"key"];
+ o = TWO(dict[@"key"]);
+ o = @{@"key": @{}};
+ NSMutableArray *marr = 0;
+ NSMutableDictionary *mdict = 0;
+ marr[2] = @"val";
+ mdict[@"key"] = @"value";
+ marr[2] = arr[4];
+ mdict[@"key"] = dict[@"key2"];
+ [mdict setObject:dict[@"key2"] forKey:
+#if 1
+ @"key1"
+#else
+ @"key2"
+#endif
+ ];
+ mdict[@"key"] = [dict objectForKey:
+#if 2
+ @"key3"
+#else
+ @"key4"
+#endif
+ ];
+ mdict[[dict objectForKey:
+#if 3
+ @"key5"
+#else
+ @"key6"
+#endif
+ ]] = @"value";
+ mdict[dict[@"key2"]] = @"val";
+ mdict[dict[@[@"arrkey"]]] = dict[@"key1"];
+ __strong NSArray **parr = 0;
+ o = (*parr)[2];
+}
+@end
diff --git a/test/ARCMT/rewrite-block-var.m b/test/ARCMT/rewrite-block-var.m
index e6a8fb7..538f16c 100644
--- a/test/ARCMT/rewrite-block-var.m
+++ b/test/ARCMT/rewrite-block-var.m
@@ -23,3 +23,23 @@ void test2(Foo *p) {
x = [p something];
});
}
+
+void test3(Foo *p) {
+ __block Foo *x; // __block used as output variable.
+ bar(^{
+ [x something];
+ });
+ bar(^{
+ x = 0;
+ });
+}
+
+void test4(Foo *p) {
+ __block Foo *x = p; // __block used just to break cycle.
+ bar(^{
+ [x something];
+ });
+ bar(^{
+ [x something];
+ });
+}
diff --git a/test/ARCMT/rewrite-block-var.m.result b/test/ARCMT/rewrite-block-var.m.result
index 27c81bd..a9d0b0f 100644
--- a/test/ARCMT/rewrite-block-var.m.result
+++ b/test/ARCMT/rewrite-block-var.m.result
@@ -23,3 +23,23 @@ void test2(Foo *p) {
x = [p something];
});
}
+
+void test3(Foo *p) {
+ __block Foo *x; // __block used as output variable.
+ bar(^{
+ [x something];
+ });
+ bar(^{
+ x = 0;
+ });
+}
+
+void test4(Foo *p) {
+ __weak Foo *x = p; // __block used just to break cycle.
+ bar(^{
+ [x something];
+ });
+ bar(^{
+ [x something];
+ });
+}
diff --git a/test/ARCMT/with-arc-mode-migrate.m b/test/ARCMT/with-arc-mode-migrate.m
index 32bcad1..4688594 100644
--- a/test/ARCMT/with-arc-mode-migrate.m
+++ b/test/ARCMT/with-arc-mode-migrate.m
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fsyntax-only -fobjc-arc %s
-// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
// RUN: rm -rf %t
@protocol NSObject
diff --git a/test/ARCMT/with-arc-mode-migrate.m.result b/test/ARCMT/with-arc-mode-migrate.m.result
index f060793..dd34b99 100644
--- a/test/ARCMT/with-arc-mode-migrate.m.result
+++ b/test/ARCMT/with-arc-mode-migrate.m.result
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fsyntax-only -fobjc-arc %s
-// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
+// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s
+// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result
// RUN: rm -rf %t
@protocol NSObject
diff --git a/test/ASTMerge/Inputs/interface2.m b/test/ASTMerge/Inputs/interface2.m
index 3fb43f5..2133bd1 100644
--- a/test/ASTMerge/Inputs/interface2.m
+++ b/test/ASTMerge/Inputs/interface2.m
@@ -69,7 +69,7 @@
@end
// Forward-declared interface
-@class I12, I10;
+@class I10; @interface I12 @end
@interface I11
@end
diff --git a/test/Analysis/CFContainers.mm b/test/Analysis/CFContainers.mm
new file mode 100644
index 0000000..7d6c175
--- /dev/null
+++ b/test/Analysis/CFContainers.mm
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+typedef const struct __CFString * CFStringRef;
+typedef unsigned char Boolean;
+typedef signed long CFIndex;
+extern
+const CFAllocatorRef kCFAllocatorDefault;
+typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef struct {
+ CFIndex version;
+ CFArrayRetainCallBack retain;
+ CFArrayReleaseCallBack release;
+ CFArrayCopyDescriptionCallBack copyDescription;
+ CFArrayEqualCallBack equal;
+} CFArrayCallBacks;
+typedef const struct __CFArray * CFArrayRef;
+CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
+typedef const struct __CFString * CFStringRef;
+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 CFIndex CFNumberType;
+typedef const struct __CFNumber * CFNumberRef;
+typedef CFIndex CFComparisonResult;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value);
+typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
+typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2);
+typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value);
+typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value);
+typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value);
+typedef struct {
+ CFIndex version;
+ CFSetRetainCallBack retain;
+ CFSetReleaseCallBack release;
+ CFSetCopyDescriptionCallBack copyDescription;
+ CFSetEqualCallBack equal;
+} CFSetCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryKeyCallBacks;
+typedef struct {
+ CFIndex version;
+ CFDictionaryRetainCallBack retain;
+ CFDictionaryReleaseCallBack release;
+ CFDictionaryCopyDescriptionCallBack copyDescription;
+ CFDictionaryEqualCallBack equal;
+} CFDictionaryValueCallBacks;
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+extern
+const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFSet * CFSetRef;
+extern
+const CFSetCallBacks kCFTypeSetCallBacks;
+extern
+const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
+extern
+const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
+extern
+CFIndex CFArrayGetCount(CFArrayRef theArray);
+CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const
+CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+extern
+CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks);
+#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
+#define NULL __null
+
+// Done with the headers.
+// Test experimental.osx.cocoa.ContainerAPI checker.
+void testContainers(int **xNoWarn, CFIndex count) {
+ int x[] = { 1, 2, 3 };
+ CFArrayRef foo = CFArrayCreate(kCFAllocatorDefault, (const void **) x, sizeof(x) / sizeof(x[0]), 0);// expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ CFArrayRef fooNoWarn = CFArrayCreate(kCFAllocatorDefault, (const void **) xNoWarn, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0); // no warning
+ CFArrayRef fooNoWarn2 = CFArrayCreate(kCFAllocatorDefault, 0, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in 0
+ CFArrayRef fooNoWarn3 = CFArrayCreate(kCFAllocatorDefault, NULL, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in NULL
+
+ CFSetRef set = CFSetCreate(NULL, (const void **)x, 3, &kCFTypeSetCallBacks); // expected-warning {{The first argument to 'CFSetCreate' must be a C array of pointer-sized values}}
+ CFArrayRef* pairs = new CFArrayRef[count];
+ CFSetRef fSet = CFSetCreate(kCFAllocatorDefault, (const void**) pairs, count - 1, &kCFTypeSetCallBacks);// no warning
+}
+
+void CreateDict(int *elems) {
+ const short days28 = 28;
+ const short days30 = 30;
+ const short days31 = 31;
+ CFIndex numValues = 6;
+ CFStringRef keys[6];
+ CFNumberRef values[6];
+ keys[0] = CFSTR("January"); values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[1] = CFSTR("February"); values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days28);
+ keys[2] = CFSTR("March"); values[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[3] = CFSTR("April"); values[3] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+ keys[4] = CFSTR("May"); values[4] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
+ keys[5] = CFSTR("June"); values[5] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
+
+ const CFDictionaryKeyCallBacks keyCB = kCFCopyStringDictionaryKeyCallBacks;
+ const CFDictionaryValueCallBacks valCB = kCFTypeDictionaryValueCallBacks;
+ CFDictionaryRef dict1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, numValues, &keyCB, &valCB); // no warning
+ CFDictionaryRef dict2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)elems[0], (const void**)values, numValues, &keyCB, &valCB); //expected-warning {{The first argument to 'CFDictionaryCreate' must be a C array of}}
+ CFDictionaryRef dict3 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)elems, numValues, &keyCB, &valCB); // expected-warning {{The second argument to 'CFDictionaryCreate' must be a C array of pointer-sized values}}
+}
+
+void OutOfBoundsSymbolicOffByOne(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, S, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, S-1); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, S); // expected-warning {{Index is out of bounds}}
+}
+
+void OutOfBoundsConst(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ array = CFArrayCreate(kCFAllocatorDefault, input, 3, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
+ const void *s2 = CFArrayGetValueAtIndex(array, 2); // no warning
+ const void *s3 = CFArrayGetValueAtIndex(array, 5); // expected-warning {{Index is out of bounds}}
+
+ // TODO: The solver is probably not strong enough here.
+ CFIndex sIndex;
+ for (sIndex = 0 ; sIndex <= 5 ; sIndex += 3 ) {
+ const void *s = CFArrayGetValueAtIndex(array, sIndex);
+ }
+}
+
+void OutOfBoundsZiro(const void ** input, CFIndex S) {
+ CFArrayRef array;
+ // The API allows to set the size to 0. Check that we don't undeflow when the size is 0.
+ array = CFArrayCreate(kCFAllocatorDefault, 0, 0, 0);
+ const void *s1 = CFArrayGetValueAtIndex(array, 0); // expected-warning {{Index is out of bounds}}
+}
+
+void TestGetCount(CFArrayRef A, CFIndex sIndex) {
+ CFIndex sCount = CFArrayGetCount(A);
+ if (sCount > sIndex)
+ const void *s1 = CFArrayGetValueAtIndex(A, sIndex);
+ const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}}
+}
+
+typedef void* XX[3];
+void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) {
+ void* x[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) &x, count, 0); // no warning
+
+ void* y[] = { p1, p2, p3 };
+ CFArrayCreate(0, (const void **) y, count, 0); // no warning
+ XX *z = &x;
+ CFArrayCreate(0, (const void **) z, count, 0); // no warning
+
+ CFArrayCreate(0, (const void **) &fn, count, 0); // false negative
+ CFArrayCreate(0, (const void **) fn, count, 0); // no warning
+ CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+
+ char cc[] = { 0, 2, 3 };
+ CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+ CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The first argument to 'CFArrayCreate' must be a C array of pointer-sized}}
+}
+
+void TestUndef(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ unsigned undefVal;
+ const void *s1 = CFArrayGetValueAtIndex(A, undefVal);
+
+ unsigned undefVal2;
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, undefVal2, 0);
+ const void *s2 = CFArrayGetValueAtIndex(B, 2);
+}
+
+void TestConst(CFArrayRef A, CFIndex sIndex, void* x[]) {
+ CFArrayRef B = CFArrayCreate(0, (const void **) &x, 4, 0);
+ const void *s1 = CFArrayGetValueAtIndex(B, 2);
+
+}
+
+void TestNullArray() {
+ CFArrayGetValueAtIndex(0, 0);
+}
diff --git a/test/Analysis/CFDateGC.m b/test/Analysis/CFDateGC.m
index 69b99f0..4884bb9 100644
--- a/test/Analysis/CFDateGC.m
+++ b/test/Analysis/CFDateGC.m
@@ -42,7 +42,7 @@ CFAbsoluteTime f1_use_after_release() {
[NSMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
@@ -55,7 +55,7 @@ CFAbsoluteTime f2_use_after_release() {
[(id) CFMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
diff --git a/test/Analysis/CheckNSError.m b/test/Analysis/CheckNSError.m
index 5bf7e08..d35b686 100644
--- a/test/Analysis/CheckNSError.m
+++ b/test/Analysis/CheckNSError.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
typedef signed char BOOL;
diff --git a/test/Analysis/NSPanel.m b/test/Analysis/NSPanel.m
index ac72571..578658e 100644
--- a/test/Analysis/NSPanel.m
+++ b/test/Analysis/NSPanel.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
// BEGIN delta-debugging reduced header stuff
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index 48450da..4035cc9 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,osx.AtomicCAS,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
@@ -97,31 +97,31 @@ extern void *_NSConstantStringClassReference;
NSComparisonResult f1(NSString* s) {
NSString *aString = 0;
- return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil.}}
+ return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil}}
}
NSComparisonResult f2(NSString* s) {
NSString *aString = 0;
- return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil.}}
+ return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil}}
}
NSComparisonResult f3(NSString* s, NSStringCompareOptions op) {
NSString *aString = 0;
- return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil.}}
+ return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil}}
}
NSComparisonResult f4(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
- return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil.}}
+ return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil}}
}
NSComparisonResult f5(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
- return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil.}}
+ return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil}}
}
NSArray *f6(NSString* s) {
- return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil.}}
+ return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil}}
}
NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
@@ -189,7 +189,7 @@ void f13(void) {
@end
void f14(MyString *s) {
- [s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil.}}
+ [s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil}}
}
// Test regular use of -autorelease
diff --git a/test/Analysis/ObjCProperties.m b/test/Analysis/ObjCProperties.m
index d88e057..b9ed9b9 100644
--- a/test/Analysis/ObjCProperties.m
+++ b/test/Analysis/ObjCProperties.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic %s -verify
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -Wno-objc-root-class %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -Wno-objc-root-class %s -verify
// The point of this test cases is to exercise properties in the static
// analyzer
diff --git a/test/Analysis/ObjCRetSigs.m b/test/Analysis/ObjCRetSigs.m
index 02be257..13078a3 100644
--- a/test/Analysis/ObjCRetSigs.m
+++ b/test/Analysis/ObjCRetSigs.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
int printf(const char *, ...);
diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c
index 71d0151..beb08aa 100644
--- a/test/Analysis/additive-folding.c
+++ b/test/Analysis/additive-folding.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.unix.Malloc -verify -analyzer-constraints=basic %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.unix.Malloc -verify -analyzer-constraints=range %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
// These are used to trigger warnings.
typedef typeof(sizeof(int)) size_t;
diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c
index 1284933..4b085c8 100644
--- a/test/Analysis/array-struct-region.c
+++ b/test/Analysis/array-struct-region.c
@@ -25,8 +25,8 @@ int string_literal_init() {
}
void nested_compound_literals(int rad) {
- int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}}
int a;
for (a = 0; a < 6; ++a) {
diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp
index 17aa486..67a8f2e 100644
--- a/test/Analysis/auto-obj-dtors-cfg-output.cpp
+++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
// XPASS: *
class A {
@@ -155,718 +156,709 @@ void test_catch_copy() {
}
}
-// CHECK: [ B2 (ENTRY) ]
-// CHECK: Predecessors (0):
-// CHECK: Successors (1): B1
-// CHECK: [ B1 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B1.3]
-// CHECK: 5: const A &b = a;
-// CHECK: 6: A()
-// CHECK: 7: [B1.6] (BindTemporary)
-// CHECK: 8: [B1.7]
-// CHECK: 9: [B1.8]
-// CHECK: 10: const A &c = A();
-// 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: [ 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: 6: [B3.5]
-// CHECK: T: if [B3.6]
-// 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: 2: [B4.1]
-// CHECK: T: if [B4.2]
-// 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: 6: [B6.5]
-// CHECK: T: if [B6.6]
-// 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.6].~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: [B4.3]
-// CHECK: 5: [B4.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B4.7]
-// CHECK: 9: [B4.8].operator int
-// CHECK: 10: [B4.9]()
-// CHECK: 11: [B4.10]
-// CHECK: T: if [B4.11]
-// 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.6].~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.6].~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: 4: [B4.3]
-// CHECK: T: if [B4.4]
-// 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.6].~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: 4: [B7.3]
-// CHECK: T: if [B7.4]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B6 B5
-// CHECK: [ B8 ]
-// CHECK: 1:
-// CHECK: 2: A a;
-// CHECK: 3: a
-// CHECK: 4: [B8.3]
-// CHECK: 5: [B8.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B8.7]
-// CHECK: 9: [B8.8].operator int
-// CHECK: 10: [B8.9]()
-// CHECK: 11: [B8.10]
-// CHECK: T: if [B8.11]
-// 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.4].~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: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: while [B2.9]
-// 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.4].~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.4].~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: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: while [B2.9]
-// 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.4].~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.4].~A() (Implicit destructor)
-// CHECK: 4: [B11.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B0
-// CHECK: [ B6 ]
-// CHECK: 1: UV
-// CHECK: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (2): B5 B4
-// CHECK: [ B7 ]
-// CHECK: 1: [B10.2].~A() (Implicit destructor)
-// CHECK: 2: [B2.4].~A() (Implicit destructor)
-// CHECK: T: continue;
-// CHECK: Predecessors (1): B8
-// CHECK: Successors (1): B3
-// CHECK: [ B8 ]
-// CHECK: 1: UV
-// CHECK: 2: [B8.1]
-// CHECK: T: if [B8.2]
-// 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: 4: [B10.3]
-// CHECK: T: if [B10.4]
-// 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: 2: [B1.1]
-// CHECK: T: do ... while [B1.2]
-// 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: 2: [B2.1]
-// CHECK: T: do ... while [B2.2]
-// 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: 2: [B5.1]
-// CHECK: T: if [B5.2]
-// 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: 2: [B7.1]
-// CHECK: T: if [B7.2]
-// 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: 4: [B9.3]
-// CHECK: T: if [B9.4]
-// 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.6].~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: [B2.3]
-// CHECK: 5: [B2.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B2.7]
-// CHECK: 9: [B2.8].operator int
-// CHECK: 10: [B2.9]()
-// CHECK: T: switch [B2.10]
-// 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.6].~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: [B2.3]
-// CHECK: 5: [B2.4]
-// CHECK: 6: A b = a;
-// CHECK: 7: b
-// CHECK: 8: [B2.7]
-// CHECK: 9: [B2.8].operator int
-// CHECK: 10: [B2.9]()
-// CHECK: T: switch [B2.10]
-// CHECK: Predecessors (1): B9
-// CHECK: Successors (3): B3 B8
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B1 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: 1
+// CHECK: 2: return [B1.1];
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: const A &b = a;
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: const A &c = A();
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A [2])
+// CHECK: 2: A a[2];
+// CHECK: 3: (CXXConstructExpr, class A [0])
+// CHECK: 4: A b[0];
+// CHECK: 5: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A c;
+// CHECK: 5: (CXXConstructExpr, class A)
+// CHECK: 6: A d;
+// CHECK: 7: [B1.6].~A() (Implicit destructor)
+// CHECK: 8: [B1.4].~A() (Implicit destructor)
+// CHECK: 9: (CXXConstructExpr, class A)
+// CHECK: 10: A b;
+// CHECK: 11: [B1.10].~A() (Implicit destructor)
+// CHECK: 12: [B1.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B3
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// 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: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: return;
+// CHECK: 2: [B3.4].~A() (Implicit destructor)
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B0
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: 5: UV
+// CHECK: 6: [B3.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B3.6]
+// CHECK: Preds (1): B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B2
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: l1:
+// CHECK: 1: (CXXConstructExpr, class A)
+// 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: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B6.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: T: goto l1;
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: UV
+// CHECK: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.2]
+// CHECK: Preds (1): B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: [B6.4].~A() (Implicit destructor)
+// CHECK: 2: [B6.2].~A() (Implicit destructor)
+// CHECK: T: goto l0;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B6
+// CHECK: [B6]
+// CHECK: l0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A a;
+// CHECK: 5: UV
+// CHECK: 6: [B6.5] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.6]
+// CHECK: Preds (2): B7 B5
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.6].~A() (Implicit destructor)
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B4.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B4.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B4.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B4.8].operator int
+// CHECK: 10: [B4.9]()
+// CHECK: 11: [B4.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B4.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B4.12]
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B3 B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: [B8.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B5
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: 4: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: return;
+// CHECK: 2: [B4.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B0
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B4.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B5.2].~A() (Implicit destructor)
+// CHECK: 4: [B7.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B1
+// CHECK: [B6]
+// CHECK: 1: return;
+// CHECK: 2: [B7.2].~A() (Implicit destructor)
+// CHECK: 3: [B8.6].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B0
+// CHECK: [B7]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B7.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.4]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B8.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B8.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B8.8].operator int
+// CHECK: 10: [B8.9]()
+// CHECK: 11: [B8.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: [B8.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: if [B8.12]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B7 B4
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B1 B3 B6
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A e;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: while [B2.10]
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: 5: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: 2: [B2.4].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: UV
+// CHECK: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B1.2]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B3 B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: [B1.2].~A() (Implicit destructor)
+// CHECK: 4: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B8 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: UV
+// CHECK: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: do ... while [B2.2]
+// CHECK: Preds (2): B3 B6
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: 4: [B9.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: return;
+// CHECK: 2: [B9.2].~A() (Implicit destructor)
+// CHECK: 3: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B5
+// CHECK: Succs (1): B0
+// CHECK: [B5]
+// CHECK: 1: UV
+// CHECK: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B5.2]
+// CHECK: Preds (1): B7
+// CHECK: Succs (2): B4 B3
+// CHECK: [B6]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B2
+// CHECK: [B7]
+// CHECK: 1: UV
+// CHECK: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B7.2]
+// CHECK: Preds (1): B9
+// CHECK: Succs (2): B6 B5
+// CHECK: [B8]
+// CHECK: 1: [B9.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B1
+// CHECK: [B9]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A b;
+// CHECK: 3: UV
+// CHECK: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B9.4]
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B8 B7
+// CHECK: [B10]
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B4
+// CHECK: [B4 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B3 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B3.2].~A() (Implicit destructor)
+// CHECK: Succs (1): B1
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B9 (ENTRY)]
+// CHECK: Succs (1): B2
+// CHECK: [B1]
+// CHECK: 1: [B2.6].~A() (Implicit destructor)
+// CHECK: 2: (CXXConstructExpr, class A)
+// CHECK: 3: A g;
+// CHECK: 4: [B1.3].~A() (Implicit destructor)
+// CHECK: 5: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (3): B3 B7 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: a
+// CHECK: 4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 5: [B2.4] (CXXConstructExpr, class A)
+// CHECK: 6: A b = a;
+// CHECK: 7: b
+// CHECK: 8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B2.8].operator int
+// CHECK: 10: [B2.9]()
+// CHECK: 11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: T: switch [B2.11]
+// CHECK: Preds (1): B9
+// CHECK: Succs (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.6].~A() (Implicit destructor)
-// CHECK: 4: [B2.2].~A() (Implicit destructor)
-// CHECK: Predecessors (1): B6
-// CHECK: Successors (1): B0
-// CHECK: [ B6 ]
-// CHECK: 1: UV
-// CHECK: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// 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: 4: [B8.3]
-// CHECK: T: if [B8.4]
-// 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.4].~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: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A b = a;
-// CHECK: 5: b
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: for (...; [B2.9]; )
-// CHECK: Predecessors (2): B3 B5
-// CHECK: Successors (2): B4 B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B2.4].~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.4].~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: [B2.1]
-// CHECK: 3: [B2.2]
-// CHECK: 4: A c = b;
-// CHECK: 5: c
-// CHECK: 6: [B2.5]
-// CHECK: 7: [B2.6].operator int
-// CHECK: 8: [B2.7]()
-// CHECK: 9: [B2.8]
-// CHECK: T: for (...; [B2.9]; )
-// CHECK: Predecessors (2): B3 B11
-// CHECK: Successors (2): B10 B1
-// CHECK: [ B3 ]
-// CHECK: 1: [B2.4].~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.4].~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: 2: [B6.1]
-// CHECK: T: if [B6.2]
-// 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: 2: [B8.1]
-// CHECK: T: if [B8.2]
-// 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: 4: [B10.3]
-// CHECK: T: if [B10.4]
-// 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):
-
+// CHECK: [B3]
+// CHECK: case 1:
+// CHECK: T: break;
+// CHECK: Preds (2): B2 B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A f;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B8.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B8.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.6].~A() (Implicit destructor)
+// CHECK: 4: [B2.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B8.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B1
+// CHECK: [B8]
+// CHECK: case 0:
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: UV
+// CHECK: 4: [B8.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B7 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B6 (ENTRY)]
+// CHECK: Succs (1): B5
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B5.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: a
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A b = a;
+// CHECK: 5: b
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B5
+// CHECK: Succs (2): B4 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A c;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B12 (ENTRY)]
+// CHECK: Succs (1): B11
+// CHECK: [B1]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: 2: [B11.4].~A() (Implicit destructor)
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A f;
+// CHECK: 5: [B1.4].~A() (Implicit destructor)
+// CHECK: 6: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (2): B9 B2
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: b
+// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B2.2] (CXXConstructExpr, class A)
+// CHECK: 4: A c = b;
+// CHECK: 5: c
+// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 7: [B2.6].operator int
+// CHECK: 8: [B2.7]()
+// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
+// CHECK: T: for (...; [B2.10]; )
+// CHECK: Preds (2): B3 B11
+// CHECK: Succs (2): B10 B1
+// CHECK: [B3]
+// CHECK: 1: [B2.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B4 B7
+// CHECK: Succs (1): B2
+// CHECK: [B4]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A e;
+// CHECK: 3: [B4.2].~A() (Implicit destructor)
+// CHECK: 4: [B10.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B3
+// CHECK: [B5]
+// CHECK: 1: return;
+// CHECK: 2: [B10.2].~A() (Implicit destructor)
+// CHECK: 3: [B2.4].~A() (Implicit destructor)
+// CHECK: 4: [B11.4].~A() (Implicit destructor)
+// CHECK: 5: [B11.2].~A() (Implicit destructor)
+// CHECK: Preds (1): B6
+// CHECK: Succs (1): B0
+// CHECK: [B6]
+// CHECK: 1: UV
+// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B6.2]
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B4
+// CHECK: [B7]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: continue;
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B3
+// CHECK: [B8]
+// CHECK: 1: UV
+// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B8.2]
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B6
+// CHECK: [B9]
+// CHECK: 1: [B10.2].~A() (Implicit destructor)
+// CHECK: T: break;
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B1
+// CHECK: [B10]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A d;
+// CHECK: 3: UV
+// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: if [B10.4]
+// CHECK: Preds (1): B2
+// CHECK: Succs (2): B9 B8
+// CHECK: [B11]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A a;
+// CHECK: 3: (CXXConstructExpr, class A)
+// CHECK: 4: A b;
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B2
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (2): B1 B5
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (const A &e):
+// CHECK: 1: catch (const A &e) {
+// CHECK: }
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
+// CHECK: [B3 (ENTRY)]
+// CHECK: Succs (1): B0
+// CHECK: [B1]
+// CHECK: T: try ...
+// CHECK: Succs (2): B2 B0
+// CHECK: [B2]
+// CHECK: catch (A e):
+// CHECK: 1: catch (A e) {
+// CHECK: }
+// CHECK: 2: [B2.1].~A() (Implicit destructor)
+// CHECK: Preds (1): B1
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (3): B2 B1 B3
diff --git a/test/Analysis/bool-assignment.cpp b/test/Analysis/bool-assignment.cpp
new file mode 100644
index 0000000..e573129
--- /dev/null
+++ b/test/Analysis/bool-assignment.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test C++'s bool
+
+void test_cppbool_initialization(int y) {
+ if (y < 0) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ bool x = y; // no-warning
+}
+
+void test_cppbool_assignment(int y) {
+ bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+// Test Objective-C's BOOL
+
+typedef signed char BOOL;
+
+void test_BOOL_initialization(int y) {
+ if (y < 0) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ BOOL x = y; // no-warning
+}
+
+void test_BOOL_assignment(int y) {
+ BOOL x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
+
+
+// Test MacTypes.h's Boolean
+
+typedef unsigned char Boolean;
+
+void test_Boolean_initialization(int y) {
+ if (y < 0) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ Boolean x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ Boolean x = y; // no-warning
+}
+
+void test_Boolean_assignment(int y) {
+ Boolean x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/test/Analysis/bool-assignment2.c b/test/Analysis/bool-assignment2.c
new file mode 100644
index 0000000..9de26cf
--- /dev/null
+++ b/test/Analysis/bool-assignment2.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c99 -analyze -analyzer-checker=core,experimental.core.BoolAssignment -analyzer-store=region -verify %s
+
+// Test stdbool.h's _Bool
+
+// Prior to C99, stdbool.h uses this typedef, but even in ANSI C mode, _Bool
+// appears to be defined.
+
+// #if __STDC_VERSION__ < 199901L
+// typedef int _Bool;
+// #endif
+
+void test_stdbool_initialization(int y) {
+ if (y < 0) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ _Bool x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ _Bool x = y; // no-warning
+}
+
+void test_stdbool_assignment(int y) {
+ _Bool x = 0; // no-warning
+ if (y < 0) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ if (y > 1) {
+ x = y; // expected-warning {{Assignment of a non-Boolean value}}
+ return;
+ }
+ x = y; // no-warning
+}
diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c
index e23059f..833c917 100644
--- a/test/Analysis/bstring.c
+++ b/test/Analysis/bstring.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.CString -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring.NullArg,experimental.unix.cstring.OutOfBounds,experimental.unix.cstring.BufferOverlap,experimental.unix.cstring.NotNullTerminated -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
diff --git a/test/Analysis/casts.m b/test/Analysis/casts.m
index d9700fe..6f19211 100644
--- a/test/Analysis/casts.m
+++ b/test/Analysis/casts.m
@@ -33,9 +33,10 @@ typedef enum {
RDR10087620Enum elem;
}
@property (readwrite, nonatomic) RDR10087620Enum elem;
+@end
+
static void
adium_media_ready_cb(RDR10087620 *InObj)
{
InObj.elem |= EEOne;
}
-@end \ No newline at end of file
diff --git a/test/Analysis/check-deserialization.cpp b/test/Analysis/check-deserialization.cpp
new file mode 100644
index 0000000..2b0bce2
--- /dev/null
+++ b/test/Analysis/check-deserialization.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyze -analyzer-checker=core %s
+// RUN: %clang_cc1 -include-pch %t -analyze -analyzer-checker=core -verify %s
+
+#ifndef HEADER
+#define HEADER
+// Header.
+
+void S1_method(); // This should not be deserialized.
+
+
+#else
+// Using the header.
+
+int test() {
+ int x = 0;
+ return 5/x; //expected-warning {{Division by zero}}
+}
+
+#endif
diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c
new file mode 100644
index 0000000..73d78da
--- /dev/null
+++ b/test/Analysis/coverage.c
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -analyzer-max-loop 4 -verify %s
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+
+static int another_function(int *y) {
+ if (*y > 0)
+ return *y;
+ return 0;
+}
+
+static void function_which_doesnt_give_up(int **x) {
+ *x = 0;
+}
+
+static void function_which_gives_up(int *x) {
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_gives_up_nested(int *x) {
+ function_which_gives_up(x);
+ for (int i = 0; i < 5; ++i)
+ (*x)++;
+}
+
+static void function_which_doesnt_give_up_nested(int *x, int *y) {
+ *y = another_function(x);
+ function_which_gives_up(x);
+}
+
+void coverage1(int *x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void coverage2(int *x) {
+ if (x) {
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+ }
+}
+
+void coverage3(int *x) {
+ x++;
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage4(int *x) {
+ *x += another_function(x);
+ function_which_gives_up(x);
+ char *m = (char*)malloc(12);// expected-warning {{potential leak}}
+}
+
+void coverage5(int *x) {
+ for (int i = 0; i<7; ++i)
+ function_which_gives_up(x);
+ // The root function gives up here.
+ char *m = (char*)malloc(12); // no-warning
+}
+
+void coverage6(int *x) {
+ for (int i = 0; i<3; ++i) {
+ function_which_gives_up(x);
+ }
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+int coverage7_inline(int *i) {
+ function_which_doesnt_give_up(&i);
+ return *i; // expected-warning {{Dereference}}
+}
+
+void coverage8(int *x) {
+ int y;
+ function_which_doesnt_give_up_nested(x, &y);
+ y = (*x)/y; // expected-warning {{Division by zero}}
+ char *m = (char*)malloc(12); // expected-warning {{potential leak}}
+}
+
+void function_which_gives_up_settonull(int **x) {
+ *x = 0;
+ int y = 0;
+ for (int i = 0; i < 5; ++i)
+ y++;
+}
+
+void coverage9(int *x) {
+ int y = 5;
+ function_which_gives_up_settonull(&x);
+ y = (*x); // no warning
+}
diff --git a/test/Analysis/cstring-syntax-cxx.cpp b/test/Analysis/cstring-syntax-cxx.cpp
new file mode 100644
index 0000000..f8975ab
--- /dev/null
+++ b/test/Analysis/cstring-syntax-cxx.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s
+
+// Ensure we don't crash on C++ declarations with special names.
+struct X {
+ X(int i): i(i) {}
+ int i;
+};
+
+X operator+(X a, X b) {
+ return X(a.i + b.i);
+}
+
+void test(X a, X b) {
+ X c = a + b;
+}
+
diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c
new file mode 100644
index 0000000..64ecb67
--- /dev/null
+++ b/test/Analysis/cstring-syntax.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s
+
+typedef __SIZE_TYPE__ size_t;
+char *strncat(char *, const char *, size_t);
+size_t strlen (const char *s);
+
+void testStrncat(const char *src) {
+ char dest[10];
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // expected-warning {{Potential buffer overflow. Replace with 'sizeof(dest) - strlen(dest) - 1' or use a safer 'strlcat' API}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning {{Potential buffer overflow. Replace with}}
+ strncat(dest, src, sizeof(src)); // expected-warning {{Potential buffer overflow. Replace with}}
+}
diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c
index 5ddb452..b8d195d 100644
--- a/test/Analysis/dead-stores.c
+++ b/test/Analysis/dead-stores.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=basic -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=range -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=basic -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores,experimental.deadcode.IdempotentOperations -analyzer-store=region -analyzer-constraints=range -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'}}
@@ -11,7 +11,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 (const char *, ...)'}} \
+ printf("%s", c); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
@@ -526,3 +526,25 @@ void rdar8405222() {
rdar8405222_aux(i);
}
+// Look through chains of assignements, e.g.: int x = y = 0, when employing
+// silencing heuristics.
+int radar11185138_foo() {
+ int x, y;
+ x = y = 0; // expected-warning {{never read}}
+ return y;
+}
+
+int rdar11185138_bar() {
+ int y;
+ int x = y = 0; // no-warning
+ x = 2;
+ y = 2;
+ return x + y;
+}
+
+int *radar11185138_baz() {
+ int *x, *y;
+ x = y = 0; // no-warning
+ return y;
+}
+
diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m
index 4ed71c4..0834274 100644
--- a/test/Analysis/dead-stores.m
+++ b/test/Analysis/dead-stores.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@@ -76,3 +76,15 @@ void foo_rdar8527823();
}
@end
+// Don't flag dead stores when a variable is captured in a block used
+// by a property access.
+@interface RDar10591355
+@property (assign) int x;
+@end
+
+RDar10591355 *rdar10591355_aux();
+
+void rdar10591355() {
+ RDar10591355 *p = rdar10591355_aux();
+ ^{ (void) p.x; }();
+}
diff --git a/test/Analysis/debug-CallGraph.c b/test/Analysis/debug-CallGraph.c
new file mode 100644
index 0000000..b7c7c8a
--- /dev/null
+++ b/test/Analysis/debug-CallGraph.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s 2>&1 | FileCheck %s
+
+static void mmm(int y) {
+ if (y != 0)
+ y++;
+ y = y/0;
+}
+
+static int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+void aaa() {
+ foo(1,2);
+}
+
+// CHECK:--- Call graph Dump ---
+// CHECK: Function: < root > calls: aaa
diff --git a/test/Analysis/default-analyze.m b/test/Analysis/default-analyze.m
new file mode 100644
index 0000000..82656b2
--- /dev/null
+++ b/test/Analysis/default-analyze.m
@@ -0,0 +1,63 @@
+// RUN: %clang --analyze %s -o %t
+
+// Tests that some specific checkers are enabled by default.
+
+id foo(int x) {
+ id title;
+ switch (x) {
+ case 1:
+ title = @"foo"; // expected-warning {{never read}}
+ case 2:
+ title = @"bar";
+ break;
+ default:
+ title = "@baz";
+ break;
+ }
+ return title;
+}
+
+// <rdar://problem/8808566> Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment
+//
+// Note: this requires inlining support. This previously issued a false positive use of
+// uninitialized value when calling NSWidth.
+typedef double CGFloat;
+
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+
+struct CGSize {
+ CGFloat width;
+ CGFloat height;
+};
+typedef struct CGSize CGSize;
+
+struct CGRect {
+ CGPoint origin;
+ CGSize size;
+};
+typedef struct CGRect CGRect;
+
+typedef CGRect NSRect;
+typedef CGSize NSSize;
+
+static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {
+ return (aRect.size.width);
+}
+
+static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {
+ return (aRect.size.height);
+}
+
+NSSize rdar880566_size();
+
+double rdar8808566() {
+ NSRect myRect;
+ myRect.size = rdar880566_size();
+ double x = NSWidth(myRect) + NSHeight(myRect); // no-warning
+ return x;
+}
+
diff --git a/test/Analysis/domtest.c b/test/Analysis/domtest.c
new file mode 100644
index 0000000..245186a
--- /dev/null
+++ b/test/Analysis/domtest.c
@@ -0,0 +1,165 @@
+// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s 2>&1 | FileCheck %s
+
+// Test the DominatorsTree implementation with various control flows
+int test1()
+{
+ int x = 6;
+ int y = x/2;
+ int z;
+
+ while(y > 0) {
+ if(y < x) {
+ x = x/y;
+ y = y-1;
+ }else{
+ z = x - y;
+ }
+ x = x - 1;
+ x = x - 1;
+ }
+ z = x+y;
+ z = 3;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,8)
+// CHECK: (3,4)
+// CHECK: (4,7)
+// CHECK: (5,7)
+// CHECK: (6,7)
+// CHECK: (7,2)
+// CHECK: (8,9)
+// CHECK: (9,9)
+
+int test2()
+{
+ int x,y,z;
+
+ x = 10; y = 100;
+ if(x > 0){
+ y = 1;
+ }else{
+ while(x<=0){
+ x++;
+ y++;
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,6)
+// CHECK: (2,6)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,7)
+// CHECK: (7,7)
+
+int test3()
+{
+ int x,y,z;
+
+ x = y = z = 1;
+ if(x>0) {
+ while(x>=0){
+ while(y>=x) {
+ x = x-1;
+ y = y/2;
+ }
+ }
+ }
+ z = y;
+
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,7)
+// CHECK: (2,7)
+// CHECK: (3,4)
+// CHECK: (4,2)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,8)
+// CHECK: (8,8)
+
+int test4()
+{
+ int y = 3;
+ while(y > 0) {
+ if(y < 3) {
+ while(y>0)
+ y ++;
+ }else{
+ while(y<10)
+ y ++;
+ }
+ }
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,2)
+// CHECK: (2,11)
+// CHECK: (3,10)
+// CHECK: (4,10)
+// CHECK: (5,6)
+// CHECK: (6,4)
+// CHECK: (7,10)
+// CHECK: (8,9)
+// CHECK: (9,7)
+// CHECK: (10,2)
+// CHECK: (11,12)
+// CHECK: (12,12)
+
+int test5()
+{
+ int x,y,z,a,b,c;
+ x = 1;
+ y = 2;
+ z = 3;
+ a = 4;
+ b = 5;
+ c = 6;
+ if ( x < 10 ) {
+ if ( y < 10 ) {
+ if ( z < 10 ) {
+ x = 4;
+ } else {
+ x = 5;
+ }
+ a = 10;
+ } else {
+ x = 6;
+ }
+ b = 10;
+ } else {
+ x = 7;
+ }
+ c = 11;
+ return 0;
+}
+
+// CHECK: Immediate dominance tree (Node#,IDom#):
+// CHECK: (0,1)
+// CHECK: (1,10)
+// CHECK: (2,10)
+// CHECK: (3,9)
+// CHECK: (4,9)
+// CHECK: (5,8)
+// CHECK: (6,8)
+// CHECK: (7,8)
+// CHECK: (8,9)
+// CHECK: (9,10)
+// CHECK: (10,11)
+// CHECK: (11,11)
+
diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp
index dfd438e..8d63cc4 100644
--- a/test/Analysis/dtor.cpp
+++ b/test/Analysis/dtor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-implicit-dtors -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -verify %s
class A {
public:
diff --git a/test/Analysis/dtors-in-dtor-cfg-output.cpp b/test/Analysis/dtors-in-dtor-cfg-output.cpp
index 7765483..68ba37e 100644
--- a/test/Analysis/dtors-in-dtor-cfg-output.cpp
+++ b/test/Analysis/dtors-in-dtor-cfg-output.cpp
@@ -35,26 +35,22 @@ public:
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):
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (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: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: this->a.~A() (Member object destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp
new file mode 100644
index 0000000..8e63b2b
--- /dev/null
+++ b/test/Analysis/dynamic-cast.cpp
@@ -0,0 +1,230 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core -verify %s
+
+class A {
+public:
+ virtual void f(){};
+
+};
+class B : public A{
+public:
+ int m;
+};
+class C : public A{};
+
+class BB: public B{};
+
+// A lot of the tests below have the if statement in them, which forces the
+// analyzer to explore both path - when the result is 0 and not. This makes
+// sure that we definitely know that the result is non-0 (as the result of
+// the cast).
+int testDynCastFromRadar() {
+ B aa;
+ A *a = &aa;
+ const int* res = 0;
+ B *b = dynamic_cast<B*>(a);
+ static const int i = 5;
+ if(b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testBaseToBase1() {
+ B b;
+ B *pb = &b;
+ B *pbb = dynamic_cast<B*>(pb);
+ const int* res = 0;
+ static const int i = 5;
+ if (pbb) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing1() {
+ BB bb;
+ B *pb = &bb;
+ A *pa = pb;
+ B *b = dynamic_cast<B*>(pa);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing2() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ BB *s = dynamic_cast<BB*>(b);
+ const int* res = 0;
+ static const int i = 5;
+ if (s) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testMultipleLevelsOfSubclassing3() {
+ BB bb;
+ A *pbb = &bb;
+ B *b = dynamic_cast<B*>(pbb);
+ return b->m; // no warning
+}
+
+int testLHS() {
+ B aa;
+ A *a = &aa;
+ return (dynamic_cast<B*>(a))->m;
+}
+
+int testLHS2() {
+ B aa;
+ A *a = &aa;
+ return (*dynamic_cast<B*>(a)).m;
+}
+
+int testDynCastUnknown2(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // no warning
+}
+
+int testDynCastUnknown(class A *a) {
+ B *b = dynamic_cast<B*>(a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning {{Dereference of null pointer}}
+}
+
+int testDynCastFail2() {
+ C c;
+ A *pa = &c;
+ B *b = dynamic_cast<B*>(pa);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testLHSFail() {
+ C c;
+ A *a = &c;
+ return (*dynamic_cast<B*>(a)).m; // expected-warning {{Dereference of null pointer}}
+}
+
+int testBaseToDerivedFail() {
+ A a;
+ B *b = dynamic_cast<B*>(&a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail() {
+ B *b = dynamic_cast<B*>((A *)0);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testConstZeroFail2() {
+ A *a = 0;
+ B *b = dynamic_cast<B*>(a);
+ return b->m; // expected-warning {{dereference of a null pointer}}
+}
+
+int testUpcast() {
+ B b;
+ A *a = dynamic_cast<A*>(&b);
+ const int* res = 0;
+ static const int i = 5;
+ if (a) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testCastToVoidStar() {
+ A a;
+ void *b = dynamic_cast<void*>(&a);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // no warning
+}
+
+int testReferenceSuccesfulCast() {
+ B rb;
+ B &b = dynamic_cast<B&>(rb);
+ int *x = 0;
+ return *x; // expected-warning {{Dereference of null pointer}}
+}
+
+int testReferenceFailedCast() {
+ A a;
+ B &b = dynamic_cast<B&>(a);
+ int *x = 0;
+ return *x; // no warning (An exception is thrown by the cast.)
+}
+
+// Here we allow any outcome of the cast and this is good because there is a
+// situation where this will fail. So if the user has written the code in this
+// way, we assume they expect the cast to succeed.
+// Note, this might need special handling if we track types of symbolic casts
+// and use them for dynamic_cast handling.
+int testDynCastMostLikelyWillFail(C *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+class M : public B, public C {};
+void callTestDynCastMostLikelyWillFail() {
+ M m;
+ testDynCastMostLikelyWillFail(&m);
+}
+
+// False positives/negatives.
+
+// Due to symbolic regions not being typed.
+int testDynCastFalsePositive(BB *c) {
+ B *b = 0;
+ b = dynamic_cast<B*>(c);
+ const int* res = 0;
+ static const int i = 5;
+ if (b) {
+ res = &i;
+ } else {
+ res = 0;
+ }
+ return *res; // expected-warning{{Dereference of null pointer}}
+}
+
+// Does not work when we new an object.
+int testDynCastFail3() {
+ A *a = new A();
+ B *b = dynamic_cast<B*>(a);
+ return b->m;
+}
+
diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c
index 5dd1f3f..b592c33 100644
--- a/test/Analysis/exercise-ps.c
+++ b/test/Analysis/exercise-ps.c
@@ -18,6 +18,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 *, const void *}} \
+ memcpy((&x[1]), (buf), 1); // expected-warning{{implicitly declaring library function 'memcpy' with type 'void *(void *, const void *}} \
// expected-note{{please include the header <string.h> or explicitly provide a declaration for 'memcpy'}}
}
diff --git a/test/Analysis/free.c b/test/Analysis/free.c
index 44c4f19..f688db7 100644
--- a/test/Analysis/free.c
+++ b/test/Analysis/free.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.unix.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.unix.MallocWithAnnotations -fblocks -verify %s
void free(void *);
void t1 () {
diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c
new file mode 100644
index 0000000..184ffb8
--- /dev/null
+++ b/test/Analysis/global-region-invalidation.c
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest -verify %s
+
+// Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
+#include "system-header-simulator.h"
+
+// Test that system header does not invalidate the internal global.
+int size_rdar9373039 = 1;
+int rdar9373039() {
+ int x;
+ int j = 0;
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ x = 1;
+
+ // strlen doesn't invalidate the value of 'size_rdar9373039'.
+ int extra = (2 + strlen ("Clang") + ((4 - ((unsigned int) (2 + strlen ("Clang")) % 4)) % 4)) + (2 + strlen ("1.0") + ((4 - ((unsigned int) (2 + strlen ("1.0")) % 4)) % 4));
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ j += x; // no-warning
+
+ return j;
+}
+
+// Test stdin does not get invalidated by a system call nor by an internal call.
+void foo();
+int stdinTest() {
+ int i = 0;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int m = i; // expected-warning + {{tainted}}
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+ return m + j; // expected-warning + {{tainted}}
+}
+
+// Test errno gets invalidated by a system call.
+int testErrnoSystem() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ fscanf(stdin, "%d", &i); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that errno gets invalidated by internal calls.
+int testErrnoInternal() {
+ int i;
+ int *p = 0;
+ fscanf(stdin, "%d", &i);
+ if (errno == 0) {
+ foo(); // errno gets invalidated here.
+ return 5 / errno; // no-warning
+ }
+ return 0;
+}
+
+// Test that const integer does not get invalidated.
+const int x = 0;
+int constIntGlob() {
+ const int *m = &x;
+ foo();
+ return 3 / *m; // expected-warning {{Division by zero}}
+}
+
+extern const int x;
+int constIntGlobExtern() {
+ if (x == 0) {
+ foo();
+ return 5 / x; // expected-warning {{Division by zero}}
+ }
+ return 0;
+}
diff --git a/test/Analysis/html-diags-multifile.c b/test/Analysis/html-diags-multifile.c
new file mode 100644
index 0000000..611dd07
--- /dev/null
+++ b/test/Analysis/html-diags-multifile.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir
+// RUN: ls %t.dir | grep report | count 0
+// RUN: rm -fR %t.dir
+// REQUIRES: shell
+
+// This tests that we do not currently emit HTML diagnostics for reports that
+// cross file boundaries.
+
+#include "html-diags-multifile.h"
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
+
diff --git a/test/Analysis/html-diags-multifile.h b/test/Analysis/html-diags-multifile.h
new file mode 100644
index 0000000..71d39ba
--- /dev/null
+++ b/test/Analysis/html-diags-multifile.h
@@ -0,0 +1,4 @@
+#define DEREF(p) *p = 0xDEADBEEF
+void has_bug(int *p) {
+ DEREF(p);
+}
diff --git a/test/Analysis/html-diags.c b/test/Analysis/html-diags.c
new file mode 100644
index 0000000..59d81a5
--- /dev/null
+++ b/test/Analysis/html-diags.c
@@ -0,0 +1,20 @@
+// RUN: mkdir %t.dir
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T.dir %s
+// RUN: rm -fR %t.dir
+
+// Currently this test mainly checks that the HTML diagnostics doesn't crash
+// when handling macros will calls with macros. We should actually validate
+// the output, but that requires being able to match against a specifically
+// generate HTML file.
+
+#define DEREF(p) *p = 0xDEADBEEF
+
+void has_bug(int *p) {
+ DEREF(p);
+}
+
+#define CALL_HAS_BUG(q) has_bug(q)
+
+void test_call_macro() {
+ CALL_HAS_BUG(0);
+}
diff --git a/test/Analysis/idempotent-operations-limited-loops.c b/test/Analysis/idempotent-operations-limited-loops.c
index 47a1f28..71e7c27 100644
--- a/test/Analysis/idempotent-operations-limited-loops.c
+++ b/test/Analysis/idempotent-operations-limited-loops.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,deadcode.IdempotentOperations %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations %s -verify
void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}}
diff --git a/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c
index 10bd9ff..6cc9a01 100644
--- a/test/Analysis/idempotent-operations.c
+++ b/test/Analysis/idempotent-operations.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations -verify %s
-// RUN: %clang --analyze -Xclang -analyzer-disable-checker=deadcode.DeadStores -fblocks -Xclang -verify %s -o %t
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
// Basic tests
diff --git a/test/Analysis/idempotent-operations.cpp b/test/Analysis/idempotent-operations.cpp
index 9d22909..51b5905 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-checker=deadcode.IdempotentOperations -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations -verify %s
// C++ specific false positives
diff --git a/test/Analysis/idempotent-operations.m b/test/Analysis/idempotent-operations.m
index b476508..9a9820c 100644
--- a/test/Analysis/idempotent-operations.m
+++ b/test/Analysis/idempotent-operations.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=experimental.deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
typedef signed char BOOL;
typedef unsigned long NSUInteger;
diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp
index b73809f..8a7a3f5 100644
--- a/test/Analysis/initializers-cfg-output.cpp
+++ b/test/Analysis/initializers-cfg-output.cpp
@@ -44,60 +44,55 @@ TestControlFlow::TestControlFlow(bool b)
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: /*implicit*/int()
-// CHECK: 10: i([B1.9]) (Member initializer)
-// CHECK: 11: this
-// CHECK: 12: [B1.11]->i
-// CHECK: 13: r([B1.12]) (Member initializer)
-// CHECK: 14:
-// CHECK: 15: 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.4] ? [B2.1] : [B3.1]
-// CHECK: 2: y([B1.1]) (Member initializer)
-// CHECK: 3: this
-// CHECK: 4: [B1.3]->y
-// CHECK: 5: [B1.4]
-// CHECK: 6: z([B1.5]) (Member initializer)
-// CHECK: 7: 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: 0
-// CHECK: 2: x([B4.1]) (Member initializer)
-// CHECK: 3: b
-// CHECK: 4: [B4.3]
-// CHECK: T: [B4.4] ? ... : ...
-// CHECK: Predecessors (1): B5
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
-
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: (CXXConstructExpr, class A)
+// CHECK: 2: A([B1.1]) (Base initializer)
+// CHECK: 3: (CXXConstructExpr, class C)
+// CHECK: 4: C([B1.3]) (Base initializer)
+// CHECK: 5: (CXXConstructExpr, class B)
+// CHECK: 6: B([B1.5]) (Base initializer)
+// CHECK: 7: (CXXConstructExpr, class A)
+// CHECK: 8: A([B1.7]) (Base initializer)
+// CHECK: 9: /*implicit*/int()
+// CHECK: 10: i([B1.9]) (Member initializer)
+// CHECK: 11: this
+// CHECK: 12: [B1.11]->i
+// CHECK: 13: r([B1.12]) (Member initializer)
+// CHECK: 14: (CXXConstructExpr, class A)
+// CHECK: 15: A a;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B5 (ENTRY)]
+// CHECK: Succs (1): B4
+// CHECK: [B1]
+// CHECK: 1: [B4.4] ? [B2.1] : [B3.1]
+// CHECK: 2: y([B1.1]) (Member initializer)
+// CHECK: 3: this
+// CHECK: 4: [B1.3]->y
+// CHECK: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK: 6: z([B1.5]) (Member initializer)
+// CHECK: 7: int v;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 1
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: 0
+// CHECK: 2: x([B4.1]) (Member initializer)
+// CHECK: 3: b
+// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK: T: [B4.4] ? ... : ...
+// CHECK: Preds (1): B5
+// CHECK: Succs (2): B2 B3
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/inline-not-supported.c b/test/Analysis/inline-not-supported.c
new file mode 100644
index 0000000..bff0e4d
--- /dev/null
+++ b/test/Analysis/inline-not-supported.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+// For now, don't inline varargs.
+void foo(int *x, ...) {
+ *x = 1;
+}
+
+void bar() {
+ foo(0, 2); // no-warning
+}
+
+// For now, don't inline vararg blocks.
+void (^baz)(int *x, ...) = ^(int *x, ...) { *x = 1; };
+
+void taz() {
+ baz(0, 2); // no-warning
+}
+
+// For now, don't inline blocks.
+void (^qux)(int *p) = ^(int *p) { *p = 1; };
+void test_qux() {
+ qux(0); // no-warning
+}
+
+
+void test_analyzer_is_running() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c
new file mode 100644
index 0000000..549082d
--- /dev/null
+++ b/test/Analysis/inline-plist.c
@@ -0,0 +1,369 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t
+// RUN: FileCheck -input-file %t %s
+
+// <rdar://problem/10967815>
+void mmm(int y) {
+ if (y != 0)
+ y++;
+}
+
+int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+// Test a bug triggering only when inlined.
+void has_bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_has_bug() {
+ has_bug(0);
+}
+
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is equal to 0</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Division by zero</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Division by zero</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Division by zero</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>foo</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_has_bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>has_bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/test/Analysis/inline-unique-reports.c b/test/Analysis/inline-unique-reports.c
new file mode 100644
index 0000000..ae94267
--- /dev/null
+++ b/test/Analysis/inline-unique-reports.c
@@ -0,0 +1,184 @@
+// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
+
+static inline bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+void test_bug_1() {
+ int *p = 0;
+ bug(p);
+}
+
+void test_bug_2() {
+ int *p = 0;
+ bug(p);
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;bug&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_bug_1&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c
index 2aac156..0827d93 100644
--- a/test/Analysis/inline.c
+++ b/test/Analysis/inline.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
-// XFAIL: *
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
int test1_f1() {
int y = 1;
@@ -29,3 +28,65 @@ void test2_f3() {
test2_f1(test2_f2()); // expected-warning{{too many arguments in call to 'test2_f1'}}
}
+// Test that inlining works with recursive functions.
+
+unsigned factorial(unsigned x) {
+ if (x <= 1)
+ return 1;
+ return x * factorial(x - 1);
+}
+
+void test_factorial() {
+ if (factorial(3) == 6) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+void test_factorial_2() {
+ unsigned x = factorial(3);
+ if (x == factorial(3)) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
+
+// Test that returning stack memory from a parent stack frame does
+// not trigger a warning.
+static char *return_buf(char *buf) {
+ return buf + 10;
+}
+
+void test_return_stack_memory_ok() {
+ char stack_buf[100];
+ char *pos = return_buf(stack_buf);
+ (void) pos;
+}
+
+char *test_return_stack_memory_bad() {
+ char stack_buf[100];
+ char *x = stack_buf;
+ return x; // expected-warning {{stack memory associated}}
+}
+
+// Test that passing a struct value with an uninitialized field does
+// not trigger a warning if we are inlining and the body is available.
+struct rdar10977037 { int x, y; };
+int test_rdar10977037_aux(struct rdar10977037 v) { return v.y; }
+int test_rdar10977037_aux_2(struct rdar10977037 v);
+int test_rdar10977037() {
+ struct rdar10977037 v;
+ v.y = 1;
+ v. y += test_rdar10977037_aux(v); // no-warning
+ return test_rdar10977037_aux_2(v); // expected-warning {{Passed-by-value struct argument contains uninitialized data}}
+}
+
+
diff --git a/test/Analysis/inline2.c b/test/Analysis/inline2.c
index 97e479d..473146c 100644
--- a/test/Analysis/inline2.c
+++ b/test/Analysis/inline2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
// Test parameter 'a' is registered to LiveVariables analysis data although it
// is not referenced in the function body.
diff --git a/test/Analysis/inline3.c b/test/Analysis/inline3.c
index 9c8e26e..968d82a 100644
--- a/test/Analysis/inline3.c
+++ b/test/Analysis/inline3.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
-// Test when entering f1(), we set the right AnalysisContext to Environment.
+// Test when entering f1(), we set the right AnalysisDeclContext to Environment.
// Otherwise, block-level expr '1 && a' would not be block-level.
int a;
diff --git a/test/Analysis/inline4.c b/test/Analysis/inline4.c
index c428aad..e7715e0 100644
--- a/test/Analysis/inline4.c
+++ b/test/Analysis/inline4.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
int g(int a) {
return a;
diff --git a/test/Analysis/keychainAPI.m b/test/Analysis/keychainAPI.m
index d10600d..cb4f72c 100644
--- a/test/Analysis/keychainAPI.m
+++ b/test/Analysis/keychainAPI.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -analyzer-ipa=inlining -verify
// Fake typedefs.
typedef unsigned int OSStatus;
@@ -77,7 +77,7 @@ void errRetVal() {
void *outData;
st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
if (st == GenericError) // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'.}}
- SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Call to free data when error was returned during allocation.}}
+ SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Only call free if a valid (non-NULL) buffer was returned}}
}
// If null is passed in, the data is not allocated, so no need for the matching free.
@@ -133,7 +133,7 @@ void* returnContent() {
return outData;
} // no-warning
-// Password was passed in as an argument and does nt have to be deleted.
+// Password was passed in as an argument and does not have to be deleted.
OSStatus getPasswordAndItem(void** password, UInt32* passwordLength) {
OSStatus err;
SecKeychainItemRef item;
@@ -275,7 +275,7 @@ void DellocWithCFStringCreate2(CFAllocatorRef alloc) {
st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &bytes);
if (st == noErr) {
CFStringRef userStr = CFStringCreateWithBytesNoCopy(alloc, bytes, length, 5, 0, kCFAllocatorNull); // expected-warning{{Allocated data is not released}}
- CFRelease(userStr);
+ CFRelease(userStr);
}
}
@@ -305,6 +305,22 @@ void DellocWithCFStringCreate4(CFAllocatorRef alloc) {
}
}
+void radar10508828() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+#pragma unused(rc)
+ if (pwdBytes)
+ SecKeychainItemFreeContent(0, pwdBytes);
+}
+
+void radar10508828_2() {
+ UInt32 pwdLen = 0;
+ void* pwdBytes = 0;
+ OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
+ SecKeychainItemFreeContent(0, pwdBytes); // expected-warning {{Only call free if a valid (non-NULL) buffer was returned.}}
+}
+
//Example from bug 10797.
__inline__ static
const char *__WBASLLevelString(int level) {
@@ -321,3 +337,73 @@ static int *bug10798(int *p, int columns, int prevRow) {
} while(10 >= row[1]);
return row;
}
+
+// Test inter-procedural behaviour.
+
+void my_FreeParam(void *attrList, void* X) {
+ SecKeychainItemFreeContent(attrList, X);
+}
+
+void *my_AllocateReturn(OSStatus *st) {
+ unsigned int *ptr = 0;
+ UInt32 length;
+ void *outData;
+ *st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ return outData;
+}
+
+OSStatus my_Allocate_Param(void** password, UInt32* passwordLength) {
+ OSStatus err;
+ SecKeychainItemRef item;
+ err = SecKeychainFindGenericPassword(0, 3, "xx", 3, "xx",
+ passwordLength, password, &item);
+ return err;
+}
+
+void allocAndFree1() {
+ unsigned int *ptr = 0;
+ OSStatus st = 0;
+ UInt32 length;
+ void *outData;
+ st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData);
+ if (st == noErr)
+ my_FreeParam(ptr, outData);
+}
+
+void consumeChar(char);
+
+void allocNoFree2(int x) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (x) {
+ consumeChar(*(char*)outData); // expected-warning{{Allocated data is not released:}}
+ return;
+ } else {
+ consumeChar(*(char*)outData);
+ }
+ return;
+}
+
+void allocAndFree2(void *attrList) {
+ OSStatus st = 0;
+ void *outData = my_AllocateReturn(&st);
+ if (st == noErr)
+ my_FreeParam(attrList, outData);
+}
+
+void allocNoFree3() {
+ UInt32 length = 32;
+ void *outData;
+ void *outData2;
+ OSStatus st = my_Allocate_Param(&outData, &length); // expected-warning{{Allocated data is not released}}
+ st = my_Allocate_Param(&outData2, &length); // expected-warning{{Allocated data is not released}}
+}
+
+void allocAndFree3(void *attrList) {
+ UInt32 length = 32;
+ void *outData;
+ OSStatus st = my_Allocate_Param(&outData, &length);
+ if (st == noErr)
+ SecKeychainItemFreeContent(attrList, outData);
+}
+
diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp
new file mode 100644
index 0000000..77b36c4
--- /dev/null
+++ b/test/Analysis/lambdas.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=debug.DumpCFG %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+struct X { X(const X&); };
+void f(X x) { (void) [x]{}; }
+
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: x
+// CHECK: 2: [B1.1] (ImplicitCastExpr, NoOp, const struct X)
+// CHECK: 3: [B1.2] (CXXConstructExpr, struct X)
+// CHECK: 4: [=x] {
+// CHECK: }
+// CHECK: 5: (void)[B1.4] (CStyleCastExpr, ToVoid, void)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+
diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c
new file mode 100644
index 0000000..a0c1452
--- /dev/null
+++ b/test/Analysis/malloc-annotations.c
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.MallocWithAnnotations -analyzer-store=region -verify %s
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
+void __attribute((ownership_takes(malloc, 1))) my_free(void *);
+void my_freeBoth(void *, void *)
+ __attribute((ownership_holds(malloc, 1, 2)));
+void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t);
+void __attribute((ownership_holds(malloc, 1))) my_hold(void *);
+
+// Duplicate attributes are silly, but not an error.
+// Duplicate attribute has no extra effect.
+// If two are of different kinds, that is an error and reported as such.
+void __attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 1)))
+__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *);
+void *my_malloc3(size_t);
+void *myglobalpointer;
+struct stuff {
+ void *somefield;
+};
+struct stuff myglobalstuff;
+
+void f1() {
+ int *p = malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void f2() {
+ int *p = malloc(12);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_0() {
+ int *p = malloc(12);
+ realloc(p,0);
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
+}
+
+void f2_realloc_1() {
+ int *p = malloc(12);
+ int *q = realloc(p,0); // no-warning
+}
+
+// ownership attributes tests
+void naf1() {
+ int *p = my_malloc3(12);
+ return; // no-warning
+}
+
+void n2af1() {
+ int *p = my_malloc2(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1() {
+ int *p = my_malloc(12);
+ return; // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_b() {
+ int *p = my_malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void af1_c() {
+ myglobalpointer = my_malloc(12); // no-warning
+}
+
+// TODO: We will be able to handle this after we add support for tracking allocations stored in struct fields.
+void af1_d() {
+ struct stuff mystuff;
+ mystuff.somefield = my_malloc(12); // false negative
+}
+
+// Test that we can pass out allocated memory via pointer-to-pointer.
+void af1_e(void **pp) {
+ *pp = my_malloc(42); // no-warning
+}
+
+void af1_f(struct stuff *somestuff) {
+ somestuff->somefield = my_malloc(12); // no-warning
+}
+
+// Allocating memory for a field via multiple indirections to our arguments is OK.
+void af1_g(struct stuff **pps) {
+ *pps = my_malloc(sizeof(struct stuff)); // no-warning
+ (*pps)->somefield = my_malloc(42); // no-warning
+}
+
+void af2() {
+ int *p = my_malloc(12);
+ my_free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2b() {
+ int *p = my_malloc(12);
+ free(p);
+ my_free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2c() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2d() {
+ int *p = my_malloc(12);
+ free(p);
+ my_hold2(0, 0, p); // expected-warning{{Attempt to free released memory}}
+}
+
+// No leak if malloc returns null.
+void af2e() {
+ int *p = my_malloc(12);
+ if (!p)
+ return; // no-warning
+ free(p); // no-warning
+}
+
+// This case would inflict a double-free elsewhere.
+// However, this case is considered an analyzer bug since it causes false-positives.
+void af3() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ free(p); // no-warning
+}
+
+int * af4() {
+ int *p = my_malloc(12);
+ my_free(p);
+ return p; // expected-warning{{Use of memory after it is freed}}
+}
+
+// This case is (possibly) ok, be conservative
+int * af5() {
+ int *p = my_malloc(12);
+ my_hold(p);
+ return p; // no-warning
+}
+
+
+
+// This case tests that storing malloc'ed memory to a static variable which is
+// then returned is not leaked. In the absence of known contracts for functions
+// or inter-procedural analysis, this is a conservative answer.
+int *f3() {
+ static int *p = 0;
+ p = malloc(12);
+ return p; // no-warning
+}
+
+// This case tests that storing malloc'ed memory to a static global variable
+// which is then returned is not leaked. In the absence of known contracts for
+// functions or inter-procedural analysis, this is a conservative answer.
+static int *p_f4 = 0;
+int *f4() {
+ p_f4 = malloc(12);
+ return p_f4; // no-warning
+}
+
+int *f5() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no-warning
+}
+
+void f6() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ free(p);
+}
+
+void f6_realloc() {
+ int *p = malloc(12);
+ if (!p)
+ return; // no-warning
+ else
+ realloc(p,0);
+}
+
+
+char *doit2();
+void pr6069() {
+ char *buf = doit2();
+ free(buf);
+}
+
+void pr6293() {
+ free(0);
+}
+
+void f7() {
+ char *x = (char*) malloc(4);
+ free(x);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void f7_realloc() {
+ char *x = (char*) malloc(4);
+ realloc(x,0);
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
+}
+
+void PR6123() {
+ int *x = malloc(11); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+}
+
+void PR7217() {
+ int *buf = malloc(2); // expected-warning{{Cast a region whose size is not a multiple of the destination type size.}}
+ buf[1] = 'c'; // not crash
+}
+
+void mallocCastToVoid() {
+ void *p = malloc(2);
+ const void *cp = p; // not crash
+ free(p);
+}
+
+void mallocCastToFP() {
+ void *p = malloc(2);
+ void (*fp)() = p; // not crash
+ free(p);
+}
+
+// This tests that malloc() buffers are undefined by default
+char mallocGarbage () {
+ char *buf = malloc(2);
+ char result = buf[1]; // expected-warning{{undefined}}
+ free(buf);
+ return result;
+}
+
+// This tests that calloc() buffers need to be freed
+void callocNoFree () {
+ char *buf = calloc(2,2);
+ return; // expected-warning{{never released}}
+}
+
+// These test that calloc() buffers are zeroed by default
+char callocZeroesGood () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] == 0) {
+ free(buf);
+ }
+ return result; // no-warning
+}
+
+char callocZeroesBad () {
+ char *buf = calloc(2,2);
+ char result = buf[3]; // no-warning
+ if (buf[1] != 0) {
+ free(buf); // expected-warning{{never executed}}
+ }
+ return result; // expected-warning{{never released}}
+}
+
+void testMultipleFreeAnnotations() {
+ int *p = malloc(12);
+ int *q = malloc(12);
+ my_freeBoth(p, q);
+}
+
diff --git a/test/Analysis/malloc-interprocedural.c b/test/Analysis/malloc-interprocedural.c
new file mode 100644
index 0000000..589bc4f
--- /dev/null
+++ b/test/Analysis/malloc-interprocedural.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-ipa=inlining -analyzer-inline-max-stack-depth=5 -analyzer-inline-max-function-size=6 -analyzer-store=region -verify %s
+
+#include "system-header-simulator.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *valloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+extern void exit(int) __attribute__ ((__noreturn__));
+
+static void my_malloc1(void **d, size_t size) {
+ *d = malloc(size);
+}
+
+static void *my_malloc2(int elevel, size_t size) {
+ void *data;
+ data = malloc(size);
+ if (data == 0)
+ exit(0);
+ return data;
+}
+
+static void my_free1(void *p) {
+ free(p);
+}
+
+static void test1() {
+ void *data = 0;
+ my_malloc1(&data, 4); // expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test11() {
+ void *data = 0;
+ my_malloc1(&data, 4);
+ my_free1(data);
+}
+
+static void testUniqueingByallocationSiteInTopLevelFunction() {
+ void *data = my_malloc2(1, 4);
+ data = 0;
+ int x = 5;// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+ data = my_malloc2(1, 4);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'data'}}
+}
+
+static void test3() {
+ void *data = my_malloc2(1, 4);
+ free(data);
+ data = my_malloc2(1, 4);
+ free(data);
+}
+
+int test4() {
+ int *data = (int*)my_malloc2(1, 4);
+ my_free1(data);
+ data = (int *)my_malloc2(1, 4);
+ my_free1(data);
+ return *data; // expected-warning {{Use of memory after it is freed}}
+}
+
+void test6() {
+ int *data = (int *)my_malloc2(1, 4);
+ my_free1((int*)data);
+ my_free1((int*)data); // expected-warning{{Use of memory after it is freed}}
+}
+
+// TODO: We should warn here.
+void test5() {
+ int *data;
+ my_free1((int*)data);
+}
+
+static char *reshape(char *in) {
+ return 0;
+}
+
+void testThatRemoveDeadBindingsRunBeforeEachCall() {
+ char *v = malloc(12);
+ v = reshape(v);
+ v = reshape(v);// expected-warning {{Memory is never released; potential leak of memory pointed to by 'v'}}
+}
+
+// Test that we keep processing after 'return;'
+void fooWithEmptyReturn(int x) {
+ if (x)
+ return;
+ x++;
+ return;
+}
+
+int uafAndCallsFooWithEmptyReturn() {
+ int *x = (int*)malloc(12);
+ free(x);
+ fooWithEmptyReturn(12);
+ return *x; // expected-warning {{Use of memory after it is freed}}
+}
diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c
new file mode 100644
index 0000000..db2e0f0
--- /dev/null
+++ b/test/Analysis/malloc-plist.c
@@ -0,0 +1,2814 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+
+void diagnosticTest(int in) {
+ if (in > 5) {
+ int *p = malloc(12);
+ (*p)++;
+ }
+ in++; // expected-warning {{leak}}
+}
+
+void myArrayAllocation() {
+ int **A;
+ A = malloc(2*sizeof(int*));
+ A[0] = 0;// expected-warning {{leak}}
+}
+
+void reallocDiagnostics() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return;// expected-warning {{leak}}
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void *wrapper() {
+ void *x = malloc(100);
+ // This is intentionally done to test diagnostic emission.
+ if (x)
+ return x;
+ return 0;
+}
+
+void test_wrapper() {
+ void *buf = wrapper();
+ (void) buf;
+}
+
+// Test what happens when the same call frees and allocated memory.
+// Also tests the stack hint for parameters, when they are passed directly or via pointer.
+void my_free(void *x) {
+ free(x);
+}
+void my_malloc_and_free(void **x) {
+ *x = malloc(100);
+ if (*x)
+ my_free(*x);
+ return;
+}
+void *test_double_action_call() {
+ void *buf;
+ my_malloc_and_free(&buf);
+ return buf;
+}
+
+// Test stack hint for 'reallocation failed'.
+char *my_realloc(char *buf) {
+ char *tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ return tmp;
+ }
+ return tmp;
+}
+void reallocIntra() {
+ char *buf = (char *)malloc(100);
+ buf = my_realloc(buf);
+ free(buf);
+}
+
+// Test stack hint when returning a result.
+static char *malloc_wrapper_ret() {
+ return (char*)malloc(12);
+}
+void use_ret() {
+ char *v;
+ v = malloc_wrapper_ret();
+}
+
+// Test that we refer to the last symbol used in the leak diagnostic.
+void LeakedSymbol(int in) {
+ int *m = 0;
+ int *p;
+ p = (int*)malloc(12);
+ (*p)++;
+ m = p;
+ p = 0;
+ (*m)++;
+ in++;
+}
+
+// CHECK: <?xml version="1.0" encoding="UTF-8"?>
+// CHECK: <plist version="1.0">
+// CHECK: <dict>
+// CHECK: <key>files</key>
+// CHECK: <array>
+// CHECK: </array>
+// CHECK: <key>diagnostics</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>col</key><integer>27</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;p&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>diagnosticTest</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>14</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>30</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;A&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>myArrayAllocation</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>21</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocDiagnostics</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_wrapper&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>34</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;x&apos; is non-null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>43</integer>
+// CHECK: <key>col</key><integer>23</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_wrapper</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>45</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;test_double_action_call&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>col</key><integer>20</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;my_malloc_and_free&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>49</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is released</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>2</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>55</integer>
+// CHECK: <key>col</key><integer>17</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned released memory via 1st parameter</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>60</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>14</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Use of memory after it is freed</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Use of memory after it is freed</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Use-after-free</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_double_action_call</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>61</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>74</integer>
+// CHECK: <key>col</key><integer>35</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;my_realloc&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;reallocIntra&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>65</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>66</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Attempt to reallocate memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>18</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>67</integer>
+// CHECK: <key>col</key><integer>40</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;tmp&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>12</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>68</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>69</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Reallocation of 1st parameter failed</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>11</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>75</integer>
+// CHECK: <key>col</key><integer>25</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>13</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;buf&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>reallocIntra</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>84</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling &apos;malloc_wrapper_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from &apos;use_ret&apos;</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>80</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>81</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Returned allocated memory</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>85</integer>
+// CHECK: <key>col</key><integer>28</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;v&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>use_ret</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>86</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>90</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is allocated</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>15</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>92</integer>
+// CHECK: <key>col</key><integer>24</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by &apos;m&apos;</string>
+// CHECK: <key>category</key><string>Memory Error</string>
+// CHECK: <key>type</key><string>Memory leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>LeakedSymbol</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>97</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </plist>
+
diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c
new file mode 100644
index 0000000..d2b3bcf
--- /dev/null
+++ b/test/Analysis/malloc-sizeof.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s
+
+#include <stddef.h>
+
+void *malloc(size_t size);
+void *calloc(size_t nmemb, size_t size);
+void *realloc(void *ptr, size_t size);
+
+struct A {};
+struct B {};
+
+void foo() {
+ int *ip1 = malloc(sizeof(1));
+ int *ip2 = malloc(4 * sizeof(int));
+
+ long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'short'}}
+ long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'double'}}
+ long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'char'}}
+
+ struct A *ap1 = calloc(1, sizeof(struct A));
+ struct A *ap2 = calloc(2, sizeof(*ap1));
+ struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+ struct A *ap6 = realloc(ap5, sizeof(struct A));
+ struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+}
diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c
index d9087ab..3b47123 100644
--- a/test/Analysis/malloc.c
+++ b/test/Analysis/malloc.c
@@ -1,42 +1,33 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,experimental.unix.Malloc -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+#include "system-header-simulator.h"
+
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
+void *valloc(size_t);
void free(void *);
void *realloc(void *ptr, size_t size);
+void *reallocf(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
-void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
-void __attribute((ownership_takes(malloc, 1))) my_free(void *);
-void __attribute((ownership_returns(malloc, 1))) *my_malloc2(size_t);
-void __attribute((ownership_holds(malloc, 1))) my_hold(void *);
-
-// Duplicate attributes are silly, but not an error.
-// Duplicate attribute has no extra effect.
-// If two are of different kinds, that is an error and reported as such.
-void __attribute((ownership_holds(malloc, 1)))
-__attribute((ownership_holds(malloc, 1)))
-__attribute((ownership_holds(malloc, 3))) my_hold2(void *, void *, void *);
-void *my_malloc3(size_t);
-void *myglobalpointer;
-struct stuff {
- void *somefield;
-};
-struct stuff myglobalstuff;
+
+void myfoo(int *p);
+void myfooint(int p);
+char *fooRetPtr();
void f1() {
int *p = malloc(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+ return; // expected-warning{{Memory is never released; potential leak}}
}
void f2() {
int *p = malloc(12);
free(p);
- free(p); // expected-warning{{Try to free a memory block that has been released}}
+ free(p); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_0() {
int *p = malloc(12);
realloc(p,0);
- realloc(p,0); // expected-warning{{Try to free a memory block that has been released}}
+ realloc(p,0); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_1() {
@@ -44,105 +35,155 @@ void f2_realloc_1() {
int *q = realloc(p,0); // no-warning
}
-// ownership attributes tests
-void naf1() {
- int *p = my_malloc3(12);
- return; // no-warning
+void reallocNotNullPtr(unsigned sizeIn) {
+ unsigned size = 12;
+ char *p = (char*)malloc(size);
+ if (p) {
+ char *q = (char*)realloc(p, sizeIn);
+ char x = *q; // expected-warning {{Memory is never released; potential leak}}
+ }
}
-void n2af1() {
- int *p = my_malloc2(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+int *realloctest1() {
+ int *q = malloc(12);
+ q = realloc(q, 20);
+ return q; // no warning - returning the allocated value
}
-void af1() {
- int *p = my_malloc(12);
- return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
+// p should be freed if realloc fails.
+void reallocFails() {
+ char *p = malloc(12);
+ char *r = realloc(p, 12+1);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
}
-void af1_b() {
- int *p = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}}
+void reallocSizeZero1() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
}
-void af1_c() {
- myglobalpointer = my_malloc(12); // no-warning
+void reallocSizeZero2() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ if (!r) {
+ free(p);
+ } else {
+ free(r);
+ }
+ free(p); // expected-warning {{Attempt to free released memory}}
}
-void af1_d() {
- struct stuff mystuff;
- mystuff.somefield = my_malloc(12); // expected-warning{{Allocated memory never released. Potential memory leak.}}
+void reallocSizeZero3() {
+ char *p = malloc(12);
+ char *r = realloc(p, 0);
+ free(r);
}
-// Test that we can pass out allocated memory via pointer-to-pointer.
-void af1_e(void **pp) {
- *pp = my_malloc(42); // no-warning
+void reallocSizeZero4() {
+ char *r = realloc(0, 0);
+ free(r);
}
-void af1_f(struct stuff *somestuff) {
- somestuff->somefield = my_malloc(12); // no-warning
+void reallocSizeZero5() {
+ char *r = realloc(0, 0);
}
-// Allocating memory for a field via multiple indirections to our arguments is OK.
-void af1_g(struct stuff **pps) {
- *pps = my_malloc(sizeof(struct stuff)); // no-warning
- (*pps)->somefield = my_malloc(42); // no-warning
+void reallocPtrZero1() {
+ char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak}}
}
-void af2() {
- int *p = my_malloc(12);
- my_free(p);
- free(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocPtrZero2() {
+ char *r = realloc(0, 12);
+ if (r)
+ free(r);
}
-void af2b() {
- int *p = my_malloc(12);
- free(p);
- my_free(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocPtrZero3() {
+ char *r = realloc(0, 12);
+ free(r);
}
-void af2c() {
- int *p = my_malloc(12);
- free(p);
- my_hold(p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocRadar6337483_1() {
+ char *buf = malloc(100);
+ buf = (char*)realloc(buf, 0x1000000);
+ if (!buf) {
+ return;// expected-warning {{Memory is never released; potential leak}}
+ }
+ free(buf);
}
-void af2d() {
- int *p = my_malloc(12);
- free(p);
- my_hold2(0, 0, p); // expected-warning{{Try to free a memory block that has been released}}
+void reallocRadar6337483_2() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) { // expected-warning {{Memory is never released; potential leak}}
+ ;
+ } else {
+ free(buf2);
+ }
}
-// No leak if malloc returns null.
-void af2e() {
- int *p = my_malloc(12);
- if (!p)
- return; // no-warning
- free(p); // no-warning
+void reallocRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)realloc(buf, 0x1000000);
+ if (!tmp) {
+ free(buf);
+ return;
+ }
+ buf = tmp;
+ free(buf);
}
-// This case would inflict a double-free elsewhere.
-// However, this case is considered an analyzer bug since it causes false-positives.
-void af3() {
- int *p = my_malloc(12);
- my_hold(p);
- free(p); // no-warning
+void reallocRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)realloc(buf, 0x1000000);
+ if (!buf2) {
+ return; // expected-warning {{Memory is never released; potential leak}}
+ } else {
+ free(buf2);
+ }
}
-// This case would inflict a double-free elsewhere.
-// However, this case is considered an analyzer bug since it causes false-positives.
-int * af4() {
- int *p = my_malloc(12);
- my_free(p);
- return p; // no-warning
+int *reallocfTest1() {
+ int *q = malloc(12);
+ q = reallocf(q, 20);
+ return q; // no warning - returning the allocated value
}
-// This case is (possibly) ok, be conservative
-int * af5() {
- int *p = my_malloc(12);
- my_hold(p);
- return p; // no-warning
+void reallocfRadar6337483_4() {
+ char *buf = malloc(100);
+ char *buf2 = (char*)reallocf(buf, 0x1000000);
+ if (!buf2) {
+ return; // no warning - reallocf frees even on failure
+ } else {
+ free(buf2);
+ }
}
+void reallocfRadar6337483_3() {
+ char * buf = malloc(100);
+ char * tmp;
+ tmp = (char*)reallocf(buf, 0x1000000);
+ if (!tmp) {
+ free(buf); // expected-warning {{Attempt to free released memory}}
+ return;
+ }
+ buf = tmp;
+ free(buf);
+}
+
+void reallocfPtrZero1() {
+ char *r = reallocf(0, 12); // expected-warning {{Memory is never released; potential leak}}
+}
// This case tests that storing malloc'ed memory to a static variable which is
@@ -199,13 +240,13 @@ void pr6293() {
void f7() {
char *x = (char*) malloc(4);
free(x);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void f7_realloc() {
char *x = (char*) malloc(4);
realloc(x,0);
- x[0] = 'a'; // expected-warning{{Use dynamically allocated memory after it is freed.}}
+ x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void PR6123() {
@@ -261,3 +302,508 @@ char callocZeroesBad () {
}
return result; // expected-warning{{never released}}
}
+
+void nullFree() {
+ int *p = 0;
+ free(p); // no warning - a nop
+}
+
+void paramFree(int *p) {
+ myfoo(p);
+ free(p); // no warning
+ myfoo(p); // TODO: This should be a warning.
+}
+
+int* mallocEscapeRet() {
+ int *p = malloc(12);
+ return p; // no warning
+}
+
+void mallocEscapeFoo() {
+ int *p = malloc(12);
+ myfoo(p);
+ return; // no warning
+}
+
+void mallocEscapeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+}
+
+void mallocEscapeFreeFree() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void mallocEscapeFreeUse() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *myalloc();
+void myalloc2(int **p);
+
+void mallocEscapeFreeCustomAlloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ p = myalloc();
+ free(p); // no warning
+}
+
+void mallocEscapeFreeCustomAlloc2() {
+ int *p = malloc(12);
+ myfoo(p);
+ free(p);
+ myalloc2(&p);
+ free(p); // no warning
+}
+
+void mallocBindFreeUse() {
+ int *x = malloc(12);
+ int *y = x;
+ free(y);
+ myfoo(x); // expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocEscapeMalloc() {
+ int *p = malloc(12);
+ myfoo(p);
+ p = malloc(12); // expected-warning{{Memory is never released; potential leak}}
+}
+
+void mallocMalloc() {
+ int *p = malloc(12);
+ p = malloc(12); // expected-warning 2 {{Memory is never released; potential leak}}
+}
+
+void mallocFreeMalloc() {
+ int *p = malloc(12);
+ free(p);
+ p = malloc(12);
+ free(p);
+}
+
+void mallocFreeUse_params() {
+ int *p = malloc(12);
+ free(p);
+ myfoo(p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFreeUse_params2() {
+ int *p = malloc(12);
+ free(p);
+ myfooint(*p); //expected-warning{{Use of memory after it is freed}}
+}
+
+void mallocFailedOrNot() {
+ int *p = malloc(12);
+ if (!p)
+ free(p);
+ else
+ free(p);
+}
+
+struct StructWithInt {
+ int g;
+};
+
+int *mallocReturnFreed() {
+ int *p = malloc(12);
+ free(p);
+ return p; // expected-warning {{Use of memory after it is freed}}
+}
+
+int useAfterFreeStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ px->g = 5;
+ free(px);
+ return px->g; // expected-warning {{Use of memory after it is freed}}
+}
+
+void nonSymbolAsFirstArg(int *pp, struct StructWithInt *p);
+
+void mallocEscapeFooNonSymbolArg() {
+ struct StructWithInt *p = malloc(sizeof(struct StructWithInt));
+ nonSymbolAsFirstArg(&p->g, p);
+ return; // no warning
+}
+
+void mallocFailedOrNotLeak() {
+ int *p = malloc(12);
+ if (p == 0)
+ return; // no warning
+ else
+ return; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void mallocAssignment() {
+ char *p = malloc(12);
+ p = fooRetPtr(); // expected-warning {{leak}}
+}
+
+int vallocTest() {
+ char *mem = valloc(12);
+ return 0; // expected-warning {{Memory is never released; potential leak}}
+}
+
+void vallocEscapeFreeUse() {
+ int *p = valloc(12);
+ myfoo(p);
+ free(p);
+ myfoo(p); // expected-warning{{Use of memory after it is freed}}
+}
+
+int *Gl;
+struct GlStTy {
+ int *x;
+};
+
+struct GlStTy GlS = {0};
+
+void GlobalFree() {
+ free(Gl);
+}
+
+void GlobalMalloc() {
+ Gl = malloc(12);
+}
+
+void GlobalStructMalloc() {
+ int *a = malloc(12);
+ GlS.x = a;
+}
+
+void GlobalStructMallocFree() {
+ int *a = malloc(12);
+ GlS.x = a;
+ free(GlS.x);
+}
+
+char *ArrayG[12];
+
+void globalArrayTest() {
+ char *p = (char*)malloc(12);
+ ArrayG[0] = p;
+}
+
+// Make sure that we properly handle a pointer stored into a local struct/array.
+typedef struct _StructWithPtr {
+ int *memP;
+} StructWithPtr;
+
+static StructWithPtr arrOfStructs[10];
+
+void testMalloc() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ arrOfStructs[0] = St;
+}
+
+StructWithPtr testMalloc2() {
+ int *x = malloc(12);
+ StructWithPtr St;
+ St.memP = x;
+ return St;
+}
+
+int *testMalloc3() {
+ int *x = malloc(12);
+ int *y = x;
+ return y;
+}
+
+void testElemRegion1() {
+ char *x = (void*)malloc(2);
+ int *ix = (int*)x;
+ free(&(x[0]));
+}
+
+void testElemRegion2(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(pp[0]);
+}
+
+void testElemRegion3(int **pp) {
+ int *p = malloc(12);
+ *pp = p;
+ free(*pp);
+}
+// Region escape testing.
+
+unsigned takePtrToPtr(int **p);
+void PassTheAddrOfAllocatedData(int f) {
+ int *p = malloc(12);
+ // We don't know what happens after the call. Should stop tracking here.
+ if (takePtrToPtr(&p))
+ f++;
+ free(p); // no warning
+}
+
+struct X {
+ int *p;
+};
+unsigned takePtrToStruct(struct X *s);
+int ** foo2(int *g, int f) {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ // We don't know what happens after this call. Should not track px nor p.
+ if (takePtrToStruct(px))
+ f++;
+ free(p);
+ return 0;
+}
+
+struct X* RegInvalidationDetect1(struct X *s2) {
+ struct X *px= malloc(sizeof(struct X));
+ px->p = 0;
+ px = s2;
+ return px; // expected-warning {{Memory is never released; potential leak}}
+}
+
+struct X* RegInvalidationGiveUp1() {
+ int *p = malloc(12);
+ struct X *px= malloc(sizeof(struct X));
+ px->p = p;
+ return px;
+}
+
+int **RegInvalidationDetect2(int **pp) {
+ int *p = malloc(12);
+ pp = &p;
+ pp++;
+ return 0;// expected-warning {{Memory is never released; potential leak}}
+}
+
+extern void exit(int) __attribute__ ((__noreturn__));
+void mallocExit(int *g) {
+ struct xx *p = malloc(12);
+ if (g != 0)
+ exit(1);
+ free(p);
+ return;
+}
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+ ((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+void mallocAssert(int *g) {
+ struct xx *p = malloc(12);
+
+ assert(g != 0);
+ free(p);
+ return;
+}
+
+void doNotInvalidateWhenPassedToSystemCalls(char *s) {
+ char *p = malloc(12);
+ strlen(p);
+ strcpy(p, s); // expected-warning {{leak}}
+}
+
+// Rely on the CString checker evaluation of the strcpy API to convey that the result of strcpy is equal to p.
+void symbolLostWithStrcpy(char *s) {
+ char *p = malloc(12);
+ p = strcpy(p, s);
+ free(p);
+}
+
+
+// The same test as the one above, but with what is actually generated on a mac.
+static __inline char *
+__inline_strcpy_chk (char *restrict __dest, const char *restrict __src)
+{
+ return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
+}
+
+void symbolLostWithStrcpy_InlineStrcpyVersion(char *s) {
+ char *p = malloc(12);
+ p = ((__builtin_object_size (p, 0) != (size_t) -1) ? __builtin___strcpy_chk (p, s, __builtin_object_size (p, 2 > 1)) : __inline_strcpy_chk (p, s));
+ free(p);
+}
+
+// Here we are returning a pointer one past the allocated value. An idiom which
+// can be used for implementing special malloc. The correct uses of this might
+// be rare enough so that we could keep this as a warning.
+static void *specialMalloc(int n){
+ int *p;
+ p = malloc( n+8 );
+ if( p ){
+ p[0] = n;
+ p++;
+ }
+ return p;
+}
+
+// Potentially, the user could free the struct by performing pointer arithmetic on the return value.
+// This is a variation of the specialMalloc issue, though probably would be more rare in correct code.
+int *specialMallocWithStruct() {
+ struct StructWithInt *px= malloc(sizeof(struct StructWithInt));
+ return &(px->g);
+}
+
+// Test various allocation/deallocation functions.
+
+char *strdup(const char *s);
+char *strndup(const char *s, size_t n);
+
+void testStrdup(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential leak}}
+}
+
+int testStrndup(const char *s, unsigned validIndex, unsigned size) {
+ char *s2 = strndup(s, size);
+ s2 [validIndex + 1] = 'b';
+ if (s2[validIndex] != 'a')
+ return 0;
+ else
+ return 1;// expected-warning {{Memory is never released; potential leak}}
+}
+
+void testStrdupContentIsDefined(const char *s, unsigned validIndex) {
+ char *s2 = strdup(s);
+ char result = s2[1];// no warning
+ free(s2);
+}
+
+// ----------------------------------------------------------------------------
+// Test the system library functions to which the pointer can escape.
+// This tests false positive suppression.
+
+// For now, we assume memory passed to pthread_specific escapes.
+// TODO: We could check that if a new pthread binding is set, the existing
+// binding must be freed; otherwise, a memory leak can occur.
+void testPthereadSpecificEscape(pthread_key_t key) {
+ void *buf = malloc(12);
+ pthread_setspecific(key, buf); // no warning
+}
+
+// PR12101: Test funopen().
+static int releasePtr(void *_ctx) {
+ free(_ctx);
+ return 0;
+}
+FILE *useFunOpen() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, releasePtr); // no warning
+ if (f == 0) {
+ free(ctx);
+ }
+ return f;
+}
+FILE *useFunOpenNoReleaseFunction() {
+ void *ctx = malloc(sizeof(int));
+ FILE *f = funopen(ctx, 0, 0, 0, 0);
+ if (f == 0) {
+ free(ctx);
+ }
+ return f; // expected-warning{{leak}}
+}
+
+// Test setbuf, setvbuf.
+int my_main_no_warning() {
+ char *p = malloc(100);
+ setvbuf(stdout, p, 0, 100);
+ return 0;
+}
+int my_main_no_warning2() {
+ char *p = malloc(100);
+ setbuf(__stdoutp, p);
+ return 0;
+}
+int my_main_warn(FILE *f) {
+ char *p = malloc(100);
+ setvbuf(f, p, 0, 100);
+ return 0;// expected-warning {{leak}}
+}
+
+// <rdar://problem/10978247>.
+// some people use stack allocated memory as an optimization to avoid
+// a heap allocation for small work sizes. This tests the analyzer's
+// understanding that the malloc'ed memory is not the same as stackBuffer.
+void radar10978247(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer != stackBuffer)
+ free(buffer);
+}
+
+void radar10978247_positive(int myValueSize) {
+ char stackBuffer[128];
+ char *buffer;
+
+ if (myValueSize <= sizeof(stackBuffer))
+ buffer = stackBuffer;
+ else
+ buffer = malloc(myValueSize);
+
+ // do stuff with the buffer
+ if (buffer == stackBuffer) // expected-warning {{leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// Below are the known false positives.
+
+// TODO: There should be no warning here. This one might be difficult to get rid of.
+void dependsOnValueOfPtr(int *g, unsigned f) {
+ int *p;
+
+ if (f) {
+ p = g;
+ } else {
+ p = malloc(12);
+ }
+
+ if (p != g)
+ free(p);
+ else
+ return; // expected-warning{{Memory is never released; potential leak}}
+ return;
+}
+
+// ----------------------------------------------------------------------------
+// False negatives.
+
+// TODO: This requires tracking symbols stored inside the structs/arrays.
+void testMalloc5() {
+ StructWithPtr St;
+ StructWithPtr *pSt = &St;
+ pSt->memP = malloc(12);
+}
+
+// TODO: This is another false negative.
+void testMallocWithParam(int **p) {
+ *p = (int*) malloc(sizeof(int));
+ *p = 0;
+}
+
+void testMallocWithParam_2(int **p) {
+ *p = (int*) malloc(sizeof(int));
+}
+
+// TODO: This should produce a warning, similar to the previous issue.
+void localArrayTest() {
+ char *p = (char*)malloc(12);
+ char *ArrayL[12];
+ ArrayL[0] = p;
+}
+
diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp
new file mode 100644
index 0000000..8f80b2b
--- /dev/null
+++ b/test/Analysis/malloc.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void *realloc(void *ptr, size_t size);
+void *calloc(size_t nmemb, size_t size);
+
+// Test for radar://11110132.
+struct Foo {
+ mutable void* m_data;
+ Foo(void* data) : m_data(data) {}
+};
+Foo aFunction() {
+ return malloc(10);
+}
diff --git a/test/Analysis/malloc.m b/test/Analysis/malloc.m
new file mode 100644
index 0000000..6c94118
--- /dev/null
+++ b/test/Analysis/malloc.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s
+#include "system-header-simulator-objc.h"
+
+@class NSString;
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// RDar10579586 - Test use of malloc() with Objective-C string literal as a
+// test condition. Not really a malloc() issue, but this also exercises
+// the check that malloc() returns uninitialized memory.
+@interface RDar10579586
+struct rdar0579586_str {
+ char str_c;
+};
+@end
+
+void rdar10579586(char x);
+
+@implementation RDar10579586
++ (NSString *)foobar
+{
+ struct rdar0579586_str *buffer = ((void*)0);
+ NSString *error = ((void*)0);
+
+ if ((buffer = malloc(sizeof(struct rdar0579586_str))) == ((void*)0))
+ error = @"buffer allocation failure";
+
+ if (error != ((void*)0))
+ return error;
+
+ rdar10579586(buffer->str_c); // expected-warning {{Function call argument is an uninitialized value}}
+ free(buffer);
+ return ((void*)0);
+}
+@end
+
diff --git a/test/Analysis/malloc.mm b/test/Analysis/malloc.mm
new file mode 100644
index 0000000..3515a4f
--- /dev/null
+++ b/test/Analysis/malloc.mm
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -fblocks %s
+#include "system-header-simulator-objc.h"
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+// Done with headers. Start testing.
+void testNSDatafFreeWhenDoneNoError(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength];
+ free(data); // no warning
+}
+
+void testNSDataFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSStringFreeWhenDoneYES(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; // no-warning
+}
+
+void testNSStringFreeWhenDoneYES2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; // no-warning
+}
+
+
+void testNSDataFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSDataFreeWhenDoneNO2(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+
+void testNSStringFreeWhenDoneNO(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) {
+ unichar *data = (unichar*)malloc(42);
+ NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}}
+}
+
+// TODO: False Negative.
+void testNSDatafFreeWhenDoneFN(NSUInteger dataLength) {
+ unsigned char *data = (unsigned char *)malloc(42);
+ NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1];
+ free(data); // false negative
+}
+
+// Test CF/NS...NoCopy. PR12100: Pointers can escape when custom deallocators are provided.
+void testNSDatafFreeWhenDone(NSUInteger dataLength) {
+ CFStringRef str;
+ char *bytes = (char*)malloc(12);
+ str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // no warning
+ CFRelease(str); // default allocator also frees bytes
+}
+
+void stringWithExternalContentsExample(void) {
+#define BufferSize 1000
+ CFMutableStringRef mutStr;
+ UniChar *myBuffer;
+
+ myBuffer = (UniChar *)malloc(BufferSize * sizeof(UniChar));
+
+ mutStr = CFStringCreateMutableWithExternalCharactersNoCopy(0, myBuffer, 0, BufferSize, kCFAllocatorNull); // expected-warning{{leak}}
+
+ CFRelease(mutStr);
+ //free(myBuffer);
+}
+
+// PR12101 : pointers can escape through custom deallocators set on creation of a container.
+void TestCallbackReleasesMemory(CFDictionaryKeyCallBacks keyCallbacks) {
+ void *key = malloc(12);
+ void *val = malloc(12);
+ CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &keyCallbacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(x, key, val);
+ return;// no-warning
+}
+
+NSData *radar10976702() {
+ void *bytes = malloc(10);
+ return [NSData dataWithBytesNoCopy:bytes length:10]; // no-warning
+}
+
+void testBlocks() {
+ int *x= (int*)malloc(sizeof(int));
+ int (^myBlock)(int) = ^(int num) {
+ free(x);
+ return num;
+ };
+ myBlock(3);
+}
+
+// Test NSMapInsert.
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSMapTable *map) {
+ const char *strkey = "key";
+ NSString *string = ( NSString *)NSMapGet(map, strkey);
+ if (!string) {
+ string = [string1 copy];
+ NSMapInsert(map, strdup(strkey), (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, strdup(strkey), (void*)string); // no warning
+ }
+ return string;
+}
+
+// Test that we handle pointer escaping through OSAtomicEnqueue.
+typedef volatile struct {
+ void *opaque1;
+ long opaque2;
+} OSQueueHead;
+void OSAtomicEnqueue( OSQueueHead *__list, void *__new, size_t __offset) __attribute__((weak_import));
+static inline void radar11111210(OSQueueHead *pool) {
+ void *newItem = malloc(4);
+ OSAtomicEnqueue(pool, newItem, 4);
+}
+
+// Pointer might escape through CGDataProviderCreateWithData (radar://11187558).
+typedef struct CGDataProvider *CGDataProviderRef;
+typedef void (*CGDataProviderReleaseDataCallback)(void *info, const void *data,
+ size_t size);
+extern CGDataProviderRef CGDataProviderCreateWithData(void *info,
+ const void *data, size_t size,
+ CGDataProviderReleaseDataCallback releaseData)
+ __attribute__((visibility("default")));
+void *calloc(size_t, size_t);
+
+static void releaseDataCallback (void *info, const void *data, size_t size) {
+#pragma unused (info, size)
+ free((void*)data);
+}
+void testCGDataProviderCreateWithData() {
+ void* b = calloc(8, 8);
+ CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
+} \ No newline at end of file
diff --git a/test/Analysis/method-arg-decay.m b/test/Analysis/method-arg-decay.m
index 9ce88b2..a36d81e 100644
--- a/test/Analysis/method-arg-decay.m
+++ b/test/Analysis/method-arg-decay.m
@@ -56,7 +56,7 @@ PBXFindMatchContains, PBXFindMatchStartsWith, PBXFindMatchWholeWords,
@interface PBXProjectModule : PBXModule <PBXFindableText> {
}
@end @class PBXBookmark;
-@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-note {{method declared here}}
+@protocol PBXSelectionTarget - (NSObject <PBXSelectionTarget> *) performAction:(id)action withSelection:(NSArray *)selection; // expected-note {{method 'performAction:withSelection:' declared here}}
@end @class XCPropertyDictionary, XCPropertyCondition, XCPropertyConditionSet, XCMutablePropertyConditionSet;
extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExposedModulesOnly);
@interface NSString (StringUtilities) - (NSString *) trimToLength:(NSInteger)length preserveRange:(NSRange)range;
@@ -72,8 +72,7 @@ extern NSMutableArray *XCFindPossibleKeyModules(PBXModule *module, BOOL useExpos
}
- (PBXModule *) moduleForTab:(NSTabViewItem *)item; // expected-note {{method definition for 'moduleForTab:' not found}}
@end
-@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+@implementation XCPerspectiveModule // expected-warning {{incomplete implementation}} expected-warning {{method 'performAction:withSelection:' in protocol not implemented}}}
+ (void) openForProjectDocument:(PBXProjectDocument *)projectDocument {
}
- (PBXModule *) type:(Class)type inPerspective:(id)perspectiveIdentifer matchingFunction:(BOOL (void *, void *))comparator usingData:(void *)data {
diff --git a/test/Analysis/method-call-intra-p.cpp b/test/Analysis/method-call-intra-p.cpp
new file mode 100644
index 0000000..701479f
--- /dev/null
+++ b/test/Analysis/method-call-intra-p.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+
+// Intra-procedural C++ tests.
+
+// Test relaxing function call arguments invalidation to be aware of const
+// arguments. radar://10595327
+struct InvalidateArgs {
+ void ttt(const int &nptr);
+ virtual void vttt(const int *nptr);
+};
+struct ChildOfInvalidateArgs: public InvalidateArgs {
+ virtual void vttt(const int *nptr);
+};
+void declarationFun(int x) {
+ InvalidateArgs t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ t.ttt(y);
+ if (x == y)
+ y = *p; // no-warning
+}
+void virtualFun(int x) {
+ ChildOfInvalidateArgs t;
+ InvalidateArgs *pt = &t;
+ x = 3;
+ int y = x + 1;
+ int *p = 0;
+ pt->vttt(&y);
+ if (x == y)
+ y = *p; // no-warning
+}
diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp
index 53b6fa2..b4dee31 100644
--- a/test/Analysis/misc-ps-cxx0x.cpp
+++ b/test/Analysis/misc-ps-cxx0x.cpp
@@ -68,3 +68,8 @@ void test2() {
*p = 0xDEADBEEF; // no-warning
}
+// Do not crash on the following when constructing the
+// callgraph.
+struct RDar11178609 {
+ ~RDar11178609() = delete;
+};
diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp
index 37153f7..8d75fb8 100644
--- a/test/Analysis/misc-ps-region-store.cpp
+++ b/test/Analysis/misc-ps-region-store.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions
// Test basic handling of references.
char &test1_aux();
@@ -466,4 +466,115 @@ void rdar10202899_test3() {
*p = 0xDEADBEEF;
}
+// This used to crash the analyzer because of the unnamed bitfield.
+void PR11249()
+{
+ struct {
+ char f1:4;
+ char :4;
+ char f2[1];
+ char f3;
+ } V = { 1, {2}, 3 };
+ int *p = 0;
+ if (V.f1 != 1)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f2[0] != 2)
+ *p = 0xDEADBEEF; // no-warning
+ if (V.f3 != 3)
+ *p = 0xDEADBEEF; // no-warning
+}
+
+// Handle doing a load from the memory associated with the code for
+// a function.
+extern double nan( const char * );
+double PR11450() {
+ double NaN = *(double*) nan;
+ return NaN;
+}
+
+// Test that 'this' is assumed non-null upon analyzing the entry to a "top-level"
+// function (i.e., when not analyzing from a specific caller).
+struct TestNullThis {
+ int field;
+ void test();
+};
+
+void TestNullThis::test() {
+ int *p = &field;
+ if (p)
+ return;
+ field = 2; // no-warning
+}
+
+// Test handling of 'catch' exception variables, and not warning
+// about uninitialized values.
+enum MyEnum { MyEnumValue };
+MyEnum rdar10892489() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ return e; // no-warning
+ }
+ return MyEnumValue;
+}
+MyEnum rdar10892489_positive() {
+ try {
+ throw MyEnumValue;
+ } catch (MyEnum e) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ return e;
+ }
+ return MyEnumValue;
+}
+
+// Test handling of catch with no condition variable.
+void PR11545() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ }
+}
+
+void PR11545_positive() {
+ try
+ {
+ throw;
+ }
+ catch (...)
+ {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+ }
+}
+
+// Test handling taking the address of a field. While the analyzer
+// currently doesn't do anything intelligent here, this previously
+// resulted in a crash.
+class PR11146 {
+public:
+ struct Entry;
+ void baz();
+};
+
+struct PR11146::Entry {
+ int x;
+};
+
+void PR11146::baz() {
+ (void) &Entry::x;
+}
+
+// Test symbolicating a reference. In this example, the
+// analyzer (originally) didn't know how to handle x[index - index2],
+// returning an UnknownVal. The conjured symbol wasn't a location,
+// and would result in a crash.
+void rdar10924675(unsigned short x[], int index, int index2) {
+ unsigned short &y = x[index - index2];
+ if (y == 0)
+ return;
+}
diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m
index 0fdab83..d263d4d 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-checker=core,deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -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,deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core.CastToStruct,experimental.security.ReturnPtrRange,experimental.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
typedef long unsigned int size_t;
void *memcpy(void *, const void *, size_t);
@@ -294,9 +294,11 @@ int test_invalidate_field_test_positive() {
struct ArrayWrapper { unsigned char y[16]; };
struct WrappedStruct { unsigned z; };
+void test_handle_array_wrapper_helper();
+
int test_handle_array_wrapper() {
struct ArrayWrapper x;
- test_handle_array_wrapper(&x);
+ test_handle_array_wrapper_helper(&x);
struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption.}}
return p->z; // no-warning
}
@@ -918,7 +920,7 @@ int rdar_7770737_pos(void)
void pr6302(id x, Class y) {
// This previously crashed the analyzer (reported in PR 6302)
- x->isa = y;
+ x->isa = y; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
}
//===----------------------------------------------------------------------===//
@@ -1323,3 +1325,19 @@ void rdar9444714() {
*dst = '\0';
}
+// Test handling symbolic elements with field accesses.
+// <rdar://problem/11127008>
+typedef struct {
+ unsigned value;
+} RDar11127008;
+
+signed rdar_11127008_index();
+
+static unsigned rdar_11127008(void) {
+ RDar11127008 values[] = {{.value = 0}, {.value = 1}};
+ signed index = rdar_11127008_index();
+ if (index < 0) return 0;
+ if (index >= 2) return 0;
+ return values[index].value;
+}
+
diff --git a/test/Analysis/misc-ps-region-store.mm b/test/Analysis/misc-ps-region-store.mm
index fee9433..8615c6a 100644
--- a/test/Analysis/misc-ps-region-store.mm
+++ b/test/Analysis/misc-ps-region-store.mm
@@ -29,3 +29,20 @@ char Test1_harness_b(Test1 *p) {
return [p foo];
}
+// Basic test of C++ references with Objective-C pointers.
+@interface RDar10569024
+@property(readonly) int x;
+@end
+
+typedef RDar10569024* RDar10569024Ref;
+
+void rdar10569024_aux(RDar10569024Ref o);
+
+int rdar10569024(id p, id collection) {
+ for (id elem in collection) {
+ const RDar10569024Ref &o = (RDar10569024Ref) elem;
+ rdar10569024_aux(o); // no-warning
+ return o.x; // no-warning
+ }
+ return 0;
+}
diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c
index bef5b06..f81b0dd 100644
--- a/test/Analysis/misc-ps.c
+++ b/test/Analysis/misc-ps.c
@@ -1,24 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=deadcode -verify %s
-unsigned long strlen(const char *);
-
int size_rdar9373039 = 1;
-int rdar9373039() {
- int x;
- int j = 0;
-
- for (int i = 0 ; i < size_rdar9373039 ; ++i)
- x = 1;
-
- // strlen doesn't invalidate the value of 'size_rdar9373039'.
- int extra = (2 + strlen ("Clang") + ((4 - ((unsigned int) (2 + strlen ("Clang")) % 4)) % 4)) + (2 + strlen ("1.0") + ((4 - ((unsigned int) (2 + strlen ("1.0")) % 4)) % 4));
-
- for (int i = 0 ; i < size_rdar9373039 ; ++i)
- j += x; // no-warning
-
- return j;
-}
-
int foo_rdar9373039(const char *);
int rdar93730392() {
@@ -81,3 +63,66 @@ int PR8962_f (int *t) {
}) ) return 0;
return *t; // no-warning
}
+
+// This previously crashed logic in the analyzer engine when evaluating locations.
+void rdar10308201_aux(unsigned val);
+void rdar10308201 (int valA, void *valB, unsigned valC) {
+ unsigned actual_base, lines;
+ if (valC == 0) {
+ actual_base = (unsigned)valB;
+ for (;;) {
+ if (valA & (1<<0))
+ rdar10308201_aux(actual_base);
+ }
+ }
+}
+
+typedef struct Struct103 {
+ unsigned i;
+} Struct103;
+typedef unsigned int size_t;
+void __my_memset_chk(char*, int, size_t);
+static int radar10367606(int t) {
+ Struct103 overall;
+ ((__builtin_object_size ((char *) &overall, 0) != (size_t) -1) ? __builtin___memset_chk ((char *) &overall, 0, sizeof(Struct103), __builtin_object_size ((char *) &overall, 0)) : __my_memset_chk ((char *) &overall, 0, sizeof(Struct103)));
+ return 0;
+}
+
+/* Caching out on a sink node. */
+extern int fooR10376675();
+extern int* bazR10376675();
+extern int nR10376675;
+void barR10376675(int *x) {
+ int *pm;
+ if (nR10376675 * 2) {
+ int *pk = bazR10376675();
+ pm = pk; //expected-warning {{never read}}
+ }
+ do {
+ *x = fooR10376675();
+ } while (0);
+}
+
+// Test accesses to wide character strings doesn't break the analyzer.
+typedef int wchar_t;
+struct rdar10385775 {
+ wchar_t *name;
+};
+void RDar10385775(struct rdar10385775* p) {
+ p->name = L"a";
+}
+
+// Test double loop of array and array literals. Previously this
+// resulted in a false positive uninitailized value warning.
+void rdar10686586() {
+ int array1[] = { 1, 2, 3, 0 };
+ int array2[] = { 1, 2, 3, 0 };
+ int *array[] = { array1, array2 };
+ int sum = 0;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 4; j++) {
+ sum += array[i][j]; // no-warning
+ }
+ }
+}
+
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 007c558..9d2ff5b 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -1,11 +1,11 @@
// 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-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
#ifndef __clang_analyzer__
-#error __clang__analyzer__ not defined
+#error __clang_analyzer__ not defined
#endif
typedef struct objc_ivar *Ivar;
@@ -274,6 +274,17 @@ void rdar_6777003(int x) {
*p = 1; // expected-warning{{Dereference of null pointer}}
}
+// Check that the pointer-to-conts arguments do not get invalidated by Obj C
+// interfaces. radar://10595327
+int rdar_10595327(char *str) {
+ char fl = str[0];
+ int *p = 0;
+ NSString *s = [NSString stringWithUTF8String:str];
+ if (str[0] != fl)
+ return *p; // no-warning
+ return 0;
+}
+
// For pointer arithmetic, --/++ should be treated as preserving non-nullness,
// regardless of how well the underlying StoreManager reasons about pointer
// arithmetic.
@@ -1237,7 +1248,7 @@ void pr9269() {
struct s { char *bar[10]; } baz[2] = { 0 };
unsigned i = 0;
for (i = 0;
- (* ({ while(0); ({ &baz[0]; }); })).bar[0] != 0;
+ (* ({ while(0); ({ &baz[0]; }); })).bar[0] != 0; // expected-warning {{while loop has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
++i) {}
}
@@ -1321,3 +1332,16 @@ void radar9414427() {
@implementation RDar9465344
@end
+// Don't crash when analyzing access to 'self' within a block.
+@interface Rdar10380300Base
+- (void) foo;
+@end
+@interface Rdar10380300 : Rdar10380300Base @end
+@implementation Rdar10380300
+- (void)foo {
+ ^{
+ [super foo];
+ }();
+}
+@end
+
diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp
index 29ac5ee..5ca8c46 100644
--- a/test/Analysis/new.cpp
+++ b/test/Analysis/new.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// XFAIL: *
void f1() {
int *n = new int;
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
index e2ad117..c1cc076 100644
--- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
+++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
@@ -1,38 +1,32 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
// <rdar://problem/6888289> - 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;
+ id *x;
}
-- (RDar6888289_data) test;
-- (RDar6888289_data) test2;
+- (void) test:(id) y;
+- (void) test2:(id) y;
- (void) invalidate;
-- (RDar6888289_data) getData;
@end
+id *getVal(void);
+
@implementation RDar6888289
-- (RDar6888289_data) test {
+- (void) test:(id)y {
if (!x)
[self invalidate];
- return [x getData];
+ *x = y;
}
-- (RDar6888289_data) test2 {
+- (void) test2:(id)y {
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}}
+ *x = y; // expected-warning {{null}}
}
- (void) invalidate {
- x = self;
+ x = getVal();
}
-- (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 eb15435..e4d5aaf 100644
--- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
+++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -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-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin8 %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
+// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -Wno-objc-root-class %s 2>&1 | FileCheck -check-prefix=darwin9 %s
@interface MyClass {}
- (void *)voidPtrM;
@@ -48,7 +48,7 @@ void createFoo4() {
}
void createFoo5() {
- MyClass *obj = @"";
+ MyClass *obj = (id)@"";
double d = [obj doubleM]; // no-warning
}
@@ -80,16 +80,16 @@ int handleVoidInComma() {
int marker(void) { // 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 'doubleM' is nil and returns a value of type '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-darwin9-NOT: 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 '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 'doubleM' is nil and returns a value of type '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 'longDoubleM' is nil and returns a value of type 'long double' 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 641dde2..a707970 100644
--- a/test/Analysis/null-deref-ps.c
+++ b/test/Analysis/null-deref-ps.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wreturn-type
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wreturn-type
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -analyzer-purge=none -verify %s -Wno-error=return-type
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,experimental.deadcode.IdempotentOperations,experimental.core -std=gnu99 -analyzer-store=region -analyzer-constraints=range -verify %s -Wno-error=return-type
typedef unsigned uintptr_t;
@@ -221,7 +221,7 @@ int* f10(int* p, signed char x, int y) {
// This tests that our symbolication worked, and that we correctly test
// x against 0 (with the same bitwidth).
if (!x) {
- if (!p) return; // expected-warning {{non-void function 'f10' should return a value}}
+ if (!p) return 0;
*p = 10;
}
else p = 0;
@@ -289,4 +289,25 @@ void pr4759() {
pr4759_aux(p); // expected-warning{{Function call argument is an uninitialized value}}
}
-
+// Relax function call arguments invalidation to be aware of const
+// arguments. Test with function pointers. radar://10595327
+void ttt(const int *nptr);
+void ttt2(const int *nptr);
+typedef void (*NoConstType)(int*);
+int foo10595327(int b) {
+ void (*fp)(int *);
+ // We use path sensitivity to get the function declaration. Even when the
+ // function pointer is cast to non pointer-to-const parameter type, we can
+ // find the right function declaration.
+ if (b > 5)
+ fp = (NoConstType)ttt2;
+ else
+ fp = (NoConstType)ttt;
+ int x = 3;
+ int y = x + 1;
+ int *p = 0;
+ fp(&y);
+ if (x == y)
+ return *p; // no-warning
+ return 0;
+}
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp
index fc7e7ef..3119b4f 100644
--- a/test/Analysis/nullptr.cpp
+++ b/test/Analysis/nullptr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s
// test to see if nullptr is detected as a null pointer
void foo1(void) {
@@ -39,7 +39,6 @@ void foo4(void) {
*np = 0; // no-warning
}
-
int pr10372(void *& x) {
// GNU null is a pointer-sized integer, not a pointer.
x = __null;
@@ -47,3 +46,38 @@ int pr10372(void *& x) {
return __null;
}
+void zoo1() {
+ char **p = 0;
+ delete *(p + 0); // expected-warning{{Dereference of null pointer}}
+}
+
+void zoo2() {
+ int **a = 0;
+ int **b = 0;
+ asm ("nop"
+ :"=a"(*a)
+ :"0"(*b) // expected-warning{{Dereference of null pointer}}
+ );
+}
+
+int exprWithCleanups() {
+ struct S {
+ S(int a):a(a){}
+ ~S() {}
+
+ int a;
+ };
+
+ int *x = 0;
+ return S(*x).a; // expected-warning{{Dereference of null pointer}}
+}
+
+int materializeTempExpr() {
+ int *n = 0;
+ struct S {
+ int a;
+ S(int i): a(i) {}
+ };
+ const S &s = S(*n); // expected-warning{{Dereference of null pointer}}
+ return s.a;
+}
diff --git a/test/Analysis/objc-arc.m b/test/Analysis/objc-arc.m
index b02af05..e6c6ab5 100644
--- a/test/Analysis/objc-arc.m
+++ b/test/Analysis/objc-arc.m
@@ -3,6 +3,7 @@
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+typedef unsigned long NSUInteger;
@protocol NSObject
- (BOOL)isEqual:(id)object;
@@ -10,12 +11,30 @@ typedef struct _NSZone NSZone;
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@end
-@protocol NSCoding
+@protocol NSCoding;
+@protocol NSMutableCopying;
+@protocol NSFastEnumeration
- (void)encodeWithCoder:(NSCoder *)aCoder;
@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
@interface NSObject <NSObject> {}
+ (id)alloc;
+- (id)init;
+- (NSString *)description;
+@end
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithArray:(NSArray *)array;
@end
+
typedef const struct __CFAllocator * CFAllocatorRef;
extern const CFAllocatorRef kCFAllocatorDefault;
typedef double CFTimeInterval;
@@ -153,3 +172,49 @@ id test_return() {
return x; // no-warning
}
+void test_objc_arrays() {
+ { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0];
+ [a description];
+ [o description];
+ }
+
+ { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
+ NSArray *a2 = [[NSArray alloc] initWithArray:a1];
+ [a2 description];
+ [o description];
+ }
+
+ { // CASE THREE -- OBJECT IN RETAINED @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a3 = @[o];
+ [a3 description];
+ [o description];
+ }
+ {
+ // CASE 4, verify analyzer still working.
+ CFCreateString(); // expected-warning {{leak}}
+ }
+}
+
+// <rdar://problem/11059275> - dispatch_set_context and ARC.
+__attribute__((cf_returns_retained)) CFTypeRef CFBridgingRetain(id X);
+typedef void* dispatch_object_t;
+void dispatch_set_context(dispatch_object_t object, const void *context);
+
+void rdar11059275(dispatch_object_t object) {
+ NSObject *o = [[NSObject alloc] init];
+ dispatch_set_context(object, CFBridgingRetain(o)); // no-warning
+}
+void rdar11059275_positive() {
+ NSObject *o = [[NSObject alloc] init]; // expected-warning {{leak}}
+ CFBridgingRetain(o);
+}
+void rdar11059275_negative() {
+ NSObject *o = [[NSObject alloc] init]; // no-warning
+ (void) o;
+}
+
diff --git a/test/Analysis/objc-bool.m b/test/Analysis/objc-bool.m
new file mode 100644
index 0000000..631cd2d
--- /dev/null
+++ b/test/Analysis/objc-bool.m
@@ -0,0 +1,22 @@
+// RUN: %clang --analyze %s -o %t -verify
+
+// Test handling of ObjC bool literals.
+
+typedef signed char BOOL;
+
+void rdar_10597458() {
+ if (__objc_yes)
+ return;
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+}
+
+void rdar_10597458_b(BOOL b) {
+ if (b == __objc_no)
+ return;
+
+ if (b == __objc_no) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // no-warning
+ }
+}
diff --git a/test/Analysis/objc-method-coverage.m b/test/Analysis/objc-method-coverage.m
new file mode 100644
index 0000000..056aafe
--- /dev/null
+++ b/test/Analysis/objc-method-coverage.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=none -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
+
+@interface I
+int f() {
+ return 0;
+}
+@end
+
+@implementation I
++ (void *)ff{
+ return (void*)0;
+}
+@end
+
+// CHECK: ... Statistics Collected ...
+// CHECK: 2 AnalysisConsumer - The # of functions analysed (as top level). \ No newline at end of file
diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c
index ac2cdc82..a97bba5 100644
--- a/test/Analysis/out-of-bounds.c
+++ b/test/Analysis/out-of-bounds.c
@@ -128,13 +128,11 @@ void test2_multi_ok(int x) {
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
+// Testing if solver handles (symbol * constant) < constant
void test3(int x) {
int buf[100];
if (x < 0)
- buf[x] = 1;
+ buf[x] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
}
// *** FIXME ***
diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m
index 23a260a..83100dc 100644
--- a/test/Analysis/plist-output-alternate.m
+++ b/test/Analysis/plist-output-alternate.m
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o %t %s
+// RUN: FileCheck --input-file %t %s
void test_null_init(void) {
int *p = 0;
@@ -57,7 +58,6 @@ void rdar8331641(int x) {
}
// CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
// CHECK: <plist version="1.0">
// CHECK: <dict>
// CHECK: <key>files</key>
@@ -76,12 +76,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>5</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>5</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -89,13 +89,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -106,7 +106,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -114,17 +114,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -134,9 +135,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -152,12 +155,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -165,13 +168,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -182,7 +185,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -190,17 +193,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -210,9 +214,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -228,12 +234,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -241,13 +247,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -258,7 +264,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -266,17 +272,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>message</key>
@@ -286,9 +293,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -304,12 +313,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -317,12 +326,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -334,7 +343,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -342,17 +351,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: <key>message</key>
@@ -366,12 +376,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -379,13 +389,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -396,7 +406,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -404,17 +414,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -424,9 +435,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>line</key><integer>24</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -442,12 +455,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -455,12 +468,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -469,34 +482,6 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming &apos;q&apos; is null</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming &apos;q&apos; is null</string>
-// CHECK: </dict>
-// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
// CHECK: <array>
@@ -504,12 +489,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -517,12 +502,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -538,12 +523,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>line</key><integer>30</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -551,13 +536,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -568,7 +553,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -576,17 +561,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -596,9 +582,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
+// CHECK: <key>line</key><integer>31</integer>
// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -614,12 +602,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -627,12 +615,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -648,12 +636,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>36</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -661,13 +649,13 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>38</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -678,7 +666,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -686,17 +674,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -706,9 +695,11 @@ void rdar8331641(int x) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>38</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -724,12 +715,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>line</key><integer>53</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>52</integer>
+// CHECK: <key>line</key><integer>53</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -737,12 +728,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -758,12 +749,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -771,12 +762,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -788,7 +779,7 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -796,17 +787,18 @@ void rdar8331641(int x) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
// CHECK: <key>message</key>
@@ -820,12 +812,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>23</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>53</integer>
+// CHECK: <key>line</key><integer>54</integer>
// CHECK: <key>col</key><integer>82</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -833,12 +825,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -854,12 +846,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -867,12 +859,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -881,34 +873,6 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming &apos;x&apos; is 0</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming &apos;x&apos; is 0</string>
-// CHECK: </dict>
-// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
// CHECK: <array>
@@ -916,12 +880,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>54</integer>
+// CHECK: <key>line</key><integer>55</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -929,12 +893,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -950,12 +914,12 @@ void rdar8331641(int x) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -963,12 +927,12 @@ void rdar8331641(int x) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -980,22 +944,25 @@ void rdar8331641(int x) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: <key>message</key>
// CHECK: <string>Object leaked: object allocated and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Potential leak of an object allocated on line 53 and stored into &apos;value&apos;</string>
+// CHECK: <key>description</key><string>Potential leak of an object stored into &apos;value&apos;</string>
// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string>
// CHECK: <key>type</key><string>Leak</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>rdar8331641</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>line</key><integer>58</integer>
// CHECK: <key>col</key><integer>1</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m
index e08ccc4..72e8f8d 100644
--- a/test/Analysis/plist-output.m
+++ b/test/Analysis/plist-output.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-output=plist -o - %s | FileCheck %s
-// XFAIL: *
+// RUN: %clang --analyze %s -o %t > /dev/null 2>&1
+// RUN: FileCheck -input-file %t %s
void test_null_init(void) {
int *p = 0;
@@ -24,9 +24,10 @@ void test_null_cond(int *p) {
*p = 0xDEADBEEF;
}
}
-
+
void test_null_cond_transitive(int *q) {
if (!q) {
+ // FIXME: we need a diagnostic saying that p is initialized to 0
int *p = q;
*p = 0xDEADBEEF;
}
@@ -38,8 +39,48 @@ void test_null_field(void) {
*(x.p) = 0xDEADBEEF;
}
+void test_assumptions(int a, int b)
+{
+ if (a == 0) {
+ return;
+ }
+ if (b != 0) {
+ return;
+ }
+ int *p = 0;
+ *p = 0xDEADBEEF;
+}
+
+int *bar_cond_assign();
+int test_cond_assign() {
+ int *p;
+ if (p = bar_cond_assign())
+ return 1;
+ return *p;
+}
+
+// The following previously crashed when generating extensive diagnostics.
+// <rdar://problem/10797980>
+@interface RDar10797980_help
+@property (readonly) int x;
+@end
+
+@interface RDar10797980 {
+ RDar10797980_help *y;
+}
+- (void) test;
+@end
+
+@implementation RDar10797980
+- (void) test {
+ if (y.x == 1) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{deference}}
+ }
+}
+@end
+
// CHECK: <?xml version="1.0" encoding="UTF-8"?>
-// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
// CHECK: <plist version="1.0">
// CHECK: <dict>
// CHECK: <key>files</key>
@@ -51,10 +92,44 @@ void test_null_field(void) {
// CHECK: <key>path</key>
// CHECK: <array>
// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>6</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -62,22 +137,39 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Variable &apos;p&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Variable &apos;p&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_init</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>6</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -86,26 +178,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
+// CHECK: <key>line</key><integer>10</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>4</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>12</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -116,7 +208,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -124,17 +216,18 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -144,9 +237,11 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>5</integer>
+// CHECK: <key>line</key><integer>12</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -162,12 +257,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>9</integer>
+// CHECK: <key>line</key><integer>16</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -175,12 +270,12 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -192,7 +287,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>19</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -200,22 +295,39 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
-// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Null pointer value stored to &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Null pointer value stored to &apos;p&apos;</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_assign_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>19</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -224,12 +336,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>10</integer>
+// CHECK: <key>line</key><integer>23</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -237,13 +349,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -254,25 +366,89 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>23</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -282,10 +458,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>11</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>24</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -300,12 +478,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>15</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -313,12 +491,12 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
+// CHECK: <key>line</key><integer>29</integer>
// CHECK: <key>col</key><integer>8</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -327,33 +505,118 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>29</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>31</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Variable &apos;q&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Variable &apos;q&apos; initialized to a null pointer value</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_cond_transitive</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>32</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
// CHECK: <key>edges</key>
@@ -362,26 +625,60 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
+// CHECK: <key>line</key><integer>37</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>17</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -392,7 +689,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -400,29 +697,32 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
-// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>line</key><integer>39</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;q&apos;)</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from field &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_null_field</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>18</integer>
+// CHECK: <key>line</key><integer>39</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -438,12 +738,12 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -451,13 +751,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>44</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -465,32 +765,38 @@ void test_null_field(void) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>kind</key><string>event</string>
-// CHECK: <key>location</key>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <key>ranges</key>
-// CHECK: <array>
-// CHECK: <array>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>7</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
-// CHECK: <key>file</key><integer>0</integer>
-// CHECK: </dict>
-// CHECK: </array>
-// CHECK: </array>
-// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming pointer value is null</string>
-// CHECK: <key>message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>44</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -500,26 +806,94 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>22</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>47</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>50</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -530,25 +904,26 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>4</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -558,10 +933,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_assumptions</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>23</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>51</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -576,12 +953,46 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>56</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -589,13 +1000,13 @@ void test_null_field(void) {
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -606,7 +1017,7 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
@@ -614,21 +1025,22 @@ void test_null_field(void) {
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: <key>message</key>
-// CHECK: <string>Assuming pointer value is null</string>
+// CHECK: <string>Assuming &apos;p&apos; is null</string>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -638,26 +1050,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
+// CHECK: <key>line</key><integer>57</integer>
// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>28</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>57</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -672,26 +1084,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>29</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -702,25 +1114,26 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>6</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>11</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
@@ -730,10 +1143,12 @@ void test_null_field(void) {
// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>test_cond_assign</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>30</integer>
-// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>line</key><integer>59</integer>
+// CHECK: <key>col</key><integer>10</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
@@ -748,26 +1163,26 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
+// CHECK: <key>line</key><integer>76</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -782,26 +1197,94 @@ void test_null_field(void) {
// CHECK: <key>start</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>35</integer>
-// CHECK: <key>col</key><integer>10</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>7</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: <key>end</key>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>line</key><integer>76</integer>
// CHECK: <key>col</key><integer>3</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>76</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>77</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
@@ -812,41 +1295,45 @@ void test_null_field(void) {
// CHECK: <key>kind</key><string>event</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <key>ranges</key>
// CHECK: <array>
// CHECK: <array>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>6</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Dereference of null pointer</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>message</key>
-// CHECK: <string>Dereference of null pointer</string>
+// CHECK: <string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: </dict>
// CHECK: </array>
-// CHECK: <key>description</key><string>Dereference of null pointer</string>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable &apos;p&apos;)</string>
// CHECK: <key>category</key><string>Logic error</string>
// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>Objective-C method</string>
+// CHECK: <key>issue_context</key><string>test</string>
// CHECK: <key>location</key>
// CHECK: <dict>
-// CHECK: <key>line</key><integer>37</integer>
-// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>line</key><integer>78</integer>
+// CHECK: <key>col</key><integer>5</integer>
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
+
diff --git a/test/Analysis/pr_2542_rdar_6793404.m b/test/Analysis/pr_2542_rdar_6793404.m
index d5125a6..19c140d 100644
--- a/test/Analysis/pr_2542_rdar_6793404.m
+++ b/test/Analysis/pr_2542_rdar_6793404.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s
// BEGIN delta-debugging reduced header stuff
diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m
index 6d04a4a..4aa9180 100644
--- a/test/Analysis/properties.m
+++ b/test/Analysis/properties.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@@ -143,3 +143,26 @@ void rdar6611873() {
return super.name;
}
@end
+
+// <rdar://problem/9241180> Static analyzer doesn't detect uninitialized variable issues for property accesses
+@interface RDar9241180
+@property (readwrite,assign) id x;
+-(id)testAnalyzer1:(int) y;
+-(void)testAnalyzer2;
+@end
+
+@implementation RDar9241180
+@synthesize x;
+-(id)testAnalyzer1:(int)y {
+ RDar9241180 *o;
+ if (y && o.x) // expected-warning {{Property access on an uninitialized object pointer}}
+ return o;
+ return o; // expected-warning {{Undefined or garbage value returned to caller}}
+}
+-(void)testAnalyzer2 {
+ id y;
+ self.x = y; // expected-warning {{Argument for property setter is an uninitialized value}}
+}
+@end
+
+
diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c
index 995470a..fb37f1c 100644
--- a/test/Analysis/ptr-arith.c
+++ b/test/Analysis/ptr-arith.c
@@ -269,7 +269,7 @@ void symbolic_region(int *p) {
int a;
if (&a == p)
- WARN; // expected-warning{{}}
+ WARN; // no-warning
if (&a != p)
WARN; // expected-warning{{}}
if (&a > p)
diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m
index b2a113c..d710c47 100644
--- a/test/Analysis/rdar-6540084.m
+++ b/test/Analysis/rdar-6540084.m
@@ -10,7 +10,7 @@ typedef struct _NSZone NSZone;
@interface NSObject <NSObject> {} @end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
@class NSArray;
-@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer;
+@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; // expected-note{{forward declaration of class here}}
@interface FooBazController : NSObject {}
@end
typedef struct {} TazVersion;
diff --git a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
index e9711e7..5af4776 100644
--- a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
+++ b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-constraints=basic -analyzer-store=region -verify -Wno-objc-root-class %s
typedef struct Foo { int x; } Bar;
@@ -14,12 +14,12 @@ typedef struct Foo { int x; } Bar;
void createFoo() {
MyClass *obj = 0;
- Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
+ Bar f = [obj foo]; // no-warning
}
void createFoo2() {
MyClass *obj = 0;
[obj foo]; // no-warning
- Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}}
+ Bar f = [obj foo]; // no-warning
}
diff --git a/test/Analysis/redefined_system.c b/test/Analysis/redefined_system.c
new file mode 100644
index 0000000..3f585c4
--- /dev/null
+++ b/test/Analysis/redefined_system.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix,core,experimental.security.taint -w -verify %s
+
+// Make sure we don't crash when someone redefines a system function we reason about.
+
+char memmove ();
+char malloc();
+char system();
+char stdin();
+char memccpy();
+char free();
+char strdup();
+char atoi();
+
+int foo () {
+ return memmove() + malloc() + system + stdin() + memccpy() + free() + strdup() + atoi();
+
+}
diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp
index c7912f4..5897e68 100644
--- a/test/Analysis/reference.cpp
+++ b/test/Analysis/reference.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s
// XFAIL
typedef typeof(sizeof(int)) size_t;
diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m
index 4e1b846..0340a3c 100644
--- a/test/Analysis/retain-release-gc-only.m
+++ b/test/Analysis/retain-release-gc-only.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
// Header stuff.
@@ -279,7 +279,7 @@ void f5b() {
@implementation TestReturnNotOwnedWhenExpectedOwned
- (NSString*)newString {
- NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object allocated}}
+ NSString *s = [NSString stringWithUTF8String:"hello"]; // expected-warning{{Potential leak (when using garbage collection) of an object}}
CFRetain(s);
return s;
}
diff --git a/test/Analysis/retain-release-inline.m b/test/Analysis/retain-release-inline.m
new file mode 100644
index 0000000..610df7f
--- /dev/null
+++ b/test/Analysis/retain-release-inline.m
@@ -0,0 +1,347 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -analyzer-ipa=inlining -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from Mac OS X headers:
+//
+// #include <Cocoa/Cocoa.h>
+// #include <CoreFoundation/CoreFoundation.h>
+// #include <DiskArbitration/DiskArbitration.h>
+// #include <QuartzCore/QuartzCore.h>
+// #include <Quartz/Quartz.h>
+// #include <IOKit/IOKitLib.h>
+//
+// It includes the basic definitions for the test cases below.
+//===----------------------------------------------------------------------===//
+
+typedef unsigned int __darwin_natural_t;
+typedef unsigned long uintptr_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+typedef unsigned int UInt32;
+typedef signed long CFIndex;
+typedef CFIndex CFByteOrder;
+typedef struct {
+ CFIndex location;
+ CFIndex length;
+} CFRange;
+static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
+ CFRange range;
+ range.location = loc;
+ range.length = len;
+ return range;
+}
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern CFTypeRef CFRetain(CFTypeRef cf);
+extern void CFRelease(CFTypeRef cf);
+typedef struct {
+}
+CFArrayCallBacks;
+extern const CFArrayCallBacks kCFTypeArrayCallBacks;
+typedef const struct __CFArray * CFArrayRef;
+typedef struct __CFArray * CFMutableArrayRef;
+extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks);
+extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
+extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value);
+typedef struct {
+}
+CFDictionaryKeyCallBacks;
+extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+typedef struct {
+}
+CFDictionaryValueCallBacks;
+extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef struct __CFDictionary * CFMutableDictionaryRef;
+extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+typedef UInt32 CFStringEncoding;
+enum {
+kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 };
+extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding);
+typedef double CFTimeInterval;
+typedef CFTimeInterval CFAbsoluteTime;
+extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+typedef const struct __CFDate * CFDateRef;
+extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
+extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
+typedef __darwin_natural_t natural_t;
+typedef natural_t mach_port_name_t;
+typedef mach_port_name_t mach_port_t;
+typedef int kern_return_t;
+typedef kern_return_t mach_error_t;
+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 CFIndex CFNumberType;
+typedef const struct __CFNumber * CFNumberRef;
+extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
+typedef const struct __CFAttributedString *CFAttributedStringRef;
+typedef struct __CFAttributedString *CFMutableAttributedStringRef;
+extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ;
+extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ;
+extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ;
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end typedef unsigned short unichar;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+- (void)setObject:(id)anObject forKey:(id)aKey;
+@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
+@end typedef double CGFloat;
+struct CGSize {
+};
+typedef struct CGSize CGSize;
+struct CGRect {
+};
+typedef struct CGRect CGRect;
+typedef mach_port_t io_object_t;
+typedef char io_name_t[128];
+typedef io_object_t io_iterator_t;
+typedef io_object_t io_service_t;
+typedef struct IONotificationPort * IONotificationPortRef;
+typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator );
+io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching );
+kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing );
+kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated));
+kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification );
+CFMutableDictionaryRef IOServiceMatching( const char * name );
+CFMutableDictionaryRef IOServiceNameMatching( const char * name );
+CFMutableDictionaryRef IOBSDNameMatching( mach_port_t masterPort, uint32_t options, const char * bsdName );
+CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, uint32_t options, const char * path );
+CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID );
+typedef struct __DASession * DASessionRef;
+extern DASessionRef DASessionCreate( CFAllocatorRef allocator );
+typedef struct __DADisk * DADiskRef;
+extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name );
+extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media );
+extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk );
+extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk );
+@interface NSTask : NSObject - (id)init;
+@end typedef struct CGColorSpace *CGColorSpaceRef;
+typedef struct CGImage *CGImageRef;
+typedef struct CGLayer *CGLayerRef;
+@interface NSResponder : NSObject <NSCoding> {
+}
+@end @protocol NSAnimatablePropertyContainer - (id)animator;
+@end extern NSString *NSAnimationTriggerOrderIn ;
+@interface NSView : NSResponder <NSAnimatablePropertyContainer> {
+}
+@end @protocol NSValidatedUserInterfaceItem - (SEL)action;
+@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
+@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
+@interface NSApplication : NSResponder <NSUserInterfaceValidations> {
+}
+@end enum {
+NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 };
+typedef NSUInteger NSApplicationTerminateReply;
+@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView;
+@interface NSCell : NSObject <NSCopying, NSCoding> {
+}
+@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+typedef struct {
+}
+CVTimeStamp;
+@interface CIImage : NSObject <NSCoding, NSCopying> {
+}
+typedef int CIFormat;
+@end enum {
+kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C };
+typedef mach_error_t DAReturn;
+typedef const struct __DADissenter * DADissenterRef;
+extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
+@interface CIContext: NSObject {
+}
+- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r;
+- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs;
+- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d;
+@end extern NSString* const QCRendererEventKey;
+@protocol QCCompositionRenderer - (NSDictionary*) attributes;
+@end @interface QCRenderer : NSObject <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end extern NSString* const QCViewDidStartRenderingNotification;
+@interface QCView : NSView <QCCompositionRenderer> {
+}
+- (id) createSnapshotImageOfType:(NSString*)type;
+@end enum {
+ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, };
+@class ICDevice;
+@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device;
+@end extern NSString *const ICScannerStatusWarmingUp;
+@class ICScannerDevice;
+@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner;
+@end
+
+typedef long unsigned int __darwin_size_t;
+typedef __darwin_size_t size_t;
+typedef unsigned long CFTypeID;
+struct CGPoint {
+ CGFloat x;
+ CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+typedef struct CGGradient *CGGradientRef;
+typedef uint32_t CGGradientDrawingOptions;
+extern CFTypeID CGGradientGetTypeID(void);
+extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef
+ space, const CGFloat components[], const CGFloat locations[], size_t count);
+extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space,
+ CFArrayRef colors, const CGFloat locations[]);
+extern CGGradientRef CGGradientRetain(CGGradientRef gradient);
+extern void CGGradientRelease(CGGradientRef gradient);
+typedef struct CGContext *CGContextRef;
+extern void CGContextDrawLinearGradient(CGContextRef context,
+ CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint,
+ CGGradientDrawingOptions options);
+extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
+
+@interface NSMutableArray : NSObject
+- (void)addObject:(id)object;
++ (id)array;
+@end
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void foo(id x) {
+ [x retain];
+}
+
+void bar(id x) {
+ [x release];
+}
+
+void test() {
+ NSString *s = [[NSString alloc] init]; // expected-warning {{Potential leak}}
+ foo(s);
+ foo(s);
+ bar(s);
+}
+void test_neg() {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ foo(s);
+ foo(s);
+ bar(s);
+ bar(s);
+ bar(s);
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning retained and not-retained values.
+//===----------------------------------------------------------------------===//
+
+// On return (intraprocedural), assume CF objects are leaked.
+CFStringRef test_return_ratained_CF(char *bytes) {
+ CFStringRef str;
+ return CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+}
+
+// On return (intraprocedural), assume NSObjects are not leaked.
+id test_return_retained_NS() {
+ return [[NSString alloc] init]; // no-warning
+}
+
+void test_test_return_retained() {
+ id x = test_return_retained_NS(); // expected-warning {{leak}}
+ [x retain];
+ [x release];
+}
+
+//===----------------------------------------------------------------------===//
+// Test not applying "double effects" from inlining and RetainCountChecker summaries.
+// If we inline a call, we should already see its retain/release semantics.
+//===----------------------------------------------------------------------===//
+
+__attribute__((cf_returns_retained)) CFStringRef test_return_inline(CFStringRef x) {
+ CFRetain(x);
+ return x;
+}
+
+void test_test_return_inline(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0);
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+ // After this call, 'str2' and 'str' has a +0 reference count.
+ CFRelease(str2);
+}
+
+void test_test_return_inline_2(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+}
+
+
+
diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m
index 19e6d7b..1e74f00 100644
--- a/test/Analysis/retain-release-path-notes-gc.m
+++ b/test/Analysis/retain-release-path-notes-gc.m
@@ -45,9 +45,9 @@ void creationViaCFCreate () {
void makeCollectable () {
CFTypeRef leaked = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +2 retain count}}
- CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1.}}
+ CFMakeCollectable(leaked); // expected-note{{In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1}}
NSMakeCollectable(leaked); // expected-note{{In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector}}
- CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again.}}
+ CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again}}
return; // expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}
@@ -61,12 +61,12 @@ void retainReleaseIgnored () {
@implementation Foo (FundamentalRuleUnderGC)
- (id)getViolation {
- id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected.}}
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
}
- (id)copyViolation {
- id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected.}}
+ id object = (id) CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected}}
return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector}}
}
@end
diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m
index e34942a..c3f5fcd 100644
--- a/test/Analysis/retain-release-path-notes.m
+++ b/test/Analysis/retain-release-path-notes.m
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s
+// This actually still works after the pseudo-object refactor, it just
+// uses messages that say 'method' instead of 'property'. Ted wanted
+// this xfailed and filed as a bug. rdar://problem/10402993
+
/***
This file is for testing the path-sensitive notes for retain/release errors.
Its goal is to have simple branch coverage of any path-based diagnostics,
@@ -100,13 +104,13 @@ void makeCollectableIgnored () {
}
CFTypeRef CFCopyRuleViolation () {
- CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain counte}}
+ CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
}
CFTypeRef CFGetRuleViolation () {
- CFTypeRef object = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain counte}}
- return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is return from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given the Memory Management Guide for Core Foundation}}
+ CFTypeRef object = CFCreateSomething(); // expected-warning{{leak}} expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+ return object; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
}
@implementation Foo (FundamentalMemoryManagementRules)
@@ -119,4 +123,10 @@ CFTypeRef CFGetRuleViolation () {
id result = [[Foo alloc] init]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +1 retain count}}
return result; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}}
}
+
+- (id)copyAutorelease {
+ id result = [[Foo alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+ [result autorelease]; // expected-note{{Object sent -autorelease message}}
+ return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
+}
@end
diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m
index 89950ce..9173813 100644
--- a/test/Analysis/retain-release-region-store.m
+++ b/test/Analysis/retain-release-region-store.m
@@ -100,6 +100,10 @@ struct foo {
NSDate* f;
};
+// FIXME: We should be warning about a use-after-free here, but we
+// temporarily "escape" retain counted objects stored to structs very eagerly
+// until we can properly tell whether they have escaped via a return value
+// or not.
CFAbsoluteTime f4() {
struct foo x;
@@ -110,7 +114,8 @@ CFAbsoluteTime f4() {
CFDateGetAbsoluteTime(date); // no-warning
x.f = (NSDate*) date;
[((NSDate*) date) release];
- t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released.}}
+ // FIXME: the following line should warn.
+ t = CFDateGetAbsoluteTime(date); // no-warning
return t;
}
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 6f8bf09..06c510e 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-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -Wno-objc-root-class %s
#if __has_feature(attribute_ns_returns_retained)
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
@@ -42,6 +42,7 @@ typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef unsigned int UInt32;
typedef signed long CFIndex;
+typedef CFIndex CFByteOrder;
typedef struct {
CFIndex location;
CFIndex length;
@@ -114,10 +115,15 @@ typedef struct _NSZone NSZone;
- (id)retain;
- (oneway void)release;
- (id)autorelease;
+- (NSString *)description;
- (id)init;
-@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
-@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
-@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+@end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
+ (id)allocWithZone:(NSZone *)zone;
@@ -131,13 +137,22 @@ extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
typedef struct {
}
NSFastEnumerationState;
-@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
-@end @class NSString, NSDictionary;
+@protocol NSFastEnumeration
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@class NSString, NSDictionary;
@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
@end @interface NSNumber : NSValue - (char)charValue;
- (id)initWithInt:(int)value;
@end @class NSString;
-@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
++ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithArray:(NSArray *)array;
@end @interface NSArray (NSArrayCreation) + (id)array;
@end @interface NSAutoreleasePool : NSObject {
}
@@ -157,8 +172,12 @@ typedef double NSTimeInterval;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary;
-@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
-@end @interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
+@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id)aKey;
@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems;
@end typedef double CGFloat;
@@ -671,7 +690,7 @@ void rdar6704930(unsigned char *s, unsigned int length) {
//===----------------------------------------------------------------------===//
// <rdar://problem/6257780> clang checker fails to catch use-after-release
//===----------------------------------------------------------------------===//
-
+
int rdar_6257780_Case1() {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSArray *array = [NSArray array];
@@ -681,6 +700,15 @@ int rdar_6257780_Case1() {
}
//===----------------------------------------------------------------------===//
+// <rdar://problem/10640253> Analyzer is confused about NSAutoreleasePool -allocWithZone:.
+//===----------------------------------------------------------------------===//
+
+void rdar_10640253_autorelease_allocWithZone() {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init];
+ (void) pool;
+}
+
+//===----------------------------------------------------------------------===//
// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs
//===----------------------------------------------------------------------===//
@@ -1458,7 +1486,7 @@ static void rdar_8724287(CFErrorRef error)
while (error_to_dump != ((void*)0)) {
CFDictionaryRef info;
- info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object allocated on line}}
+ info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}}
if (info != ((void*)0)) {
}
@@ -1604,3 +1632,110 @@ void rdar10232019_positive() {
NSLog(@"%@", otherString);
}
+// RetainCountChecker support for XPC.
+// <rdar://problem/9658496>
+typedef void * xpc_object_t;
+xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf);
+void xpc_release(xpc_object_t object);
+
+void rdar9658496() {
+ CFStringRef cf;
+ xpc_object_t xpc;
+ cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ xpc = _CFXPCCreateXPCObjectFromCFObject( cf );
+ CFRelease(cf);
+ xpc_release(xpc);
+}
+
+// Support annotations with method families.
+@interface RDar10824732 : NSObject
+- (id)initWithObj:(id CF_CONSUMED)obj;
+@end
+
+@implementation RDar10824732
+- (id)initWithObj:(id)obj {
+ [obj release];
+ return [super init];
+}
+@end
+
+void rdar_10824732() {
+ @autoreleasepool {
+ NSString *obj = @"test";
+ RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
+ [foo release];
+ }
+}
+
+//===----------------------------------------------------------------------===//
+// Test returning allocated memory in a struct.
+//
+// We currently don't have a general way to track pointers that "escape".
+// Here we test that RetainCountChecker doesn't get excited about returning
+// allocated CF objects in struct fields.
+//===----------------------------------------------------------------------===//
+void *malloc(size_t);
+struct rdar11104566 { CFStringRef myStr; };
+struct rdar11104566 test_rdar11104566() {
+ CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ struct rdar11104566 V;
+ V.myStr = cf;
+ return V; // no-warning
+}
+
+struct rdar11104566 *test_2_rdar11104566() {
+ CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning
+ struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V));
+ V->myStr = cf;
+ return V; // no-warning
+}
+
+//===----------------------------------------------------------------------===//
+// ObjC literals support.
+//===----------------------------------------------------------------------===//
+
+void test_objc_arrays() {
+ { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}}
+ [o release];
+ [a description];
+ [o description];
+ }
+
+ { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0];
+ NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}}
+ [o release];
+ [a2 description];
+ [o description];
+ }
+
+ { // CASE THREE -- OBJECT IN RETAINED @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a3 = [@[o] retain]; // expected-warning {{leak}}
+ [o release];
+ [a3 description];
+ [o description];
+ }
+
+ { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[]
+ NSObject *o = [[NSObject alloc] init];
+ NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}}
+ [o release];
+
+ [a description];
+ [o description];
+ }
+
+ { // CASE FIVE -- OBJECT IN RETAINED @{}
+ NSValue *o = [[NSValue alloc] init];
+ NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}}
+ [o release];
+
+ [a description];
+ [o description];
+ }
+}
+
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
index bae8dc3..01727ea 100644
--- a/test/Analysis/retain-release.mm
+++ b/test/Analysis/retain-release.mm
@@ -111,6 +111,7 @@ typedef struct _NSZone NSZone;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
+- (id)copy;
- (oneway void)release;
- (id)autorelease;
@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@@ -304,6 +305,12 @@ void test_smartpointer_3() {
foo.noAdopt(x);
}
+void test_smartpointer_4() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer *foo = new SmartPointer(x);
+ delete foo;
+}
+
extern CFStringRef ElectronMicroscopyEngage(void);
void test_microscopy() {
NSString *token = (NSString*) ElectronMicroscopyEngage();
@@ -315,3 +322,47 @@ void test_Scopy() {
NSString *token = (NSString*) Scopy();
[token release]; // expected-warning {{object that is not owned}}
}
+
+//===----------------------------------------------------------------------===//
+// Test handling of template functions used to do magic with
+// tracked retained pointers.
+//===----------------------------------------------------------------------===//
+
+template <typename T, typename U> T static_objc_cast(U* value)
+{
+ // ...debugging code omitted...
+ return static_cast<T>(value);
+}
+
+int rdar10553686(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ return 0;
+}
+int rdar10553686_positive(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ [bar retain]; // expected-warning {{used after it is released}}
+ return 0;
+}
+
+@interface NSMapTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
+@end
+extern void *NSMapGet(NSMapTable *table, const void *key);
+extern void NSMapInsert(NSMapTable *table, const void *key, const void *value);
+extern void NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value);
+char *strdup(const char *s);
+
+NSString * radar11152419(NSString *string1, NSString *key1, NSMapTable *map) {
+ NSString *string = ( NSString *)NSMapGet(map, key1);
+ if (!string) {
+ string = [string1 copy];
+ NSString *key = [key1 copy];
+ NSMapInsert(map, (void*) key, (void*)string); // no warning
+ NSMapInsertKnownAbsent(map, (void*)key, (void*)string); // no warning
+ }
+ return string;
+}
+
diff --git a/test/Analysis/security-syntax-checks-no-emit.c b/test/Analysis/security-syntax-checks-no-emit.c
index cbd432a..c2869ca 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-checker=experimental.security.SecuritySyntactic %s -verify
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %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 a04401b..f4ccefe 100644
--- a/test/Analysis/security-syntax-checks.m
+++ b/test/Analysis/security-syntax-checks.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.SecuritySyntactic %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
#ifdef USE_BUILTINS
# define BUILTIN(f) __builtin_ ## f
@@ -138,7 +138,7 @@ void test_strcpy() {
char x[4];
char *y;
- strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncpy'. CWE-119.}}
+ strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119.}}
}
//===----------------------------------------------------------------------===
@@ -162,7 +162,7 @@ void test_strcat() {
char x[4];
char *y;
- strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strncat'. CWE-119.}}
+ strcat(x, y); //expected-warning{{Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119.}}
}
//===----------------------------------------------------------------------===
@@ -175,3 +175,25 @@ pid_t vfork(void);
void test_vfork() {
vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process.}}
}
+
+//===----------------------------------------------------------------------===
+// mkstemp()
+//===----------------------------------------------------------------------===
+
+char *mkdtemp(char *template);
+int mkstemps(char *template, int suffixlen);
+int mkstemp(char *template);
+char *mktemp(char *template);
+
+void test_mkstemp() {
+ mkstemp("XX"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (2 'X's seen)}}
+ mkstemp("XXXXXX");
+ mkstemp("XXXXXXX");
+ mkstemps("XXXXXX", 0);
+ mkstemps("XXXXXX", 1); // expected-warning {{5 'X's seen}}
+ mkstemps("XXXXXX", 2); // expected-warning {{Call to 'mkstemps' should have at least 6 'X's in the format string to be secure (4 'X's seen, 2 characters used as a suffix)}}
+ mkdtemp("XX"); // expected-warning {{2 'X's seen}}
+ mkstemp("X"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (1 'X' seen)}}
+ mkdtemp("XXXXXX");
+}
+
diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m
index 019fdcd..3db42e9 100644
--- a/test/Analysis/self-init.m
+++ b/test/Analysis/self-init.m
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.SelfInit %s -verify
+// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit %s -verify
@class NSZone, NSCoder;
-@protocol NSObject
-@end
+@protocol NSObject- (id)self;
+@end
@protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
@@ -22,9 +22,14 @@
//#import "Foundation/NSObject.h"
typedef unsigned NSUInteger;
-typedef int NSInteger;
+typedef long NSInteger;
+
+@interface NSInvocation : NSObject {}
+- (void)getArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+- (void)setArgument:(void *)argumentLocation atIndex:(NSInteger)idx;
+@end
-@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@class NSMethodSignature, NSCoder, NSString, NSEnumerator;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@@ -147,13 +152,30 @@ static id _commonInit(MyObj *self) {
}
-(id)init14 {
- if (!(self = [super init]))
- return 0;
if (!(self = _commonInit(self)))
return 0;
return self;
}
+-(id)init15 {
+ if (!(self = [super init]))
+ return 0;
+ return self;
+}
+
+-(id)init16 {
+ somePtr = [super init];
+ self = somePtr;
+ myivar = 0;
+ return self;
+}
+
+-(id)init17 {
+ somePtr = [super init];
+ myivar = 0; // expected-warning {{Instance variable used}}
+ return 0;
+}
+
-(void)doSomething {}
@end
@@ -163,3 +185,19 @@ static id _commonInit(MyObj *self) {
- (id)init { return self; }
@end
+
+
+// Test for radar://10973514 : self should not be invalidated by a method call.
+@interface Test : NSObject {
+ NSInvocation *invocation_;
+}
+@end
+@implementation Test
+-(id) initWithTarget:(id) rec selector:(SEL) cb {
+ if (self=[super init]) {
+ [invocation_ setArgument:&self atIndex:2];
+ }
+ return self;
+}
+@end
+
diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c
index 558986d..a443a32 100644
--- a/test/Analysis/stack-addr-ps.c
+++ b/test/Analysis/stack-addr-ps.c
@@ -57,8 +57,15 @@ int struct_test(struct baz byVal, int flag) {
typedef int (^ComparatorBlock)(int a, int b);
ComparatorBlock test_return_block(void) {
+ // This block is a global since it has no captures.
ComparatorBlock b = ^int(int a, int b){ return a > b; };
- return b; // expected-warning{{Address of stack-allocated block declared on line 60 returned to caller}}
+ return b; // no-warning
+}
+
+ComparatorBlock test_return_block_with_capture(int x) {
+ // This block is stack allocated because it has captures.
+ ComparatorBlock b = ^int(int a, int b){ return a > b + x; };
+ return b; // expected-warning{{Address of stack-allocated block}}
}
ComparatorBlock test_return_block_neg_aux(void);
@@ -73,4 +80,13 @@ int *rdar_7523821_f2() {
return a; // expected-warning 2 {{ddress of stack memory associated with local variable 'a' returned}}
};
+// Handle blocks that have no captures or are otherwise declared 'static'.
+// <rdar://problem/10348049>
+typedef int (^RDar10348049)(int value);
+RDar10348049 test_rdar10348049(void) {
+ static RDar10348049 b = ^int(int x) {
+ return x + 2;
+ };
+ return b; // no-warning
+}
diff --git a/test/Analysis/stats.c b/test/Analysis/stats.c
new file mode 100644
index 0000000..6beadbe
--- /dev/null
+++ b/test/Analysis/stats.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s
+
+void foo() {
+ int x;
+}
+// CHECK: ... Statistics Collected ...
+// CHECK:100 AnalysisConsumer - The % of reachable basic blocks.
+// CHECK:The # of times RemoveDeadBindings is called
diff --git a/test/Analysis/string.c b/test/Analysis/string.c
index a71e1f0..c0814b8 100644
--- a/test/Analysis/string.c
+++ b/test/Analysis/string.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
//===----------------------------------------------------------------------===
// Declarations
@@ -26,6 +26,7 @@
#define NULL 0
typedef typeof(sizeof(int)) size_t;
+int scanf(const char *restrict format, ...);
//===----------------------------------------------------------------------===
// strlen()
@@ -132,6 +133,18 @@ void strlen_indirect(char *x) {
(void)*(char*)0; // expected-warning{{null}}
}
+void strlen_indirect2(char *x) {
+ size_t a = strlen(x);
+ char *p = x;
+ char **p2 = &p;
+ extern void use_string_ptr2(char**);
+ use_string_ptr2(p2);
+
+ size_t c = strlen(x);
+ if (a == 0 && c != 0)
+ (void)*(char*)0; // expected-warning{{null}}
+}
+
void strlen_liveness(const char *x) {
if (strlen(x) < 5)
return;
@@ -284,6 +297,10 @@ void strcpy_fn(char *x) {
strcpy(x, (char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
}
+void strcpy_fn_const(char *x) {
+ strcpy(x, (const char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
+}
+
void strcpy_effects(char *x, char *y) {
char a = x[0];
@@ -436,6 +453,13 @@ void strcat_symbolic_src_length(char *src) {
(void)*(char*)0; // no-warning
}
+void strcat_symbolic_dst_length_taint(char *dst) {
+ scanf("%s", dst); // Taint data.
+ strcat(dst, "1234");
+ if (strlen(dst) < 4)
+ (void)*(char*)0; // no-warning
+}
+
void strcat_unknown_src_length(char *src, int offset) {
char dst[8] = "1234";
strcat(dst, &src[offset]);
diff --git a/test/Analysis/system-header-simulator-objc.h b/test/Analysis/system-header-simulator-objc.h
new file mode 100644
index 0000000..92d5899
--- /dev/null
+++ b/test/Analysis/system-header-simulator-objc.h
@@ -0,0 +1,114 @@
+#pragma clang system_header
+
+typedef unsigned int UInt32;
+typedef unsigned short UInt16;
+
+typedef signed long CFIndex;
+typedef signed char BOOL;
+typedef unsigned long NSUInteger;
+typedef unsigned short unichar;
+typedef UInt16 UniChar;
+
+enum {
+ NSASCIIStringEncoding = 1,
+ NSNEXTSTEPStringEncoding = 2,
+ NSJapaneseEUCStringEncoding = 3,
+ NSUTF8StringEncoding = 4,
+ NSISOLatin1StringEncoding = 5,
+ NSSymbolStringEncoding = 6,
+ NSNonLossyASCIIStringEncoding = 7,
+};
+typedef const struct __CFString * CFStringRef;
+typedef struct __CFString * CFMutableStringRef;
+typedef NSUInteger NSStringEncoding;
+typedef UInt32 CFStringEncoding;
+
+typedef const void * CFTypeRef;
+
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+extern const CFAllocatorRef kCFAllocatorSystemDefault;
+extern const CFAllocatorRef kCFAllocatorMalloc;
+extern const CFAllocatorRef kCFAllocatorMallocZone;
+extern const CFAllocatorRef kCFAllocatorNull;
+
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
+- (id)retain;
+- (id)copy;
+- (oneway void)release;
+- (id)autorelease;
+- (id)init;
+@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
+@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone;
+@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+@interface NSObject (NSCoderMethods)
+- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;
+@end
+extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
+typedef struct {
+}
+NSFastEnumerationState;
+@protocol NSFastEnumeration - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end @class NSString, NSDictionary;
+@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value;
+@end @interface NSNumber : NSValue - (char)charValue;
+- (id)initWithInt:(int)value;
+@end @class NSString;
+@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count;
+@end @interface NSArray (NSArrayCreation) + (id)array;
+@end @interface NSAutoreleasePool : NSObject {
+}
+- (void)drain;
+@end extern NSString * const NSBundleDidLoadNotification;
+typedef double NSTimeInterval;
+@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
+@end
+
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- ( const char *)UTF8String;
+- (id)initWithUTF8String:(const char *)nullTerminatedCString;
+- (id)initWithCharactersNoCopy:(unichar *)characters length:(NSUInteger)length freeWhenDone:(BOOL)freeBuffer;
+- (id)initWithCharacters:(const unichar *)characters length:(NSUInteger)length;
+- (id)initWithBytes:(const void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer;
++ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
+@end @class NSString, NSURL, NSError;
+@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
++ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length;
+- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b;
+@end
+
+typedef struct {
+}
+CFDictionaryKeyCallBacks;
+extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+typedef struct {
+}
+CFDictionaryValueCallBacks;
+extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+typedef const struct __CFDictionary * CFDictionaryRef;
+typedef struct __CFDictionary * CFMutableDictionaryRef;
+extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
+void CFDictionarySetValue(CFMutableDictionaryRef, const void *, const void *);
+
+
+extern void CFRelease(CFTypeRef cf);
+
+extern CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator);
+extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
+extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
diff --git a/test/Analysis/system-header-simulator.h b/test/Analysis/system-header-simulator.h
new file mode 100644
index 0000000..6212131
--- /dev/null
+++ b/test/Analysis/system-header-simulator.h
@@ -0,0 +1,38 @@
+#pragma clang system_header
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+// Include a variant of standard streams that occur in the pre-processed file.
+extern FILE *__stdinp;
+extern FILE *__stdoutp;
+extern FILE *__stderrp;
+
+
+int fscanf(FILE *restrict, const char *restrict, ...);
+
+// Note, on some platforms errno macro gets replaced with a function call.
+extern int errno;
+
+unsigned long strlen(const char *);
+
+char *strcpy(char *restrict, const char *restrict);
+
+typedef unsigned long __darwin_pthread_key_t;
+typedef __darwin_pthread_key_t pthread_key_t;
+int pthread_setspecific(pthread_key_t, const void *);
+
+typedef long long __int64_t;
+typedef __int64_t __darwin_off_t;
+typedef __darwin_off_t fpos_t;
+
+void setbuf(FILE * restrict, char * restrict);
+int setvbuf(FILE * restrict, char * restrict, int, size_t);
+
+FILE *funopen(const void *,
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ fpos_t (*)(void *, fpos_t, int),
+ int (*)(void *));
+
diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c
new file mode 100644
index 0000000..b00372a
--- /dev/null
+++ b/test/Analysis/taint-generic.c
@@ -0,0 +1,185 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,core,experimental.security.ArrayBoundV2 -Wno-format-security -verify %s
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int sprintf(char *str, const char *format, ...);
+void setproctitle(const char *fmt, ...);
+typedef __typeof(sizeof(int)) size_t;
+
+// Define string functions. Use builtin for some of them. They all default to
+// the processing in the taint checker.
+#define strcpy(dest, src) \
+ ((__builtin_object_size(dest, 0) != -1ULL) \
+ ? __builtin___strcpy_chk (dest, src, __builtin_object_size(dest, 1)) \
+ : __inline_strcpy_chk(dest, src))
+
+static char *__inline_strcpy_chk (char *dest, const char *src) {
+ return __builtin___strcpy_chk(dest, src, __builtin_object_size(dest, 1));
+}
+char *stpcpy(char *restrict s1, const char *restrict s2);
+char *strncpy( char * destination, const char * source, size_t num );
+char *strndup(const char *s, size_t n);
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+void *malloc(size_t);
+void *calloc(size_t nmemb, size_t size);
+void bcopy(void *s1, void *s2, size_t n);
+
+#define BUFSIZE 10
+
+int Buffer[BUFSIZE];
+void bufferScanfDirect(void)
+{
+ int n;
+ scanf("%d", &n);
+ Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic1(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = (n - 3);
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfArithmetic2(int x) {
+ int n;
+ scanf("%d", &n);
+ int m = 100 - (n + 3) * x;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void bufferScanfAssignment(int x) {
+ int n;
+ scanf("%d", &n);
+ int m;
+ if (x > 0) {
+ m = n;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+ }
+}
+
+void scanfArg() {
+ int t = 0;
+ scanf("%d", t); // expected-warning {{format specifies type 'int *' but the argument has type 'int'}}
+}
+
+void bufferGetchar(int x) {
+ int m = getchar();
+ Buffer[m] = 1; //expected-warning {{Out of bound memory access (index is tainted)}}
+}
+
+void testUncontrolledFormatString(char **p) {
+ char s[80];
+ fscanf(stdin, "%s", s);
+ char buf[128];
+ sprintf(buf,s); // expected-warning {{Uncontrolled Format String}}
+ setproctitle(s, 3); // expected-warning {{Uncontrolled Format String}}
+
+ // Test taint propagation through strcpy and family.
+ char scpy[80];
+ strcpy(scpy, s);
+ sprintf(buf,scpy); // expected-warning {{Uncontrolled Format String}}
+
+ stpcpy(*(++p), s); // this generates __inline.
+ setproctitle(*(p), 3); // expected-warning {{Uncontrolled Format String}}
+
+ char spcpy[80];
+ stpcpy(spcpy, s);
+ setproctitle(spcpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *spcpyret;
+ spcpyret = stpcpy(spcpy, s);
+ setproctitle(spcpyret, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char sncpy[80];
+ strncpy(sncpy, s, 20);
+ setproctitle(sncpy, 3); // expected-warning {{Uncontrolled Format String}}
+
+ char *dup;
+ dup = strndup(s, 20);
+ setproctitle(dup, 3); // expected-warning {{Uncontrolled Format String}}
+
+}
+
+int system(const char *command);
+void testTaintSystemCall() {
+ char buffer[156];
+ char addr[128];
+ scanf("%s", addr);
+ system(addr); // expected-warning {{Untrusted data is passed to a system call}}
+
+ // Test that spintf transfers taint.
+ sprintf(buffer, "/bin/mail %s < /tmp/email", addr);
+ system(buffer); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall2() {
+ // Test that snpintf transfers taint.
+ char buffern[156];
+ char addr[128];
+ scanf("%s", addr);
+ __builtin_snprintf(buffern, 10, "/bin/mail %s < /tmp/email", addr);
+ system(buffern); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintSystemCall3() {
+ char buffern2[156];
+ int numt;
+ char addr[128];
+ scanf("%s %d", addr, &numt);
+ __builtin_snprintf(buffern2, numt, "/bin/mail %s < /tmp/email", "abcd");
+ system(buffern2); // expected-warning {{Untrusted data is passed to a system call}}
+}
+
+void testTaintedBufferSize() {
+ size_t ts;
+ scanf("%zd", &ts);
+
+ int *buf1 = (int*)malloc(ts*sizeof(int)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ char *dst = (char*)calloc(ts, sizeof(char)); //expected-warning {{Untrusted data is used to specify the buffer size}}
+ bcopy(buf1, dst, ts); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ __builtin_memcpy(dst, buf1, (ts + 4)*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+
+ // If both buffers are trusted, do not issue a warning.
+ char *dst2 = (char*)malloc(ts*sizeof(char)); // expected-warning {{Untrusted data is used to specify the buffer size}}
+ strncat(dst2, dst, ts); // no-warning
+}
+
+#define AF_UNIX 1 /* local to host (pipes) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_LOCAL AF_UNIX /* backward compatibility */
+#define SOCK_STREAM 1
+int socket(int, int, int);
+size_t read(int, void *, size_t);
+int execl(const char *, const char *, ...);
+
+void testSocket() {
+ int sock;
+ char buffer[100];
+
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
+
+ sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+ read(sock, buffer, 100);
+ execl(buffer, "filename", 0); // no-warning
+}
+
+int testDivByZero() {
+ int x;
+ scanf("%d", &x);
+ return 5/x; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+// Zero-sized VLAs.
+void testTaintedVLASize() {
+ int x;
+ scanf("%d", &x);
+ int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}}
+}
diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c
new file mode 100644
index 0000000..3773335
--- /dev/null
+++ b/test/Analysis/taint-tester.c
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#include <stdarg.h>
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+typedef __typeof(sizeof(int)) size_t;
+
+#define BUFSIZE 10
+int Buffer[BUFSIZE];
+
+struct XYStruct {
+ int x;
+ int y;
+ char z;
+};
+
+void taintTracking(int x) {
+ int n;
+ int *addr = &Buffer[0];
+ scanf("%d", &n);
+ addr += n;// expected-warning + {{tainted}}
+ *addr = n; // expected-warning + {{tainted}}
+
+ double tdiv = n / 30; // expected-warning+ {{tainted}}
+ char *loc_cast = (char *) n; // expected-warning +{{tainted}}
+ char tinc = tdiv++; // expected-warning + {{tainted}}
+ int tincdec = (char)tinc--; // expected-warning+{{tainted}}
+
+ // Tainted ptr arithmetic/array element address.
+ int tprtarithmetic1 = *(addr+1); // expected-warning + {{tainted}}
+
+ // Dereference.
+ int *ptr;
+ scanf("%p", &ptr);
+ int ptrDeref = *ptr; // expected-warning + {{tainted}}
+ int _ptrDeref = ptrDeref + 13; // expected-warning + {{tainted}}
+
+ // Pointer arithmetic + dereferencing.
+ // FIXME: We fail to propagate the taint here because RegionStore does not
+ // handle ElementRegions with symbolic indexes.
+ int addrDeref = *addr; // expected-warning + {{tainted}}
+ int _addrDeref = addrDeref;
+
+ // Tainted struct address, casts.
+ struct XYStruct *xyPtr = 0;
+ scanf("%p", &xyPtr);
+ void *tXYStructPtr = xyPtr; // expected-warning + {{tainted}}
+ struct XYStruct *xyPtrCopy = tXYStructPtr; // expected-warning + {{tainted}}
+ int ptrtx = xyPtr->x;// expected-warning + {{tainted}}
+ int ptrty = xyPtr->y;// expected-warning + {{tainted}}
+
+ // Taint on fields of a struct.
+ struct XYStruct xy = {2, 3, 11};
+ scanf("%d", &xy.y);
+ scanf("%d", &xy.x);
+ int tx = xy.x; // expected-warning + {{tainted}}
+ int ty = xy.y; // FIXME: This should be tainted as well.
+ char ntz = xy.z;// no warning
+ // Now, scanf scans both.
+ scanf("%d %d", &xy.y, &xy.x);
+ int ttx = xy.x; // expected-warning + {{tainted}}
+ int tty = xy.y; // expected-warning + {{tainted}}
+}
+
+void BitwiseOp(int in, char inn) {
+ // Taint on bitwise operations, integer to integer cast.
+ int m;
+ int x = 0;
+ scanf("%d", &x);
+ int y = (in << (x << in)) * 5;// expected-warning + {{tainted}}
+ // The next line tests integer to integer cast.
+ int z = y & inn; // expected-warning + {{tainted}}
+ if (y == 5) // expected-warning + {{tainted}}
+ m = z | z;// expected-warning + {{tainted}}
+ else
+ m = inn;
+ int mm = m; // expected-warning + {{tainted}}
+}
+
+// Test getenv.
+char *getenv(const char *name);
+void getenvTest(char *home) {
+ home = getenv("HOME"); // expected-warning + {{tainted}}
+ if (home != 0) { // expected-warning + {{tainted}}
+ char d = home[0]; // expected-warning + {{tainted}}
+ }
+}
+
+typedef struct _FILE FILE;
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+int fscanf(FILE *restrict stream, const char *restrict format, ...);
+int fprintf(FILE *stream, const char *format, ...);
+int fclose(FILE *stream);
+FILE *fopen(const char *path, const char *mode);
+
+int fscanfTest(void) {
+ FILE *fp;
+ char s[80];
+ int t;
+
+ // Check if stdin is treated as tainted.
+ fscanf(stdin, "%s %d", s, &t);
+ // Note, here, s is not tainted, but the data s points to is tainted.
+ char *ts = s;
+ char tss = s[0]; // expected-warning + {{tainted}}
+ int tt = t; // expected-warning + {{tainted}}
+ if((fp=fopen("test", "w")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fprintf(fp, "%s %d", s, t); // expected-warning + {{tainted}}
+ fclose(fp); // expected-warning + {{tainted}}
+
+ // Test fscanf and fopen.
+ if((fp=fopen("test","r")) == 0) // expected-warning + {{tainted}}
+ return 1;
+ fscanf(fp, "%s%d", s, &t); // expected-warning + {{tainted}}
+ fprintf(stdout, "%s %d", s, t); // expected-warning + {{tainted}}
+ return 0;
+}
+
+// Check if we propagate taint from stdin when it's used in an assignment.
+void stdinTest1() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ int j = i; // expected-warning + {{tainted}}
+}
+void stdinTest2(FILE *pIn) {
+ FILE *p = stdin;
+ FILE *pp = p;
+ int ii;
+
+ fscanf(pp, "%d", &ii);
+ int jj = ii;// expected-warning + {{tainted}}
+
+ fscanf(p, "%d", &ii);
+ int jj2 = ii;// expected-warning + {{tainted}}
+
+ ii = 3;
+ int jj3 = ii;// no warning
+
+ p = pIn;
+ fscanf(p, "%d", &ii);
+ int jj4 = ii;// no warning
+}
+
+void stdinTest3() {
+ FILE **ppp = &stdin;
+ int iii;
+ fscanf(*ppp, "%d", &iii);
+ int jjj = iii;// expected-warning + {{tainted}}
+}
+
+// Test that stdin does not get invalidated by calls.
+void foo();
+void stdinTest4() {
+ int i;
+ fscanf(stdin, "%d", &i);
+ foo();
+ int j = i; // expected-warning + {{tainted}}
+}
+
+int getw(FILE *);
+void getwTest() {
+ int i = getw(stdin); // expected-warning + {{tainted}}
+}
+
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ while ((read = getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // expected-warning + {{tainted}}
+ }
+ free(line); // expected-warning + {{tainted}}
+}
+
+// Test propagation functions - the ones that propagate taint from arguments to
+// return value, ptr arguments.
+
+int atoi(const char *nptr);
+long atol(const char *nptr);
+long long atoll(const char *nptr);
+
+void atoiTest() {
+ char s[80];
+ scanf("%s", s);
+ int d = atoi(s); // expected-warning + {{tainted}}
+ int td = d; // expected-warning + {{tainted}}
+
+ long l = atol(s); // expected-warning + {{tainted}}
+ int tl = l; // expected-warning + {{tainted}}
+
+ long long ll = atoll(s); // expected-warning + {{tainted}}
+ int tll = ll; // expected-warning + {{tainted}}
+
+}
+
diff --git a/test/Analysis/taint-tester.cpp b/test/Analysis/taint-tester.cpp
new file mode 100644
index 0000000..679fbc2
--- /dev/null
+++ b/test/Analysis/taint-tester.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+typedef struct _FILE FILE;
+typedef __typeof(sizeof(int)) size_t;
+extern FILE *stdin;
+typedef long ssize_t;
+ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+int printf(const char * __restrict, ...);
+void free(void *ptr);
+
+struct GetLineTestStruct {
+ ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict);
+};
+
+void getlineTest(void) {
+ FILE *fp;
+ char *line = 0;
+ size_t len = 0;
+ ssize_t read;
+ struct GetLineTestStruct T;
+
+ while ((read = T.getline(&line, &len, stdin)) != -1) {
+ printf("%s", line); // no warning
+ }
+ free(line);
+}
diff --git a/test/Analysis/taint-tester.m b/test/Analysis/taint-tester.m
new file mode 100644
index 0000000..ae55c66
--- /dev/null
+++ b/test/Analysis/taint-tester.m
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest %s -verify
+
+#import <stdarg.h>
+
+@interface NSString
+- (NSString *)stringByAppendingString:(NSString *)aString;
+@end
+extern void NSLog (NSString *format, ...);
+extern void NSLogv(NSString *format, va_list args);
+
+void TestLog (NSString *format, ...);
+void TestLog (NSString *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ NSString *string = @"AAA: ";
+
+ NSLogv([string stringByAppendingString:format], ap);
+
+ va_end(ap);
+} \ No newline at end of file
diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp
index 17864e4..53ab211 100644
--- a/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -106,661 +106,662 @@ 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] (BindTemporary)
-// CHECK: 3: [B1.2].operator int
-// CHECK: 4: [B1.3]()
-// CHECK: 5: [B1.4]
-// CHECK: 6: int([B1.5])
-// CHECK: 7: B()
-// CHECK: 8: [B1.7] (BindTemporary)
-// CHECK: 9: [B1.8].operator int
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10]
-// CHECK: 12: int([B1.11])
-// CHECK: 13: [B1.6] + [B1.12]
-// CHECK: 14: int a = int(A().operator int()) + int(B().operator int());
-// CHECK: 15: ~B() (Temporary object destructor)
-// CHECK: 16: ~A() (Temporary object destructor)
-// CHECK: 17: A()
-// CHECK: 18: [B1.17] (BindTemporary)
-// CHECK: 19: [B1.18].operator int
-// CHECK: 20: [B1.19]()
-// CHECK: 21: [B1.20]
-// CHECK: 22: int([B1.21])
-// CHECK: 23: B()
-// CHECK: 24: [B1.23] (BindTemporary)
-// CHECK: 25: [B1.24].operator int
-// CHECK: 26: [B1.25]()
-// CHECK: 27: [B1.26]
-// CHECK: 28: int([B1.27])
-// CHECK: 29: [B1.22] + [B1.28]
-// CHECK: 30: foo
-// CHECK: 31: [B1.30]
-// CHECK: 32: [B1.31]([B1.29])
-// CHECK: 33: ~B() (Temporary object destructor)
-// CHECK: 34: ~A() (Temporary object destructor)
-// CHECK: 35: 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.5] && [B5.4]
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: T: [B4.5] && ...
-// 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] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: T: [B4.5] && ...
-// CHECK: Predecessors (2): B6 B7
-// CHECK: Successors (2): B5 B3
-// CHECK: [ B5 ]
-// CHECK: 1: B()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2].operator _Bool
-// CHECK: 4: [B5.3]()
-// 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.4] && [B9.4]
-// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool();
-// CHECK: T: [B8.4] && ...
-// CHECK: Predecessors (2): B9 B8
-// CHECK: Successors (2): B6 B4
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2].operator _Bool
-// CHECK: 4: [B8.3]()
-// CHECK: T: [B8.4] && ...
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B9 B7
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator _Bool
-// CHECK: 4: [B9.3]()
-// 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.5] || [B5.4]
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: T: [B4.5] || ...
-// 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] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: T: [B4.5] || ...
-// CHECK: Predecessors (2): B6 B7
-// CHECK: Successors (2): B3 B5
-// CHECK: [ B5 ]
-// CHECK: 1: B()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2].operator _Bool
-// CHECK: 4: [B5.3]()
-// 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.4] || [B9.4]
-// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool();
-// CHECK: T: [B8.4] || ...
-// CHECK: Predecessors (2): B9 B8
-// CHECK: Successors (2): B4 B6
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2].operator _Bool
-// CHECK: 4: [B8.3]()
-// CHECK: T: [B8.4] || ...
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (2): B7 B9
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator _Bool
-// CHECK: 4: [B9.3]()
-// 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.4].~A() (Implicit destructor)
-// CHECK: Predecessors (2): B2 B3
-// CHECK: Successors (1): B0
-// CHECK: [ B2 ]
-// CHECK: 1: 0
-// CHECK: 2: foo
-// CHECK: 3: [B2.2]
-// CHECK: 4: [B2.3]([B2.1])
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B3 ]
-// CHECK: 1: 0
-// CHECK: 2: foo
-// CHECK: 3: [B3.2]
-// CHECK: 4: [B3.3]([B3.1])
-// CHECK: Predecessors (1): B4
-// CHECK: Successors (1): B1
-// CHECK: [ B4 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: 2: B()
-// CHECK: 3: [B4.2] (BindTemporary)
-// CHECK: 4: [B4.3].operator _Bool
-// CHECK: 5: [B4.4]()
-// CHECK: 6: ~B() (Temporary object destructor)
-// CHECK: T: if [B4.5]
-// 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.4] ? [B8.5] : [B9.13]
-// CHECK: 2: [B7.1]
-// CHECK: 3: [B7.2]
-// CHECK: 4: A a = B().operator _Bool() ? A() : A(B().operator A());
-// CHECK: T: [B10.4] ? ... : ...
-// CHECK: Predecessors (2): B8 B9
-// CHECK: Successors (2): B5 B6
-// CHECK: [ B8 ]
-// CHECK: 1: A()
-// CHECK: 2: [B8.1] (BindTemporary)
-// CHECK: 3: [B8.2]
-// CHECK: 4: [B8.3]
-// CHECK: 5: [B8.4] (BindTemporary)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B9 ]
-// CHECK: 1: B()
-// CHECK: 2: [B9.1] (BindTemporary)
-// CHECK: 3: [B9.2].operator A
-// CHECK: 4: [B9.3]()
-// CHECK: 5: [B9.4] (BindTemporary)
-// CHECK: 6: [B9.5]
-// CHECK: 7: [B9.6]
-// CHECK: 8: [B9.7]
-// CHECK: 9: [B9.8] (BindTemporary)
-// CHECK: 10: A([B9.9])
-// CHECK: 11: [B9.10]
-// CHECK: 12: [B9.11]
-// CHECK: 13: [B9.12] (BindTemporary)
-// CHECK: Predecessors (1): B10
-// CHECK: Successors (1): B7
-// CHECK: [ B10 ]
-// CHECK: 1: B()
-// CHECK: 2: [B10.1] (BindTemporary)
-// CHECK: 3: [B10.2].operator _Bool
-// CHECK: 4: [B10.3]()
-// CHECK: T: [B10.4] ? ... : ...
-// 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.4].~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.5] ? [B5.5] : [B6.13]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: foo
-// CHECK: 5: [B4.4]
-// CHECK: 6: [B4.5]([B4.3])
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: A()
-// CHECK: 2: [B5.1] (BindTemporary)
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: B()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2].operator A
-// CHECK: 4: [B6.3]()
-// CHECK: 5: [B6.4] (BindTemporary)
-// CHECK: 6: [B6.5]
-// CHECK: 7: [B6.6]
-// CHECK: 8: [B6.7]
-// CHECK: 9: [B6.8] (BindTemporary)
-// CHECK: 10: A([B6.9])
-// CHECK: 11: [B6.10]
-// CHECK: 12: [B6.11]
-// CHECK: 13: [B6.12] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: ~B() (Temporary object destructor)
-// CHECK: 2: B()
-// CHECK: 3: [B7.2] (BindTemporary)
-// CHECK: 4: [B7.3].operator _Bool
-// CHECK: 5: [B7.4]()
-// CHECK: T: [B7.5] ? ... : ...
-// 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.4] ? [B11.5] : [B12.13]
-// CHECK: 2: [B10.1]
-// CHECK: 3: [B10.2]
-// CHECK: 4: const A &a = B().operator _Bool() ? A() : A(B().operator A());
-// CHECK: T: [B13.4] ? ... : ...
-// CHECK: Predecessors (2): B11 B12
-// CHECK: Successors (2): B8 B9
-// CHECK: [ B11 ]
-// CHECK: 1: A()
-// CHECK: 2: [B11.1] (BindTemporary)
-// CHECK: 3: [B11.2]
-// CHECK: 4: [B11.3]
-// CHECK: 5: [B11.4] (BindTemporary)
-// CHECK: Predecessors (1): B13
-// CHECK: Successors (1): B10
-// CHECK: [ B12 ]
-// CHECK: 1: B()
-// CHECK: 2: [B12.1] (BindTemporary)
-// CHECK: 3: [B12.2].operator A
-// CHECK: 4: [B12.3]()
-// CHECK: 5: [B12.4] (BindTemporary)
-// CHECK: 6: [B12.5]
-// CHECK: 7: [B12.6]
-// CHECK: 8: [B12.7]
-// CHECK: 9: [B12.8] (BindTemporary)
-// CHECK: 10: A([B12.9])
-// CHECK: 11: [B12.10]
-// CHECK: 12: [B12.11]
-// CHECK: 13: [B12.12] (BindTemporary)
-// CHECK: Predecessors (1): B13
-// CHECK: Successors (1): B10
-// CHECK: [ B13 ]
-// CHECK: 1: B()
-// CHECK: 2: [B13.1] (BindTemporary)
-// CHECK: 3: [B13.2].operator _Bool
-// CHECK: 4: [B13.3]()
-// CHECK: T: [B13.4] ? ... : ...
-// 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.4].~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.5]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: A a = A() ?: A();
-// CHECK: T: [B7.5] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: [B7.3]
-// CHECK: 2: [B7.3]
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: A()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2]
-// CHECK: 4: [B6.3]
-// CHECK: 5: [B6.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B7 ]
-// CHECK: 1: A()
-// CHECK: 2: [B7.1] (BindTemporary)
-// CHECK: 3:
-// CHECK: 4: [B7.3].operator _Bool
-// CHECK: 5: [B7.4]()
-// CHECK: T: [B7.5] ? ... : ...
-// 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.4].~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.5]
-// CHECK: 2: [B4.1]
-// CHECK: 3: [B4.2]
-// CHECK: 4: foo
-// CHECK: 5: [B4.4]
-// CHECK: 6: [B4.5]([B4.3])
-// CHECK: T: [B7.6] ? ... : ...
-// CHECK: Predecessors (2): B5 B6
-// CHECK: Successors (2): B2 B3
-// CHECK: [ B5 ]
-// CHECK: 1: [B7.4]
-// CHECK: 2: [B7.4]
-// CHECK: 3: [B5.2]
-// CHECK: 4: [B5.3]
-// CHECK: 5: [B5.4] (BindTemporary)
-// CHECK: Predecessors (1): B7
-// CHECK: Successors (1): B4
-// CHECK: [ B6 ]
-// CHECK: 1: A()
-// CHECK: 2: [B6.1] (BindTemporary)
-// CHECK: 3: [B6.2]
-// CHECK: 4: [B6.3]
-// CHECK: 5: [B6.4] (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:
-// CHECK: 5: [B7.4].operator _Bool
-// CHECK: 6: [B7.5]()
-// CHECK: T: [B7.6] ? ... : ...
-// 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.5]
-// CHECK: 2: [B9.1]
-// CHECK: 3: [B9.2]
-// CHECK: 4: const A &a = A() ?: A();
-// CHECK: T: [B12.5] ? ... : ...
-// CHECK: Predecessors (2): B10 B11
-// CHECK: Successors (2): B7 B8
-// CHECK: [ B10 ]
-// CHECK: 1: [B12.3]
-// CHECK: 2: [B12.3]
-// CHECK: 3: [B10.2]
-// CHECK: 4: [B10.3]
-// CHECK: 5: [B10.4] (BindTemporary)
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B9
-// CHECK: [ B11 ]
-// CHECK: 1: A()
-// CHECK: 2: [B11.1] (BindTemporary)
-// CHECK: 3: [B11.2]
-// CHECK: 4: [B11.3]
-// CHECK: 5: [B11.4] (BindTemporary)
-// CHECK: Predecessors (1): B12
-// CHECK: Successors (1): B9
-// CHECK: [ B12 ]
-// CHECK: 1: A()
-// CHECK: 2: [B12.1] (BindTemporary)
-// CHECK: 3:
-// CHECK: 4: [B12.3].operator _Bool
-// CHECK: 5: [B12.4]()
-// CHECK: T: [B12.5] ? ... : ...
-// 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: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2]
-// CHECK: 4: [B1.3]
-// CHECK: 5: A a = A();
-// CHECK: 6: ~A() (Temporary object destructor)
-// CHECK: 7: int b;
-// CHECK: 8: [B1.5].~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: [B1.1] (BindTemporary)
-// CHECK: 3: [B1.2]
-// CHECK: 4: [B1.3]
-// CHECK: 5: const A &a = A();
-// CHECK: 6: A()
-// CHECK: 7: [B1.6] (BindTemporary)
-// CHECK: 8: [B1.7]
-// CHECK: 9: [B1.8]
-// CHECK: 10: foo
-// CHECK: 11: [B1.10]
-// CHECK: 12: [B1.11]([B1.9])
-// CHECK: 13: ~A() (Temporary object destructor)
-// CHECK: 14: int b;
-// CHECK: 15: [B1.5].~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: [B1.1]
-// CHECK: 3: [B1.2]()
-// CHECK: 4: [B1.3] (BindTemporary)
-// CHECK: 5: [B1.4]
-// CHECK: 6: [B1.5]
-// CHECK: 7: A a = A::make();
-// CHECK: 8: ~A() (Temporary object destructor)
-// CHECK: 9: int b;
-// CHECK: 10: [B1.7].~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: [B1.1]
-// CHECK: 3: [B1.2]()
-// CHECK: 4: [B1.3] (BindTemporary)
-// CHECK: 5: [B1.4]
-// CHECK: 6: [B1.5]
-// CHECK: 7: const A &a = A::make();
-// CHECK: 8: A::make
-// CHECK: 9: [B1.8]
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10] (BindTemporary)
-// CHECK: 12: [B1.11]
-// CHECK: 13: [B1.12]
-// CHECK: 14: foo
-// CHECK: 15: [B1.14]
-// CHECK: 16: [B1.15]([B1.13])
-// CHECK: 17: ~A() (Temporary object destructor)
-// CHECK: 18: int b;
-// CHECK: 19: [B1.7].~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] (BindTemporary)
-// CHECK: 4: [B1.3].operator int
-// CHECK: 5: [B1.4]()
-// CHECK: 6: a
-// CHECK: 7: [B1.6] = [B1.5]
-// CHECK: 8: ~A() (Temporary object destructor)
-// CHECK: 9: 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] (BindTemporary)
-// CHECK: 3: [B1.2].operator int
-// CHECK: 4: [B1.3]()
-// CHECK: 5: [B1.4]
-// CHECK: 6: int([B1.5])
-// CHECK: 7: B()
-// CHECK: 8: [B1.7] (BindTemporary)
-// CHECK: 9: [B1.8].operator int
-// CHECK: 10: [B1.9]()
-// CHECK: 11: [B1.10]
-// CHECK: 12: int([B1.11])
-// CHECK: 13: [B1.6] + [B1.12]
-// CHECK: 14: a([B1.13]) (Member initializer)
-// CHECK: 15: ~B() (Temporary object destructor)
-// CHECK: 16: ~A() (Temporary object destructor)
-// CHECK: 17: /*implicit*/int()
-// CHECK: 18: b([B1.17]) (Member initializer)
-// CHECK: Predecessors (1): B2
-// CHECK: Successors (1): B0
-// CHECK: [ B0 (EXIT) ]
-// CHECK: Predecessors (1): B1
-// CHECK: Successors (0):
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: int a = int(A().operator int()) + int(B().operator int());
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: A() (CXXConstructExpr, class A)
+// CHECK: 18: [B1.17] (BindTemporary)
+// CHECK: 19: [B1.18].operator int
+// CHECK: 20: [B1.19]()
+// CHECK: 21: [B1.20] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 22: int([B1.21]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 23: B() (CXXConstructExpr, class B)
+// CHECK: 24: [B1.23] (BindTemporary)
+// CHECK: 25: [B1.24].operator int
+// CHECK: 26: [B1.25]()
+// CHECK: 27: [B1.26] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 28: int([B1.27]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 29: [B1.22] + [B1.28]
+// CHECK: 30: foo
+// CHECK: 31: [B1.30] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 32: [B1.31]([B1.29])
+// CHECK: 33: ~B() (Temporary object destructor)
+// CHECK: 34: ~A() (Temporary object destructor)
+// CHECK: 35: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] && [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B2 B1
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] && ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B5 B3
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] && [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool();
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B6 B4
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] && ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B9 B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B10 (ENTRY)]
+// CHECK: Succs (1): B8
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B3
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: [B4.6] || [B5.5]
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B5 B4
+// CHECK: Succs (2): B1 B2
+// CHECK: [B4]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B4.6] || ...
+// CHECK: Preds (2): B6 B7
+// CHECK: Succs (2): B3 B5
+// CHECK: [B5]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2].operator _Bool
+// CHECK: 4: [B5.3]()
+// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B3
+// CHECK: [B6]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B8.5] || [B9.5]
+// CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool();
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B4 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2].operator _Bool
+// CHECK: 4: [B8.3]()
+// CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B8.5] || ...
+// CHECK: Preds (1): B10
+// CHECK: Succs (2): B7 B9
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator _Bool
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: Preds (1): B8
+// CHECK: Succs (1): B7
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B11 (ENTRY)]
+// CHECK: Succs (1): B10
+// CHECK: [B1]
+// CHECK: 1: int b;
+// CHECK: 2: [B7.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B2.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B2.3]([B2.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: 0
+// CHECK: 2: foo
+// CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(int))
+// CHECK: 4: [B3.3]([B3.1])
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B4.2] (BindTemporary)
+// CHECK: 4: [B4.3].operator _Bool
+// CHECK: 5: [B4.4]()
+// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: 7: ~B() (Temporary object destructor)
+// CHECK: T: if [B4.6]
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B3 B2
+// CHECK: [B5]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B7
+// CHECK: Succs (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: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: [B10.5] ? [B8.6] : [B9.15]
+// CHECK: 2: [B7.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B7.2]
+// CHECK: 4: [B7.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B8.1] (BindTemporary)
+// CHECK: 3: [B8.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B8.3]
+// CHECK: 5: [B8.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B8.5] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B9.1] (BindTemporary)
+// CHECK: 3: [B9.2].operator A
+// CHECK: 4: [B9.3]()
+// CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B9.5] (BindTemporary)
+// CHECK: 7: [B9.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B9.7]
+// CHECK: 9: [B9.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B9.9] (BindTemporary)
+// CHECK: 11: A([B9.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B9.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B9.12]
+// CHECK: 14: [B9.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B9.14] (BindTemporary)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B10.1] (BindTemporary)
+// CHECK: 3: [B10.2].operator _Bool
+// CHECK: 4: [B10.3]()
+// CHECK: 5: [B10.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B10.5] ? ... : ...
+// CHECK: Preds (1): B11
+// CHECK: Succs (2): B8 B9
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B14 (ENTRY)]
+// CHECK: Succs (1): B13
+// CHECK: [B1]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B10.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (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: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.6] ? [B5.6] : [B6.15]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B5.1] (BindTemporary)
+// CHECK: 3: [B5.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B5.3]
+// CHECK: 5: [B5.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B5.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2].operator A
+// CHECK: 4: [B6.3]()
+// CHECK: 5: [B6.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: 7: [B6.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B6.7]
+// CHECK: 9: [B6.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B6.9] (BindTemporary)
+// CHECK: 11: A([B6.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B6.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B6.12]
+// CHECK: 14: [B6.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B6.14] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~B() (Temporary object destructor)
+// CHECK: 2: B() (CXXConstructExpr, class B)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B8 B9
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: 3: ~B() (Temporary object destructor)
+// CHECK: Preds (1): B10
+// CHECK: Succs (1): B7
+// CHECK: [B10]
+// CHECK: 1: [B13.5] ? [B11.6] : [B12.15]
+// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B10.2]
+// CHECK: 4: const A &a = B().operator _Bool() ? A() : A(B().operator A());
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (2): B11 B12
+// CHECK: Succs (2): B8 B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B12]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator A
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, class A)
+// CHECK: 6: [B12.5] (BindTemporary)
+// CHECK: 7: [B12.6] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 8: [B12.7]
+// CHECK: 9: [B12.8] (CXXConstructExpr, class A)
+// CHECK: 10: [B12.9] (BindTemporary)
+// CHECK: 11: A([B12.10]) (CXXFunctionalCastExpr, ConstructorConversion, class A)
+// CHECK: 12: [B12.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B12.12]
+// CHECK: 14: [B12.13] (CXXConstructExpr, class A)
+// CHECK: 15: [B12.14] (BindTemporary)
+// CHECK: Preds (1): B13
+// CHECK: Succs (1): B10
+// CHECK: [B13]
+// CHECK: 1: B() (CXXConstructExpr, class B)
+// CHECK: 2: [B13.1] (BindTemporary)
+// CHECK: 3: [B13.2].operator _Bool
+// CHECK: 4: [B13.3]()
+// CHECK: 5: [B13.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B13.5] ? ... : ...
+// CHECK: Preds (1): B14
+// CHECK: Succs (2): B11 B12
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B8 (ENTRY)]
+// CHECK: Succs (1): B7
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B4.5].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.2] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: [B4.3] (CXXConstructExpr, class A)
+// CHECK: 5: A a = A() ?: A();
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B7.1] (BindTemporary)
+// CHECK: 3: [B7.2].operator _Bool
+// CHECK: 4: [B7.3]()
+// CHECK: 5: [B7.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.5] ? ... : ...
+// CHECK: Preds (1): B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B13 (ENTRY)]
+// CHECK: Succs (1): B12
+// CHECK: [B1]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: int b;
+// CHECK: 3: [B9.4].~A() (Implicit destructor)
+// CHECK: Preds (2): B2 B3
+// CHECK: Succs (1): B0
+// CHECK: [B2]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B3]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B4
+// CHECK: Succs (1): B1
+// CHECK: [B4]
+// CHECK: 1: [B7.3] ?: [B6.6]
+// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B4.2]
+// CHECK: 4: foo
+// CHECK: 5: [B4.4] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 6: [B4.5]([B4.3])
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B5 B6
+// CHECK: Succs (2): B2 B3
+// CHECK: [B5]
+// CHECK: 1: [B7.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B5.1]
+// CHECK: 3: [B5.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B5.3] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B6]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B6.1] (BindTemporary)
+// CHECK: 3: [B6.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B6.3]
+// CHECK: 5: [B6.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B6.5] (BindTemporary)
+// CHECK: Preds (1): B7
+// CHECK: Succs (1): B4
+// CHECK: [B7]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B7.2] (BindTemporary)
+// CHECK: 4: [B7.3].operator _Bool
+// CHECK: 5: [B7.4]()
+// CHECK: 6: [B7.5] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B7.6] ? ... : ...
+// CHECK: Preds (2): B9 B8
+// CHECK: Succs (2): B5 B6
+// CHECK: [B8]
+// CHECK: 1: ~A() (Temporary object destructor)
+// CHECK: Preds (1): B9
+// CHECK: Succs (1): B7
+// CHECK: [B9]
+// CHECK: 1: [B12.2] ?: [B11.6]
+// CHECK: 2: [B9.1] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 3: [B9.2]
+// CHECK: 4: const A &a = A() ?: A();
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (2): B10 B11
+// CHECK: Succs (2): B7 B8
+// CHECK: [B10]
+// CHECK: 1: [B12.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 2: [B10.1]
+// CHECK: 3: [B10.2] (CXXConstructExpr, class A)
+// CHECK: 4: [B10.3] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B11]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B11.1] (BindTemporary)
+// CHECK: 3: [B11.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B11.3]
+// CHECK: 5: [B11.4] (CXXConstructExpr, class A)
+// CHECK: 6: [B11.5] (BindTemporary)
+// CHECK: Preds (1): B12
+// CHECK: Succs (1): B9
+// CHECK: [B12]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B12.1] (BindTemporary)
+// CHECK: 3: [B12.2].operator _Bool
+// CHECK: 4: [B12.3]()
+// CHECK: 5: [B12.4] (ImplicitCastExpr, UserDefinedConversion, _Bool)
+// CHECK: T: [B12.5] ? ... : ...
+// CHECK: Preds (1): B13
+// CHECK: Succs (2): B10 B11
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: [B1.4] (CXXConstructExpr, class A)
+// CHECK: 6: A a = A();
+// CHECK: 7: ~A() (Temporary object destructor)
+// CHECK: 8: int b;
+// CHECK: 9: [B1.6].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 4: [B1.3]
+// CHECK: 5: const A &a = A();
+// CHECK: 6: A() (CXXConstructExpr, class A)
+// CHECK: 7: [B1.6] (BindTemporary)
+// CHECK: 8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 9: [B1.8]
+// CHECK: 10: foo
+// CHECK: 11: [B1.10] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 12: [B1.11]([B1.9])
+// CHECK: 13: ~A() (Temporary object destructor)
+// CHECK: 14: int b;
+// CHECK: 15: [B1.5].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: [B1.6] (CXXConstructExpr, class A)
+// CHECK: 8: A a = A::make();
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: 11: [B1.8].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A::make
+// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 3: [B1.2]()
+// CHECK: 4: [B1.3] (BindTemporary)
+// CHECK: 5: [B1.4] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 6: [B1.5]
+// CHECK: 7: const A &a = A::make();
+// CHECK: 8: A::make
+// CHECK: 9: [B1.8] (ImplicitCastExpr, FunctionToPointerDecay, class A (*)(void))
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (BindTemporary)
+// CHECK: 12: [B1.11] (ImplicitCastExpr, NoOp, const class A)
+// CHECK: 13: [B1.12]
+// CHECK: 14: foo
+// CHECK: 15: [B1.14] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(const class A &))
+// CHECK: 16: [B1.15]([B1.13])
+// CHECK: 17: ~A() (Temporary object destructor)
+// CHECK: 18: int b;
+// CHECK: 19: [B1.7].~A() (Implicit destructor)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: int a;
+// CHECK: 2: A() (CXXConstructExpr, class A)
+// CHECK: 3: [B1.2] (BindTemporary)
+// CHECK: 4: [B1.3].operator int
+// CHECK: 5: [B1.4]()
+// CHECK: 6: [B1.5] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 7: a
+// CHECK: 8: [B1.7] = [B1.6]
+// CHECK: 9: ~A() (Temporary object destructor)
+// CHECK: 10: int b;
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
+// CHECK: [B2 (ENTRY)]
+// CHECK: Succs (1): B1
+// CHECK: [B1]
+// CHECK: 1: A() (CXXConstructExpr, class A)
+// CHECK: 2: [B1.1] (BindTemporary)
+// CHECK: 3: [B1.2].operator int
+// CHECK: 4: [B1.3]()
+// CHECK: 5: [B1.4] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 6: int([B1.5]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 7: B() (CXXConstructExpr, class B)
+// CHECK: 8: [B1.7] (BindTemporary)
+// CHECK: 9: [B1.8].operator int
+// CHECK: 10: [B1.9]()
+// CHECK: 11: [B1.10] (ImplicitCastExpr, UserDefinedConversion, int)
+// CHECK: 12: int([B1.11]) (CXXFunctionalCastExpr, NoOp, int)
+// CHECK: 13: [B1.6] + [B1.12]
+// CHECK: 14: a([B1.13]) (Member initializer)
+// CHECK: 15: ~B() (Temporary object destructor)
+// CHECK: 16: ~A() (Temporary object destructor)
+// CHECK: 17: /*implicit*/int()
+// CHECK: 18: b([B1.17]) (Member initializer)
+// CHECK: Preds (1): B2
+// CHECK: Succs (1): B0
+// CHECK: [B0 (EXIT)]
+// CHECK: Preds (1): B1
diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m
index c62818a..d613c71 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-store=region -analyzer-checker=core,deadcode.IdempotentOperations -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,experimental.deadcode.IdempotentOperations -verify %s
struct s {
int data;
diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c
index cf5ca81..ec62098 100644
--- a/test/Analysis/unix-fns.c
+++ b/test/Analysis/unix-fns.c
@@ -9,7 +9,11 @@ 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 *calloc(size_t, size_t);
void *malloc(size_t);
+void *realloc(void *, size_t);
+void *alloca(size_t);
+void *valloc(size_t);
typedef void (^dispatch_block_t)(void);
typedef long dispatch_once_t;
@@ -66,3 +70,69 @@ void pr2899_nowarn(size_t size) {
foo[i] = 0;
}
}
+void test_calloc(void) {
+ char *foo = calloc(0, 42); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc2(void) {
+ char *foo = calloc(42, 0); // expected-warning{{Call to 'calloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_calloc_nowarn(size_t nmemb, size_t size) {
+ char *foo = calloc(nmemb, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc(char *ptr) {
+ char *foo = realloc(ptr, 0); // expected-warning{{Call to 'realloc' has an allocation size of 0 bytes}}
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_realloc_nowarn(char *ptr, size_t size) {
+ char *foo = realloc(ptr, size); // no-warning
+ for (unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca() {
+ char *foo = alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_alloca_nowarn(size_t sz) {
+ char *foo = alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_builtin_alloca() {
+ char *foo2 = __builtin_alloca(0); // expected-warning{{Call to 'alloca' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_builtin_alloca_nowarn(size_t sz) {
+ char *foo2 = __builtin_alloca(sz); // no-warning
+ for(unsigned i = 0; i < 100; i++) {
+ foo2[i] = 0;
+ }
+}
+void test_valloc() {
+ char *foo = valloc(0); // expected-warning{{Call to 'valloc' has an allocation size of 0 bytes}}
+ for(unsigned i = 0; i < 100; i++) {
+ foo[i] = 0;
+ }
+}
+void test_valloc_nowarn(size_t sz) {
+ char *foo = valloc(sz); // 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 da14f4c..48a3462 100644
--- a/test/Analysis/unreachable-code-path.c
+++ b/test/Analysis/unreachable-code-path.c
@@ -122,3 +122,20 @@ void test10() {
goto d;
f: ;
}
+
+// test11: we can actually end up in the default case, even if it is not
+// obvious: there might be something wrong with the given argument.
+enum foobar { FOO, BAR };
+extern void error();
+void test11(enum foobar fb) {
+ switch (fb) {
+ case FOO:
+ break;
+ case BAR:
+ break;
+ default:
+ error(); // no-warning
+ return;
+ error(); // expected-warning {{never executed}}
+ }
+}
diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m
index 42bde10..8941840 100644
--- a/test/Analysis/unused-ivars.m
+++ b/test/Analysis/unused-ivars.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars %s -verify
+// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s
//===--- BEGIN: Delta-debugging reduced headers. --------------------------===//
diff --git a/test/Analysis/variadic-method-types.m b/test/Analysis/variadic-method-types.m
index caa0c59..4d0f6bc 100644
--- a/test/Analysis/variadic-method-types.m
+++ b/test/Analysis/variadic-method-types.m
@@ -57,6 +57,12 @@ typedef struct {} NSFastEnumerationState;
+ (id)setWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
@end
+@interface NSOrderedSet : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+@end
+@interface NSOrderedSet (NSOrderedSetCreation)
++ (id)orderedSetWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1)));
+@end
@protocol P;
@class C;
@@ -71,6 +77,7 @@ void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
[NSArray arrayWithObjects:@"Foo", "Bar", "Baz", nil]; // expected-warning 2 {{Argument to 'NSArray' method 'arrayWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[NSDictionary dictionaryWithObjectsAndKeys:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSDictionary' method 'dictionaryWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
[NSSet setWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSSet' method 'setWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [NSOrderedSet orderedSetWithObjects:@"Foo", "Bar", nil]; // expected-warning {{Argument to 'NSOrderedSet' method 'orderedSetWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[[[NSArray alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSArray' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'char *'}}
@@ -79,6 +86,7 @@ void f(id a, id<P> b, C* c, C<P> *d, FooType fooType, BarType barType) {
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", fooType, nil] autorelease]; // no-warning
[[[NSDictionary alloc] initWithObjectsAndKeys:@"Foo", barType, nil] autorelease]; // expected-warning {{Argument to 'NSDictionary' method 'initWithObjectsAndKeys:' should be an Objective-C pointer type, not 'BarType'}}
[[[NSSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
+ [[[NSOrderedSet alloc] initWithObjects:@"Foo", "Bar", nil] autorelease]; // expected-warning {{Argument to 'NSOrderedSet' method 'initWithObjects:' should be an Objective-C pointer type, not 'char *'}}
}
// This previously crashed the variadic argument checker.
diff --git a/test/Analysis/virtualcall.cpp b/test/Analysis/virtualcall.cpp
new file mode 100644
index 0000000..127d04f
--- /dev/null
+++ b/test/Analysis/virtualcall.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.cplusplus.VirtualCall -analyzer-store region -verify %s
+
+class A {
+public:
+ A();
+ ~A() {};
+
+ virtual int foo() = 0;
+ virtual void bar() = 0;
+ void f() {
+ foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+ }
+};
+
+class B : public A {
+public:
+ B() {
+ foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+ }
+ ~B();
+
+ virtual int foo();
+ virtual void bar() { foo(); } // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+};
+
+A::A() {
+ f();
+}
+
+B::~B() {
+ this->B::foo(); // no-warning
+ this->B::bar();
+ this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+class C : public B {
+public:
+ C();
+ ~C();
+
+ virtual int foo();
+ void f(int i);
+};
+
+C::C() {
+ f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+}
+
+int main() {
+ A *a;
+ B *b;
+ C *c;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b7356c2..ae9de78 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -86,7 +86,6 @@ if(PYTHONINTERP_FOUND)
${LIT_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running Clang regression tests")
- set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
if( NOT CLANG_BUILT_STANDALONE )
add_custom_target(check-all
@@ -107,12 +106,12 @@ if(PYTHONINTERP_FOUND)
llvm-dis llc opt
FileCheck count not
)
- set_target_properties(check-all PROPERTIES FOLDER "Clang tests")
endif()
add_dependencies(clang-test clang-test.deps)
add_dependencies(clang-test.deps
clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test
+ clang-check
)
endif()
diff --git a/test/CXX/basic/basic.link/p9.cpp b/test/CXX/basic/basic.link/p9.cpp
index bd16b02..680c93d 100644
--- a/test/CXX/basic/basic.link/p9.cpp
+++ b/test/CXX/basic/basic.link/p9.cpp
@@ -6,6 +6,5 @@ namespace N { } // expected-note{{here}}
// First bullet: two names with external linkage that refer to
// different kinds of entities.
void f() {
- int N(); // expected-error{{redefinition}}
+ int N(); // expected-error{{redefinition}} expected-warning{{interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
}
-
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
index cee7c02..f5ad68b 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp
@@ -46,7 +46,7 @@ namespace M {
int g(N::X); // expected-note{{candidate function}}
void test(N::X x) {
- g(x); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+ g(x); // expected-error{{call to 'g' is ambiguous}}
int i = (g)(x);
int g(N::X);
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 15d86b7..32dd75a 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 {
A::A() + A::A();
B::B() + B::B();
C::C() + C::C();
- D::D() + D::D(); // expected-error {{ invalid operands to binary expression ('D::D' and 'D::D') }}
+ D::D() + D::D(); // expected-error {{invalid operands to binary expression ('D::D' and 'D::D')}}
}
}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
index c35af1d..c207283 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -36,7 +36,7 @@ void resolves_to_different() {
Value v;
// The fact that the next line is a warning rather than an error is an
// extension.
- v.set<double>(3.2); // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value' [-Wambiguous-member-template]}}
+ v.set<double>(3.2); // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}}
}
{
int set; // Non-template.
@@ -62,3 +62,28 @@ namespace rdar9915664 {
}
};
}
+
+namespace PR11856 {
+ template<typename T> T end(T);
+
+ template <typename T>
+ void Foo() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+ }
+
+ template<typename T> T *end(T*);
+
+ class X { };
+ template <typename T>
+ void Foo2() {
+ T it1;
+ if (it1->end < it1->end) {
+ }
+
+ X *x;
+ if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}}
+ }
+ }
+}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2f.cpp b/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
index a3d6a79..ea5a752 100644
--- a/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
+++ b/test/CXX/basic/basic.start/basic.start.main/p2f.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void // expected-error {{error: 'main' must return 'int'}}
-main( // expected-error {{error: first parameter of 'main' (argument count) must be of type 'int'}}
+void // expected-error {{'main' must return 'int'}}
+main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}}
float a
) {
}
diff --git a/test/CXX/basic/basic.start/basic.start.main/p2i.cpp b/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
new file mode 100644
index 0000000..db8da3c
--- /dev/null
+++ b/test/CXX/basic/basic.start/basic.start.main/p2i.cpp
@@ -0,0 +1,6 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify
+// RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit
+// RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only
+
+constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}}
diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp
index 3b438d1..83b910b 100644
--- a/test/CXX/basic/basic.types/p10.cpp
+++ b/test/CXX/basic/basic.types/p10.cpp
@@ -5,21 +5,40 @@ struct NonLiteral { NonLiteral(); };
// A type is a literal type if it is:
// - a scalar type
-constexpr int f1(double);
+constexpr int f1(double) { return 0; }
// - a reference type
struct S { S(); };
-constexpr int f2(S &);
+constexpr int f2(S &) { return 0; }
+
+// FIXME: I'm not entirely sure whether the following is legal or not...
+struct BeingDefined;
+extern BeingDefined beingdefined;
+struct BeingDefined {
+ static constexpr BeingDefined& t = beingdefined;
+};
// - a class type that has all of the following properties:
+// (implied) - it is complete
+
+struct Incomplete;
+template<class T> struct ClassTemp {};
+
+constexpr Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}}
+constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}}
+constexpr ClassTemp<int> classtemplate = {};
+constexpr ClassTemp<int> classtemplate2[] = {};
+
// - it has a trivial destructor
struct UserProvDtor {
- constexpr UserProvDtor(); // expected-error {{non-literal type 'UserProvDtor' cannot have constexpr members}}
+ constexpr int f(); // expected-error {{non-literal type 'UserProvDtor' cannot have constexpr members}}
~UserProvDtor(); // expected-note {{has a user-provided destructor}}
};
+
struct NonTrivDtor {
- constexpr NonTrivDtor(); // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
+ constexpr NonTrivDtor();
+ constexpr int f(); // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}}
};
struct NonTrivDtorBase {
@@ -29,17 +48,16 @@ template<typename T>
struct DerivedFromNonTrivDtor : T { // expected-note {{'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not literal because it has base class 'NonTrivDtorBase' of non-literal type}}
constexpr DerivedFromNonTrivDtor();
};
-constexpr int f(DerivedFromNonTrivDtor<NonTrivDtorBase>); // expected-error {{constexpr function's 1st parameter type 'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not a literal type}}
+constexpr int f(DerivedFromNonTrivDtor<NonTrivDtorBase>) { return 0; } // expected-error {{constexpr function's 1st parameter type 'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not a literal type}}
struct TrivDtor {
constexpr TrivDtor();
};
-// FIXME: when building DefinitionData we look at 'isUserProvided' before it's set up!
-#if 0
+constexpr int f(TrivDtor) { return 0; }
struct TrivDefaultedDtor {
constexpr TrivDefaultedDtor();
~TrivDefaultedDtor() = default;
};
-#endif
+constexpr int f(TrivDefaultedDtor) { return 0; }
// - it is an aggregate type or has at least one constexpr constructor or
// constexpr constructor template that is not a copy or move constructor
@@ -52,36 +70,41 @@ struct CtorTemplate {
template<typename T> constexpr CtorTemplate(T);
};
struct CopyCtorOnly { // expected-note {{'CopyCtorOnly' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}}
- constexpr CopyCtorOnly(CopyCtorOnly&); // expected-error {{non-literal type 'CopyCtorOnly' cannot have constexpr members}}
+ constexpr CopyCtorOnly(CopyCtorOnly&);
+ constexpr int f(); // expected-error {{non-literal type 'CopyCtorOnly' cannot have constexpr members}}
};
struct MoveCtorOnly { // expected-note {{no constexpr constructors other than copy or move constructors}}
- constexpr MoveCtorOnly(MoveCtorOnly&&); // expected-error {{non-literal type 'MoveCtorOnly' cannot have constexpr members}}
+ constexpr MoveCtorOnly(MoveCtorOnly&&);
+ constexpr int f(); // expected-error {{non-literal type 'MoveCtorOnly' cannot have constexpr members}}
};
template<typename T>
-struct CtorArg { // expected-note {{no constexpr constructors other than copy or move constructors}}
- constexpr CtorArg(T); // expected-note {{constructor template instantiation is not constexpr because 1st parameter type 'NonLiteral' is not a literal type}}
+struct CtorArg {
+ constexpr CtorArg(T);
};
-constexpr int f(CtorArg<int>);
-constexpr int f(CtorArg<NonLiteral>); // expected-error {{not a literal type}}
+constexpr int f(CtorArg<int>) { return 0; } // ok
+constexpr int f(CtorArg<NonLiteral>) { return 0; } // ok, ctor is still constexpr
// We have a special-case diagnostic for classes with virtual base classes.
struct VBase {};
struct HasVBase : virtual VBase {}; // expected-note 2{{virtual base class declared here}}
struct Derived : HasVBase {
- constexpr Derived(); // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+ constexpr Derived() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
};
template<typename T> struct DerivedFromVBase : T { // expected-note {{struct with virtual base class is not a literal type}}
constexpr DerivedFromVBase();
};
-constexpr int f(DerivedFromVBase<HasVBase>); // expected-error {{constexpr function's 1st parameter type 'DerivedFromVBase<HasVBase>' is not a literal type}}
+constexpr int f(DerivedFromVBase<HasVBase>) {} // expected-error {{constexpr function's 1st parameter type 'DerivedFromVBase<HasVBase>' is not a literal type}}
+template<typename T> constexpr DerivedFromVBase<T>::DerivedFromVBase() : T() {}
+constexpr int nVBase = (DerivedFromVBase<HasVBase>(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase<HasVBase>' with virtual base class in a constant expression}}
// - it has all non-static data members and base classes of literal types
struct NonLitMember {
S s; // expected-note {{has data member 's' of non-literal type 'S'}}
};
-constexpr int f(NonLitMember); // expected-error {{1st parameter type 'NonLitMember' is not a literal type}}
+constexpr int f(NonLitMember) {} // expected-error {{1st parameter type 'NonLitMember' is not a literal type}}
struct NonLitBase :
S { // expected-note {{base class 'S' of non-literal type}}
- constexpr NonLitBase(); // expected-error {{non-literal type 'NonLitBase' cannot have constexpr members}}
+ constexpr NonLitBase();
+ constexpr int f() { return 0; } // expected-error {{non-literal type 'NonLitBase' cannot have constexpr members}}
};
struct LitMemBase : Agg {
Agg agg;
@@ -91,37 +114,19 @@ struct MemberType {
T t; // expected-note {{'MemberType<NonLiteral>' is not literal because it has data member 't' of non-literal type 'NonLiteral'}}
constexpr MemberType();
};
-constexpr int f(MemberType<int>);
-constexpr int f(MemberType<NonLiteral>); // expected-error {{not a literal type}}
+constexpr int f(MemberType<int>) { return 0; }
+constexpr int f(MemberType<NonLiteral>) { return 0; } // expected-error {{not a literal type}}
// - an array of literal type
struct ArrGood {
Agg agg[24];
double d[12];
TrivDtor td[3];
+ TrivDefaultedDtor tdd[3];
};
-constexpr int f(ArrGood);
+constexpr int f(ArrGood) { return 0; }
struct ArrBad {
S s[3]; // expected-note {{data member 's' of non-literal type 'S [3]'}}
};
-constexpr int f(ArrBad); // expected-error {{1st parameter type 'ArrBad' is not a literal type}}
-
-
-// As a non-conforming tweak to the standard, we do not allow a literal type to
-// have any mutable data members.
-namespace MutableMembers {
- struct MM {
- mutable int n; // expected-note {{'MM' is not literal because it has a mutable data member}}
- };
- constexpr int f(MM); // expected-error {{not a literal type}}
-
- // Here's one reason why allowing this would be a disaster...
- template<int n> struct Id { int k = n; };
- int f() {
- // FIXME: correctly check whether the initializer is a constant expression.
- constexpr MM m = { 0 }; // desired-error {{must be a constant expression}}
- ++m.n;
- return Id<m.n>().k; // expected-error {{not an integral constant expression}}
- }
-}
+constexpr int f(ArrBad) { return 0; } // expected-error {{1st parameter type 'ArrBad' is not a literal type}}
diff --git a/test/CXX/class.access/class.protected/p1-cxx11.cpp b/test/CXX/class.access/class.protected/p1-cxx11.cpp
new file mode 100644
index 0000000..dc9b20d
--- /dev/null
+++ b/test/CXX/class.access/class.protected/p1-cxx11.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR12497
+namespace test0 {
+ class A {
+ protected:
+ A() {}
+ A(const A &) {}
+ ~A() {}
+ A &operator=(const A &a) { return *this; }
+ };
+
+ class B : public A {};
+
+ void test() {
+ B b1;
+ B b2 = b1;
+ b1 = b2;
+ }
+}
diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp
index 79bb6cd..c9491e1 100644
--- a/test/CXX/class.access/class.protected/p1.cpp
+++ b/test/CXX/class.access/class.protected/p1.cpp
@@ -68,7 +68,7 @@ namespace test1 {
namespace test2 {
class A {
- protected: int x; // expected-note 3 {{object type must derive}}
+ protected: int x; // expected-note 3 {{can only access this member on an object of type}}
static int sx;
static void test(A&);
};
@@ -103,7 +103,7 @@ namespace test2 {
namespace test3 {
class B;
class A {
- protected: int x; // expected-note {{object type must derive}}
+ protected: int x; //expected-note {{declared protected}} // expected-note {{can only access this member on an object of type}}
static int sx;
static void test(B&);
};
@@ -130,7 +130,7 @@ namespace test3 {
(void) b.sx;
}
void D::test(B &b) {
- (void) b.x;
+ (void) b.x; // expected-error {{'x' is a protected member}}
(void) b.sx;
}
}
@@ -138,7 +138,7 @@ namespace test3 {
namespace test4 {
class C;
class A {
- protected: int x; // expected-note {{declared}} expected-note 2 {{object type must derive}}
+ protected: int x; // expected-note 2{{declared protected here}} expected-note{{member is declared here}}
static int sx; // expected-note 3{{member is declared here}}
static void test(C&);
};
@@ -215,7 +215,7 @@ namespace test6 {
class Static {};
class A {
protected:
- void foo(int); // expected-note 3 {{object type must derive}}
+ void foo(int); // expected-note 3 {{can only access this member on an object of type}}
void foo(long);
static void foo(Static);
@@ -253,7 +253,7 @@ namespace test7 {
class Static {};
class A {
protected:
- void foo(int); // expected-note 3 {{object type must derive}}
+ void foo(int); // expected-note 3 {{must name member using the type of the current context}}
void foo(long);
static void foo(Static);
@@ -291,7 +291,7 @@ namespace test8 {
class Static {};
class A {
protected:
- void foo(int); // expected-note 3 {{object type must derive}}
+ void foo(int); // expected-note 3 {{must name member using the type of the current context}}
void foo(long);
static void foo(Static);
@@ -329,7 +329,7 @@ namespace test8 {
namespace test9 {
class A { // expected-note {{member is declared here}}
- protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{object type must derive}} expected-note {{object type 'test9::A' must derive}}
+ protected: int foo(); // expected-note 4 {{declared}} expected-note 2 {{can only access this member on an object of type}} expected-note {{member is declared here}}
};
class B : public A { // expected-note {{member is declared here}}
@@ -423,7 +423,7 @@ namespace test12 {
// This friendship is not considered because a public member of A is
// inaccessible in C.
namespace test13 {
- class A { protected: int foo(); }; // expected-note {{object type 'test13::D' must derive from context type 'test13::C'}}
+ class A { protected: int foo(); }; // expected-note {{can only access this member on an object of type}}
class B : private virtual A {};
class C : private B { friend void test(); };
class D : public virtual A {};
@@ -433,3 +433,87 @@ namespace test13 {
d.A::foo(); // expected-error {{protected member}}
}
}
+
+// PR8058
+namespace test14 {
+ class A {
+ protected:
+ template <class T> void temp(T t); // expected-note {{must name member using the type of the current context}}
+
+ void nontemp(int); // expected-note {{must name member using the type of the current context}}
+
+ template <class T> void ovl_temp(T t); // expected-note {{must name member using the type of the current context}}
+ void ovl_temp(float);
+
+ void ovl_nontemp(int); // expected-note {{must name member using the type of the current context}}
+ void ovl_nontemp(float);
+
+ template <class T> void ovl_withtemp(T);
+ void ovl_withtemp(int); // expected-note {{must name member using the type of the current context}}
+ };
+
+ class B : public A {
+ void use() {
+ void (A::*ptr)(int);
+ ptr = &A::temp; // expected-error {{protected member}}
+ ptr = &A::nontemp; // expected-error {{protected member}}
+ ptr = &A::ovl_temp; // expected-error {{protected member}}
+ ptr = &A::ovl_nontemp; // expected-error {{protected member}}
+ ptr = &A::ovl_withtemp; // expected-error {{protected member}}
+ }
+ };
+}
+
+namespace test15 {
+ class A {
+ protected:
+ A(); // expected-note 2 {{protected constructor can only be used to construct a base class subobject}}
+ A(const A &); // expected-note {{protected constructor can only be used to construct a base class subobject}}
+ ~A(); // expected-note 3 {{protected destructor can only be used to destroy a base class subobject}}
+ };
+
+ class B : public A {
+ // The uses here are fine.
+ B() {}
+ B(int i) : A() {}
+ ~B() {}
+
+ // All these uses are bad.
+
+ void test0() {
+ A a; // expected-error {{protected constructor}} expected-error {{protected destructor}}
+ }
+
+ A *test1() {
+ return new A(); // expected-error {{protected constructor}}
+ }
+
+ void test2(A *a) {
+ delete a; // expected-error {{protected destructor}}
+ }
+
+ A test3(A *a) {
+ return *a; // expected-error {{protected constructor}}
+ }
+
+ void test4(A *a) {
+ a->~A(); // expected-error {{protected member}}
+ }
+ };
+}
+
+namespace test16 {
+ class A {
+ protected:
+ ~A();
+ };
+
+ class B : public virtual A {
+ public:
+ ~B() {}
+ };
+
+ class C : public B {
+ ~C() {}
+ };
+}
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index add3635..5ad738b 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -372,7 +372,7 @@ namespace test15 {
int private_foo; // expected-note {{declared private here}}
static int private_sfoo; // expected-note {{declared private here}}
protected:
- int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{object type must derive from context type 'test15::B<int>'}}
+ int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B<int>'}}
static int protected_sfoo; // expected-note 3 {{declared protected here}}
int test1(A<int> &a) {
@@ -481,7 +481,7 @@ namespace test21 {
};
template <class T> class A<T>::Inner {};
class B {
- template <class T> class A<T>::Inner;
+ template <class T> class A<T>::Inner; // expected-error{{non-friend class member 'Inner' cannot have a qualified name}}
};
void test() {
diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp
index 932b4f4..fbdc87b 100644
--- a/test/CXX/class.access/p6.cpp
+++ b/test/CXX/class.access/p6.cpp
@@ -150,7 +150,7 @@ namespace test6 {
class B : A {
public_inner a;
protected_inner b;
- private_inner c; // expected-error {{ 'private_inner' is a private member of 'test6::A'}}
+ private_inner c; // expected-error {{'private_inner' is a private member of 'test6::A'}}
};
}
diff --git a/test/CXX/class.derived/class.member.lookup/p6.cpp b/test/CXX/class.derived/class.member.lookup/p6.cpp
index 5f4b2a7..7239881 100644
--- a/test/CXX/class.derived/class.member.lookup/p6.cpp
+++ b/test/CXX/class.derived/class.member.lookup/p6.cpp
@@ -29,7 +29,7 @@ void D::glorp() {
x++;
f();
y++; // expected-error{{member 'y' found in multiple base classes of different types}}
- g(); // expected-error{{error: member 'g' found in multiple base classes of different types}}
+ g(); // expected-error{{member 'g' found in multiple base classes of different types}}
}
// PR6462
diff --git a/test/CXX/class.derived/p1.cpp b/test/CXX/class.derived/p1.cpp
new file mode 100644
index 0000000..dc5cb2b
--- /dev/null
+++ b/test/CXX/class.derived/p1.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
+
+// base-clause:
+// : base-specifier-list
+// base-specifier-list:
+// base-specifier ...[opt]
+// base-specifier-list , base-specifier ...[opt]
+// base-specifier:
+// attribute-specifier-seq[opt] base-type-specifier
+// attribute-specifier-seq[opt] virtual access-specifier[opt] base-type-specifier
+// attribute-specifier-seq[opt] access-specifier virtual[opt] base-type-specifier
+// class-or-decltype:
+// nested-name-specifier[opt] class-name
+// decltype-specifier
+// base-type-specifier:
+// class-or-decltype
+// access-specifier:
+// private
+// protected
+// public
+
+namespace PR11216 {
+ struct Base { };
+ struct Derived : decltype(Base()) { };
+
+ int func();
+ struct Derived2 : decltype(func()) { }; // expected-error {{base specifier must name a class}}
+
+ template<typename T>
+ struct Derived3 : decltype(T().foo()) { };
+ struct Foo { Base foo(); };
+ Derived3<Foo> d;
+
+ struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
+
+ struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
+
+ template<typename T>
+ struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}}
+}
diff --git a/test/CXX/class/class.base/class.base.init/p5-0x.cpp b/test/CXX/class/class.base/class.base.init/p5-0x.cpp
new file mode 100644
index 0000000..e9aa6da
--- /dev/null
+++ b/test/CXX/class/class.base/class.base.init/p5-0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// [class.base.init]p5
+// A ctor-initializer may initialize a variant member of the constructor’s
+// class. If a ctor-initializer specifies more than one mem-initializer for the
+// same member or for the same base class, the ctor-initializer is ill-formed.
+
+union E {
+ int a;
+ int b;
+ E() : a(1), // expected-note{{previous initialization is here}}
+ b(2) { // expected-error{{initializing multiple members of union}}
+ }
+};
+
+union F {
+ struct {
+ int a;
+ int b;
+ };
+ int c;
+ F() : a(1), // expected-note{{previous initialization is here}}
+ b(2),
+ c(3) { // expected-error{{initializing multiple members of union}}
+ }
+};
diff --git a/test/CXX/class/class.friend/p1-cxx11.cpp b/test/CXX/class/class.friend/p1-cxx11.cpp
new file mode 100644
index 0000000..235f295
--- /dev/null
+++ b/test/CXX/class/class.friend/p1-cxx11.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+class A {
+ class AInner {
+ };
+
+ void a_member();
+ friend void A::a_member(); // ok in c++11, ill-formed in c++98
+ friend void a_member(); // ok in both, refers to non-member
+ friend class A::AInner; // ok in c++11, extension in c++98
+ friend class AInner; // ok in both, refers to non-member
+};
diff --git a/test/CXX/class/class.friend/p1.cpp b/test/CXX/class/class.friend/p1.cpp
index bb1af10..07b3a10 100644
--- a/test/CXX/class/class.friend/p1.cpp
+++ b/test/CXX/class/class.friend/p1.cpp
@@ -29,36 +29,36 @@ class A {
friend class PreDeclared;
friend class Outer::Inner;
- friend int Outer::Inner::intfield; // expected-error {{ friends can only be classes or functions }}
- friend int Outer::Inner::missing_field; //expected-error {{ friends can only be classes or functions }}
+ friend int Outer::Inner::intfield; // expected-error {{friends can only be classes or functions}}
+ friend int Outer::Inner::missing_field; //expected-error {{friends can only be classes or functions}}
friend int myoperation(float); // okay
- friend int myglobal; // expected-error {{ friends can only be classes or functions }}
+ friend int myglobal; // expected-error {{friends can only be classes or functions}}
friend void global_function();
friend void global_c_function();
friend class UndeclaredSoFar;
- UndeclaredSoFar x; // expected-error {{ unknown type name 'UndeclaredSoFar' }}
+ UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}}
void a_member();
- friend void A::a_member(); // expected-error {{ friends cannot be members of the declaring class }}
+ friend void A::a_member(); // expected-error {{friends cannot be members of the declaring class}}
friend void a_member(); // okay (because we ignore class scopes when looking up friends)
friend class A::AInner; // this is okay as an extension
friend class AInner; // okay, refers to ::AInner
- friend void Derived::missing_member(); // expected-error {{ no function named 'missing_member' with type 'void ()' was found in the specified scope }}
+ friend void Derived::missing_member(); // expected-error {{no function named 'missing_member' with type 'void ()' was found in the specified scope}}
- friend void Derived::base_member(); // expected-error {{ no function named 'base_member' with type 'void ()' was found in the specified scope }}
+ friend void Derived::base_member(); // expected-error {{no function named 'base_member' with type 'void ()' was found in the specified scope}}
friend int Base::typedeffed_member(); // okay: should look through typedef
// These test that the friend is properly not being treated as a
// member function.
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 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 }} \
- // expected-error{{type qualifier is not allowed on this function}}
+ friend operator bool() const; // expected-error {{must use a qualified name when declaring a conversion operator as a friend}} \
+ // expected-error{{non-member function cannot have 'const' qualifier}}
typedef void ftypedef();
friend ftypedef typedeffed_function; // okay (because it's not declared as a member)
diff --git a/test/CXX/class/class.friend/p6.cpp b/test/CXX/class/class.friend/p6.cpp
index 82a90ff..7d7a064 100644
--- a/test/CXX/class/class.friend/p6.cpp
+++ b/test/CXX/class/class.friend/p6.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify %s
class A {
friend static class B; // expected-error {{'static' is invalid in friend declarations}}
diff --git a/test/CXX/class/class.local/p1-0x.cpp b/test/CXX/class/class.local/p1-0x.cpp
new file mode 100644
index 0000000..49125f5
--- /dev/null
+++ b/test/CXX/class/class.local/p1-0x.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+void f() {
+ int x = 3; // expected-note{{'x' declared here}}
+ const int c = 2;
+ struct C {
+ int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
+ int cc = c;
+ };
+ (void)[]() mutable {
+ int x = 3; // expected-note{{'x' declared here}}
+ struct C {
+ int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}}
+ };
+ };
+ C();
+}
+
diff --git a/test/CXX/class/class.local/p1.cpp b/test/CXX/class/class.local/p1.cpp
index 05ae5c7..62ade5c 100644
--- a/test/CXX/class/class.local/p1.cpp
+++ b/test/CXX/class/class.local/p1.cpp
@@ -8,7 +8,7 @@ void f()
extern int g();
struct local {
- int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosed function 'f'}}
+ int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
int h() { return s; }
int k() { return :: x; }
int l() { return g(); }
diff --git a/test/CXX/class/class.local/p3.cpp b/test/CXX/class/class.local/p3.cpp
index c24d5d8..3753790 100644
--- a/test/CXX/class/class.local/p3.cpp
+++ b/test/CXX/class/class.local/p3.cpp
@@ -24,7 +24,7 @@ void f2() {
void f3(int a) { // expected-note{{'a' declared here}}
struct X {
struct Y {
- int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosed function 'f3'}}
+ int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}}
};
};
}
diff --git a/test/CXX/class/class.mem/p13.cpp b/test/CXX/class/class.mem/p13.cpp
index 7cded23..8488584 100644
--- a/test/CXX/class/class.mem/p13.cpp
+++ b/test/CXX/class/class.mem/p13.cpp
@@ -17,7 +17,7 @@ struct X1 { // expected-note{{previous use is here}}
};
struct X2 {
- typedef int X2; // expected-error{{member 'X2' has the same name as its class)}}
+ 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
diff --git a/test/CXX/class/class.nest/p1-cxx0x.cpp b/test/CXX/class/class.nest/p1-cxx0x.cpp
index 0f12579..b7a1a48 100644
--- a/test/CXX/class/class.nest/p1-cxx0x.cpp
+++ b/test/CXX/class/class.nest/p1-cxx0x.cpp
@@ -9,6 +9,6 @@ class Outer {
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 }}
+ 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 350cc81..b0341da 100644
--- a/test/CXX/class/class.nest/p1.cpp
+++ b/test/CXX/class/class.nest/p1.cpp
@@ -5,10 +5,10 @@ class Outer {
static int sx;
int f();
- // 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.
+ // C++11 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 a[sizeof(x)]; // expected-error {{invalid use of non-static 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 }}
+ static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
};
};
diff --git a/test/CXX/class/class.static/class.static.data/p3.cpp b/test/CXX/class/class.static/class.static.data/p3.cpp
index 007e416..117997e 100644
--- a/test/CXX/class/class.static/class.static.data/p3.cpp
+++ b/test/CXX/class/class.static/class.static.data/p3.cpp
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-struct NonLit {
+struct NonLit { // expected-note 3{{no constexpr constructors}}
NonLit();
};
struct S {
static constexpr int a = 0;
- static constexpr int b; // expected-error {{declaration of constexpr variable 'b' requires an initializer}}
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
static constexpr int c = 0;
static const int d;
@@ -24,3 +24,21 @@ constexpr int S::b = 0;
const int S::c;
constexpr int S::d = 0;
constexpr int S::d2;
+
+template<typename T>
+struct U {
+ static constexpr int a = 0;
+ static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
+ static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}}
+ static constexpr T c = T(); // expected-error {{cannot have non-literal type}}
+ static const T d;
+};
+
+template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}}
+
+U<int> u1;
+U<NonLit> u2; // expected-note {{here}}
+
+static_assert(U<int>::a == 0, "");
+
+constexpr int outofline = (U<NonLit>::d, 0); // expected-note {{here}} expected-warning {{unused}}
diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp
index 011185f..f344ae5 100644
--- a/test/CXX/class/class.union/p1.cpp
+++ b/test/CXX/class/class.union/p1.cpp
@@ -19,6 +19,9 @@ class Ctor {
class Ctor2 {
Ctor2(); // expected-note 3 {{because type 'Ctor2' has a user-declared constructor}}
};
+class CtorTmpl {
+ template<typename T> CtorTmpl(); // expected-note {{because type 'CtorTmpl' has a user-declared constructor}}
+};
class CopyCtor {
CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}}
@@ -38,6 +41,7 @@ union U1 {
VirtualBase vbase; // expected-error {{union member 'vbase' has a non-trivial copy constructor}}
Ctor ctor; // expected-error {{union member 'ctor' has a non-trivial constructor}}
Ctor2 ctor2; // expected-error {{union member 'ctor2' has a non-trivial constructor}}
+ CtorTmpl ctortmpl; // expected-error {{union member 'ctortmpl' has a non-trivial constructor}}
CopyCtor copyctor; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}}
CopyAssign copyassign; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}}
Dtor dtor; // expected-error {{union member 'dtor' has a non-trivial destructor}}
@@ -91,8 +95,9 @@ union U3 {
};
union U4 {
- static int i1; // expected-error {{static data member 'i1' not allowed in union}}
+ static int i1; // expected-warning {{static data member 'i1' in union is a C++11 extension}}
};
+int U4::i1 = 10;
union U5 {
int& i1; // expected-error {{union member 'i1' has reference type 'int &'}}
diff --git a/test/CXX/class/class.union/p2-0x.cpp b/test/CXX/class/class.union/p2-0x.cpp
new file mode 100644
index 0000000..b5c4109
--- /dev/null
+++ b/test/CXX/class/class.union/p2-0x.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+// Unlike in C++98, C++11 allows unions to have static data members.
+
+union U1 {
+ static constexpr int k1 = 0;
+ static const int k2 = k1;
+ static int k3 = k2; // expected-error {{non-const static data member must be initialized out of line}}
+ static constexpr double k4 = k2;
+ static const double k5 = k4; // expected-warning {{GNU extension}} expected-note {{use 'constexpr'}}
+ int n[k1 + 3];
+};
+
+constexpr int U1::k1;
+constexpr int U1::k2;
+int U1::k3;
+
+const double U1::k4;
+const double U1::k5;
+
+template<typename T>
+union U2 {
+ static const int k1;
+ static double k2;
+ T t;
+};
+template<typename T> constexpr int U2<T>::k1 = sizeof(U2<T>);
+template<typename T> double U2<T>::k2 = 5.3;
+
+static_assert(U2<int>::k1 == sizeof(int), "");
+static_assert(U2<char>::k1 == sizeof(char), "");
+
+union U3 {
+ static const int k;
+ U3() : k(0) {} // expected-error {{does not name a non-static data member}}
+};
+
+struct S {
+ union {
+ static const int n; // expected-error {{static members cannot be declared in an anonymous union}}
+ int a;
+ int b;
+ };
+};
+static union {
+ static const int k; // expected-error {{static members cannot be declared in an anonymous union}}
+ int n;
+};
diff --git a/test/CXX/class/p6-0x.cpp b/test/CXX/class/p6-0x.cpp
index 3384af0..f2cf482 100644
--- a/test/CXX/class/p6-0x.cpp
+++ b/test/CXX/class/p6-0x.cpp
@@ -13,3 +13,18 @@ static_assert(!__is_trivial(NonTrivial2), "NonTrivial2 is trivial");
static_assert(!__is_trivial(NonTrivial3), "NonTrivial3 is trivial");
static_assert(!__is_trivial(NonTrivial4), "NonTrivial4 is trivial");
static_assert(!__is_trivial(NonTrivial5), "NonTrivial5 is trivial");
+
+struct Trivial2 {
+ Trivial2() = default;
+ Trivial2(const Trivial2 &) = default;
+ Trivial2(Trivial2 &&) = default;
+ Trivial2 &operator=(const Trivial2 &) = default;
+ Trivial2 &operator=(Trivial2 &) = default;
+ ~Trivial2() = default;
+};
+
+class NonTrivial6 { ~NonTrivial6(); };
+
+NonTrivial6::~NonTrivial6() = default;
+
+static_assert(!__is_trivial(NonTrivial6), "NonTrivial6 is trivial");
diff --git a/test/CXX/conv/conv.prom/p2.cpp b/test/CXX/conv/conv.prom/p2.cpp
new file mode 100644
index 0000000..8d75419
--- /dev/null
+++ b/test/CXX/conv/conv.prom/p2.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fshort-wchar -ffreestanding %s
+
+#include <stdint.h>
+
+// In theory, the promoted types vary by platform; however, in reality they
+// are quite consistent across all platforms where clang runs.
+
+extern int promoted_wchar;
+extern decltype(+L'a') promoted_wchar;
+
+extern int promoted_char16;
+extern decltype(+u'a') promoted_char16;
+
+extern unsigned promoted_char32;
+extern decltype(+U'a') promoted_char32;
diff --git a/test/CXX/conv/conv.prom/p4.cpp b/test/CXX/conv/conv.prom/p4.cpp
new file mode 100644
index 0000000..02a91cd
--- /dev/null
+++ b/test/CXX/conv/conv.prom/p4.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+enum X : short { A, B };
+extern decltype(+A) x;
+extern int x;
+
+enum Y : long { C, D };
+extern decltype(+C) y;
+extern long y;
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 634369d..bf30ee7 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
@@ -39,7 +39,7 @@ namespace Test0 {
test<2> _1 = (foo)(a);
class Test0::foo b;
- test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo' is possible}}
+ test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}}
}
}
}
@@ -76,7 +76,7 @@ namespace test2 {
class B : private A {
protected:
- using A::operator int; // expected-note {{'declared protected here'}}
+ using A::operator int; // expected-note {{declared protected here}}
public:
using A::operator bool;
};
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
index 63b3022..c7966ce 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
@@ -12,26 +12,26 @@
namespace test0 {
namespace ns { void foo(); } // expected-note {{target of using declaration}}
- int foo(); // expected-note {{conflicting declaration}}
+ int foo(void); // expected-note {{conflicting declaration}}
using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
}
namespace test1 {
namespace ns { void foo(); } // expected-note {{target of using declaration}}
using ns::foo; //expected-note {{using declaration}}
- int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
}
namespace test2 {
namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
void test0() {
- int foo(); // expected-note {{conflicting declaration}}
+ int foo(void); // expected-note {{conflicting declaration}}
using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
}
void test1() {
using ns::foo; //expected-note {{using declaration}}
- int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
}
}
@@ -39,7 +39,7 @@ namespace test3 {
namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
class Test0 {
void test() {
- int foo(); // expected-note {{conflicting declaration}}
+ int foo(void); // expected-note {{conflicting declaration}}
using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
}
};
@@ -47,7 +47,7 @@ namespace test3 {
class Test1 {
void test() {
using ns::foo; //expected-note {{using declaration}}
- int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
}
};
}
@@ -56,7 +56,7 @@ namespace test4 {
namespace ns { void foo(); } // expected-note 2 {{target of using declaration}}
template <typename> class Test0 {
void test() {
- int foo(); // expected-note {{conflicting declaration}}
+ int foo(void); // expected-note {{conflicting declaration}}
using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}}
}
};
@@ -64,16 +64,14 @@ namespace test4 {
template <typename> class Test1 {
void test() {
using ns::foo; //expected-note {{using declaration}}
- int foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}}
}
};
}
// FIXME: we should be able to diagnose both of these, but we can't.
-// ...I'm actually not sure why we can diagnose either of them; it's
-// probably a bug.
namespace test5 {
- namespace ns { void foo(int); } // expected-note {{target of using declaration}}
+ namespace ns { void foo(int); }
template <typename T> class Test0 {
void test() {
int foo(T);
@@ -83,12 +81,11 @@ namespace test5 {
template <typename T> class Test1 {
void test() {
- using ns::foo; // expected-note {{using declaration}}
- int foo(T); // expected-error {{declaration conflicts with target of using declaration already in scope}}
+ using ns::foo;
+ int foo(T);
}
};
template class Test0<int>;
- template class Test1<int>; // expected-note {{in instantiation of member function}}
+ template class Test1<int>;
}
-
diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
new file mode 100644
index 0000000..f9702ba
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace std_example {
+
+int p[10];
+void f() {
+ int x = 42, y[5];
+ // FIXME: Produce a better diagnostic for this case.
+ int(p[[x] { return x; }()]); // expected-error {{expected ']'}}
+ y[[] { return 2; }()] = 2; // expected-error {{consecutive left square brackets}}
+}
+
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index ed98c1e..6820fc6 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-struct notlit {
+struct notlit { // expected-note {{not literal because}}
notlit() {}
};
struct notlit2 {
@@ -20,7 +20,7 @@ constexpr int s1::mi2 = 0;
// not a definition of an object
constexpr extern int i2; // expected-error {{constexpr variable declaration must be a definition}}
// not a literal type
-constexpr notlit nl1; // expected-error {{declaration of constexpr variable 'nl1' requires an initializer}}
+constexpr notlit nl1; // expected-error {{constexpr variable cannot have non-literal type 'const notlit'}}
// function parameters
void f2(constexpr int i) {} // expected-error {{function parameter cannot be constexpr}}
// non-static member
@@ -35,6 +35,9 @@ constexpr class C1 {}; // expected-error {{class cannot be marked constexpr}}
constexpr struct S1 {}; // expected-error {{struct cannot be marked constexpr}}
constexpr union U1 {}; // expected-error {{union cannot be marked constexpr}}
constexpr enum E1 {}; // expected-error {{enum cannot be marked constexpr}}
+template <typename T> constexpr class TC1 {}; // expected-error {{class cannot be marked constexpr}}
+template <typename T> constexpr struct TS1 {}; // expected-error {{struct cannot be marked constexpr}}
+template <typename T> constexpr union TU1 {}; // expected-error {{union cannot be marked constexpr}}
class C2 {} constexpr; // expected-error {{class cannot be marked constexpr}}
struct S2 {} constexpr; // expected-error {{struct cannot be marked constexpr}}
union U2 {} constexpr; // expected-error {{union cannot be marked constexpr}}
@@ -72,21 +75,18 @@ struct S {
};
// explicit specialization can differ in constepxr
-// FIXME: When checking the explicit specialization, we implicitly instantiate
-// the primary template then claim a constexpr mismatch.
template <> notlit ft(notlit nl) { return nl; }
-template <> char ft(char c) { return c; } // desired-note {{previous}} unexpected-error {{follows constexpr declaration}} unexpected-note {{here}}
-template <> constexpr char ft(char nl); // desired-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}}
-template <> constexpr int gt(int nl) { return nl; } // unexpected-error {{follows non-constexpr declaration}} unexpected-note {{here}}
+template <> char ft(char c) { return c; } // expected-note {{previous}}
+template <> constexpr char ft(char nl); // expected-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}}
+template <> constexpr int gt(int nl) { return nl; }
template <> notlit S::f() const { return notlit(); }
-template <> constexpr int S::g() { return 0; } // desired-note {{previous}} unexpected-error {{follows non-constexpr declaration}} unexpected-note {{here}}
-template <> int S::g() const; // desired-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}}
+template <> constexpr int S::g() { return 0; } // expected-note {{previous}}
+template <> int S::g() const; // expected-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}}
// specializations can drop the 'constexpr' but not the implied 'const'.
template <> char S::g() { return 0; } // expected-error {{no function template matches}}
template <> double S::g() const { return 0; } // ok
-// FIXME: The initializer is a constant expression.
-constexpr int i3 = ft(1); // unexpected-error {{must be initialized by a constant expression}}
+constexpr int i3 = ft(1);
void test() {
// ignore constexpr when instantiating with non-literal
@@ -95,7 +95,7 @@ void test() {
}
// Examples from the standard:
-constexpr int square(int x);
+constexpr int square(int x); // expected-note {{declared here}}
constexpr int bufsz = 1024;
constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}}
@@ -105,17 +105,16 @@ constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}}
};
constexpr pixel::pixel(int a)
- : x(square(a)), y(square(a))
+ : x(square(a)), y(square(a)) // expected-note {{undefined function 'square' cannot be used in a constant expression}}
{ }
-constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}}
+constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'pixel(2)'}}
constexpr int square(int x) {
return x * x;
}
-// FIXME: The initializer is a constant expression.
-constexpr pixel large(4); // unexpected-error {{must be initialized by a constant expression}}
+constexpr pixel large(4);
int next(constexpr int x) { // expected-error {{function parameter cannot be constexpr}}
return x + 1;
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 03406db..cafdd63 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -8,7 +8,7 @@ namespace M {
typedef double D;
}
-struct NonLiteral { // expected-note 4{{no constexpr constructors}}
+struct NonLiteral { // expected-note 2{{no constexpr constructors}}
NonLiteral() {}
NonLiteral(int) {}
};
@@ -24,30 +24,28 @@ struct SS : S {
int ImplicitlyVirtual() const;
};
-// Note, the wording applies constraints to the definition of constexpr
-// functions, but we intentionally apply all that we can to the declaration
-// instead. See DR1360.
-
// The definition of a constexpr function shall satisfy the following
// constraints:
-struct T : SS { // expected-note {{base class 'SS' of non-literal type}}
- constexpr T(); // expected-error {{non-literal type 'T' cannot have constexpr members}}
+struct T : SS, NonLiteral { // expected-note {{base class 'NonLiteral' of non-literal type}}
+ constexpr T();
+ constexpr int f(); // expected-error {{non-literal type 'T' cannot have constexpr members}}
// - it shall not be virtual;
- virtual constexpr int ExplicitlyVirtual(); // expected-error {{virtual function cannot be constexpr}}
+ virtual constexpr int ExplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
- constexpr int ImplicitlyVirtual(); // expected-error {{virtual function cannot be constexpr}}
+ constexpr int ImplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
// - its return type shall be a literal type;
- constexpr NonLiteral NonLiteralReturn(); // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr NonLiteral NonLiteralReturn() { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr void VoidReturn() { return; } // expected-error {{constexpr function's return type 'void' is not a literal type}}
constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}}
typedef NonLiteral F();
- constexpr F NonLiteralReturn2; // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr F NonLiteralReturn2; // ok until definition
// - each of its parameter types shall be a literal type;
- constexpr int NonLiteralParam(NonLiteral); // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
+ constexpr int NonLiteralParam(NonLiteral) { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
typedef int G(NonLiteral);
- constexpr G NonLiteralParam2; // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
+ constexpr G NonLiteralParam2; // ok until definition
// - its function-body shall be = delete, = default,
constexpr int Deleted() = delete;
@@ -63,6 +61,10 @@ struct U {
constexpr int SelfParam(U);
};
+struct V : virtual U { // expected-note {{here}}
+ constexpr int F() { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}}
+};
+
// or a compound-statememt that contains only
constexpr int AllowedStmts() {
// - null statements
@@ -123,3 +125,15 @@ constexpr int MultiReturn() {
// return value shall be one of those allowed in a constant expression.
//
// We implement the proposed resolution of DR1364 and ignore this bullet.
+// However, we implement the spirit of the check as part of the p5 checking that
+// a constexpr function must be able to produce a constant expression.
+namespace DR1364 {
+ constexpr int f(int k) {
+ return k; // ok, even though lvalue-to-rvalue conversion of a function
+ // parameter is not allowed in a constant expression.
+ }
+ int kGlobal; // expected-note {{here}}
+ constexpr int f() { // expected-error {{constexpr function never produces a constant expression}}
+ return kGlobal; // expected-note {{read of non-const}}
+ }
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
index 9218bcf..65573c7 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -14,19 +14,16 @@ struct NonLiteral { // expected-note 2{{no constexpr constructors}}
};
struct Literal {
constexpr Literal() {}
+ explicit Literal(int); // expected-note 2 {{here}}
operator int() const { return 0; }
};
-// Note, the wording applies constraints to the definition of constexpr
-// constructors, but we intentionally apply all that we can to the declaration
-// instead. See DR1360.
-
// In the definition of a constexpr constructor, each of the parameter types
// shall be a literal type.
struct S {
- constexpr S(int, N::C);
- constexpr S(int, NonLiteral, N::C); // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
- constexpr S(int, NonLiteral = 42); // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
+ constexpr S(int, N::C) {}
+ constexpr S(int, NonLiteral, N::C) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
+ constexpr S(int, NonLiteral = 42) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}}
// In addition, either its function-body shall be = delete or = default
constexpr S() = default;
@@ -37,14 +34,14 @@ struct S {
// - the class shall not have any virtual base classes;
struct T : virtual S { // expected-note {{here}}
- constexpr T(); // expected-error {{constexpr constructor not allowed in struct with virtual base classes}}
+ constexpr T() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
};
namespace IndirectVBase {
struct A {};
struct B : virtual A {}; // expected-note {{here}}
class C : public B {
public:
- constexpr C(); // expected-error {{constexpr constructor not allowed in class with virtual base classes}}
+ constexpr C() {} // expected-error {{constexpr constructor not allowed in class with virtual base class}}
};
}
@@ -150,6 +147,16 @@ struct AnonMembers {
constexpr AnonMembers(int(&)[6]) {} // expected-error {{constexpr constructor must initialize all members}}
};
+union Empty {
+ constexpr Empty() {} // ok
+} constexpr empty1;
+
+struct EmptyVariant {
+ union {};
+ struct {};
+ constexpr EmptyVariant() {} // ok
+} constexpr empty2;
+
template<typename T> using Int = int;
template<typename T>
struct TemplateInit {
@@ -190,9 +197,17 @@ constexpr int f(enable_shared_from_this<int>);
// - every constructor involved in initializing non-static data members and base
// class sub-objects shall be a constexpr constructor.
-//
-// FIXME: Implement this as part of the 'must be able to produce a constant
-// expression' rules.
+struct ConstexprBaseMemberCtors : Literal {
+ Literal l;
+
+ constexpr ConstexprBaseMemberCtors() : Literal(), l() {} // ok
+ constexpr ConstexprBaseMemberCtors(char) : // expected-error {{constexpr constructor never produces a constant expression}}
+ Literal(0), // expected-note {{non-constexpr constructor}}
+ l() {}
+ constexpr ConstexprBaseMemberCtors(double) : Literal(), // expected-error {{constexpr constructor never produces a constant expression}}
+ l(0) // expected-note {{non-constexpr constructor}}
+ {}
+};
// - every assignment-expression that is an initializer-caluse appearing
// directly or indirectly within a brace-or-equal-initializer for a non-static
@@ -215,6 +230,14 @@ struct X {
// expression.
//
// We implement the proposed resolution of DR1364 and ignore this bullet.
+// However, we implement the intent of this wording as part of the p5 check that
+// the function must be able to produce a constant expression.
+int kGlobal; // expected-note {{here}}
+struct Z {
+ constexpr Z(int a) : n(a) {}
+ constexpr Z() : n(kGlobal) {} // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}}
+ int n;
+};
namespace StdExample {
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
new file mode 100644
index 0000000..fd17d35
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fcxx-exceptions -Wno-invalid-constexpr %s
+
+namespace StdExample {
+
+constexpr int f(void *) { return 0; }
+constexpr int f(...) { return 1; }
+constexpr int g1() { return f(0); }
+constexpr int g2(int n) { return f(n); }
+constexpr int g3(int n) { return f(n*0); }
+
+namespace N {
+ constexpr int c = 5;
+ constexpr int h() { return c; }
+}
+constexpr int c = 0;
+constexpr int g4() { return N::h(); }
+
+static_assert(f(0) == 0, "");
+static_assert(f('0') == 1, "");
+static_assert(g1() == 0, "");
+static_assert(g2(0) == 1, "");
+static_assert(g2(1) == 1, "");
+static_assert(g3(0) == 1, "");
+static_assert(g3(1) == 1, "");
+static_assert(N::h() == 5, "");
+static_assert(g4() == 5, "");
+
+
+constexpr int f(bool b)
+ { return b ? throw 0 : 0; } // ok
+constexpr int f() { return throw 0, 0; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{subexpression}}
+
+struct B {
+ constexpr B(int x) : i(0) { }
+ int i;
+};
+
+int global; // expected-note {{declared here}}
+
+struct D : B {
+ constexpr D() : B(global) { } // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}}
+};
+
+}
+
+namespace PotentialConstant {
+
+constexpr int Comma(int n) { return // expected-error {{constexpr function never produces a constant expression}}
+ (void)(n * 2),
+ throw 0, // expected-note {{subexpression}}
+ 0;
+}
+
+int ng; // expected-note 6{{here}}
+constexpr int BinaryOp1(int n) { return n + ng; } // expected-error {{never produces}} expected-note {{read}}
+constexpr int BinaryOp2(int n) { return ng + n; } // expected-error {{never produces}} expected-note {{read}}
+
+double dg; // expected-note 2{{here}}
+constexpr double BinaryOp1(double d) { return d + dg; } // expected-error {{never produces}} expected-note {{read}}
+constexpr double BinaryOp2(double d) { return dg + d; } // expected-error {{never produces}} expected-note {{read}}
+
+constexpr int Add(int a, int b, int c) { return a + b + c; }
+constexpr int FunctionArgs(int a) { return Add(a, ng, a); } // expected-error {{never produces}} expected-note {{read}}
+
+struct S { int a; int b; int c[2]; };
+constexpr S InitList(int a) { return { a, ng }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList1a(int a) { return S{ a, ng }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList2(int a) { return { a, a, { ng } }; }; // expected-error {{never produces}} expected-note {{read}}
+constexpr S InitList3(int a) { return a ? S{ a, a } : S{ a, ng }; }; // ok
+
+constexpr int LogicalAnd1(int n) { return n && (throw, 0); } // ok
+constexpr int LogicalAnd2(int n) { return 1 && (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}}
+
+constexpr int LogicalOr1(int n) { return n || (throw, 0); } // ok
+constexpr int LogicalOr2(int n) { return 0 || (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}}
+
+constexpr int Conditional1(bool b, int n) { return b ? n : ng; } // ok
+constexpr int Conditional2(bool b, int n) { return b ? n * ng : n + ng; } // expected-error {{never produces}} expected-note {{both arms of conditional operator are unable to produce a constant expression}}
+
+// __builtin_constant_p ? : is magical, and is always a potential constant.
+constexpr bool BcpCall(int n) {
+ return __builtin_constant_p((int*)n != &n) ? (int*)n != &n : (int*)n != &n;
+}
+static_assert(BcpCall(0), "");
+
+// DR1311: A function template which can produce a constant expression, but
+// for which a particular specialization cannot, is ok.
+template<typename T> constexpr T cmin(T a, T b) {
+ return a < b ? a : b;
+}
+int n = cmin(3, 5); // ok
+
+struct X {
+ constexpr X() {}
+ bool operator<(X); // not constexpr
+};
+
+X x = cmin(X(), X()); // ok, not constexpr
+
+// Same with other temploids.
+template<typename T>
+struct Y {
+ constexpr Y() {}
+ constexpr int get() { return T(); }
+};
+struct Z { operator int(); };
+
+int y1 = Y<int>().get(); // ok
+int y2 = Y<Z>().get(); // ok
+
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
index e383bc0..1a6dc9e 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
@@ -10,7 +10,7 @@ namespace M {
struct NonLiteral {
NonLiteral() {}
- NonLiteral(int) {}
+ NonLiteral(int) {} // expected-note 2{{here}}
operator int() const { return 0; }
};
struct Literal {
@@ -19,7 +19,7 @@ struct Literal {
};
struct S {
- virtual int ImplicitlyVirtual();
+ virtual int ImplicitlyVirtual() const;
};
struct T {};
@@ -27,48 +27,42 @@ template<typename T> struct ImplicitVirtualFromDependentBase : T {
constexpr int ImplicitlyVirtual() { return 0; }
};
-// FIXME: Can't test this until we have function invocation substitution
-#if 0
-constexpr int a = ImplicitVirtualFromDependentBase<S>().ImplicitlyVirtual(); // desired-error {{not a constant expression}}
+constexpr int a = ImplicitVirtualFromDependentBase<S>().ImplicitlyVirtual(); // expected-error {{constant expression}} expected-note {{cannot evaluate virtual function call}}
constexpr int b = ImplicitVirtualFromDependentBase<T>().ImplicitlyVirtual(); // ok
-#endif
+constexpr int c = ImplicitVirtualFromDependentBase<S>().ImplicitVirtualFromDependentBase<S>::ImplicitlyVirtual();
template<typename R> struct ConstexprMember {
constexpr R F() { return 0; }
};
-// FIXME: Can't test this until we have function invocation substitution
-#if 0
-constexpr int c = ConstexprMember<int>().F(); // ok
-constexpr int d = ConstexprMember<NonLiteral>().F(); // desired-error {{not a constant expression}}
-#endif
+constexpr int d = ConstexprMember<int>().F(); // ok
+constexpr int e = ConstexprMember<NonLiteral>().F(); // expected-error {{constant expression}}
-template<typename ...P> struct ConstexprCtor { // expected-note 2{{no constexpr constructors}}
- constexpr ConstexprCtor(P...); // expected-note {{constructor template instantiation is not constexpr because 1st parameter type 'NonLiteral' is not a literal type}} \
- expected-note {{constructor template instantiation is not constexpr because 2nd parameter type 'NonLiteral' is not a literal type}}
+template<typename ...P> struct ConstexprCtor {
+ constexpr ConstexprCtor(P...) {}
};
-constexpr ConstexprCtor<> f1(); // ok
-constexpr ConstexprCtor<int> f2(); // ok
-constexpr ConstexprCtor<NonLiteral> f3(); // expected-error {{not a literal type}}
-constexpr ConstexprCtor<int, NonLiteral> f4(); // expected-error {{not a literal type}}
+constexpr ConstexprCtor<> f1() { return {}; } // ok
+constexpr ConstexprCtor<int> f2() { return 0; } // ok
+constexpr ConstexprCtor<NonLiteral> f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
+constexpr ConstexprCtor<int, NonLiteral> f4() { return { 0, 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
struct VirtBase : virtual S {}; // expected-note {{here}}
namespace TemplateVBase {
template<typename T> struct T1 : virtual Literal { // expected-note {{here}}
- constexpr T1(); // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
+ constexpr T1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}}
};
- template<typename T> struct T2 : virtual T { // expected-note {{struct with virtual base class is not a literal type}} expected-note {{here}}
+ template<typename T> struct T2 : virtual T {
// FIXME: This is ill-formed (no diagnostic required).
// We should diagnose it now rather than waiting until instantiation.
- constexpr T2(); // desired-error {{constexpr constructor not allowed in class with virtual base classes}}
+ constexpr T2() {}
};
- constexpr T2<Literal> g2(); // expected-error {{not a literal type}}
+ constexpr T2<Literal> g2() { return {}; }
template<typename T> class T3 : public T { // expected-note {{class with virtual base class is not a literal type}}
public:
constexpr T3() {}
};
- constexpr T3<Literal> g3(); // ok
- constexpr T3<VirtBase> g4(); // expected-error {{not a literal type}}
+ constexpr T3<Literal> g3() { return {}; } // ok
+ constexpr T3<VirtBase> g4() { return {}; } // expected-error {{not a literal type}}
}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
index f7da24d..c4935b3 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
@@ -1,13 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct S {
- constexpr void f();
- constexpr void g() const;
+ constexpr int f();
+ constexpr int g() const;
+ static constexpr int Sf();
};
void f(const S &s) {
s.f();
s.g();
+
+ int (*f)() = &S::Sf;
+ int (S::*g)() const = &S::g;
}
namespace std_example {
@@ -26,3 +30,9 @@ namespace std_example {
{ return x * 2 + 3 * y; }
}
+
+// The constexpr specifier is allowed for static member functions of non-literal types.
+class NonLiteralClass {
+ NonLiteralClass(bool);
+ static constexpr bool isDebugFlag();
+};
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
index 53d232d..2412a14 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp
@@ -5,7 +5,7 @@
constexpr int a = 0;
extern const int a;
-int i;
+int i; // expected-note 2{{here}}
constexpr int *b = &i;
extern int *const b;
@@ -17,21 +17,21 @@ extern int (*const d)(int);
// A variable declaration which uses the constexpr specifier shall have an
// initializer and shall be initialized by a constant expression.
-constexpr int ni1; // expected-error {{declaration of constexpr variable 'ni1' requires an initializer}}
-constexpr struct C { C(); } ni2; // expected-error {{declaration of constexpr variable 'ni2' requires an initializer}}
-constexpr double &ni3; // expected-error {{declaration of constexpr variable 'ni3' requires an initializer}}
+constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}}
+constexpr struct C { C(); } ni2; // expected-error {{cannot have non-literal type 'const struct C'}} expected-note 3{{has no constexpr constructors}}
+constexpr double &ni3; // expected-error {{declaration of reference variable 'ni3' requires an initializer}}
-constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}}
-constexpr C nc2 = C(); // expected-error {{constexpr variable 'nc2' must be initialized by a constant expression}}
-int &f();
-constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}}
-constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}}
-constexpr C nc5((C())); // expected-error {{constexpr variable 'nc5' must be initialized by a constant expression}}
-int &f();
-constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}}
+constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+constexpr C nc2 = C(); // expected-error {{cannot have non-literal type 'const C'}}
+int &f(); // expected-note {{declared here}}
+constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+constexpr C nc5((C())); // expected-error {{cannot have non-literal type 'const C'}}
+int &f(); // expected-note {{here}}
+constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f'}}
struct pixel {
int x, y;
};
constexpr pixel ur = { 1294, 1024 }; // ok
-constexpr pixel origin; // expected-error {{requires an initializer}}
+constexpr pixel origin; // expected-error {{default initialization of an object of const type 'const pixel' requires a user-provided default constructor}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
new file mode 100644
index 0000000..44cc5a7
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-compat %s
+
+// The auto or register specifiers can be applied only to names of objects
+// declared in a block (6.3) or to function parameters (8.4).
+
+auto int ao; // expected-error {{illegal storage class on file-scoped variable}}
+auto void af(); // expected-error {{illegal storage class on function}}
+
+register int ro; // expected-error {{illegal storage class on file-scoped variable}}
+register void rf(); // expected-error {{illegal storage class on function}}
+
+struct S {
+ auto int ao; // expected-error {{storage class specified for a member declaration}}
+ auto void af(); // expected-error {{storage class specified for a member declaration}}
+
+ register int ro; // expected-error {{storage class specified for a member declaration}}
+ register void rf(); // expected-error {{storage class specified for a member declaration}}
+};
+
+void foo(auto int ap, register int rp) {
+ auto int abo;
+ auto void abf(); // expected-error {{illegal storage class on function}}
+
+ register int rbo;
+ register void rbf(); // expected-error {{illegal storage class on function}}
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp
index 7b55775..a385aa9 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp
@@ -44,6 +44,6 @@ struct F : auto(*)()->int {}; // expected-error{{expected class name}}
template<typename T = auto(*)()->int> struct G { };
int g();
-auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed here}}
+auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed in function return type}}
auto (*i)() = &g; // ok; auto deduced as int.
auto (*k)() -> int = i; // ok; no deduction.
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 682ee9f..1daf02f 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,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions -Wc++11-compat
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}}
@@ -13,9 +13,9 @@ void g() {
auto *b; // expected-error{{declaration of variable 'b' with type 'auto *' requires an initializer}}
- if (auto b) {} // expected-error {{expected '='}}
- for (;auto b;) {} // expected-error {{expected '='}}
- while (auto b) {} // expected-error {{expected '='}}
+ if (auto b) {} // expected-error {{must have an initializer}}
+ for (;auto b;) {} // expected-error {{must have an initializer}}
+ while (auto b) {} // expected-error {{must have an initializer}}
if (auto b = true) { (void)b; }
}
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
index 095c031..e566d2a 100644
--- 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
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
template<typename T>
struct only {
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 a52ef41..71f57dc 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
@@ -60,9 +60,9 @@ int ints[] = {1, 2, 3};
template <const auto (*a)[3] = &ints> 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<typename T = auto> struct G { }; // expected-error{{'auto' not allowed here}}
+template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed in template argument}}
using A = auto; // expected-error{{'auto' not allowed in type alias}}
// FIXME: don't issue the second diagnostic for this error.
-auto k() -> auto; // expected-error{{'auto' not allowed here}} unexpected-error{{without trailing return type}}
+auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} unexpected-error{{without trailing return type}}
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
index 7ed4dae..d327efc 100644
--- 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
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
template<typename T>
struct only {
@@ -92,7 +92,7 @@ namespace PR10939 {
template<typename T> T g(T);
void f(X *x) {
- auto value = x->method; // expected-error{{variable 'value' with type 'auto' has incompatible initializer of type '<bound member function type>'}}
+ auto value = x->method; // expected-error {{reference to non-static member function must be called}}
if (value) { }
auto funcptr = &g<int>;
@@ -100,4 +100,5 @@ namespace PR10939 {
}
}
-// TODO: if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>.
+// if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>:
+// see SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
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
index 4f230cf..9c1d397 100644
--- 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
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
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'}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
index b04e869..8d58498 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-class A {}; // expected-note 3 {{previous use is here}}
+class A {}; // expected-note 4 {{previous use is here}}
+enum E {};
void a1(struct A);
void a2(class A);
@@ -12,8 +13,8 @@ class A1 {
friend class A;
friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
- friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} \
- // expected-warning {{cannot be a friend}}
+ friend enum A; // expected-error {{use of 'A' with tag type that does not match previous declaration}}
+ friend enum E; // expected-warning {{cannot be a friend}}
};
template <class T> struct B { // expected-note {{previous use is here}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
index bc60b5e..53227ea 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp
@@ -19,3 +19,9 @@ static_assert(is_same<decltype(foo()), const int&&>::value, "");
static_assert(is_same<decltype(i), int>::value, "");
static_assert(is_same<decltype(a->x), double>::value, "");
static_assert(is_same<decltype((a->x)), const double&>::value, "");
+static_assert(is_same<decltype(static_cast<int&&>(i)), int&&>::value, "");
+
+int f0(int); // expected-note{{possible target}}
+float f0(float); // expected-note{{possible target}}
+
+decltype(f0) f0_a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
new file mode 100644
index 0000000..2bd5d23
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace std_example {
+
+template<class T> struct A { ~A() = delete; }; // expected-note {{deleted here}}
+template<class T> auto h() -> A<T>;
+template<class T> auto i(T) -> T;
+template<class T> auto f(T) -> decltype(i(h<T>())); // #1
+template<class T> auto f(T) -> void; // #2
+auto g() -> void {
+ f(42); // ok, calls #2, since #1 is not viable.
+}
+template<class T> auto q(T) -> decltype((h<T>()));
+void r() {
+ // Deduction against q succeeds, but results in a temporary which can't be
+ // destroyed.
+ q(42); // expected-error {{attempt to use a deleted function}}
+}
+
+}
+
+class PD {
+ friend struct A;
+ ~PD(); // expected-note 4{{here}}
+public:
+ typedef int n;
+};
+struct DD {
+ ~DD() = delete; // expected-note 2{{here}}
+ typedef int n;
+};
+
+struct A {
+ decltype(PD()) s; // ok
+ decltype(PD())::n n; // ok
+ decltype(DD()) *p = new decltype(DD()); // ok
+};
+
+// Two errors here: one for the decltype, one for the variable.
+decltype(PD(), PD()) pd1; // expected-error 2{{private destructor}}
+decltype(DD(), DD()) dd1; // expected-error 2{{deleted function}}
+
+decltype(((13, ((DD())))))::n dd_parens; // ok
+decltype(((((42)), PD())))::n pd_parens_comma; // ok
+
+// Ensure parens aren't stripped from a decltype node.
+extern decltype(PD()) pd_ref; // ok
+decltype((pd_ref)) pd_ref3 = pd_ref; // ok, PD &
+decltype(pd_ref) pd_ref2 = pd_ref; // expected-error {{private destructor}}
+
+namespace libcxx_example {
+ struct nat {
+ nat() = delete;
+ nat(const nat&) = delete;
+ nat &operator=(const nat&) = delete;
+ ~nat() = delete;
+ };
+ struct any {
+ any(...);
+ };
+
+ template<typename T, typename U> struct is_same { static const bool value = false; };
+ template<typename T> struct is_same<T, T> { static const bool value = true; };
+
+ template<typename T> T declval();
+
+ void swap(int &a, int &b);
+ nat swap(any, any);
+
+ template<typename T> struct swappable {
+ typedef decltype(swap(declval<T&>(), declval<T&>())) type;
+ static const bool value = !is_same<type, nat>::value;
+ constexpr operator bool() { return value; }
+ };
+
+ static_assert(swappable<int>(), "");
+ static_assert(!swappable<const int>(), "");
+}
+
+namespace RequireCompleteType {
+ template<int N, bool OK> struct S {
+ static_assert(OK, "boom!"); // expected-error 2{{boom!}}
+ };
+
+ template<typename T> T make();
+ template<int N, bool OK> S<N, OK> make();
+ void consume(...);
+
+ decltype(make<0, false>()) *p1; // ok
+ decltype((make<1, false>())) *p2; // ok
+
+ // A complete type is required here in order to detect an overloaded 'operator,'.
+ decltype(123, make<2, false>()) *p3; // expected-note {{here}}
+
+ decltype(consume(make<3, false>())) *p4; // expected-note {{here}}
+
+ decltype(make<decltype(make<4, false>())>()) *p5; // ok
+}
+
+namespace Overload {
+ DD operator+(PD &a, PD &b);
+ decltype(PD()) *pd_ptr;
+ decltype(*pd_ptr + *pd_ptr) *dd_ptr; // ok
+
+ decltype(0, *pd_ptr) pd_ref2 = pd_ref; // ok
+ DD operator,(int a, PD b);
+ decltype(0, *pd_ptr) *dd_ptr2; // expected-error {{private destructor}}
+}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
index e32774a..0b518bb 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcxx-exceptions
using X = struct { // ok
};
@@ -7,21 +7,21 @@ template<typename T> using Y = struct { // expected-error {{can not be defined i
class K {
virtual ~K();
- // FIXME: Diagnostic could use some work
- operator struct S {} (); // expected-error{{ 'operator S' cannot be the name of a variable or data member}} \
- // expected-error{{expected ';' at end of declaration list}}
+ operator struct S {} (); // expected-error{{'K::S' can not be defined in a type specifier}}
};
+struct A {};
+
void f() {
int arr[3] = {1,2,3};
for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}}
}
- new struct T {}; // expected-error {{allocation of incomplete type}} expected-note {{forward declaration}}
+ new struct T {}; // expected-error {{'T' can not be defined in a type specifier}}
+ new struct A {}; // expected-error {{'A' can not be defined in a type specifier}}
- // FIXME: the diagnostic here isn't very good
- try {} catch (struct U {}); // expected-error 3{{}} expected-note 2{{}}
+ try {} catch (struct U {}) {} // expected-error {{'U' can not be defined in a type specifier}}
(void)(struct V { V(int); })0; // expected-error {{'V' can not be defined in a type specifier}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
index 0ff40bc..b06eb01 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp
@@ -15,12 +15,12 @@ namespace IllegalTypeIds {
using C = virtual void(int n); // expected-error {{type name does not allow function specifier}}
using D = explicit void(int n); // expected-error {{type name does not allow function specifier}}
using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}}
- // FIXME: this is illegal; we incorrectly accept it for typedefs too.
- using F = void(*)(int n) &&; // expected-err
+ using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}}
using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}}
+ using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}}
- using H = void(int n); // ok
- using I = void(int n) &&; // ok
+ using Y = void(int n); // ok
+ using Z = void(int n) &&; // ok
}
namespace IllegalSyntax {
@@ -124,9 +124,8 @@ namespace TagName {
}
namespace CWG1044 {
- // FIXME: this is terrible. one error is plenty.
+ // FIXME: this diagnostic isn't ideal. one diagnostic is enough.
using T = T; // expected-error {{type name requires a specifier}} \
- expected-error {{C++ requires a type specifier}} \
expected-error {{expected ';' after alias declaration}}
}
diff --git a/test/CXX/dcl.dcl/p4-0x.cpp b/test/CXX/dcl.dcl/p4-0x.cpp
new file mode 100644
index 0000000..31d4912
--- /dev/null
+++ b/test/CXX/dcl.dcl/p4-0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s
+
+struct S {
+ constexpr S(bool b) : b(b) {}
+ constexpr explicit operator bool() { return b; }
+ bool b;
+};
+struct T {
+ constexpr operator int() { return 1; }
+};
+struct U {
+ constexpr operator int() { return 1; } // expected-note {{candidate}}
+ constexpr operator long() { return 0; } // expected-note {{candidate}}
+};
+
+static_assert(S(true), "");
+static_assert(S(false), "not so fast"); // expected-error {{not so fast}}
+static_assert(T(), "");
+static_assert(U(), ""); // expected-error {{ambiguous}}
+
+static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed L"\024hi!\""}}
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
new file mode 100644
index 0000000..06dd1bb
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// An explicitly-defaulted function may be declared constexpr only if it would
+// have been implicitly declared as constexpr.
+struct S1 {
+ constexpr S1() = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+ constexpr S1(const S1&) = default;
+ constexpr S1(S1&&) = default;
+ constexpr S1 &operator=(const S1&) = default; // expected-error {{explicitly-defaulted copy assignment operator may not have}}
+ constexpr S1 &operator=(S1&&) = default; // expected-error {{explicitly-defaulted move assignment operator may not have}}
+ constexpr ~S1() = default; // expected-error {{destructor cannot be marked constexpr}}
+ int n;
+};
+struct NoCopyMove {
+ constexpr NoCopyMove() {}
+ NoCopyMove(const NoCopyMove&);
+ NoCopyMove(NoCopyMove&&);
+};
+struct S2 {
+ constexpr S2() = default;
+ constexpr S2(const S2&) = default; // expected-error {{defaulted definition of copy constructor is not constexpr}}
+ constexpr S2(S2&&) = default; // expected-error {{defaulted definition of move constructor is not constexpr}}
+ NoCopyMove ncm;
+};
+
+// If a function is explicitly defaulted on its first declaration
+// -- it is implicitly considered to be constexpr if the implicit declaration
+// would be
+struct S3 {
+ S3() = default; // expected-note {{here}}
+ S3(const S3&) = default;
+ S3(S3&&) = default;
+ constexpr S3(int n) : n(n) {}
+ int n;
+};
+constexpr S3 s3a = S3(0);
+constexpr S3 s3b = s3a;
+constexpr S3 s3c = S3();
+constexpr S3 s3d; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct S4 {
+ S4() = default;
+ S4(const S4&) = default; // expected-note {{here}}
+ S4(S4&&) = default; // expected-note {{here}}
+ NoCopyMove ncm;
+};
+constexpr S4 s4a; // ok
+constexpr S4 s4b = S4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+constexpr S4 s4c = s4a; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct S5 {
+ constexpr S5();
+ int n = 1, m = n + 3;
+};
+constexpr S5::S5() = default;
+static_assert(S5().m == 4, "");
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
index b8c1e18..7764980 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
@@ -8,55 +8,71 @@ private:
protected:
struct Inner { int m; };
public:
- bool &br;
+ bool &br; // expected-note {{default constructor of 'Aggr' is implicitly deleted because field 'br' of reference type 'bool &' would not be initialized}}
};
bool b;
Aggr ag = { b };
// with no user-provided constructors, ...
-struct NonAggr1a {
- NonAggr1a(int, int);
+struct NonAggr1a { // expected-note 2 {{candidate constructor}}
+ NonAggr1a(int, int); // expected-note {{candidate constructor}}
int k;
};
// In C++0x, 'user-provided' is only defined for special member functions, so
// this type is considered to be an aggregate. This is considered to be
// a language defect.
-NonAggr1a na1a = { 42 }; // expected-error {{non-aggregate type 'NonAggr1a'}}
+NonAggr1a na1a = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1a'}}
struct NonAggr1b {
- NonAggr1b(const NonAggr1b &);
+ NonAggr1b(const NonAggr1b &); // expected-note {{candidate constructor}}
int k;
};
-NonAggr1b na1b = { 42 }; // expected-error {{non-aggregate type 'NonAggr1b'}}
+NonAggr1b na1b = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1b'}}
// no brace-or-equal-initializers for non-static data members, ...
-struct NonAggr2 {
+struct NonAggr2 { // expected-note 3 {{candidate constructor}}
int m = { 123 };
};
-NonAggr2 na2 = { 42 }; // expected-error {{non-aggregate type 'NonAggr2'}}
+NonAggr2 na2 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr2'}}
// no private...
-struct NonAggr3 {
+struct NonAggr3 { // expected-note 3 {{candidate constructor}}
private:
int n;
};
-NonAggr3 na3 = { 42 }; // expected-error {{non-aggregate type 'NonAggr3'}}
+NonAggr3 na3 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr3'}}
// or protected non-static data members, ...
-struct NonAggr4 {
+struct NonAggr4 { // expected-note 3 {{candidate constructor}}
protected:
int n;
};
-NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}}
+NonAggr4 na4 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr4'}}
// no base classes, ...
-struct NonAggr5 : Aggr {
+struct NonAggr5 : Aggr { // expected-note 3 {{candidate constructor}}
};
-NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}}
+NonAggr5 na5 = { b }; // expected-error {{no matching constructor for initialization of 'NonAggr5'}}
+template<typename...BaseList>
+struct MaybeAggr5a : BaseList... {}; // expected-note {{default constructor of 'MaybeAggr5a<Aggr>' is implicitly deleted because base class 'Aggr' has a deleted default constructor}}
+MaybeAggr5a<> ma5a0 = {}; // ok
+MaybeAggr5a<Aggr> ma5a1 = {}; // expected-error {{call to implicitly-deleted default constructor of 'MaybeAggr5a<Aggr>'}}
// and no virtual functions.
-struct NonAggr6 {
+struct NonAggr6 { // expected-note 3 {{candidate constructor}}
virtual void f();
int n;
};
-NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}}
+NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr6'}}
+
+struct DefaultedAggr {
+ int n;
+
+ DefaultedAggr() = default;
+ DefaultedAggr(const DefaultedAggr &) = default;
+ DefaultedAggr(DefaultedAggr &&) = default;
+ DefaultedAggr &operator=(const DefaultedAggr &) = default;
+ DefaultedAggr &operator=(DefaultedAggr &) = default;
+ ~DefaultedAggr() = default;
+};
+DefaultedAggr da = { 42 } ;
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
index 5ebc22f..b30e0ec 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp
@@ -1,5 +1,17 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
void f0() {
int &ir = { 17 }; // expected-error{{reference to type 'int' cannot bind to an initializer list}}
}
+
+namespace PR12453 {
+ template<typename T>
+ void f(int i) {
+ T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \
+ // expected-note{{override this message by inserting an explicit cast}}
+ }
+
+ template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}}
+}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
index dc49deab..0bea4ed 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wc++0x-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// Verify that the appropriate fixits are emitted for narrowing conversions in
// initializer lists.
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
index 2294a4e..db20ea6 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp
@@ -31,12 +31,20 @@ struct Agg {
T t;
};
+template<typename T>
+struct Convert {
+ constexpr Convert(T v) : v(v) {}
+ constexpr operator T() const { return v; }
+ T v;
+};
+template<typename T> Convert<T> ConvertVar();
+
// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion
//
// * from a floating-point type to an integer type, or
void float_to_int() {
- Agg<char> a1 = {1.0F}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
Agg<char> a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
Agg<char> a3 = {1.0L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
@@ -46,6 +54,9 @@ void float_to_int() {
Agg<char> a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
Agg<char> a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
Agg<char> a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-error {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
}
// * from long double to double or float, or from double to float, except where
@@ -61,7 +72,7 @@ void shrink_float() {
// Variables.
Agg<float> f1 = {f}; // OK (no-op)
- Agg<float> f2 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
Agg<float> f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
// Exact constants.
Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
@@ -70,7 +81,7 @@ void shrink_float() {
Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
// Out of range constants.
- Agg<float> f8 = {1E50}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+ Agg<float> f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
Agg<float> f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
// More complex constant expression.
constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
@@ -89,6 +100,9 @@ void shrink_float() {
// More complex constant expression.
constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
+
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
}
// * from an integer type or unscoped enumeration type to a floating-point type,
@@ -107,6 +121,9 @@ void int_to_float() {
// Constants.
Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
Agg<float> f5 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
}
// * from an integer type or unscoped enumeration type to an integer type that
@@ -147,6 +164,9 @@ void shrink_int() {
// Conversions from pointers to booleans aren't narrowing conversions.
Agg<bool> b = {&b1}; // OK
+
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
}
// Be sure that type- and value-dependent expressions in templates get the error
@@ -173,3 +193,17 @@ void test_qualifiers(int i) {
// Template arguments make it harder to avoid printing qualifiers:
Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
}
+
+// Test SFINAE checks.
+template<unsigned> struct Value { };
+
+template<typename T>
+int &check_narrowed(Value<sizeof((T){1.1})>);
+
+template<typename T>
+float &check_narrowed(...);
+
+void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) {
+ int &ir = check_narrowed<double>(vd);
+ float &fr = check_narrowed<int>(vi);
+}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
new file mode 100644
index 0000000..4bcf113
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp
@@ -0,0 +1,210 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=c++11-narrowing -triple x86_64-apple-macosx10.6.7 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=narrowing -triple x86_64-apple-macosx10.6.7 -verify %s
+
+// Verify that narrowing conversions in initializer lists cause errors in C++0x
+// mode.
+
+void std_example() {
+ int x = 999; // x is not a constant expression
+ const int y = 999;
+ const int z = 99;
+ char c1 = x; // OK, though it might narrow (in this case, it does narrow)
+ char c2{x}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ char c3{y}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ char c4{z}; // OK: no narrowing needed
+ unsigned char uc1 = {5}; // OK: no narrowing needed
+ unsigned char uc2 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ unsigned int ui1 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ signed int si1 =
+ { (unsigned int)-1 }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ int ii = {2.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ float f1 { x }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ float f2 { 7 }; // OK: 7 can be exactly represented as a float
+ int f(int);
+ int a[] =
+ { 2, f(2), f(2.0) }; // OK: the double-to-int conversion is not at the top level
+}
+
+// Test each rule individually.
+
+template<typename T>
+struct Agg {
+ T t;
+};
+
+template<typename T>
+struct Convert {
+ constexpr Convert(T v) : v(v) {}
+ constexpr operator T() const { return v; }
+ T v;
+};
+template<typename T> Convert<T> ConvertVar();
+
+// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion
+//
+// * from a floating-point type to an integer type, or
+
+void float_to_int() {
+ Agg<char> a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a3 = {1.0L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+ Agg<char> a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<char> a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<char> ce1 = { Convert<float>(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{override}}
+ Agg<char> ce2 = { ConvertVar<double>() }; // expected-warning {{type 'double' cannot be narrowed to 'char'}} expected-note {{override}}
+}
+
+// * from long double to double or float, or from double to float, except where
+// the source is a constant expression and the actual value after conversion
+// is within the range of values that can be represented (even if it cannot be
+// represented exactly), or
+
+void shrink_float() {
+ // These aren't constant expressions.
+ float f = 1.0;
+ double d = 1.0;
+ long double ld = 1.0;
+
+ // Variables.
+ Agg<float> f1 = {f}; // OK (no-op)
+ Agg<float> f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{override}}
+ Agg<float> f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constants.
+ Agg<float> f4 = {1.0}; // OK (double constant represented exactly)
+ Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constants.
+ Agg<float> f6 = {0.1}; // OK (double constant in range but rounded)
+ Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constants.
+ Agg<float> f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<float> f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L;
+ Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK
+
+ // Variables.
+ Agg<double> d1 = {f}; // OK (widening)
+ Agg<double> d2 = {d}; // OK (no-op)
+ Agg<double> d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // Exact constant.
+ Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly)
+ // Inexact but in-range constant.
+ Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded)
+ // Out of range constant.
+ Agg<double> d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ // More complex constant expression.
+ constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L;
+ Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK
+
+ Agg<float> ce1 = { Convert<double>(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long double>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to a floating-point type,
+// except where the source is a constant expression and the actual value after
+// conversion will fit into the target type and will produce the original
+// value when converted back to the original type, or
+void int_to_float() {
+ // Not a constant expression.
+ char c = 1;
+
+ // Variables. Yes, even though all char's will fit into any floating type.
+ Agg<float> f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<double> f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<long double> f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Constants.
+ Agg<float> f4 = {12345678}; // OK (exactly fits in a float)
+ Agg<float> f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ Agg<float> ce1 = { Convert<int>(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{override}}
+ Agg<double> ce2 = { ConvertVar<long long>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{override}}
+}
+
+// * from an integer type or unscoped enumeration type to an integer type that
+// cannot represent all the values of the original type, except where the
+// source is a constant expression and the actual value after conversion will
+// fit into the target type and will produce the original value when converted
+// back to the original type.
+void shrink_int() {
+ // Not a constant expression.
+ short s = 1;
+ unsigned short us = 1;
+ Agg<char> c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned short> s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {us}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // "that cannot represent all the values of the original type" means that the
+ // validity of the program depends on the relative sizes of integral types.
+ // This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long
+ // long).
+ long l1 = 1;
+ Agg<int> i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ long long ll = 1;
+ Agg<long> l2 = {ll}; // OK
+
+ // Constants.
+ Agg<char> c2 = {127}; // OK
+ Agg<char> c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+
+ Agg<int> i2 = {0x7FFFFFFFU}; // OK
+ Agg<int> i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<unsigned int> i4 = {-0x80000000L}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Bool is also an integer type, but conversions to it are a different AST
+ // node.
+ Agg<bool> b1 = {0}; // OK
+ Agg<bool> b2 = {1}; // OK
+ Agg<bool> b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+
+ // Conversions from pointers to booleans aren't narrowing conversions.
+ Agg<bool> b = {&b1}; // OK
+
+ Agg<short> ce1 = { Convert<int>(100000) }; // expected-warning {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}}
+ Agg<char> ce2 = { ConvertVar<short>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}}
+}
+
+// Be sure that type- and value-dependent expressions in templates get the warning
+// too.
+
+template<int I, typename T>
+void maybe_shrink_int(T t) {
+ Agg<short> s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
+ Agg<short> s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+ Agg<T> t2 = {700}; // expected-warning {{ cannot be narrowed }} expected-note {{override}} expected-warning {{changes value}}
+}
+
+void test_template() {
+ maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}}
+ maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}}
+}
+
+
+// We don't want qualifiers on the types in the diagnostic.
+
+void test_qualifiers(int i) {
+ const int j = i;
+ struct {const unsigned char c;} c1 = {j}; // expected-warning {{from type 'int' to 'unsigned char' in}} expected-note {{override}}
+ // Template arguments make it harder to avoid printing qualifiers:
+ Agg<const unsigned char> c2 = {j}; // expected-warning {{from type 'int' to 'const unsigned char' in}} expected-note {{override}}
+}
+
+// Make sure we still get the right SFINAE behavior.
+template<unsigned> struct Value { };
+
+template<typename T>
+int &check_narrowed(Value<sizeof((T){1.1})>);
+
+template<typename T>
+float &check_narrowed(...);
+
+void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) {
+ int &ir = check_narrowed<double>(vd);
+ float &fr = check_narrowed<int>(vi);
+}
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
index 95cc56c..adbdff6 100644
--- 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
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
-// Test the C++0x-specific reference initialization rules, e.g., the
+// Test the c++0x-specific reference initialization rules, e.g., the
// rules for rvalue references.
template<typename T> T prvalue();
template<typename T> T&& xvalue();
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 8c65411..d58a129 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
@@ -30,7 +30,7 @@ template<typename T>
T get_value_badly() {
double *dp = 0;
// The extension doesn't extend far enough to turn this error into a warning.
- T *tp = dp; // expected-error{{ cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}}
+ T *tp = dp; // expected-error{{cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}}
return T();
}
@@ -54,7 +54,7 @@ void g5(const X5&);
void test() {
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]}}
+ g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private}}
g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}}
g4(X4<int>());
g5(X5()); // Generates a warning in the default argument.
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp
index 07a5cef..3631af1 100644
--- a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp
@@ -5,3 +5,15 @@ extern char x1[6];
char x2[] = "hello";
extern char x2[6];
+
+char x3[] = { "hello" };
+extern char x3[6];
+
+wchar_t x4[](L"hello");
+extern wchar_t x4[6];
+
+wchar_t x5[] = L"hello";
+extern wchar_t x5[6];
+
+wchar_t x6[] = { L"hello" };
+extern wchar_t x6[6];
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
index ce0a082..2ec1454 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp
@@ -1,20 +1,45 @@
// RUN: %clang_cc1 -std=c++11 -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}}
+void f0() &; // expected-error {{non-member function cannot have '&' qualifier}}
+void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}}
+void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}}
struct X {
- void f0() &;
+ 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}}
+ static void f2() &; // expected-error{{static member function cannot have '&' qualifier}}
+ static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}}
};
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 '&&'}}
+typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
+
+template<typename T = func_type_lvalue> struct wrap {
+ typedef T val;
+ typedef T *ptr;
+ typedef T &ref;
+};
+
+using func_type_lvalue = wrap<>::val;
+using func_type_lvalue = wrap<func_type_lvalue>::val;
+using func_type_rvalue = wrap<func_type_rvalue>::val;
+
+using func_type_lvalue_ptr = wrap<>::ptr;
+using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr;
+using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr;
+
+using func_type_lvalue_ref = wrap<>::ref;
+using func_type_lvalue_ref = wrap<func_type_lvalue>::ref;
+using func_type_rvalue_ref = wrap<func_type_rvalue>::ref;
+
+func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}}
+func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}}
struct Y {
func_type_lvalue f0;
@@ -25,4 +50,4 @@ 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}}
+void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}}
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
index 4873c09..e2d94fb 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp
@@ -1,14 +1,20 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void f() const; // expected-error{{type qualifier is not allowed on this function}}
+typedef void F() const;
+
+void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+F g; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
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}}
+ friend void g() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+ static void h() const; // expected-error {{static member function cannot have 'const' qualifier}}
+ F i; // ok
+ friend F j; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
+ static F k; // expected-error {{static member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}}
};
struct Y {
friend void X::f() const;
- friend void ::f() const; // expected-error{{type qualifier is not allowed on this function}}
+ friend void ::f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
};
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
index 4d71a8e..574a3e7 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
@@ -1,3 +1,3 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-auto j() -> enum { e3 }; // expected-error{{can not be defined in a type specifier}}
+auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{requires a specifier or qualifier}} expected-error {{without trailing return type}}
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
index aaf7451..c02105c 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp
@@ -12,7 +12,7 @@ typedef intref &intrefref;
template <class T> class RefMem { // expected-warning{{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}}
T
&
- member; // expected-note{{ reference member 'member' will never be initialized}}
+ member; // expected-note{{reference member 'member' will never be initialized}}
};
struct RefRef {
diff --git a/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
new file mode 100644
index 0000000..99334b8
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// The nested-name-specifier of a qualified declarator-id shall not begin with a decltype-specifier.
+class foo {
+ static int i;
+ void func();
+};
+
+int decltype(foo())::i; // expected-error{{'decltype' cannot be used to name a declaration}}
+void decltype(foo())::func() { // expected-error{{'decltype' cannot be used to name a declaration}}
+}
+
+
+template<typename T>
+class tfoo {
+ static int i;
+ void func();
+};
+
+template<typename T>
+int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+template<typename T>
+void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}}
+}
diff --git a/test/CXX/dcl.decl/dcl.meaning/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/p1.cpp
new file mode 100644
index 0000000..3672ea0
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.meaning/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR8019 {
+ struct x;
+ template<typename T> struct x2;
+ struct y {
+ struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}}
+
+ struct inner;
+ struct y::inner { }; // expected-warning{{extra qualification on member 'inner'}}
+
+ template<typename T>
+ struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}}
+
+ template<typename T>
+ struct inner_template;
+
+ template<typename T>
+ struct y::inner_template { }; // expected-warning{{extra qualification on member 'inner_template'}}
+ };
+
+}
+
+namespace NS {
+ void foo();
+ extern int bar;
+ struct X;
+ template<typename T> struct Y;
+ template<typename T> void wibble(T);
+}
+namespace NS {
+ void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}}
+ int NS::bar; // expected-warning{{extra qualification on member 'bar'}}
+ struct NS::X { }; // expected-warning{{extra qualification on member 'X'}}
+ template<typename T> struct NS::Y; // expected-warning{{extra qualification on member 'Y'}}
+ template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}}
+}
diff --git a/test/CXX/dcl.decl/dcl.name/p1.cpp b/test/CXX/dcl.decl/dcl.name/p1.cpp
index 7586007..9838b4f 100644
--- a/test/CXX/dcl.decl/dcl.name/p1.cpp
+++ b/test/CXX/dcl.decl/dcl.name/p1.cpp
@@ -2,15 +2,19 @@
namespace pr6200 {
struct v {};
+ enum E { e };
struct s {
int i;
operator struct v() { return v(); };
+ operator enum E() { return e; }
};
void f()
{
- // Neither of these is a declaration.
+ // None of these is a declaration.
(void)new struct s;
+ (void)new enum E;
(void)&s::operator struct v;
+ (void)&s::operator enum E;
}
}
diff --git a/test/CXX/except/except.spec/p1.cpp b/test/CXX/except/except.spec/p1.cpp
index a6e7850..c68ec56 100644
--- a/test/CXX/except/except.spec/p1.cpp
+++ b/test/CXX/except/except.spec/p1.cpp
@@ -74,7 +74,7 @@ namespace noexcept_unevaluated {
namespace PR11084 {
template<int X> struct A {
- static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}}
+ static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}}
};
void g() { A<0>::f(); } // expected-note{{in instantiation of template class 'PR11084::A<0>' requested here}}
diff --git a/test/CXX/expr/expr.ass/p9-cxx11.cpp b/test/CXX/expr/expr.ass/p9-cxx11.cpp
new file mode 100644
index 0000000..206c82c
--- /dev/null
+++ b/test/CXX/expr/expr.ass/p9-cxx11.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+template<typename T> struct complex {
+ complex(T = T(), T = T());
+ void operator+=(complex);
+ T a, b;
+};
+
+void std_example() {
+ complex<double> z;
+ z = { 1, 2 };
+ z += { 1, 2 };
+
+ int a, b;
+ a = b = { 1 };
+ a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
+ a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}}
+ a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \
+ expected-error {{initializer list cannot be used on the right hand side of operator '*'}}
+}
+
+struct S {
+ constexpr S(int a, int b) : a(a), b(b) {}
+ int a, b;
+};
+struct T {
+ constexpr int operator=(S s) { return s.a; }
+ constexpr int operator+=(S s) { return s.b; }
+};
+static_assert((T() = {4, 9}) == 4, "");
+static_assert((T() += {4, 9}) == 9, "");
+
+int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}}
+int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}}
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index 2c6a46b..054669e 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -1,7 +1,575 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu
+
+// A conditional-expression is a core constant expression unless it involves one
+// of the following as a potentially evaluated subexpression [...]:
+
+// - this (5.1.1 [expr.prim.general]) [Note: when evaluating a constant
+// expression, function invocation substitution (7.1.5 [dcl.constexpr])
+// replaces each occurrence of this in a constexpr member function with a
+// pointer to the class object. -end note];
+struct This {
+ int this1 : this1; // expected-error {{undeclared}}
+ int this2 : this->this1; // expected-error {{invalid}}
+ void this3() {
+ int n1[this->this1]; // expected-warning {{variable length array}}
+ int n2[this1]; // expected-warning {{variable length array}}
+ (void)n1, (void)n2;
+ }
+};
+
+// - an invocation of a function other than a constexpr constructor for a
+// literal class or a constexpr function [ Note: Overload resolution (13.3)
+// is applied as usual - end note ];
+struct NonConstexpr1 {
+ static int f() { return 1; } // expected-note {{here}}
+ int n : f(); // expected-error {{constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
+};
+struct NonConstexpr2 {
+ constexpr NonConstexpr2(); // expected-note {{here}}
+ int n;
+};
+struct NonConstexpr3 {
+ NonConstexpr3();
+ int m : NonConstexpr2().n; // expected-error {{constant expression}} expected-note {{undefined constructor 'NonConstexpr2'}}
+};
+struct NonConstexpr4 {
+ NonConstexpr4(); // expected-note {{declared here}}
+ int n;
+};
+struct NonConstexpr5 {
+ int n : NonConstexpr4().n; // expected-error {{constant expression}} expected-note {{non-constexpr constructor 'NonConstexpr4' cannot be used in a constant expression}}
+};
+
+// - an invocation of an undefined constexpr function or an undefined
+// constexpr constructor;
+struct UndefinedConstexpr {
+ constexpr UndefinedConstexpr();
+ static constexpr int undefinedConstexpr1(); // expected-note {{here}}
+ int undefinedConstexpr2 : undefinedConstexpr1(); // expected-error {{constant expression}} expected-note {{undefined function 'undefinedConstexpr1' cannot be used in a constant expression}}
+};
+
+// - an invocation of a constexpr function with arguments that, when substituted
+// by function invocation substitution (7.1.5), do not produce a core constant
+// expression;
+namespace NonConstExprReturn {
+ static constexpr const int &id_ref(const int &n) {
+ return n;
+ }
+ struct NonConstExprFunction {
+ int n : id_ref(16); // ok
+ };
+ constexpr const int *address_of(const int &a) {
+ return &a;
+ }
+ constexpr const int *return_param(int n) { // expected-note {{declared here}}
+ return address_of(n);
+ }
+ struct S {
+ int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}}
+ };
+}
+
+// - an invocation of a constexpr constructor with arguments that, when
+// substituted by function invocation substitution (7.1.5), do not produce all
+// constant expressions for the constructor calls and full-expressions in the
+// mem-initializers (including conversions);
+namespace NonConstExprCtor {
+ struct T {
+ constexpr T(const int &r) :
+ r(r) {
+ }
+ const int &r;
+ };
+ constexpr int n = 0;
+ constexpr T t1(n); // ok
+ constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-note {{temporary created here}} expected-note {{reference to temporary is not a constant expression}}
+
+ struct S {
+ int n : T(4).r; // ok
+ };
+}
+
+// - an invocation of a constexpr function or a constexpr constructor that would
+// exceed the implementation-defined recursion limits (see Annex B);
+namespace RecursionLimits {
+ constexpr int RecurseForever(int n) {
+ return n + RecurseForever(n+1); // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'RecurseForever(}} expected-note {{skipping 118 calls}}
+ }
+ struct AlsoRecurseForever {
+ constexpr AlsoRecurseForever(int n) :
+ n(AlsoRecurseForever(n+1).n) // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'AlsoRecurseForever(}} expected-note {{skipping 118 calls}}
+ {}
+ int n;
+ };
+ struct S {
+ int k : RecurseForever(0); // expected-error {{constant expression}} expected-note {{in call to}}
+ int l : AlsoRecurseForever(0).n; // expected-error {{constant expression}} expected-note {{in call to}}
+ };
+}
+
+// DR1458: taking the address of an object of incomplete class type
+namespace IncompleteClassTypeAddr {
+ struct S;
+ extern S s;
+ constexpr S *p = &s; // ok
+ static_assert(p, "");
+
+ extern S sArr[];
+ constexpr S (*p2)[] = &sArr; // ok
+
+ struct S {
+ constexpr S *operator&() { return nullptr; }
+ };
+ constexpr S *q = &s; // ok
+ static_assert(!q, "");
+}
+
+// - an operation that would have undefined behavior [Note: including, for
+// example, signed integer overflow (Clause 5 [expr]), certain pointer
+// arithmetic (5.7 [expr.add]), division by zero (5.6 [expr.mul]), or certain
+// shift operations (5.8 [expr.shift]) -end note];
+namespace UndefinedBehavior {
+ void f(int n) {
+ switch (n) {
+ case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}}
+ case (int)0x80000000u: // ok
+ case (int)10000000000ll: // expected-note {{here}}
+ case (unsigned int)10000000000ll: // expected-error {{duplicate case value}}
+ case (int)(unsigned)(long long)4.4e9: // ok
+ case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}}
+ case (int)((float)1e37 / 1e30): // ok
+ case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}}
+ break;
+ }
+ }
+
+ constexpr int int_min = ~0x7fffffff;
+ constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} expected-warning {{undefined}}
+ constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+ constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}}
+
+ constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shl_0 = 0 << 0; // ok
+ constexpr int shl_31 = 0 << 31; // ok
+ constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type 'int' (32}} expected-warning {{>= width of type}}
+ constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok
+ constexpr int shl_unsigned_into_sign = 1u << 31; // ok
+ constexpr int shl_unsigned_overflow = 1024u << 31; // ok
+ constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}}
+ constexpr int shl_signed_ok = 1 << 30; // ok
+ constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457)
+ constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457)
+ constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}}
+ constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}}
+ constexpr int shl_signed_ok2 = 1024 << 20; // ok
+
+ constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} expected-warning {{negative}}
+ constexpr int shr_0 = 0 >> 0; // ok
+ constexpr int shr_31 = 0 >> 31; // ok
+ constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type}} expected-warning {{>= width of type}}
+
+ struct S {
+ int m;
+ };
+ constexpr S s = { 5 };
+ constexpr const int *p = &s.m + 1;
+ constexpr const int &f(const int *q) {
+ return q[0];
+ }
+ constexpr int n = (f(p), 0); // ok
+ struct T {
+ int n : f(p); // expected-error {{not an integral constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+ };
+
+ namespace Ptr {
+ struct A {};
+ struct B : A { int n; };
+ B a[3][3];
+ constexpr B *p = a[0] + 4; // expected-error {{constant expression}} expected-note {{element 4 of array of 3 elements}}
+ B b = {};
+ constexpr A *pa = &b + 1; // expected-error {{constant expression}} expected-note {{base class of pointer past the end}}
+ constexpr B *pb = (B*)((A*)&b + 1); // expected-error {{constant expression}} expected-note {{derived class of pointer past the end}}
+ constexpr const int *pn = &(&b + 1)->n; // expected-error {{constant expression}} expected-note {{field of pointer past the end}}
+ constexpr B *parr = &a[3][0]; // expected-error {{constant expression}} expected-note {{array element of pointer past the end}}
+
+ constexpr A *na = nullptr;
+ constexpr B *nb = nullptr;
+ constexpr A &ra = *nb; // expected-error {{constant expression}} expected-note {{cannot access base class of null pointer}}
+ constexpr B &rb = (B&)*na; // expected-error {{constant expression}} expected-note {{cannot access derived class of null pointer}}
+ static_assert((A*)nb == 0, "");
+ static_assert((B*)na == 0, "");
+ constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot access field of null pointer}}
+ constexpr const int &np = (*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot access array element of null pointer}}
+
+ struct C {
+ constexpr int f() { return 0; }
+ } constexpr c = C();
+ constexpr int k1 = c.f(); // ok
+ constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}}
+ constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot call member function on pointer past the end of object}}
+ C c2;
+ constexpr int k4 = c2.f(); // ok!
+
+ constexpr int diff1 = &a[2] - &a[0];
+ constexpr int diff2 = &a[1][3] - &a[1][0];
+ constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ static_assert(&a[2][0] == &a[1][3], "");
+ constexpr int diff4 = (&b + 1) - &b;
+ constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ constexpr int diff6 = &a[1][2].n - &a[1][2].n;
+ constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}}
+ }
+
+ namespace Overflow {
+ // Signed int overflow.
+ constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok
+ constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n3 = n1 + 1; // ok
+ constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n5 = -65536 * 32768; // ok
+ constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n7 = -n3 + -1; // ok
+ constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n9 = n3 - 0; // ok
+ constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }}
+ constexpr int n11 = -1 - n3; // ok
+ constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }}
+ constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }}
+ constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 4294967295 is outside the range of }}
+ constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 4611686018427387904 is outside the range of }}
+ constexpr signed char c1 = 100 * 2; // ok
+ constexpr signed char c2 = '\x64' * '\2'; // also ok
+ constexpr long long ll1 = 0x7fffffffffffffff; // ok
+ constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 9223372036854775808 }}
+ constexpr long long ll3 = -ll1 - 1; // ok
+ constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -9223372036854775809 }}
+ constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 85070591730234615865843651857942052864 }}
+
+ // Yikes.
+ char melchizedek[2200000000];
+ typedef decltype(melchizedek[1] - melchizedek[0]) ptrdiff_t;
+ constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok
+ constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant expression}} expected-note {{ 2147483648 }}
+ constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok
+ constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant expression}} expected-note {{ -2147483649 }}
+
+ // Unsigned int overflow.
+ static_assert(65536u * 65536u == 0u, ""); // ok
+ static_assert(4294967295u + 1u == 0u, ""); // ok
+ static_assert(0u - 1u == 4294967295u, ""); // ok
+ static_assert(~0u * ~0u == 1u, ""); // ok
+
+ // Floating-point overflow and NaN.
+ constexpr float f1 = 1e38f * 3.4028f; // ok
+ constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f3 = 1e38f / -.2939f; // ok
+ constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}}
+ constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces a NaN}}
+ }
+}
+
+// - a lambda-expression (5.1.2);
+struct Lambda {
+ // FIXME: clang crashes when trying to parse this! Revisit this check once
+ // lambdas are fully implemented.
+ //int n : []{ return 1; }();
+};
+
+// - an lvalue-to-rvalue conversion (4.1) unless it is applied to
+namespace LValueToRValue {
+ // - a non-volatile glvalue of integral or enumeration type that refers to a
+ // non-volatile const object with a preceding initialization, initialized
+ // with a constant expression [Note: a string literal (2.14.5 [lex.string])
+ // corresponds to an array of such objects. -end note], or
+ volatile const int vi = 1; // expected-note 2{{here}}
+ const int ci = 1;
+ volatile const int &vrci = ci;
+ static_assert(vi, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(vi), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}}
+ static_assert(vrci, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+
+ // - a non-volatile glvalue of literal type that refers to a non-volatile
+ // object defined with constexpr, or that refers to a sub-object of such an
+ // object, or
+ struct V {
+ constexpr V() : v(1) {}
+ volatile int v; // expected-note {{not literal because}}
+ };
+ constexpr V v; // expected-error {{non-literal type}}
+ struct S {
+ constexpr S(int=0) : i(1), v(const_cast<volatile int&>(vi)) {}
+ constexpr S(const S &s) : i(2), v(const_cast<volatile int&>(vi)) {}
+ int i;
+ volatile int &v;
+ };
+ constexpr S s; // ok
+ constexpr volatile S vs; // expected-note {{here}}
+ constexpr const volatile S &vrs = s; // ok
+ static_assert(s.i, "");
+ static_assert(s.v, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(s.v), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}}
+ static_assert(vs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+ static_assert(const_cast<int&>(vs.i), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vs'}}
+ static_assert(vrs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}}
+
+ // - a non-volatile glvalue of literal type that refers to a non-volatile
+ // temporary object whose lifetime has not ended, initialized with a
+ // constant expression;
+ constexpr volatile S f() { return S(); }
+ static_assert(f().i, ""); // ok! there's no lvalue-to-rvalue conversion here!
+ static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}}
+}
+
+// DR1312: The proposed wording for this defect has issues, so we ignore this
+// bullet and instead prohibit casts from pointers to cv void (see core-20842
+// and core-20845).
+//
+// - an lvalue-to-rvalue conversion (4.1 [conv.lval]) that is applied to a
+// glvalue of type cv1 T that refers to an object of type cv2 U, where T and U
+// are neither the same type nor similar types (4.4 [conv.qual]);
+
+// - an lvalue-to-rvalue conversion (4.1) that is applied to a glvalue that
+// refers to a non-active member of a union or a subobject thereof;
+namespace LValueToRValueUnion {
+ // test/SemaCXX/constant-expression-cxx11.cpp contains more thorough testing
+ // of this.
+ union U { int a, b; } constexpr u = U();
+ static_assert(u.a == 0, "");
+ constexpr const int *bp = &u.b;
+ constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
+
+ extern const U pu;
+ constexpr const int *pua = &pu.a;
+ constexpr const int *pub = &pu.b;
+ constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}}
+ constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
+ constexpr const int b2 = *pub; // ok
+}
+
+// - an id-expression that refers to a variable or data member of reference type
+// unless the reference has a preceding initialization, initialized with a
+// constant expression;
+namespace References {
+ const int a = 2;
+ int &b = *const_cast<int*>(&a);
+ int c = 10; // expected-note 2 {{here}}
+ int &d = c;
+ constexpr int e = 42;
+ int &f = const_cast<int&>(e);
+ extern int &g;
+ constexpr int &h(); // expected-note {{here}}
+ int &i = h(); // expected-note {{here}}
+ constexpr int &j() { return b; }
+ int &k = j();
+
+ struct S {
+ int A : a;
+ int B : b;
+ int C : c; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}}
+ int D : d; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}}
+ int D2 : &d - &c + 1;
+ int E : e / 2;
+ int F : f - 11;
+ int G : g; // expected-error {{constant expression}}
+ int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}}
+ int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
+ int J : j();
+ int K : k;
+ };
+}
+
+// - a dynamic_cast (5.2.7);
+namespace DynamicCast {
+ struct S { int n; };
+ constexpr S s { 16 };
+ struct T {
+ int n : dynamic_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{dynamic_cast}}
+ };
+}
+
+// - a reinterpret_cast (5.2.10);
+namespace ReinterpretCast {
+ struct S { int n; };
+ constexpr S s { 16 };
+ struct T {
+ int n : reinterpret_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}}
+ };
+ struct U {
+ int m : (long)(S*)6; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}}
+ };
+}
+
+// - a pseudo-destructor call (5.2.4);
+namespace PseudoDtor {
+ int k;
+ typedef int I;
+ struct T {
+ int n : (k.~I(), 0); // expected-error {{constant expression}}
+ };
+}
+
+// - increment or decrement operations (5.2.6, 5.3.2);
+namespace IncDec {
+ int k = 2;
+ struct T {
+ int n : ++k; // expected-error {{constant expression}}
+ int m : --k; // expected-error {{constant expression}}
+ };
+}
+
+// - a typeid expression (5.2.8) whose operand is of a polymorphic class type;
+namespace std {
+ struct type_info {
+ virtual ~type_info();
+ const char *name;
+ };
+}
+namespace TypeId {
+ struct S { virtual void f(); };
+ constexpr S *p = 0;
+ constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} expected-note {{typeid applied to expression of polymorphic type 'TypeId::S'}}
+
+ struct T {} t;
+ constexpr const std::type_info &ti2 = typeid(t);
+}
+
+// - a new-expression (5.3.4);
+// - a delete-expression (5.3.5);
+namespace NewDelete {
+ int *p = 0;
+ struct T {
+ int n : *new int(4); // expected-error {{constant expression}}
+ int m : (delete p, 2); // expected-error {{constant expression}}
+ };
+}
+
+// - a relational (5.9) or equality (5.10) operator where the result is
+// unspecified;
+namespace UnspecifiedRelations {
+ int a, b;
+ constexpr int *p = &a, *q = &b;
+ // C++11 [expr.rel]p2: If two pointers p and q of the same type point to
+ // different objects that are not members of the same array or to different
+ // functions, or if only one of them is null, the results of p<q, p>q, p<=q,
+ // and p>=q are unspecified.
+ constexpr bool u1 = p < q; // expected-error {{constant expression}}
+ constexpr bool u2 = p > q; // expected-error {{constant expression}}
+ constexpr bool u3 = p <= q; // expected-error {{constant expression}}
+ constexpr bool u4 = p >= q; // expected-error {{constant expression}}
+ constexpr bool u5 = p < 0; // expected-error {{constant expression}}
+ constexpr bool u6 = p <= 0; // expected-error {{constant expression}}
+ constexpr bool u7 = p > 0; // expected-error {{constant expression}}
+ constexpr bool u8 = p >= 0; // expected-error {{constant expression}}
+ constexpr bool u9 = 0 < q; // expected-error {{constant expression}}
+ constexpr bool u10 = 0 <= q; // expected-error {{constant expression}}
+ constexpr bool u11 = 0 > q; // expected-error {{constant expression}}
+ constexpr bool u12 = 0 >= q; // expected-error {{constant expression}}
+ void f(), g();
+
+ constexpr void (*pf)() = &f, (*pg)() = &g;
+ constexpr bool u13 = pf < pg; // expected-error {{constant expression}}
+ constexpr bool u14 = pf == pg;
+
+ // If two pointers point to non-static data members of the same object with
+ // different access control, the result is unspecified.
+ struct A {
+ public:
+ constexpr A() : a(0), b(0) {}
+ int a;
+ constexpr bool cmp() { return &a < &b; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}}
+ private:
+ int b;
+ };
+ class B {
+ public:
+ A a;
+ constexpr bool cmp() { return &a.a < &b.a; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}}
+ protected:
+ A b;
+ };
+
+ // If two pointers point to different base sub-objects of the same object, or
+ // one points to a base subobject and the other points to a member, the result
+ // of the comparison is unspecified. This is not explicitly called out by
+ // [expr.rel]p2, but is covered by 'Other pointer comparisons are
+ // unspecified'.
+ struct C {
+ int c[2];
+ };
+ struct D {
+ int d;
+ };
+ struct E : C, D {
+ struct Inner {
+ int f;
+ } e;
+ } e;
+ constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{comparison of addresses of subobjects of different base classes has unspecified value}}
+ constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'C' of class 'E' to field 'e' has unspecified value}}
+ constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'D' of class 'E' to field 'e' has unspecified value}}
+
+ // [expr.rel]p3: Pointers to void can be compared [...] if both pointers
+ // represent the same address or are both the null pointer [...]; otherwise
+ // the result is unspecified.
+ struct S { int a, b; } s;
+ constexpr void *null = 0;
+ constexpr void *pv = (void*)&s.a;
+ constexpr void *qv = (void*)&s.b;
+ constexpr bool v1 = null < 0;
+ constexpr bool v2 = null < pv; // expected-error {{constant expression}}
+ constexpr bool v3 = null == pv; // ok
+ constexpr bool v4 = qv == pv; // ok
+ constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
+ constexpr bool v6 = qv > null; // expected-error {{constant expression}}
+ constexpr bool v7 = qv <= (void*)&s.b; // ok
+ constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}}
+}
+
+// - an assignment or a compound assignment (5.17); or
+namespace Assignment {
+ int k;
+ struct T {
+ int n : (k = 9); // expected-error {{constant expression}}
+ int m : (k *= 2); // expected-error {{constant expression}}
+ };
+
+ struct Literal {
+ constexpr Literal(const char *name) : name(name) {}
+ const char *name;
+ };
+ struct Expr {
+ constexpr Expr(Literal l) : IsLiteral(true), l(l) {}
+ bool IsLiteral;
+ union {
+ Literal l;
+ // ...
+ };
+ };
+ struct MulEq {
+ constexpr MulEq(Expr a, Expr b) : LHS(a), RHS(b) {}
+ Expr LHS;
+ Expr RHS;
+ };
+ constexpr MulEq operator*=(Expr a, Expr b) { return MulEq(a, b); }
+ Literal a("a");
+ Literal b("b");
+ MulEq c = a *= b; // ok
+}
+
+// - a throw-expression (15.1)
+namespace Throw {
+ struct S {
+ int n : (throw "hello", 10); // expected-error {{constant expression}}
+ };
+}
// PR9999
-template<bool v>
+template<unsigned int v>
class bitWidthHolding {
public:
static const
@@ -23,3 +591,6 @@ struct and_or {
static const bool and_value = and_or<true>::and_value;
static const bool or_value = and_or<true>::or_value;
+
+static_assert(and_value == false, "");
+static_assert(or_value == true, "");
diff --git a/test/CXX/expr/expr.const/p3-0x-nowarn.cpp b/test/CXX/expr/expr.const/p3-0x-nowarn.cpp
new file mode 100644
index 0000000..c891374
--- /dev/null
+++ b/test/CXX/expr/expr.const/p3-0x-nowarn.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-c++11-narrowing -verify %s
+
+// <rdar://problem/11121178>
+void f(int x) {
+ switch (x) {
+ case 0x80000001: break;
+ }
+}
diff --git a/test/CXX/expr/expr.const/p3-0x.cpp b/test/CXX/expr/expr.const/p3-0x.cpp
new file mode 100644
index 0000000..6ddd11b
--- /dev/null
+++ b/test/CXX/expr/expr.const/p3-0x.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// A converted constant expression of type T is a core constant expression,
+int nonconst = 8; // expected-note 3 {{here}}
+enum NonConstE : unsigned char { NCE = nonconst }; // expected-error {{enumerator value is not a constant expression}} expected-note {{read of non-const}}
+template<int = nonconst> struct NonConstT {}; // expected-error {{non-type template argument is not a constant expression}} expected-note {{read of non-const}}
+void NonConstF() {
+ switch (nonconst) {
+ case nonconst: // expected-error {{case value is not a constant expression}} expected-note {{read of non-const}}
+ break;
+ }
+ return;
+}
+
+// implicitly converted to a prvalue of type T, where the converted expression
+// is a literal constant expression
+
+bool a(int n) {
+ constexpr char vowels[] = "aeiou";
+ switch (n) {
+ case vowels[0]:
+ case vowels[1]:
+ case vowels[2]:
+ case vowels[3]:
+ case vowels[4]:
+ static_assert(!vowels[5], "unexpected number of vowels");
+ return true;
+ }
+ return false;
+}
+
+// and the implicit conversion sequence contains only
+//
+// user-defined conversions,
+struct S { constexpr operator int() const { return 5; } };
+enum E : unsigned char { E5 = S(), E6, E10 = S() * 2, E1 = E5 / 5 };
+
+// lvalue-to-rvalue conversions,
+const E e10 = E10;
+template<E> struct T {};
+T<e10> s10;
+
+// integral promotions, and
+enum class EE { EE32 = ' ', EE65 = 'A', EE1 = (short)1, EE5 = E5 };
+
+// integral conversions other than narrowing conversions
+int b(unsigned n) {
+ switch (n) {
+ case E6:
+ case EE::EE32: // expected-error {{not implicitly convertible}}
+ case (int)EE::EE32:
+ case 1000:
+ case (long long)1e10: // expected-error {{case value evaluates to 10000000000, which cannot be narrowed to type 'unsigned int'}}
+ case -3: // expected-error {{case value evaluates to -3, which cannot be narrowed to type 'unsigned int'}}
+ return n;
+ }
+ return 0;
+}
+enum class EEE : unsigned short {
+ a = E6,
+ b = EE::EE32, // expected-error {{not implicitly convertible}}
+ c = (int)EE::EE32,
+ d = 1000,
+ e = 123456, // expected-error {{enumerator value evaluates to 123456, which cannot be narrowed to type 'unsigned short'}}
+ f = -3 // expected-error {{enumerator value evaluates to -3, which cannot be narrowed to type 'unsigned short'}}
+};
+template<unsigned char> using A = int;
+using Int = A<E6>;
+using Int = A<EE::EE32>; // expected-error {{not implicitly convertible}}
+using Int = A<(int)EE::EE32>;
+using Int = A<200>;
+using Int = A<1000>; // expected-error {{template argument evaluates to 1000, which cannot be narrowed to type 'unsigned char'}}
+using Int = A<-3>; // expected-error {{template argument evaluates to -3, which cannot be narrowed to type 'unsigned char'}}
+
+// Note, conversions from integral or unscoped enumeration types to bool are
+// integral conversions as well as boolean conversions.
+template<typename T, T v> struct Val { static constexpr T value = v; };
+static_assert(Val<bool, E1>::value == 1, ""); // ok
+static_assert(Val<bool, '\0'>::value == 0, ""); // ok
+static_assert(Val<bool, U'\1'>::value == 1, ""); // ok
+static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}}
+
+// (no other conversions are permitted)
+using Int = A<1.0>; // expected-error {{conversion from 'double' to 'unsigned char' is not allowed in a converted constant expression}}
+enum B : bool {
+ True = &a, // expected-error {{conversion from 'bool (*)(int)' to 'bool' is not allowed in a converted constant expression}}
+ False = nullptr // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}}
+};
+void c() {
+ // Note, promoted type of switch is 'int'.
+ switch (bool b = a(5)) { // expected-warning {{boolean value}}
+ case 0.0f: // expected-error {{conversion from 'float' to 'int' is not allowed in a converted constant expression}}
+ break;
+ }
+}
+template<bool B> int f() { return B; }
+template int f<&S::operator int>(); // expected-error {{does not refer to a function template}}
+template int f<(bool)&S::operator int>();
+
+int n = Val<bool, &S::operator int>::value; // expected-error {{conversion from 'int (S::*)() const' to 'bool' is not allowed in a converted constant expression}}
+
+namespace NonConstLValue {
+ struct S {
+ constexpr operator int() { return 10; }
+ };
+ S s; // not constexpr
+ // Under the FDIS, this is not a converted constant expression.
+ // Under the new proposed wording, it is.
+ enum E : char { e = s };
+}
diff --git a/test/CXX/expr/expr.const/p5-0x.cpp b/test/CXX/expr/expr.const/p5-0x.cpp
new file mode 100644
index 0000000..60fabe3
--- /dev/null
+++ b/test/CXX/expr/expr.const/p5-0x.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+// If an expression of literal class type is used in a context where an integral
+// constant expression is required, then that class type shall have a single
+// non-explicit conversion function to an integral or unscoped enumeration type
+namespace std_example {
+
+struct A {
+ constexpr A(int i) : val(i) { }
+ constexpr operator int() { return val; }
+ constexpr operator long() { return 43; }
+private:
+ int val;
+};
+template<int> struct X { };
+constexpr A a = 42;
+X<a> x; // ok, unique conversion to int
+int ary[a]; // expected-error {{size of array has non-integer type 'const std_example::A'}}
+
+}
+
+struct OK {
+ constexpr OK() {}
+ constexpr operator int() { return 8; }
+} constexpr ok;
+extern struct Incomplete incomplete; // expected-note 4{{forward decl}}
+struct Explicit {
+ constexpr Explicit() {}
+ constexpr explicit operator int() { return 4; } // expected-note 4{{here}}
+} constexpr expl;
+struct Ambiguous {
+ constexpr Ambiguous() {}
+ constexpr operator int() { return 2; } // expected-note 4{{here}}
+ constexpr operator long() { return 1; } // expected-note 4{{here}}
+} constexpr ambig;
+
+constexpr int test_ok = ok; // ok
+constexpr int test_explicit(expl); // ok
+constexpr int test_ambiguous = ambig; // ok
+
+static_assert(test_ok == 8, "");
+static_assert(test_explicit == 4, "");
+static_assert(test_ambiguous == 2, "");
+
+// [expr.new]p6: Every constant-expression in a noptr-new-declarator shall be
+// an integral constant expression
+auto new1 = new int[1][ok];
+auto new2 = new int[1][incomplete]; // expected-error {{incomplete}}
+auto new3 = new int[1][expl]; // expected-error {{explicit conversion}}
+auto new4 = new int[1][ambig]; // expected-error {{ambiguous conversion}}
+
+// [dcl.enum]p5: If the underlying type is not fixed [...] the initializing
+// value [...] shall be an integral constant expression.
+enum NotFixed {
+ enum1 = ok,
+ enum2 = incomplete, // expected-error {{incomplete}}
+ enum3 = expl, // expected-error {{explicit conversion}}
+ enum4 = ambig // expected-error {{ambiguous conversion}}
+};
+
+// [dcl.align]p2: When the alignment-specifier is of the form
+// alignas(assignment-expression), the assignment-expression shall be an
+// integral constant expression
+int alignas(ok) alignas1;
+int alignas(incomplete) alignas2; // expected-error {{incomplete}}
+int alignas(expl) alignas3; // expected-error {{explicit conversion}}
+int alignas(ambig) alignas4; // expected-error {{ambiguous conversion}}
+
+// [dcl.array]p1: If the constant-expression is present, it shall be an integral
+// constant expression
+// FIXME: The VLA recovery results in us giving diagnostics which aren't great
+// here.
+int array1[ok];
+int array2[incomplete]; // expected-error {{non-integer type}}
+int array3[expl]; // expected-error {{non-integer type}}
+int array4[ambig]; // expected-error {{non-integer type}}
+
+// [class.bit]p1: The constasnt-expression shall be an integral constant
+// expression
+struct Bitfields {
+ int bitfield1 : ok;
+ int bitfield2 : incomplete; // expected-error {{incomplete}}
+ int bitfield3 : expl; // expected-error {{explicit conversion}}
+ int bitfield4 : ambig; // expected-error {{ambiguous conversion}}
+};
diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
new file mode 100644
index 0000000..253744e
--- /dev/null
+++ b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct foo {
+ foo();
+ foo(int);
+};
+
+int func(foo& f) {
+ decltype(foo())();
+ f = (decltype(foo()))5;
+ return decltype(3)(5);
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
new file mode 100644
index 0000000..249c976
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S {
+ int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}}
+ int *m = &n; // ok
+
+ int n = f(); // ok
+ int f();
+};
+
+int i = sizeof(S::m); // ok
+int j = sizeof(S::m + 42); // ok
+
+
+struct T {
+ int n;
+ static void f() {
+ int a[n]; // expected-error {{invalid use of member 'n' in static member function}}
+ int b[sizeof n]; // ok
+ }
+};
+
+// Make sure the rule for unevaluated operands works correctly with typeid.
+namespace std {
+ class type_info;
+}
+class Poly { virtual ~Poly(); };
+const std::type_info& k = typeid(S::m);
+const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}}
+const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m));
+
+namespace PR11956 {
+ struct X { char a; };
+ struct Y { int f() { return sizeof(X::a); } }; // ok
+
+ struct A { enum E {} E; };
+ struct B { int f() { return sizeof(A::E); } }; // ok
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
new file mode 100644
index 0000000..4e57b74
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S {
+ S *p = this; // ok
+ decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+
+ int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ int sz = sizeof(this); // ok
+};
+
+namespace CaptureThis {
+ struct X {
+ int n = 10;
+ int m = [&]{return n + 1; }();
+ int o = [&]{return this->m + 1; }();
+ int p = [&]{return [&](int x) { return this->m + x;}(o); }();
+ };
+
+ X x;
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp
new file mode 100644
index 0000000..5b3a004
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct global {
+};
+
+namespace PR10127 {
+ struct outer {
+ struct middle {
+ struct inner {
+ int func();
+ int i;
+ };
+ struct inner2 {
+ };
+ struct inner3 {
+ };
+ int mfunc();
+ };
+ typedef int td_int;
+ };
+
+ struct str {
+ operator decltype(outer::middle::inner()) ();
+ operator decltype(outer::middle())::inner2 ();
+ operator decltype(outer())::middle::inner3 ();
+ str(int (decltype(outer::middle::inner())::*n)(),
+ int (decltype(outer::middle())::inner::*o)(),
+ int (decltype(outer())::middle::inner::*p)());
+ };
+
+ decltype(outer::middle::inner()) a;
+ void scope() {
+ a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}}
+ a.decltype(outer::middle::inner())::func();
+ a.decltype(outer::middle())::inner::func();
+ a.decltype(outer())::middle::inner::func();
+
+ a.decltype(outer())::middle::inner::~inner();
+
+ decltype(outer())::middle::inner().func();
+ }
+ decltype(outer::middle())::inner b;
+ decltype(outer())::middle::inner c;
+ decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}}
+ decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}}
+ decltype()::fail f; // expected-error{{expected expression}}
+ decltype()::middle::fail g; // expected-error{{expected expression}}
+
+ decltype(int()) h;
+ decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
+ decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
+
+ outer::middle k = decltype(outer())::middle();
+ outer::middle::inner l = decltype(outer())::middle::inner();
+
+ template<typename T>
+ struct templ {
+ typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}}
+ };
+
+ template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}}
+ template class templ<outer>;
+
+ enum class foo {
+ bar,
+ baz
+ };
+
+ foo m = decltype(foo::bar)::baz;
+
+ enum E {
+ };
+ struct bar {
+ enum E : decltype(outer())::td_int(4);
+ enum F : decltype(outer())::td_int;
+ enum G : decltype; // expected-error{{expected '(' after 'decltype'}}
+ };
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
new file mode 100644
index 0000000..0c3fdb2
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -std=c++11 -fblocks %s -verify
+
+void block_capture_errors() {
+ __block int var; // expected-note 2{{'var' declared here}}
+ (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
+
+ (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}}
+}
+
+void conversion_to_block(int captured) {
+ int (^b1)(int) = [=](int x) { return x + captured; };
+
+ const auto lambda = [=](int x) { return x + captured; };
+ int (^b2)(int) = lambda;
+}
+
+template<typename T>
+class ConstCopyConstructorBoom {
+public:
+ ConstCopyConstructorBoom(ConstCopyConstructorBoom&);
+
+ ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) {
+ T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
+ }
+
+ void foo() const;
+};
+
+void conversion_to_block_init(ConstCopyConstructorBoom<int> boom,
+ ConstCopyConstructorBoom<float> boom2) {
+ const auto& lambda1([=] { boom.foo(); }); // okay
+
+ const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}}
+ void (^block)(void) = lambda2;
+}
+
+
+void nesting() {
+ int array[7]; // expected-note 2{{'array' declared here}}
+ [=] () mutable {
+ [&] {
+ ^ {
+ int i = array[2];
+ i += array[3];
+ }();
+ }();
+ }();
+
+ [&] {
+ [=] () mutable {
+ ^ {
+ int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}}
+ i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}}
+ }();
+ }();
+ }();
+}
+
+namespace overloading {
+ void bool_conversion() {
+ if ([](){}) {
+ }
+
+ bool b = []{};
+ b = (bool)[]{};
+ }
+
+ void conversions() {
+ int (*fp)(int) = [](int x) { return x + 1; };
+ fp = [](int x) { return x + 1; };
+
+ typedef int (*func_ptr)(int);
+ fp = (func_ptr)[](int x) { return x + 1; };
+
+ int (^bp)(int) = [](int x) { return x + 1; };
+ bp = [](int x) { return x + 1; };
+
+ typedef int (^block_ptr)(int);
+ bp = (block_ptr)[](int x) { return x + 1; };
+ }
+
+ int &accept_lambda_conv(int (*fp)(int));
+ float &accept_lambda_conv(int (^bp)(int));
+
+ void call_with_lambda() {
+ int &ir = accept_lambda_conv([](int x) { return x + 1; });
+ }
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
new file mode 100644
index 0000000..5dac886
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -Wno-lambda-extensions -verify
+
+void defargs() {
+ auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; };
+ int i1 = l1(1);
+ int i2 = l1(1, 2);
+ int i3 = l1(1, 2, 3);
+}
+
+
+void defargs_errors() {
+ auto l1 = [](int i,
+ int j = 17,
+ int k) { }; // expected-error{{missing default argument on parameter 'k'}}
+
+ auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}}
+
+ int foo;
+ auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}}
+}
+
+struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD&);
+ ~NonPOD();
+};
+
+struct NoDefaultCtor {
+ NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}}
+ ~NoDefaultCtor();
+};
+
+template<typename T>
+void defargs_in_template_unused(T t) {
+ auto l1 = [](const T& value = T()) { };
+ l1(t);
+}
+
+template void defargs_in_template_unused(NonPOD);
+template void defargs_in_template_unused(NoDefaultCtor);
+
+template<typename T>
+void defargs_in_template_used() {
+ auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}}
+ l1(); // expected-note{{in instantiation of default function argument expression for 'operator()<NoDefaultCtor>' required here}}
+}
+
+template void defargs_in_template_used<NonPOD>();
+template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}}
+
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
new file mode 100644
index 0000000..245e270
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+int GlobalVar; // expected-note {{declared here}}
+
+namespace N {
+ int AmbiguousVar; // expected-note {{candidate}}
+}
+int AmbiguousVar; // expected-note {{candidate}}
+using namespace N;
+
+class X0 {
+ int Member;
+
+ static void Overload(int);
+ void Overload();
+ virtual X0& Overload(float);
+
+ void explicit_capture() {
+ int variable; // expected-note {{declared here}}
+ (void)[&Overload] () {}; // expected-error {{does not name a variable}}
+ (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}}
+ (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}}
+ (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}}
+ }
+};
+
+void test_reaching_scope() {
+ int local; // expected-note{{declared here}}
+ static int local_static; // expected-note{{'local_static' declared here}}
+ (void)[=]() {
+ struct InnerLocal {
+ void member() {
+ (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}}
+ local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}}
+ return 0;
+ };
+ }
+ };
+ };
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp
new file mode 100644
index 0000000..d265dd7
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+void test_reaching_scope() {
+ int local; // expected-note{{declared here}}
+ static int local_static;
+ (void)[=]() {
+ struct InnerLocal {
+ void member() {
+ (void)[=]() {
+ return local + // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}}
+ local_static;
+ };
+ }
+ };
+ };
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
new file mode 100644
index 0000000..4a2a4f3
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+void odr_used() {
+ int i = 17;
+ [i]{}();
+}
+
+struct ReachingThis {
+ static void static_foo() {
+ (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
+
+ struct Local {
+ int i;
+
+ void bar() {
+ (void)[this](){};
+ (void)[&](){i = 7; };
+ }
+ };
+ }
+
+ void foo() {
+ (void)[this](){};
+
+ struct Local {
+ int i;
+
+ static void static_bar() {
+ (void)[this](){}; // expected-error{{'this' cannot be captured in this context}}
+ (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}}
+ }
+ };
+ }
+};
+
+void immediately_enclosing(int i) { // expected-note{{'i' declared here}}
+ [i]() {
+ [i] {}();
+ }();
+
+ [=]() {
+ [i] {}();
+ }();
+
+ []() { // expected-note{{lambda expression begins here}}
+ [i] {}(); // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
+ }();
+}
+
+void f1(int i) { // expected-note{{declared here}}
+ int const N = 20;
+ auto m1 = [=]{
+ int const M = 30;
+ auto m2 = [i]{
+ int x[N][M];
+ x[0][0] = i;
+ };
+ (void)N;
+ (void)M;
+ (void)m2;
+ };
+ struct s1 {
+ int f;
+ void work(int n) { // expected-note{{declared here}}
+ int m = n*n;
+ int j = 40; // expected-note{{declared here}}
+ auto m3 = [this,m] { // expected-note 3{{lambda expression begins here}}
+ auto m4 = [&,j] { // expected-error{{variable 'j' cannot be implicitly captured in a lambda with no capture-default specified}}
+ int x = n; // expected-error{{variable 'n' cannot be implicitly captured in a lambda with no capture-default specified}}
+ x += m;
+ x += i; // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
+ x += f;
+ };
+ };
+ }
+ };
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
new file mode 100644
index 0000000..8bb707e
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+void f2() {
+ int i = 1;
+ void g1(int = ([i]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g2(int = ([i]{ return 0; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g3(int = ([=]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}}
+ void g4(int = ([=]{ return 0; })());
+ void g5(int = ([]{ return sizeof i; })());
+}
+
+namespace lambda_in_default_args {
+ int f(int = [] () -> int { int n; return ++n; } ());
+ template<typename T> T g(T = [] () -> T { T n; return ++n; } ());
+ int k = f() + g<int>();
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
new file mode 100644
index 0000000..678fa4b
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+template<typename T> void capture(const T&);
+
+class NonCopyable {
+ NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}}
+public:
+ void foo() const;
+};
+
+class NonConstCopy {
+public:
+ NonConstCopy(NonConstCopy&); // expected-note{{would lose const}}
+};
+
+void capture_by_copy(NonCopyable nc, NonCopyable &ncr, const NonConstCopy nco) {
+ (void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}}
+ (void)[=] {
+ ncr.foo(); // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}}
+ }();
+
+ [nco] {}(); // expected-error{{no matching constructor for initialization of 'const NonConstCopy'}}
+}
+
+struct NonTrivial {
+ NonTrivial();
+ NonTrivial(const NonTrivial &);
+ ~NonTrivial();
+};
+
+struct CopyCtorDefault {
+ CopyCtorDefault();
+ CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial());
+
+ void foo() const;
+};
+
+void capture_with_default_args(CopyCtorDefault cct) {
+ (void)[=] () -> void { cct.foo(); };
+}
+
+struct ExpectedArrayLayout {
+ CopyCtorDefault array[3];
+};
+
+void capture_array() {
+ CopyCtorDefault array[3];
+ auto x = [=]() -> void {
+ capture(array[0]);
+ };
+ static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch");
+}
+
+// Check for the expected non-static data members.
+
+struct ExpectedLayout {
+ char a;
+ short b;
+};
+
+void test_layout(char a, short b) {
+ auto x = [=] () -> void {
+ capture(a);
+ capture(b);
+ };
+ static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!");
+}
+
+struct ExpectedThisLayout {
+ ExpectedThisLayout* a;
+ void f() {
+ auto x = [this]() -> void {};
+ static_assert(sizeof(x) == sizeof(ExpectedThisLayout), "Layout mismatch!");
+ }
+};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
new file mode 100644
index 0000000..c4deba9
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+class NonCopyable {
+ NonCopyable(const NonCopyable&);
+};
+
+void capture_by_ref(NonCopyable nc, NonCopyable &ncr) {
+ int array[3];
+ (void)[&nc] () -> void {};
+ (void)[&ncr] () -> void {};
+ (void)[&array] () -> void {};
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
new file mode 100644
index 0000000..0cf01ad
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+
+struct X {
+ X(const X&) = delete; // expected-note 2{{explicitly marked deleted}}
+ X(X&);
+};
+
+void test_capture(X x) {
+ [x] { }(); // okay: non-const copy ctor
+
+ [x] {
+ [x] { // expected-error{{call to deleted constructor of 'X'}}
+ }();
+ }();
+
+ [x] {
+ [&x] {
+ [x] { // expected-error{{call to deleted constructor of 'const X'}}
+ }();
+ }();
+ }();
+
+ int a;
+ [=]{
+ [&] {
+ int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ }();
+ }();
+
+ [=]{
+ [&a] {
+ [&] {
+ int &x = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ int &x2 = a; // expected-error{{binding of reference to type 'int' to a value of type 'const int' drops qualifiers}}
+ }();
+ }();
+ }();
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
new file mode 100644
index 0000000..930a4b3
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+void f3() {
+ float x, &r = x;
+ int i;
+ int &ir = i;
+ const int &irc = i;
+
+ [=,&irc,&ir] {
+ static_assert(is_same<decltype(((r))), float const&>::value,
+ "should be const float&");
+ static_assert(is_same<decltype(x), float>::value, "should be float");
+ static_assert(is_same<decltype((x)), const float&>::value,
+ "should be const float&");
+ static_assert(is_same<decltype(r), float&>::value, "should be float&");
+ static_assert(is_same<decltype(ir), int&>::value, "should be int&");
+ static_assert(is_same<decltype((ir)), int&>::value, "should be int&");
+ static_assert(is_same<decltype(irc), const int&>::value,
+ "should be const int&");
+ static_assert(is_same<decltype((irc)), const int&>::value,
+ "should be const int&");
+ }();
+
+ [=] {
+ [=] () mutable {
+ static_assert(is_same<decltype(x), float>::value, "should be float");
+ static_assert(is_same<decltype((x)), float&>::value,
+ "should be float&");
+ }();
+ }();
+
+ [&i] {
+ static_assert(is_same<decltype((i)), int&>::value, "should be int&");
+ }();
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
new file mode 100644
index 0000000..6fe3b25
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+struct MoveOnly {
+ MoveOnly(MoveOnly&&);
+ MoveOnly(const MoveOnly&);
+};
+
+template<typename T> T &&move(T&);
+void test_special_member_functions(MoveOnly mo, int i) {
+ auto lambda1 = [i]() { }; // expected-note 2 {{lambda expression begins here}}
+
+ // Default constructor
+ decltype(lambda1) lambda2; // expected-error{{call to implicitly-deleted default constructor of 'decltype(lambda1)' (aka '<lambda}}
+
+ // Copy assignment operator
+ lambda1 = lambda1; // expected-error{{overload resolution selected implicitly-deleted copy assignment operator}}
+
+ // Move assignment operator
+ lambda1 = move(lambda1);
+
+ // Copy constructor
+ decltype(lambda1) lambda3 = lambda1;
+ decltype(lambda1) lambda4(lambda1);
+
+ // Move constructor
+ decltype(lambda1) lambda5 = move(lambda1);
+ decltype(lambda1) lambda6(move(lambda1));
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp
new file mode 100644
index 0000000..c6ed308d
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+// prvalue
+void prvalue() {
+ auto&& x = []()->void { };
+ auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}}
+}
+
+namespace std {
+ class type_info;
+}
+
+struct P {
+ virtual ~P();
+};
+
+void unevaluated_operand(P &p, int i) {
+ int i2 = sizeof([]()->void{}()); // expected-error{{lambda expression in an unevaluated operand}}
+ const std::type_info &ti1 = typeid([&]() -> P& { return p; }());
+ const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}}
+}
+
+template<typename T>
+struct Boom {
+ Boom(const Boom&) {
+ T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'int'}}
+ }
+ void tickle() const;
+};
+
+void odr_used(P &p, Boom<int> boom_int, Boom<float> boom_float,
+ Boom<double> boom_double) {
+ const std::type_info &ti1
+ = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom<int>::Boom' requested here}}
+ const std::type_info &ti2
+ = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} \
+ // expected-note{{in instantiation of member function 'Boom<float>::Boom' requested here}}
+
+ auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom<double>::Boom' requested here}}
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp
new file mode 100644
index 0000000..4487cfc
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify
+
+template<typename T>
+void destroy(T* ptr) {
+ ptr->~T();
+ (*ptr).~T();
+}
+
+void destructor() {
+ auto lambda = []{};
+ destroy(&lambda);
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp
new file mode 100644
index 0000000..7139058
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+struct DirectInitOnly {
+ explicit DirectInitOnly(DirectInitOnly&);
+};
+
+void direct_init_capture(DirectInitOnly &dio) {
+ [dio] {}();
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
new file mode 100644
index 0000000..174db25
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void print();
+
+template<typename T, typename... Ts>
+void print(T first, Ts... rest) {
+ (void)first;
+ print(rest...);
+}
+
+template<typename... Ts>
+void unsupported(Ts ...values) {
+ auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}}
+}
+
+template<typename... Ts>
+void implicit_capture(Ts ...values) {
+ auto implicit = [&] { print(values...); };
+ implicit();
+}
+
+template<typename... Ts>
+void do_print(Ts... values) {
+ auto bycopy = [values...]() { print(values...); };
+ bycopy();
+ auto byref = [&values...]() { print(values...); };
+ byref();
+
+ auto bycopy2 = [=]() { print(values...); };
+ bycopy2();
+ auto byref2 = [&]() { print(values...); };
+ byref2();
+}
+
+template void do_print(int, float, double);
+
+template<typename T, int... Values>
+void bogus_expansions(T x) {
+ auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
+ auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}}
+}
+
+void g(int*, float*, double*);
+
+template<class... Args>
+void std_example(Args... args) {
+ auto lm = [&, args...] { return g(args...); };
+};
+
+template void std_example(int*, float*, double*);
+
+template<typename ...Args>
+void variadic_lambda(Args... args) {
+ auto lambda = [](Args... inner_args) { return g(inner_args...); };
+ lambda(args...);
+}
+
+template void variadic_lambda(int*, float*, double*);
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
new file mode 100644
index 0000000..562f92a
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void test_nonaggregate(int i) {
+ auto lambda = [i]() -> void {}; // expected-note 3{{candidate constructor}}
+ decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}}
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
new file mode 100644
index 0000000..d816e17
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void missing_lambda_declarator() {
+ [](){}();
+}
+
+template<typename T> T get();
+
+void infer_void_return_type(int i) {
+ if (i > 17)
+ return []() { }();
+
+ if (i > 11)
+ return []() { return; }();
+
+ return [](int x) {
+ switch (x) {
+ case 0: return get<void>();
+ case 1: return;
+ case 2: return { 1, 2.0 }; // expected-error{{cannot deduce lambda return type from initializer list}}
+ }
+ }(7);
+}
+
+struct X { };
+
+X infer_X_return_type(X x) {
+ return [&x](int y) { // expected-warning{{omitted result type}}
+ if (y > 0)
+ return X();
+ else
+ return x;
+ }(5);
+}
+
+X infer_X_return_type_fail(X x) {
+ return [x](int y) { // expected-warning{{omitted result type}}
+ if (y > 0)
+ return X();
+ else
+ return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}}
+ }(5);
+}
+
+struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}}
+void test_result_type(int N) {
+ auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}}
+
+ typedef int vla[N];
+ auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int [N]')}}
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm
new file mode 100644
index 0000000..0126e23
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+@interface A
+@end
+
+void test_result_type() {
+ auto l1 = [] () -> A { }; // expected-error{{non-pointer Objective-C class type 'A' in lambda expression result}}
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
new file mode 100644
index 0000000..68460f0
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -std=c++11 %s -Winvalid-noreturn -verify
+
+// An attribute-specifier-seq in a lambda-declarator appertains to the
+// type of the corresponding function call operator.
+void test_attributes() {
+ auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-warning{{control may reach end of non-void lambda}}
+
+ auto nrl2 = []() [[noreturn]] { return; }; // expected-error{{lambda declared 'noreturn' should not return}}
+}
+
+template<typename T>
+struct bogus_override_if_virtual : public T {
+ bogus_override_if_virtual() : T(*(T*)0) { }
+ int operator()() const;
+};
+
+void test_quals() {
+ // This function call operator is declared const (9.3.1) if and only
+ // if the lambda- expression's parameter-declaration-clause is not
+ // followed by mutable.
+ auto l = [=](){}; // expected-note{{method is not marked volatile}}
+ const decltype(l) lc = l;
+ l();
+ lc();
+
+ auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \
+ // expected-note{{method is not marked volatile}}
+ const decltype(ml) mlc = ml;
+ ml();
+ mlc(); // expected-error{{no matching function for call to object of type}}
+
+ // It is neither virtual nor declared volatile.
+ volatile decltype(l) lv = l;
+ volatile decltype(ml) mlv = ml;
+ lv(); // expected-error{{no matching function for call to object of type}}
+ mlv(); // expected-error{{no matching function for call to object of type}}
+
+ bogus_override_if_virtual<decltype(l)> bogus;
+}
+
+// Default arguments (8.3.6) shall not be specified in the
+// parameter-declaration-clause of a lambda- declarator.
+// Note: Removed by core issue 974.
+int test_default_args() {
+ return [](int i = 5, // expected-warning{{C++11 forbids default arguments for lambda expressions}}
+ int j = 17) { return i+j;}(5, 6);
+}
+
+// Any exception-specification specified on a lambda-expression
+// applies to the corresponding function call operator.
+void test_exception_spec() {
+ auto tl1 = []() throw(int) {};
+ auto tl2 = []() {};
+ static_assert(!noexcept(tl1()), "lambda can throw");
+ static_assert(!noexcept(tl2()), "lambda can throw");
+
+ auto ntl1 = []() throw() {};
+ auto ntl2 = []() noexcept(true) {};
+ auto ntl3 = []() noexcept {};
+ static_assert(noexcept(ntl1()), "lambda cannot throw");
+ static_assert(noexcept(ntl2()), "lambda cannot throw");
+ static_assert(noexcept(ntl3()), "lambda cannot throw");
+}
+
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp
new file mode 100644
index 0000000..8b43cef
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+void test_conversion() {
+ int (*fp1)(int) = [](int x) { return x + 1; };
+ void (*fp2)(int) = [](int x) { };
+
+ const auto lambda = [](int x) { };
+ void (*fp3)(int) = lambda;
+
+ volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}}
+ void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}}
+}
+
+void test_no_conversion() {
+ int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}}
+ void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}}
+}
+
+void test_wonky() {
+ const auto l = [](int x) mutable -> int { return + 1; };
+ l(17); // okay: uses conversion function
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
new file mode 100644
index 0000000..9dbe2e1
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
+
+// Check that analysis-based warnings work in lambda bodies.
+void analysis_based_warnings() {
+ (void)[]() -> int { }; // expected-warning{{control reaches end of non-void lambda}}
+}
+
+// Check that we get the right types of captured variables (the
+// semantic-analysis part of p7).
+int &check_const_int(int&);
+float &check_const_int(const int&);
+
+void test_capture_constness(int i, const int ic) {
+ (void)[i,ic] ()->void {
+ float &fr1 = check_const_int(i);
+ float &fr2 = check_const_int(ic);
+ };
+
+ (void)[=] ()->void {
+ float &fr1 = check_const_int(i);
+ float &fr2 = check_const_int(ic);
+ };
+
+ (void)[i,ic] () mutable ->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[=] () mutable ->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[&i,&ic] ()->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+
+ (void)[&] ()->void {
+ int &ir = check_const_int(i);
+ float &fr = check_const_int(ic);
+ };
+}
+
+
+struct S1 {
+ int x, y;
+ S1 &operator=(int*);
+ int operator()(int);
+ void f() {
+ [&]()->int {
+ S1 &s1 = operator=(&this->x);
+ return operator()(this->x + y);
+ }();
+ }
+};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
new file mode 100644
index 0000000..d1384f1
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+class X0 {
+ void explicit_capture() {
+ int foo;
+
+ (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}}
+ (void)[this, this] () {}; // expected-error {{'this' can appear only once}}
+ (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
+ (void)[=, &foo] () {};
+ (void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
+ (void)[&, foo] () {};
+ (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}}
+ (void)[&, this] () {};
+ }
+};
+
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
+
+void S2::f(int i) {
+ (void)[&, i]{ };
+ (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
+ (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[=]{ this->g(i); };
+ (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+}
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
new file mode 100644
index 0000000..49b9c66
--- /dev/null
+++ b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Winvalid-noreturn %s -verify
+
+template<typename T>
+void test_attributes() {
+ auto nrl = []() [[noreturn]] {}; // expected-error{{lambda declared 'noreturn' should not return}}
+}
+
+template void test_attributes<int>(); // expected-note{{in instantiation of function}}
+
+template<typename T>
+void call_with_zero() {
+ [](T *ptr) -> T& { return *ptr; }(0);
+}
+
+template void call_with_zero<int>();
+
+template<typename T>
+T captures(T x, T y) {
+ auto lambda = [=, &y] () -> T {
+ T i = x;
+ return i + y;
+ };
+
+ return lambda();
+}
+
+struct X {
+ X(const X&);
+};
+
+X operator+(X, X);
+X operator-(X, X);
+
+template int captures(int, int);
+template X captures(X, X);
+
+template<typename T>
+int infer_result(T x, T y) {
+ auto lambda = [=](bool b) { return x + y; };
+ return lambda(true); // expected-error{{no viable conversion from 'X' to 'int'}}
+}
+
+template int infer_result(int, int);
+template int infer_result(X, X); // expected-note{{in instantiation of function template specialization 'infer_result<X>' requested here}}
+
+// Make sure that lambda's operator() can be used from templates.
+template<typename F>
+void accept_lambda(F f) {
+ f(1);
+}
+
+template<typename T>
+void pass_lambda(T x) {
+ accept_lambda([&x](T y) { return x + y; });
+}
+
+template void pass_lambda(int);
+
+namespace std {
+ class type_info;
+}
+
+namespace p2 {
+ struct P {
+ virtual ~P();
+ };
+
+ template<typename T>
+ struct Boom {
+ Boom(const Boom&) {
+ T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \
+ // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}}
+ }
+ void tickle() const;
+ };
+
+ template<typename R, typename T>
+ void odr_used(R &r, Boom<T> boom) {
+ const std::type_info &ti
+ = typeid([=,&r] () -> R& { // expected-error{{lambda expression in an unevaluated operand}}
+ boom.tickle(); // expected-note{{in instantiation of member function}}
+ return r;
+ }());
+ }
+
+ template void odr_used(int&, Boom<int>); // expected-note{{in instantiation of function template specialization}}
+
+ template<typename R, typename T>
+ void odr_used2(R &r, Boom<T> boom) {
+ const std::type_info &ti
+ = typeid([=,&r] () -> R& {
+ boom.tickle(); // expected-note{{in instantiation of member function}}
+ return r;
+ }());
+ }
+
+ template void odr_used2(P&, Boom<float>);
+}
+
+namespace p5 {
+ struct NonConstCopy {
+ NonConstCopy(const NonConstCopy&) = delete;
+ NonConstCopy(NonConstCopy&);
+ };
+
+ template<typename T>
+ void double_capture(T &nc) {
+ [=] () mutable {
+ [=] () mutable {
+ T nc2(nc);
+ }();
+ }();
+ }
+
+ template void double_capture(NonConstCopy&);
+}
+
+namespace NonLocalLambdaInstantation {
+ template<typename T>
+ struct X {
+ static int value;
+ };
+
+ template<typename T>
+ int X<T>::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}}
+
+ template int X<int>::value;
+ template int X<float>::value;
+ template int X<int*>::value; // expected-note{{in instantiation of static data member }}
+
+ template<typename T>
+ void defaults(int x = []{ return T(); }()) { }; // expected-error{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}} \
+ // expected-note{{passing argument to parameter 'x' here}}
+
+ void call_defaults() {
+ defaults<int>();
+ defaults<float>();
+ defaults<int*>(); // expected-note{{in instantiation of default function argument expression for 'defaults<int *>' required here}}
+ }
+
+ template<typename T>
+ struct X2 {
+ int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}}
+ };
+
+ X2<int> x2i;
+ X2<float> x2f;
+ X2<int*> x2ip; // expected-note{{in instantiation of template class 'NonLocalLambdaInstantation::X2<int *>' requested here}}
+}
diff --git a/test/CXX/expr/expr.prim/p12-0x.cpp b/test/CXX/expr/expr.prim/p12-0x.cpp
deleted file mode 100644
index aec62dd..0000000
--- a/test/CXX/expr/expr.prim/p12-0x.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-
-struct S {
- int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}}
- int *m = &n; // ok
-
- int n = f(); // ok
- int f();
-};
-
-int i = sizeof(S::m); // ok
-int j = sizeof(S::m + 42); // ok
diff --git a/test/CXX/expr/expr.prim/p4-0x.cpp b/test/CXX/expr/expr.prim/p4-0x.cpp
deleted file mode 100644
index 143ba89..0000000
--- a/test/CXX/expr/expr.prim/p4-0x.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-
-struct S {
- S *p = this; // ok
- decltype(this) q; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} \
- expected-error {{C++ requires a type specifier for all declarations}}
-
- int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
- int sz = sizeof(this); // ok
-};
diff --git a/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp b/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp
new file mode 100644
index 0000000..27b915e
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm-only %s
+
+// this used to crash due to templ<int>'s dtor not being marked as used by the
+// new expression in func()
+struct non_trivial {
+ non_trivial() {}
+ ~non_trivial() {}
+};
+template < typename T > class templ {
+ non_trivial n;
+};
+void func() {
+ new templ<int>[1][1];
+}
diff --git a/test/CXX/expr/expr.unary/expr.new/p17.cpp b/test/CXX/expr/expr.unary/expr.new/p17.cpp
new file mode 100644
index 0000000..0d108eb
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.new/p17.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class ctor {
+ ctor(); // expected-note{{implicitly declared private here}}
+};
+
+class dtor {
+ ~dtor(); // expected-note 3 {{implicitly declared private here}}
+};
+
+void test() {
+ new ctor[0]; // expected-error{{calling a private constructor of class 'ctor'}}
+ new dtor[0]; // expected-error{{calling a private destructor of class 'dtor'}}
+ new dtor[3]; // expected-error{{calling a private destructor of class 'dtor'}}
+ new dtor[3][3]; // expected-error{{calling a private destructor of class 'dtor'}}
+}
diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp
new file mode 100644
index 0000000..2dd6b23
--- /dev/null
+++ b/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+namespace rdar10544564 {
+ // Check that we don't attempt to use an overloaded operator& when
+ // naming a pointer-to-member.
+ struct X {
+ void** operator & ();
+ };
+
+ struct Y
+ {
+ public:
+ X member;
+ X memfunc1();
+ X memfunc2();
+ X memfunc2(int);
+
+ void test() {
+ X Y::*data_mem_ptr = &Y::member;
+ X (Y::*func_mem_ptr1)() = &Y::memfunc1;
+ X (Y::*func_mem_ptr2)() = &Y::memfunc2;
+ }
+ };
+
+ X Y::*data_mem_ptr = &Y::member;
+ X (Y::*func_mem_ptr1)() = &Y::memfunc1;
+ X (Y::*func_mem_ptr2)() = &Y::memfunc2;
+}
diff --git a/test/CXX/lex/lex.charset/p2-cxx11.cpp b/test/CXX/lex/lex.charset/p2-cxx11.cpp
new file mode 100644
index 0000000..b9192ce
--- /dev/null
+++ b/test/CXX/lex/lex.charset/p2-cxx11.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+char c00 = '\u0000'; // ok
+char c01 = '\u0001'; // ok
+char c1f = '\u001f'; // ok
+char c20 = '\u0020'; // ' ', ok
+char c22 = '\u0022'; // ", ok
+char c23 = '\u0023'; // #, ok
+char c24 = '\u0024'; // $, ok
+char c25 = '\u0025'; // %, ok
+char c27 = '\u0027'; // ', ok
+char c3f = '\u003f'; // ?, ok
+char c40 = '\u0040'; // @, ok
+char c41 = '\u0041'; // A, ok
+char c5f = '\u005f'; // _, ok
+char c60 = '\u0060'; // `, ok
+char c7e = '\u007e'; // ~, ok
+char c7f = '\u007f'; // ok
+
+wchar_t w007f = L'\u007f';
+wchar_t w0080 = L'\u0080';
+wchar_t w009f = L'\u009f';
+wchar_t w00a0 = L'\u00a0';
+
+wchar_t wd799 = L'\ud799';
+wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}}
+wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}}
+wchar_t we000 = L'\ue000';
+
+char32_t w10fffe = U'\U0010fffe';
+char32_t w10ffff = U'\U0010ffff';
+char32_t w110000 = U'\U00110000'; // expected-error {{invalid universal character}}
+
+const char *p1 = "\u0000\u0001\u001f\u0020\u0022\u0023\u0024\u0025\u0027\u003f\u0040\u0041\u005f\u0060\u007e\u007f";
+const wchar_t *p2 = L"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char *p3 = u8"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char16_t *p4 = u"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const char32_t *p5 = U"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000";
+const wchar_t *p6 = L"foo \U00110000 bar"; // expected-error {{invalid universal character}}
+const char *p7 = u8"foo \U0000d800 bar"; // expected-error {{invalid universal character}}
+const char16_t *p8 = u"foo \U0000dfff bar"; // expected-error {{invalid universal character}}
+const char32_t *p9 = U"foo \U0010ffff bar"; // ok
diff --git a/test/CXX/lex/lex.charset/p2-cxx98.cpp b/test/CXX/lex/lex.charset/p2-cxx98.cpp
new file mode 100644
index 0000000..a5b7ab6
--- /dev/null
+++ b/test/CXX/lex/lex.charset/p2-cxx98.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++98 %s
+
+char c00 = '\u0000'; // expected-error {{universal character name refers to a control character}}
+char c01 = '\u0001'; // expected-error {{universal character name refers to a control character}}
+char c1f = '\u001f'; // expected-error {{universal character name refers to a control character}}
+char c20 = '\u0020'; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}}
+char c22 = '\u0022'; // ", expected-error {{character '"' cannot be specified by a universal character name}}
+char c23 = '\u0023'; // #, expected-error {{character '#' cannot be specified by a universal character name}}
+char c24 = '\u0024'; // $, ok
+char c25 = '\u0025'; // %, expected-error {{character '%' cannot be specified by a universal character name}}
+char c27 = '\u0027'; // ', expected-error {{character ''' cannot be specified by a universal character name}}
+char c3f = '\u003f'; // ?, expected-error {{character '?' cannot be specified by a universal character name}}
+char c40 = '\u0040'; // @, ok
+char c41 = '\u0041'; // A, expected-error {{character 'A' cannot be specified by a universal character name}}
+char c5f = '\u005f'; // _, expected-error {{character '_' cannot be specified by a universal character name}}
+char c60 = '\u0060'; // `, ok
+char c7e = '\u007e'; // ~, expected-error {{character '~' cannot be specified by a universal character name}}
+char c7f = '\u007f'; // expected-error {{universal character name refers to a control character}}
+
+wchar_t w007f = L'\u007f'; // expected-error {{universal character name refers to a control character}}
+wchar_t w0080 = L'\u0080'; // expected-error {{universal character name refers to a control character}}
+wchar_t w009f = L'\u009f'; // expected-error {{universal character name refers to a control character}}
+wchar_t w00a0 = L'\u00a0';
+
+wchar_t wd799 = L'\ud799';
+wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}}
+wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}}
+wchar_t we000 = L'\ue000';
+
+const char *s00 = "\u0000"; // expected-error {{universal character name refers to a control character}}
+const char *s01 = "\u0001"; // expected-error {{universal character name refers to a control character}}
+const char *s1f = "\u001f"; // expected-error {{universal character name refers to a control character}}
+const char *s20 = "\u0020"; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}}
+const char *s22 = "\u0022"; // ", expected-error {{character '"' cannot be specified by a universal character name}}
+const char *s23 = "\u0023"; // #, expected-error {{character '#' cannot be specified by a universal character name}}
+const char *s24 = "\u0024"; // $, ok
+const char *s25 = "\u0025"; // %, expected-error {{character '%' cannot be specified by a universal character name}}
+const char *s27 = "\u0027"; // ', expected-error {{character ''' cannot be specified by a universal character name}}
+const char *s3f = "\u003f"; // ?, expected-error {{character '?' cannot be specified by a universal character name}}
+const char *s40 = "\u0040"; // @, ok
+const char *s41 = "\u0041"; // A, expected-error {{character 'A' cannot be specified by a universal character name}}
+const char *s5f = "\u005f"; // _, expected-error {{character '_' cannot be specified by a universal character name}}
+const char *s60 = "\u0060"; // `, ok
+const char *s7e = "\u007e"; // ~, expected-error {{character '~' cannot be specified by a universal character name}}
+const char *s7f = "\u007f"; // expected-error {{universal character name refers to a control character}}
+
+const wchar_t *ws007f = L"\u007f"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws0080 = L"\u0080"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws009f = L"\u009f"; // expected-error {{universal character name refers to a control character}}
+const wchar_t *ws00a0 = L"\u00a0";
+
+const wchar_t *wsd799 = L"\ud799";
+const wchar_t *wsd800 = L"\ud800"; // expected-error {{invalid universal character}}
+const wchar_t *wsdfff = L"\udfff"; // expected-error {{invalid universal character}}
+const wchar_t *wse000 = L"\ue000";
diff --git a/test/CXX/lex/lex.literal/lex.ext/p1.cpp b/test/CXX/lex/lex.literal/lex.ext/p1.cpp
index 3981228..1c227a1 100644
--- a/test/CXX/lex/lex.literal/lex.ext/p1.cpp
+++ b/test/CXX/lex/lex.literal/lex.ext/p1.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
-int * operator "" p31(long double); // expected-warning{{user-defined literal with suffix 'p31' is preempted by C99 hexfloat extension}}
-long double operator "" _p31(long double);
-long double operator "" pi(long double); // expected-warning{{user-defined literals not starting with '_' are reserved by the implementation}}
+void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" _p31(long double);
+long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
float hexfloat = 0x1p31; // allow hexfloats
diff --git a/test/CXX/lex/lex.literal/lex.ext/p10.cpp b/test/CXX/lex/lex.literal/lex.ext/p10.cpp
new file mode 100644
index 0000000..1b5d388
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p10.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
+
+template<typename T>
+void f() {
+ // A program containing a reserved ud-suffix is ill-formed.
+ 123wibble; // expected-error {{invalid suffix 'wibble'}}
+ 123.0wibble; // expected-error {{invalid suffix 'wibble'}}
+ const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}}
+ const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}}
+}
diff --git a/test/CXX/lex/lex.literal/lex.ext/p2.cpp b/test/CXX/lex/lex.literal/lex.ext/p2.cpp
new file mode 100644
index 0000000..3f3f796
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p2.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+typedef decltype(sizeof(int)) size_t;
+
+// FIXME: These diagnostics should say 'size_t' instead of 'unsigned long'
+int a = 123_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
+int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'long double' or 'const char *', and no matching literal operator template}}
+int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
+int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const wchar_t *' and 'unsigned}}
+int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char *' and 'unsigned}}
+int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char16_t *' and 'unsigned}}
+int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with arguments of types 'const char32_t *' and 'unsigned}}
+int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char'}}
+int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'wchar_t'}}
+int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char16_t'}}
+int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator "" _x' with argument of type 'char32_t'}}
diff --git a/test/CXX/lex/lex.literal/lex.ext/p3.cpp b/test/CXX/lex/lex.literal/lex.ext/p3.cpp
new file mode 100644
index 0000000..43f3468
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p3.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+int &operator "" _x1 (unsigned long long);
+int &i1 = 0x123_x1;
+
+double &operator "" _x1 (const char *);
+int &i2 = 45_x1;
+
+template<char...> char &operator "" _x1 ();
+int &i3 = 0377_x1;
+
+int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-warning {{integer constant is too large}}
+
+double &operator "" _x2 (const char *);
+double &i5 = 123123123123123123123123123123123123123123123_x2;
+
+template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); }
+static_assert(123456789012345678901234567890123456789012345678901234567890_x3 == 60, "");
diff --git a/test/CXX/lex/lex.literal/lex.ext/p4.cpp b/test/CXX/lex/lex.literal/lex.ext/p4.cpp
new file mode 100644
index 0000000..011e832
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p4.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+int &operator "" _x1 (long double);
+int &i1 = 0.123_x1;
+
+double &operator "" _x1 (const char *);
+int &i2 = 45._x1;
+
+template<char...> char &operator "" _x1 ();
+int &i3 = 0377e-1_x1;
+
+int &i4 = 1e1000000_x1; // expected-warning {{too large for type 'long double'}}
+
+double &operator "" _x2 (const char *);
+double &i5 = 1e1000000_x2;
+
+template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); }
+static_assert(1e1000000_x3 == 9, "");
diff --git a/test/CXX/lex/lex.literal/lex.ext/p5.cpp b/test/CXX/lex/lex.literal/lex.ext/p5.cpp
new file mode 100644
index 0000000..4655aa17
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p5.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+
+int &operator "" _x1 (const char *);
+double &operator "" _x1 (const char *, size_t);
+double &i1 = "foo"_x1;
+double &i2 = u8"foo"_x1;
+double &i3 = L"foo"_x1; // expected-error {{no matching literal operator}}
+
+char &operator "" _x1(const wchar_t *, size_t);
+char &i4 = L"foo"_x1; // ok
+double &i5 = R"(foo)"_x1; // ok
diff --git a/test/CXX/lex/lex.literal/lex.ext/p6.cpp b/test/CXX/lex/lex.literal/lex.ext/p6.cpp
new file mode 100644
index 0000000..23cd708
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p6.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+
+int &operator "" _x1 (const char *);
+double &i1 = 'a'_x1; // expected-error {{no matching literal operator}}
+double &operator "" _x1 (wchar_t);
+double &i2 = L'a'_x1;
+double &i3 = 'a'_x1; // expected-error {{no matching literal operator}}
+double &i4 = operator"" _x1('a'); // ok
+
+char &operator "" _x1(char16_t);
+char &i5 = u'a'_x1; // ok
+double &i6 = L'a'_x1; // ok
diff --git a/test/CXX/lex/lex.literal/lex.ext/p7.cpp b/test/CXX/lex/lex.literal/lex.ext/p7.cpp
new file mode 100644
index 0000000..79c9394
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p7.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+namespace std {
+ struct string {};
+}
+
+template<typename T, typename U> struct same_type;
+template<typename T> struct same_type<T, T> {};
+
+namespace std_example {
+
+long double operator "" _w(long double);
+std::string operator "" _w(const char16_t*, size_t);
+unsigned operator "" _w(const char*);
+int main() {
+ auto v1 = 1.2_w; // calls operator "" _w(1.2L)
+ auto v2 = u"one"_w; // calls operator "" _w(u"one", 3)
+ auto v3 = 12_w; // calls operator "" _w("12")
+ "two"_w; // expected-error {{no matching literal operator}}
+
+ same_type<decltype(v1), long double> test1;
+ same_type<decltype(v2), std::string> test2;
+ same_type<decltype(v3), unsigned> test3;
+}
+
+}
diff --git a/test/CXX/lex/lex.literal/lex.ext/p8.cpp b/test/CXX/lex/lex.literal/lex.ext/p8.cpp
new file mode 100644
index 0000000..d907822
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p8.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+using size_t = decltype(sizeof(int));
+constexpr const char *operator "" _id(const char *p, size_t) { return p; }
+constexpr const char *s = "foo"_id "bar" "baz"_id "quux";
+
+constexpr bool streq(const char *p, const char *q) {
+ return *p == *q && (!*p || streq(p+1, q+1));
+}
+static_assert(streq(s, "foobarbazquux"), "");
+
+constexpr const char *operator "" _trim(const char *p, size_t n) {
+ return *p == ' ' ? operator "" _trim(p + 1, n - 1) : p;
+}
+constexpr const char *t = " " " "_trim " foo";
+static_assert(streq(t, "foo"), "");
+
+const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}}
diff --git a/test/CXX/lex/lex.literal/lex.ext/p9.cpp b/test/CXX/lex/lex.literal/lex.ext/p9.cpp
new file mode 100644
index 0000000..65e27b4
--- /dev/null
+++ b/test/CXX/lex/lex.literal/lex.ext/p9.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+using size_t = decltype(sizeof(int));
+void operator "" _x(const wchar_t *, size_t);
+
+namespace std_example {
+
+int main() {
+ L"A" "B" "C"_x;
+ "P"_x "Q" "R"_y; // expected-error {{differing user-defined suffixes ('_x' and '_y') in string literal concatenation}}
+}
+
+}
diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
new file mode 100644
index 0000000..ea059ce
--- /dev/null
+++ b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// rdar://problem/11120365
+namespace test0 {
+ template <class T> struct A {
+ static void foo(const T &t) {}
+ static void foo(T &&t) {
+ t.foo(); // expected-error {{member reference base type 'int' is not a structure or union}}
+ }
+ };
+
+ void test() {
+ A<int>::foo({}); // expected-note {{requested here}}
+ }
+}
diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
new file mode 100644
index 0000000..31a679f
--- /dev/null
+++ b/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
+
+namespace ExplicitConv {
+ struct X { }; // expected-note 2{{candidate constructor}}
+
+ struct Y {
+ explicit operator X() const;
+ };
+
+ void test(const Y& y) {
+ X x(static_cast<X>(y));
+ X x2((X)y);
+ X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}}
+ }
+}
+
+namespace DR899 {
+ struct C { }; // expected-note 2 {{candidate constructor}}
+
+ struct A {
+ explicit operator int() const;
+ explicit operator C() const;
+ };
+
+ struct B {
+ int i;
+ B(const A& a): i(a) { }
+ };
+
+ int main() {
+ A a;
+ int i = a; // expected-error{{no viable conversion}}
+ int j(a);
+ C c = a; // expected-error{{no viable conversion}}
+ C c2(a);
+ }
+}
diff --git a/test/CXX/over/over.oper/over.literal/p2.cpp b/test/CXX/over/over.oper/over.literal/p2.cpp
new file mode 100644
index 0000000..c012104
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p2.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+void operator "" _a(const char *);
+
+namespace N {
+ using ::operator "" _a;
+
+ void operator "" _b(const char *);
+}
+
+using N::operator "" _b;
+
+class C {
+ void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}}
+
+ static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}}
+
+ friend void operator "" _d(const char *);
+};
+
+int operator "" _e; // expected-error {{cannot be the name of a variable}}
+
+void f() {
+ int operator "" _f; // expected-error {{cannot be the name of a variable}}
+}
+
+extern "C++" {
+ void operator "" _g(const char *);
+}
+
+template<char...> void operator "" _h() {}
+
+template<> void operator "" _h<'a', 'b', 'c'>() {}
+
+template void operator "" _h<'a', 'b', 'c', 'd'>();
diff --git a/test/CXX/over/over.oper/over.literal/p3.cpp b/test/CXX/over/over.oper/over.literal/p3.cpp
new file mode 100644
index 0000000..674ace9
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p3.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+using size_t = decltype(sizeof(int));
+
+// Acceptable parameter declarations
+char operator "" _a(const char *);
+char operator "" _a(const char []);
+char operator "" _a(unsigned long long);
+char operator "" _a(long double);
+char operator "" _a(char);
+char operator "" _a(const volatile char);
+char operator "" _a(wchar_t);
+char operator "" _a(char16_t);
+char operator "" _a(char32_t);
+char operator "" _a(const char *, size_t);
+char operator "" _a(const wchar_t *, size_t);
+char operator "" _a(const char16_t *, size_t);
+char operator "" _a(const char32_t *, size_t);
+char operator "" _a(const char [32], size_t);
+
+// Unacceptable parameter declarations
+char operator "" _b(); // expected-error {{parameter}}
+char operator "" _b(const wchar_t *); // expected-error {{parameter}}
+char operator "" _b(long long); // expected-error {{parameter}}
+char operator "" _b(double); // expected-error {{parameter}}
+char operator "" _b(short); // expected-error {{parameter}}
+char operator "" _a(char, int = 0); // expected-error {{parameter}}
+char operator "" _b(unsigned short); // expected-error {{parameter}}
+char operator "" _b(signed char); // expected-error {{parameter}}
+char operator "" _b(unsigned char); // expected-error {{parameter}}
+char operator "" _b(const short *, size_t); // expected-error {{parameter}}
+char operator "" _b(const unsigned short *, size_t); // expected-error {{parameter}}
+char operator "" _b(const signed char *, size_t); // expected-error {{parameter}}
+char operator "" _b(const unsigned char *, size_t); // expected-error {{parameter}}
+char operator "" _a(const volatile char *, size_t); // expected-error {{parameter}}
+char operator "" _a(volatile wchar_t *, size_t); // expected-error {{parameter}}
+char operator "" _a(char16_t *, size_t); // expected-error {{parameter}}
+char operator "" _a(const char32_t *, size_t, bool = false); // expected-error {{parameter}}
+char operator "" _a(const char *, signed long); // expected-error {{parameter}}
+char operator "" _a(const char *, size_t = 0); // expected-error {{default argument}}
diff --git a/test/CXX/over/over.oper/over.literal/p5.cpp b/test/CXX/over/over.oper/over.literal/p5.cpp
new file mode 100644
index 0000000..66f3f97
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p5.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+using size_t = decltype(sizeof(int));
+template<char...> struct S {};
+
+template<char...> void operator "" _a();
+template<char... C> S<C...> operator "" _a();
+
+template<typename T> struct U {
+ friend int operator "" _a(const char *, size_t);
+ // FIXME: It's not entirely clear whether this is intended to be legal.
+ friend U operator "" _a(const T *, size_t); // expected-error {{parameter}}
+};
+template<char...> struct V {
+ friend void operator "" _b(); // expected-error {{parameter}}
+};
+
+template<char... C, int N = 0> void operator "" _b(); // expected-error {{parameter}}
+template<char... C> void operator "" _b(int N = 0); // expected-error {{parameter}}
+template<char, char...> void operator "" _b(); // expected-error {{parameter}}
+template<typename T> T operator "" _b(const char *); // expected-error {{parameter}}
+template<typename T> int operator "" _b(const T *, size_t); // expected-error {{parameter}}
diff --git a/test/CXX/over/over.oper/over.literal/p6.cpp b/test/CXX/over/over.oper/over.literal/p6.cpp
new file mode 100644
index 0000000..6bfb856
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p6.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}}
+extern "C" template<char...> void operator "" _b(); // expected-error {{must have C++ linkage}}
+
+extern "C" {
+ void operator "" _c(const char *); // expected-error {{must have C++ linkage}}
+ template<char...> void operator "" _d(); // expected-error {{must have C++ linkage}}
+ namespace N {
+ void operator "" _e(const char *); // expected-error {{must have C++ linkage}}
+ template<char...> void operator "" _f(); // expected-error {{must have C++ linkage}}
+ }
+}
diff --git a/test/CXX/over/over.oper/over.literal/p7.cpp b/test/CXX/over/over.oper/over.literal/p7.cpp
new file mode 100644
index 0000000..72411b9
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p7.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+constexpr int operator "" _a(const char *c) {
+ return c[0];
+}
+
+static_assert(operator "" _a("foo") == 'f', "");
+
+void puts(const char *);
+static inline void operator "" _puts(const char *c) {
+ puts(c);
+}
+void f() {
+ operator "" _puts("foo");
+ operator "" _puts("bar");
+}
diff --git a/test/CXX/over/over.oper/over.literal/p8.cpp b/test/CXX/over/over.oper/over.literal/p8.cpp
new file mode 100644
index 0000000..3f76082
--- /dev/null
+++ b/test/CXX/over/over.oper/over.literal/p8.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+struct string;
+namespace std {
+ using size_t = decltype(sizeof(int));
+}
+
+void operator "" _km(long double); // ok
+string operator "" _i18n(const char*, std::size_t); // ok
+// FIXME: This should be accepted once we support UCNs
+template<char...> int operator "" \u03C0(); // ok, UCN for lowercase pi // expected-error {{expected identifier}}
+float operator ""E(const char *); // expected-error {{C++11 requires a space between literal and identifier}} expected-warning {{reserved}}
+float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}}
+string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}}
+double operator "" _miles(double); // expected-error {{parameter}}
+template<char...> int operator "" j(const char*); // expected-error {{parameter}}
+
+// FIXME: Accept this as an extension, with a fix-it to add the space
+float operator ""_E(const char *); // expected-error {{C++11 requires a space between the "" and the user-defined suffix in a literal operator}}
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
index d2a23ce..e021711 100644
--- a/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
+++ b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
@@ -100,8 +100,8 @@ int main()
{ (void) reinterpret_cast<int>(two); } //expected-error {{reinterpret_cast}}
{ (void) reinterpret_cast<int (*)(char, double)>(two); } //expected-error {{reinterpret_cast}}
- { bool b = (twoT<int>); } // ok
- { bool b = (twoT<int, int>); } //ok
+ { bool b = (twoT<int>); }
+ { bool b = (twoT<int, int>); }
{ bool b = &twoT<int>; //&foo<int>; }
b = &(twoT<int>); }
@@ -116,7 +116,7 @@ int main()
{ ptrdiff_t x = (ptrdiff_t) &twoT<int,int>;
x = (ptrdiff_t) &twoT<int>; }
- { oneT<int>; &oneT<int>; } //expected-warning 2{{ expression result unused }}
+ { oneT<int>; &oneT<int>; } //expected-warning 2{{expression result unused}}
{ static_cast<void>(cant_resolve<int>); } // expected-error {{address of overload}}
{ bool b = cant_resolve<int>; } // expected-error {{address of overload}}
{ (void) cant_resolve<int>; } // expected-error {{address of overload}}
@@ -165,8 +165,8 @@ namespace member_pointers {
{ bool b = &S::f<char>; }
{ bool b = &S::f<int>; }
// These next two errors are terrible.
- { bool b = s.f<char>; } // expected-error {{cannot initialize}}
- { bool b = s.f<int>; } // expected-error {{cannot initialize}}
+ { bool b = s.f<char>; } // expected-error {{reference to non-static member function must be called}}
+ { bool b = s.f<int>; } // expected-error {{reference to non-static member function must be called}}
{ bool b = &s.f<char>; } // expected-error {{cannot create a non-constant pointer to member function}}
{ bool b = &s.f<int>; } // expected-error {{cannot create a non-constant pointer to member function}}
diff --git a/test/CXX/special/class.copy/implicit-move-def.cpp b/test/CXX/special/class.copy/implicit-move-def.cpp
index 94023cb..5c54aea 100644
--- a/test/CXX/special/class.copy/implicit-move-def.cpp
+++ b/test/CXX/special/class.copy/implicit-move-def.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s
+// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s
// RUN: %clang_cc1 -emit-llvm -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-CTOR %s
// construct
@@ -96,21 +97,21 @@ void move_VirtualWithEmptyBase(VirtualWithEmptyBase &x, VirtualWithEmptyBase &y)
// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_
// CHECK-ASSIGN: store
// CHECK-ASSIGN-NEXT: store
-// CHECK-NOT: call
-// CHECK: ret
+// CHECK-ASSIGN-NOT: call
+// CHECK-ASSIGN: ret
// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_
// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_
// move ctors
-// CHECK-CTOR: define linkonce_odr void @_ZN1HC2EOS_
-// CHECK-CTOR: call void @_ZN1GC2EOS_
-// CHECK-CTOR: call void @_ZN1FC1EOS_
-// CHECK-CTOR: call void @_ZN1EC1EOS_
+// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1HC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1GC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_
// array loop
// CHECK-CTOR: br i1
-// CHECK-CTOR: call void @_ZN1FC1EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_
-// CHECK-CTOR: define linkonce_odr void @_ZN1GC2EOS_
-// CHECK-CTOR: call void @_ZN1EC1EOS_
+// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1GC2EOS_
+// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_
diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp
index 74f7eee..b1b298e 100644
--- a/test/CXX/special/class.copy/implicit-move.cpp
+++ b/test/CXX/special/class.copy/implicit-move.cpp
@@ -25,10 +25,10 @@ struct HasCopyAssignment {
HasCopyAssignment & operator =(const HasCopyAssignment &) noexcept(false);
};
-struct HasMoveConstructor { // expected-note {{implicit copy assignment}}
+struct HasMoveConstructor {
ThrowingCopy tc;
HasMoveConstructor() noexcept;
- HasMoveConstructor(HasMoveConstructor &&) noexcept;
+ HasMoveConstructor(HasMoveConstructor &&) noexcept; // expected-note {{copy assignment operator is implicitly deleted because 'HasMoveConstructor' has a user-declared move constructor}}
};
struct HasMoveAssignment { // expected-note {{implicit copy constructor}}
@@ -54,7 +54,7 @@ void test_basic_exclusion() {
static_assert(noexcept(HasMoveConstructor((HasMoveConstructor()))), "");
HasMoveConstructor hmc;
- hmc = HasMoveConstructor(); // expected-error {{selected deleted operator}}
+ hmc = HasMoveConstructor(); // expected-error {{selected implicitly-deleted copy assignment}}
(HasMoveAssignment(HasMoveAssignment())); // expected-error {{uses deleted function}}
HasMoveAssignment hma;
@@ -87,9 +87,9 @@ private:
~PrivateDestructor() noexcept;
};
-struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note {{explicitly marked deleted}}
-struct ContainsPrivateDestructor { // expected-note {{explicitly marked deleted}}
- PrivateDestructor pd;
+struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note{{base class 'PrivateDestructor' has an inaccessible destructor}}
+struct ContainsPrivateDestructor {
+ PrivateDestructor pd; // expected-note{{field 'pd' has an inaccessible destructor}}
};
struct NonTrivialCopyOnly {
@@ -131,8 +131,8 @@ void test_deletion_exclusion() {
ContainsPrivateMove cpm;
static_assert(!noexcept(cpm = ContainsPrivateMove()), "");
- (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to deleted constructor}}
- (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to deleted constructor}}
+ (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}}
+ (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}}
static_assert(!noexcept(InheritsNonTrivialCopyOnly(InheritsNonTrivialCopyOnly())), "");
static_assert(!noexcept(ContainsNonTrivialCopyOnly(ContainsNonTrivialCopyOnly())), "");
@@ -162,3 +162,75 @@ struct ContainsRValueRef {
void test_contains_rref() {
(ContainsRValueRef(ContainsRValueRef()));
}
+
+
+namespace DR1402 {
+ struct NonTrivialCopyCtor {
+ NonTrivialCopyCtor(const NonTrivialCopyCtor &);
+ };
+ struct NonTrivialCopyAssign {
+ NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &);
+ };
+
+ struct NonTrivialCopyCtorVBase : virtual NonTrivialCopyCtor {
+ NonTrivialCopyCtorVBase(NonTrivialCopyCtorVBase &&);
+ NonTrivialCopyCtorVBase &operator=(NonTrivialCopyCtorVBase &&) = default;
+ };
+ struct NonTrivialCopyAssignVBase : virtual NonTrivialCopyAssign {
+ NonTrivialCopyAssignVBase(NonTrivialCopyAssignVBase &&);
+ NonTrivialCopyAssignVBase &operator=(NonTrivialCopyAssignVBase &&) = default;
+ };
+
+ struct NonTrivialMoveAssign {
+ NonTrivialMoveAssign(NonTrivialMoveAssign&&);
+ NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&);
+ };
+ struct NonTrivialMoveAssignVBase : virtual NonTrivialMoveAssign {
+ NonTrivialMoveAssignVBase(NonTrivialMoveAssignVBase &&);
+ NonTrivialMoveAssignVBase &operator=(NonTrivialMoveAssignVBase &&) = default;
+ };
+
+ // A non-movable, non-trivially-copyable class type as a subobject inhibits
+ // the declaration of a move operation.
+ struct NoMove1 { NonTrivialCopyCtor ntcc; }; // expected-note 2{{'const DR1402::NoMove1 &'}}
+ struct NoMove2 { NonTrivialCopyAssign ntcc; }; // expected-note 2{{'const DR1402::NoMove2 &'}}
+ struct NoMove3 : NonTrivialCopyCtor {}; // expected-note 2{{'const DR1402::NoMove3 &'}}
+ struct NoMove4 : NonTrivialCopyAssign {}; // expected-note 2{{'const DR1402::NoMove4 &'}}
+ struct NoMove5 : virtual NonTrivialCopyCtor {}; // expected-note 2{{'const DR1402::NoMove5 &'}}
+ struct NoMove6 : virtual NonTrivialCopyAssign {}; // expected-note 2{{'const DR1402::NoMove6 &'}}
+ struct NoMove7 : NonTrivialCopyCtorVBase {}; // expected-note 2{{'DR1402::NoMove7 &'}}
+ struct NoMove8 : NonTrivialCopyAssignVBase {}; // expected-note 2{{'DR1402::NoMove8 &'}}
+
+ // A non-trivially-move-assignable virtual base class inhibits the declaration
+ // of a move assignment (which might move-assign the base class multiple
+ // times).
+ struct NoMove9 : NonTrivialMoveAssign {};
+ struct NoMove10 : virtual NonTrivialMoveAssign {}; // expected-note {{'DR1402::NoMove10 &'}}
+ struct NoMove11 : NonTrivialMoveAssignVBase {}; // expected-note {{'DR1402::NoMove11 &'}}
+
+ struct Test {
+ friend NoMove1::NoMove1(NoMove1 &&); // expected-error {{no matching function}}
+ friend NoMove2::NoMove2(NoMove2 &&); // expected-error {{no matching function}}
+ friend NoMove3::NoMove3(NoMove3 &&); // expected-error {{no matching function}}
+ friend NoMove4::NoMove4(NoMove4 &&); // expected-error {{no matching function}}
+ friend NoMove5::NoMove5(NoMove5 &&); // expected-error {{no matching function}}
+ friend NoMove6::NoMove6(NoMove6 &&); // expected-error {{no matching function}}
+ friend NoMove7::NoMove7(NoMove7 &&); // expected-error {{no matching function}}
+ friend NoMove8::NoMove8(NoMove8 &&); // expected-error {{no matching function}}
+ friend NoMove9::NoMove9(NoMove9 &&);
+ friend NoMove10::NoMove10(NoMove10 &&);
+ friend NoMove11::NoMove11(NoMove11 &&);
+
+ friend NoMove1 &NoMove1::operator=(NoMove1 &&); // expected-error {{no matching function}}
+ friend NoMove2 &NoMove2::operator=(NoMove2 &&); // expected-error {{no matching function}}
+ friend NoMove3 &NoMove3::operator=(NoMove3 &&); // expected-error {{no matching function}}
+ friend NoMove4 &NoMove4::operator=(NoMove4 &&); // expected-error {{no matching function}}
+ friend NoMove5 &NoMove5::operator=(NoMove5 &&); // expected-error {{no matching function}}
+ friend NoMove6 &NoMove6::operator=(NoMove6 &&); // expected-error {{no matching function}}
+ friend NoMove7 &NoMove7::operator=(NoMove7 &&); // expected-error {{no matching function}}
+ friend NoMove8 &NoMove8::operator=(NoMove8 &&); // expected-error {{no matching function}}
+ friend NoMove9 &NoMove9::operator=(NoMove9 &&);
+ friend NoMove10 &NoMove10::operator=(NoMove10 &&); // expected-error {{no matching function}}
+ friend NoMove11 &NoMove11::operator=(NoMove11 &&); // expected-error {{no matching function}}
+ };
+}
diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp
index 752872a..b2b4f6a 100644
--- a/test/CXX/special/class.copy/p11.0x.copy.cpp
+++ b/test/CXX/special/class.copy/p11.0x.copy.cpp
@@ -4,22 +4,28 @@ struct NonTrivial {
NonTrivial(const NonTrivial&);
};
-union DeletedNTVariant { // expected-note{{here}}
- NonTrivial NT;
+// A defaulted copy constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
+union DeletedNTVariant {
+ NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
DeletedNTVariant();
};
DeletedNTVariant DVa;
-DeletedNTVariant DVb(DVa); // expected-error{{call to deleted constructor}}
+DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy constructor}}
-struct DeletedNTVariant2 { // expected-note{{here}}
+struct DeletedNTVariant2 {
union {
- NonTrivial NT;
+ NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant2' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
};
DeletedNTVariant2();
};
DeletedNTVariant2 DV2a;
-DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to deleted constructor}}
+DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}}
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
struct NoAccess {
NoAccess() = default;
private:
@@ -28,11 +34,11 @@ private:
friend struct HasAccess;
};
-struct HasNoAccess { // expected-note{{here}}
- NoAccess NA;
+struct HasNoAccess {
+ NoAccess NA; // expected-note{{copy constructor of 'HasNoAccess' is implicitly deleted because field 'NA' has an inaccessible copy constructor}}
};
HasNoAccess HNAa;
-HasNoAccess HNAb(HNAa); // expected-error{{call to deleted constructor}}
+HasNoAccess HNAb(HNAa); // expected-error{{call to implicitly-deleted copy constructor}}
struct HasAccess {
NoAccess NA;
@@ -49,33 +55,52 @@ struct Ambiguity {
Ambiguity(volatile Ambiguity&);
};
-struct IsAmbiguous { // expected-note{{here}}
+struct IsAmbiguous {
NonConst NC;
- Ambiguity A;
+ Ambiguity A; // expected-note 2{{copy constructor of 'IsAmbiguous' is implicitly deleted because field 'A' has multiple copy constructors}}
IsAmbiguous();
};
IsAmbiguous IAa;
-IsAmbiguous IAb(IAa); // expected-error{{call to deleted constructor}}
+IsAmbiguous IAb(IAa); // expected-error{{call to implicitly-deleted copy constructor}}
-struct Deleted { // expected-note{{here}}
- IsAmbiguous IA;
+struct Deleted {
+ IsAmbiguous IA; // expected-note{{copy constructor of 'Deleted' is implicitly deleted because field 'IA' has a deleted copy constructor}}
};
Deleted Da;
-Deleted Db(Da); // expected-error{{call to deleted constructor}}
+Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}}
+
+// -- a direct or virtual base class B that cannot be copied because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousCopyBase : Ambiguity { // expected-note 2{{copy constructor of 'AmbiguousCopyBase' is implicitly deleted because base class 'Ambiguity' has multiple copy constructors}}
+ NonConst NC;
+};
+extern AmbiguousCopyBase ACBa;
+AmbiguousCopyBase ACBb(ACBa); // expected-error {{deleted copy constructor}}
+struct DeletedCopyBase : AmbiguousCopyBase {}; // expected-note {{copy constructor of 'DeletedCopyBase' is implicitly deleted because base class 'AmbiguousCopyBase' has a deleted copy constructor}}
+extern DeletedCopyBase DCBa;
+DeletedCopyBase DCBb(DCBa); // expected-error {{deleted copy constructor}}
+
+struct InaccessibleCopyBase : NoAccess {}; // expected-note {{copy constructor of 'InaccessibleCopyBase' is implicitly deleted because base class 'NoAccess' has an inaccessible copy constructor}}
+extern InaccessibleCopyBase ICBa;
+InaccessibleCopyBase ICBb(ICBa); // expected-error {{deleted copy constructor}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
struct NoAccessDtor {
private:
~NoAccessDtor();
friend struct HasAccessDtor;
};
-struct HasNoAccessDtor { // expected-note{{here}}
- NoAccessDtor NAD;
+struct HasNoAccessDtor {
+ NoAccessDtor NAD; // expected-note{{copy constructor of 'HasNoAccessDtor' is implicitly deleted because field 'NAD' has an inaccessible destructor}}
HasNoAccessDtor();
~HasNoAccessDtor();
};
HasNoAccessDtor HNADa;
-HasNoAccessDtor HNADb(HNADa); // expected-error{{call to deleted constructor}}
+HasNoAccessDtor HNADb(HNADa); // expected-error{{call to implicitly-deleted copy constructor}}
struct HasAccessDtor {
NoAccessDtor NAD;
@@ -83,8 +108,14 @@ struct HasAccessDtor {
HasAccessDtor HADa;
HasAccessDtor HADb(HADa);
-struct RValue { // expected-note{{here}}
- int && ri = 1;
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has an inaccessible destructor}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// -- a non-static data member of rvalue reference type
+struct RValue {
+ int && ri = 1; // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}}
};
RValue RVa;
-RValue RVb(RVa); // expected-error{{call to deleted constructor}}
+RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}}
diff --git a/test/CXX/special/class.copy/p11.0x.move.cpp b/test/CXX/special/class.copy/p11.0x.move.cpp
index 402bc31..ff9478b 100644
--- a/test/CXX/special/class.copy/p11.0x.move.cpp
+++ b/test/CXX/special/class.copy/p11.0x.move.cpp
@@ -4,6 +4,9 @@ struct NonTrivial {
NonTrivial(NonTrivial&&);
};
+// A defaulted move constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
union DeletedNTVariant {
NonTrivial NT;
DeletedNTVariant(DeletedNTVariant&&);
@@ -18,6 +21,9 @@ struct DeletedNTVariant2 {
};
DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // expected-error{{would delete}}
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
struct NoAccess {
NoAccess() = default;
private:
@@ -38,8 +44,45 @@ struct HasAccess {
};
HasAccess::HasAccess(HasAccess&&) = default;
+struct Ambiguity {
+ Ambiguity(const Ambiguity&&);
+ Ambiguity(volatile Ambiguity&&);
+};
+
+struct IsAmbiguous {
+ Ambiguity A;
+ IsAmbiguous(IsAmbiguous&&);
+};
+IsAmbiguous::IsAmbiguous(IsAmbiguous&&) = default; // expected-error{{would delete}}
+
+struct Deleted {
+ IsAmbiguous IA;
+ Deleted(Deleted&&);
+};
+Deleted::Deleted(Deleted&&) = default; // expected-error{{would delete}}
+
+// -- a direct or virtual base class B that cannot be moved because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousMoveBase : Ambiguity {
+ AmbiguousMoveBase(AmbiguousMoveBase&&);
+};
+AmbiguousMoveBase::AmbiguousMoveBase(AmbiguousMoveBase&&) = default; // expected-error{{would delete}}
+
+struct DeletedMoveBase : AmbiguousMoveBase {
+ DeletedMoveBase(DeletedMoveBase&&);
+};
+DeletedMoveBase::DeletedMoveBase(DeletedMoveBase&&) = default; // expected-error{{would delete}}
+
+struct InaccessibleMoveBase : NoAccess {
+ InaccessibleMoveBase(InaccessibleMoveBase&&);
+};
+InaccessibleMoveBase::InaccessibleMoveBase(InaccessibleMoveBase&&) = default; // expected-error{{would delete}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
struct NoAccessDtor {
- NoAccessDtor(NoAccessDtor&&);
+ NoAccessDtor(NoAccessDtor&&); // expected-note{{copy constructor is implicitly deleted because 'NoAccessDtor' has a user-declared move constructor}}
private:
~NoAccessDtor();
friend struct HasAccessDtor;
@@ -57,12 +100,21 @@ struct HasAccessDtor {
};
HasAccessDtor::HasAccessDtor(HasAccessDtor&&) = default;
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has a deleted copy constructor}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// The restriction on rvalue reference members applies to only the copy
+// constructor.
struct RValue {
int &&ri = 1;
RValue(RValue&&);
};
RValue::RValue(RValue&&) = default;
+// -- a non-static data member or direct or virtual base class with a type that
+// does not have a move constructor and is not trivially copyable
struct CopyOnly {
CopyOnly(const CopyOnly&);
};
@@ -71,7 +123,7 @@ struct NonMove {
CopyOnly CO;
NonMove(NonMove&&);
};
-NonMove::NonMove(NonMove&&) = default; // expected-error{{would delete}}
+NonMove::NonMove(NonMove&&) = default; // ok under DR1402
struct Moveable {
Moveable();
@@ -83,3 +135,30 @@ struct HasMove {
HasMove(HasMove&&);
};
HasMove::HasMove(HasMove&&) = default;
+
+namespace DR1402 {
+ struct member {
+ member();
+ member(const member&);
+ member& operator=(const member&);
+ ~member();
+ };
+
+ struct A {
+ member m_;
+
+ A() = default;
+ A(const A&) = default;
+ A& operator=(const A&) = default;
+ A(A&&) = default;
+ A& operator=(A&&) = default;
+ ~A() = default;
+ };
+
+ // ok, A's explicitly-defaulted move operations copy m_.
+ void f() {
+ A a, b(a), c(static_cast<A&&>(a));
+ a = b;
+ b = static_cast<A&&>(c);
+ }
+}
diff --git a/test/CXX/special/class.copy/p13-0x.cpp b/test/CXX/special/class.copy/p13-0x.cpp
new file mode 100644
index 0000000..0a9aa62
--- /dev/null
+++ b/test/CXX/special/class.copy/p13-0x.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// If the implicitly-defined constructor would satisfy the requirements of a
+// constexpr constructor, the implicitly-defined constructor is constexpr.
+struct Constexpr1 {
+ constexpr Constexpr1() : n(0) {}
+ int n;
+};
+constexpr Constexpr1 c1a = Constexpr1(Constexpr1()); // ok
+constexpr Constexpr1 c1b = Constexpr1(Constexpr1(c1a)); // ok
+
+struct Constexpr2 {
+ Constexpr1 ce1;
+ constexpr Constexpr2() = default;
+ constexpr Constexpr2(const Constexpr2 &o) : ce1(o.ce1) {}
+ // no move constructor
+};
+
+constexpr Constexpr2 c2a = Constexpr2(Constexpr2()); // ok
+constexpr Constexpr2 c2b = Constexpr2(Constexpr2(c2a)); // ok
+
+struct Constexpr3 {
+ Constexpr2 ce2;
+ // all special constructors are constexpr, move ctor calls ce2's copy ctor
+};
+
+constexpr Constexpr3 c3a = Constexpr3(Constexpr3()); // ok
+constexpr Constexpr3 c3b = Constexpr3(Constexpr3(c3a)); // ok
+
+struct NonConstexprCopy {
+ constexpr NonConstexprCopy() = default;
+ NonConstexprCopy(const NonConstexprCopy &);
+ constexpr NonConstexprCopy(NonConstexprCopy &&) = default;
+
+ int n = 42;
+};
+
+NonConstexprCopy::NonConstexprCopy(const NonConstexprCopy &) = default; // expected-note {{here}}
+
+constexpr NonConstexprCopy ncc1 = NonConstexprCopy(NonConstexprCopy()); // ok
+constexpr NonConstexprCopy ncc2 = ncc1; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}}
+
+struct NonConstexprDefault {
+ NonConstexprDefault() = default;
+ constexpr NonConstexprDefault(int n) : n(n) {}
+ int n;
+};
+struct Constexpr4 {
+ NonConstexprDefault ncd;
+};
+
+constexpr NonConstexprDefault ncd = NonConstexprDefault(NonConstexprDefault(1));
+constexpr Constexpr4 c4a = { ncd };
+constexpr Constexpr4 c4b = Constexpr4(c4a);
+constexpr Constexpr4 c4c = Constexpr4(static_cast<Constexpr4&&>(const_cast<Constexpr4&>(c4b)));
+
+struct Constexpr5Base {};
+struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} };
+constexpr Constexpr5 ce5move = Constexpr5();
+constexpr Constexpr5 ce5copy = ce5move;
diff --git a/test/CXX/special/class.copy/p15-0x.cpp b/test/CXX/special/class.copy/p15-0x.cpp
index 32b2714..fff8844 100644
--- a/test/CXX/special/class.copy/p15-0x.cpp
+++ b/test/CXX/special/class.copy/p15-0x.cpp
@@ -16,3 +16,26 @@ namespace PR10622 {
bar obj2(obj);
}
}
+
+namespace PR11418 {
+ template<typename T>
+ T may_throw() {
+ return T();
+ }
+
+ template<typename T> T &&declval() noexcept;
+
+ struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD &) noexcept;
+ NonPOD(NonPOD &&) noexcept;
+ };
+
+ struct X {
+ NonPOD np = may_throw<NonPOD>();
+ };
+
+ static_assert(noexcept(declval<X>()), "noexcept isn't working at all");
+ static_assert(noexcept(X(declval<X&>())), "copy constructor can't throw");
+ static_assert(noexcept(X(declval<X>())), "move constructor can't throw");
+}
diff --git a/test/CXX/special/class.copy/p15-inclass.cpp b/test/CXX/special/class.copy/p15-inclass.cpp
new file mode 100644
index 0000000..c4f8eaf
--- /dev/null
+++ b/test/CXX/special/class.copy/p15-inclass.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+namespace PR11418 {
+ struct NonPOD {
+ NonPOD();
+ NonPOD(const NonPOD &);
+ NonPOD(NonPOD &&);
+ };
+
+ struct X {
+ NonPOD np;
+ int a = 17;
+ };
+
+ void check_copy(X x) {
+ X x2(x);
+ }
+
+ void check_move(X x) {
+ X x3(static_cast<X&&>(x));
+ }
+
+ // CHECK: define linkonce_odr void @_ZN7PR114181XC2EOS0_
+ // CHECK-NOT: 17
+ // CHECK: call void @_ZN7PR114186NonPODC1EOS0_
+ // CHECK-NOT: 17
+ // CHECK: load i32*
+ // CHECK-NOT: 17
+ // CHECK: store i32
+ // CHECK-NOT: 17
+ // CHECK: ret
+
+ // CHECK: define linkonce_odr void @_ZN7PR114181XC2ERKS0_
+ // CHECK-NOT: 17
+ // CHECK: call void @_ZN7PR114186NonPODC1ERKS0_
+ // CHECK-NOT: 17
+ // CHECK: load i32*
+ // CHECK-NOT: 17
+ // CHECK: store i32
+ // CHECK-NOT: 17
+ // CHECK: ret
+}
diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp
index de2dea5..694ab5b 100644
--- a/test/CXX/special/class.ctor/p5-0x.cpp
+++ b/test/CXX/special/class.ctor/p5-0x.cpp
@@ -2,9 +2,9 @@
struct DefaultedDefCtor1 {};
struct DefaultedDefCtor2 { DefaultedDefCtor2() = default; };
-struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); };
+struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); }; // expected-note {{explicitly marked deleted here}}
class PrivateDefCtor { PrivateDefCtor() = default; public: PrivateDefCtor(int); };
-struct DeletedDtor { ~DeletedDtor() = delete; };
+struct DeletedDtor { ~DeletedDtor() = delete; }; // expected-note 4{{explicitly marked deleted here}}
class PrivateDtor { ~PrivateDtor() = default; };
class Friend {
Friend() = default; ~Friend() = default;
@@ -21,37 +21,42 @@ int n;
// - X is a union-like class that has a variant member with a non-trivial
// default constructor,
-union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{deleted here}}
-Deleted1a d1a; // expected-error {{deleted constructor}}
+union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of union 'Deleted1a' is implicitly deleted because field 'u' has a non-trivial default constructor}}
+Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}}
union NotDeleted1a { DefaultedDefCtor1 nu; };
NotDeleted1a nd1a;
-// FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2's
-// default constructor is non-trivial.
-union NotDeleted1b { DefaultedDefCtor2 nu; }; // unexpected-note {{deleted here}}
-NotDeleted1b nd1b; // unexpected-error {{deleted constructor}}
+union NotDeleted1b { DefaultedDefCtor2 nu; };
+NotDeleted1b nd1b;
// - any non-static data member with no brace-or-equal-initializer is of
// reference type,
-class Deleted2a { Deleted2a() = default; int &a; }; // expected-note {{deleted here}}
-Deleted2a d2a; // expected-error {{deleted constructor}}
+class Deleted2a {
+ Deleted2a() = default; // expected-note 4{{implicitly deleted here}}
+ int &a; // expected-note 4{{because field 'a' of reference type 'int &' would not be initialized}}
+};
+Deleted2a d2a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted2b {
+ int &&b; // expected-note {{default constructor of 'Deleted2b' is implicitly deleted because field 'b' of reference type 'int &&' would not be initialized}}
+};
+Deleted2b d2b; // expected-error {{deleted default constructor}}
class NotDeleted2a { int &a = n; };
NotDeleted2a nd2a;
class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}}
NotDeleted2b nd2b;
+class NotDeleted2c { int &&a = 0; };
+NotDeleted2c nd2c;
// - any non-variant non-static data member of const qualified type (or array
// thereof) with no brace-or-equal-initializer does not have a user-provided
// default constructor,
-class Deleted3a { const int a; }; // expected-note {{here}} \
+class Deleted3a { const int a; }; // expected-note {{because field 'a' of const-qualified type 'const int' would not be initialized}} \
expected-warning {{does not declare any constructor}} \
expected-note {{will never be initialized}}
-Deleted3a d3a; // expected-error {{deleted constructor}}
-class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{here}}
-Deleted3b d3b; // expected-error {{deleted constructor}}
-// FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2's
-// default constructor is user-provided.
-class Deleted3c { const DefaultedDefCtor2 a; }; // desired-note {{here}}
-Deleted3c d3c; // desired-error {{deleted constructor}}
+Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}}
+class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1' would not be initialized}}
+Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}}
+class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor2' would not be initialized}}
+Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}}
class NotDeleted3a { const int a = 0; };
NotDeleted3a nd3a;
class NotDeleted3b { const DefaultedDefCtor1 a[42] = {}; };
@@ -60,45 +65,51 @@ class NotDeleted3c { const DefaultedDefCtor2 a = DefaultedDefCtor2(); };
NotDeleted3c nd3c;
union NotDeleted3d { const int a; int b; };
NotDeleted3d nd3d;
-// FIXME: this class should not have a deleted default constructor.
-union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; }; // unexpected-note {{here}}
-NotDeleted3e nd3e; // unexpected-error {{deleted constructor}}
-// FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2 is
-// non-trivial.
-union NotDeleted3f { const DefaultedDefCtor2 a; int b; }; // unexpected-note {{here}}
-NotDeleted3f nd3f; // unexpected-error {{deleted constructor}}
+union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; };
+NotDeleted3e nd3e;
+union NotDeleted3f { const DefaultedDefCtor2 a; int b; };
+NotDeleted3f nd3f;
+struct NotDeleted3g { union { const int a; int b; }; };
+NotDeleted3g nd3g;
// - X is a union and all of its variant members are of const-qualified type (or
// array thereof),
-union Deleted4a { const int a; const int b; const UserProvidedDefCtor c; }; // expected-note {{here}}
-Deleted4a d4a; // expected-error {{deleted constructor}}
-union Deleted4b { const int a; int b; };
-Deleted4b d4b;
+union Deleted4a {
+ const int a;
+ const int b;
+ const UserProvidedDefCtor c; // expected-note {{because field 'c' has a non-trivial default constructor}}
+};
+Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}}
+union NotDeleted4a { const int a; int b; };
+NotDeleted4a nd4a;
// - X is a non-union class and all members of any anonymous union member are of
// const-qualified type (or array thereof),
-struct Deleted5a { union { const int a; }; union { int b; }; }; // expected-note {{here}}
-Deleted5a d5a; // expected-error {{deleted constructor}}
-struct Deleted5b { union { const int a; int b; }; union { const int c; int d; }; };
-Deleted5b d5b;
+struct Deleted5a {
+ union { const int a; }; // expected-note {{because all data members of an anonymous union member are const-qualified}}
+ union { int b; };
+};
+Deleted5a d5a; // expected-error {{implicitly-deleted default constructor}}
+struct NotDeleted5a { union { const int a; int b; }; union { const int c; int d; }; };
+NotDeleted5a nd5a;
// - any direct or virtual base class, or non-static data member with no
// brace-or-equal-initializer, has class type M (or array thereof) and either
// M has no default constructor or overload resolution as applied to M's default
// constructor results in an ambiguity or in a function that is deleted or
// inaccessible from the defaulted default constructor, or
-struct Deleted6a : Deleted2a {}; // expected-note {{here}}
-Deleted6a d6a; // expected-error {{deleted constructor}}
-struct Deleted6b : virtual Deleted2a {}; // expected-note {{here}}
-Deleted6b d6b; // expected-error {{deleted constructor}}
-struct Deleted6c { Deleted2a a; }; // expected-note {{here}}
-Deleted6c d6c; // expected-error {{deleted constructor}}
-struct Deleted6d { DeletedDefCtor a; }; // expected-note {{here}}
-Deleted6d d6d; // expected-error {{deleted constructor}}
+struct Deleted6a : Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}}
+Deleted6a d6a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6b : virtual Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}}
+Deleted6b d6b; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6c { Deleted2a a; }; // expected-note {{because field 'a' has a deleted default constructor}}
+Deleted6c d6c; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted6d { DeletedDefCtor a; }; // expected-note {{because field 'a' has a deleted default constructor}}
+Deleted6d d6d; // expected-error {{implicitly-deleted default constructor}}
struct NotDeleted6a { DeletedDefCtor a = 0; };
NotDeleted6a nd6a;
-struct Deleted6e { PrivateDefCtor a; }; // expected-note {{here}}
-Deleted6e d6e; // expected-error {{deleted constructor}}
+struct Deleted6e { PrivateDefCtor a; }; // expected-note {{because field 'a' has an inaccessible default constructor}}
+Deleted6e d6e; // expected-error {{implicitly-deleted default constructor}}
struct NotDeleted6b { PrivateDefCtor a = 0; };
NotDeleted6b nd6b;
struct NotDeleted6c { Friend a; };
@@ -107,22 +118,22 @@ NotDeleted6c nd6c;
// - any direct or virtual base class or non-static data member has a type with
// a destructor that is deleted or inaccessible from the defaulted default
// constructor.
-struct Deleted7a : DeletedDtor {}; // expected-note {{here}}
-Deleted7a d7a; // expected-error {{deleted constructor}}
-struct Deleted7b : virtual DeletedDtor {}; // expected-note {{here}}
-Deleted7b d7b; // expected-error {{deleted constructor}}
-struct Deleted7c { DeletedDtor a; }; // expected-note {{here}}
-Deleted7c d7c; // expected-error {{deleted constructor}}
-struct Deleted7d { DeletedDtor a = {}; }; // expected-note {{here}}
-Deleted7d d7d; // expected-error {{deleted constructor}}
-struct Deleted7e : PrivateDtor {}; // expected-note {{here}}
-Deleted7e d7e; // expected-error {{deleted constructor}}
-struct Deleted7f : virtual PrivateDtor {}; // expected-note {{here}}
-Deleted7f d7f; // expected-error {{deleted constructor}}
-struct Deleted7g { PrivateDtor a; }; // expected-note {{here}}
-Deleted7g d7g; // expected-error {{deleted constructor}}
-struct Deleted7h { PrivateDtor a = {}; }; // expected-note {{here}}
-Deleted7h d7h; // expected-error {{deleted constructor}}
+struct Deleted7a : DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}}
+Deleted7a d7a; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7b : virtual DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}}
+Deleted7b d7b; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7c { DeletedDtor a; }; // expected-note {{because field 'a' has a deleted destructor}}
+Deleted7c d7c; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7d { DeletedDtor a = {}; }; // expected-note {{because field 'a' has a deleted destructor}}
+Deleted7d d7d; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7e : PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}}
+Deleted7e d7e; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7f : virtual PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}}
+Deleted7f d7f; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7g { PrivateDtor a; }; // expected-note {{field 'a' has an inaccessible destructor}}
+Deleted7g d7g; // expected-error {{implicitly-deleted default constructor}}
+struct Deleted7h { PrivateDtor a = {}; }; // expected-note {{field 'a' has an inaccessible destructor}}
+Deleted7h d7h; // expected-error {{implicitly-deleted default constructor}}
struct NotDeleted7i : Friend {};
NotDeleted7i d7i;
struct NotDeleted7j : virtual Friend {};
@@ -159,11 +170,13 @@ static_assert(!__has_trivial_constructor(NonTrivialDefCtor6), "NonTrivialDefCtor
// Otherwise, the default constructor is non-trivial.
class Trivial2 { Trivial2() = delete; };
-//static_assert(__has_trivial_constructor(Trivial2), "NonTrivialDefCtor2 is trivial");
-// FIXME: clang implements the pre-FDIS rule, under which this class is non-trivial.
-static_assert(!__has_trivial_constructor(Trivial2), "NonTrivialDefCtor2 is trivial");
+static_assert(__has_trivial_constructor(Trivial2), "Trivial2 is trivial");
class Trivial3 { Trivial3() = default; };
-//static_assert(__has_trivial_constructor(Trivial3), "NonTrivialDefCtor3 is trivial");
-// FIXME: clang implements the pre-FDIS rule, under which this class is non-trivial.
-static_assert(!__has_trivial_constructor(Trivial3), "NonTrivialDefCtor3 is trivial");
+static_assert(__has_trivial_constructor(Trivial3), "Trivial3 is trivial");
+
+template<typename T> class Trivial4 { Trivial4() = default; };
+static_assert(__has_trivial_constructor(Trivial4<int>), "Trivial4 is trivial");
+
+template<typename T> class Trivial5 { Trivial5() = delete; };
+static_assert(__has_trivial_constructor(Trivial5<int>), "Trivial5 is trivial");
diff --git a/test/CXX/special/class.ctor/p6-0x.cpp b/test/CXX/special/class.ctor/p6-0x.cpp
new file mode 100644
index 0000000..8c8800f
--- /dev/null
+++ b/test/CXX/special/class.ctor/p6-0x.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// Implicitly-defined default constructors are constexpr if the implicit
+// definition would be.
+struct NonConstexpr1 { // expected-note {{here}}
+ int a;
+};
+struct NonConstexpr2 { // expected-note {{here}}
+ NonConstexpr1 nl;
+};
+struct NonConstexpr2a : NonConstexpr1 { };
+constexpr NonConstexpr1 nc1 = NonConstexpr1(); // ok, does not call constructor
+constexpr NonConstexpr2 nc2 = NonConstexpr2(); // ok, does not call constructor
+constexpr NonConstexpr2a nc2a = NonConstexpr2a(); // ok, does not call constructor
+constexpr int nc2_a = NonConstexpr2().nl.a; // ok
+constexpr int nc2a_a = NonConstexpr2a().a; // ok
+struct Helper {
+ friend constexpr NonConstexpr1::NonConstexpr1(); // expected-error {{follows non-constexpr declaration}}
+ friend constexpr NonConstexpr2::NonConstexpr2(); // expected-error {{follows non-constexpr declaration}}
+};
+
+struct Constexpr1 {};
+constexpr Constexpr1 c1 = Constexpr1(); // ok
+struct NonConstexpr3 : virtual Constexpr1 {}; // expected-note {{struct with virtual base}} expected-note {{declared here}}
+constexpr NonConstexpr3 nc3 = NonConstexpr3(); // expected-error {{non-literal type 'const NonConstexpr3'}}
+
+struct Constexpr2 {
+ int a = 0;
+};
+constexpr Constexpr2 c2 = Constexpr2(); // ok
+
+int n;
+struct Member {
+ Member() : a(n) {}
+ constexpr Member(int&a) : a(a) {}
+ int &a;
+};
+struct NonConstexpr4 { // expected-note {{here}}
+ Member m;
+};
+constexpr NonConstexpr4 nc4 = NonConstexpr4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor 'NonConstexpr4'}}
+struct Constexpr3 {
+ constexpr Constexpr3() : m(n) {}
+ Member m;
+};
+constexpr Constexpr3 c3 = Constexpr3(); // ok
+struct Constexpr4 {
+ Constexpr3 m;
+};
+constexpr Constexpr4 c4 = Constexpr4(); // ok
+
+
+// This rule breaks some legal C++98 programs!
+struct A {}; // expected-note {{here}}
+struct B {
+ friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}}
+};
diff --git a/test/CXX/special/class.dtor/p10-0x.cpp b/test/CXX/special/class.dtor/p10-0x.cpp
new file mode 100644
index 0000000..e10afb5
--- /dev/null
+++ b/test/CXX/special/class.dtor/p10-0x.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// PR10127/N3031
+struct A { ~A(); };
+struct B {};
+template<typename T>
+void b(const T *x, const A *y) {
+ x->~decltype(T())();
+ x->~decltype(*x)(); // expected-error{{the type of object expression ('const int') does not match the type being destroyed ('decltype(*x)' (aka 'const int &')) in pseudo-destructor expression}} \
+ expected-error{{no member named '~const struct A &' in 'A'}}
+ x->~decltype(int())(); // expected-error{{no member named '~int' in 'A'}}
+
+ y->~decltype(*y)(); // expected-error{{destructor type 'decltype(*y)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ y->~decltype(T())(); // expected-error{{destructor type 'decltype(T())' in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ y->~decltype(A())();
+}
+template void b(const int*, const A*); // expected-note{{in instantiation of function template specialization 'b<int>' requested here}}
+template void b(const A*,const A*); // expected-note{{in instantiation of function template specialization 'b<A>' requested here}}
+void a(const A *x, int i, int *pi) {
+ x->~decltype(A())();
+ x->~decltype(*x)(); // expected-error{{destructor type 'decltype(*x)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ x->~decltype()(); // expected-error{{expected expression}}
+ x->~decltype(B())(); // expected-error{{destructor type 'decltype(B())' (aka 'B') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ x->~decltype(x)(); // expected-error{{destructor type 'decltype(x)' (aka 'const A *') in object destruction expression does not match the type 'const A' of the object being destroyed}}
+ // this last one could be better, mentioning that the nested-name-specifier could be removed or a type name after the ~
+ x->::A::~decltype(*x)(); // expected-error{{expected a class name after '~' to name a destructor}}
+ y->~decltype(A())(); // expected-error{{use of undeclared identifier 'y'}}
+
+ typedef int *intp;
+ i->~decltype(int())(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}}
+ i.~decltype(int())();
+ i->~decltype(intp())(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}} \
+ expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+ i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+ pi->~decltype(int())();
+ pi.~decltype(int())(); // expected-error{{the type of object expression ('int *') does not match the type being destroyed ('decltype(int())' (aka 'int')) in pseudo-destructor expression}}
+ pi.~decltype(intp())();
+ pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
+}
diff --git a/test/CXX/special/class.dtor/p5-0x.cpp b/test/CXX/special/class.dtor/p5-0x.cpp
new file mode 100644
index 0000000..dbfa004
--- /dev/null
+++ b/test/CXX/special/class.dtor/p5-0x.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+struct NonTrivDtor {
+ ~NonTrivDtor();
+};
+struct DeletedDtor {
+ ~DeletedDtor() = delete; // expected-note 5 {{deleted here}}
+};
+class InaccessibleDtor {
+ ~InaccessibleDtor() = default;
+};
+
+// A defaulted destructor for a class X is defined as deleted if:
+
+// -- X is a union-like class that has a variant member with a non-trivial
+// destructor.
+union A1 {
+ A1();
+ NonTrivDtor n; // expected-note {{destructor of union 'A1' is implicitly deleted because field 'n' has a non-trivial destructor}}
+};
+A1 a1; // expected-error {{deleted function}}
+struct A2 {
+ A2();
+ union {
+ NonTrivDtor n; // expected-note {{because field 'n' has a non-trivial destructor}}
+ };
+};
+A2 a2; // expected-error {{deleted function}}
+union A3 {
+ A3();
+ NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+};
+A3 a3; // expected-error {{deleted function}}
+struct A4 {
+ A4();
+ union {
+ NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+ };
+};
+A4 a4; // expected-error {{deleted function}}
+
+// -- any of the non-static data members has class type M (or array thereof) and
+// M has a deleted or inaccessible destructor.
+struct B1 {
+ B1();
+ DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
+};
+B1 b1; // expected-error {{deleted function}}
+struct B2 {
+ B2();
+ InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
+};
+B2 b2; // expected-error {{deleted function}}
+struct B3 {
+ B3();
+ DeletedDtor a[4]; // expected-note {{because field 'a' has a deleted destructor}}
+};
+B3 b3; // expected-error {{deleted function}}
+struct B4 {
+ B4();
+ InaccessibleDtor a[4]; // expected-note {{because field 'a' has an inaccessible destructor}}
+};
+B4 b4; // expected-error {{deleted function}}
+union B5 {
+ B5();
+ // FIXME: Describe the anonymous union member better than ''.
+ union { // expected-note {{because field '' has a deleted destructor}}
+ DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}}
+ };
+};
+B5 b5; // expected-error {{deleted function}}
+union B6 {
+ B6();
+ union { // expected-note {{because field '' has a deleted destructor}}
+ InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}}
+ };
+};
+B6 b6; // expected-error {{deleted function}}
+
+// -- any direct or virtual base class has a deleted or inaccessible destructor.
+struct C1 : DeletedDtor { C1(); } c1; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
+struct C2 : InaccessibleDtor { C2(); } c2; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
+struct C3 : virtual DeletedDtor { C3(); } c3; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}}
+struct C4 : virtual InaccessibleDtor { C4(); } c4; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}}
+
+// -- for a virtual destructor, lookup of the non-array deallocation function
+// results in an ambiguity or a function that is deleted or inaccessible.
+class D1 {
+ void operator delete(void*);
+public:
+ virtual ~D1() = default;
+} d1; // ok
+struct D2 : D1 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ // implicitly-virtual destructor
+} d2; // expected-error {{deleted function}}
+struct D3 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ virtual ~D3() = default; // expected-note {{explicitly defaulted function was implicitly deleted here}}
+ void operator delete(void*, double = 0.0);
+ void operator delete(void*, char = 0);
+} d3; // expected-error {{deleted function}}
+struct D4 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+ virtual ~D4() = default; // expected-note {{implicitly deleted here}}
+ void operator delete(void*) = delete;
+} d4; // expected-error {{deleted function}}
diff --git a/test/CXX/special/class.free/p1.cpp b/test/CXX/special/class.free/p1.cpp
index e4fe127..5c0240b 100644
--- a/test/CXX/special/class.free/p1.cpp
+++ b/test/CXX/special/class.free/p1.cpp
@@ -3,9 +3,9 @@
struct A {
void *operator new(size_t) {
- return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+ return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
}
void *operator new[](size_t) {
- return this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+ return this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
}
};
diff --git a/test/CXX/special/class.free/p6.cpp b/test/CXX/special/class.free/p6.cpp
index 555d4e9..fc4b2ae 100644
--- a/test/CXX/special/class.free/p6.cpp
+++ b/test/CXX/special/class.free/p6.cpp
@@ -3,9 +3,9 @@
struct A {
void operator delete(void*) {
- (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+ (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
}
void operator delete[](void*) {
- (void)this; // expected-error {{invalid use of 'this' outside of a nonstatic member function}}
+ (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
}
};
diff --git a/test/CXX/special/class.inhctor/elsewhere.cpp b/test/CXX/special/class.inhctor/elsewhere.cpp
index 60cfff8..66afa17 100644
--- a/test/CXX/special/class.inhctor/elsewhere.cpp
+++ b/test/CXX/special/class.inhctor/elsewhere.cpp
@@ -29,3 +29,29 @@ struct I1 : B1 {
struct D1 : I1 {
using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}}
};
+
+template<typename T> struct A {};
+
+template<typename T> struct B : A<bool>, A<char> {
+ using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}}
+};
+B<bool> bb;
+B<char> bc;
+B<double> bd; // expected-note {{here}}
+
+template<typename T> struct C : A<T> {
+ using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}}
+};
+C<bool> cb;
+C<char> cc; // expected-note {{here}}
+
+template<typename T> struct D : A<T> {};
+template<typename T> struct E : D<T> {
+ using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}}
+};
+E<bool> eb; // expected-note {{here}}
+
+template<typename T> struct F : D<bool> {
+ using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}}
+};
+F<bool> fb; // expected-note {{here}}
diff --git a/test/CXX/special/class.inhctor/p3.cpp b/test/CXX/special/class.inhctor/p3.cpp
index 989c17c..f71ab16 100644
--- a/test/CXX/special/class.inhctor/p3.cpp
+++ b/test/CXX/special/class.inhctor/p3.cpp
@@ -28,3 +28,21 @@ struct D3 : B3 { // expected-note 2 {{candidate constructor}}
using B3::B3; // expected-note {{candidate constructor (inherited)}}
};
D3 fd3() { return 1; } // expected-error {{no viable conversion}}
+
+template<typename T> struct T1 : B1 {
+ using B1::B1;
+};
+template<typename T> struct T2 : T1<T> {
+ using T1<int>::T1;
+};
+template<typename T> struct T3 : T1<int> {
+ using T1<T>::T1;
+};
+struct U {
+ friend T1<int>::T1(int);
+ friend T1<int>::T1(int, int);
+ friend T2<int>::T2(int);
+ friend T2<int>::T2(int, int);
+ friend T3<int>::T3(int);
+ friend T3<int>::T3(int, int);
+};
diff --git a/test/CXX/special/class.inhctor/p7.cpp b/test/CXX/special/class.inhctor/p7.cpp
index 736754d..9ae160f 100644
--- a/test/CXX/special/class.inhctor/p7.cpp
+++ b/test/CXX/special/class.inhctor/p7.cpp
@@ -2,7 +2,7 @@
// Straight from the standard
struct B1 {
- B1(int); // expected-note {{previous constructor}}
+ B1(int); // expected-note {{previous constructor}} expected-note {{conflicting constructor}}
};
struct B2 {
B2(int); // expected-note {{conflicting constructor}}
@@ -16,3 +16,14 @@ struct D2 : B1, B2 {
using B2::B2;
D2(int);
};
+
+template<typename T> struct B3 {
+ B3(T); // expected-note {{previous constructor}}
+};
+template<typename T> struct B4 : B3<T>, B1 {
+ B4();
+ using B3<T>::B3; // expected-note {{inherited here}}
+ using B1::B1; // expected-error {{already inherited}}
+};
+B4<char> b4c;
+B4<int> b4i; // expected-note {{here}}
diff --git a/test/CXX/special/class.init/class.base.init/p8-0x.cpp b/test/CXX/special/class.init/class.base.init/p8-0x.cpp
index 3e26e49..a108533 100644
--- a/test/CXX/special/class.init/class.base.init/p8-0x.cpp
+++ b/test/CXX/special/class.init/class.base.init/p8-0x.cpp
@@ -16,14 +16,17 @@ struct S {
} s(0);
union U {
- int a = 0;
+ int a = 0; // desired-note 5 {{previous initialization is here}}
char b = 'x';
// FIXME: these should all be rejected
- U() {} // desired-error {{at most one member of a union may be initialized}}
- U(int) : a(1) {} // desired-error {{at most one member of a union may be initialized}}
- U(char) : b('y') {} // desired-error {{at most one member of a union may be initialized}}
- U(double) : a(1), b('y') {} // desired-error {{at most one member of a union may be initialized}}
+ U() {} // desired-error {{initializing multiple members of union}}
+ U(int) : a(1) {} // desired-error {{initializing multiple members of union}}
+ U(char) : b('y') {} // desired-error {{initializing multiple members of union}}
+ // this expected note should be removed & the note should appear on the
+ // declaration of 'a' when this set of cases is handled correctly.
+ U(double) : a(1), // expected-note{{previous initialization is here}} desired-error {{initializing multiple members of union}}
+ b('y') {} // expected-error{{initializing multiple members of union}}
};
// PR10954: variant members do not acquire an implicit initializer.
diff --git a/test/CXX/special/class.temporary/p1.cpp b/test/CXX/special/class.temporary/p1.cpp
index 384b1f8..4f6ac0a 100644
--- a/test/CXX/special/class.temporary/p1.cpp
+++ b/test/CXX/special/class.temporary/p1.cpp
@@ -31,8 +31,7 @@ namespace test1 {
void test() {
A a;
- // FIXME: this error about variadics is bogus
- foo(a); // expected-error {{calling a private constructor of class 'test1::A'}} expected-error {{cannot pass object of non-trivial type 'test1::A' through variadic function}}
+ foo(a); // expected-error {{calling a private constructor of class 'test1::A'}}
}
}
diff --git a/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp b/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
new file mode 100644
index 0000000..81e8e25
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct T {
+ struct x {
+ int m;
+ };
+ x* operator->();
+ void operator++(int);
+ void operator<<(int);
+ T();
+ T(int);
+ T(int, int);
+};
+
+template<typename A, typename B, typename C, typename D, typename E>
+void func(A, B, C, D, E);
+
+void func(int a, int c) {
+ T(a)->m = 7;
+ T(a)++;
+ T(a,5)<<c;
+
+ T(*d)(int);
+ T(e)[5];
+ T(f) = {1, 2};
+ T(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'T (*)' with an rvalue of type 'double'}}
+ func(a, d, e, f, g);
+}
+
+void func2(int a, int c) {
+ decltype(T())(a)->m = 7;
+ decltype(T())(a)++;
+ decltype(T())(a,5)<<c;
+
+ decltype(T())(*d)(int);
+ decltype(T())(e)[5];
+ decltype(T())(f) = {1, 2};
+ decltype(T())(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'decltype(T()) (*)' (aka 'T *') with an rvalue of type 'double'}}
+ func(a, d, e, f, g);
+}
diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
index 18fd340..f52e3b6 100644
--- a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
+++ b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
@@ -30,7 +30,7 @@ struct Y {
void test_Y() {
goto end; // expected-error{{goto into protected scope}}
- Y y; // expected-note{{jump bypasses variable initialization}}
+ Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
end:
return;
}
@@ -41,7 +41,7 @@ struct Z {
void test_Z() {
goto end; // expected-error{{goto into protected scope}}
- Z z; // expected-note{{jump bypasses variable initialization}}
+ Z z; // expected-note{{jump bypasses initialization of non-POD variable}}
end:
return;
}
diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
index b157fd4..a45b35f 100644
--- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
+++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
@@ -128,7 +128,7 @@ void g() {
void *begin(); // expected-note {{selected 'begin' function with iterator type 'void *'}}
void *end();
};
- for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void type}}
+ for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void}}
}
struct NoNotEq {
diff --git a/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp b/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
new file mode 100644
index 0000000..000c870
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+struct Value {
+ constexpr Value(int n) : n(n) {}
+ constexpr operator short() { return n; }
+ int n;
+};
+enum E { E0, E1 };
+struct Alt {
+ constexpr operator E() { return E0; }
+};
+
+constexpr short s = Alt();
+
+void test(Value v) {
+ switch (v) {
+ case Alt():
+ case E1:
+ case Value(2):
+ case 3:
+ break;
+ }
+ switch (Alt a = Alt()) {
+ case Alt():
+ case E1:
+ case Value(2):
+ case 3:
+ break;
+ }
+ switch (E0) {
+ case Alt():
+ case E1:
+ // FIXME: These should produce a warning that 2 and 3 are not values of the
+ // enumeration.
+ case Value(2):
+ case 3:
+ break;
+ }
+}
diff --git a/test/CXX/temp/p3.cpp b/test/CXX/temp/p3.cpp
index 16ebb38..c146bc4 100644
--- a/test/CXX/temp/p3.cpp
+++ b/test/CXX/temp/p3.cpp
@@ -6,11 +6,9 @@ template<typename T> struct S {
template<typename T> int S<T>::a, S<T>::b; // expected-error {{can only declare a single entity}}
-// FIXME: the last two diagnostics here are terrible.
template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \
expected-error {{use of undeclared identifier 'T'}} \
- expected-error {{cannot name the global scope}} \
- expected-error {{no member named 'a' in the global namespace}}
+ expected-warning{{extra qualification}}
template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \
expected-error {{requires a type specifier}}
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
new file mode 100644
index 0000000..59ce8b6
--- /dev/null
+++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify
+
+namespace std {
+ typedef decltype(nullptr) nullptr_t;
+}
+
+template<int *ip> struct IP { // expected-note 4 {{template parameter is declared here}}
+ IP<ip> *ip2;
+};
+
+constexpr std::nullptr_t get_nullptr() { return nullptr; }
+
+constexpr std::nullptr_t np = nullptr;
+
+std::nullptr_t nonconst_np; // expected-note{{declared here}}
+
+IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+IP<nullptr> ip2;
+IP<get_nullptr()> ip3;
+IP<(int*)0> ip4;
+IP<np> ip5;
+IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \
+// expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}}
+IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}}
+
+struct X { };
+template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}}
+ PM<pm> *pm2;
+};
+
+PM<0> pm0; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
+PM<(0)> pm1; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
+PM<nullptr> pm2;
+PM<get_nullptr()> pm3;
+PM<(int X::*)0> pm4;
+PM<np> pm5;
+
+template<int (X::*pmf)(int)> struct PMF { // expected-note 2 {{template parameter is declared here}}
+ PMF<pmf> *pmf2;
+};
+
+PMF<0> pmf0; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
+PMF<(0)> pmf1; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
+PMF<nullptr> pmf2;
+PMF<get_nullptr()> pmf3;
+PMF<(int (X::*)(int))0> pmf4;
+PMF<np> pmf5;
+
+
+template<std::nullptr_t np> struct NP { // expected-note 2{{template parameter is declared here}}
+ NP<np> *np2;
+};
+
+NP<nullptr> np1;
+NP<np> np2;
+NP<get_nullptr()> np3;
+NP<0> np4; // expected-error{{null non-type template argument must be cast to template parameter type 'std::nullptr_t' (aka 'nullptr_t')}}
+constexpr int i = 7;
+NP<i> np5; // expected-error{{non-type template argument of type 'const int' cannot be converted to a value of type 'std::nullptr_t'}}
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
index 14dace8..c4db002 100644
--- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s
-// C++0x [temp.arg.nontype]p1:
+// C++11 [temp.arg.nontype]p1:
//
// A template-argument for a non-type, non-template template-parameter shall
// be one of:
@@ -19,27 +19,65 @@ namespace non_type_tmpl_param {
template <typename T, int (T::* M)(int)> X5<T, M>::X5() { }
}
-// -- the address of an object or function with external linkage, including
-// function templates and function template-ids but excluding non-static
-// class members, expressed as & id-expression where the & is optional if
-// the name refers to a function or array, or if the corresponding
-// template-parameter is a reference; or
+// -- a constant expression that designates the address of an object with
+// static storage duration and external or internal linkage or a function
+// with external or internal linkage, including function templates and
+// function template-ids, but excluting non-static class members, expressed
+// (ignoring parentheses) as & id-expression, except that the & may be
+// omitted if the name refers to a function or array and shall be omitted
+// if the corresopnding template-parameter is a reference; or
namespace addr_of_obj_or_func {
- template <int* p> struct X0 { };
+ template <int* p> struct X0 { }; // expected-note 4{{here}}
template <int (*fp)(int)> struct X1 { };
- // FIXME: Add reference template parameter tests.
+ template <int &p> struct X2 { }; // expected-note 4{{here}}
+ template <const int &p> struct X2k { }; // expected-note {{here}}
+ template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}}
int i = 42;
int iarr[10];
int f(int i);
+ const int ki = 9; // expected-note 5{{here}}
+ __thread int ti = 100; // expected-note 2{{here}}
+ static int f_internal(int); // expected-note 4{{here}}
template <typename T> T f_tmpl(T t);
+
void test() {
- X0<&i> x0a;
+ X0<i> x0a; // expected-error {{must have its address taken}}
+ X0<&i> x0a_addr;
X0<iarr> x0b;
- X1<&f> x1a;
- X1<f> x1b;
- X1<f_tmpl> x1c;
- X1<f_tmpl<int> > x1d;
+ X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}}
+ X0<ki> x0c; // expected-error {{must have its address taken}} expected-warning {{internal linkage is a C++11 extension}}
+ X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} expected-warning {{internal linkage is a C++11 extension}}
+ X0<&ti> x0d_addr; // expected-error {{refers to thread-local object}}
+ X1<f> x1a;
+ X1<&f> x1a_addr;
+ X1<f_tmpl> x1b;
+ X1<&f_tmpl> x1b_addr;
+ X1<f_tmpl<int> > x1c;
+ X1<&f_tmpl<int> > x1c_addr;
+ X1<f_internal> x1d; // expected-warning {{internal linkage is a C++11 extension}}
+ X1<&f_internal> x1d_addr; // expected-warning {{internal linkage is a C++11 extension}}
+ X2<i> x2a;
+ X2<&i> x2a_addr; // expected-error {{address taken}}
+ X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}}
+ X2<&iarr> x2b_addr; // expected-error {{address taken}}
+ X2<ki> x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}}
+ X2k<ki> x2kc; // expected-warning {{internal linkage is a C++11 extension}}
+ X2k<&ki> x2kc_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+ X2<ti> x2d_addr; // expected-error {{refers to thread-local object}}
+ X3<f> x3a;
+ X3<&f> x3a_addr; // expected-error {{address taken}}
+ X3<f_tmpl> x3b;
+ X3<&f_tmpl> x3b_addr; // expected-error {{address taken}}
+ X3<f_tmpl<int> > x3c;
+ X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}}
+ X3<f_internal> x3d; // expected-warning {{internal linkage is a C++11 extension}}
+ X3<&f_internal> x3d_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+
+ int n; // expected-note {{here}}
+ X0<&n> x0_no_linkage; // expected-error {{non-type template argument refers to object 'n' that does not have linkage}}
+ struct Local { static int f() {} }; // expected-note {{here}}
+ X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}}
}
}
diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
new file mode 100644
index 0000000..f8cc009
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
@@ -0,0 +1,152 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+template<typename T> struct A {
+ enum E : T; // expected-note {{here}}
+ E v;
+ E f() { return A::e1; } // expected-error {{no member named 'e1' in 'A<T>'}}
+ E g() { return E::e1; }
+ E h();
+};
+
+A<int> a;
+A<int>::E a0 = A<int>().v;
+int n = A<int>::E::e1; // expected-error {{implicit instantiation of undefined member}}
+
+template<typename T> enum A<T>::E : T { e1, e2 };
+
+// FIXME: Now that A<T>::E is defined, we are supposed to inject its enumerators
+// into the already-instantiated class A<T>. This seems like a really bad idea,
+// though, so we don't implement that, but what we do implement is inconsistent.
+//
+// Either do as the standard says, or only include enumerators lexically defined
+// within the class in its scope.
+A<int>::E a1 = A<int>::e1; // expected-error {{no member named 'e1' in 'A<int>'}}
+
+A<char>::E a2 = A<char>::e2;
+
+template<typename T> typename A<T>::E A<T>::h() { return e2; }
+A<short>::E a3 = A<short>().h();
+
+
+template<typename T> struct B {
+ enum class E;
+ E v;
+ E f() { return E::e1; }
+ E g();
+};
+
+B<int> b;
+B<int>::E b0 = B<int>().v;
+
+template<typename T> enum class B<T>::E { e1, e2 };
+B<int>::E b1 = B<int>::E::e1;
+
+B<char>::E b2 = B<char>::E::e2;
+
+template<typename T> typename B<T>::E B<T>::g() { return e2; }
+B<short>::E b3 = B<short>().g();
+
+
+// Enumeration members of class templates can be explicitly specialized. For
+// unscoped enumerations, specializations must be defined before the primary
+// template is, since otherwise the primary template will be implicitly
+// instantiated when we parse the nested name specifier.
+template<> enum A<long long>::E : long long { e3, e4 }; // expected-error {{explicit specialization of 'E' after instantiation}} expected-note {{first required here}}
+
+template<> enum class B<long long>::E { e3, e4 };
+B<long long>::E b4 = B<long long>::E::e4;
+
+B<long>::E b5;
+template<> enum class B<long>::E { e5 };
+void fb5() { b5 = decltype(b5)::e5; }
+B<long>::E b6 = B<long>::E::e5;
+
+
+template<typename T> struct C {
+ enum class E : T;
+};
+
+template<> enum class C<long long>::E : long long { e3, e4 };
+C<long long>::E c0 = C<long long>::E::e3;
+
+C<long>::E c1;
+template<> enum class C<long>::E : long { e5 };
+void fc1() { c1 = decltype(c1)::e5; }
+C<long>::E c2 = C<long>::E::e5;
+
+template<> enum class C<int>::E : int { e6 };
+template<typename T> enum class C<T>::E : T { e0 };
+C<int>::E c3 = C<int>::E::e6;
+C<int>::E c4 = C<int>::E::e0; // expected-error {{no member named 'e0' in 'C<int>::E'}}
+
+
+// Enumeration members can't be partially-specialized.
+template<typename T> enum class B<T*>::E { e5, e6 }; // expected-error {{nested name specifier for a declaration cannot depend on a template parameter}}
+
+
+// Explicit specializations can be forward-declared.
+template<typename T>
+struct D {
+ enum class E { e1 };
+};
+template<> enum class D<int>::E;
+D<int>::E d1 = D<int>::E::e1; // expected-error {{incomplete type 'D<int>::E'}}
+template<> enum class D<int>::E { e2 };
+D<int>::E d2 = D<int>::E::e2;
+D<char>::E d3 = D<char>::E::e1; // expected-note {{first required here}}
+D<char>::E d4 = D<char>::E::e2; // expected-error {{no member named 'e2'}}
+template<> enum class D<char>::E { e3 }; // expected-error {{explicit specialization of 'E' after instantiation}}
+
+template<> enum class D<short>::E;
+struct F {
+ // Per C++11 [class.friend]p3, these friend declarations have no effect.
+ // Only classes and functions can be friends.
+ template<typename T> friend enum D<T>::E;
+ template<> friend enum D<short>::E;
+
+ template<> friend enum D<double>::E { e3 }; // expected-error {{cannot define a type in a friend declaration}}
+
+private:
+ static const int n = 1; // expected-note {{private here}}
+};
+template<> enum class D<short>::E {
+ e = F::n // expected-error {{private member}}
+};
+
+class Access {
+ friend class X;
+
+ template<typename T>
+ class Priv {
+ friend class X;
+
+ enum class E : T;
+ };
+
+ class S {
+ typedef int N; // expected-note {{here}}
+ static const int k = 3; // expected-note {{here}}
+
+ friend class Priv<char>;
+ };
+
+ static const int k = 5;
+};
+
+template<> enum class Access::Priv<Access::S::N>::E
+ : Access::S::N { // expected-error {{private member}}
+ a = Access::k, // ok
+ b = Access::S::k // expected-error {{private member}}
+};
+
+template<typename T> enum class Access::Priv<T>::E : T {
+ c = Access::k,
+ d = Access::S::k
+};
+
+class X {
+ Access::Priv<int>::E a = Access::Priv<int>::E::a;
+ Access::Priv<char>::E c = Access::Priv<char>::E::d;
+ // FIXME: We should see an access error for this enumerator.
+ Access::Priv<short>::E b = Access::Priv<short>::E::d;
+};
diff --git a/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp b/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
new file mode 100644
index 0000000..fb72754
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T, typename U> struct pair { };
+template<typename ...Types> struct tuple { };
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
+
+namespace ExpandIntoFixed {
+ template<typename T,
+ typename U,
+ typename V = pair<T, U>,
+ typename W = V*>
+ class X0 { };
+
+ template<typename ...Ts>
+ class X1 {
+ public:
+ typedef X0<Ts...> type;
+ };
+
+ static_assert(is_same<X1<int, int>::type,
+ X0<int, int, pair<int, int>, pair<int, int>*>>::value,
+ "fails with two default arguments");
+
+ static_assert(is_same<X1<int, int, float>::type,
+ X0<int, int, float, float*>>::value,
+ "fails with one default argument");
+
+ static_assert(is_same<X1<int, int, float, double>::type,
+ X0<int, int, float, double>>::value,
+ "fails with no default arguments");
+}
+
+namespace ExpandIntoFixedShifted {
+ template<typename T,
+ typename U,
+ typename V = pair<T, U>,
+ typename W = V*>
+ class X0 { };
+
+ template<typename ...Ts>
+ class X1 {
+ public:
+ typedef X0<char, Ts...> type;
+ };
+
+ static_assert(is_same<X1<int>::type,
+ X0<char, int, pair<char, int>, pair<char, int>*>>::value,
+ "fails with two default arguments");
+
+ static_assert(is_same<X1<int, float>::type,
+ X0<char, int, float, float*>>::value,
+ "fails with one default argument");
+
+ static_assert(is_same<X1<int, float, double>::type,
+ X0<char, int, float, double>>::value,
+ "fails with no default arguments");
+}
+
+namespace Deduction {
+ template <typename X, typename Y = double> struct Foo {};
+ template <typename ...Args> tuple<Args...> &foo(Foo<Args...>);
+
+ void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) {
+ tuple<int, float> &t1 = foo(foo_if);
+ tuple<int, double> &t2 = foo(foo_i);
+ }
+}
+
+namespace PR9021a {
+ template<typename, typename>
+ struct A { };
+
+ template<typename ...T>
+ struct B {
+ A<T...> a1;
+ };
+
+ void test() {
+ B<int, int> c;
+ }
+}
+
+namespace PR9021b {
+ template<class, class>
+ struct t2
+ {
+
+ };
+
+ template<template<class...> class M>
+ struct m
+ {
+ template<class... B>
+ using inner = M<B...>;
+ };
+
+ m<t2> sta2;
+}
+
+namespace PartialSpecialization {
+ template<typename T, typename U, typename V = U>
+ struct X0; // expected-note{{template is declared here}}
+
+ template<typename ...Ts>
+ struct X0<Ts...> {
+ };
+
+ X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}}
+ X0<int, float> x0if;
+ X0<int, float, double> x0ifd;
+}
+
+namespace FixedAliasTemplate {
+ template<typename,typename,typename> struct S {};
+ template<typename T, typename U> using U = S<T, int, U>;
+ template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...);
+ S<int, int, double> &s1 = f({}, 0, 0.0);
+}
diff --git a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp b/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
index 05e4921..d8294a1 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/p4.cpp
@@ -20,6 +20,52 @@ struct is_same<T, T> {
// FIXME: Several more bullets to go
+// In a function parameter pack, the pattern is the parameter-declaration
+// without the ellipsis.
+namespace PR11850 {
+ template<typename ...T> struct S {
+ int f(T...a, int b) { return b; }
+ };
+ S<> s;
+ S<int*, char, const double&> t;
+ int k = s.f(0);
+ int l = t.f(&k, 'x', 5.9, 4);
+
+ template<typename ...As> struct A {
+ template<typename ...Bs> struct B {
+ template<typename ...Cs> struct C {
+ C(As..., Bs..., int &k, Cs...);
+ };
+ };
+ };
+ A<>::B<>::C<> c000(k);
+ A<int>::B<>::C<int> c101(1, k, 3);
+ A<>::B<int>::C<int> c011(1, k, 3);
+ A<int>::B<int>::C<> c110(1, 2, k);
+ A<int, int>::B<int, int>::C<int, int> c222(1, 2, 3, 4, k, 5, 6);
+ A<int, int, int>::B<>::C<> c300(1, 2, 3, k);
+
+ int &f();
+ char &f(void*);
+ template<typename ...A> struct U {
+ template<typename ...B> struct V {
+ auto g(A...a, B...b) -> decltype(f(a...));
+ };
+ };
+ U<>::V<int*> v0;
+ U<int*>::V<> v1;
+ int &v0f = v0.g(0);
+ char &v1f = v1.g(0);
+}
+namespace PR12096 {
+ void Foo(int) {}
+ void Foo(int, int) = delete;
+ template<typename ...Args> struct Var {
+ Var(const Args &...args, int *) { Foo(args...); }
+ };
+ Var<int> var(1, 0);
+}
+
// In an initializer-list (8.5); the pattern is an initializer-clause.
// Note: this also covers expression-lists, since expression-list is
// just defined as initializer-list.
@@ -37,7 +83,8 @@ template void initializer_list_expansion<1, 2, 3, 4, 5, 6>(); // expected-note{{
namespace PR8977 {
struct A { };
template<typename T, typename... Args> void f(Args... args) {
- T t(args...);
+ // An empty expression-list performs value initialization.
+ constexpr T t(args...);
};
template void f<A>();
@@ -90,6 +137,16 @@ struct X {
X() : member()... { } // expected-error{{pack expansion for initialization of member 'member'}}
};
+// There was a bug in the delayed parsing code for the
+// following case.
+template<typename ...T>
+struct DelayedParseTest : T...
+{
+ int a;
+ DelayedParseTest(T... i) : T{i}..., a{10} {}
+};
+
+
// In a template-argument-list (14.3); the pattern is a template-argument.
template<typename ...Types>
struct tuple_of_refs {
diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
index 0f409e7..6955219 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -160,9 +160,9 @@ struct TestUnexpandedTTP {
};
// Test for unexpanded parameter packs in declarations.
-// FIXME: Attributes?
template<typename T, typename... Types>
-struct TestUnexpandedDecls : T{
+// FIXME: this should test that the diagnostic reads "type contains..."
+struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}}
void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
void member_function () throw(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
@@ -185,10 +185,16 @@ struct TestUnexpandedDecls : T{
void test_initializers() {
T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
- T direct_init(0, static_cast<Types>(0)); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
+ T direct_init(0, static_cast<Types>(0)); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
}
+ T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ TestUnexpandedDecls() :
+ Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+ Types(static_cast<Types>(0))...,
+ in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
+
void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
index 9236efc..83b5f23 100644
--- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp
@@ -10,3 +10,11 @@ namespace PR8598 {
void g() { (f)(&X::f, 0); }
}
+
+namespace PR12132 {
+ template<typename S> void fun(const int* const S::* member) {}
+ struct A { int* x; };
+ void foo() {
+ fun(&A::x);
+ }
+}
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp
index 16b5cd2..8b18189 100644
--- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp
@@ -50,7 +50,7 @@ namespace test0 {
namespace test1 {
template<class T> void invoke(void (*f)(T)) { f(T()); } // expected-note 6 {{couldn't infer template argument}} \
- // expected-note {{failed template argument deduction}}
+ // expected-note {{candidate template ignored: couldn't infer template argument 'T'}}
template<class T> void temp(T);
void test0() {
@@ -111,3 +111,18 @@ namespace rdar8360106 {
f2(&g, 1);
}
}
+
+namespace PR11713 {
+ template<typename T>
+ int f(int, int, int);
+
+ template<typename T>
+ float f(float, float);
+
+ template<typename R, typename B1, typename B2, typename A1, typename A2>
+ R& g(R (*)(B1, B2), A1, A2);
+
+ void h() {
+ float &fr = g(f<int>, 1, 2);
+ }
+}
diff --git a/test/CXX/temp/temp.param/p11-0x.cpp b/test/CXX/temp/temp.param/p11-0x.cpp
index 1971aa1..d2276a3 100644
--- a/test/CXX/temp/temp.param/p11-0x.cpp
+++ b/test/CXX/temp/temp.param/p11-0x.cpp
@@ -24,8 +24,9 @@ template<template<class> class M = vector, template<class> class... Metas>
// If a template-parameter of a primary class template or alias template is a
// template parameter pack, it shall be the last template-parameter.
template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}}
- int After>
+ int After, int After2>
struct X0t;
+X0t<int> pr9789();
template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}}
int After>
using A0t = int;
diff --git a/test/CXX/temp/temp.param/p5.cpp b/test/CXX/temp/temp.param/p5.cpp
new file mode 100644
index 0000000..3cbb3b7
--- /dev/null
+++ b/test/CXX/temp/temp.param/p5.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s -std=c++11
+
+template<const int I> struct S {
+ decltype(I) n;
+ int &&r = I;
+};
+S<5> s;
+
+template<typename T, T v> struct U {
+ decltype(v) n;
+ int &&r = v;
+};
+U<const int, 6> u;
diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
new file mode 100644
index 0000000..0aba402
--- /dev/null
+++ b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+template<int n> struct S;
+
+template<int n> struct T {
+ T() {
+ // An identifier is value-dependent if it is:
+ // - a name declared with a dependent type
+ S<n> s;
+ S<s> check1; // ok, s is value-dependent
+ // - the name of a non-type template parameter
+ typename S<n>::T check2; // ok, n is value-dependent
+ // - a constant with literal type and is initialized with an expression
+ // that is value-dependent.
+ const int k = n;
+ typename S<k>::T check3a; // ok, u is value-dependent
+
+ constexpr const int *p = &k;
+ typename S<*p>::T check3b; // ok, p is value-dependent
+
+ // (missing from the standard)
+ // - a reference and is initialized with an expression that is
+ // value-dependent.
+ const int &i = k;
+ typename S<i>::T check4; // ok, i is value-dependent
+ }
+};
diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
new file mode 100644
index 0000000..68a41c7
--- /dev/null
+++ b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++98 -verify %s
+
+template<int n> struct S;
+
+template<int n> struct T {
+ T() {
+ // An identifier is value-dependent if it is:
+ // - a name declared with a dependent type
+ S<n> s;
+ S<s> check1; // ok, s is value-dependent
+ // - the name of a non-type template parameter
+ typename S<n>::T check2; // ok, n is value-dependent
+ // - a constant with literal type and is initialized with an expression
+ // that is value-dependent.
+ const int k = n;
+ typename S<k>::T check3; // ok, u is value-dependent
+
+ const int &i = k;
+ typename S<i>::T check4; // expected-error {{not an integral constant expression}} expected-error {{qualified name}}
+ }
+};
diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp
index ba99dd7..0e69a26 100644
--- a/test/CXX/temp/temp.spec/p5.cpp
+++ b/test/CXX/temp/temp.spec/p5.cpp
@@ -14,9 +14,10 @@ struct X0 {
};
template<typename T>
-T X0<T>::value = 3.14;
+T X0<T>::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}}
-template struct X0<int>; // expected-note{{previous explicit instantiation}}
+template struct X0<int>; // expected-note{{previous explicit instantiation}} \
+ expected-note{{requested here}}
template struct X0<int>; // expected-error{{duplicate explicit instantiation}}
template void X0<float>::f(float); // expected-note{{previous explicit instantiation}}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
index f04c544..aecbfb5 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
@@ -207,3 +207,128 @@ namespace template_class_spec_perClassDecl_nested
static void foo();
};
}
+
+
+namespace spec_vs_expl_inst {
+
+ // Test all permutations of Specialization,
+ // explicit instantiation Declaration, and explicit instantiation defInition.
+
+ namespace SDI { // PR11558
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ }
+
+ namespace SID {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ }
+
+ namespace ISD {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::ISD::BasicStringPiece<int>'}}
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ }
+
+ namespace IDS {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::IDS::BasicStringPiece<int>'}} // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ template <> class BasicStringPiece<int> { };
+ }
+
+ namespace DIS {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DIS::BasicStringPiece<int>'}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { };
+ }
+
+ namespace DSI {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DSI::BasicStringPiece<int>'}}
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>;
+ }
+
+ // The same again, with a defined template class.
+
+ namespace SDI_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ }
+
+ namespace SID_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ }
+
+ namespace ISD_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::ISD_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ extern template class BasicStringPiece<int>;
+ }
+
+ namespace IDS_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::IDS_WithDefinedTemplate::BasicStringPiece<int>'}}
+ }
+
+ namespace DIS_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DIS_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ }
+
+ namespace DSI_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}}
+ template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DSI_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}}
+ template class BasicStringPiece<int>;
+ }
+
+ // And some more random tests.
+
+ namespace SII_WithDefinedTemplate {
+ template <typename STRING_TYPE> class BasicStringPiece {};
+ template <> class BasicStringPiece<int> { };
+ template class BasicStringPiece<int>; // expected-note {{previous explicit instantiation is here}}
+ template class BasicStringPiece<int>; // expected-error {{duplicate explicit instantiation of 'BasicStringPiece<int>'}}
+ }
+
+ namespace SIS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SIS::BasicStringPiece<int>'}}
+ }
+
+ namespace SDS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SDS::BasicStringPiece<int>'}}
+ }
+
+ namespace SDIS {
+ template <typename STRING_TYPE> class BasicStringPiece;
+ template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}}
+ extern template class BasicStringPiece<int>;
+ template class BasicStringPiece<int>;
+ template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'spec_vs_expl_inst::SDIS::BasicStringPiece<int>'}}
+ }
+
+}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
index acfbb46..b0a19fb 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp
@@ -33,7 +33,7 @@ namespace N0 {
template<> void N0::f0(int) { } // okay
namespace N1 {
- template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+ template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
}
template<> void N0::f0(double) { }
@@ -129,7 +129,7 @@ template<> int N0::X0<int>::member;
template<> float N0::X0<float>::member = 3.14f;
namespace N1 {
- template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+ template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
}
// -- member class of a class template
@@ -227,7 +227,7 @@ void N0::X0<void*>::ft1(void *, float) { }
namespace N1 {
template<> template<>
- void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+ void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
index 2295235..c972bf7 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
@@ -33,10 +33,11 @@ namespace N0 {
template<> void N0::f0(int) { } // okay
namespace N1 {
- template<> void N0::f0(long) { } // expected-error{{not in a namespace enclosing}}
+ template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}}
}
-template<> void N0::f0(double) { } // expected-warning{{originally be declared}}
+template<> void N0::f0(double); // expected-warning{{C++11 extension}}
+template<> void N0::f0(double) { }
struct X1 {
template<typename T> void f(T);
@@ -75,7 +76,7 @@ void N0::X0<T>::ft1(T t, U u) {
template<typename T> T N0::X0<T>::member;
-template<> struct N0::X0<void> { }; // expected-warning{{originally}}
+template<> struct N0::X0<void> { }; // expected-warning{{C++11 extension}}
N0::X0<void> test_X0;
namespace N1 {
@@ -124,12 +125,12 @@ NonDefaultConstructible &get_static_member() {
return N0::X0<NonDefaultConstructible>::member;
}
-template<> int N0::X0<int>::member; // expected-warning{{originally}}
+template<> int N0::X0<int>::member; // expected-warning{{C++11 extension}}
template<> float N0::X0<float>::member = 3.14f;
namespace N1 {
- template<> double N0::X0<double>::member = 3.14; // expected-error{{not in a namespace enclosing}}
+ template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}}
}
// -- member class of a class template
@@ -152,7 +153,7 @@ namespace N0 {
}
template<>
-struct N0::X0<long>::Inner { }; // expected-warning{{originally}}
+struct N0::X0<long>::Inner { }; // expected-warning{{C++11 extension}}
template<>
struct N0::X0<float>::Inner { };
@@ -227,7 +228,7 @@ void N0::X0<void*>::ft1(void *, float) { } // expected-warning{{function templat
namespace N1 {
template<> template<>
- void N0::X0<void*>::ft1(void *, long) { } // expected-error{{enclosing}}
+ void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}}
}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
index 97e78fd..80f0598 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -13,3 +13,12 @@ struct Y {
};
template constexpr int Y<int>::f(); // expected-error{{explicit instantiation cannot be 'constexpr'}}
+
+template<typename T>
+struct Z {
+ enum E : T { e1, e2 };
+ T t; // expected-note {{refers here}}
+};
+
+template enum Z<int>::E; // expected-error {{enumerations cannot be explicitly instantiated}}
+template int Z<int>::t; // expected-error {{explicit instantiation of 't' does not refer to}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
index 822f881..1dfcf0ce 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
// Example from the standard
template<class T> class Array { void mf() { } };
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
index 48c42c3..38ae768 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
// A declaration of a function template shall be in scope at the point of the
// explicit instantiation of the function template.
@@ -72,3 +72,10 @@ namespace PR7979 {
template <typename T> int S<T>::i;
template <typename T> void S<T>::S2::h() {}
}
+
+namespace PR11599 {
+ template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}}
+
+ extern template class BasicStringPiece<int>; // expected-error{{explicit instantiation of undefined template 'PR11599::BasicStringPiece<int>}}
+ template class BasicStringPiece<int>;
+}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
index d304374..09c428e 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
@@ -43,6 +43,6 @@ namespace test0 {
// inappropriately instantiating this template.
void *ptr = x;
}
- extern template class foo<char>;
+ extern template class foo<char>; // expected-warning {{extern templates are a C++11 extension}}
template class foo<char>;
}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p5.cpp b/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
index 7522d02..8422c51 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
namespace N {
template<class T> class Y { // expected-note{{explicit instantiation refers here}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p8.cpp b/test/CXX/temp/temp.spec/temp.explicit/p8.cpp
index 0c5aec3..550078a 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p8.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p8.cpp
@@ -1,16 +1,15 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
template<typename T>
struct X0 {
struct MemberClass;
-
+
T* f0(T* ptr);
-
+
static T* static_member;
};
-template class X0<int>; // okay
-template class X0<int(int)>; // okay; nothing gets instantiated.
+template class X0<int(int)>; // ok; nothing gets instantiated.
template<typename T>
struct X0<T>::MemberClass {
@@ -25,3 +24,17 @@ T* X0<T>::f0(T* ptr) {
template<typename T>
T* X0<T>::static_member = 0;
+template class X0<int>; // ok
+
+
+template<typename T>
+struct X1 {
+ enum class E {
+ e = T::error // expected-error 2{{no members}}
+ };
+};
+template struct X1<int>; // expected-note {{here}}
+
+extern template struct X1<char>; // ok
+
+template struct X1<char>; // expected-note {{here}}
diff --git a/test/CXX/temp/temp.spec/temp.inst/p1.cpp b/test/CXX/temp/temp.spec/temp.inst/p1.cpp
new file mode 100644
index 0000000..8684fc4
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.inst/p1.cpp
@@ -0,0 +1,104 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// The implicit specialization of a class template specialuzation causes the
+// implicit instantiation of the declarations, but not the definitions or
+// default arguments, of:
+
+// FIXME: Many omitted cases
+
+// - scoped member enumerations
+namespace ScopedEnum {
+ template<typename T> struct ScopedEnum1 {
+ enum class E {
+ e = T::error // expected-error {{'double' cannot be used prior to '::'}}
+ };
+ };
+ ScopedEnum1<int> se1; // ok
+
+ template<typename T> struct ScopedEnum2 {
+ enum class E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
+ e = 0
+ };
+ };
+ ScopedEnum2<void*> se2; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum3 {
+ enum class E : T {
+ e = 4
+ };
+ int arr[(int)E::e];
+ };
+ UnscopedEnum3<int> ue3; // ok
+
+ ScopedEnum1<double>::E e1; // ok
+ ScopedEnum1<double>::E e2 = decltype(e2)::e; // expected-note {{in instantiation of enumeration 'ScopedEnum::ScopedEnum1<double>::E' requested here}}
+
+ // The behavior for enums defined within function templates is not clearly
+ // specified by the standard. We follow the rules for enums defined within
+ // class templates.
+ template<typename T>
+ int f() {
+ enum class E {
+ e = T::error
+ };
+ return (int)E();
+ }
+ int test1 = f<int>();
+
+ template<typename T>
+ int g() {
+ enum class E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return E::e; // expected-note {{here}}
+ }
+ int test2 = g<int>(); // expected-note {{here}}
+}
+
+// And it cases the implicit instantiations of the definitions of:
+
+// - unscoped member enumerations
+namespace UnscopedEnum {
+ template<typename T> struct UnscopedEnum1 {
+ enum E {
+ e = T::error // expected-error {{'int' cannot be used prior to '::'}}
+ };
+ };
+ UnscopedEnum1<int> ue1; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum2 {
+ enum E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}}
+ e = 0
+ };
+ };
+ UnscopedEnum2<void*> ue2; // expected-note {{here}}
+
+ template<typename T> struct UnscopedEnum3 {
+ enum E : T {
+ e = 4
+ };
+ int arr[E::e];
+ };
+ UnscopedEnum3<int> ue3; // ok
+
+ template<typename T>
+ int f() {
+ enum E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return (int)E();
+ }
+ int test1 = f<int>(); // expected-note {{here}}
+
+ template<typename T>
+ int g() {
+ enum E {
+ e = T::error // expected-error {{has no members}}
+ };
+ return E::e;
+ }
+ int test2 = g<int>(); // expected-note {{here}}
+}
+
+// FIXME:
+//- - member anonymous unions
diff --git a/test/CodeCompletion/enum-switch-case.c b/test/CodeCompletion/enum-switch-case.c
index d5df371..b83bd7f 100644
--- a/test/CodeCompletion/enum-switch-case.c
+++ b/test/CodeCompletion/enum-switch-case.c
@@ -40,6 +40,6 @@ void test(enum Color color) {
// CHECK-CC2-NEXT: COMPLETION: Indigo : [#enum Color#]Indigo
// CHECK-CC2-NEXT: COMPLETION: Orange : [#enum Color#]Orange
// CHECK-CC2-NEXT: COMPLETION: Red : [#enum Color#]Red
- // CHECK-CC2-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>)
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
// CHECK-CC2-NEXT: COMPLETION: Violet : [#enum Color#]Violet
// CHECK-CC2-NEXT: COMPLETION: Yellow : [#enum Color#]Yellow
diff --git a/test/CodeCompletion/ordinary-name.cpp b/test/CodeCompletion/ordinary-name.cpp
index 4dbf84d..d0b09b5 100644
--- a/test/CodeCompletion/ordinary-name.cpp
+++ b/test/CodeCompletion/ordinary-name.cpp
@@ -10,14 +10,14 @@ void foo() {
// CHECK-CC1-NEXT: COMPLETION: class
// CHECK-CC1-NEXT: COMPLETION: const
// CHECK-CC1-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
- // CHECK-CC1: COMPLETION: Pattern : delete <#expression#>
- // CHECK-CC1-NEXT: COMPLETION: Pattern : delete [] <#expression#>
+ // CHECK-CC1: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : do{<#statements#>
// CHECK-CC1: COMPLETION: double
// CHECK-CC1-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
// CHECK-CC1-NEXT: COMPLETION: enum
// CHECK-CC1-NEXT: COMPLETION: extern
- // CHECK-CC1-NEXT: COMPLETION: false
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]false
// CHECK-CC1-NEXT: COMPLETION: float
// CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
// CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
@@ -32,18 +32,18 @@ void foo() {
// CHECK-CC1-NEXT: COMPLETION: Pattern : return
// CHECK-CC1-NEXT: COMPLETION: short
// CHECK-CC1-NEXT: COMPLETION: signed
- // CHECK-CC1-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>)
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
// CHECK-CC1-NEXT: COMPLETION: static
// CHECK-CC1-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
// CHECK-CC1-NEXT: COMPLETION: struct
// CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){
// CHECK-CC1: COMPLETION: t : t
- // CHECK-CC1-NEXT: COMPLETION: Pattern : throw <#expression#>
- // CHECK-CC1-NEXT: COMPLETION: true
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#bool#]true
// CHECK-CC1-NEXT: COMPLETION: Pattern : try{<#statements#>
// CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
- // CHECK-CC1-NEXT: COMPLETION: Pattern : typeid(<#expression-or-type#>)
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
// CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
@@ -138,12 +138,12 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: class
// CHECK-CC4-NEXT: COMPLETION: const
// CHECK-CC4-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
- // CHECK-CC4-NEXT: COMPLETION: Pattern : delete <#expression#>
- // CHECK-CC4-NEXT: COMPLETION: Pattern : delete [] <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
// CHECK-CC4-NEXT: COMPLETION: double
// CHECK-CC4-NEXT: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
// CHECK-CC4-NEXT: COMPLETION: enum
- // CHECK-CC4-NEXT: COMPLETION: false
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]false
// CHECK-CC4-NEXT: COMPLETION: float
// CHECK-CC4-NEXT: COMPLETION: foo : [#void#]foo()
// CHECK-CC4-NEXT: COMPLETION: int
@@ -154,14 +154,14 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
// CHECK-CC4-NEXT: COMPLETION: short
// CHECK-CC4-NEXT: COMPLETION: signed
- // CHECK-CC4-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
// CHECK-CC4-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
// CHECK-CC4-NEXT: COMPLETION: struct
// CHECK-CC4-NEXT: COMPLETION: t : t
- // CHECK-CC4-NEXT: COMPLETION: Pattern : throw <#expression#>
- // CHECK-CC4-NEXT: COMPLETION: true
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#void#]throw <#expression#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
// CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
- // CHECK-CC4-NEXT: COMPLETION: Pattern : typeid(<#expression-or-type#>)
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
// CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
@@ -180,14 +180,14 @@ void foo() {
// CHECK-NO-RTTI-NEXT: COMPLETION: class
// CHECK-NO-RTTI-NEXT: COMPLETION: const
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : const_cast<<#type#>>(<#expression#>)
- // CHECK-NO-RTTI: COMPLETION: Pattern : delete <#expression#>
- // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : delete [] <#expression#>
+ // CHECK-NO-RTTI: COMPLETION: Pattern : [#void#]delete <#expression#>
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#void#]delete [] <#expression#>
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : do{<#statements#>
// CHECK-NO-RTTI: COMPLETION: double
// CHECK-NO-RTTI-NOT: dynamic_cast
// CHECK-NO-RTTI: COMPLETION: enum
// CHECK-NO-RTTI-NEXT: COMPLETION: extern
- // CHECK-NO-RTTI-NEXT: COMPLETION: false
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#bool#]false
// CHECK-NO-RTTI-NEXT: COMPLETION: float
// CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo()
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
@@ -202,14 +202,14 @@ void foo() {
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : return
// CHECK-NO-RTTI-NEXT: COMPLETION: short
// CHECK-NO-RTTI-NEXT: COMPLETION: signed
- // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>)
+ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
// CHECK-NO-RTTI-NEXT: COMPLETION: static
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : static_cast<<#type#>>(<#expression#>)
// CHECK-NO-RTTI-NEXT: COMPLETION: struct
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : switch(<#condition#>){
// CHECK-NO-RTTI: COMPLETION: t : t
// CHECK-NO-RTTI-NOT: throw
- // CHECK-NO-RTTI: COMPLETION: true
+ // CHECK-NO-RTTI: COMPLETION: Pattern : [#bool#]true
// CHECK-NO-RTTI-NOT: try
// CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
diff --git a/test/CodeGen/2005-05-06-CountBuiltins.c b/test/CodeGen/2005-05-06-CountBuiltins.c
deleted file mode 100644
index 4c12100..0000000
--- a/test/CodeGen/2005-05-06-CountBuiltins.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang_cc1 %s -emit-llvm -o %t
-// RUN: not grep call*__builtin %t
-
-int G, H, I;
-void foo(int P) {
- G = __builtin_clz(P);
- H = __builtin_ctz(P);
- I = __builtin_popcount(P);
-}
-
-long long g, h, i;
-void fooll(float P) {
- g = __builtin_clzll(P);
- g = __builtin_clzll(P);
- h = __builtin_ctzll(P);
- i = __builtin_popcountll(P);
-}
diff --git a/test/CodeGen/2007-09-28-PackedUnionMember.c b/test/CodeGen/2007-09-28-PackedUnionMember.c
index 943480e..f018306 100644
--- a/test/CodeGen/2007-09-28-PackedUnionMember.c
+++ b/test/CodeGen/2007-09-28-PackedUnionMember.c
@@ -27,6 +27,7 @@ extern long bork(FuncPtr handler, const struct E *list);
static long hndlr()
{
struct H cmd = { 4, 412 };
+ struct H cmd2 = { 4, 412, 0 };
return 0;
}
void foo(void *inWindow) {
@@ -35,4 +36,3 @@ void foo(void *inWindow) {
};
bork(hndlr, events);
}
-
diff --git a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c
index 21b4705..8787bd4 100644
--- a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c
+++ b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c
@@ -1,6 +1,5 @@
-// RUN: %clang_cc1 %s -m32 -emit-llvm -o - | grep {i32 32} | count 3
+// RUN: %clang_cc1 %s -triple powerpc-pc-linux -emit-llvm -o - | grep {i32 32} | count 3
// XFAIL: *
-// XTARGET: powerpc
// Every printf has 'i32 0' for the GEP of the string; no point counting those.
typedef unsigned int Foo __attribute__((aligned(32)));
typedef union{Foo:0;}a;
diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c
index 42f020e..8828eef 100644
--- a/test/CodeGen/2009-10-20-GlobalDebug.c
+++ b/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -1,9 +1,10 @@
// REQUIRES: x86-registered-target
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s
+// RUN: %clang -target i386-apple-darwin10 -flto -S -g %s -o - | FileCheck %s
int global;
-// CHECK: ascii "localstatic" ## DW_AT_name
-// CHECK: asciz "global" ## External Name
int main() {
static int localstatic;
return 0;
}
+
+// CHECK: !14 = metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ]
+// CHECK: !15 = metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ]
diff --git a/test/CodeGen/3dnow-builtins.c b/test/CodeGen/3dnow-builtins.c
new file mode 100644
index 0000000..294fbc0
--- /dev/null
+++ b/test/CodeGen/3dnow-builtins.c
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-unknown-unknown -target-feature +3dnow -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+__m64 test_m_pavgusb(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pavgusb
+ // CHECK: @llvm.x86.3dnow.pavgusb
+ return _m_pavgusb(m1, m2);
+}
+
+__m64 test_m_pf2id(__m64 m) {
+ // CHECK: define i64 @test_m_pf2id
+ // CHECK: @llvm.x86.3dnow.pf2id
+ return _m_pf2id(m);
+}
+
+__m64 test_m_pfacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfacc
+ // CHECK: @llvm.x86.3dnow.pfacc
+ return _m_pfacc(m1, m2);
+}
+
+__m64 test_m_pfadd(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfadd
+ // CHECK: @llvm.x86.3dnow.pfadd
+ return _m_pfadd(m1, m2);
+}
+
+__m64 test_m_pfcmpeq(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpeq
+ // CHECK: @llvm.x86.3dnow.pfcmpeq
+ return _m_pfcmpeq(m1, m2);
+}
+
+__m64 test_m_pfcmpge(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpge
+ // CHECK: @llvm.x86.3dnow.pfcmpge
+ return _m_pfcmpge(m1, m2);
+}
+
+__m64 test_m_pfcmpgt(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfcmpgt
+ // CHECK: @llvm.x86.3dnow.pfcmpgt
+ return _m_pfcmpgt(m1, m2);
+}
+
+__m64 test_m_pfmax(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmax
+ // CHECK: @llvm.x86.3dnow.pfmax
+ return _m_pfmax(m1, m2);
+}
+
+__m64 test_m_pfmin(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmin
+ // CHECK: @llvm.x86.3dnow.pfmin
+ return _m_pfmin(m1, m2);
+}
+
+__m64 test_m_pfmul(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfmul
+ // CHECK: @llvm.x86.3dnow.pfmul
+ return _m_pfmul(m1, m2);
+}
+
+__m64 test_m_pfrcp(__m64 m) {
+ // CHECK: define i64 @test_m_pfrcp
+ // CHECK: @llvm.x86.3dnow.pfrcp
+ return _m_pfrcp(m);
+}
+
+__m64 test_m_pfrcpit1(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrcpit1
+ // CHECK: @llvm.x86.3dnow.pfrcpit1
+ return _m_pfrcpit1(m1, m2);
+}
+
+__m64 test_m_pfrcpit2(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrcpit2
+ // CHECK: @llvm.x86.3dnow.pfrcpit2
+ return _m_pfrcpit2(m1, m2);
+}
+
+__m64 test_m_pfrsqrt(__m64 m) {
+ // CHECK: define i64 @test_m_pfrsqrt
+ // CHECK: @llvm.x86.3dnow.pfrsqrt
+ return _m_pfrsqrt(m);
+}
+
+__m64 test_m_pfrsqrtit1(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfrsqrtit1
+ // CHECK: @llvm.x86.3dnow.pfrsqit1
+ return _m_pfrsqrtit1(m1, m2);
+}
+
+__m64 test_m_pfsub(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfsub
+ // CHECK: @llvm.x86.3dnow.pfsub
+ return _m_pfsub(m1, m2);
+}
+
+__m64 test_m_pfsubr(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfsubr
+ // CHECK: @llvm.x86.3dnow.pfsubr
+ return _m_pfsubr(m1, m2);
+}
+
+__m64 test_m_pi2fd(__m64 m) {
+ // CHECK: define i64 @test_m_pi2fd
+ // CHECK: @llvm.x86.3dnow.pi2fd
+ return _m_pi2fd(m);
+}
+
+__m64 test_m_pmulhrw(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pmulhrw
+ // CHECK: @llvm.x86.3dnow.pmulhrw
+ return _m_pmulhrw(m1, m2);
+}
+
+__m64 test_m_pf2iw(__m64 m) {
+ // CHECK: define i64 @test_m_pf2iw
+ // CHECK: @llvm.x86.3dnowa.pf2iw
+ return _m_pf2iw(m);
+}
+
+__m64 test_m_pfnacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfnacc
+ // CHECK: @llvm.x86.3dnowa.pfnacc
+ return _m_pfnacc(m1, m2);
+}
+
+__m64 test_m_pfpnacc(__m64 m1, __m64 m2) {
+ // CHECK: define i64 @test_m_pfpnacc
+ // CHECK: @llvm.x86.3dnowa.pfpnacc
+ return _m_pfpnacc(m1, m2);
+}
+
+__m64 test_m_pi2fw(__m64 m) {
+ // CHECK: define i64 @test_m_pi2fw
+ // CHECK: @llvm.x86.3dnowa.pi2fw
+ return _m_pi2fw(m);
+}
+
+__m64 test_m_pswapdsf(__m64 m) {
+ // CHECK: define i64 @test_m_pswapdsf
+ // CHECK: @llvm.x86.3dnowa.pswapd
+ return _m_pswapdsf(m);
+}
+
+__m64 test_m_pswapdsi(__m64 m) {
+ // CHECK: define i64 @test_m_pswapdsi
+ // CHECK: @llvm.x86.3dnowa.pswapd
+ return _m_pswapdsi(m);
+}
diff --git a/test/CodeGen/Inputs/stdio.h b/test/CodeGen/Inputs/stdio.h
new file mode 100644
index 0000000..cfe3595
--- /dev/null
+++ b/test/CodeGen/Inputs/stdio.h
@@ -0,0 +1,9 @@
+struct FILE;
+extern int vfprintf(struct FILE *s, const char *format, __builtin_va_list arg);
+extern int vprintf(const char *format, __builtin_va_list arg);
+
+extern __inline __attribute__((gnu_inline,always_inline)) int
+vprintf(const char *x, __builtin_va_list y)
+{
+ return vfprintf (0, 0, 0);
+}
diff --git a/test/CodeGen/address-safety-attr.cpp b/test/CodeGen/address-safety-attr.cpp
new file mode 100644
index 0000000..9d0fb95
--- /dev/null
+++ b/test/CodeGen/address-safety-attr.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s
+
+// The address_safety attribute should be attached to functions
+// when AddressSanitizer is enabled, unless no_address_safety_analysis attribute
+// is present.
+
+// CHECK-NOT: NoAddressSafety1{{.*}} address_safety
+// ASAN-NOT: NoAddressSafety1{{.*}} address_safety
+__attribute__((no_address_safety_analysis))
+int NoAddressSafety1(int *a) { return *a; }
+
+// CHECK-NOT: NoAddressSafety2{{.*}} address_safety
+// ASAN-NOT: NoAddressSafety2{{.*}} address_safety
+__attribute__((no_address_safety_analysis))
+int NoAddressSafety2(int *a);
+int NoAddressSafety2(int *a) { return *a; }
+
+// CHECK-NOT: AddressSafetyOk{{.*}} address_safety
+// ASAN: AddressSafetyOk{{.*}} address_safety
+int AddressSafetyOk(int *a) { return *a; }
+
+// CHECK-NOT: TemplateNoAddressSafety{{.*}} address_safety
+// ASAN-NOT: TemplateNoAddressSafety{{.*}} address_safety
+template<int i>
+__attribute__((no_address_safety_analysis))
+int TemplateNoAddressSafety() { return i; }
+
+// CHECK-NOT: TemplateAddressSafetyOk{{.*}} address_safety
+// ASAN: TemplateAddressSafetyOk{{.*}} address_safety
+template<int i>
+int TemplateAddressSafetyOk() { return i; }
+
+int force_instance = TemplateAddressSafetyOk<42>()
+ + TemplateNoAddressSafety<42>();
diff --git a/test/CodeGen/align-param.c b/test/CodeGen/align-param.c
new file mode 100644
index 0000000..8907f66
--- /dev/null
+++ b/test/CodeGen/align-param.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 < %s | FileCheck %s
+
+// The preferred alignment for a long long on x86-32 is 8; make sure the
+// alloca for x uses that alignment.
+int test (long long x) {
+ return (int)x;
+}
+// CHECK: define i32 @test
+// CHECK: alloca i64, align 8
+
+
+// Make sure we honor the aligned attribute.
+struct X { int x,y,z,a; };
+int test2(struct X x __attribute((aligned(16)))) {
+ return x.z;
+}
+// CHECK: define i32 @test2
+// CHECK: alloca %struct.X, align 16
diff --git a/test/CodeGen/alignment.c b/test/CodeGen/alignment.c
new file mode 100644
index 0000000..8882c91
--- /dev/null
+++ b/test/CodeGen/alignment.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+__attribute((aligned(16))) float a[128];
+union {int a[4]; __attribute((aligned(16))) float b[4];} b;
+
+// CHECK: @a = {{.*}}zeroinitializer, align 16
+// CHECK: @b = {{.*}}zeroinitializer, align 16
+
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef int myint __attribute__((aligned(1)));
+
+void test1(myint *p) {
+ *p = 0;
+}
+// CHECK: @test1(
+// CHECK: store i32 0, i32* {{.*}}, align 1
+// CHECK: ret void
+
+int test1a(myint *p) {
+ return *p;
+}
+// CHECK: @test1a(
+// CHECK: load i32* {{.*}}, align 1
+// CHECK: ret i32
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef float __attribute__((vector_size(16), aligned(4))) packedfloat4;
+
+void test2(packedfloat4 *p) {
+ *p = (packedfloat4) { 3.2f, 2.3f, 0.1f, 0.0f };
+}
+// CHECK: @test2(
+// CHECK: store <4 x float> {{.*}}, align 4
+// CHECK: ret void
+
+
+// PR5279 - Reduced alignment on typedef.
+typedef float __attribute__((ext_vector_type(3), aligned(4))) packedfloat3;
+void test3(packedfloat3 *p) {
+ *p = (packedfloat3) { 3.2f, 2.3f, 0.1f };
+}
+// CHECK: @test3(
+// CHECK: store <3 x float> {{.*}}, align 4
+// CHECK: ret void
+
+
+
+typedef float __attribute__((vector_size(16), aligned(64))) float4align64;
+
+// rdar://10639962 - Typedef alignment lost in p[]-style dereferencing
+void test4(float4align64 *p) {
+ p[0] = (float4align64){ 3.2f, 2.3f, 0.1f, 0.0f };
+}
+// CHECK: @test4(
+// CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}, align 64
+
diff --git a/test/CodeGen/altivec.c b/test/CodeGen/altivec.c
index c3b1f42..2982303 100644
--- a/test/CodeGen/altivec.c
+++ b/test/CodeGen/altivec.c
@@ -5,6 +5,15 @@
vector int test0 = (vector int)(1); // CHECK: @test0 = global <4 x i32> <i32 1, i32 1, i32 1, i32 1>
vector float test1 = (vector float)(1.0); // CHECK: @test1 = global <4 x float> <float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}, float 1.000000e+{{0+}}>
+// CHECK: @v1 = global <16 x i8> <i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 0, i8 2, i8 0, i8 0, i8 0, i8 3, i8 0, i8 0, i8 0, i8 4>
+vector char v1 = (vector char)((vector int)(1, 2, 3, 4));
+// CHECK: @v2 = global <16 x i8> <i8 63, i8 -128, i8 0, i8 0, i8 64, i8 0, i8 0, i8 0, i8 64, i8 64, i8 0, i8 0, i8 64, i8 -128, i8 0, i8 0>
+vector char v2 = (vector char)((vector float)(1.0f, 2.0f, 3.0f, 4.0f));
+// CHECK: @v3 = global <16 x i8> <i8 0, i8 0, i8 0, i8 97, i8 0, i8 0, i8 0, i8 98, i8 0, i8 0, i8 0, i8 99, i8 0, i8 0, i8 0, i8 100>
+vector char v3 = (vector char)((vector int)('a', 'b', 'c', 'd'));
+// CHECK: @v4 = global <4 x i32> <i32 16909060, i32 0, i32 0, i32 0>
+vector int v4 = (vector char){1, 2, 3, 4};
+
void test2()
{
vector int vi;
diff --git a/test/CodeGen/arm-aapcs-vfp.c b/test/CodeGen/arm-aapcs-vfp.c
index 20b8a74..017c145 100644
--- a/test/CodeGen/arm-aapcs-vfp.c
+++ b/test/CodeGen/arm-aapcs-vfp.c
@@ -12,10 +12,10 @@ struct homogeneous_struct {
float f3;
float f4;
};
-// CHECK: define arm_aapcs_vfpcc void @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
-extern void struct_callee(struct homogeneous_struct);
-void test_struct(struct homogeneous_struct arg) {
- struct_callee(arg);
+// CHECK: define arm_aapcs_vfpcc %struct.homogeneous_struct @test_struct(float %{{.*}}, float %{{.*}}, float %{{.*}}, float %{{.*}})
+extern struct homogeneous_struct struct_callee(struct homogeneous_struct);
+struct homogeneous_struct test_struct(struct homogeneous_struct arg) {
+ return struct_callee(arg);
}
struct nested_array {
diff --git a/test/CodeGen/arm-aapcs-zerolength-bitfield.c b/test/CodeGen/arm-aapcs-zerolength-bitfield.c
new file mode 100644
index 0000000..9fece19
--- /dev/null
+++ b/test/CodeGen/arm-aapcs-zerolength-bitfield.c
@@ -0,0 +1,236 @@
+// RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify
+
+#include <stddef.h>
+
+struct t1
+{
+ int foo : 1;
+ char : 0;
+ char bar;
+};
+static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 4) ? 0 : -1];
+
+struct t2
+{
+ int foo : 1;
+ short : 0;
+ char bar;
+};
+static int arr2_offset[(offsetof(struct t2, bar) == 2) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 4) ? 0 : -1];
+
+struct t3
+{
+ int foo : 1;
+ int : 0;
+ char bar;
+};
+static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
+static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
+
+struct t4
+{
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
+static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
+
+struct t5
+{
+ int foo : 1;
+ long long : 0;
+ char bar;
+};
+static int arr5_offset[(offsetof(struct t5, bar) == 8) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 16) ? 0 : -1];
+
+struct t6
+{
+ int foo : 1;
+ char : 0;
+ char bar : 1;
+ char bar2;
+};
+static int arr6_offset[(offsetof(struct t6, bar2) == 2) ? 0 : -1];
+static int arr6_sizeof[(sizeof(struct t6) == 4) ? 0 : -1];
+
+struct t7
+{
+ int foo : 1;
+ short : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr7_offset[(offsetof(struct t7, bar2) == 3) ? 0 : -1];
+static int arr7_sizeof[(sizeof(struct t7) == 4) ? 0 : -1];
+
+struct t8
+{
+ int foo : 1;
+ int : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1];
+static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1];
+
+struct t9
+{
+ int foo : 1;
+ long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1];
+static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1];
+
+struct t10
+{
+ int foo : 1;
+ long long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr10_offset[(offsetof(struct t10, bar2) == 9) ? 0 : -1];
+static int arr10_sizeof[(sizeof(struct t10) == 16) ? 0 : -1];
+
+struct t11
+{
+ int foo : 1;
+ long long : 0;
+ char : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr11_offset[(offsetof(struct t11, bar2) == 9) ? 0 : -1];
+static int arr11_sizeof[(sizeof(struct t11) == 16) ? 0 : -1];
+
+struct t12
+{
+ int foo : 1;
+ char : 0;
+ long long : 0;
+ char : 0;
+ char bar;
+};
+static int arr12_offset[(offsetof(struct t12, bar) == 8) ? 0 : -1];
+static int arr12_sizeof[(sizeof(struct t12) == 16) ? 0 : -1];
+
+struct t13
+{
+ char foo;
+ long : 0;
+ char bar;
+};
+static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1];
+static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1];
+
+struct t14
+{
+ char foo1;
+ int : 0;
+ char foo2 : 1;
+ short foo3 : 16;
+ char : 0;
+ short foo4 : 16;
+ char bar1;
+ int : 0;
+ char bar2;
+};
+static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1];
+static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1];
+static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1];
+
+struct t15
+{
+ char foo;
+ char : 0;
+ int : 0;
+ char bar;
+ long : 0;
+ char : 0;
+};
+static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1];
+static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1];
+
+struct t16
+{
+ long : 0;
+ char bar;
+};
+static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1];
+static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1];
+
+struct t17
+{
+ char foo;
+ long : 0;
+ long : 0;
+ char : 0;
+ char bar;
+};
+static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1];
+static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1];
+
+struct t18
+{
+ long : 0;
+ long : 0;
+ char : 0;
+};
+static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1];
+
+struct t19
+{
+ char foo1;
+ long foo2 : 1;
+ char : 0;
+ long foo3 : 32;
+ char bar;
+};
+static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1];
+static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1];
+
+struct t20
+{
+ short : 0;
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1];
+static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1];
+
+struct t21
+{
+ short : 0;
+ int foo1 : 1;
+ char : 0;
+ int foo2 : 16;
+ long : 0;
+ char bar1;
+ int bar2;
+ long bar3;
+ char foo3 : 8;
+ char : 0;
+ long : 0;
+ int foo4 : 32;
+ short foo5: 1;
+ long bar4;
+ short foo6: 16;
+ short foo7: 16;
+ short foo8: 16;
+};
+static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 4) ? 0 : -1];
+static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 8) ? 0 : -1];
+static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 12) ? 0 : -1];
+static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 28) ? 0 : -1];
+static int arr21_sizeof[(sizeof(struct t21) == 40) ? 0 : -1];
+
+int main() {
+ return 0;
+}
+
diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c
index 3ae3b8e..4686d4a 100644
--- a/test/CodeGen/arm-arguments.c
+++ b/test/CodeGen/arm-arguments.c
@@ -153,3 +153,15 @@ struct s29 f29() {}
// AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret
struct s30 { _Complex int f0; };
struct s30 f30() {}
+
+// PR11905
+struct s31 { char x; };
+void f31(struct s31 s) { }
+// AAPCS: @f31([1 x i32] %s.coerce)
+// AAPCS: %s = alloca %struct.s31, align 4
+// AAPCS: alloca [1 x i32]
+// AAPCS: store [1 x i32] %s.coerce, [1 x i32]*
+// APCS-GNU: @f31([1 x i32] %s.coerce)
+// APCS-GNU: %s = alloca %struct.s31, align 4
+// APCS-GNU: alloca [1 x i32]
+// APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]*
diff --git a/test/CodeGen/arm-vector-align.c b/test/CodeGen/arm-vector-align.c
index c1119cb..b481a0c 100644
--- a/test/CodeGen/arm-vector-align.c
+++ b/test/CodeGen/arm-vector-align.c
@@ -12,8 +12,18 @@
// intrinsics.
typedef float AlignedAddr __attribute__ ((aligned (16)));
void t1(AlignedAddr *addr1, AlignedAddr *addr2) {
+// CHECK: @t1
// CHECK: call <4 x float> @llvm.arm.neon.vld1.v4f32(i8* %{{.*}}, i32 16)
float32x4_t a = vld1q_f32(addr1);
// CHECK: call void @llvm.arm.neon.vst1.v4f32(i8* %{{.*}}, <4 x float> %{{.*}}, i32 16)
vst1q_f32(addr2, a);
}
+
+// Radar 10538555: Make sure unaligned load/stores do not gain alignment.
+void t2(char *addr) {
+// CHECK: @t2
+// CHECK: load i32* %{{.*}}, align 1
+ int32x2_t vec = vld1_dup_s32(addr);
+// CHECK: store i32 %{{.*}}, i32* {{.*}}, align 1
+ vst1_lane_s32(addr, vec, 1);
+}
diff --git a/test/CodeGen/asm-inout.c b/test/CodeGen/asm-inout.c
index ce524fe..c7d1aec 100644
--- a/test/CodeGen/asm-inout.c
+++ b/test/CodeGen/asm-inout.c
@@ -19,21 +19,30 @@ void test2() {
}
// PR7338
+// CHECK: @test3
void test3(int *vout, int vin)
{
// CHECK: call void asm "opr $0,$1", "=*r|m|r,r|m|r,~{edi},~{dirflag},~{fpsr},~{flags}"
-asm(
- "opr %[vout],%[vin]"
- : [vout] "=r,=m,=r" (*vout)
- : [vin] "r,m,r" (vin)
- : "edi"
- );
+ asm ("opr %[vout],%[vin]"
+ : [vout] "=r,=m,=r" (*vout)
+ : [vin] "r,m,r" (vin)
+ : "edi");
}
// PR8959 - This should implicitly truncate the immediate to a byte.
+// CHECK: @test4
int test4(volatile int *addr) {
unsigned char oldval;
+ // CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
__asm__ ("frob %0" : "=r"(oldval) : "0"(0xff));
return (int)oldval;
-// CHECK: call i8 asm "frob $0", "=r,0{{.*}}"(i8 -1)
+}
+
+// <rdar://problem/10919182> - This should have both inputs be of type x86_mmx.
+// CHECK: @test5
+typedef long long __m64 __attribute__((__vector_size__(8)));
+__m64 test5(__m64 __A, __m64 __B) {
+ // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
+ asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
+ return __A;
}
diff --git a/test/CodeGen/asm-label.c b/test/CodeGen/asm-label.c
index 7be2ad3..c06f11f 100644
--- a/test/CodeGen/asm-label.c
+++ b/test/CodeGen/asm-label.c
@@ -2,11 +2,18 @@
// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm %s -o - | FileCheck %s --check-prefix=DARWIN
char *strerror(int) asm("alias");
+int x __asm("foo");
-void test(void)
-{
- strerror(-1);
+int *test(void) {
+ static int y __asm("bar");
+ strerror(-1);
+ return &y;
}
+// LINUX: @bar = internal global i32 0
+// LINUX: @foo = common global i32 0
// LINUX: declare i8* @alias(i32)
+
+// DARWIN: @"\01bar" = internal global i32 0
+// DARWIN: @"\01foo" = common global i32 0
// DARWIN: declare i8* @"\01alias"(i32)
diff --git a/test/CodeGen/asm-variable.c b/test/CodeGen/asm-variable.c
index a37132d..dc087bd 100644
--- a/test/CodeGen/asm-variable.c
+++ b/test/CodeGen/asm-variable.c
@@ -57,3 +57,9 @@ unsigned long long foo2(unsigned long long addr, double a0,
}
// CHECK: call i64 asm "call *$1", "={rax},r,{xmm0},{xmm1},{xmm2},{xmm3},{xmm4},{xmm5},{xmm6},{xmm7},~{dirflag},~{fpsr},~{flags}
+
+int randomvar asm("randomvar");
+void foo3() {
+ asm("vartest %0" : : "r"(randomvar));
+}
+// CHECK: call void asm sideeffect "vartest $0", "r,~{dirflag},~{fpsr},~{flags}"
diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c
index 019eb9c..84f26e1 100644
--- a/test/CodeGen/asm.c
+++ b/test/CodeGen/asm.c
@@ -63,7 +63,6 @@ void t10(int r) {
// CHECK:PR3908 $1 $3 $2 $0
}
-
// PR3373
unsigned t11(signed char input) {
unsigned output;
@@ -101,9 +100,6 @@ unsigned long t15(int x, struct large *P) {
return x;
}
-
-
-
// bitfield destination of an asm.
struct S {
int a : 4;
@@ -113,7 +109,6 @@ void t14(struct S *P) {
__asm__("abc %0" : "=r"(P->a) );
}
-
// PR4938
int t16() {
int a,b;
@@ -145,7 +140,6 @@ int t18(unsigned data) {
// CHECK-NEXT: extractvalue
}
-
// PR6780
int t19(unsigned data) {
int a, b;
@@ -156,7 +150,6 @@ int t19(unsigned data) {
// CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z"
}
-
// PR6845 - Mismatching source/dest fp types.
double t20(double x) {
register long double result;
@@ -209,9 +202,8 @@ void *t24(char c) {
return addr;
}
-
// PR10299 - fpsr, fpcr
-void test(void)
+void t25(void)
{
__asm__ __volatile__( \
"finit" \
@@ -222,3 +214,9 @@ void test(void)
"fpsr","fpcr" \
);
}
+
+// rdar://10510405 - AVX registers
+typedef long long __m256i __attribute__((__vector_size__(32)));
+void t26 (__m256i *p) {
+ __asm__ volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0");
+}
diff --git a/test/CodeGen/atomic-ops.c b/test/CodeGen/atomic-ops.c
index e2904cf..1a9ed36 100644
--- a/test/CodeGen/atomic-ops.c
+++ b/test/CodeGen/atomic-ops.c
@@ -1,8 +1,13 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
-// Basic IRGen tests for __atomic_*
+// Also test serialization of atomic operations here, to avoid duplicating the
+// test.
+// RUN: %clang_cc1 %s -emit-pch -o %t -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -include-pch %t -triple=i686-apple-darwin9 -emit-llvm -o - | FileCheck %s
+#ifndef ALREADY_INCLUDED
+#define ALREADY_INCLUDED
-// FIXME: Need to implement __atomic_is_lock_free
+// Basic IRGen tests for __c11_atomic_* and GNU __atomic_*
typedef enum memory_order {
memory_order_relaxed, memory_order_consume, memory_order_acquire,
@@ -12,66 +17,298 @@ typedef enum memory_order {
int fi1(_Atomic(int) *i) {
// CHECK: @fi1
// CHECK: load atomic i32* {{.*}} seq_cst
- return __atomic_load(i, memory_order_seq_cst);
+ return __c11_atomic_load(i, memory_order_seq_cst);
+}
+
+int fi1a(int *i) {
+ // CHECK: @fi1a
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ int v;
+ __atomic_load(i, &v, memory_order_seq_cst);
+ return v;
+}
+
+int fi1b(int *i) {
+ // CHECK: @fi1b
+ // CHECK: load atomic i32* {{.*}} seq_cst
+ return __atomic_load_n(i, memory_order_seq_cst);
}
void fi2(_Atomic(int) *i) {
// CHECK: @fi2
// CHECK: store atomic i32 {{.*}} seq_cst
- __atomic_store(i, 1, memory_order_seq_cst);
+ __c11_atomic_store(i, 1, memory_order_seq_cst);
+}
+
+void fi2a(int *i) {
+ // CHECK: @fi2a
+ // CHECK: store atomic i32 {{.*}} seq_cst
+ int v = 1;
+ __atomic_store(i, &v, memory_order_seq_cst);
}
-void fi3(_Atomic(int) *i) {
+void fi2b(int *i) {
+ // CHECK: @fi2b
+ // CHECK: store atomic i32 {{.*}} seq_cst
+ __atomic_store_n(i, 1, memory_order_seq_cst);
+}
+
+int fi3(_Atomic(int) *i) {
// CHECK: @fi3
// CHECK: atomicrmw and
- __atomic_fetch_and(i, 1, memory_order_seq_cst);
+ // CHECK-NOT: and
+ return __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+}
+
+int fi3a(int *i) {
+ // CHECK: @fi3a
+ // CHECK: atomicrmw xor
+ // CHECK-NOT: xor
+ return __atomic_fetch_xor(i, 1, memory_order_seq_cst);
+}
+
+int fi3b(int *i) {
+ // CHECK: @fi3b
+ // CHECK: atomicrmw add
+ // CHECK: add
+ return __atomic_add_fetch(i, 1, memory_order_seq_cst);
+}
+
+int fi3c(int *i) {
+ // CHECK: @fi3c
+ // CHECK: atomicrmw nand
+ // CHECK-NOT: and
+ return __atomic_fetch_nand(i, 1, memory_order_seq_cst);
}
-void fi4(_Atomic(int) *i) {
+int fi3d(int *i) {
+ // CHECK: @fi3d
+ // CHECK: atomicrmw nand
+ // CHECK: and
+ // CHECK: xor
+ return __atomic_nand_fetch(i, 1, memory_order_seq_cst);
+}
+
+_Bool fi4(_Atomic(int) *i) {
+ // CHECK: @fi4
+ // CHECK: cmpxchg i32*
+ int cmp = 0;
+ return __c11_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire);
+}
+
+_Bool fi4a(int *i) {
+ // CHECK: @fi4
+ // CHECK: cmpxchg i32*
+ int cmp = 0;
+ int desired = 1;
+ return __atomic_compare_exchange(i, &cmp, &desired, 0, memory_order_acquire, memory_order_acquire);
+}
+
+_Bool fi4b(int *i) {
// CHECK: @fi4
// CHECK: cmpxchg i32*
int cmp = 0;
- __atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire);
+ return __atomic_compare_exchange_n(i, &cmp, 1, 1, memory_order_acquire, memory_order_acquire);
}
float ff1(_Atomic(float) *d) {
// CHECK: @ff1
// CHECK: load atomic i32* {{.*}} monotonic
- return __atomic_load(d, memory_order_relaxed);
+ return __c11_atomic_load(d, memory_order_relaxed);
}
void ff2(_Atomic(float) *d) {
// CHECK: @ff2
// CHECK: store atomic i32 {{.*}} release
- __atomic_store(d, 1, memory_order_release);
+ __c11_atomic_store(d, 1, memory_order_release);
}
float ff3(_Atomic(float) *d) {
- return __atomic_exchange(d, 2, memory_order_seq_cst);
+ return __c11_atomic_exchange(d, 2, memory_order_seq_cst);
}
int* fp1(_Atomic(int*) *p) {
// CHECK: @fp1
// CHECK: load atomic i32* {{.*}} seq_cst
- return __atomic_load(p, memory_order_seq_cst);
+ return __c11_atomic_load(p, memory_order_seq_cst);
}
int* fp2(_Atomic(int*) *p) {
// CHECK: @fp2
// CHECK: store i32 4
// CHECK: atomicrmw add {{.*}} monotonic
- return __atomic_fetch_add(p, 1, memory_order_relaxed);
+ return __c11_atomic_fetch_add(p, 1, memory_order_relaxed);
+}
+
+int *fp2a(int **p) {
+ // CHECK: @fp2a
+ // CHECK: store i32 4
+ // CHECK: atomicrmw sub {{.*}} monotonic
+ // Note, the GNU builtins do not multiply by sizeof(T)!
+ return __atomic_fetch_sub(p, 4, memory_order_relaxed);
}
_Complex float fc(_Atomic(_Complex float) *c) {
// CHECK: @fc
// CHECK: atomicrmw xchg i64*
- return __atomic_exchange(c, 2, memory_order_seq_cst);
+ return __c11_atomic_exchange(c, 2, memory_order_seq_cst);
}
typedef struct X { int x; } X;
X fs(_Atomic(X) *c) {
// CHECK: @fs
// CHECK: atomicrmw xchg i32*
- return __atomic_exchange(c, (X){2}, memory_order_seq_cst);
+ return __c11_atomic_exchange(c, (X){2}, memory_order_seq_cst);
+}
+
+X fsa(X *c, X *d) {
+ // CHECK: @fsa
+ // CHECK: atomicrmw xchg i32*
+ X ret;
+ __atomic_exchange(c, d, &ret, memory_order_seq_cst);
+ return ret;
}
+
+_Bool fsb(_Bool *c) {
+ // CHECK: @fsb
+ // CHECK: atomicrmw xchg i8*
+ return __atomic_exchange_n(c, 1, memory_order_seq_cst);
+}
+
+char flag1;
+volatile char flag2;
+void test_and_set() {
+ // CHECK: atomicrmw xchg i8* @flag1, i8 1 seq_cst
+ __atomic_test_and_set(&flag1, memory_order_seq_cst);
+ // CHECK: atomicrmw volatile xchg i8* @flag2, i8 1 acquire
+ __atomic_test_and_set(&flag2, memory_order_acquire);
+ // CHECK: store atomic volatile i8 0, i8* @flag2 release
+ __atomic_clear(&flag2, memory_order_release);
+ // CHECK: store atomic i8 0, i8* @flag1 seq_cst
+ __atomic_clear(&flag1, memory_order_seq_cst);
+}
+
+struct Sixteen {
+ char c[16];
+} sixteen;
+struct Seventeen {
+ char c[17];
+} seventeen;
+
+int lock_free(struct Incomplete *incomplete) {
+ // CHECK: @lock_free
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 3, i8* null)
+ __c11_atomic_is_lock_free(3);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 16, i8* {{.*}}@sixteen{{.*}})
+ __atomic_is_lock_free(16, &sixteen);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 17, i8* {{.*}}@seventeen{{.*}})
+ __atomic_is_lock_free(17, &seventeen);
+
+ // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+ __atomic_is_lock_free(4, incomplete);
+
+ char cs[20];
+ // CHECK: call i32 @__atomic_is_lock_free(i32 4, {{.*}})
+ __atomic_is_lock_free(4, cs+1);
+
+ // CHECK-NOT: call
+ __atomic_always_lock_free(3, 0);
+ __atomic_always_lock_free(16, 0);
+ __atomic_always_lock_free(17, 0);
+ __atomic_always_lock_free(16, &sixteen);
+ __atomic_always_lock_free(17, &seventeen);
+
+ int n;
+ __atomic_is_lock_free(4, &n);
+
+ // CHECK: ret i32 1
+ return __c11_atomic_is_lock_free(sizeof(_Atomic(int)));
+}
+
+// Tests for atomic operations on big values. These should call the functions
+// defined here:
+// http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary#The_Library_interface
+
+struct foo {
+ int big[128];
+};
+struct bar {
+ char c[3];
+};
+
+struct bar smallThing, thing1, thing2;
+struct foo bigThing;
+_Atomic(struct foo) bigAtomic;
+
+void structAtomicStore() {
+ // CHECK: @structAtomicStore
+ struct foo f = {0};
+ __c11_atomic_store(&bigAtomic, f, 5);
+ // CHECK: call void @__atomic_store(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+ struct bar b = {0};
+ __atomic_store(&smallThing, &b, 5);
+ // CHECK: call void @__atomic_store(i32 3, i8* {{.*}} @smallThing
+
+ __atomic_store(&bigThing, &f, 5);
+ // CHECK: call void @__atomic_store(i32 512, i8* {{.*}} @bigThing
+}
+void structAtomicLoad() {
+ // CHECK: @structAtomicLoad
+ struct foo f = __c11_atomic_load(&bigAtomic, 5);
+ // CHECK: call void @__atomic_load(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+
+ struct bar b;
+ __atomic_load(&smallThing, &b, 5);
+ // CHECK: call void @__atomic_load(i32 3, i8* {{.*}} @smallThing
+
+ __atomic_load(&bigThing, &f, 5);
+ // CHECK: call void @__atomic_load(i32 512, i8* {{.*}} @bigThing
+}
+struct foo structAtomicExchange() {
+ // CHECK: @structAtomicExchange
+ struct foo f = {0};
+ struct foo old;
+ __atomic_exchange(&f, &bigThing, &old, 5);
+ // CHECK: call void @__atomic_exchange(i32 512, {{.*}}, i8* bitcast ({{.*}} @bigThing to i8*),
+
+ return __c11_atomic_exchange(&bigAtomic, f, 5);
+ // CHECK: call void @__atomic_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+}
+int structAtomicCmpExchange() {
+ // CHECK: @structAtomicCmpExchange
+ _Bool x = __atomic_compare_exchange(&smallThing, &thing1, &thing2, 1, 5, 5);
+ // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 3, {{.*}} @smallThing{{.*}} @thing1{{.*}} @thing2
+
+ struct foo f = {0};
+ struct foo g = {0};
+ g.big[12] = 12;
+ return x & __c11_atomic_compare_exchange_strong(&bigAtomic, &f, g, 5, 5);
+ // CHECK: call zeroext i1 @__atomic_compare_exchange(i32 512, i8* bitcast ({{.*}} @bigAtomic to i8*),
+}
+
+// Check that no atomic operations are used in any initialisation of _Atomic
+// types.
+_Atomic(int) atomic_init_i = 42;
+
+// CHECK: @atomic_init_foo
+void atomic_init_foo()
+{
+ // CHECK-NOT: }
+ // CHECK-NOT: atomic
+ // CHECK: store
+ _Atomic(int) j = 12;
+
+ // CHECK-NOT: }
+ // CHECK-NOT: atomic
+ // CHECK: store
+ __c11_atomic_init(&j, 42);
+
+ // CHECK-NOT: atomic
+ // CHECK: }
+}
+
+#endif
diff --git a/test/CodeGen/atomic.c b/test/CodeGen/atomic.c
index c8f4fd09..ac3848f 100644
--- a/test/CodeGen/atomic.c
+++ b/test/CodeGen/atomic.c
@@ -8,6 +8,7 @@ int atomic(void) {
_Bool valb = 0;
unsigned int uval = 1;
int cmp = 0;
+ int* ptrval;
old = __sync_fetch_and_add(&val, 1);
// CHECK: atomicrmw add i32* %val, i32 1 seq_cst
@@ -75,8 +76,11 @@ int atomic(void) {
// CHECK: cmpxchg i32* null, i32 0, i32 0 seq_cst
__sync_lock_release(&val);
- // CHECK: store atomic {{.*}} release, align 4
-
+ // CHECK: store atomic i32 0, {{.*}} release, align 4
+
+ __sync_lock_release(&ptrval);
+ // CHECK: store atomic i32 0, {{.*}} release, align 4
+
__sync_synchronize ();
// CHECK: fence seq_cst
diff --git a/test/CodeGen/atomic_ops.c b/test/CodeGen/atomic_ops.c
new file mode 100644
index 0000000..9a18c9e
--- /dev/null
+++ b/test/CodeGen/atomic_ops.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+
+void foo(void)
+{
+ _Atomic(int) i = 0;
+ // Check that multiply / divides on atomics produce a cmpxchg loop
+ i *= 2; // CHECK: cmpxchg
+ i /= 2; // CHECK: cmpxchg
+ // These should be emitting atomicrmw instructions, but they aren't yet
+ i += 2; // CHECK: cmpxchg
+ i -= 2; // CHECK: cmpxchg
+ i++; // CHECK: cmpxchg
+ i--; // CHECK: cmpxchg
+}
diff --git a/test/CodeGen/avx-builtins.c b/test/CodeGen/avx-builtins.c
new file mode 100644
index 0000000..b963c97
--- /dev/null
+++ b/test/CodeGen/avx-builtins.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+//
+// Test LLVM IR codegen of shuffle instructions
+//
+
+__m256 test__mm256_loadu_ps(void* p) {
+ // CHECK: load <8 x float>* %{{.*}}, align 1
+ return _mm256_loadu_ps(p);
+}
+
+__m256d test__mm256_loadu_pd(void* p) {
+ // CHECK: load <4 x double>* %{{.*}}, align 1
+ return _mm256_loadu_pd(p);
+}
+
+__m256i test__mm256_loadu_si256(void* p) {
+ // CHECK: load <4 x i64>* %{{.+}}, align 1
+ return _mm256_loadu_si256(p);
+}
diff --git a/test/CodeGen/avx-shuffle-builtins.c b/test/CodeGen/avx-shuffle-builtins.c
index c11780a..538ae50 100644
--- a/test/CodeGen/avx-shuffle-builtins.c
+++ b/test/CodeGen/avx-shuffle-builtins.c
@@ -14,3 +14,52 @@ __m256 x(__m256 a, __m256 b) {
// CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 8, i32 11, i32 7, i32 6, i32 12, i32 15>
return _mm256_shuffle_ps(a, b, 203);
}
+
+__m128d test_mm_permute_pd(__m128d a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 1, i32 0>
+ return _mm_permute_pd(a, 1);
+}
+
+__m256d test_mm256_permute_pd(__m256d a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 1, i32 0, i32 3, i32 2>
+ return _mm256_permute_pd(a, 5);
+}
+
+__m128 test_mm_permute_ps(__m128 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0>
+ return _mm_permute_ps(a, 0x1b);
+}
+
+// Test case for PR12401
+__m128 test_mm_permute_ps2(__m128 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 2, i32 1, i32 2, i32 3>
+ return _mm_permute_ps(a, 0xe6);
+}
+
+__m256 test_mm256_permute_ps(__m256 a) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
+ return _mm256_permute_ps(a, 0x1b);
+}
+
+__m256d test_mm256_permute2f128_pd(__m256d a, __m256d b) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7>
+ return _mm256_permute2f128_pd(a, b, 0x31);
+}
+
+__m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 12, i32 13, i32 14, i32 15, i32 4, i32 5, i32 6, i32 7>
+ return _mm256_permute2f128_ps(a, b, 0x13);
+}
+
+__m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) {
+ // Check if the mask is correct
+ // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
+ return _mm256_permute2f128_si256(a, b, 0x20);
+}
diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c
new file mode 100644
index 0000000..a5ddc8e
--- /dev/null
+++ b/test/CodeGen/avx2-builtins.c
@@ -0,0 +1,782 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +avx2 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <immintrin.h>
+
+__m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) {
+ // CHECK: @llvm.x86.avx2.mpsadbw({{.*}}, {{.*}}, i32 3)
+ return _mm256_mpsadbw_epu8(x, y, 3);
+}
+
+__m256i test_mm256_abs_epi8(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.b
+ return _mm256_abs_epi8(a);
+}
+
+__m256i test_mm256_abs_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.w
+ return _mm256_abs_epi16(a);
+}
+
+__m256i test_mm256_abs_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pabs.d
+ return _mm256_abs_epi32(a);
+}
+
+__m256i test_mm256_packs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packsswb
+ return _mm256_packs_epi16(a, b);
+}
+
+__m256i test_mm256_packs_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packssdw
+ return _mm256_packs_epi32(a, b);
+}
+
+__m256i test_mm256_packs_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packuswb
+ return _mm256_packus_epi16(a, b);
+}
+
+__m256i test_mm256_packs_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.packusdw
+ return _mm256_packus_epi32(a, b);
+}
+
+__m256i test_mm256_add_epi8(__m256i a, __m256i b) {
+ // CHECK: add <32 x i8>
+ return _mm256_add_epi8(a, b);
+}
+
+__m256i test_mm256_add_epi16(__m256i a, __m256i b) {
+ // CHECK: add <16 x i16>
+ return _mm256_add_epi16(a, b);
+}
+
+__m256i test_mm256_add_epi32(__m256i a, __m256i b) {
+ // CHECK: add <8 x i32>
+ return _mm256_add_epi32(a, b);
+}
+
+__m256i test_mm256_add_epi64(__m256i a, __m256i b) {
+ // CHECK: add <4 x i64>
+ return _mm256_add_epi64(a, b);
+}
+
+__m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.padds.b
+ return _mm256_adds_epi8(a, b);
+}
+
+__m256i test_mm256_adds_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.padds.w
+ return _mm256_adds_epi16(a, b);
+}
+
+__m256i test_mm256_adds_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.paddus.b
+ return _mm256_adds_epu8(a, b);
+}
+
+__m256i test_mm256_adds_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.paddus.w
+ return _mm256_adds_epu16(a, b);
+}
+
+__m256i test_mm256_alignr_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 32, i32 33, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 48, i32 49>
+ return _mm256_alignr_epi8(a, b, 2);
+}
+
+__m256i test2_mm256_alignr_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrl.dq({{.*}}, i32 8)
+ return _mm256_alignr_epi8(a, b, 17);
+}
+
+__m256i test_mm256_sub_epi8(__m256i a, __m256i b) {
+ // CHECK: sub <32 x i8>
+ return _mm256_sub_epi8(a, b);
+}
+
+__m256i test_mm256_sub_epi16(__m256i a, __m256i b) {
+ // CHECK: sub <16 x i16>
+ return _mm256_sub_epi16(a, b);
+}
+
+__m256i test_mm256_sub_epi32(__m256i a, __m256i b) {
+ // CHECK: sub <8 x i32>
+ return _mm256_sub_epi32(a, b);
+}
+
+__m256i test_mm256_sub_epi64(__m256i a, __m256i b) {
+ // CHECK: sub <4 x i64>
+ return _mm256_sub_epi64(a, b);
+}
+
+__m256i test_mm256_subs_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubs.b
+ return _mm256_subs_epi8(a, b);
+}
+
+__m256i test_mm256_subs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubs.w
+ return _mm256_subs_epi16(a, b);
+}
+
+__m256i test_mm256_subs_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubus.b
+ return _mm256_subs_epu8(a, b);
+}
+
+__m256i test_mm256_subs_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psubus.w
+ return _mm256_subs_epu16(a, b);
+}
+
+__m256i test_mm256_and_si256(__m256i a, __m256i b) {
+ // CHECK: and <4 x i64>
+ return _mm256_and_si256(a, b);
+}
+
+__m256i test_mm256_andnot_si256(__m256i a, __m256i b) {
+ // CHECK: xor <4 x i64>
+ // CHECK: and <4 x i64>
+ return _mm256_andnot_si256(a, b);
+}
+
+__m256i test_mm256_or_si256(__m256i a, __m256i b) {
+ // CHECK: or <4 x i64>
+ return _mm256_or_si256(a, b);
+}
+
+__m256i test_mm256_xor_si256(__m256i a, __m256i b) {
+ // CHECK: xor <4 x i64>
+ return _mm256_xor_si256(a, b);
+}
+
+__m256i test_mm256_avg_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pavg.b
+ return _mm256_avg_epu8(a, b);
+}
+
+__m256i test_mm256_avg_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pavg.w
+ return _mm256_avg_epu16(a, b);
+}
+
+__m256i test_mm256_blendv_epi8(__m256i a, __m256i b, __m256i m) {
+ // CHECK: @llvm.x86.avx2.pblendvb
+ return _mm256_blendv_epi8(a, b, m);
+}
+
+__m256i test_mm256_blend_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pblendw(<16 x i16> %{{.*}}, <16 x i16> %{{.*}}, i32 2)
+ return _mm256_blend_epi16(a, b, 2);
+}
+
+__m256i test_mm256_cmpeq_epi8(__m256i a, __m256i b) {
+ // CHECK: icmp eq <32 x i8>
+ return _mm256_cmpeq_epi8(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi16(__m256i a, __m256i b) {
+ // CHECK: icmp eq <16 x i16>
+ return _mm256_cmpeq_epi16(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi32(__m256i a, __m256i b) {
+ // CHECK: icmp eq <8 x i32>
+ return _mm256_cmpeq_epi32(a, b);
+}
+
+__m256i test_mm256_cmpeq_epi64(__m256i a, __m256i b) {
+ // CHECK: icmp eq <4 x i64>
+ return _mm256_cmpeq_epi64(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi8(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <32 x i8>
+ return _mm256_cmpgt_epi8(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi16(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <16 x i16>
+ return _mm256_cmpgt_epi16(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi32(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <8 x i32>
+ return _mm256_cmpgt_epi32(a, b);
+}
+
+__m256i test_mm256_cmpgt_epi64(__m256i a, __m256i b) {
+ // CHECK: icmp sgt <4 x i64>
+ return _mm256_cmpgt_epi64(a, b);
+}
+
+__m256i test_mm256_hadd_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.w
+ return _mm256_hadd_epi16(a, b);
+}
+
+__m256i test_mm256_hadd_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.d
+ return _mm256_hadd_epi32(a, b);
+}
+
+__m256i test_mm256_hadds_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phadd.sw
+ return _mm256_hadds_epi16(a, b);
+}
+
+__m256i test_mm256_hsub_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.w
+ return _mm256_hsub_epi16(a, b);
+}
+
+__m256i test_mm256_hsub_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.d
+ return _mm256_hsub_epi32(a, b);
+}
+
+__m256i test_mm256_hsubs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.phsub.sw
+ return _mm256_hsubs_epi16(a, b);
+}
+
+__m256i test_mm256_maddubs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmadd.ub.sw
+ return _mm256_maddubs_epi16(a, b);
+}
+
+__m256i test_mm256_madd_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmadd.wd
+ return _mm256_madd_epi16(a, b);
+}
+
+__m256i test_mm256_max_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.b
+ return _mm256_max_epi8(a, b);
+}
+
+__m256i test_mm256_max_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.w
+ return _mm256_max_epi16(a, b);
+}
+
+__m256i test_mm256_max_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxs.d
+ return _mm256_max_epi32(a, b);
+}
+
+__m256i test_mm256_max_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.b
+ return _mm256_max_epu8(a, b);
+}
+
+__m256i test_mm256_max_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.w
+ return _mm256_max_epu16(a, b);
+}
+
+__m256i test_mm256_max_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmaxu.d
+ return _mm256_max_epu32(a, b);
+}
+
+__m256i test_mm256_min_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.b
+ return _mm256_min_epi8(a, b);
+}
+
+__m256i test_mm256_min_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.w
+ return _mm256_min_epi16(a, b);
+}
+
+__m256i test_mm256_min_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmins.d
+ return _mm256_min_epi32(a, b);
+}
+
+__m256i test_mm256_min_epu8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.b
+ return _mm256_min_epu8(a, b);
+}
+
+__m256i test_mm256_min_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.w
+ return _mm256_min_epu16(a, b);
+}
+
+__m256i test_mm256_min_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pminu.d
+ return _mm256_min_epu32(a, b);
+}
+
+int test_mm256_movemask_epi8(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pmovmskb
+ return _mm256_movemask_epi8(a);
+}
+
+__m256i test_mm256_cvtepi8_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbw
+ return _mm256_cvtepi8_epi16(a);
+}
+
+__m256i test_mm256_cvtepi8_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbd
+ return _mm256_cvtepi8_epi32(a);
+}
+
+__m256i test_mm256_cvtepi8_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxbq
+ return _mm256_cvtepi8_epi64(a);
+}
+
+__m256i test_mm256_cvtepi16_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxwd
+ return _mm256_cvtepi16_epi32(a);
+}
+
+__m256i test_mm256_cvtepi16_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxwq
+ return _mm256_cvtepi16_epi64(a);
+}
+
+__m256i test_mm256_cvtepi32_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovsxdq
+ return _mm256_cvtepi32_epi64(a);
+}
+
+__m256i test_mm256_cvtepu8_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbw
+ return _mm256_cvtepu8_epi16(a);
+}
+
+__m256i test_mm256_cvtepu8_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbd
+ return _mm256_cvtepu8_epi32(a);
+}
+
+__m256i test_mm256_cvtepu8_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxbq
+ return _mm256_cvtepu8_epi64(a);
+}
+
+__m256i test_mm256_cvtepu16_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxwd
+ return _mm256_cvtepu16_epi32(a);
+}
+
+__m256i test_mm256_cvtepu16_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxwq
+ return _mm256_cvtepu16_epi64(a);
+}
+
+__m256i test_mm256_cvtepu32_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pmovzxdq
+ return _mm256_cvtepu32_epi64(a);
+}
+
+__m256i test_mm256_mul_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmul.dq
+ return _mm256_mul_epi32(a, b);
+}
+
+__m256i test_mm256_mulhrs_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmul.hr.sw
+ return _mm256_mulhrs_epi16(a, b);
+}
+
+__m256i test_mm256_mulhi_epu16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulhu.w
+ return _mm256_mulhi_epu16(a, b);
+}
+
+__m256i test_mm256_mulhi_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulh.w
+ return _mm256_mulhi_epi16(a, b);
+}
+
+__m256i test_mm256_mullo_epi16(__m256i a, __m256i b) {
+ // CHECK: mul <16 x i16>
+ return _mm256_mullo_epi16(a, b);
+}
+
+__m256i test_mm256_mullo_epi32(__m256i a, __m256i b) {
+ // CHECK: mul <8 x i32>
+ return _mm256_mullo_epi32(a, b);
+}
+
+__m256i test_mm256_mul_epu32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pmulu.dq
+ return _mm256_mul_epu32(a, b);
+}
+
+__m256i test_mm256_shuffle_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pshuf.b
+ return _mm256_shuffle_epi8(a, b);
+}
+
+__m256i test_mm256_shuffle_epi32(__m256i a) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> undef, <8 x i32> <i32 3, i32 3, i32 0, i32 0, i32 7, i32 7, i32 4, i32 4>
+ return _mm256_shuffle_epi32(a, 15);
+}
+
+__m256i test_mm256_shufflehi_epi16(__m256i a) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> undef, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 7, i32 6, i32 6, i32 5, i32 8, i32 9, i32 10, i32 11, i32 15, i32 14, i32 14, i32 13>
+ return _mm256_shufflehi_epi16(a, 107);
+}
+
+__m256i test_mm256_shufflelo_epi16(__m256i a) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> undef, <16 x i32> <i32 3, i32 0, i32 1, i32 1, i32 4, i32 5, i32 6, i32 7, i32 11, i32 8, i32 9, i32 9, i32 12, i32 13, i32 14, i32 15>
+ return _mm256_shufflelo_epi16(a, 83);
+}
+
+__m256i test_mm256_sign_epi8(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.b
+ return _mm256_sign_epi8(a, b);
+}
+
+__m256i test_mm256_sign_epi16(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.w
+ return _mm256_sign_epi16(a, b);
+}
+
+__m256i test_mm256_sign_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psign.d
+ return _mm256_sign_epi32(a, b);
+}
+
+__m256i test_mm256_slli_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psll.dq
+ return _mm256_slli_si256(a, 3);
+}
+
+__m256i test_mm256_slli_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.w
+ return _mm256_slli_epi16(a, 3);
+}
+
+__m256i test_mm256_sll_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.w
+ return _mm256_sll_epi16(a, b);
+}
+
+__m256i test_mm256_slli_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.d
+ return _mm256_slli_epi32(a, 3);
+}
+
+__m256i test_mm256_sll_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.d
+ return _mm256_sll_epi32(a, b);
+}
+
+__m256i test_mm256_slli_epi64(__m256i a) {
+ // CHECK: @llvm.x86.avx2.pslli.q
+ return _mm256_slli_epi64(a, 3);
+}
+
+__m256i test_mm256_sll_epi64(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psll.q
+ return _mm256_sll_epi64(a, b);
+}
+
+__m256i test_mm256_srai_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrai.w
+ return _mm256_srai_epi16(a, 3);
+}
+
+__m256i test_mm256_sra_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psra.w
+ return _mm256_sra_epi16(a, b);
+}
+
+__m256i test_mm256_srai_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrai.d
+ return _mm256_srai_epi32(a, 3);
+}
+
+__m256i test_mm256_sra_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psra.d
+ return _mm256_sra_epi32(a, b);
+}
+
+__m256i test_mm256_srli_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrl.dq
+ return _mm256_srli_si256(a, 3);
+}
+
+__m256i test_mm256_srli_epi16(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.w
+ return _mm256_srli_epi16(a, 3);
+}
+
+__m256i test_mm256_srl_epi16(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.w
+ return _mm256_srl_epi16(a, b);
+}
+
+__m256i test_mm256_srli_epi32(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.d
+ return _mm256_srli_epi32(a, 3);
+}
+
+__m256i test_mm256_srl_epi32(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.d
+ return _mm256_srl_epi32(a, b);
+}
+
+__m256i test_mm256_srli_epi64(__m256i a) {
+ // CHECK: @llvm.x86.avx2.psrli.q
+ return _mm256_srli_epi64(a, 3);
+}
+
+__m256i test_mm256_srl_epi64(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrl.q
+ return _mm256_srl_epi64(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 8, i32 40, i32 9, i32 41, i32 10, i32 42, i32 11, i32 43, i32 12, i32 44, i32 13, i32 45, i32 14, i32 46, i32 15, i32 47, i32 24, i32 56, i32 25, i32 57, i32 26, i32 58, i32 27, i32 59, i32 28, i32 60, i32 29, i32 61, i32 30, i32 62, i32 31, i32 63>
+ return _mm256_unpackhi_epi8(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi16(__m256i a, __m256i b) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
+ return _mm256_unpackhi_epi16(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi32(__m256i a, __m256i b) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 2, i32 10, i32 3, i32 11, i32 6, i32 14, i32 7, i32 15>
+ return _mm256_unpackhi_epi32(a, b);
+}
+
+__m256i test_mm256_unpackhi_epi64(__m256i a, __m256i b) {
+ // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 1, i32 5, i32 3, i32 7>
+ return _mm256_unpackhi_epi64(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi8(__m256i a, __m256i b) {
+ // CHECK: shufflevector <32 x i8> %{{.*}}, <32 x i8> %{{.*}}, <32 x i32> <i32 0, i32 32, i32 1, i32 33, i32 2, i32 34, i32 3, i32 35, i32 4, i32 36, i32 5, i32 37, i32 6, i32 38, i32 7, i32 39, i32 16, i32 48, i32 17, i32 49, i32 18, i32 50, i32 19, i32 51, i32 20, i32 52, i32 21, i32 53, i32 22, i32 54, i32 23, i32 55>
+ return _mm256_unpacklo_epi8(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi16(__m256i a, __m256i b) {
+ // CHECK: shufflevector <16 x i16> %{{.*}}, <16 x i16> %{{.*}}, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27>
+ return _mm256_unpacklo_epi16(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi32(__m256i a, __m256i b) {
+ // CHECK: shufflevector <8 x i32> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> <i32 0, i32 8, i32 1, i32 9, i32 4, i32 12, i32 5, i32 13>
+ return _mm256_unpacklo_epi32(a, b);
+}
+
+__m256i test_mm256_unpacklo_epi64(__m256i a, __m256i b) {
+ // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> <i32 0, i32 4, i32 2, i32 6>
+ return _mm256_unpacklo_epi64(a, b);
+}
+
+__m256i test_mm256_stream_load_si256(__m256i *a) {
+ // CHECK: @llvm.x86.avx2.movntdqa
+ return _mm256_stream_load_si256(a);
+}
+
+__m128 test_mm_broadcastss_ps(__m128 a) {
+ // CHECK: @llvm.x86.avx2.vbroadcast.ss.ps
+ return _mm_broadcastss_ps(a);
+}
+
+__m256 test_mm256_broadcastss_ps(__m128 a) {
+ // CHECK: @llvm.x86.avx2.vbroadcast.ss.ps.256
+ return _mm256_broadcastss_ps(a);
+}
+
+__m256d test_mm256_broadcastsd_pd(__m128d a) {
+ // check: @llvm.x86.avx2.vbroadcast.sd.pd.256
+ return _mm256_broadcastsd_pd(a);
+}
+
+__m256i test_mm_broadcastsi128_si256(__m128i *a) {
+ // CHECK: @llvm.x86.avx2.vbroadcasti128
+ return _mm_broadcastsi128_si256(a);
+}
+
+__m128i test_mm_blend_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.pblendd.128
+ return _mm_blend_epi32(a, b, 57);
+}
+
+__m256i test_mm256_blend_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.pblendd.256
+ return _mm256_blend_epi32(a, b, 57);
+}
+
+__m256i test_mm256_broadcastb_epi8(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastb.256
+ return _mm256_broadcastb_epi8(a);
+}
+
+__m256i test_mm256_broadcastw_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastw.256
+ return _mm256_broadcastw_epi16(a);
+}
+
+__m256i test_mm256_broadcastd_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastd.256
+ return _mm256_broadcastd_epi32(a);
+}
+
+__m256i test_mm256_broadcastq_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastq.256
+ return _mm256_broadcastq_epi64(a);
+}
+
+__m128i test_mm_broadcastb_epi8(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastb.128
+ return _mm_broadcastb_epi8(a);
+}
+
+__m128i test_mm_broadcastw_epi16(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastw.128
+ return _mm_broadcastw_epi16(a);
+}
+
+__m128i test_mm_broadcastd_epi32(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastd.128
+ return _mm_broadcastd_epi32(a);
+}
+
+__m128i test_mm_broadcastq_epi64(__m128i a) {
+ // CHECK: @llvm.x86.avx2.pbroadcastq.128
+ return _mm_broadcastq_epi64(a);
+}
+
+__m256i test_mm256_permutevar8x32_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.permd
+ return _mm256_permutevar8x32_epi32(a, b);
+}
+
+__m256d test_mm256_permute4x64_pd(__m256d a) {
+ // CHECK: @llvm.x86.avx2.permpd
+ return _mm256_permute4x64_pd(a, 25);
+}
+
+__m256 test_mm256_permutevar8x32_ps(__m256 a, __m256 b) {
+ // CHECK: @llvm.x86.avx2.permps
+ return _mm256_permutevar8x32_ps(a, b);
+}
+
+__m256i test_mm256_permute4x64_epi64(__m256i a) {
+ // CHECK: @llvm.x86.avx2.permq
+ return _mm256_permute4x64_epi64(a, 35);
+}
+
+__m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) {
+ // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7>
+ return _mm256_permute2x128_si256(a, b, 0x31);
+}
+
+__m128i test_mm256_extracti128_si256(__m256i a) {
+ // CHECK: @llvm.x86.avx2.vextracti128
+ return _mm256_extracti128_si256(a, 1);
+}
+
+__m256i test_mm256_inserti128_si256(__m256i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.vinserti128
+ return _mm256_inserti128_si256(a, b, 1);
+}
+
+__m256i test_mm256_maskload_epi32(int const *a, __m256i m) {
+ // CHECK: @llvm.x86.avx2.maskload.d.256
+ return _mm256_maskload_epi32(a, m);
+}
+
+__m256i test_mm256_maskload_epi64(long long const *a, __m256i m) {
+ // CHECK: @llvm.x86.avx2.maskload.q.256
+ return _mm256_maskload_epi64(a, m);
+}
+
+__m128i test_mm_maskload_epi32(int const *a, __m128i m) {
+ // CHECK: @llvm.x86.avx2.maskload.d
+ return _mm_maskload_epi32(a, m);
+}
+
+__m128i test_mm_maskload_epi64(long long const *a, __m128i m) {
+ // CHECK: @llvm.x86.avx2.maskload.q
+ return _mm_maskload_epi64(a, m);
+}
+
+void test_mm256_maskstore_epi32(int *a, __m256i m, __m256i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.d.256
+ _mm256_maskstore_epi32(a, m, b);
+}
+
+void test_mm256_maskstore_epi64(long long *a, __m256i m, __m256i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.q.256
+ _mm256_maskstore_epi64(a, m, b);
+}
+
+void test_mm_maskstore_epi32(int *a, __m128i m, __m128i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.d
+ _mm_maskstore_epi32(a, m, b);
+}
+
+void test_mm_maskstore_epi64(long long *a, __m128i m, __m128i b) {
+ // CHECK: @llvm.x86.avx2.maskstore.q
+ _mm_maskstore_epi64(a, m, b);
+}
+
+__m256i test_mm256_sllv_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psllv.d.256
+ return _mm256_sllv_epi32(a, b);
+}
+
+__m128i test_mm_sllv_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psllv.d
+ return _mm_sllv_epi32(a, b);
+}
+
+__m256i test_mm256_sllv_epi64(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psllv.q.256
+ return _mm256_sllv_epi64(a, b);
+}
+
+__m128i test_mm_sllv_epi64(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psllv.q
+ return _mm_sllv_epi64(a, b);
+}
+
+__m256i test_mm256_srav_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrav.d.256
+ return _mm256_srav_epi32(a, b);
+}
+
+__m128i test_mm_srav_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrav.d
+ return _mm_srav_epi32(a, b);
+}
+
+__m256i test_mm256_srlv_epi32(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.d.256
+ return _mm256_srlv_epi32(a, b);
+}
+
+__m128i test_mm_srlv_epi32(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.d
+ return _mm_srlv_epi32(a, b);
+}
+
+__m256i test_mm256_srlv_epi64(__m256i a, __m256i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.q.256
+ return _mm256_srlv_epi64(a, b);
+}
+
+__m128i test_mm_srlv_epi64(__m128i a, __m128i b) {
+ // CHECK: @llvm.x86.avx2.psrlv.q
+ return _mm_srlv_epi64(a, b);
+}
diff --git a/test/CodeGen/bmi-builtins.c b/test/CodeGen/bmi-builtins.c
new file mode 100644
index 0000000..47b0da2
--- /dev/null
+++ b/test/CodeGen/bmi-builtins.c
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned short test__tzcnt16(unsigned short __X) {
+ // CHECK: @llvm.cttz.i16
+ return __tzcnt16(__X);
+}
+
+unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: [[DEST:%.*]] = xor i32 %{{.*}}, -1
+ // CHECK-NEXT: %{{.*}} = and i32 %{{.*}}, [[DEST]]
+ return __andn_u32(__X, __Y);
+}
+
+unsigned int test__bextr_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.bextr.32
+ return __bextr_u32(__X, __Y);
+}
+
+unsigned int test__blsi_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = sub i32 0, [[SRC:%.*]]
+ // CHECK-NEXT: %{{.*}} = and i32 [[SRC]], [[DEST]]
+ return __blsi_u32(__X);
+}
+
+unsigned int test__blsmsk_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = xor i32 [[DEST]], [[SRC]]
+ return __blsmsk_u32(__X);
+}
+
+unsigned int test__blsr_u32(unsigned int __X) {
+ // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = and i32 [[DEST]], [[SRC]]
+ return __blsr_u32(__X);
+}
+
+unsigned int test_tzcnt32(unsigned int __X) {
+ // CHECK: @llvm.cttz.i32
+ return __tzcnt32(__X);
+}
+
+unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
+ // CHECK: [[DEST:%.*]] = xor i64 %{{.*}}, -1
+ // CHECK-NEXT: %{{.*}} = and i64 %{{.*}}, [[DEST]]
+ return __andn_u64(__X, __Y);
+}
+
+unsigned long long test__bextr_u64(unsigned long __X, unsigned long __Y) {
+ // CHECK: @llvm.x86.bmi.bextr.64
+ return __bextr_u64(__X, __Y);
+}
+
+unsigned long long test__blsi_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = sub i64 0, [[SRC:%.*]]
+ // CHECK-NEXT: %{{.*}} = and i64 [[SRC]], [[DEST]]
+ return __blsi_u64(__X);
+}
+
+unsigned long long test__blsmsk_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = xor i64 [[DEST]], [[SRC]]
+ return __blsmsk_u64(__X);
+}
+
+unsigned long long test__blsr_u64(unsigned long long __X) {
+ // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1
+ // CHECK-NEXT: %{{.*}} = and i64 [[DEST]], [[SRC]]
+ return __blsr_u64(__X);
+}
+
+unsigned long long test__tzcnt64(unsigned long long __X) {
+ // CHECK: @llvm.cttz.i64
+ return __tzcnt64(__X);
+}
diff --git a/test/CodeGen/bmi2-builtins.c b/test/CodeGen/bmi2-builtins.c
new file mode 100644
index 0000000..18b2319
--- /dev/null
+++ b/test/CodeGen/bmi2-builtins.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test_bzhi_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.bzhi.32
+ return _bzhi_u32(__X, __Y);
+}
+
+unsigned int test_pdep_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.pdep.32
+ return _pdep_u32(__X, __Y);
+}
+
+unsigned int test_pext_u32(unsigned int __X, unsigned int __Y) {
+ // CHECK: @llvm.x86.bmi.pext.32
+ return _pext_u32(__X, __Y);
+}
+
+unsigned long long test_bzhi_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.bzhi.64
+ return _bzhi_u64(__X, __Y);
+}
+
+unsigned long long test_pdep_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.pdep.64
+ return _pdep_u64(__X, __Y);
+}
+
+unsigned long long test_pext_u64(unsigned long long __X, unsigned long long __Y) {
+ // CHECK: @llvm.x86.bmi.pext.64
+ return _pext_u64(__X, __Y);
+}
diff --git a/test/CodeGen/builtin-count-zeros.c b/test/CodeGen/builtin-count-zeros.c
index 5a0be2f..acd22e6 100644
--- a/test/CodeGen/builtin-count-zeros.c
+++ b/test/CodeGen/builtin-count-zeros.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | grep 'cttz' | count 2
-// RUN: %clang_cc1 -emit-llvm %s -o - | grep 'ctlz' | count 2
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple arm-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-ARM
int a(int a) {return __builtin_ctz(a) + __builtin_clz(a);}
+// CHECK: call i32 @llvm.cttz.i32({{.*}}, i1 true)
+// CHECK: call i32 @llvm.ctlz.i32({{.*}}, i1 true)
+// CHECK-ARM: call i32 @llvm.cttz.i32({{.*}}, i1 false)
+// CHECK-ARM: call i32 @llvm.ctlz.i32({{.*}}, i1 false)
diff --git a/test/CodeGen/builtin-memfns.c b/test/CodeGen/builtin-memfns.c
index fb4d720..72d3406 100644
--- a/test/CodeGen/builtin-memfns.c
+++ b/test/CodeGen/builtin-memfns.c
@@ -48,3 +48,18 @@ void test5(char *P, char *Q) {
int test6(char *X) {
return __builtin___memcpy_chk(X, X, 42, 42) != 0;
}
+
+// CHECK: @test7
+// PR12094
+int test7(int *p) {
+ struct snd_pcm_hw_params_t* hwparams; // incomplete type.
+
+ // CHECK: call void @llvm.memset{{.*}}256, i32 4, i1 false)
+ __builtin_memset(p, 0, 256); // Should be alignment = 4
+
+ // CHECK: call void @llvm.memset{{.*}}256, i32 1, i1 false)
+ __builtin_memset((char*)p, 0, 256); // Should be alignment = 1
+
+ __builtin_memset(hwparams, 0, 256); // No crash alignment = 1
+ // CHECK: call void @llvm.memset{{.*}}256, i32 1, i1 false)
+}
diff --git a/test/CodeGen/builtin-recursive.cc b/test/CodeGen/builtin-recursive.cc
new file mode 100644
index 0000000..81e9b9a
--- /dev/null
+++ b/test/CodeGen/builtin-recursive.cc
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -nostdsysteminc -nobuiltininc -isystem Inputs -emit-llvm-only %s
+
+// This used to cause a read past the end of a global variable.
+
+#include <stdio.h>
+
+void testcase(void) {
+ vprintf(0, 0);
+}
+
diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c
index 728ade3..30138d6 100644
--- a/test/CodeGen/builtins-x86.c
+++ b/test/CodeGen/builtins-x86.c
@@ -199,12 +199,6 @@ void f0() {
tmp_V8s = __builtin_ia32_pmulhw128(tmp_V8s, tmp_V8s);
tmp_V16c = __builtin_ia32_pavgb128(tmp_V16c, tmp_V16c);
tmp_V8s = __builtin_ia32_pavgw128(tmp_V8s, tmp_V8s);
- tmp_V16c = __builtin_ia32_pcmpeqb128(tmp_V16c, tmp_V16c);
- tmp_V8s = __builtin_ia32_pcmpeqw128(tmp_V8s, tmp_V8s);
- tmp_V4i = __builtin_ia32_pcmpeqd128(tmp_V4i, tmp_V4i);
- tmp_V16c = __builtin_ia32_pcmpgtb128(tmp_V16c, tmp_V16c);
- tmp_V8s = __builtin_ia32_pcmpgtw128(tmp_V8s, tmp_V8s);
- tmp_V4i = __builtin_ia32_pcmpgtd128(tmp_V4i, tmp_V4i);
tmp_V16c = __builtin_ia32_pmaxub128(tmp_V16c, tmp_V16c);
tmp_V8s = __builtin_ia32_pmaxsw128(tmp_V8s, tmp_V8s);
tmp_V16c = __builtin_ia32_pminub128(tmp_V16c, tmp_V16c);
@@ -420,13 +414,6 @@ void f0() {
tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d);
tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d);
tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f);
- tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7);
- tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7);
- tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7);
- tmp_V2d = __builtin_ia32_vpermilpd(tmp_V2d, 0x7);
- tmp_V4f = __builtin_ia32_vpermilps(tmp_V4f, 0x7);
- tmp_V4d = __builtin_ia32_vpermilpd256(tmp_V4d, 0x7);
- tmp_V8f = __builtin_ia32_vpermilps256(tmp_V8f, 0x7);
tmp_V4d = __builtin_ia32_vinsertf128_pd256(tmp_V4d, tmp_V2d, 0x7);
tmp_V8f = __builtin_ia32_vinsertf128_ps256(tmp_V8f, tmp_V4f, 0x7);
tmp_V8i = __builtin_ia32_vinsertf128_si256(tmp_V8i, tmp_V4i, 0x7);
@@ -434,8 +421,8 @@ void f0() {
tmp_V8f = __builtin_ia32_sqrtps256(tmp_V8f);
tmp_V8f = __builtin_ia32_rsqrtps256(tmp_V8f);
tmp_V8f = __builtin_ia32_rcpps256(tmp_V8f);
- tmp_V4d = __builtin_ia32_roundpd256(tmp_V4d, tmp_i);
- tmp_V8f = __builtin_ia32_roundps256(tmp_V8f, tmp_i);
+ tmp_V4d = __builtin_ia32_roundpd256(tmp_V4d, 0x1);
+ tmp_V8f = __builtin_ia32_roundps256(tmp_V8f, 0x1);
tmp_i = __builtin_ia32_vtestzpd(tmp_V2d, tmp_V2d);
tmp_i = __builtin_ia32_vtestcpd(tmp_V2d, tmp_V2d);
tmp_i = __builtin_ia32_vtestnzcpd(tmp_V2d, tmp_V2d);
@@ -460,11 +447,8 @@ void f0() {
tmp_V8f = __builtin_ia32_vbroadcastss256(tmp_fCp);
tmp_V4d = __builtin_ia32_vbroadcastf128_pd256(tmp_V2dCp);
tmp_V8f = __builtin_ia32_vbroadcastf128_ps256(tmp_V4fCp);
- tmp_V4d = __builtin_ia32_loadupd256(tmp_dCp);
- tmp_V8f = __builtin_ia32_loadups256(tmp_fCp);
__builtin_ia32_storeupd256(tmp_dp, tmp_V4d);
__builtin_ia32_storeups256(tmp_fp, tmp_V8f);
- tmp_V32c = __builtin_ia32_loaddqu256(tmp_cCp);
__builtin_ia32_storedqu256(tmp_cp, tmp_V32c);
tmp_V32c = __builtin_ia32_lddqu256(tmp_cCp);
__builtin_ia32_movntdq256(tmp_V4LLip, tmp_V4LLi);
@@ -495,7 +479,6 @@ void f0() {
tmp_V2f = __builtin_ia32_pfrcpit2(tmp_V2f, tmp_V2f);
tmp_V2f = __builtin_ia32_pfrsqrt(tmp_V2f);
tmp_V2f = __builtin_ia32_pfrsqit1(tmp_V2f, tmp_V2f);
- tmp_V2f = __builtin_ia32_pfrsqrtit1(tmp_V2f, tmp_V2f);
tmp_V2f = __builtin_ia32_pfsub(tmp_V2f, tmp_V2f);
tmp_V2f = __builtin_ia32_pfsubr(tmp_V2f, tmp_V2f);
tmp_V2f = __builtin_ia32_pi2fd(tmp_V2i);
diff --git a/test/CodeGen/builtinshufflevector2.c b/test/CodeGen/builtinshufflevector2.c
new file mode 100644
index 0000000..faf7a3e
--- /dev/null
+++ b/test/CodeGen/builtinshufflevector2.c
@@ -0,0 +1,35 @@
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef unsigned int uint4 __attribute__((ext_vector_type(4)));
+
+// CHECK: define void @clang_shufflevector_v_v(
+void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) {
+// CHECK: [[MASK:%.*]] = and <4 x i32> {{%.*}}, <i32 3, i32 3, i32 3, i32 3>
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 0
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X:%.*]], i32 [[I]]
+//
+// Here is where ToT Clang code generation makes a mistake.
+// It uses [[I]] as the insertion index instead of 0.
+// Similarly on the remaining insertelement.
+// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float [[E]], i32 0
+
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 1
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 1
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 2
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 2
+// CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i32 3
+// CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i32 [[I]]
+// CHECK: [[V:%.*]] = insertelement <4 x float> [[V]], float [[E]], i32 3
+// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}},
+ *A = __builtin_shufflevector( x, mask );
+}
+
+// CHECK: define void @clang_shufflevector_v_v_c(
+void clang_shufflevector_v_v_c( float4* A, float4 x, float4 y, uint4 mask ) {
+// CHECK: [[V:%.*]] = shufflevector <4 x float> {{%.*}}, <4 x float> {{%.*}}, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
+// CHECK: store <4 x float> [[V]], <4 x float>* {{%.*}}
+ *A = __builtin_shufflevector( x, y, 0, 4, 1, 5 );
+}
diff --git a/test/CodeGen/cfstring.c b/test/CodeGen/cfstring.c
index 1f0977f..9d98b56 100644
--- a/test/CodeGen/cfstring.c
+++ b/test/CodeGen/cfstring.c
@@ -1,4 +1,14 @@
// RUN: %clang_cc1 -emit-llvm %s -o %t
+
+// <rdar://problem/10657500>: Check that the backing store of CFStrings are
+// constant with the -fwritable-strings flag.
+//
+// RUN: %clang_cc1 -fwritable-strings -emit-llvm %s -o - | FileCheck %s
+//
+// CHECK: @.str = linker_private unnamed_addr constant [14 x i8] c"Hello, World!\00", align 1
+// CHECK: @.str1 = linker_private unnamed_addr constant [7 x i8] c"yo joe\00", align 1
+// CHECK: @.str3 = linker_private unnamed_addr constant [16 x i8] c"Goodbye, World!\00", align 1
+
#define CFSTR __builtin___CFStringMakeConstantString
void f() {
diff --git a/test/CodeGen/char-literal.c b/test/CodeGen/char-literal.c
index 5963ede..237d4b2 100644
--- a/test/CodeGen/char-literal.c
+++ b/test/CodeGen/char-literal.c
@@ -9,11 +9,26 @@ int main() {
// CHECK-CPP0X: store i8 97
char a = 'a';
- // Should pick second character.
+ // Should truncate value (equal to last character).
// CHECK-C: store i8 98
// CHECK-CPP0X: store i8 98
char b = 'ab';
+ // Should get concatenated characters
+ // CHECK-C: store i32 24930
+ // CHECK-CPP0X: store i32 24930
+ int b1 = 'ab';
+
+ // Should get concatenated characters
+ // CHECK-C: store i32 808464432
+ // CHECK-CPP0X: store i32 808464432
+ int b2 = '0000';
+
+ // Should get truncated value (last four characters concatenated)
+ // CHECK-C: store i32 1919512167
+ // CHECK-CPP0X: store i32 1919512167
+ int b3 = 'somesillylongstring';
+
// CHECK-C: store i32 97
// CHECK-CPP0X: store i32 97
wchar_t wa = L'a';
@@ -27,25 +42,24 @@ int main() {
// CHECK-CPP0X: store i16 97
char16_t ua = u'a';
- // Should pick second character.
- // CHECK-CPP0X: store i16 98
- char16_t ub = u'ab';
-
// CHECK-CPP0X: store i32 97
char32_t Ua = U'a';
- // Should pick second character.
- // CHECK-CPP0X: store i32 98
- char32_t Ub = U'ab';
-#endif
+ // CHECK-CPP0X: store i16 1047
+ char16_t ua1 = u'З';
+ // CHECK-CPP0X: store i16 12538
+ char16_t ua2 = u'ヺ';
+ // CHECK-CPP0X: store i16 -27177
+ char16_t ua3 = u'é——';
- // Should pick last character and store its lowest byte.
- // This does not match gcc, which takes the last character, converts it to
- // utf8, and then picks the second-lowest byte of that (they probably store
- // the utf8 in uint16_ts internally and take the lower byte of that).
- // CHECK-C: store i8 48
- // CHECK-CPP0X: store i8 48
- char c = '\u1120\u0220\U00102030';
+ // CHECK-CPP0X: store i32 181
+ char32_t Ua1 = U'µ';
+ // CHECK-CPP0X: store i32 38359
+ char32_t Ua2 = U'é——';
+ // CHECK-CPP0X: store i32 128128
+ char32_t Ua3 = U'💀';
+
+#endif
// CHECK-C: store i32 61451
// CHECK-CPP0X: store i32 61451
@@ -65,13 +79,6 @@ int main() {
wchar_t wd = L'\U0010F00B';
#if __cplusplus >= 201103L
- // Should take lower word of the 4byte UNC sequence. This does not match
- // gcc. I don't understand what gcc does (it looks like it converts to utf16,
- // then takes the second (!) utf16 word, swaps the lower two nibbles, and
- // stores that?).
- // CHECK-CPP0X: store i16 -4085
- char16_t ud = u'\U0010F00B'; // has utf16 encoding dbc8 dcb0
-
// CHECK-CPP0X: store i32 1110027
char32_t Ud = U'\U0010F00B';
#endif
@@ -80,14 +87,4 @@ int main() {
// CHECK-C: store i32 1110027
// CHECK-CPP0X: store i32 1110027
wchar_t we = L'\u1234\U0010F00B';
-
-#if __cplusplus >= 201103L
- // Should pick second character.
- // CHECK-CPP0X: store i16 -4085
- char16_t ue = u'\u1234\U0010F00B';
-
- // Should pick second character.
- // CHECK-CPP0X: store i32 1110027
- char32_t Ue = U'\u1234\U0010F00B';
-#endif
}
diff --git a/test/CodeGen/complex-indirect.c b/test/CodeGen/complex-indirect.c
index 45eb195..0daa970 100644
--- a/test/CodeGen/complex-indirect.c
+++ b/test/CodeGen/complex-indirect.c
@@ -1,10 +1,12 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o %t -triple=x86_64-apple-darwin10
+// RUN: FileCheck < %t %s
-// Make sure this doesn't crash, and that we don't generate a byval alloca
-// with insufficient alignment.
+// Make sure this doesn't crash. We used to generate a byval here and wanted to
+// verify a valid alignment, but we now realize we can use an i16 and let the
+// backend guarantee the alignment.
void a(int,int,int,int,int,int,__complex__ char);
void b(__complex__ char *y) { a(0,0,0,0,0,0,*y); }
// CHECK: define void @b
// CHECK: alloca { i8, i8 }*, align 8
-// CHECK: call void @a(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { i8, i8 }* byval align 8
+// CHECK: call void @a(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i16 {{.*}})
diff --git a/test/CodeGen/complex-init-list.c b/test/CodeGen/complex-init-list.c
index 819d4f9..99c1c62 100644
--- a/test/CodeGen/complex-init-list.c
+++ b/test/CodeGen/complex-init-list.c
@@ -9,4 +9,10 @@ _Complex float x = { 1.0f, 1.0f/0.0f };
_Complex float f(float x, float y) { _Complex float z = { x, y }; return z; }
// CHECK: define <2 x float> @f
-// CHECK: alloca { float, float } \ No newline at end of file
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }
+
+_Complex float f2(float x, float y) { return (_Complex float){ x, y }; }
+// CHECK: define <2 x float> @f2
+// CHECK: alloca { float, float }
+// CHECK: alloca { float, float }
diff --git a/test/CodeGen/compound-literal.c b/test/CodeGen/compound-literal.c
index 0164c2b..969c5af 100644
--- a/test/CodeGen/compound-literal.c
+++ b/test/CodeGen/compound-literal.c
@@ -2,8 +2,9 @@
int* a = &(int){1};
struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
-// Not working; complex constants are broken
-// _Complex double * x = &(_Complex double){1.0f};
+_Complex double * x = &(_Complex double){1.0f};
+typedef int v4i32 __attribute((vector_size(16)));
+v4i32 *y = &(v4i32){1,2,3,4};
void xxx() {
int* a = &(int){1};
diff --git a/test/CodeGen/conditional.c b/test/CodeGen/conditional.c
index 15e15f1..88538a2 100644
--- a/test/CodeGen/conditional.c
+++ b/test/CodeGen/conditional.c
@@ -66,3 +66,9 @@ int test11(int c) {
double test12(int c) {
return c ? 4.0 : 2.0;
}
+// CHECK: @test13
+// CHECK: call {{.*}} @f2(
+int f2(void);
+void test13() {
+ f2() ? (void)0 : (void)0;
+}
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c
index 9bc3bba..4f3f7ab 100644
--- a/test/CodeGen/const-init.c
+++ b/test/CodeGen/const-init.c
@@ -132,3 +132,15 @@ int g25() {
void g27() { // PR8073
static void *x = &x;
}
+
+void g28() {
+ typedef long long v1i64 __attribute((vector_size(8)));
+ typedef short v12i16 __attribute((vector_size(24)));
+ typedef long double v2f80 __attribute((vector_size(24)));
+ // CHECK: @g28.a = internal global <1 x i64> <i64 10>
+ // CHECK: @g28.b = internal global <12 x i16> <i16 0, i16 0, i16 0, i16 -32768, i16 16383, i16 0, i16 0, i16 0, i16 0, i16 -32768, i16 16384, i16 0>
+ // CHECK: @g28.c = internal global <2 x x86_fp80> <x86_fp80 0xK3FFF8000000000000000, x86_fp80 0xK40008000000000000000>, align 32
+ static v1i64 a = (v1i64)10LL;
+ static v12i16 b = (v2f80){1,2};
+ static v2f80 c = (v12i16){0,0,0,-32768,16383,0,0,0,0,-32768,16384,0};
+}
diff --git a/test/CodeGen/count-builtins.c b/test/CodeGen/count-builtins.c
new file mode 100644
index 0000000..e6133c5
--- /dev/null
+++ b/test/CodeGen/count-builtins.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+int leading, trailing, pop;
+
+void test_i16(short P) {
+ leading = __builtin_clzs(P);
+ trailing = __builtin_ctzs(P);
+
+// CHECK: @test_i16
+// CHECK: call i16 @llvm.ctlz.i16
+// CHECK: call i16 @llvm.cttz.i16
+}
+
+void test_i32(int P) {
+ leading = __builtin_clz(P);
+ trailing = __builtin_ctz(P);
+ pop = __builtin_popcount(P);
+
+// CHECK: @test_i32
+// CHECK: call i32 @llvm.ctlz.i32
+// CHECK: call i32 @llvm.cttz.i32
+// CHECK: call i32 @llvm.ctpop.i32
+}
+
+void test_i64(float P) {
+ leading = __builtin_clzll(P);
+ trailing = __builtin_ctzll(P);
+ pop = __builtin_popcountll(P);
+// CHECK: @test_i64
+// CHECK: call i64 @llvm.ctlz.i64
+// CHECK: call i64 @llvm.cttz.i64
+// CHECK: call i64 @llvm.ctpop.i64
+}
diff --git a/test/CodeGen/darwin-string-literals.c b/test/CodeGen/darwin-string-literals.c
index 6f9e0d2..968386a 100644
--- a/test/CodeGen/darwin-string-literals.c
+++ b/test/CodeGen/darwin-string-literals.c
@@ -2,13 +2,16 @@
// CHECK-LSB: @.str = private unnamed_addr constant [8 x i8] c"string0\00"
// CHECK-LSB: @.str1 = linker_private unnamed_addr constant [8 x i8] c"string1\00"
-// CHECK-LSB: @.str2 = internal unnamed_addr constant [36 x i8] c"h\00e\00l\00l\00o\00 \00\92! \00\03& \00\90! \00w\00o\00r\00l\00d\00\00\00", align 2
+// CHECK-LSB: @.str2 = internal unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], align 2
+// CHECK-LSB: @.str4 = internal unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], align 2
+
// RUN: %clang_cc1 -triple powerpc-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix MSB %s
// CHECK-MSB: @.str = private unnamed_addr constant [8 x i8] c"string0\00"
// CHECK-MSB: @.str1 = linker_private unnamed_addr constant [8 x i8] c"string1\00"
-// CHECK-MSB: @.str2 = internal unnamed_addr constant [36 x i8] c"\00h\00e\00l\00l\00o\00 !\92\00 &\03\00 !\90\00 \00w\00o\00r\00l\00d\00\00", align 2
+// CHECK-MSB: @.str2 = internal unnamed_addr constant [18 x i16] [i16 104, i16 101, i16 108, i16 108, i16 111, i16 32, i16 8594, i16 32, i16 9731, i16 32, i16 8592, i16 32, i16 119, i16 111, i16 114, i16 108, i16 100, i16 0], align 2
+// CHECK-MSB: @.str4 = internal unnamed_addr constant [6 x i16] [i16 116, i16 101, i16 115, i16 116, i16 8482, i16 0], align 2
const char *g0 = "string0";
const void *g1 = __builtin___CFStringMakeConstantString("string1");
diff --git a/test/CodeGen/debug-info-args.c b/test/CodeGen/debug-info-args.c
new file mode 100644
index 0000000..1d4ea10
--- /dev/null
+++ b/test/CodeGen/debug-info-args.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -g %s | FileCheck %s
+
+int somefunc(char *x, int y, double z) {
+
+ // CHECK: {{.*metadata !8, i32 0, i32 0}.*DW_TAG_subroutine_type}}
+ // CHECK: {{!8 = .*metadata ![^,]*, metadata ![^,]*, metadata ![^,]*, metadata ![^,]*}}
+
+ return y;
+}
diff --git a/test/CodeGen/debug-info-block.c b/test/CodeGen/debug-info-block.c
new file mode 100644
index 0000000..403e4aa
--- /dev/null
+++ b/test/CodeGen/debug-info-block.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fblocks -g -emit-llvm -o - %s | FileCheck %s
+// APPLE LOCAL file 5939894 */
+// Verify that the desired debugging type is generated for a structure
+// member that is a pointer to a block.
+
+// CHECK: __block_literal_generic{{.*}}DW_TAG_structure_type
+// CHECK: __block_descriptor{{.*}}DW_TAG_structure_type
+struct inStruct {
+ void (^genericBlockPtr)();
+} is;
+
diff --git a/test/CodeGen/debug-info-compilation-dir.c b/test/CodeGen/debug-info-compilation-dir.c
new file mode 100644
index 0000000..4b47299
--- /dev/null
+++ b/test/CodeGen/debug-info-compilation-dir.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm -g %s -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
+// CHECK-NONSENSE: nonsense
+
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck -check-prefix=CHECK-DIR %s
+// CHECK-DIR: CodeGen
+
diff --git a/test/CodeGen/debug-info-iv.c b/test/CodeGen/debug-info-iv.c
index 1d9bf32..6684fe3 100644
--- a/test/CodeGen/debug-info-iv.c
+++ b/test/CodeGen/debug-info-iv.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -Os -S -g -o - %s | FileCheck %s
+// REQUIRES: x86-registered-target
int calculate(int);
static void test_indvars(int *Array1, int Array2[100][200]) {
@@ -26,7 +27,7 @@ int main() {
Array[i][j] = 0;
test_indvars(Array[0], Array);
-//CHECK: .loc 2 30 8
+//CHECK: .loc 2 31 8
for (i=0; i < 100; i+=2)
for (j=0; j < 200; j++)
sum += Array[i][j];
diff --git a/test/CodeGen/debug-info-static.c b/test/CodeGen/debug-info-static.c
new file mode 100644
index 0000000..e75d20f
--- /dev/null
+++ b/test/CodeGen/debug-info-static.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: xyzzy} ; [ DW_TAG_variable ]
+void f(void)
+{
+ static int xyzzy;
+ xyzzy += 3;
+}
diff --git a/test/CodeGen/debug-line-1.c b/test/CodeGen/debug-line-1.c
new file mode 100644
index 0000000..00d4f42
--- /dev/null
+++ b/test/CodeGen/debug-line-1.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -o - -emit-llvm -g %s | FileCheck %s
+// REQUIRES: asserts
+// PR9796
+
+// Check to make sure that we emit the block for the break so that we can count the line.
+// CHECK: sw.bb: ; preds = %entry
+// CHECK: br label %sw.epilog, !dbg !21
+
+extern int atoi(const char *);
+
+int f(char* arg) {
+ int x = atoi(arg);
+
+ switch(x) {
+ case 1:
+ break;
+ }
+
+ return 0;
+}
diff --git a/test/CodeGen/decl-in-prototype.c b/test/CodeGen/decl-in-prototype.c
new file mode 100644
index 0000000..949793d
--- /dev/null
+++ b/test/CodeGen/decl-in-prototype.c
@@ -0,0 +1,21 @@
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck %s
+
+const int AA = 5;
+
+// CHECK: define i32 @f1
+int f1(enum {AA,BB} E) {
+ // CHECK: ret i32 1
+ return BB;
+}
+
+// CHECK: define i32 @f2
+int f2(enum {AA=7,BB} E) {
+ // CHECK: ret i32 7
+ return AA;
+}
+
+// Check nested function declarators work.
+int f(void (*g)(), enum {AA,BB} h) {
+ // CHECK: ret i32 0
+ return AA;
+}
diff --git a/test/CodeGen/ext-vector-member-alignment.c b/test/CodeGen/ext-vector-member-alignment.c
new file mode 100644
index 0000000..49e6997
--- /dev/null
+++ b/test/CodeGen/ext-vector-member-alignment.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+struct __attribute__((packed, aligned(4))) struct1 {
+ float4 position;
+};
+int x = __alignof(struct struct1);
+
+float4 f(struct struct1* x) { return x->position; }
+
+void func(struct struct1* p, float *a, float *b, float c) {
+ p->position.x = c;
+ *a = p->position.y;
+ *b = p->position[0];
+ p->position[2] = c;
+ // FIXME: We should be able to come up with a more aggressive alignment
+ // estimate.
+ // CHECK: @func
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: store <4 x float> {{%.*}}, <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: load <4 x float>* {{%.*}}, align 1
+ // CHECK: store <4 x float> {{%.*}}, <4 x float>* {{%.*}}, align 1
+ // CHECK: ret void
+}
diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c
index a222f94..a9fa151 100644
--- a/test/CodeGen/ext-vector.c
+++ b/test/CodeGen/ext-vector.c
@@ -252,7 +252,8 @@ int4 test13(int4 *V) {
void test14(uint4 *ap, uint4 *bp, unsigned c) {
uint4 a = *ap;
uint4 b = *bp;
-
+ int4 d;
+
// CHECK: udiv <4 x i32>
// CHECK: urem <4 x i32>
a = a / b;
@@ -269,10 +270,19 @@ void test14(uint4 *ap, uint4 *bp, unsigned c) {
// CHECK: icmp uge
// CHECK: icmp eq
// CHECK: icmp ne
- a = a < b;
- a = a <= b;
- a = a > b;
- a = a >= b;
- a = a == b;
- a = a != b;
+ d = a < b;
+ d = a <= b;
+ d = a > b;
+ d = a >= b;
+ d = a == b;
+ d = a != b;
+}
+
+// CHECK: @test15
+int4 test15(uint4 V0) {
+ // CHECK: icmp eq <4 x i32>
+ int4 V = !V0;
+ V = V && V;
+ V = V || V;
+ return V;
}
diff --git a/test/CodeGen/fma4-builtins.c b/test/CodeGen/fma4-builtins.c
new file mode 100644
index 0000000..ddbaba7
--- /dev/null
+++ b/test/CodeGen/fma4-builtins.c
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma4 -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+__m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ps
+ return _mm_macc_ps(a, b, c);
+}
+
+__m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.pd
+ return _mm_macc_pd(a, b, c);
+}
+
+__m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ss
+ return _mm_macc_ss(a, b, c);
+}
+
+__m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.sd
+ return _mm_macc_sd(a, b, c);
+}
+
+__m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ps
+ return _mm_msub_ps(a, b, c);
+}
+
+__m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.pd
+ return _mm_msub_pd(a, b, c);
+}
+
+__m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ss
+ return _mm_msub_ss(a, b, c);
+}
+
+__m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.sd
+ return _mm_msub_sd(a, b, c);
+}
+
+__m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ps
+ return _mm_nmacc_ps(a, b, c);
+}
+
+__m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.pd
+ return _mm_nmacc_pd(a, b, c);
+}
+
+__m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ss
+ return _mm_nmacc_ss(a, b, c);
+}
+
+__m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.sd
+ return _mm_nmacc_sd(a, b, c);
+}
+
+__m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ps
+ return _mm_nmsub_ps(a, b, c);
+}
+
+__m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.pd
+ return _mm_nmsub_pd(a, b, c);
+}
+
+__m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ss
+ return _mm_nmsub_ss(a, b, c);
+}
+
+__m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.sd
+ return _mm_nmsub_sd(a, b, c);
+}
+
+__m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.ps
+ return _mm_maddsub_ps(a, b, c);
+}
+
+__m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.pd
+ return _mm_maddsub_pd(a, b, c);
+}
+
+__m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.ps
+ return _mm_msubadd_ps(a, b, c);
+}
+
+__m128d test_mm_msubadd_pd(__m128d a, __m128d b, __m128d c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.pd
+ return _mm_msubadd_pd(a, b, c);
+}
+
+__m256 test_mm256_macc_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.ps.256
+ return _mm256_macc_ps(a, b, c);
+}
+
+__m256d test_mm256_macc_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmadd.pd.256
+ return _mm256_macc_pd(a, b, c);
+}
+
+__m256 test_mm256_msub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.ps.256
+ return _mm256_msub_ps(a, b, c);
+}
+
+__m256d test_mm256_msub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmsub.pd.256
+ return _mm256_msub_pd(a, b, c);
+}
+
+__m256 test_mm256_nmacc_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.ps.256
+ return _mm256_nmacc_ps(a, b, c);
+}
+
+__m256d test_mm256_nmacc_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfnmadd.pd.256
+ return _mm256_nmacc_pd(a, b, c);
+}
+
+__m256 test_mm256_nmsub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.ps.256
+ return _mm256_nmsub_ps(a, b, c);
+}
+
+__m256d test_mm256_nmsub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfnmsub.pd.256
+ return _mm256_nmsub_pd(a, b, c);
+}
+
+__m256 test_mm256_maddsub_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.ps.256
+ return _mm256_maddsub_ps(a, b, c);
+}
+
+__m256d test_mm256_maddsub_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmaddsub.pd.256
+ return _mm256_maddsub_pd(a, b, c);
+}
+
+__m256 test_mm256_msubadd_ps(__m256 a, __m256 b, __m256 c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.ps.256
+ return _mm256_msubadd_ps(a, b, c);
+}
+
+__m256d test_mm256_msubadd_pd(__m256d a, __m256d b, __m256d c) {
+ // CHECK: @llvm.x86.fma4.vfmsubadd.pd.256
+ return _mm256_msubadd_pd(a, b, c);
+}
diff --git a/test/CodeGen/frame-pointer-elim.c b/test/CodeGen/frame-pointer-elim.c
index 4e8e946..b105a19 100644
--- a/test/CodeGen/frame-pointer-elim.c
+++ b/test/CodeGen/frame-pointer-elim.c
@@ -1,6 +1,6 @@
// REQUIRES: x86-registered-target
-// RUN: %clang -ccc-host-triple i386-apple-darwin -S -o - %s | \
+// RUN: %clang -target i386-apple-darwin -S -o - %s | \
// RUN: FileCheck --check-prefix=DARWIN %s
// DARWIN: f0:
// DARWIN: pushl %ebp
@@ -9,7 +9,7 @@
// DARWIN: pushl %ebp
// DARWIN: ret
-// RUN: %clang -ccc-host-triple i386-pc-linux-gnu -S -o - %s | \
+// RUN: %clang -target i386-pc-linux-gnu -S -o - %s | \
// RUN: FileCheck --check-prefix=LINUX %s
// LINUX: f0:
// LINUX-NOT: pushl %ebp
@@ -18,7 +18,7 @@
// LINUX: pushl %ebp
// LINUX: ret
-// RUN: %clang -ccc-host-triple i386-darwin -S -o - -fomit-frame-pointer %s | \
+// RUN: %clang -target i386-darwin -S -o - -fomit-frame-pointer %s | \
// RUN: FileCheck --check-prefix=OMIT_ALL %s
// OMIT_ALL: f0:
// OMIT_ALL-NOT: pushl %ebp
@@ -27,7 +27,7 @@
// OMIT_ALL-NOT: pushl %ebp
// OMIT_ALL: ret
-// RUN: %clang -ccc-host-triple i386-darwin -S -o - -momit-leaf-frame-pointer %s | \
+// RUN: %clang -target i386-darwin -S -o - -momit-leaf-frame-pointer %s | \
// RUN: FileCheck --check-prefix=OMIT_LEAF %s
// OMIT_LEAF: f0:
// OMIT_LEAF-NOT: pushl %ebp
diff --git a/test/CodeGen/global-init.c b/test/CodeGen/global-init.c
index 074c2a0..dab5a07 100644
--- a/test/CodeGen/global-init.c
+++ b/test/CodeGen/global-init.c
@@ -32,7 +32,7 @@ struct ManyFields FewInits = {1, 2};
// PR6766
-// CHECK: @l = global { [24 x i8], i32 } { [24 x i8] c"f\00\00\00o\00\00\00o\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i32 1 }
+// CHECK: @l = global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
typedef __WCHAR_TYPE__ wchar_t;
struct K {
wchar_t L[6];
diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c
index 599b4f2..426233d 100644
--- a/test/CodeGen/init.c
+++ b/test/CodeGen/init.c
@@ -123,3 +123,10 @@ struct test12 {
struct test12 (*p)(void);
} test12g;
+
+void test13(int x) {
+ struct X { int a; int b : 10; int c; };
+ struct X y = {.c = x};
+ // CHECK: @test13
+ // CHECK: and i32 {{.*}}, -1024
+}
diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c
index 6bc583df..2a01f25 100644
--- a/test/CodeGen/inline.c
+++ b/test/CodeGen/inline.c
@@ -13,8 +13,14 @@
// RUN: grep "define available_externally i32 @test4" %t
// RUN: grep "define available_externally i32 @test5" %t
// RUN: grep "define i32 @test6" %t
-
-// RUN: echo "\nC99 tests:"
+// RUN: grep "define void @test7" %t
+// RUN: grep "define i.. @strlcpy" %t
+// RUN: not grep test9 %t
+// RUN: grep "define void @testA" %t
+// RUN: grep "define void @testB" %t
+// RUN: grep "define void @testC" %t
+
+// RUN: echo "C99 tests:"
// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=gnu99
// RUN: grep "define i32 @ei()" %t
// RUN: grep "define available_externally i32 @foo()" %t
@@ -29,9 +35,14 @@
// RUN: grep "define available_externally i32 @test4" %t
// RUN: grep "define available_externally i32 @test5" %t
// RUN: grep "define i32 @test6" %t
+// RUN: grep "define void @test7" %t
// RUN: grep "define available_externally i.. @strlcpy" %t
+// RUN: grep "define void @test9" %t
+// RUN: grep "define void @testA" %t
+// RUN: grep "define void @testB" %t
+// RUN: grep "define void @testC" %t
-// RUN: echo "\nC++ tests:"
+// RUN: echo "C++ tests:"
// RUN: %clang -x c++ %s -O1 -emit-llvm -S -o %t -std=c++98
// RUN: grep "define linkonce_odr i32 @_Z2eiv()" %t
// RUN: grep "define linkonce_odr i32 @_Z3foov()" %t
@@ -102,3 +113,17 @@ void test7();
// PR11062; the fact that the function is named strlcpy matters here.
inline __typeof(sizeof(int)) strlcpy(char *dest, const char *src, __typeof(sizeof(int)) size) { return 3; }
void test8() { strlcpy(0,0,0); }
+
+// PR10657; the test crashed in C99 mode
+extern inline void test9() { }
+void test9();
+
+inline void testA() {}
+void testA();
+
+void testB();
+inline void testB() {}
+extern void testB();
+
+extern inline void testC() {}
+inline void testC();
diff --git a/test/CodeGen/kr-call.c b/test/CodeGen/kr-call.c
deleted file mode 100644
index ea4e3d3..0000000
--- a/test/CodeGen/kr-call.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -triple s390x-unknown-linux -emit-llvm -o - %s | FileCheck %s
-
-// Test that we don't crash. The s390x-unknown-linux target happens
-// to need to set a sext argument attribute on this call, and we need
-// to make sure that rewriting it correctly keeps that attribute.
-void test0_helper();
-void test0() {
- // CHECK: call void bitcast (void ()* @test0_helper to void (i32)*)(i32 signext 1)
- test0_helper(1);
-}
-void test0_helper() {}
-
diff --git a/test/CodeGen/libcalls-fno-builtin.c b/test/CodeGen/libcalls-fno-builtin.c
new file mode 100644
index 0000000..ce10759
--- /dev/null
+++ b/test/CodeGen/libcalls-fno-builtin.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck %s
+// rdar://10551066
+
+double ceil(double x);
+double copysign(double,double);
+double cos(double x);
+double fabs(double x);
+double floor(double x);
+
+double t1(double x) { return ceil(x); }
+// CHECK: t1
+// CHECK: ceil
+
+double t2(double x, double y) { return copysign(x,y); }
+// CHECK: t2
+// CHECK: copysign
+
+double t3(double x) { return cos(x); }
+// CHECK: t3
+// CHECK: cos
+
+double t4(double x) { return fabs(x); }
+// CHECK: t4
+// CHECK: fabs
+
+double t5(double x) { return floor(x); }
+// CHECK: t5
+// CHECK: floor
diff --git a/test/CodeGen/lifetime.c b/test/CodeGen/lifetime.c
new file mode 100644
index 0000000..2203840
--- /dev/null
+++ b/test/CodeGen/lifetime.c
@@ -0,0 +1,23 @@
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s -check-prefix=O1
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
+// RUN: %clang -S -emit-llvm -o - -O3 %s | FileCheck %s -check-prefix=O3
+
+extern void use(char *a);
+
+__attribute__((always_inline)) void helper_no_markers() {
+ char a;
+ use(&a);
+}
+
+void lifetime_test() {
+// O0: lifetime_test
+// O1: lifetime_test
+// O2: lifetime_test
+// O3: lifetime_test
+// O0-NOT: @llvm.lifetime.start
+// O1: @llvm.lifetime.start
+// O2: @llvm.lifetime.start
+// O3: @llvm.lifetime.start
+ helper_no_markers();
+}
diff --git a/test/CodeGen/link-bitcode-file.c b/test/CodeGen/link-bitcode-file.c
new file mode 100644
index 0000000..7740406
--- /dev/null
+++ b/test/CodeGen/link-bitcode-file.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NO-BC %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -DBITCODE -mlink-bitcode-file %t.bc -O3 -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-BC %s
+
+int f(void);
+
+#ifdef BITCODE
+
+// CHECK-BC: 'f': symbol multiply defined
+int f(void) {
+ return 42;
+}
+
+#else
+
+// CHECK-NO-BC: define i32 @g
+// CHECK-NO-BC: ret i32 42
+int g(void) {
+ return f();
+}
+
+// CHECK-NO-BC: define i32 @f
+
+#endif
diff --git a/test/CodeGen/lzcnt-builtins.c b/test/CodeGen/lzcnt-builtins.c
new file mode 100644
index 0000000..a43c4ee
--- /dev/null
+++ b/test/CodeGen/lzcnt-builtins.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +lzcnt -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned short test__lzcnt16(unsigned short __X)
+{
+ // CHECK: @llvm.ctlz.i16
+ return __lzcnt16(__X);
+}
+
+unsigned int test_lzcnt32(unsigned int __X)
+{
+ // CHECK: @llvm.ctlz.i32
+ return __lzcnt32(__X);
+}
+
+unsigned long long test__lzcnt64(unsigned long long __X)
+{
+ // CHECK: @llvm.ctlz.i64
+ return __lzcnt64(__X);
+}
diff --git a/test/CodeGen/mips-clobber-reg.c b/test/CodeGen/mips-clobber-reg.c
new file mode 100644
index 0000000..2a06e53
--- /dev/null
+++ b/test/CodeGen/mips-clobber-reg.c
@@ -0,0 +1,80 @@
+// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -S -o - -emit-llvm %s
+
+/*
+ This checks that the frontend will accept both
+ enumerated and symbolic Mips GPR register names.
+
+ Any bad names will make the frontend choke.
+ */
+
+main()
+{
+
+ __asm__ __volatile__ (".set noat \n\t addi $7,$at,77":::"at");
+ __asm__ __volatile__ ("addi $7,$v0,77":::"v0");
+ __asm__ __volatile__ ("addi $7,$v1,77":::"v1");
+ __asm__ __volatile__ ("addi $7,$a0,77":::"a0");
+ __asm__ __volatile__ ("addi $7,$a1,77":::"a1");
+ __asm__ __volatile__ ("addi $7,$a2,77":::"a2");
+ __asm__ __volatile__ ("addi $7,$a3,77":::"a3");
+ __asm__ __volatile__ ("addi $7,$t0,77":::"t0");
+ __asm__ __volatile__ ("addi $7,$t1,77":::"t1");
+ __asm__ __volatile__ ("addi $7,$t2,77":::"t2");
+ __asm__ __volatile__ ("addi $7,$t3,77":::"t3");
+ __asm__ __volatile__ ("addi $7,$t4,77":::"t4");
+ __asm__ __volatile__ ("addi $7,$t5,77":::"t5");
+ __asm__ __volatile__ ("addi $7,$t6,77":::"t6");
+ __asm__ __volatile__ ("addi $7,$t7,77":::"t7");
+ __asm__ __volatile__ ("addi $7,$s0,77":::"s0");
+ __asm__ __volatile__ ("addi $7,$s1,77":::"s1");
+ __asm__ __volatile__ ("addi $7,$s2,77":::"s2");
+ __asm__ __volatile__ ("addi $7,$s3,77":::"s3");
+ __asm__ __volatile__ ("addi $7,$s4,77":::"s4");
+ __asm__ __volatile__ ("addi $7,$s5,77":::"s5");
+ __asm__ __volatile__ ("addi $7,$s6,77":::"s6");
+ __asm__ __volatile__ ("addi $7,$s7,77":::"s7");
+ __asm__ __volatile__ ("addi $7,$t8,77":::"t8");
+ __asm__ __volatile__ ("addi $7,$t9,77":::"t9");
+ __asm__ __volatile__ ("addi $7,$k0,77":::"k0");
+ __asm__ __volatile__ ("addi $7,$k1,77":::"k1");
+ __asm__ __volatile__ ("addi $7,$gp,77":::"gp");
+ __asm__ __volatile__ ("addi $7,$sp,77":::"sp");
+ __asm__ __volatile__ ("addi $7,$fp,77":::"fp");
+ __asm__ __volatile__ ("addi $7,$sp,77":::"$sp");
+ __asm__ __volatile__ ("addi $7,$fp,77":::"$fp");
+ __asm__ __volatile__ ("addi $7,$ra,77":::"ra");
+
+ __asm__ __volatile__ ("addi $7,$0,77":::"$0");
+ __asm__ __volatile__ (".set noat \n\t addi $7,$1,77":::"$1");
+ __asm__ __volatile__ ("addi $7,$2,77":::"$2");
+ __asm__ __volatile__ ("addi $7,$3,77":::"$3");
+ __asm__ __volatile__ ("addi $7,$4,77":::"$4");
+ __asm__ __volatile__ ("addi $7,$5,77":::"$5");
+ __asm__ __volatile__ ("addi $7,$6,77":::"$6");
+ __asm__ __volatile__ ("addi $7,$7,77":::"$7");
+ __asm__ __volatile__ ("addi $7,$8,77":::"$8");
+ __asm__ __volatile__ ("addi $7,$9,77":::"$9");
+ __asm__ __volatile__ ("addi $7,$10,77":::"$10");
+ __asm__ __volatile__ ("addi $7,$11,77":::"$10");
+ __asm__ __volatile__ ("addi $7,$12,77":::"$12");
+ __asm__ __volatile__ ("addi $7,$13,77":::"$13");
+ __asm__ __volatile__ ("addi $7,$14,77":::"$14");
+ __asm__ __volatile__ ("addi $7,$15,77":::"$15");
+ __asm__ __volatile__ ("addi $7,$16,77":::"$16");
+ __asm__ __volatile__ ("addi $7,$17,77":::"$17");
+ __asm__ __volatile__ ("addi $7,$18,77":::"$18");
+ __asm__ __volatile__ ("addi $7,$19,77":::"$19");
+ __asm__ __volatile__ ("addi $7,$20,77":::"$20");
+ __asm__ __volatile__ ("addi $7,$21,77":::"$21");
+ __asm__ __volatile__ ("addi $7,$22,77":::"$22");
+ __asm__ __volatile__ ("addi $7,$23,77":::"$23");
+ __asm__ __volatile__ ("addi $7,$24,77":::"$24");
+ __asm__ __volatile__ ("addi $7,$25,77":::"$25");
+ __asm__ __volatile__ ("addi $7,$26,77":::"$26");
+ __asm__ __volatile__ ("addi $7,$27,77":::"$27");
+ __asm__ __volatile__ ("addi $7,$28,77":::"$28");
+ __asm__ __volatile__ ("addi $7,$29,77":::"$29");
+ __asm__ __volatile__ ("addi $7,$30,77":::"$30");
+ __asm__ __volatile__ ("addi $7,$31,77":::"$31");
+
+}
diff --git a/test/CodeGen/mips-constraint-regs.c b/test/CodeGen/mips-constraint-regs.c
new file mode 100644
index 0000000..075be05
--- /dev/null
+++ b/test/CodeGen/mips-constraint-regs.c
@@ -0,0 +1,44 @@
+// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -S -o - -emit-llvm %s
+
+// This checks that the frontend will accept inline asm constraints
+// c', 'l' and 'x'. Semantic checking will happen in the
+// llvm backend. Any bad constraint letters will cause the frontend to
+// error out.
+
+int main()
+{
+ // 'c': 16 bit address register for Mips16, GPR for all others
+ // I am using 'c' to constrain both the target and one of the source
+ // registers. We are looking for syntactical correctness.
+ int __s, __v = 17;
+ int __t;
+ __asm__ __volatile__(
+ "addi %0,%1,%2 \n\t\t"
+ : "=c" (__t)
+ : "c" (__s), "I" (__v));
+
+ // 'l': lo register
+ // We are making it clear that destination register is lo with the
+ // use of the 'l' constraint ("=l").
+ int i_temp = 44;
+ int i_result;
+ __asm__ __volatile__(
+ "mtlo %1 \n\t\t"
+ : "=l" (i_result)
+ : "r" (i_temp)
+ : "lo");
+
+ // 'x': Combined lo/hi registers
+ // We are specifying that destination registers are the hi/lo pair with the
+ // use of the 'x' constraint ("=x").
+ int i_hi = 3;
+ int i_lo = 2;
+ long long ll_result = 0;
+ __asm__ __volatile__(
+ "mthi %1 \n\t\t"
+ "mtlo %2 \n\t\t"
+ : "=x" (ll_result)
+ : "r" (i_hi), "r" (i_lo)
+ : );
+ return 0;
+}
diff --git a/test/CodeGen/mips64-class-return.cpp b/test/CodeGen/mips64-class-return.cpp
new file mode 100644
index 0000000..dc9ec0f
--- /dev/null
+++ b/test/CodeGen/mips64-class-return.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+class B0 {
+ double d;
+};
+
+class D0 : public B0 {
+ float f;
+};
+
+class B1 {
+};
+
+class D1 : public B1 {
+ double d;
+ float f;
+};
+
+class D2 : public B0 {
+ double d2;
+};
+
+extern D0 gd0;
+extern D1 gd1;
+extern D2 gd2;
+
+// CHECK: define { i64, i64 } @_Z4foo1v()
+D0 foo1(void) {
+ return gd0;
+}
+
+// CHECK: define { double, float } @_Z4foo2v()
+D1 foo2(void) {
+ return gd1;
+}
+
+// CHECK: define void @_Z4foo32D2(i64 %a0.coerce0, double %a0.coerce1)
+void foo3(D2 a0) {
+ gd2 = a0;
+}
+
+// CHECK: define void @_Z4foo42D0(%class.D0* nocapture byval %a0)
+void foo4(D0 a0) {
+ gd0 = a0;
+}
+
diff --git a/test/CodeGen/mips64-f128-literal.c b/test/CodeGen/mips64-f128-literal.c
new file mode 100644
index 0000000..2f01520
--- /dev/null
+++ b/test/CodeGen/mips64-f128-literal.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+typedef long double LD;
+
+// CHECK: ret fp128
+
+LD foo0() {
+ return 2.625L;
+}
diff --git a/test/CodeGen/mips64-nontrivial-return.cpp b/test/CodeGen/mips64-nontrivial-return.cpp
new file mode 100644
index 0000000..8aff9ab
--- /dev/null
+++ b/test/CodeGen/mips64-nontrivial-return.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+class B {
+public:
+ virtual ~B() {}
+};
+
+class D : public B {
+};
+
+extern D gd0;
+
+// CHECK: _Z4foo1v(%class.D* noalias nocapture sret
+
+D foo1(void) {
+ return gd0;
+}
diff --git a/test/CodeGen/mips64-padding-arg.c b/test/CodeGen/mips64-padding-arg.c
new file mode 100644
index 0000000..b4dcfba
--- /dev/null
+++ b/test/CodeGen/mips64-padding-arg.c
@@ -0,0 +1,43 @@
+// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s
+
+typedef struct {
+ double d;
+ long double ld;
+} S0;
+
+// Insert padding to ensure arguments of type S0 are aligned to 16-byte boundaries.
+
+// CHECK: define void @foo1(i32 %a0, i64, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 %b, i64, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
+// CHECK: tail call void @foo2(i32 1, i32 2, i32 %a0, i64 undef, double %a1.coerce0, i64 %a1.coerce1, i64 %a1.coerce2, i64 %a1.coerce3, double %a2.coerce0, i64 %a2.coerce1, i64 %a2.coerce2, i64 %a2.coerce3, i32 3, i64 undef, double %a3.coerce0, i64 %a3.coerce1, i64 %a3.coerce2, i64 %a3.coerce3)
+// CHECK: declare void @foo2(i32, i32, i32, i64, double, i64, i64, i64, double, i64, i64, i64, i32, i64, double, i64, i64, i64)
+
+extern void foo2(int, int, int, S0, S0, int, S0);
+
+void foo1(int a0, S0 a1, S0 a2, int b, S0 a3) {
+ foo2(1, 2, a0, a1, a2, 3, a3);
+}
+
+// Insert padding before long double argument.
+//
+// CHECK: define void @foo3(i32 %a0, i64, fp128 %a1)
+// CHECK: tail call void @foo4(i32 1, i32 2, i32 %a0, i64 undef, fp128 %a1)
+// CHECK: declare void @foo4(i32, i32, i32, i64, fp128)
+
+extern void foo4(int, int, int, long double);
+
+void foo3(int a0, long double a1) {
+ foo4(1, 2, a0, a1);
+}
+
+// Insert padding after hidden argument.
+//
+// CHECK: define void @foo5(%struct.S0* noalias sret %agg.result, i64, fp128 %a0)
+// CHECK: call void @foo6(%struct.S0* sret %agg.result, i32 1, i32 2, i64 undef, fp128 %a0)
+// CHECK: declare void @foo6(%struct.S0* sret, i32, i32, i64, fp128)
+
+extern S0 foo6(int, int, long double);
+
+S0 foo5(long double a0) {
+ return foo6(1, 2, a0);
+}
+
diff --git a/test/CodeGen/mmx-inline-asm.c b/test/CodeGen/mmx-inline-asm.c
index 5d1371e..635e2a6 100644
--- a/test/CodeGen/mmx-inline-asm.c
+++ b/test/CodeGen/mmx-inline-asm.c
@@ -1,4 +1,4 @@
-// RUN: %clang -mmmx -ccc-host-triple i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
+// RUN: %clang -mmmx -target i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
// <rdar://problem/9091220>
#include <mmintrin.h>
diff --git a/test/CodeGen/mmx-shift-with-immediate.c b/test/CodeGen/mmx-shift-with-immediate.c
index f430d2e..ecd1881 100644
--- a/test/CodeGen/mmx-shift-with-immediate.c
+++ b/test/CodeGen/mmx-shift-with-immediate.c
@@ -1,4 +1,4 @@
-// RUN: %clang -mmmx -ccc-host-triple i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
+// RUN: %clang -mmmx -target i386-unknown-unknown -emit-llvm -S %s -o - | FileCheck %s
#include <mmintrin.h>
void shift(__m64 a, __m64 b, int c) {
diff --git a/test/CodeGen/ms-declspecs.c b/test/CodeGen/ms-declspecs.c
new file mode 100644
index 0000000..d3235ae
--- /dev/null
+++ b/test/CodeGen/ms-declspecs.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s
+
+// CHECK: define void @t3() nounwind noinline naked {
+__declspec(naked) void t3() {}
+
+// CHECK: define void @t22() nounwind
+void __declspec(nothrow) t22();
+void t22() {}
+
+// CHECK: define void @t2() nounwind noinline {
+__declspec(noinline) void t2() {}
+
+// CHECK: call void @f20_t()
+// CHECK: noreturn
+__declspec(noreturn) void f20_t(void);
+void f20(void) { f20_t(); }
diff --git a/test/CodeGen/mult-alt-generic.c b/test/CodeGen/mult-alt-generic.c
index 9ae1bbf..1665f9c 100644
--- a/test/CodeGen/mult-alt-generic.c
+++ b/test/CodeGen/mult-alt-generic.c
@@ -1,14 +1,12 @@
// RUN: %clang_cc1 -triple i686 %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple x86_64 %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple arm %s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -triple bfin %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple cellspu %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple mblaze %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple mips %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple mipsel %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple powerpc %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64 %s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -triple s390x %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple sparc %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
diff --git a/test/CodeGen/noinline.c b/test/CodeGen/noinline.c
new file mode 100644
index 0000000..e64a1a5
--- /dev/null
+++ b/test/CodeGen/noinline.c
@@ -0,0 +1,14 @@
+// Make sure -fno-inline-functions is behaving correctly.
+// rdar://10972766
+
+// RUN: %clang_cc1 -O3 -fno-inline -fno-inline-functions -emit-llvm %s -o - | FileCheck -check-prefix=NOINLINE %s
+
+inline int dont_inline_me(int a, int b) { return(a+b); }
+
+volatile int *pa = (int*) 0x1000;
+void foo() {
+// NOINLINE: @foo
+// NOINLINE: dont_inline_me
+// NOINLINE-NOT: inlinehint
+ pa[0] = dont_inline_me(pa[1],pa[2]);
+}
diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c
index 287d742..1f16d02 100644
--- a/test/CodeGen/object-size.c
+++ b/test/CodeGen/object-size.c
@@ -55,8 +55,7 @@ void test6() {
// CHECK: define void @test7
void test7() {
int i;
- // CHECK-NOT: __strcpy_chk
- // CHECK: = call i8* @__inline_strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0))
+ // CHECK: = call i64 @llvm.objectsize.i64(i8* {{.*}}@gbuf{{.*}}, i1 false)
strcpy((++i, gbuf), "Hi there");
}
diff --git a/test/CodeGen/override-layout.c b/test/CodeGen/override-layout.c
new file mode 100644
index 0000000..99c2cd6
--- /dev/null
+++ b/test/CodeGen/override-layout.c
@@ -0,0 +1,174 @@
+// RUN: %clang_cc1 -w -fdump-record-layouts %s 2> %t.layouts
+// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before 2>&1
+// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
+// RUN: diff %t.before %t.after
+// RUN: FileCheck %s < %t.after
+
+// If not explicitly disabled, set PACKED to the packed attribute.
+#ifndef PACKED
+# define PACKED __attribute__((packed))
+#endif
+
+// If not explicitly disabled, set ALIGNED16 to 16-byte alignment.
+#ifndef ALIGNED16
+# define ALIGNED16 __attribute__((aligned(16)))
+#endif
+
+// CHECK: Type: struct X0
+struct X0 {
+ int x[6] PACKED;
+};
+
+// CHECK: Type: struct X1
+struct X1 {
+ char x[13];
+ struct X0 y;
+} PACKED;
+
+// CHECK: Type: struct X2
+struct PACKED X2 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X3
+struct X3 {
+ short x PACKED;
+ int y;
+};
+
+#pragma pack(push,2)
+// CHECK: Type: struct X4
+struct X4 {
+ int x;
+ int y;
+};
+#pragma pack(pop)
+
+// CHECK: Type: struct X5
+struct PACKED X5 { double a[19]; signed char b; };
+
+// CHECK: Type: struct X6
+struct PACKED X6 { long double a; char b; };
+
+// CHECK: Type: struct X7
+struct X7 {
+ unsigned x;
+ unsigned char y;
+} PACKED;
+
+// CHECK: Type: union X8
+union X8 {
+ struct X7 x;
+ unsigned y;
+} PACKED;
+
+// CHECK: Type: struct X9
+struct X9 {
+ unsigned int x[2] PACKED;
+ unsigned int y;
+ unsigned int z PACKED;
+};
+
+// CHECK: Type: struct X10
+struct X10 {
+ unsigned int x[2] PACKED;
+ unsigned int y PACKED;
+ unsigned int z PACKED;
+};
+
+// CHECK: Type: struct X11
+struct PACKED X11 {
+ unsigned int x[2];
+ unsigned int y;
+ unsigned int z;
+};
+
+// CHECK: Type: struct X12
+struct PACKED X12 {
+ int x : 24;
+};
+
+// CHECK: Type: struct X13
+struct PACKED X13 {
+ signed x : 10;
+ signed y : 10;
+};
+
+// CHECK: Type: union X14
+union PACKED X14 {
+ unsigned long long x : 3;
+};
+
+// CHECK: Type: struct X15
+struct X15 {
+ unsigned x : 16;
+ unsigned y : 28 PACKED;
+};
+
+// CHECK: Type: struct X16
+struct ALIGNED16 X16 {
+ int a, b, c;
+ int x : 5;
+ int y : 29;
+};
+
+void use_structs() {
+ struct X0 x0;
+ x0.x[5] = sizeof(struct X0);
+
+ struct X1 x1;
+ x1.x[5] = sizeof(struct X1);
+
+ struct X2 x2;
+ x2.y = sizeof(struct X2);
+
+ struct X3 x3;
+ x3.y = sizeof(struct X3);
+
+ struct X4 x4;
+ x4.y = sizeof(struct X4);
+
+ struct X5 x5;
+ x5.b = sizeof(struct X5);
+
+ struct X6 x6;
+ x6.b = sizeof(struct X6);
+
+ struct X7 x7;
+ typedef int X7array[sizeof(struct X7)];
+ x7.x = sizeof(struct X7);
+ x7.y = x7.x;
+
+ union X8 x8;
+ typedef int X8array[sizeof(union X8)];
+ x8.y = sizeof(union X8);
+ x8.x.x = x8.y;
+
+ struct X9 x9;
+ typedef int X9array[sizeof(struct X9)];
+ x9.y = sizeof(struct X9);
+
+ struct X10 x10;
+ typedef int X10array[sizeof(struct X10)];
+ x10.y = sizeof(struct X10);
+
+ struct X11 x11;
+ typedef int X11array[sizeof(struct X11)];
+ x11.y = sizeof(struct X11);
+
+ struct X12 x12;
+ x12.x = sizeof(struct X12);
+
+ struct X13 x13;
+ x13.x = sizeof(struct X13);
+
+ union X14 x14;
+ x14.x = sizeof(union X14);
+
+ struct X15 x15;
+ x15.x = sizeof(struct X15);
+
+ struct X16 x16;
+ x16.x = sizeof(struct X16);
+}
diff --git a/test/CodeGen/packed-nest-unpacked.c b/test/CodeGen/packed-nest-unpacked.c
new file mode 100644
index 0000000..af1508a
--- /dev/null
+++ b/test/CodeGen/packed-nest-unpacked.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s
+// <rdar://problem/10463337>
+
+struct X { int x[6]; };
+struct Y { char x[13]; struct X y; } __attribute((packed));
+struct Y g;
+void f(struct X);
+
+struct X test1() {
+ // CHECK: @test1
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ return g.y;
+}
+struct X test2() {
+ // CHECK: @test2
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ struct X a = g.y;
+ return a;
+}
+
+void test3(struct X a) {
+ // CHECK: @test3
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* {{.*}}, i64 24, i32 1, i1 false)
+ g.y = a;
+}
+
+void test4() {
+ // CHECK: @test4
+ // FIXME: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ f(g.y);
+}
diff --git a/test/CodeGen/pascal-wchar-string.c b/test/CodeGen/pascal-wchar-string.c
index a6b6196..626fc99 100644
--- a/test/CodeGen/pascal-wchar-string.c
+++ b/test/CodeGen/pascal-wchar-string.c
@@ -29,8 +29,8 @@ int main(int argc, char* argv[])
return 0;
}
-// CHECK: c"\03\00b\00a\00r\00\00\00"
-// CHECK: c"\04\00g\00o\00r\00f\00\00\00"
+// CHECK: [i16 3, i16 98, i16 97, i16 114, i16 0]
+// CHECK: [i16 4, i16 103, i16 111, i16 114, i16 102, i16 0]
// PR8856 - -fshort-wchar makes wchar_t be unsigned.
diff --git a/test/CodeGen/popcnt-builtins.c b/test/CodeGen/popcnt-builtins.c
new file mode 100644
index 0000000..f072b29
--- /dev/null
+++ b/test/CodeGen/popcnt-builtins.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test_mm_popcnt_u32(unsigned int __X) {
+ // CHECK: @llvm.ctpop.i32
+ return _mm_popcnt_u32(__X);
+}
+
+unsigned long long test_mm_popcnt_u64(unsigned long long __X) {
+ // CHECK: @llvm.ctpop.i64
+ return _mm_popcnt_u64(__X);
+}
diff --git a/test/CodeGen/va_list_test.c b/test/CodeGen/powerpc_types.c
index 74f7837..b7d0f5d 100644
--- a/test/CodeGen/va_list_test.c
+++ b/test/CodeGen/powerpc_types.c
@@ -4,3 +4,7 @@
int va_list_size = sizeof(va_list);
// SVR4-CHECK: va_list_size = global i32 12, align 4
+int long_double_size = sizeof(long double);
+// SVR4-CHECK: long_double_size = global i32 8, align 4
+int double_size = sizeof(double);
+// SVR4-CHECK: double_size = global i32 8, align 4
diff --git a/test/CodeGen/pr12251.c b/test/CodeGen/pr12251.c
new file mode 100644
index 0000000..a644bb7
--- /dev/null
+++ b/test/CodeGen/pr12251.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s
+
+enum e1 {e1_a = -1 };
+enum e1 g1(enum e1 *x) {
+ return *x;
+}
+
+// CHECK: define i32 @g1
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
diff --git a/test/CodeGen/pr9614.c b/test/CodeGen/pr9614.c
index 8c76776..8fdb2f2 100644
--- a/test/CodeGen/pr9614.c
+++ b/test/CodeGen/pr9614.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -O1 -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-llvm %s -o - | FileCheck %s
extern void foo_alias (void) __asm ("foo");
inline void foo (void) {
@@ -8,15 +8,22 @@ extern void bar_alias (void) __asm ("bar");
inline __attribute__ ((__always_inline__)) void bar (void) {
return bar_alias ();
}
+extern char *strrchr_foo (const char *__s, int __c) __asm ("strrchr");
+extern inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char * strrchr_foo (const char *__s, int __c) {
+ return __builtin_strrchr (__s, __c);
+}
void f(void) {
foo();
bar();
+ strrchr_foo("", '.');
}
// CHECK: define void @f()
// CHECK: call void @foo()
// CHECK-NEXT: call void @bar()
+// CHECK-NEXT: call i8* @strrchr(
// CHECK-NEXT: ret void
// CHECK: declare void @foo()
// CHECK: declare void @bar()
+// CHECK: declare i8* @strrchr(i8*, i32)
diff --git a/test/CodeGen/redefine_extname.c b/test/CodeGen/redefine_extname.c
new file mode 100644
index 0000000..e73a3ad
--- /dev/null
+++ b/test/CodeGen/redefine_extname.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=i386-pc-solaris2.11 -w -emit-llvm %s -o - | FileCheck %s
+
+#pragma redefine_extname fake real
+#pragma redefine_extname name alias
+
+extern int fake(void);
+
+int name;
+
+// __PRAGMA_REDEFINE_EXTNAME should be defined. This will fail if it isn't...
+int fish() { return fake() + __PRAGMA_REDEFINE_EXTNAME + name; }
+// Check that the call to fake() is emitted as a call to real()
+// CHECK: call i32 @real()
+// Check that this also works with variables names
+// CHECK: load i32* @alias
diff --git a/test/CodeGen/sse-builtins.c b/test/CodeGen/sse-builtins.c
index 64ee4c9..2d57425 100644
--- a/test/CodeGen/sse-builtins.c
+++ b/test/CodeGen/sse-builtins.c
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4.1 -g -emit-llvm %s -o - | FileCheck %s
#include <emmintrin.h>
+#include <smmintrin.h>
__m128 test_loadl_pi(__m128 x, void* y) {
// CHECK: define {{.*}} @test_loadl_pi
@@ -102,3 +103,51 @@ __m128i test_loadl_epi64(void* y) {
// CHECK: load i64* {{.*}}, align 1{{$}}
return _mm_loadl_epi64(y);
}
+
+__m128i test_mm_minpos_epu16(__m128i x) {
+ // CHECK: define {{.*}} @test_mm_minpos_epu16
+ // CHECK: @llvm.x86.sse41.phminposuw
+ return _mm_minpos_epu16(x);
+}
+
+__m128i test_mm_mpsadbw_epu8(__m128i x, __m128i y) {
+ // CHECK: define {{.*}} @test_mm_mpsadbw_epu8
+ // CHECK: @llvm.x86.sse41.mpsadbw
+ return _mm_mpsadbw_epu8(x, y, 1);
+}
+
+__m128 test_mm_dp_ps(__m128 x, __m128 y) {
+ // CHECK: define {{.*}} @test_mm_dp_ps
+ // CHECK: @llvm.x86.sse41.dpps
+ return _mm_dp_ps(x, y, 2);
+}
+
+__m128d test_mm_dp_pd(__m128d x, __m128d y) {
+ // CHECK: define {{.*}} @test_mm_dp_pd
+ // CHECK: @llvm.x86.sse41.dppd
+ return _mm_dp_pd(x, y, 2);
+}
+
+__m128 test_mm_round_ps(__m128 x) {
+ // CHECK: define {{.*}} @test_mm_round_ps
+ // CHECK: @llvm.x86.sse41.round.ps
+ return _mm_round_ps(x, 2);
+}
+
+__m128 test_mm_round_ss(__m128 x, __m128 y) {
+ // CHECK: define {{.*}} @test_mm_round_ss
+ // CHECK: @llvm.x86.sse41.round.ss
+ return _mm_round_ss(x, y, 2);
+}
+
+__m128d test_mm_round_pd(__m128d x) {
+ // CHECK: define {{.*}} @test_mm_round_pd
+ // CHECK: @llvm.x86.sse41.round.pd
+ return _mm_round_pd(x, 2);
+}
+
+__m128d test_mm_round_sd(__m128d x, __m128d y) {
+ // CHECK: define {{.*}} @test_mm_round_sd
+ // CHECK: @llvm.x86.sse41.round.sd
+ return _mm_round_sd(x, y, 2);
+}
diff --git a/test/CodeGen/statements.c b/test/CodeGen/statements.c
index 1d4f633..e2bbb5a 100644
--- a/test/CodeGen/statements.c
+++ b/test/CodeGen/statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wreturn-type %s -emit-llvm-only
+// RUN: %clang_cc1 -Wno-error=return-type %s -emit-llvm-only
void test1(int x) {
switch (x) {
diff --git a/test/CodeGen/string-literal-short-wstring.c b/test/CodeGen/string-literal-short-wstring.c
index 770c3d4..88e4a1e 100644
--- a/test/CodeGen/string-literal-short-wstring.c
+++ b/test/CodeGen/string-literal-short-wstring.c
@@ -6,11 +6,11 @@ int main() {
// CHECK: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
char b[10] = "\u1120\u0220\U00102030";
- // CHECK: private unnamed_addr constant [6 x i8] c"A\00B\00\00\00"
+ // CHECK: private unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
const wchar_t *foo = L"AB";
// This should convert to utf16.
- // CHECK: private unnamed_addr constant [10 x i8] c" \11 \02\C8\DB0\DC\00\00"
+ // CHECK: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
const wchar_t *bar = L"\u1120\u0220\U00102030";
@@ -29,15 +29,4 @@ int main() {
// -4085 == 0xf00b
// CHECK: store i16 -4085
wchar_t wc = L'\uF00B';
-
- // Should take lower word of the 4byte UNC sequence. This does not match
- // gcc. I don't understand what gcc does (it looks like it converts to utf16,
- // then takes the second (!) utf16 word, swaps the lower two nibbles, and
- // stores that?).
- // CHECK: store i16 -4085
- wchar_t wd = L'\U0010F00B'; // has utf16 encoding dbc8 dcb0
-
- // Should pick second character. (gcc: -9205)
- // CHECK: store i16 -4085
- wchar_t we = L'\u1234\U0010F00B';
}
diff --git a/test/CodeGen/string-literal-unicode-conversion.c b/test/CodeGen/string-literal-unicode-conversion.c
new file mode 100644
index 0000000..3e5b7fb
--- /dev/null
+++ b/test/CodeGen/string-literal-unicode-conversion.c
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -fshort-wchar -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=SHORTWCHAR %s
+
+// This file contains a mix of ISO-8859-1 and UTF-8 encoded data.
+// the literal assigned to 'aa' should be the ISO-8859-1 encoding for the code
+// points U+00C0 U+00E9 U+00EE U+00F5 U+00FC
+
+// The rest of the literals should contain the UTF-8 encoding for U+041A U+043E
+// U+0448 U+043A U+0430
+
+#ifndef __cplusplus
+#include <stddef.h>
+#endif
+
+#ifdef __cplusplus
+extern "C"
+#endif
+void f() {
+ // CHECK-C: private unnamed_addr constant [6 x i8] c"\C0\E9\EE\F5\FC\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [6 x i8] c"\C0\E9\EE\F5\FC\00", align 1
+ char const *aa = "Àéîõü";
+
+ // CHECK-C: private unnamed_addr constant [11 x i8] c"\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ // CHECK-CPP0X: private unnamed_addr constant [11 x i8] c"\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *a = "Кошка";
+
+ // CHECK-C: private unnamed_addr constant [6 x i32] [i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [6 x i16] [i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [6 x i32] [i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ wchar_t const *b = L"Кошка";
+
+ // CHECK-C: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [4 x i16] [i16 20320, i16 22909, i16 768, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [4 x i32] [i32 20320, i32 22909, i32 66304, i32 0], align 4
+ wchar_t const *b2 = L"\x4f60\x597d\x10300";
+
+#if __cplusplus >= 201103L
+
+ // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"1\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *c = u8"1Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i16] [i16 50, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ char16_t const *e = u"2Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 51, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ char32_t const *f = U"3Кошка";
+
+ // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"4\D0\9A\D0\BE\D1\88\D0\BA\D0\B0\00", align 1
+ char const *d = u8R"(4Кошка)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i16] [i16 53, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ char16_t const *g = uR"(5Кошка)";
+
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 54, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ char32_t const *h = UR"(6Кошка)";
+
+ // CHECK-SHORTWCHAR: private unnamed_addr constant [7 x i16] [i16 55, i16 1050, i16 1086, i16 1096, i16 1082, i16 1072, i16 0], align 2
+ // CHECK-CPP0X: private unnamed_addr constant [7 x i32] [i32 55, i32 1050, i32 1086, i32 1096, i32 1082, i32 1072, i32 0], align 4
+ wchar_t const *i = LR"(7Кошка)";
+
+#endif
+}
diff --git a/test/CodeGen/string-literal.c b/test/CodeGen/string-literal.c
index fa8f28a..12d431a 100644
--- a/test/CodeGen/string-literal.c
+++ b/test/CodeGen/string-literal.c
@@ -14,37 +14,37 @@ int main() {
// CHECK-CPP0X: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
char b[10] = "\u1120\u0220\U00102030";
- // CHECK-C: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 4
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 4
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
const wchar_t *foo = L"AB";
- // CHECK-C: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 4
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 4
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
const wchar_t *bar = L"\u1234\U0010F00B";
- // CHECK-C: private unnamed_addr constant [12 x i8] c"4\12\00\00\0C\F0\10\00\00\00\00\00", align 4
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"4\12\00\00\0C\F0\10\00\00\00\00\00", align 4
+ // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
const wchar_t *baz = L"\u1234" "\U0010F00C";
#if __cplusplus >= 201103L
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"C\00\00\00D\00\00\00\00\00\00\00", align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4
const char32_t *c = U"CD";
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"5\12\00\00\0C\F0\10\00\00\00\00\00", align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4
const char32_t *d = U"\u1235\U0010F00C";
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"5\12\00\00\0B\F0\10\00\00\00\00\00", align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4
const char32_t *o = "\u1235" U"\U0010F00B";
- // CHECK-CPP0X: private unnamed_addr constant [6 x i8] c"E\00F\00\00\00", align 2
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2
const char16_t *e = u"EF";
// This should convert to utf16.
- // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c" \11 \02\C8\DB0\DC\00\00", align 2
+ // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2
const char16_t *f = u"\u1120\u0220\U00102030";
// This should convert to utf16.
- // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c" \11 \03\C8\DB0\DC\00\00", align 2
+ // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2
const char16_t *p = u"\u1120\u0320" "\U00102030";
// CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"def\00", align 1
@@ -56,13 +56,13 @@ int main() {
// CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"jkl\00", align 1
const char *i = u8R"bar(jkl)bar";
- // CHECK-CPP0X: private unnamed_addr constant [6 x i8] c"G\00H\00\00\00", align 2
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 71, i16 72, i16 0], align 2
const char16_t *j = uR"foo(GH)foo";
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"I\00\00\00J\00\00\00\00\00\00\00", align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 73, i32 74, i32 0], align 4
const char32_t *k = UR"bar(IJ)bar";
- // CHECK-CPP0X: private unnamed_addr constant [12 x i8] c"K\00\00\00L\00\00\00\00\00\00\00", align 4
+ // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 75, i32 76, i32 0], align 4
const wchar_t *l = LR"bar(KL)bar";
// CHECK-CPP0X: private unnamed_addr constant [9 x i8] c"abc\5Cndef\00", align 1
diff --git a/test/CodeGen/switch-dce.c b/test/CodeGen/switch-dce.c
index bbb5f7e..a18d3bc 100644
--- a/test/CodeGen/switch-dce.c
+++ b/test/CodeGen/switch-dce.c
@@ -216,32 +216,19 @@ void test12() {
}
}
-
-// rdar://9289524 - Check that the empty cases don't produce an empty block.
+// Verify that case 42 only calls test14 once.
// CHECK: @test13
-// CHECK: switch
-// CHECK: i32 42, label [[EPILOG:%[0-9.a-z]+]]
-// CHECK: i32 11, label [[EPILOG]]
+// CHECK: call void @test13(i32 97)
+// CHECK-NEXT: br label %[[EPILOG2:[0-9.a-z]+]]
+// CHECK: [[EPILOG2]]
+// CHECK-NEXT: br label [[EPILOG:%[0-9.a-z]+]]
+// CHECK: call void @test13(i32 42)
+// CHECK-NEXT: br label [[EPILOG]]
void test13(int x) {
switch (x) {
- case 42: break; // No empty block please.
- case 11: break; // No empty block please.
- default: test13(42); break;
- }
-}
-
-
-// Verify that case 42 only calls test14 once.
-// CHECK: @test14
-// CHECK: call void @test14(i32 97)
-// CHECK-NEXT: br label [[EPILOG2:%[0-9.a-z]+]]
-// CHECK: call void @test14(i32 42)
-// CHECK-NEXT: br label [[EPILOG2]]
-void test14(int x) {
- switch (x) {
- case 42: test14(97); // fallthrough
+ case 42: test13(97); // fallthrough
case 11: break;
- default: test14(42); break;
+ default: test13(42); break;
}
}
diff --git a/test/CodeGen/tbaa-for-vptr.cpp b/test/CodeGen/tbaa-for-vptr.cpp
new file mode 100644
index 0000000..f4885f80
--- /dev/null
+++ b/test/CodeGen/tbaa-for-vptr.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s
+// Check that we generate TBAA for vtable pointer loads and stores.
+struct A {
+ virtual int foo() const ;
+ virtual ~A();
+};
+
+void CreateA() {
+ new A;
+}
+
+void CallFoo(A *a) {
+ a->foo();
+}
+
+// CHECK: %{{.*}} = load {{.*}} !tbaa !0
+// CHECK: store {{.*}} !tbaa !0
+// CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1}
+// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA", null}
diff --git a/test/CodeGen/utf16-cfstrings.c b/test/CodeGen/utf16-cfstrings.c
new file mode 100644
index 0000000..d4f214b
--- /dev/null
+++ b/test/CodeGen/utf16-cfstrings.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+// <rdar://problem/10655949>
+
+// CHECK: @.str = internal unnamed_addr constant [9 x i16] [i16 252, i16 98, i16 101, i16 114, i16 104, i16 117, i16 110, i16 100, i16 0], align 2
+
+#define CFSTR __builtin___CFStringMakeConstantString
+
+void foo() {
+ CFSTR("überhund");
+}
diff --git a/test/CodeGen/var-align.c b/test/CodeGen/var-align.c
deleted file mode 100644
index fefd35a..0000000
--- a/test/CodeGen/var-align.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | grep "align 16" | count 2
-
-__attribute((aligned(16))) float a[128];
-union {int a[4]; __attribute((aligned(16))) float b[4];} u;
diff --git a/test/CodeGen/vla-4.c b/test/CodeGen/vla-4.c
new file mode 100644
index 0000000..6e4ca98
--- /dev/null
+++ b/test/CodeGen/vla-4.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+int f();
+int h();
+
+void t1() {
+ _Atomic(typeof((int (*)[f()]) h())) v;
+ // CHECK: [[N:%.*]] = alloca i32*, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
+
+void t2() {
+ typeof(typeof((int (*)[f()]) h())) v;
+ // CHECK: [[N:%.*]] = alloca i32*, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
+
+void t3(typeof((int (*)[f()]) h()) v) {
+ // CHECK: store i32* %v, i32** %{{[.0-9A-Za-z]+}}, align 4
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @f to i32 ()*)()
+ // CHECK-NEXT: [[P:%.*]] = call i32 bitcast (i32 (...)* @h to i32 ()*)()
+}
diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c
index c9612bc..9e62da5 100644
--- a/test/CodeGen/vla.c
+++ b/test/CodeGen/vla.c
@@ -116,9 +116,6 @@ int test4(unsigned n, char (*p)[n][n+1][6]) {
// CHECK-NEXT: [[T0:%.*]] = load i32* [[N]], align 4
// CHECK-NEXT: [[DIM1:%.*]] = add i32 [[T0]], 1
- // __typeof. FIXME: does this really need to be loaded?
- // CHECK-NEXT: load [6 x i8]** [[P]]
-
// CHECK-NEXT: [[T0:%.*]] = load [6 x i8]** [[P]], align 4
// CHECK-NEXT: [[T1:%.*]] = load i32* [[N]], align 4
// CHECK-NEXT: [[T2:%.*]] = udiv i32 [[T1]], 2
diff --git a/test/CodeGen/vld_dup.c b/test/CodeGen/vld_dup.c
new file mode 100644
index 0000000..e1d63cc
--- /dev/null
+++ b/test/CodeGen/vld_dup.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple armv7a-linux-gnueabi \
+// RUN: -target-cpu cortex-a8 \
+// RUN: -emit-llvm -O0 -o - %s | FileCheck %s
+#include <arm_neon.h>
+int main(){
+ int32_t v0[3];
+ int32x2x3_t v1;
+ int32_t v2[4];
+ int32x2x4_t v3;
+ int64x1x3_t v4;
+ int64x1x4_t v5;
+ int64_t v6[3];
+ int64_t v7[4];
+
+ v1 = vld3_dup_s32(v0);
+// CHECK: [[T168:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld3lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}})
+// CHECK-NEXT: [[T169:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], 0
+// CHECK-NEXT: [[T170:%.*]] = shufflevector <2 x i32> [[T169]], <2 x i32> [[T169]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T171:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T168]], <2 x i32> [[T170]], 0
+// CHECK-NEXT: [[T172:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T171]], 1
+// CHECK-NEXT: [[T173:%.*]] = shufflevector <2 x i32> [[T172]], <2 x i32> [[T172]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T174:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T171]], <2 x i32> [[T173]], 1
+// CHECK-NEXT: [[T175:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T174]], 2
+// CHECK-NEXT: [[T176:%.*]] = shufflevector <2 x i32> [[T175]], <2 x i32> [[T175]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T177:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32> } [[T174]], <2 x i32> [[T176]], 2
+
+ v3 = vld4_dup_s32(v2);
+// CHECK: [[T178:%.*]] = call { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } @llvm.arm.neon.vld4lane.v2i32(i8* {{.*}}, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, <2 x i32> undef, i32 {{[0-9]+}}, i32 {{[0-9]+}})
+// CHECK-NEXT: [[T179:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], 0
+// CHECK-NEXT: [[T180:%.*]] = shufflevector <2 x i32> [[T179]], <2 x i32> [[T179]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T181:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T178]], <2 x i32> [[T180]], 0
+// CHECK-NEXT: [[T182:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T181]], 1
+// CHECK-NEXT: [[T183:%.*]] = shufflevector <2 x i32> [[T182]], <2 x i32> [[T182]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T184:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T181]], <2 x i32> [[T183]], 1
+// CHECK-NEXT: [[T185:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T184]], 2
+// CHECK-NEXT: [[T186:%.*]] = shufflevector <2 x i32> [[T185]], <2 x i32> [[T185]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T187:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T184]], <2 x i32> [[T186]], 2
+// CHECK-NEXT: [[T188:%.*]] = extractvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T187]], 3
+// CHECK-NEXT: [[T189:%.*]] = shufflevector <2 x i32> [[T188]], <2 x i32> [[T188]], <2 x i32> zeroinitializer
+// CHECK-NEXT: [[T190:%.*]] = insertvalue { <2 x i32>, <2 x i32>, <2 x i32>, <2 x i32> } [[T187]], <2 x i32> [[T189]], 3
+
+ v4 = vld3_dup_s64(v6);
+// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld3.v1i64(i8* {{.*}}, i32 {{[0-9]+}})
+
+ v5 = vld4_dup_s64(v7);
+// CHECK: {{%.*}} = call { <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64> } @llvm.arm.neon.vld4.v1i64(i8* {{.*}}, i32 {{[0-9]+}})
+
+ return 0;
+}
diff --git a/test/CodeGen/wchar-const.c b/test/CodeGen/wchar-const.c
index b672b15..a9e7e52 100644
--- a/test/CodeGen/wchar-const.c
+++ b/test/CodeGen/wchar-const.c
@@ -14,8 +14,8 @@ typedef __WCHAR_TYPE__ wchar_t;
#endif
-// CHECK-DAR: private unnamed_addr constant [72 x i8] c"
-// CHECK-WIN: private unnamed_addr constant [36 x i8] c"
+// CHECK-DAR: private unnamed_addr constant [18 x i32] [i32 84,
+// CHECK-WIN: private unnamed_addr constant [18 x i16] [i16 84,
extern void foo(const wchar_t* p);
int main (int argc, const char * argv[])
{
diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c
index 7727c43..0ac18b7 100644
--- a/test/CodeGen/x86_32-arguments-darwin.c
+++ b/test/CodeGen/x86_32-arguments-darwin.c
@@ -173,7 +173,7 @@ struct s42 { enum e40 f0; } f42(void) { }
// CHECK: define i64 @f43()
struct s43 { enum e40 f0; int f1; } f43(void) { }
-// CHECK: define i32 @f44()
+// CHECK: define void ()* @f44()
struct s44 { vvbp f0; } f44(void) { }
// CHECK: define i64 @f45()
@@ -275,3 +275,52 @@ void f56(char a0, struct s56_0 a1,
f56_0(1, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13);
}
+
+// CHECK: define void @f57(i32 %x.0, i32 %x.1)
+// CHECK: call void @f57(
+struct s57 { _Complex int x; };
+void f57(struct s57 x) {} void f57a(void) { f57((struct s57){1}); }
+
+// CHECK: define void @f58()
+union u58 {};
+void f58(union u58 x) {}
+
+// CHECK: define i64 @f59()
+struct s59 { float x __attribute((aligned(8))); };
+struct s59 f59() { while (1) {} }
+
+// CHECK: define void @f60(%struct.s60* byval align 4, i32 %y)
+struct s60 { int x __attribute((aligned(8))); };
+void f60(struct s60 x, int y) {}
+
+// CHECK: define void @f61(i32 %x, %struct.s61* byval align 16 %y)
+typedef int T61 __attribute((vector_size(16)));
+struct s61 { T61 x; int y; };
+void f61(int x, struct s61 y) {}
+
+// CHECK: define void @f62(i32 %x, %struct.s62* byval align 4)
+typedef int T62 __attribute((vector_size(16)));
+struct s62 { T62 x; int y; } __attribute((packed, aligned(8)));
+void f62(int x, struct s62 y) {}
+
+// CHECK: define i32 @f63
+// CHECK: ptrtoint
+// CHECK: and {{.*}}, -16
+// CHECK: inttoptr
+typedef int T63 __attribute((vector_size(16)));
+struct s63 { T63 x; int y; };
+int f63(int i, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ struct s63 s = __builtin_va_arg(ap, struct s63);
+ __builtin_va_end(ap);
+ return s.y;
+}
+
+// CHECK: define void @f64(%struct.s64* byval align 4 %x)
+struct s64 { signed char a[0]; signed char b[]; };
+void f64(struct s64 x) {}
+
+// CHECK: define float @f65()
+struct s65 { signed char a[0]; float b; };
+struct s65 f65() { return (struct s65){{},2}; }
diff --git a/test/CodeGen/x86_32-arguments-win32.c b/test/CodeGen/x86_32-arguments-win32.c
new file mode 100644
index 0000000..f18bb30
--- /dev/null
+++ b/test/CodeGen/x86_32-arguments-win32.c
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -w -triple i386-pc-win32 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define i64 @f1_1()
+// CHECK: define void @f1_2(i32 %a0.0, i32 %a0.1)
+struct s1 {
+ int a;
+ int b;
+};
+struct s1 f1_1(void) { while (1) {} }
+void f1_2(struct s1 a0) {}
+
+// CHECK: define i32 @f2_1()
+struct s2 {
+ short a;
+ short b;
+};
+struct s2 f2_1(void) { while (1) {} }
+
+// CHECK: define i16 @f3_1()
+struct s3 {
+ char a;
+ char b;
+};
+struct s3 f3_1(void) { while (1) {} }
+
+// CHECK: define i8 @f4_1()
+struct s4 {
+ char a:4;
+ char b:4;
+};
+struct s4 f4_1(void) { while (1) {} }
+
+// CHECK: define i64 @f5_1()
+// CHECK: define void @f5_2(double %a0.0)
+struct s5 {
+ double a;
+};
+struct s5 f5_1(void) { while (1) {} }
+void f5_2(struct s5 a0) {}
+
+// CHECK: define i32 @f6_1()
+// CHECK: define void @f6_2(float %a0.0)
+struct s6 {
+ float a;
+};
+struct s6 f6_1(void) { while (1) {} }
+void f6_2(struct s6 a0) {}
+
diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c
index 8571ac9..f73e1f0 100644
--- a/test/CodeGen/x86_64-arguments.c
+++ b/test/CodeGen/x86_64-arguments.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | FileCheck %s -check-prefix=AVX
#include <stdarg.h>
// CHECK: define signext i8 @f0()
@@ -263,8 +264,10 @@ void f9122143()
typedef unsigned v2i32 __attribute((__vector_size__(8)));
v2i32 f36(v2i32 arg) { return arg; }
-// CHECK: declare void @f38(<8 x float>)
-// CHECK: declare void @f37(<8 x float>)
+// AVX: declare void @f38(<8 x float>)
+// AVX: declare void @f37(<8 x float>)
+// CHECK: declare void @f38(%struct.s256* byval align 32)
+// CHECK: declare void @f37(<8 x float>* byval align 32)
typedef float __m256 __attribute__ ((__vector_size__ (32)));
typedef struct {
__m256 m;
@@ -304,3 +307,50 @@ extern void func42(SA s);
void func43(SA s) {
func42(s);
}
+
+// CHECK: define i32 @f44
+// CHECK: ptrtoint
+// CHECK-NEXT: and {{.*}}, -32
+// CHECK-NEXT: inttoptr
+typedef int T44 __attribute((vector_size(32)));
+struct s44 { T44 x; int y; };
+int f44(int i, ...) {
+ __builtin_va_list ap;
+ __builtin_va_start(ap, i);
+ struct s44 s = __builtin_va_arg(ap, struct s44);
+ __builtin_va_end(ap);
+ return s.y;
+}
+
+// Text that vec3 returns the correct LLVM IR type.
+// AVX: define i32 @foo(<3 x i64> %X)
+typedef long long3 __attribute((ext_vector_type(3)));
+int foo(long3 X)
+{
+ return 0;
+}
+
+// Make sure we don't use a varargs convention for a function without a
+// prototype where AVX types are involved.
+// AVX: @test45
+// AVX: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*)
+int f45();
+__m256 x45;
+void test45() { f45(x45); }
+
+// Make sure we use byval to pass 64-bit vectors in memory; the LLVM call
+// lowering can't handle this case correctly because it runs after legalization.
+// CHECK: @test46
+// CHECK: call void @f46({{.*}}<2 x float>* byval align 8 {{.*}}, <2 x float>* byval align 8 {{.*}})
+typedef float v46 __attribute((vector_size(8)));
+void f46(v46,v46,v46,v46,v46,v46,v46,v46,v46,v46);
+void test46() { v46 x = {1,2}; f46(x,x,x,x,x,x,x,x,x,x); }
+
+// Check that we pass the struct below without using byval, which helps out
+// codegen.
+//
+// CHECK: @test47
+// CHECK: call void @f47(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}})
+struct s47 { unsigned a; };
+void f47(int,int,int,int,int,int,struct s47);
+void test47(int a, struct s47 b) { f47(a, a, a, a, a, a, b); }
diff --git a/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp b/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp
index f3aa51e..37005c5 100644
--- a/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp
+++ b/test/CodeGenCXX/2007-01-06-PtrMethodInit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -o -
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-apple-macosx10.7.2
// PR1084
extern "C"
diff --git a/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp b/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
new file mode 100644
index 0000000..a853a57
--- /dev/null
+++ b/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
+
+struct A {
+ A(const char *);
+};
+
+// CHECK: @arr = global [3 x %struct.S] zeroinitializer
+// CHECK: @.str = {{.*}}constant [6 x i8] c"hello\00"
+// CHECK: @.str1 = {{.*}}constant [6 x i8] c"world\00"
+// CHECK: @.str2 = {{.*}}constant [8 x i8] c"goodbye\00"
+
+struct S {
+ int n;
+ A s;
+} arr[] = {
+ { 0, "hello" },
+ { 1, "world" },
+ { 2, "goodbye" }
+};
+
+// CHECK: store i32 0, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 0, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 0, i32 1), i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0))
+// CHECK: store i32 1, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 1, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 1, i32 1), i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0))
+// CHECK: store i32 2, i32* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 2, i32 0)
+// CHECK: call void @_ZN1AC1EPKc(%struct.A* getelementptr inbounds ([3 x %struct.S]* @arr, i64 0, i64 2, i32 1), i8* getelementptr inbounds ([8 x i8]* @.str2, i32 0, i32 0))
diff --git a/test/CodeGenCXX/2012-02-06-VecInitialization.cpp b/test/CodeGenCXX/2012-02-06-VecInitialization.cpp
new file mode 100644
index 0000000..720420e
--- /dev/null
+++ b/test/CodeGenCXX/2012-02-06-VecInitialization.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i386-apple-darwin %s | FileCheck %s
+// PR11930
+
+typedef char vec_t __attribute__ ((__ext_vector_type__ (8)));
+void h() {
+// CHECK: store <8 x i8>
+ vec_t v(0);
+}
diff --git a/test/CodeGenCXX/2012-03-16-StoreAlign.cpp b/test/CodeGenCXX/2012-03-16-StoreAlign.cpp
new file mode 100644
index 0000000..a6375f8
--- /dev/null
+++ b/test/CodeGenCXX/2012-03-16-StoreAlign.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin %s | FileCheck %s
+// <rdar://problem/11043589>
+
+struct Length {
+ Length(double v) {
+ m_floatValue = static_cast<float>(v);
+ }
+
+ bool operator==(const Length& o) const {
+ return getFloatValue() == o.getFloatValue();
+ }
+ bool operator!=(const Length& o) const { return !(*this == o); }
+private:
+ float getFloatValue() const {
+ return m_floatValue;
+ }
+ float m_floatValue;
+};
+
+
+struct Foo {
+ static Length inchLength(double inch);
+ static bool getPageSizeFromName(const Length &A) {
+ static const Length legalWidth = inchLength(8.5);
+ if (A != legalWidth) return true;
+ return false;
+ }
+};
+
+// CHECK: @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth = linkonce_odr global %struct.Length zeroinitializer, align 4
+// CHECK: store float %{{.*}}, float* getelementptr inbounds (%struct.Length* @_ZZN3Foo19getPageSizeFromNameERK6LengthE10legalWidth, i32 0, i32 0), align 1
+
+bool bar(Length &b) {
+ Foo f;
+ return f.getPageSizeFromName(b);
+}
diff --git a/test/CodeGenCXX/apple-kext-guard-variable.cpp b/test/CodeGenCXX/apple-kext-guard-variable.cpp
index 26b0d14..76875a0 100644
--- a/test/CodeGenCXX/apple-kext-guard-variable.cpp
+++ b/test/CodeGenCXX/apple-kext-guard-variable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -o %t.s -mkernel -Xclang -verify %s
+// RUN: %clang -target x86_64-apple-darwin10 -S -o %t.s -mkernel -Xclang -verify %s
// rdar://problem/9143356
diff --git a/test/CodeGenCXX/apple-kext.cpp b/test/CodeGenCXX/apple-kext.cpp
new file mode 100644
index 0000000..03506a8
--- /dev/null
+++ b/test/CodeGenCXX/apple-kext.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-use-cxa-atexit -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @_ZN5test01aE = global [[A:%.*]] zeroinitializer
+// CHECK: @llvm.global_ctors = appending global {{.*}} { i32 65535, void ()* [[CTOR0:@.*]] }
+// CHECK: @llvm.global_dtors = appending global {{.*}} { i32 65535, void ()* [[DTOR0:@.*]] }
+
+// rdar://11241230
+namespace test0 {
+ struct A { A(); ~A(); };
+ A a;
+}
+// CHECK: define internal void [[CTOR0_:@.*]]()
+// CHECK: call void @_ZN5test01AC1Ev([[A]]* @_ZN5test01aE)
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void [[CTOR0]]()
+// CHECK: call void [[CTOR0_]]()
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void [[DTOR0]]()
+// CHECK: call void @_ZN5test01AD1Ev([[A]]* @_ZN5test01aE)
+// CHECK-NEXT: ret void
diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp
index a767f42..6c60f30 100644
--- a/test/CodeGenCXX/arm.cpp
+++ b/test/CodeGenCXX/arm.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s
+// RUN: %clang_cc1 %s -triple=thumbv7-apple-ios3.0 -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - -fexceptions | FileCheck %s
// CHECK: @_ZZN5test74testEvE1x = internal global i32 0, align 4
// CHECK: @_ZGVZN5test74testEvE1x = internal global i32 0
@@ -20,9 +20,17 @@ public:
// The global dtor needs the right calling conv with -fno-use-cxa-atexit
// rdar://7817590
-// Checked at end of file.
bar baz;
+// PR9593
+// Make sure atexit(3) is used for global dtors.
+
+// CHECK: call [[BAR:%.*]]* @_ZN3barC1Ev(
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_baz)
+
+// CHECK: define internal void @__dtor_baz()
+// CHECK: call [[BAR]]* @_ZN3barD1Ev([[BAR]]* @baz)
+
// Destructors and constructors must return this.
namespace test1 {
void foo();
@@ -45,24 +53,18 @@ namespace test1 {
}
// CHECK: define linkonce_odr [[A]]* @_ZN5test11AC1Ei([[A]]* %this, i32 %i) unnamed_addr
- // CHECK: [[RET:%.*]] = alloca [[A]]*, align 4
// CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4
// CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]]
// CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]]
- // CHECK: store [[A]]* [[THIS1]], [[A]]** [[RET]]
// CHECK: call [[A]]* @_ZN5test11AC2Ei(
- // CHECK: [[THIS2:%.*]] = load [[A]]** [[RET]]
- // CHECK: ret [[A]]* [[THIS2]]
+ // CHECK: ret [[A]]* [[THIS1]]
// CHECK: define linkonce_odr [[A]]* @_ZN5test11AD1Ev([[A]]* %this) unnamed_addr
- // CHECK: [[RET:%.*]] = alloca [[A]]*, align 4
// CHECK: [[THIS:%.*]] = alloca [[A]]*, align 4
// CHECK: store [[A]]* {{.*}}, [[A]]** [[THIS]]
// CHECK: [[THIS1:%.*]] = load [[A]]** [[THIS]]
- // CHECK: store [[A]]* [[THIS1]], [[A]]** [[RET]]
// CHECK: call [[A]]* @_ZN5test11AD2Ev(
- // CHECK: [[THIS2:%.*]] = load [[A]]** [[RET]]
- // CHECK: ret [[A]]* [[THIS2]]
+ // CHECK: ret [[A]]* [[THIS1]]
}
// Awkward virtual cases.
@@ -363,5 +365,5 @@ namespace test8 {
// CHECK: call void @_ZN5test21CD0Ev(
// CHECK: ret void
-// CHECK: @_GLOBAL__D_a()
-// CHECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)
+// CH_ECK: @_GLOBAL__D_a()
+// CH_ECK: call %class.bar* @_ZN3barD1Ev(%class.bar* @baz)
diff --git a/test/CodeGenCXX/assign-operator.cpp b/test/CodeGenCXX/assign-operator.cpp
index c4b64e6..e19df27 100644
--- a/test/CodeGenCXX/assign-operator.cpp
+++ b/test/CodeGenCXX/assign-operator.cpp
@@ -17,3 +17,14 @@ void f(int i, int j) {
// CHECK: ret
(i += j) = 17;
}
+
+// Taken from g++.old-deja/g++.jason/net.C
+namespace test1 {
+ template <class T> void fn (T t) { }
+ template <class T> struct A {
+ void (*p)(T);
+ A() { p = fn; }
+ };
+
+ A<int> a;
+}
diff --git a/test/CodeGenCXX/atomic.cpp b/test/CodeGenCXX/atomic.cpp
new file mode 100644
index 0000000..36bb4ef
--- /dev/null
+++ b/test/CodeGenCXX/atomic.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin9 | FileCheck %s
+
+namespace PR11411 {
+ template<typename _Tp> struct Ptr {
+ void f();
+ };
+
+ // CHECK: define linkonce_odr void @_ZN7PR114113PtrIiE1fEv
+ // CHECK-NOT: ret
+ template<typename _Tp> inline void Ptr<_Tp>::f() {
+ int* _refcount;
+ // CHECK: atomicrmw add i32*
+ __sync_fetch_and_add(_refcount, 1);
+ // CHECK-NEXT: ret void
+ }
+ void f(Ptr<int> *a) { a->f(); }
+}
diff --git a/test/CodeGenCXX/atomicinit.cpp b/test/CodeGenCXX/atomicinit.cpp
new file mode 100644
index 0000000..38d012e
--- /dev/null
+++ b/test/CodeGenCXX/atomicinit.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -o - -triple=i686-apple-darwin9 | FileCheck %s
+struct A {
+ _Atomic(int) i;
+ A(int j);
+ void v(int j);
+};
+// Storing to atomic values should be atomic
+// CHECK: store atomic i32
+void A::v(int j) { i = j; }
+// Initialising atomic values should not be atomic
+// CHECK-NOT: store atomic
+A::A(int j) : i(j) {}
+
+struct B {
+ int i;
+ B(int x) : i(x) {}
+};
+
+_Atomic(B) b;
+
+// CHECK: define void @_Z11atomic_initR1Ai
+void atomic_init(A& a, int i) {
+ // CHECK-NOT: atomic
+ // CHECK: tail call void @_ZN1BC1Ei
+ __c11_atomic_init(&b, B(i));
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @_Z16atomic_init_boolPU7_Atomicbb
+void atomic_init_bool(_Atomic(bool) *ab, bool b) {
+ // CHECK-NOT: atomic
+ // CHECK: {{zext i1.*to i8}}
+ // CHECK-NEXT: store i8
+ __c11_atomic_init(ab, b);
+ // CHECK-NEXT: ret void
+}
+
+struct AtomicBoolMember {
+ _Atomic(bool) ab;
+ AtomicBoolMember(bool b);
+};
+
+// CHECK: define void @_ZN16AtomicBoolMemberC2Eb
+// CHECK: {{zext i1.*to i8}}
+// CHECK-NEXT: store i8
+// CHECK-NEXT: ret void
+AtomicBoolMember::AtomicBoolMember(bool b) : ab(b) { }
+
diff --git a/test/CodeGenCXX/block.cpp b/test/CodeGenCXX/block.cpp
new file mode 100644
index 0000000..619d8b0
--- /dev/null
+++ b/test/CodeGenCXX/block.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks
+// Just test that this doesn't crash the compiler...
+
+void func(void*);
+
+struct Test
+{
+ virtual void use() { func((void*)this); }
+ Test(Test&c) { func((void*)this); }
+ Test() { func((void*)this); }
+};
+
+void useBlock(void (^)(void));
+
+int main (void) {
+ __block Test t;
+ useBlock(^(void) { t.use(); });
+}
+
diff --git a/test/CodeGenCXX/blocks-cxx11.cpp b/test/CodeGenCXX/blocks-cxx11.cpp
new file mode 100644
index 0000000..996db1a
--- /dev/null
+++ b/test/CodeGenCXX/blocks-cxx11.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - | FileCheck %s
+
+template <class T> void takeItByValue(T);
+void takeABlock(void (^)());
+
+// rdar://problem/11022704
+namespace test_int {
+ void test() {
+ const int x = 100;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueIiEvT_(i32 100)
+ }
+}
+
+namespace test_int_ref {
+ void test() {
+ const int y = 200;
+ const int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+
+ // TODO: there's no good reason that this isn't foldable.
+ // CHECK: call void @_Z13takeItByValueIiEvT_(i32 {{%.*}})
+ }
+}
+
+namespace test_float {
+ void test() {
+ const float x = 1;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueIfEvT_(float 1.0
+ }
+}
+
+namespace test_float_ref {
+ void test() {
+ const float y = 100;
+ const float &x = y;
+ takeABlock(^{ takeItByValue(x); });
+
+ // TODO: there's no good reason that this isn't foldable.
+ // CHECK: call void @_Z13takeItByValueIfEvT_(float {{%.*}})
+ }
+}
+
+namespace test_complex_int {
+ void test() {
+ constexpr _Complex int x = 500;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: store i32 500,
+
+ // CHECK: store i32 500,
+ // CHECK-NEXT: store i32 0,
+ // CHECK-NEXT: [[COERCE:%.*]] = bitcast
+ // CHECK-NEXT: [[CVAL:%.*]] = load i64* [[COERCE]]
+ // CHECK-NEXT: call void @_Z13takeItByValueICiEvT_(i64 [[CVAL]])
+ }
+}
+
+namespace test_complex_int_ref {
+ void test() {
+ const _Complex int y = 100;
+ const _Complex int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: call void @_Z13takeItByValueICiEvT_(i64
+ }
+}
+
+namespace test_complex_int_ref_mutable {
+ _Complex int y = 100;
+ void test() {
+ const _Complex int &x = y;
+ takeABlock(^{ takeItByValue(x); });
+ // CHECK: [[R:%.*]] = load i32* getelementptr inbounds ({ i32, i32 }* @_ZN28test_complex_int_ref_mutable1yE, i32 0, i32 0)
+ // CHECK-NEXT: [[I:%.*]] = load i32* getelementptr inbounds ({ i32, i32 }* @_ZN28test_complex_int_ref_mutable1yE, i32 0, i32 1)
+ // CHECK-NEXT: [[RSLOT:%.*]] = getelementptr inbounds { i32, i32 }* [[CSLOT:%.*]], i32 0, i32 0
+ // CHECK-NEXT: [[ISLOT:%.*]] = getelementptr inbounds { i32, i32 }* [[CSLOT]], i32 0, i32 1
+ // CHECK-NEXT: store i32 [[R]], i32* [[RSLOT]]
+ // CHECK-NEXT: store i32 [[I]], i32* [[ISLOT]]
+ // CHECK-NEXT: [[COERCE:%.*]] = bitcast { i32, i32 }* [[CSLOT]] to i64*
+ // CHECK-NEXT: [[CVAL:%.*]] = load i64* [[COERCE]],
+ // CHECK-NEXT: call void @_Z13takeItByValueICiEvT_(i64 [[CVAL]])
+ }
+}
+
diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp
index cc56525..eb54478 100644
--- a/test/CodeGenCXX/blocks.cpp
+++ b/test/CodeGenCXX/blocks.cpp
@@ -128,3 +128,101 @@ namespace test4 {
// CHECK-NEXT: ret void
}
+namespace test5 {
+ struct A {
+ unsigned afield;
+ A();
+ A(const A&);
+ ~A();
+ void foo() const;
+ };
+
+ void doWithBlock(void(^)());
+
+ void test(bool cond) {
+ A x;
+ void (^b)() = (cond ? ^{ x.foo(); } : (void(^)()) 0);
+ doWithBlock(b);
+ }
+
+ // CHECK: define void @_ZN5test54testEb(
+ // CHECK: [[COND:%.*]] = alloca i8
+ // CHECK-NEXT: [[X:%.*]] = alloca [[A:%.*]], align 4
+ // CHECK-NEXT: [[B:%.*]] = alloca void ()*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align 8
+ // CHECK-NEXT: [[CLEANUP_ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[T0:%.*]] = zext i1
+ // CHECK-NEXT: store i8 [[T0]], i8* [[COND]], align 1
+ // CHECK-NEXT: call void @_ZN5test51AC1Ev([[A]]* [[X]])
+ // CHECK-NEXT: [[CLEANUP_ADDR:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8* [[COND]], align 1
+ // CHECK-NEXT: [[T1:%.*]] = trunc i8 [[T0]] to i1
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T1]],
+
+ // CHECK-NOT: br
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: call void @_ZN5test51AC1ERKS0_([[A]]* [[CAPTURE]], [[A]]* [[X]])
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: br label
+ // CHECK: br label
+ // CHECK: phi
+ // CHECK-NEXT: store
+ // CHECK-NEXT: load
+ // CHECK-NEXT: call void @_ZN5test511doWithBlockEU13block_pointerFvvE(
+ // CHECK-NEXT: [[T0:%.*]] = load i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: call void @_ZN5test51AD1Ev([[A]]* [[CLEANUP_ADDR]])
+ // CHECK-NEXT: br label
+ // CHECK: call void @_ZN5test51AD1Ev([[A]]* [[X]])
+ // CHECK-NEXT: ret void
+}
+
+namespace test6 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ void foo(const A &, void (^)());
+ void bar();
+
+ void test() {
+ // Make sure that the temporary cleanup isn't somehow captured
+ // within the block.
+ foo(A(), ^{ bar(); });
+ bar();
+ }
+
+ // CHECK: define void @_ZN5test64testEv()
+ // CHECK: [[TEMP:%.*]] = alloca [[A:%.*]], align 1
+ // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63fooERKNS_1AEU13block_pointerFvvE(
+ // CHECK-NEXT: call void @_ZN5test61AD1Ev([[A]]* [[TEMP]])
+ // CHECK-NEXT: call void @_ZN5test63barEv()
+ // CHECK-NEXT: ret void
+}
+
+namespace test7 {
+ int f() {
+ static int n;
+ int *const p = &n;
+ return ^{ return *p; }();
+ }
+}
+
+namespace test8 {
+ // <rdar://problem/10832617>: failure to capture this after skipping rebuild
+ // of the 'this' pointer.
+ struct X {
+ int x;
+
+ template<typename T>
+ int foo() {
+ return ^ { return x; }();
+ }
+ };
+
+ template int X::foo<int>();
+}
diff --git a/test/CodeGenCXX/c99-variable-length-array.cpp b/test/CodeGenCXX/c99-variable-length-array.cpp
index 76f99c7..d486f9b 100644
--- a/test/CodeGenCXX/c99-variable-length-array.cpp
+++ b/test/CodeGenCXX/c99-variable-length-array.cpp
@@ -25,3 +25,13 @@ void f(int argc, const char* argv[]) {
// CHECK: call void @_ZN1XD1Ev
// CHECK: ret void
}
+
+namespace PR11744 {
+ // Make sure this doesn't crash; there was a use-after-free issue
+ // for this testcase.
+ template<typename T> int f(int n) {
+ T arr[3][n];
+ return 3;
+ }
+ int test = f<int>(0);
+}
diff --git a/test/CodeGenCXX/compound-literals.cpp b/test/CodeGenCXX/compound-literals.cpp
index cd44e97..17a3114 100644
--- a/test/CodeGenCXX/compound-literals.cpp
+++ b/test/CodeGenCXX/compound-literals.cpp
@@ -25,3 +25,20 @@ int f() {
// CHECK-NEXT: ret i32 [[RESULT]]
return ((Y){17, "seventeen"}).i;
}
+
+// CHECK: define i32 @_Z1gv()
+int g() {
+ // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]]
+ const int (&v)[2] = (int [2]) {1,2};
+
+ // CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]** [[V]]
+ // CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32]* [[A]], i32 0, {{.*}} 0
+ // CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32* [[A0ADDR]]
+ // CHECK-NEXT: ret i32 [[A0]]
+ return v[0];
+}
+
+struct Z { int i[3]; };
+int *p = (Z){ {1, 2, 3} }.i;
+// CHECK: define {{.*}}__cxx_global_var_init()
+// CHECK: store i32* getelementptr inbounds (%struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p
diff --git a/test/CodeGenCXX/conditional-gnu-ext.cpp b/test/CodeGenCXX/conditional-gnu-ext.cpp
index 46c5e7f..104a91d 100644
--- a/test/CodeGenCXX/conditional-gnu-ext.cpp
+++ b/test/CodeGenCXX/conditional-gnu-ext.cpp
@@ -140,3 +140,11 @@ namespace test3 {
}
}
+
+namespace test4 {
+ // Make sure this doesn't crash.
+ void f() {
+ const int a = 10, b = 20;
+ const int *c = &(a ?: b);
+ }
+}
diff --git a/test/CodeGenCXX/const-base-cast.cpp b/test/CodeGenCXX/const-base-cast.cpp
index ed47069..320c790 100644
--- a/test/CodeGenCXX/const-base-cast.cpp
+++ b/test/CodeGenCXX/const-base-cast.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -O1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
// Check that the following construct, which is similar to one which occurs
-// in Firefox, is not misfolded (folding it correctly would be a bonus, but
-// that doesn't work at the moment, hence the -O1 in the runline).
+// in Firefox, is folded correctly.
struct A { char x; };
struct B { char y; };
struct C : A,B {};
diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp
new file mode 100644
index 0000000..c745dee
--- /dev/null
+++ b/test/CodeGenCXX/const-init-cxx11.cpp
@@ -0,0 +1,425 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s
+
+// FIXME: The padding in all these objects should be zero-initialized.
+namespace StructUnion {
+ struct A {
+ int n;
+ double d;
+ union U {
+ constexpr U(int x) : x(x) {}
+ constexpr U(const char *y) : y(y) {}
+ int x;
+ const char *y;
+ } u;
+
+ constexpr A(int n, double d, int x) : n(n), d(d), u(x) {}
+ constexpr A(int n, double d, const char *y) : n(n), d(d), u(y) {}
+ };
+
+ // CHECK: @_ZN11StructUnion1aE = constant {{.*}} { i32 1, double 2.000000e+00, {{.*}} { i32 3, [4 x i8] undef } }
+ extern constexpr A a(1, 2.0, 3);
+
+ // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8]* @{{.*}}, i32 0, i32 0) } }
+ extern constexpr A b(4, 5, "hello");
+
+ struct B {
+ int n;
+ };
+
+ // CHECK: @_ZN11StructUnion1cE = global {{.*}} zeroinitializer
+ // CHECK: @_ZN11StructUnion2c2E = global {{.*}} zeroinitializer
+ B c;
+ B c2 = B();
+
+ // CHECK: @_ZN11StructUnion1dE = global {{.*}} zeroinitializer
+ B d[10];
+
+ struct C {
+ constexpr C() : c(0) {}
+ int c;
+ };
+
+ // CHECK: @_ZN11StructUnion1eE = global {{.*}} zeroinitializer
+ C e[10];
+
+ struct D {
+ constexpr D() : d(5) {}
+ int d;
+ };
+
+ // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 }
+ D f;
+}
+
+namespace BaseClass {
+ template<typename T, unsigned> struct X : T {};
+ struct C { char c = 1; };
+ template<unsigned... Ns> struct Cs : X<C,Ns>... {};
+ struct N { int n = 3; };
+ struct D { double d = 4.0; };
+
+ template<typename ...Ts>
+ struct Test : Ts... { constexpr Test() : Ts()..., n(5) {} int n; };
+
+ using Test1 = Test<N, C, Cs<1,2>, D, X<C,1>>;
+ // CHECK: @_ZN9BaseClass2t1E = constant {{.*}} { i32 3, i8 1, i8 1, i8 1, double 4.000000e+00, i8 1, i32 5 }, align 8
+ extern constexpr Test1 t1 = Test1();
+
+ struct DN : D, N {};
+ struct DND : DN, X<D,0> {};
+ struct DNN : DN, X<N,0> {};
+ // CHECK: @_ZN9BaseClass3dndE = constant {{.*}} { double 4.000000e+00, i32 3, double 4.000000e+00 }
+ extern constexpr DND dnd = DND();
+ // Note, N subobject is laid out in DN subobject's tail padding.
+ // CHECK: @_ZN9BaseClass3dnnE = constant {{.*}} { double 4.000000e+00, i32 3, i32 3 }
+ extern constexpr DNN dnn = DNN();
+
+ struct E {};
+ struct Test2 : X<E,0>, X<E,1>, X<E,2>, X<E,3> {};
+ // CHECK: @_ZN9BaseClass2t2E = constant {{.*}} undef
+ extern constexpr Test2 t2 = Test2();
+
+ struct __attribute((packed)) PackedD { double y = 2; };
+ struct Test3 : C, PackedD { constexpr Test3() {} };
+ // CHECK: @_ZN9BaseClass2t3E = constant <{ i8, double }> <{ i8 1, double 2.000000e+00 }>
+ extern constexpr Test3 t3 = Test3();
+}
+
+namespace Array {
+ // CHECK: @_ZN5Array3arrE = constant [2 x i32] [i32 4, i32 0]
+ extern constexpr int arr[2] = { 4 };
+
+ // CHECK: @_ZN5Array1cE = constant [6 x [4 x i8]] [{{.*}} c"foo\00", [4 x i8] c"a\00\00\00", [4 x i8] c"bar\00", [4 x i8] c"xyz\00", [4 x i8] c"b\00\00\00", [4 x i8] c"123\00"]
+ extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' };
+
+ struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; };
+ // CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }]
+ extern const C ctors[3];
+ constexpr C ctors[3];
+
+ // CHECK: @_ZN5Array1dE = constant {{.*}} { [2 x i32] [i32 1, i32 2], [3 x i32] [i32 3, i32 4, i32 5] }
+ struct D { int n[2]; int m[3]; } extern constexpr d = { 1, 2, 3, 4, 5 };
+
+ struct E {
+ char c[4];
+ char d[4];
+ constexpr E() : c("foo"), d("x") {}
+ };
+ // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" }
+ extern constexpr E e = E();
+}
+
+namespace MemberPtr {
+ struct B1 {
+ int a, b;
+ virtual void f();
+ void g();
+ };
+ struct B2 {
+ int c, d;
+ virtual void h();
+ void i();
+ };
+ struct C : B1 {
+ int e;
+ virtual void j();
+ void k();
+ };
+ struct D : C, B2 {
+ int z;
+ virtual void l();
+ void m();
+ };
+
+ // CHECK: @_ZN9MemberPtr2daE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2dbE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2dcE = constant i64 32
+ // CHECK: @_ZN9MemberPtr2ddE = constant i64 36
+ // CHECK: @_ZN9MemberPtr2deE = constant i64 16
+ // CHECK: @_ZN9MemberPtr2dzE = constant i64 40
+ extern constexpr int (D::*da) = &B1::a;
+ extern constexpr int (D::*db) = &C::b;
+ extern constexpr int (D::*dc) = &B2::c;
+ extern constexpr int (D::*dd) = &D::d;
+ extern constexpr int (D::*de) = &C::e;
+ extern constexpr int (D::*dz) = &D::z;
+
+ // CHECK: @_ZN9MemberPtr2baE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2bbE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2bcE = constant i64 8
+ // CHECK: @_ZN9MemberPtr2bdE = constant i64 12
+ // CHECK: @_ZN9MemberPtr2beE = constant i64 16
+ // CHECK: @_ZN9MemberPtr3b1zE = constant i64 40
+ // CHECK: @_ZN9MemberPtr3b2zE = constant i64 16
+ extern constexpr int (B1::*ba) = (int(B1::*))&B1::a;
+ extern constexpr int (B1::*bb) = (int(B1::*))&C::b;
+ extern constexpr int (B2::*bc) = (int(B2::*))&B2::c;
+ extern constexpr int (B2::*bd) = (int(B2::*))&D::d;
+ extern constexpr int (B1::*be) = (int(B1::*))&C::e;
+ extern constexpr int (B1::*b1z) = (int(B1::*))&D::z;
+ extern constexpr int (B2::*b2z) = (int(B2::*))&D::z;
+
+ // CHECK: @_ZN9MemberPtr2dfE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dhE = constant {{.*}} { i64 1, i64 24 }
+ // CHECK: @_ZN9MemberPtr2diE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 24 }
+ // CHECK: @_ZN9MemberPtr2djE = constant {{.*}} { i64 9, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dlE = constant {{.*}} { i64 17, i64 0 }
+ // CHECK: @_ZN9MemberPtr2dmE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
+ extern constexpr void (D::*df)() = &C::f;
+ extern constexpr void (D::*dg)() = &B1::g;
+ extern constexpr void (D::*dh)() = &B2::h;
+ extern constexpr void (D::*di)() = &D::i;
+ extern constexpr void (D::*dj)() = &C::j;
+ extern constexpr void (D::*dk)() = &C::k;
+ extern constexpr void (D::*dl)() = &D::l;
+ extern constexpr void (D::*dm)() = &D::m;
+
+ // CHECK: @_ZN9MemberPtr2bfE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bhE = constant {{.*}} { i64 1, i64 0 }
+ // CHECK: @_ZN9MemberPtr2biE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bjE = constant {{.*}} { i64 9, i64 0 }
+ // CHECK: @_ZN9MemberPtr2bkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b1lE = constant {{.*}} { i64 17, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b1mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
+ // CHECK: @_ZN9MemberPtr3b2lE = constant {{.*}} { i64 17, i64 -24 }
+ // CHECK: @_ZN9MemberPtr3b2mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 -24 }
+ extern constexpr void (B1::*bf)() = (void(B1::*)())&C::f;
+ extern constexpr void (B1::*bg)() = (void(B1::*)())&B1::g;
+ extern constexpr void (B2::*bh)() = (void(B2::*)())&B2::h;
+ extern constexpr void (B2::*bi)() = (void(B2::*)())&D::i;
+ extern constexpr void (B1::*bj)() = (void(B1::*)())&C::j;
+ extern constexpr void (B1::*bk)() = (void(B1::*)())&C::k;
+ extern constexpr void (B1::*b1l)() = (void(B1::*)())&D::l;
+ extern constexpr void (B1::*b1m)() = (void(B1::*)())&D::m;
+ extern constexpr void (B2::*b2l)() = (void(B2::*)())&D::l;
+ extern constexpr void (B2::*b2m)() = (void(B2::*)())&D::m;
+}
+
+namespace LiteralReference {
+ struct Lit {
+ constexpr Lit() : n(5) {}
+ int n;
+ };
+ // FIXME: This should have static initialization, but we do not implement
+ // that yet. For now, just check that we don't set the (pointer) value of
+ // the reference to 5!
+ //
+ // CHECK: @_ZN16LiteralReference3litE = global {{.*}} null
+ const Lit &lit = Lit();
+}
+
+namespace NonLiteralConstexpr {
+ constexpr int factorial(int n) {
+ return n ? factorial(n-1) * n : 1;
+ }
+ extern void f(int *p);
+
+ struct NonTrivialDtor {
+ constexpr NonTrivialDtor() : n(factorial(5)), p(&n) {}
+ ~NonTrivialDtor() {
+ f(p);
+ }
+
+ int n;
+ int *p;
+ };
+ static_assert(!__is_literal(NonTrivialDtor), "");
+ // CHECK: @_ZN19NonLiteralConstexpr3ntdE = global {{.*}} { i32 120, i32* getelementptr
+ NonTrivialDtor ntd;
+
+ struct VolatileMember {
+ constexpr VolatileMember() : n(5) {}
+ volatile int n;
+ };
+ static_assert(!__is_literal(VolatileMember), "");
+ // CHECK: @_ZN19NonLiteralConstexpr2vmE = global {{.*}} { i32 5 }
+ VolatileMember vm;
+
+ struct Both {
+ constexpr Both() : n(10) {}
+ ~Both();
+ volatile int n;
+ };
+ // CHECK: @_ZN19NonLiteralConstexpr1bE = global {{.*}} { i32 10 }
+ Both b;
+
+ void StaticVars() {
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE3ntd = {{.*}} { i32 120, i32* getelementptr {{.*}}
+ // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE3ntd =
+ static NonTrivialDtor ntd;
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE2vm = {{.*}} { i32 5 }
+ // CHECK-NOT: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE2vm =
+ static VolatileMember vm;
+ // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE1b = {{.*}} { i32 10 }
+ // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE1b =
+ static Both b;
+ }
+}
+
+// PR12067
+namespace VirtualMembers {
+ struct A {
+ constexpr A(double d) : d(d) {}
+ virtual void f();
+ double d;
+ };
+ struct B : A {
+ constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {}
+ constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {}
+ virtual void g();
+ char c[5];
+ };
+ struct C {
+ constexpr C() : n(64) {}
+ int n;
+ };
+ struct D : C, A, B {
+ constexpr D() : A(1.0), B(), s(5) {}
+ short s;
+ };
+ struct E : D, B {
+ constexpr E() : B(3), c{'b','y','e'} {}
+ char c[3];
+ };
+
+ // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
+ E e;
+
+ struct nsMemoryImpl {
+ virtual void f();
+ };
+ // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
+ static nsMemoryImpl sGlobalMemory;
+}
+
+// Constant initialization tests go before this point,
+// dynamic initialization tests go after.
+
+// We must emit a constant initializer for NonLiteralConstexpr::ntd, but also
+// emit an initializer to register its destructor.
+// CHECK: define {{.*}}cxx_global_var_init{{.*}}
+// CHECK-NOT: NonLiteralConstexpr
+// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev {{.*}} @_ZN19NonLiteralConstexpr3ntdE
+// CHECK-NEXT: ret void
+
+// We don't need to emit any dynamic initialization for NonLiteralConstexpr::vm.
+// CHECK-NOT: NonLiteralConstexpr2vm
+
+// We must emit a constant initializer for NonLiteralConstexpr::b, but also
+// emit an initializer to register its destructor.
+// CHECK: define {{.*}}cxx_global_var_init{{.*}}
+// CHECK-NOT: NonLiteralConstexpr
+// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr4BothD1Ev {{.*}} @_ZN19NonLiteralConstexpr1bE
+// CHECK-NEXT: ret void
+
+// CHECK: define {{.*}}NonLiteralConstexpr10StaticVars
+// CHECK-NOT: }
+// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev
+// CHECK-NOT: }
+// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr4BothD1Ev
+
+namespace CrossFuncLabelDiff {
+ // Make sure we refuse to constant-fold the variable b.
+ constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); }
+ void test() { static long b = (long)&&lbl - a(false); lbl: return; }
+ // CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
+ // CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
+}
+
+// PR12012
+namespace VirtualBase {
+ struct B {};
+ struct D : virtual B {};
+ D d;
+ // CHECK: call {{.*}}@_ZN11VirtualBase1DC1Ev
+
+ template<typename T> struct X : T {
+ constexpr X() : T() {}
+ };
+ X<D> x;
+ // CHECK: call {{.*}}@_ZN11VirtualBase1XINS_1DEEC1Ev
+}
+
+// PR12145
+namespace Unreferenced {
+ int n;
+ constexpr int *p = &n;
+ // We must not emit a load of 'p' here, since it's not odr-used.
+ int q = *p;
+ // CHECK-NOT: _ZN12Unreferenced1pE
+ // CHECK: = load i32* @_ZN12Unreferenced1nE
+ // CHECK-NEXT: store i32 {{.*}}, i32* @_ZN12Unreferenced1qE
+ // CHECK-NOT: _ZN12Unreferenced1pE
+
+ // Technically, we are not required to substitute variables of reference types
+ // initialized by constant expressions, because the special case for odr-use
+ // of variables in [basic.def.odr]p2 only applies to objects. But we do so
+ // anyway.
+
+ constexpr int &r = n;
+ // CHECK-NOT: _ZN12Unreferenced1rE
+ int s = r;
+
+ const int t = 1;
+ const int &rt = t;
+ int f(int);
+ int u = f(rt);
+ // CHECK: call i32 @_ZN12Unreferenced1fEi(i32 1)
+}
+
+namespace InitFromConst {
+ template<typename T> void consume(T);
+
+ const bool b = true;
+ const int n = 5;
+ constexpr double d = 4.3;
+
+ struct S { int n = 7; S *p = 0; };
+ constexpr S s = S();
+ const S &r = s;
+ constexpr const S *p = &r;
+ constexpr int S::*mp = &S::n;
+ constexpr int a[3] = { 1, 4, 9 };
+
+ void test() {
+ // CHECK: call void @_ZN13InitFromConst7consumeIbEEvT_(i1 zeroext true)
+ consume(b);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIiEEvT_(i32 5)
+ consume(n);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIdEEvT_(double 4.300000e+00)
+ consume(d);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ consume<const S&>(s);
+
+ // FIXME CHECK-NOT: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ // There's no lvalue-to-rvalue conversion here, so 'r' is odr-used, and
+ // we're permitted to emit a load of it. This seems likely to be a defect
+ // in the standard. If we start emitting a direct reference to 's', update
+ // this test.
+ consume<const S&>(r);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
+ consume(p);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIMNS_1SEiEEvT_(i64 0)
+ consume(mp);
+
+ // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
+ consume(a);
+ }
+}
+
+namespace Null {
+ decltype(nullptr) null();
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int *p = null();
+ struct S {};
+ // CHECK: call {{.*}} @_ZN4Null4nullEv(
+ int S::*q = null();
+}
diff --git a/test/CodeGenCXX/const-init.cpp b/test/CodeGenCXX/const-init.cpp
index 797d137..201ce8f 100644
--- a/test/CodeGenCXX/const-init.cpp
+++ b/test/CodeGenCXX/const-init.cpp
@@ -29,10 +29,50 @@ namespace test2 {
struct A {
static const double d = 1.0;
static const float f = d / 2;
- };
+ static int g();
+ } a;
// CHECK: @_ZN5test22t0E = global double {{1\.0+e\+0+}}, align 8
// CHECK: @_ZN5test22t1E = global [2 x double] [double {{1\.0+e\+0+}}, double {{5\.0+e-0*}}1], align 16
+ // CHECK: @_ZN5test22t2E = global double* @_ZN5test21A1d
+ // CHECK: @_ZN5test22t3E = global {{.*}} @_ZN5test21A1g
double t0 = A::d;
double t1[] = { A::d, A::f };
+ const double *t2 = &a.d;
+ int (*t3)() = &a.g;
}
+
+// We don't expect to fold this in the frontend, but make sure it doesn't crash.
+// CHECK: @PR9558 = global float 0.000000e+0
+float PR9558 = reinterpret_cast<const float&>("asd");
+
+// An initialized const automatic variable cannot be promoted to a constant
+// global if it has a mutable member.
+struct MutableMember {
+ mutable int n;
+};
+int writeToMutable() {
+ // CHECK-NOT: {{.*}}MM{{.*}} = {{.*}}constant
+ const MutableMember MM = { 0 };
+ return ++MM.n;
+}
+
+// Make sure we don't try to fold this in the frontend; the backend can't
+// handle it.
+// CHECK: @PR11705 = global i128 0
+__int128_t PR11705 = (__int128_t)&PR11705;
+
+// Make sure we don't try to fold this either.
+// CHECK: @_ZZ23UnfoldableAddrLabelDiffvE1x = internal global i128 0
+void UnfoldableAddrLabelDiff() { static __int128_t x = (long)&&a-(long)&&b; a:b:return;}
+
+// But make sure we do fold this.
+// CHECK: @_ZZ21FoldableAddrLabelDiffvE1x = internal global i64 sub (i64 ptrtoint (i8* blockaddress(@_Z21FoldableAddrLabelDiffv
+void FoldableAddrLabelDiff() { static long x = (long)&&a-(long)&&b; a:b:return;}
+
+// CHECK: @i = constant i32* bitcast (float* @PR9558 to i32*)
+int &i = reinterpret_cast<int&>(PR9558);
+
+int arr[2];
+// CHECK: @pastEnd = constant i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @arr to i8*), i64 8) to i32*)
+int &pastEnd = arr[2];
diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp
index 6af5188..9f808f6 100644
--- a/test/CodeGenCXX/constructor-init.cpp
+++ b/test/CodeGenCXX/constructor-init.cpp
@@ -201,7 +201,7 @@ namespace PR10720 {
pair2(const pair2&) = default;
};
- struct pair {
+ struct pair : X { // Make the copy constructor non-trivial, so we actually generate it.
int second[4];
// CHECK-PR10720: define linkonce_odr void @_ZN7PR107204pairC2ERKS0_
// CHECK-PR10720-NOT: ret
@@ -220,4 +220,3 @@ namespace PR10720 {
}
}
-
diff --git a/test/CodeGenCXX/constructors.cpp b/test/CodeGenCXX/constructors.cpp
index ec7f06c..9e2da31 100644
--- a/test/CodeGenCXX/constructors.cpp
+++ b/test/CodeGenCXX/constructors.cpp
@@ -111,7 +111,5 @@ namespace test1 {
B::B() {}
// CHECK: define void @_ZN5test11BC2Ev(
// CHECK: [[THIS:%.*]] = load [[B:%.*]]**
- // CHECK-NEXT: [[A:%.*]] = getelementptr inbounds [[B:%.*]]* [[THIS]], i32 0, i32 1
- // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [0 x {{%.*}}]* [[A]], i32 0, i32 0
// CHECK-NEXT: ret void
}
diff --git a/test/CodeGenCXX/copy-constructor-elim-2.cpp b/test/CodeGenCXX/copy-constructor-elim-2.cpp
index a4a688f..9480cbf 100644
--- a/test/CodeGenCXX/copy-constructor-elim-2.cpp
+++ b/test/CodeGenCXX/copy-constructor-elim-2.cpp
@@ -53,3 +53,25 @@ void f() {
}
}
+
+namespace PR12139 {
+ struct A {
+ A() : value(1) { }
+ A(A const &, int value = 2) : value(value) { }
+ int value;
+
+ static A makeA() { A a; a.value = 2; return a; }
+ };
+
+ // CHECK: define i32 @_ZN7PR121394testEv
+ int test() {
+ // CHECK: call void @_ZN7PR121391A5makeAEv
+ // CHECK-NEXT: call void @_ZN7PR121391AC1ERKS0_i
+ A a(A::makeA(), 3);
+ // CHECK-NEXT: getelementptr inbounds
+ // CHECK-NEXT: load
+ // CHECK-NEXT: ret i32
+ return a.value;
+ }
+}
+
diff --git a/test/CodeGenCXX/cxx-apple-kext.cpp b/test/CodeGenCXX/cxx-apple-kext.cpp
index e9a1727..e5ec78b 100644
--- a/test/CodeGenCXX/cxx-apple-kext.cpp
+++ b/test/CodeGenCXX/cxx-apple-kext.cpp
@@ -1,6 +1,6 @@
-// RUN: %clangxx -ccc-host-triple x86_64-apple-darwin10 %s -flto -S -o - |\
+// RUN: %clangxx -target x86_64-apple-darwin10 %s -flto -S -o - |\
// RUN: FileCheck --check-prefix=CHECK-NO-KEXT %s
-// RUN: %clangxx -ccc-host-triple x86_64-apple-darwin10 %s -fapple-kext -flto -S -o - |\
+// RUN: %clangxx -target x86_64-apple-darwin10 %s -fapple-kext -flto -S -o - |\
// RUN: FileCheck --check-prefix=CHECK-KEXT %s
// CHECK-NO-KEXT-NOT: _GLOBAL__D_a
diff --git a/test/CodeGenCXX/cxx0x-initializer-array.cpp b/test/CodeGenCXX/cxx0x-initializer-array.cpp
new file mode 100644
index 0000000..b773178
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-initializer-array.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+struct A { int a[1]; };
+typedef A x[];
+int f() {
+ x{{{1}}};
+ // CHECK: define i32 @_Z1fv
+ // CHECK: store i32 1
+ // (It's okay if the output changes here, as long as we don't crash.)
+}
diff --git a/test/CodeGenCXX/cxx0x-initializer-references.cpp b/test/CodeGenCXX/cxx0x-initializer-references.cpp
new file mode 100644
index 0000000..4c847b8
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-initializer-references.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace reference {
+ struct A {
+ int i1, i2;
+ };
+
+ void single_init() {
+ // No superfluous instructions allowed here, they could be
+ // hiding extra temporaries.
+
+ // CHECK: store i32 1, i32*
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ const int &cri2a = 1;
+
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ const int &cri1a = {1};
+
+ // CHECK-NEXT: store i32 1, i32*
+ int i = 1;
+ // CHECK-NEXT: store i32* %{{.*}}, i32**
+ int &ri1a = {i};
+
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: memcpy
+ A a{1, 2};
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %
+ A &ra1a = {a};
+
+ // CHECK-NEXT: ret
+ }
+
+ void reference_to_aggregate() {
+ // CHECK: getelementptr {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: store i32 1
+ // CHECK-NEXT: getelementptr {{.*}}, i32 0, i32 1
+ // CHECK-NEXT: store i32 2
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %{{.*}}, align
+ const A &ra1{1, 2};
+
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]* %{{.*}}, i{{32|64}} 0, i{{32|64}} 0
+ // CHECK-NEXT: store i32 1
+ // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1
+ // CHECK-NEXT: store i32 2
+ // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1
+ // CHECK-NEXT: store i32 3
+ // CHECK-NEXT: store [3 x i32]* %{{.*}}, [3 x i32]** %{{.*}}, align
+ const int (&arrayRef)[] = {1, 2, 3};
+
+ // CHECK-NEXT: ret
+ }
+
+ struct B {
+ B();
+ ~B();
+ };
+
+ void single_init_temp_cleanup()
+ {
+ // Ensure lifetime extension.
+
+ // CHECK: call void @_ZN9reference1BC1Ev
+ // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %
+ const B &rb{ B() };
+ // CHECK: call void @_ZN9reference1BD1Ev
+ }
+
+}
diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
new file mode 100644
index 0000000..14d2f77
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - -verify %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+std::initializer_list<std::initializer_list<int>> pleasefail = {
+ {1, 2}, {3, 4}, {5, 6} // expected-error {{cannot compile}}
+};
diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
new file mode 100644
index 0000000..c533e45
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-startend.cpp
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation with __size_ replaced by __end_
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ const _E* __end_;
+
+ initializer_list(const _E* __b, const _E* __e)
+ : __begin_(__b),
+ __end_(__e)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __end_(nullptr) {}
+
+ size_t size() const {return __end_ - __begin_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __end_;}
+ };
+}
+
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, {{[^)]*}}), i32*
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
+void fn1(int i) {
+ // CHECK: define void @_Z3fn1i
+ // temporary array
+ // CHECK: [[array:%[^ ]+]] = alloca [3 x i32]
+ // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load
+ // CHECK-NEXT: store
+ // init the list
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]*
+ // CHECK-NEXT: store i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0, i{{32|64}} 3
+ // CHECK-NEXT: store i32*
+ std::initializer_list<int> intlist{1, 2, i};
+}
+
+struct destroyme1 {
+ ~destroyme1();
+};
+struct destroyme2 {
+ ~destroyme2();
+};
+
+
+void fn2() {
+ // CHECK: define void @_Z3fn2v
+ void target(std::initializer_list<destroyme1>);
+ // objects should be destroyed before dm2, after call returns
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn3() {
+ // CHECK: define void @_Z3fn3v
+ // objects should be destroyed after dm2
+ auto list = { destroyme1(), destroyme1() };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
new file mode 100644
index 0000000..81ce559
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+struct destroyme1 {
+ ~destroyme1();
+};
+struct destroyme2 {
+ ~destroyme2();
+};
+struct witharg1 {
+ witharg1(const destroyme1&);
+ ~witharg1();
+};
+struct wantslist1 {
+ wantslist1(std::initializer_list<destroyme1>);
+ ~wantslist1();
+};
+
+// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3]
+// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 }
+std::initializer_list<int> globalInitList1 = {1, 2, 3};
+
+// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer
+// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x
+// CHECK: appending global
+// CHECK: define internal void
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0
+// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1
+// CHECK: __cxa_atexit
+// CHECK: call void @_ZN10destroyme1D1Ev
+// CHECK: call void @_ZN10destroyme1D1Ev
+std::initializer_list<witharg1> globalInitList2 = {
+ witharg1(destroyme1()), witharg1(destroyme1())
+};
+
+void fn1(int i) {
+ // CHECK: define void @_Z3fn1i
+ // temporary array
+ // CHECK: [[array:%[^ ]+]] = alloca [3 x i32]
+ // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0
+ // CHECK-NEXT: store i32 1, i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: load
+ // CHECK-NEXT: store
+ // init the list
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: getelementptr inbounds [3 x i32]*
+ // CHECK-NEXT: store i32*
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: store i{{32|64}} 3
+ std::initializer_list<int> intlist{1, 2, i};
+}
+
+void fn2() {
+ // CHECK: define void @_Z3fn2v
+ void target(std::initializer_list<destroyme1>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn3() {
+ // CHECK: define void @_Z3fn3v
+ // objects should be destroyed after dm2
+ auto list = { destroyme1(), destroyme1() };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
+
+void fn4() {
+ // CHECK: define void @_Z3fn4v
+ void target(std::initializer_list<witharg1>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+ // CHECK: call void @_Z6targetSt16initializer_listI8witharg1E
+ target({ witharg1(destroyme1()), witharg1(destroyme1()) });
+ // CHECK: call void @_ZN8witharg1D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn5() {
+ // CHECK: define void @_Z3fn5v
+ // temps should be destroyed before dm2
+ // objects should be destroyed after dm2
+ // CHECK: call void @_ZN8witharg1C1ERK10destroyme1
+ auto list = { witharg1(destroyme1()), witharg1(destroyme1()) };
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN8witharg1D1Ev
+}
+
+void fn6() {
+ // CHECK: define void @_Z3fn6v
+ void target(const wantslist1&);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E
+ // CHECK: call void @_Z6targetRK10wantslist1
+ target({ destroyme1(), destroyme1() });
+ // CHECK: call void @_ZN10wantslist1D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn7() {
+ // CHECK: define void @_Z3fn7v
+ // temps should be destroyed before dm2
+ // object should be destroyed after dm2
+ // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E
+ wantslist1 wl = { destroyme1(), destroyme1() };
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10wantslist1D1Ev
+}
+
+void fn8() {
+ // CHECK: define void @_Z3fn8v
+ void target(std::initializer_list<std::initializer_list<destroyme1>>);
+ // objects should be destroyed before dm2, after call returns
+ // CHECK: call void @_Z6targetSt16initializer_listIS_I10destroyme1EE
+ std::initializer_list<destroyme1> inner;
+ target({ inner, { destroyme1() } });
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ // Only one destroy loop, since only one inner init list is directly inited.
+ // CHECK-NOT: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+void fn9() {
+ // CHECK: define void @_Z3fn9v
+ // objects should be destroyed after dm2
+ std::initializer_list<destroyme1> inner;
+ std::initializer_list<std::initializer_list<destroyme1>> list =
+ { inner, { destroyme1() } };
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ // Only one destroy loop, since only one inner init list is directly inited.
+ // CHECK-NOT: call void @_ZN10destroyme1D1Ev
+ // CHECK: ret void
+}
+
+struct haslist1 {
+ std::initializer_list<int> il;
+ haslist1();
+};
+
+// CHECK: define void @_ZN8haslist1C2Ev
+haslist1::haslist1()
+// CHECK: alloca [3 x i32]
+// CHECK: store i32 1
+// CHECK: store i32 2
+// CHECK: store i32 3
+// CHECK: store i{{32|64}} 3
+ : il{1, 2, 3}
+{
+ destroyme2 dm2;
+}
+
+struct haslist2 {
+ std::initializer_list<destroyme1> il;
+ haslist2();
+};
+
+// CHECK: define void @_ZN8haslist2C2Ev
+haslist2::haslist2()
+ : il{destroyme1(), destroyme1()}
+{
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+ // CHECK: call void @_ZN10destroyme1D1Ev
+}
+
+void fn10() {
+ // CHECK: define void @_Z4fn10v
+ // CHECK: alloca [3 x i32]
+ // CHECK: call noalias i8* @_Znw{{[jm]}}
+ // CHECK: store i32 1
+ // CHECK: store i32 2
+ // CHECK: store i32 3
+ // CHECK: store i32*
+ // CHECK: store i{{32|64}} 3
+ (void) new std::initializer_list<int> {1, 2, 3};
+}
+
+void fn11() {
+ // CHECK: define void @_Z4fn11v
+ (void) new std::initializer_list<destroyme1> {destroyme1(), destroyme1()};
+ // CHECK: call void @_ZN10destroyme1D1Ev
+ destroyme2 dm2;
+ // CHECK: call void @_ZN10destroyme2D1Ev
+}
+
+namespace PR12178 {
+ struct string {
+ string(int);
+ ~string();
+ };
+
+ struct pair {
+ string a;
+ int b;
+ };
+
+ struct map {
+ map(std::initializer_list<pair>);
+ };
+
+ map m{ {1, 2}, {3, 4} };
+}
diff --git a/test/CodeGenCXX/cxx11-unrestricted-union.cpp b/test/CodeGenCXX/cxx11-unrestricted-union.cpp
new file mode 100644
index 0000000..0397775
--- /dev/null
+++ b/test/CodeGenCXX/cxx11-unrestricted-union.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - | FileCheck %s
+
+struct A {
+ A(); A(const A&); A(A&&); A &operator=(const A&); A &operator=(A&&); ~A();
+};
+struct B {
+ B(); B(const B&); B(B&&); B &operator=(const B&); B &operator=(B&&); ~B();
+};
+
+union U {
+ U();
+ U(const U &);
+ U(U &&);
+ U &operator=(const U&);
+ U &operator=(U&&);
+ ~U();
+
+ A a;
+ int n;
+};
+
+// CHECK-NOT: _ZN1A
+U::U() {}
+U::U(const U&) {}
+U::U(U&&) {}
+U &U::operator=(const U&) { return *this; }
+U &U::operator=(U &&) { return *this; }
+U::~U() {}
+
+struct S {
+ S();
+ S(const S &);
+ S(S &&);
+ S &operator=(const S&);
+ S &operator=(S&&);
+ ~S();
+
+ union {
+ A a;
+ int n;
+ };
+ B b;
+ int m;
+};
+
+// CHECK: _ZN1SC2Ev
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S() {}
+
+// CHECK-NOT: _ZN1A
+
+// CHECK: _ZN1SC2ERKS_
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S(const S&) {}
+
+// CHECK-NOT: _ZN1A
+
+// CHECK: _ZN1SC2EOS_
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BC1Ev
+S::S(S&&) {}
+
+// CHECK-NOT: _ZN1A
+// CHECK-NOT: _ZN1B
+S &S::operator=(const S&) { return *this; }
+
+S &S::operator=(S &&) { return *this; }
+
+// CHECK: _ZN1SD2Ev
+// CHECK-NOT: _ZN1A
+// CHECK: _ZN1BD1Ev
+S::~S() {}
+
+// CHECK-NOT: _ZN1A
diff --git a/test/CodeGenCXX/cxx11-user-defined-literal.cpp b/test/CodeGenCXX/cxx11-user-defined-literal.cpp
new file mode 100644
index 0000000..347ffe9
--- /dev/null
+++ b/test/CodeGenCXX/cxx11-user-defined-literal.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct S { S(); ~S(); S(const S &); void operator()(int); };
+using size_t = decltype(sizeof(int));
+S operator"" _x(const char *, size_t);
+S operator"" _y(wchar_t);
+S operator"" _z(unsigned long long);
+S operator"" _f(long double);
+S operator"" _r(const char *);
+template<char...Cs> S operator"" _t() { return S(); }
+
+// CHECK: @[[s_foo:.*]] = {{.*}} constant [4 x i8] c"foo\00"
+// CHECK: @[[s_bar:.*]] = {{.*}} constant [4 x i8] c"bar\00"
+// CHECK: @[[s_123:.*]] = {{.*}} constant [4 x i8] c"123\00"
+// CHECK: @[[s_4_9:.*]] = {{.*}} constant [4 x i8] c"4.9\00"
+// CHECK: @[[s_0xffffeeee:.*]] = {{.*}} constant [11 x i8] c"0xffffeeee\00"
+
+void f() {
+ // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_foo]], i32 0, i32 0), i64 3)
+ // CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_bar]], i32 0, i32 0), i64 3)
+ // CHECK: call void @_Zli2_yw({{.*}} 97)
+ // CHECK: call void @_Zli2_zy({{.*}} 42)
+ // CHECK: call void @_Zli2_fe({{.*}} x86_fp80 0xK3FFF8000000000000000)
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ "foo"_x, "bar"_x, L'a'_y, 42_z, 1.0_f;
+
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_123]], i32 0, i32 0))
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([4 x i8]* @[[s_4_9]], i32 0, i32 0))
+ // CHECK: call void @_Zli2_rPKc({{.*}}, i8* getelementptr inbounds ([11 x i8]* @[[s_0xffffeeee]], i32 0, i32 0))
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ 123_r, 4.9_r, 0xffff\
+eeee_r;
+
+ // FIXME: This mangling is insane. Maybe we should have a special case for
+ // char parameter packs?
+ // CHECK: call void @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv({{.*}})
+ // CHECK: call void @_ZN1SD1Ev({{.*}})
+ 0x12345678_t;
+}
+
+// CHECK: define {{.*}} @_Zli2_tIJLc48ELc120ELc49ELc50ELc51ELc52ELc53ELc54ELc55ELc56EEE1Sv(
+
+template<typename T> auto g(T t) -> decltype("foo"_x(t)) { return "foo"_x(t); }
+template<typename T> auto i(T t) -> decltype(operator"" _x("foo", 3)(t)) { return operator"" _x("foo", 3)(t); }
+
+void h() {
+ g(42);
+ i(42);
+}
+
+// CHECK: define {{.*}} @_Z1hv()
+// CHECK: call void @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32 42)
+// CHECK: call void @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32 42)
+
+// CHECK: define {{.*}} @_Z1gIiEDTclclL_Zli2_xPKcmELA4_S0_ELm3EEfp_EET_(i32
+// CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
+// CHECK: call void @_ZN1SclEi
+// CHECK: call void @_ZN1SD1Ev
+
+// CHECK: define {{.*}} @_Z1iIiEDTclclL_Zli2_xPKcmELA4_S0_ELi3EEfp_EET_(i32
+// CHECK: call void @_Zli2_xPKcm({{.*}}, i8* getelementptr inbounds ([4 x i8]* @{{.*}}, i32 0, i32 0), i64 3)
+// CHECK: call void @_ZN1SclEi
+// CHECK: call void @_ZN1SD1Ev
diff --git a/test/CodeGenCXX/debug-info-artificial-arg.cpp b/test/CodeGenCXX/debug-info-artificial-arg.cpp
new file mode 100644
index 0000000..92d1b16
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-artificial-arg.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+template<class X> class B {
+public:
+ explicit B(X* p = 0);
+};
+
+class A
+{
+public:
+ A(int value) : m_a_value(value) {};
+ A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}
+
+ virtual ~A() {}
+
+private:
+ int m_a_value;
+ B<A> m_client_A;
+};
+
+int main(int argc, char **argv) {
+ A reallyA (500);
+}
+
+// FIXME: The numbers are truly awful.
+// CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ]
+// CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ]
+// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47, i32 12} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
+// CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34}
diff --git a/test/CodeGenCXX/debug-info-byval.cpp b/test/CodeGenCXX/debug-info-byval.cpp
index f0cb6d6..56ffe13 100644
--- a/test/CodeGenCXX/debug-info-byval.cpp
+++ b/test/CodeGenCXX/debug-info-byval.cpp
@@ -23,7 +23,7 @@ void foo(EVT e);
EVT bar();
void get(int *i, unsigned dl, VAL v, VAL *p, unsigned n, EVT missing_arg) {
-//CHECK: .ascii "missing_arg"
+//CHECK: .asciz "missing_arg"
EVT e = bar();
if (dl == n)
foo(missing_arg);
diff --git a/test/CodeGenCXX/debug-info-char16.cpp b/test/CodeGenCXX/debug-info-char16.cpp
index da8ca05..24216f9 100644
--- a/test/CodeGenCXX/debug-info-char16.cpp
+++ b/test/CodeGenCXX/debug-info-char16.cpp
@@ -1,9 +1,6 @@
-// RUN: %clang_cc1 -S -std=c++11 -masm-verbose -g %s -o -| FileCheck %s
-
-//CHECK: .ascii "char16_t"
-//CHECK-NEXT: .byte 0
-//CHECK-NEXT: .byte 16
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o -| FileCheck %s
// 16 is DW_ATE_UTF (0x10) encoding attribute.
char16_t char_a = u'h';
+// CHECK: !7 = metadata !{i32 {{.*}}, null, metadata !"char16_t", null, i32 0, i64 16, i64 16, i64 0, i32 0, i32 16} ; [ DW_TAG_base_type ]
diff --git a/test/CodeGenCXX/debug-info-context.cpp b/test/CodeGenCXX/debug-info-context.cpp
new file mode 100644
index 0000000..d6d44a1
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-context.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// PR11345
+
+class locale {
+private:
+ void _M_add_reference() const throw() {
+ }
+};
+class ios_base {
+ locale _M_ios_locale;
+public:
+ class Init {
+ };
+};
+static ios_base::Init __ioinit;
+
+// CHECK-NOT: _M_ios_locale
diff --git a/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp b/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
new file mode 100644
index 0000000..e67987b
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-dup-fwd-decl.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -fno-limit-debug-info %s -o - | FileCheck %s
+
+class Test
+{
+public:
+ Test () : reserved (new data()) {}
+
+ unsigned
+ getID() const
+ {
+ return reserved->objectID;
+ }
+protected:
+ struct data {
+ unsigned objectID;
+ };
+ data* reserved;
+};
+
+Test t;
+
+// CHECK: metadata !"", null, i32 0, i64 64, i64 64, i64 0, i32 0, metadata {{.*}} [ DW_TAG_pointer_type ]
+// CHECK: metadata !"data", metadata !6, i32 14, i64 32, i64 32, i32 0, i32 0
+// CHECK-NOT: metadata !"data", metadata {{.*}}, i32 14, i64 0, i64 0, i32 0, i32 4,
diff --git a/test/CodeGenCXX/debug-info-fn-template.cpp b/test/CodeGenCXX/debug-info-fn-template.cpp
index c8291af..bef9fe14 100644
--- a/test/CodeGenCXX/debug-info-fn-template.cpp
+++ b/test/CodeGenCXX/debug-info-fn-template.cpp
@@ -10,6 +10,6 @@ T fx(XF<T> xi) {
return xi.member;
}
-//CHECK: DW_TAG_template_type_parameter
//CHECK: XF<int>
+//CHECK: DW_TAG_template_type_parameter
template int fx(XF<int>);
diff --git a/test/CodeGenCXX/debug-info-fwd-ref.cpp b/test/CodeGenCXX/debug-info-fwd-ref.cpp
new file mode 100644
index 0000000..5480c6b
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-fwd-ref.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+struct baz {
+ int h;
+ baz(int a) : h(a) {}
+};
+
+struct bar {
+ baz b;
+ baz& b_ref;
+ bar(int x) : b(x), b_ref(b) {}
+};
+
+int main(int argc, char** argv) {
+ bar myBar(1);
+ return 0;
+}
+
+// Make sure we have two DW_TAG_class_types for baz and bar and no forward
+// references.
+// FIXME: These should be struct types to match the declaration.
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !23, i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 9, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ]
+// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_class_type ]
+
diff --git a/test/CodeGenCXX/debug-info-limit-type.cpp b/test/CodeGenCXX/debug-info-limit-type.cpp
new file mode 100644
index 0000000..e03024f
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-limit-type.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s
+// XFAIL: *
+
+class B {
+public:
+ int bb;
+ void fn2() {}
+};
+
+class A {
+public:
+ int aa;
+ void fn1(B b) { b.fn2(); }
+};
+
+void foo(A *aptr) {
+}
+
+void bar() {
+ A a;
+}
+
+// B should only be emitted as a forward reference (i32 4).
+// CHECK: metadata !"B", metadata !6, i32 3, i32 0, i32 0, i32 0, i32 4} ; [ DW_TAG_class_type ]
diff --git a/test/CodeGenCXX/debug-info-limit.cpp b/test/CodeGenCXX/debug-info-limit.cpp
index 75f9271..bca887b 100644
--- a/test/CodeGenCXX/debug-info-limit.cpp
+++ b/test/CodeGenCXX/debug-info-limit.cpp
@@ -7,8 +7,8 @@ public:
int z;
};
-A *foo () {
- A *a = new A();
+A *foo (A* x) {
+ A *a = new A(*x);
return a;
}
diff --git a/test/CodeGenCXX/debug-info-member.cpp b/test/CodeGenCXX/debug-info-member.cpp
index 5052a6c..8c2e3eb 100644
--- a/test/CodeGenCXX/debug-info-member.cpp
+++ b/test/CodeGenCXX/debug-info-member.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -fverbose-asm -cc1 -g -S %s -o - | grep DW_ACCESS_public
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_ACCESS_public
class A {
public:
int x;
diff --git a/test/CodeGenCXX/debug-info-method-spec.cpp b/test/CodeGenCXX/debug-info-method-spec.cpp
index 31f6663..2068c5c 100644
--- a/test/CodeGenCXX/debug-info-method-spec.cpp
+++ b/test/CodeGenCXX/debug-info-method-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -fverbose-asm -cc1 -g -S %s -o - | grep DW_AT_specification
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_AT_specification
// Radar 9254491
class A {
public:
diff --git a/test/CodeGenCXX/debug-info-method.cpp b/test/CodeGenCXX/debug-info-method.cpp
index 5935727..cb022bc 100644
--- a/test/CodeGenCXX/debug-info-method.cpp
+++ b/test/CodeGenCXX/debug-info-method.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -fverbose-asm -cc1 -g -S %s -o - | grep DW_ACCESS_protected
+// RUN: %clang -fverbose-asm -g -S %s -o - | grep DW_ACCESS_protected
class A {
protected:
int foo();
diff --git a/test/CodeGenCXX/debug-info-method2.cpp b/test/CodeGenCXX/debug-info-method2.cpp
new file mode 100644
index 0000000..a927c49
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-method2.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -flimit-debug-info -x c++ -g -S -emit-llvm < %s | FileCheck %s
+// rdar://10336845
+// Preserve type qualifiers in -flimit-debug-info mode.
+
+// CHECK: DW_TAG_const_type
+class A {
+public:
+ int bar(int arg) const;
+};
+
+int A::bar(int arg) const{
+ return arg+2;
+}
+
+int main() {
+ A a;
+ int i = a.bar(2);
+ return i;
+}
diff --git a/test/CodeGenCXX/debug-info-nullptr.cpp b/test/CodeGenCXX/debug-info-nullptr.cpp
index 588dc5f..5540a92 100644
--- a/test/CodeGenCXX/debug-info-nullptr.cpp
+++ b/test/CodeGenCXX/debug-info-nullptr.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang_cc1 -S -std=c++11 -masm-verbose -g %s -o -| FileCheck %s
-
-//CHECK: DW_TAG_unspecified_type
-//CHECK-NEXT: "nullptr_t"
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o -| FileCheck %s
void foo() {
decltype(nullptr) t = 0;
- }
+}
+
+// CHECK: !13 = metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ]
diff --git a/test/CodeGenCXX/debug-info-pubtypes.cpp b/test/CodeGenCXX/debug-info-pubtypes.cpp
index 35ba90b..a7abade 100644
--- a/test/CodeGenCXX/debug-info-pubtypes.cpp
+++ b/test/CodeGenCXX/debug-info-pubtypes.cpp
@@ -1,7 +1,9 @@
// REQUIRES: x86-64-registered-target
-// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -S %s -o %t
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -fno-limit-debug-info -S %s -o %t
// RUN: FileCheck %s < %t
+// FIXME: This testcase shouldn't rely on assembly emission.
+//CHECK: Lpubtypes_begin1:
//CHECK: .asciz "G"
//CHECK-NEXT: .long 0
//CHECK-NEXT: Lpubtypes_end1:
diff --git a/test/CodeGenCXX/debug-info-static-fns.cpp b/test/CodeGenCXX/debug-info-static-fns.cpp
new file mode 100644
index 0000000..485d28a
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-static-fns.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+namespace A {
+ static int a(int b) { return b + 4; }
+
+ int b(int c) { return c + a(c); }
+}
+
+// Verify that a is present and mangled.
+// CHECK: metadata !{i32 786478, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !14, i32 4} ; [ DW_TAG_subprogram ]
diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp
new file mode 100644
index 0000000..796a80f
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-template-limit.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
+
+// Check that this pointer type is TC<int>
+// CHECK: !10} ; [ DW_TAG_pointer_type
+// CHECK-NEXT: !10 ={{.*}}"TC<int>"
+
+template<typename T>
+class TC {
+public:
+ TC(const TC &) {}
+ TC() {}
+};
+
+TC<int> tci;
+
diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp
new file mode 100644
index 0000000..6208c80
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-template-member.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+class MyClass
+{
+public:
+ int add2(int j)
+ {
+ return add<2>(j);
+ }
+private:
+ template <int i> int add(int j)
+ {
+ return i + j;
+ }
+};
+
+MyClass m;
+
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"MyClass", metadata {{.*}}, i32 {{.*}}, i64 8, i64 8, i32 0, i32 0, null, metadata [[C_MEM:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]], metadata {{.*}}}
+// CHECK: [[C_TEMP]] = metadata !{i32 {{.*}}, i32 0, metadata {{.*}}, metadata !"add<2>", metadata !"add<2>", metadata !"_ZN7MyClass3addILi2EEEii", metadata {{.*}}
diff --git a/test/CodeGenCXX/debug-info-template-recursive.cpp b/test/CodeGenCXX/debug-info-template-recursive.cpp
new file mode 100644
index 0000000..ef04d03
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-template-recursive.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+
+class base { };
+
+template <class T> class foo : public base {
+ void operator=(const foo r) { }
+};
+
+class bar : public foo<void> { };
+bar filters;
+
+// For now check that it simply doesn't crash.
+// CHECK: {{.*}}
diff --git a/test/CodeGenCXX/debug-info-use-after-free.cpp b/test/CodeGenCXX/debug-info-use-after-free.cpp
new file mode 100644
index 0000000..9757ca4
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-use-after-free.cpp
@@ -0,0 +1,312 @@
+// RUN: %clang_cc1 -g -emit-llvm-only %s
+// Check that we don't crash.
+// PR12305, PR12315
+
+# 1 "a.h" 3
+template < typename T1 > struct Types1
+{
+ typedef T1 Head;
+};
+template < typename > struct Types;
+template < template < typename > class Tmpl > struct TemplateSel
+{
+ template < typename T > struct Bind
+ {
+ typedef Tmpl < T > type;
+ };
+};
+template < typename > struct NoneT;
+template < template < typename > class T1, template < typename > class > struct Templates2
+{
+ typedef TemplateSel < T1 > Head;
+};
+template < template < typename > class, template < typename > class =
+ NoneT, template < typename > class = NoneT, template < typename > class =
+ NoneT > struct Templates;
+template < template < typename > class T1,
+ template < typename > class T2 > struct Templates <T1, T2 >
+{
+ typedef Templates2 < T1, T2 > type;
+};
+template < typename T > struct TypeList
+{
+ typedef Types1 < T > type;
+};
+template < template < typename > class, class TestSel,
+ typename Types > class TypeParameterizedTest
+{
+public:static bool Register ()
+ {
+ typedef typename Types::Head Type;
+ typename TestSel::template Bind < Type >::type TestClass;
+}};
+
+template < template < typename > class Fixture, typename Tests,
+ typename Types > class TypeParameterizedTestCase
+{
+public:static bool Register (char *, char *, int *)
+ {
+ typedef typename Tests::Head Head;
+ TypeParameterizedTest < Fixture, Head, Types >::Register;
+}};
+
+template < typename > class TypedTestP1
+{
+};
+
+namespace gtest_case_TypedTestP1_
+{
+ template < typename gtest_TypeParam_ > class A:TypedTestP1 <
+ gtest_TypeParam_ >
+ {
+ };
+template < typename gtest_TypeParam_ > class B:TypedTestP1 <
+ gtest_TypeParam_ >
+ {
+ };
+ typedef Templates < A >::type gtest_AllTests_;
+}
+
+template < typename > class TypedTestP2
+{
+};
+
+namespace gtest_case_TypedTestP2_
+{
+ template < typename gtest_TypeParam_ > class A:TypedTestP2 <
+ gtest_TypeParam_ >
+ {
+ };
+ typedef Templates < A >::type gtest_AllTests_;
+}
+
+bool gtest_Int_TypedTestP1 =
+ TypeParameterizedTestCase < TypedTestP1,
+ gtest_case_TypedTestP1_::gtest_AllTests_,
+ TypeList < int >::type >::Register ("Int", "TypedTestP1", 0);
+bool gtest_Int_TypedTestP2 =
+ TypeParameterizedTestCase < TypedTestP2,
+ gtest_case_TypedTestP2_::gtest_AllTests_,
+ TypeList < Types < int > >::type >::Register ("Int", "TypedTestP2", 0);
+
+template < typename _Tp > struct new_allocator
+{
+ typedef _Tp *pointer;
+ template < typename > struct rebind {
+ typedef new_allocator other;
+ };
+};
+template < typename _Tp > struct allocator:new_allocator < _Tp > {
+};
+template < typename _Tp, typename _Alloc > struct _Vector_base {
+ typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
+ struct _Vector_impl {
+ typename _Tp_alloc_type::pointer _M_end_of_storage;
+ };
+ _Vector_base () {
+ foo((int *) this->_M_impl._M_end_of_storage);
+ }
+ void foo(int *);
+ _Vector_impl _M_impl;
+};
+template < typename _Tp, typename _Alloc =
+allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
+
+
+template < class T> struct HHH {};
+struct DDD { int x_;};
+struct Data;
+struct X1;
+struct CCC:DDD { virtual void xxx (HHH < X1 >); };
+template < class SSS > struct EEE:vector < HHH < SSS > > { };
+template < class SSS, class = EEE < SSS > >class FFF { };
+template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
+class BBB:virtual CCC {
+ void xxx (HHH < X1 >);
+ vector < HHH < X1 > >aaa;
+};
+class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
+ZZZ * ZZZ::ppp () { return new ZZZ; }
+
+namespace std
+{
+ template < class, class > struct pair;
+}
+namespace __gnu_cxx {
+template < typename > class new_allocator;
+}
+namespace std {
+template < typename _Tp > class allocator:__gnu_cxx::new_allocator < _Tp > {
+};
+template < typename, typename > struct _Vector_base {
+};
+template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:_Vector_base < _Tp,
+ _Alloc
+ > {
+ };
+}
+
+namespace
+std {
+ template <
+ typename,
+ typename > struct unary_function;
+ template <
+ typename,
+ typename,
+ typename > struct binary_function;
+ template <
+ typename
+ _Tp > struct equal_to:
+ binary_function <
+ _Tp,
+ _Tp,
+ bool > {
+ };
+ template <
+ typename
+ _Pair > struct _Select1st:
+ unary_function <
+ _Pair,
+ typename
+ _Pair::first_type > {
+ };
+}
+# 1 "f.h" 3
+using
+std::pair;
+namespace
+__gnu_cxx {
+ template <
+ class > struct hash;
+ template <
+ class,
+ class,
+ class,
+ class,
+ class
+ _EqualKey,
+ class >
+ class
+ hashtable {
+ public:
+ typedef _EqualKey
+ key_equal;
+ };
+ using
+ std::equal_to;
+ using
+ std::allocator;
+ using
+ std::_Select1st;
+ template < class _Key, class _Tp, class _HashFn =
+ hash < _Key >, class _EqualKey = equal_to < _Key >, class _Alloc =
+ allocator < _Tp > >class hash_map {
+ typedef
+ hashtable <
+ pair <
+ _Key,
+ _Tp >,
+ _Key,
+ _HashFn,
+ _Select1st <
+ pair <
+ _Key,
+ _Tp > >,
+ _EqualKey,
+ _Alloc >
+ _Ht;
+ public:
+ typename _Ht::key_type;
+ typedef typename
+ _Ht::key_equal
+ key_equal;
+ };
+}
+using
+__gnu_cxx::hash_map;
+class
+C2;
+template < class > class scoped_ptr {
+};
+namespace {
+class
+ AAA {
+ virtual ~
+ AAA () {
+ }};
+}
+template < typename > class EEE;
+template < typename CCC, typename =
+typename CCC::key_equal, typename =
+EEE < CCC > >class III {
+};
+namespace
+util {
+ class
+ EEE {
+ };
+}
+namespace {
+class
+ C1:
+ util::EEE {
+ public:
+ class
+ C3:
+ AAA {
+ struct FFF;
+ typedef
+ III <
+ hash_map <
+ C2,
+ FFF > >
+ GGG;
+ GGG
+ aaa;
+ friend
+ C1;
+ };
+ void
+ HHH (C3::GGG &);
+ };
+}
+namespace
+n1 {
+ class
+ Test {
+ };
+ template <
+ typename >
+ class
+ C7 {
+ };
+ class
+ C4:
+ n1::Test {
+ vector <
+ C1::C3 * >
+ a1;
+ };
+ enum C5 { };
+ class
+ C6:
+ C4,
+ n1::C7 <
+ C5 > {
+ };
+ class
+ C8:
+ C6 {
+ };
+ class
+ C9:
+ C8 {
+ void
+ TestBody ();
+ };
+ void
+ C9::TestBody () {
+ scoped_ptr < C1::C3 > context;
+ }
+}
diff --git a/test/CodeGenCXX/debug-lambda-expressions.cpp b/test/CodeGenCXX/debug-lambda-expressions.cpp
new file mode 100644
index 0000000..859a71b
--- /dev/null
+++ b/test/CodeGenCXX/debug-lambda-expressions.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s
+
+auto var = [](int i) { return i+1; };
+
+extern "C" auto cvar = []{};
+
+int a() { return []{ return 1; }(); }
+
+int b(int x) { return [x]{return x;}(); }
+
+int c(int x) { return [&x]{return x;}(); }
+
+struct D { D(); D(const D&); int x; };
+int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
+
+
+// A: 5
+// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE:.*]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ]
+
+// Randomness for file. -- 6
+// CHECK: [[FILE]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ]
+
+// B: 12
+// CHECK: [[B_FUNC:.*]] = metadata !{i32 786478, i32 0, metadata [[FILE]], metadata !"b", metadata !"b", metadata !"_Z1bi", metadata [[FILE]], i32 [[B_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1bi, null, null, {{.*}} ; [ DW_TAG_subprogram ]
+
+// C: 17
+// CHECK: [[C_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"c", metadata !"c", metadata !"_Z1ci", metadata [[FILE]], i32 [[C_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1ci, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ]
+
+// D: 20
+// CHECK: [[D_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"d", metadata !"d", metadata !"_Z1di", metadata [[FILE]], i32 [[D_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1di, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ]
+
+// Back to D. -- 120
+// CHECK: [[LAM_D:.*]] = metadata !{i32 {{.*}}, metadata [[D_FUNC]], metadata !"", metadata [[FILE]], i32 [[D_LINE]], i64 352, i64 32, i32 0, i32 0, null, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]}
+// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 14, i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ]
+// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 14, i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+
+// Back to C. -- 159
+// CHECK: [[LAM_C:.*]] = metadata !{i32 {{.*}}, metadata [[C_FUNC]], metadata !"", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i32 0, i32 0, null, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]}
+// Ignoring the member type for now.
+// CHECK: [[CAP_C]] = metadata !{i32 {{.*}}, metadata [[LAM_C]], metadata !"x", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+
+// Back to B. -- 179
+// CHECK: [[LAM_B:.*]] = metadata !{i32 {{.*}}, metadata [[B_FUNC]], metadata !"", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i32 0, i32 0, null, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]}
+// CHECK: [[CAP_B]] = metadata !{i32 {{.*}}, metadata [[LAM_B]], metadata !"x", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ]
+// CHECK: [[CON_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+// Back to A. -- 204
+// CHECK: [[LAM_A:.*]] = metadata !{i32 {{.*}}, metadata [[A_FUNC]], metadata !"", metadata [[FILE]], i32 [[A_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]}
+// CHECK: [[CON_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ]
+// CHECK: [[DES_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ]
+
+// VAR:
+// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ]
+// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
+
+// CVAR:
+// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"cvar", metadata !"cvar", metadata !"", metadata [[FILE]], i32 [[CVAR_LINE:.*]], metadata ![[CVAR_T:.*]], i32 0, i32 1, %class.anon.0* @cvar} ; [ DW_TAG_variable ]
+// CHECK: [[CVAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[CVAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ]
+// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}}
diff --git a/test/CodeGenCXX/default-arguments.cpp b/test/CodeGenCXX/default-arguments.cpp
index 6560d35..206d4d6 100644
--- a/test/CodeGenCXX/default-arguments.cpp
+++ b/test/CodeGenCXX/default-arguments.cpp
@@ -63,3 +63,14 @@ void f3() {
B *bs = new B[2];
delete bs;
}
+
+void f4() {
+ void g4(int a, int b = 7);
+ {
+ void g4(int a, int b = 5);
+ }
+ void g4(int a = 5, int b);
+
+ // CHECK: call void @_Z2g4ii(i32 5, i32 7)
+ g4();
+}
diff --git a/test/CodeGenCXX/empty-union.cpp b/test/CodeGenCXX/empty-union.cpp
index 118a0d2..7f3e6cc 100644
--- a/test/CodeGenCXX/empty-union.cpp
+++ b/test/CodeGenCXX/empty-union.cpp
@@ -1,10 +1,7 @@
// RUN: %clang_cc1 -emit-llvm -o - %s
union sigval { };
+union sigval Test1;
-union sigval sigev_value;
-
-int main()
-{
- return sizeof(sigev_value);
-}
+union NonPODUnion { ~NonPODUnion(); };
+union NonPODUnion Test2;
diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp
index 0fbb09c..079c1e5 100644
--- a/test/CodeGenCXX/exceptions.cpp
+++ b/test/CodeGenCXX/exceptions.cpp
@@ -53,8 +53,8 @@ namespace test1 {
A *c() {
// CHECK: define [[A:%.*]]* @_ZN5test11cEv()
// CHECK: [[ACTIVE:%.*]] = alloca i1
- // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
// CHECK: [[T1:%.*]] = getelementptr inbounds [[B]]* [[T0]], i32 0, i32 0
@@ -72,8 +72,8 @@ namespace test1 {
A *d() {
// CHECK: define [[A:%.*]]* @_ZN5test11dEv()
// CHECK: [[ACTIVE:%.*]] = alloca i1
- // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
// CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
@@ -90,8 +90,8 @@ namespace test1 {
A *e() {
// CHECK: define [[A:%.*]]* @_ZN5test11eEv()
// CHECK: [[ACTIVE:%.*]] = alloca i1
- // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
// CHECK-NEXT: invoke void @_ZN5test11BC1Ev([[B:%.*]]* [[T0:%.*]])
// CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
@@ -121,8 +121,8 @@ namespace test1 {
// CHECK: define [[A:%.*]]* @_ZN5test11iEv()
// CHECK: [[X:%.*]] = alloca [[A]]*, align 8
// CHECK: [[ACTIVE:%.*]] = alloca i1
- // CHECK: store i1 true, i1* [[ACTIVE]]
- // CHECK-NEXT: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK: [[NEW:%.*]] = call noalias i8* @_Znwm(i64 8)
+ // CHECK-NEXT: store i1 true, i1* [[ACTIVE]]
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
// CHECK-NEXT: invoke void @_ZN5test15makeBEv([[B:%.*]]* sret [[T0:%.*]])
// CHECK: [[T1:%.*]] = invoke i32 @_ZN5test11BcviEv([[B]]* [[T0]])
@@ -194,12 +194,9 @@ namespace test3 {
// CHECK: [[SAVED0:%.*]] = alloca i8*
// CHECK-NEXT: [[SAVED1:%.*]] = alloca i8*
// CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
- // CHECK-NEXT: [[TMP:%.*]] = alloca [[A]], align 8
- // CHECK: [[TMPACTIVE:%.*]] = alloca i1
- // CHECK-NEXT: store i1 false, i1* [[CLEANUPACTIVE]]
// CHECK: [[COND:%.*]] = trunc i8 {{.*}} to i1
- // CHECK-NEXT: store i1 false, i1* [[TMPACTIVE]]
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUPACTIVE]]
// CHECK-NEXT: br i1 [[COND]]
return (cond ?
@@ -209,24 +206,18 @@ namespace test3 {
// CHECK-NEXT: store i8* [[FOO]], i8** [[SAVED1]]
// CHECK-NEXT: store i1 true, i1* [[CLEANUPACTIVE]]
// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[NEW]] to [[A]]*
- // CHECK-NEXT: invoke void @_ZN5test35makeAEv([[A]]* sret [[TMP]])
- // CHECK: store i1 true, i1* [[TMPACTIVE]]
- // CHECK-NEXT: invoke void @_ZN5test31AC1ERKS0_([[A]]* [[CAST]], [[A]]* [[TMP]])
- // CHECK: store i1 false, i1* [[CLEANUPACTIVE]]
- // CHECK-NEXT: br label
+ // CHECK-NEXT: invoke void @_ZN5test35makeAEv([[A]]* sret [[CAST]])
+ // CHECK: br label
// -> cond.end
new(foo(),10.0) A(makeA()) :
- // CHECK: [[MAKE:%.*]] = invoke [[A]]* @_ZN5test38makeAPtrEv()
+ // CHECK: [[MAKE:%.*]] = call [[A]]* @_ZN5test38makeAPtrEv()
// CHECK: br label
// -> cond.end
makeAPtr());
// cond.end:
// CHECK: [[RESULT:%.*]] = phi [[A]]* {{.*}}[[CAST]]{{.*}}[[MAKE]]
- // CHECK-NEXT: [[ISACTIVE:%.*]] = load i1* [[TMPACTIVE]]
- // CHECK-NEXT: br i1 [[ISACTIVE]]
- // CHECK: invoke void @_ZN5test31AD1Ev
// CHECK: ret [[A]]* [[RESULT]]
// in the EH path:
@@ -330,17 +321,15 @@ namespace test7 {
// CHECK-NEXT: alloca [[A]]
// CHECK-NEXT: [[INNER_A:%.*]] = alloca i1
- // These entry-block stores are to deactivate the delete cleanups.
- // CHECK-NEXT: store i1 false, i1* [[INNER_NEW]]
- // CHECK-NEXT: store i1 false, i1* [[OUTER_NEW]]
-
// Allocate the outer object.
// CHECK-NEXT: [[NEW:%.*]] = call i8* @_ZN5test71BnwEm(
// CHECK-NEXT: icmp eq i8* [[NEW]], null
// These stores, emitted before the outermost conditional branch,
// deactivate the temporary cleanups.
+ // CHECK-NEXT: store i1 false, i1* [[OUTER_NEW]]
// CHECK-NEXT: store i1 false, i1* [[OUTER_A]]
+ // CHECK-NEXT: store i1 false, i1* [[INNER_NEW]]
// CHECK-NEXT: store i1 false, i1* [[INNER_A]]
// CHECK-NEXT: br i1
diff --git a/test/CodeGenCXX/field-access-debug-info.cpp b/test/CodeGenCXX/field-access-debug-info.cpp
index 907fe04..fd899ed 100644
--- a/test/CodeGenCXX/field-access-debug-info.cpp
+++ b/test/CodeGenCXX/field-access-debug-info.cpp
@@ -1,5 +1,8 @@
-// RUN: %clang_cc1 -g -S -masm-verbose -o %t %s
-// RUN: grep DW_AT_accessibility %t
+// RUN: %clang_cc1 -g -S -masm-verbose -o - %s | FileCheck %s
+
+// CHECK: abbrev_begin:
+// CHECK: DW_AT_accessibility
+// CHECK-NEXT: DW_FORM_data1
class A {
public:
diff --git a/test/CodeGenCXX/for-range-temporaries.cpp b/test/CodeGenCXX/for-range-temporaries.cpp
index c705702..a03bb0a 100644
--- a/test/CodeGenCXX/for-range-temporaries.cpp
+++ b/test/CodeGenCXX/for-range-temporaries.cpp
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR %s | opt -instnamer -S | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -UDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -std=c++11 -emit-llvm -o - -DDESUGAR -DTEMPLATE -DDEPENDENT %s | opt -instnamer -S | FileCheck %s
struct A {
A();
@@ -67,7 +70,11 @@ struct I {
void body(const I &);
#ifdef TEMPLATE
+#ifdef DEPENDENT
template<typename D>
+#else
+template<typename>
+#endif
#endif
void for_temps() {
A a;
diff --git a/test/CodeGenCXX/forward-enum.cpp b/test/CodeGenCXX/forward-enum.cpp
new file mode 100644
index 0000000..c1169e0
--- /dev/null
+++ b/test/CodeGenCXX/forward-enum.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11.0.0 -emit-llvm -o - %s | FileCheck %s
+
+enum MyEnum : char;
+void bar(MyEnum value) { }
+
+// CHECK: define void @_Z3foo6MyEnum
+void foo(MyEnum value)
+{
+ // CHECK: call void @_Z3bar6MyEnum(i8 signext
+ bar(value);
+}
diff --git a/test/CodeGenCXX/global-dtor-no-atexit.cpp b/test/CodeGenCXX/global-dtor-no-atexit.cpp
index 1e125e3..def97b2 100644
--- a/test/CodeGenCXX/global-dtor-no-atexit.cpp
+++ b/test/CodeGenCXX/global-dtor-no-atexit.cpp
@@ -3,10 +3,15 @@
// PR7097
// RUN: %clang_cc1 -triple x86_64 %s -fno-use-cxa-atexit -mconstructor-aliases -emit-llvm -o - | FileCheck %s
-// CHECK: define internal void @_GLOBAL__D_a()
-// CHECK: call void @_ZN1AD1Ev(%class.A* @b)
-// CHECK: call void @_ZN1AD1Ev(%class.A* @a)
-// CHECK: }
+// CHECK: call void @_ZN1AC1Ev([[A:%.*]]* @a)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_a)
+// CHECK: define internal void @__dtor_a() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @a)
+
+// CHECK: call void @_ZN1AC1Ev([[A]]* @b)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor_b)
+// CHECK: define internal void @__dtor_b() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @b)
class A {
public:
@@ -15,3 +20,25 @@ public:
};
A a, b;
+
+// PR9593
+// CHECK: define void @_Z4funcv()
+// CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a1)
+// CHECK: call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a1)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a1)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a1)
+
+// CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ4funcvE2a2)
+// CHECK: call void @_ZN1AC1Ev([[A]]* @_ZZ4funcvE2a2)
+// CHECK-NEXT: call i32 @atexit(void ()* @__dtor__ZZ4funcvE2a2)
+// CHECK-NEXT: call void @__cxa_guard_release(i64* @_ZGVZ4funcvE2a2)
+
+// CHECK: define internal void @__dtor__ZZ4funcvE2a1() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a1)
+
+// CHECK: define internal void @__dtor__ZZ4funcvE2a2() nounwind
+// CHECK: call void @_ZN1AD1Ev([[A]]* @_ZZ4funcvE2a2)
+
+void func() {
+ static A a1, a2;
+}
diff --git a/test/CodeGenCXX/global-init.cpp b/test/CodeGenCXX/global-init.cpp
index 053210b..8e6ef77 100644
--- a/test/CodeGenCXX/global-init.cpp
+++ b/test/CodeGenCXX/global-init.cpp
@@ -12,7 +12,7 @@ struct C { void *field; };
struct D { ~D(); };
-// CHECK: @__dso_handle = external unnamed_addr global i8*
+// CHECK: @__dso_handle = external unnamed_addr global i8
// CHECK: @c = global %struct.C zeroinitializer, align 8
// It's okay if we ever implement the IR-generation optimization to remove this.
@@ -24,18 +24,18 @@ struct D { ~D(); };
// CHECK: @_ZN6PR59741bE = global %"struct.PR5974::B"* bitcast (i8* getelementptr (i8* bitcast (%"struct.PR5974::C"* @_ZN6PR59741cE to i8*), i64 4) to %"struct.PR5974::B"*), align 8
// CHECK: call void @_ZN1AC1Ev(%struct.A* @a)
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @a, i32 0, i32 0), i8* @__dso_handle)
A a;
// CHECK: call void @_ZN1BC1Ev(%struct.B* @b)
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.B*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.B* @b, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.B*)* @_ZN1BD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.B* @b, i32 0, i32 0), i8* @__dso_handle)
B b;
// PR6205: this should not require a global initializer
// CHECK-NOT: call void @_ZN1CC1Ev(%struct.C* @c)
C c;
-// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.D*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.D* @d, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+// CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.D*)* @_ZN1DD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.D* @d, i32 0, i32 0), i8* @__dso_handle)
D d;
// <rdar://problem/7458115>
diff --git a/test/CodeGenCXX/goto.cpp b/test/CodeGenCXX/goto.cpp
index f32847d..77b6166 100644
--- a/test/CodeGenCXX/goto.cpp
+++ b/test/CodeGenCXX/goto.cpp
@@ -16,10 +16,10 @@ namespace test0 {
// CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
// CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
// CHECK-NEXT: [[CLEANUPACTIVE:%.*]] = alloca i1
- // CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
// CHECK: call void @_ZN5test01AC1Ev([[A]]* [[Y]])
// CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[Z]])
// CHECK: [[NEW:%.*]] = invoke noalias i8* @_Znwm(i64 1)
+ // CHECK: store i1 true, i1* [[CLEANUPACTIVE]]
// CHECK: [[NEWCAST:%.*]] = bitcast i8* [[NEW]] to [[V]]*
// CHECK-NEXT: invoke void @_ZN5test01AC1Ev([[A]]* [[TMP]])
// CHECK: invoke void @_ZN5test01VC1ERKNS_1AE([[V]]* [[NEWCAST]], [[A]]* [[TMP]])
diff --git a/test/CodeGenCXX/inheriting-constructor.cpp b/test/CodeGenCXX/inheriting-constructor.cpp
new file mode 100644
index 0000000..b921a6d
--- /dev/null
+++ b/test/CodeGenCXX/inheriting-constructor.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+// PR12219
+struct A { A(int); virtual ~A(); };
+struct B : A { using A::A; ~B(); };
+B::~B() {}
+// CHECK: define void @_ZN1BD0Ev
+// CHECK: define void @_ZN1BD1Ev
+// CHECK: define void @_ZN1BD2Ev
diff --git a/test/CodeGenCXX/init-invariant.cpp b/test/CodeGenCXX/init-invariant.cpp
new file mode 100644
index 0000000..9eb1989
--- /dev/null
+++ b/test/CodeGenCXX/init-invariant.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O0 -o - | FileCheck %s --check-prefix=CHECK-O0
+// RUN: %clang_cc1 -triple i686-linux-gnu -emit-llvm %s -O1 -o - | FileCheck %s
+
+// Check that we add an llvm.invariant.start to mark when a global becomes
+// read-only. If globalopt can fold the initializer, it will then mark the
+// variable as constant.
+
+// Do not produce markers at -O0.
+// CHECK-O0-NOT: llvm.invariant.start
+
+struct A {
+ A();
+ int n;
+};
+
+// CHECK: @a = global {{.*}} zeroinitializer
+extern const A a = A();
+
+struct B {
+ B();
+ mutable int n;
+};
+
+// CHECK: @b = global {{.*}} zeroinitializer
+extern const B b = B();
+
+struct C {
+ C();
+ ~C();
+ int n;
+};
+
+// CHECK: @c = global {{.*}} zeroinitializer
+extern const C c = C();
+
+int f();
+// CHECK: @d = global i32 0
+extern const int d = f();
+
+void e() {
+ static const A a = A();
+}
+
+// CHECK: call void @_ZN1AC1Ev({{.*}}* @a)
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @a to i8*))
+
+// CHECK: call void @_ZN1BC1Ev({{.*}}* @b)
+// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @b to i8*))
+
+// CHECK: call void @_ZN1CC1Ev({{.*}}* @c)
+// CHECK-NOT: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @c to i8*))
+
+// CHECK: call i32 @_Z1fv(
+// CHECK: store {{.*}}, i32* @d
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @d to i8*))
+
+// CHECK: define void @_Z1ev(
+// CHECK: call void @_ZN1AC1Ev(%struct.A* @_ZZ1evE1a)
+// CHECK: call {{.*}}@llvm.invariant.start(i64 4, i8* bitcast ({{.*}} @_ZZ1evE1a to i8*))
+// CHECK-NOT: llvm.invariant.end
diff --git a/test/CodeGenCXX/instantiate-temporaries.cpp b/test/CodeGenCXX/instantiate-temporaries.cpp
new file mode 100644
index 0000000..29cfc07
--- /dev/null
+++ b/test/CodeGenCXX/instantiate-temporaries.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
+
+struct X {
+ X();
+ ~X();
+};
+
+struct Y {
+ X get();
+};
+
+struct X2 {
+ X x;
+};
+
+template<typename T>
+void call() {
+ Y().get();
+}
+
+// CHECK: define weak_odr void @_Z4callIiEvv
+// CHECK: call void @_ZN1Y3getEv
+// CHECK-NEXT: call void @_ZN1XD1Ev
+// CHECK-NEXT: ret void
+template void call<int>();
+
+template<typename T>
+void compound_literal() {
+ (X2){};
+}
+
+// CHECK: define weak_odr void @_Z16compound_literalIiEvv
+// CHECK: call void @_ZN1XC1Ev
+// CHECK-NEXT: call void @_ZN2X2D1Ev
+// CHECK-NEXT: ret void
+template void compound_literal<int>();
+
diff --git a/test/CodeGenCXX/lambda-expressions.cpp b/test/CodeGenCXX/lambda-expressions.cpp
new file mode 100644
index 0000000..797cbf4
--- /dev/null
+++ b/test/CodeGenCXX/lambda-expressions.cpp
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
+
+// CHECK: @var = internal global
+auto var = [](int i) { return i+1; };
+
+// CHECK: @cvar = global
+extern "C" auto cvar = []{};
+
+int a() { return []{ return 1; }(); }
+// CHECK: define i32 @_Z1av
+// CHECK: call i32 @"_ZZ1avENK3$_0clEv"
+// CHECK: define internal i32 @"_ZZ1avENK3$_0clEv"
+// CHECK: ret i32 1
+
+int b(int x) { return [x]{return x;}(); }
+// CHECK: define i32 @_Z1bi
+// CHECK: store i32
+// CHECK: load i32*
+// CHECK: store i32
+// CHECK: call i32 @"_ZZ1biENK3$_1clEv"
+// CHECK: define internal i32 @"_ZZ1biENK3$_1clEv"
+// CHECK: load i32*
+// CHECK: ret i32
+
+int c(int x) { return [&x]{return x;}(); }
+// CHECK: define i32 @_Z1ci
+// CHECK: store i32
+// CHECK: store i32*
+// CHECK: call i32 @"_ZZ1ciENK3$_2clEv"
+// CHECK: define internal i32 @"_ZZ1ciENK3$_2clEv"
+// CHECK: load i32**
+// CHECK: load i32*
+// CHECK: ret i32
+
+struct D { D(); D(const D&); int x; };
+int d(int x) { D y[10]; [x,y] { return y[x].x; }(); }
+
+// CHECK: define i32 @_Z1di
+// CHECK: call void @_ZN1DC1Ev
+// CHECK: icmp ult i64 %{{.*}}, 10
+// CHECK: call void @_ZN1DC1ERKS_
+// CHECK: call i32 @"_ZZ1diENK3$_3clEv"
+// CHECK: define internal i32 @"_ZZ1diENK3$_3clEv"
+// CHECK: load i32*
+// CHECK: load i32*
+// CHECK: ret i32
+
+struct E { E(); E(const E&); ~E(); int x; };
+int e(E a, E b, bool cond) { [a,b,cond](){ return (cond ? a : b).x; }(); }
+// CHECK: define i32 @_Z1e1ES_b
+// CHECK: call void @_ZN1EC1ERKS_
+// CHECK: invoke void @_ZN1EC1ERKS_
+// CHECK: invoke i32 @"_ZZ1e1ES_bENK3$_4clEv"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
+// CHECK: call void @"_ZZ1e1ES_bEN3$_4D1Ev"
+
+// CHECK: define internal i32 @"_ZZ1e1ES_bENK3$_4clEv"
+// CHECK: trunc i8
+// CHECK: load i32*
+// CHECK: ret i32
+
+void f() {
+ // CHECK: define void @_Z1fv()
+ // CHECK: @"_ZZ1fvENK3$_5cvPFiiiEEv"
+ // CHECK-NEXT: store i32 (i32, i32)*
+ // CHECK-NEXT: ret void
+ int (*fp)(int, int) = [](int x, int y){ return x + y; };
+}
+
+// CHECK: define internal i32 @"_ZZ1fvEN3$_58__invokeEii"
+// CHECK: store i32
+// CHECK-NEXT: store i32
+// CHECK-NEXT: load i32*
+// CHECK-NEXT: load i32*
+// CHECK-NEXT: call i32 @"_ZZ1fvENK3$_5clEii"
+// CHECK-NEXT: ret i32
+
+// CHECK: define internal void @"_ZZ1e1ES_bEN3$_4D2Ev"
diff --git a/test/CodeGenCXX/mangle-98.cpp b/test/CodeGenCXX/mangle-98.cpp
new file mode 100644
index 0000000..a9ab6ca
--- /dev/null
+++ b/test/CodeGenCXX/mangle-98.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++98 | FileCheck %s
+
+template <bool B> struct S3 {};
+
+// CHECK: define void @_Z1f2S3ILb1EE
+void f(S3<true>) {}
+
+// CHECK: define void @_Z1f2S3ILb0EE
+void f(S3<false>) {}
+
+// CHECK: define void @_Z2f22S3ILb1EE
+void f2(S3<100>) {}
diff --git a/test/CodeGenCXX/mangle-address-space.cpp b/test/CodeGenCXX/mangle-address-space.cpp
index fbbcbfa..ff23c20 100644
--- a/test/CodeGenCXX/mangle-address-space.cpp
+++ b/test/CodeGenCXX/mangle-address-space.cpp
@@ -4,3 +4,9 @@
void f0(char *p) { }
// CHECK: define void @_Z2f0PU3AS1c
void f0(char __attribute__((address_space(1))) *p) { }
+
+struct OpaqueType;
+typedef OpaqueType __attribute__((address_space(100))) * OpaqueTypePtr;
+
+// CHECK: define void @_Z2f0PU5AS10010OpaqueType
+void f0(OpaqueTypePtr) { }
diff --git a/test/CodeGenCXX/mangle-alias-template.cpp b/test/CodeGenCXX/mangle-alias-template.cpp
index 1143ea1..5ace0b0 100644
--- a/test/CodeGenCXX/mangle-alias-template.cpp
+++ b/test/CodeGenCXX/mangle-alias-template.cpp
@@ -11,6 +11,10 @@ template<typename T> void g(T);
template<template<typename> class F> void h(F<int>);
+template<typename,typename,typename> struct S {};
+template<typename T, typename U> using U = S<T, int, U>;
+template<typename...Ts> void h(U<Ts...>, Ts...);
+
// CHECK: define void @_Z1zv(
void z() {
vector<int> VI;
@@ -38,4 +42,7 @@ void z() {
Vec<Vec<int>> VVI;
g(VVI);
// CHECK: call void @_Z1gI6vectorIS0_Ii5allocIiEES1_IS3_EEEvT_(
+
+ // CHECK: call void @_Z1hIJidEEv1UIDpT_ES2_
+ h({}, 0, 0.0);
}
diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp
index c5f72d8..30da4fb 100644
--- a/test/CodeGenCXX/mangle-exprs.cpp
+++ b/test/CodeGenCXX/mangle-exprs.cpp
@@ -1,5 +1,37 @@
// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
template < bool condition, typename T = void >
struct enable_if { typedef T type; };
@@ -28,6 +60,10 @@ namespace Casts {
void auto_(decltype(new auto(T()))) {
}
+ template< typename T >
+ void scalar_(decltype(T(), int())) {
+ }
+
// FIXME: Test const_cast, reinterpret_cast, dynamic_cast, which are
// a bit harder to use in template arguments.
template <unsigned N> struct T {};
@@ -48,6 +84,9 @@ namespace Casts {
// CHECK: define weak_odr void @_ZN5Casts5auto_IiEEvDTnw_DapicvT__EEE(
template void auto_<int>(int*);
+
+ // CHECK: define weak_odr void @_ZN5Casts7scalar_IiEEvDTcmcvT__Ecvi_EE(
+ template void scalar_<int>(int);
}
namespace test1 {
@@ -125,3 +164,30 @@ namespace test3 {
a(x, &X::member, ip);
}
}
+
+namespace test4 {
+ struct X {
+ X(int);
+ };
+
+ template <typename T>
+ void tf1(decltype(new T(1)) p)
+ {}
+
+ template <typename T>
+ void tf2(decltype(new T({1})) p)
+ {}
+
+ template <typename T>
+ void tf3(decltype(new T{1}) p)
+ {}
+
+ // CHECK: void @_ZN5test43tf1INS_1XEEEvDTnw_T_piLi1EEE
+ template void tf1<X>(X*);
+
+ // CHECK: void @_ZN5test43tf2INS_1XEEEvDTnw_T_piilLi1EEEE
+ template void tf2<X>(X*);
+
+ // CHECK: void @_ZN5test43tf3INS_1XEEEvDTnw_T_ilLi1EEE
+ template void tf3<X>(X*);
+}
diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp
new file mode 100644
index 0000000..cc53b01
--- /dev/null
+++ b/test/CodeGenCXX/mangle-lambdas.cpp
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define linkonce_odr void @_Z11inline_funci
+inline void inline_func(int n) {
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE_clEv
+ int i = []{ return 1; }();
+
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE0_clEv
+ int j = [=] { return n + i; }();
+
+ // CHECK: call double @_ZZ11inline_funciENKUlvE1_clEv
+ int k = [=] () -> double { return n + i; }();
+
+ // CHECK: call i32 @_ZZ11inline_funciENKUliE_clEi
+ int l = [=] (int x) -> int { return x + i; }(n);
+
+ int inner(int i = []{ return 17; }());
+ // CHECK: call i32 @_ZZ11inline_funciENKUlvE2_clEv
+ // CHECK-NEXT: call i32 @_Z5inneri
+ inner();
+
+ // CHECK-NEXT: ret void
+}
+
+void call_inline_func() {
+ inline_func(17);
+}
+
+struct S {
+ void f(int = []{return 1;}()
+ + []{return 2;}(),
+ int = []{return 3;}());
+ void g(int, int);
+};
+
+void S::g(int i = []{return 1;}(),
+ int j = []{return 2; }()) {}
+
+// CHECK: define void @_Z6test_S1S
+void test_S(S s) {
+ // CHECK: call i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv
+ // CHECK-NEXT: call i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv
+ // CHECK-NEXT: add nsw i32
+ // CHECK-NEXT: call i32 @_ZZN1S1fEiiEd_NKUlvE_clEv
+ // CHECK-NEXT: call void @_ZN1S1fEii
+ s.f();
+
+ // NOTE: These manglings don't actually matter that much, because
+ // the lambdas in the default arguments of g() won't be seen by
+ // multiple translation units. We check them mainly to ensure that they don't
+ // get the special mangling for lambdas in in-class default arguments.
+ // CHECK: call i32 @"_ZNK1S3$_0clEv"
+ // CHECK-NEXT: call i32 @"_ZNK1S3$_1clEv"
+ // CHECK-NEXT: call void @_ZN1S1gEi
+ s.g();
+
+ // CHECK-NEXT: ret void
+}
+
+// Check the linkage of the lambda call operators used in test_S.
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd0_NKUlvE0_clEv
+// CHECK: ret i32 2
+// CHECK: define linkonce_odr i32 @_ZZN1S1fEiiEd_NKUlvE_clEv
+// CHECK: ret i32 3
+// CHECK: define internal i32 @"_ZNK1S3$_0clEv"
+// CHECK: ret i32 1
+// CHECK: define internal i32 @"_ZNK1S3$_1clEv"
+// CHECK: ret i32 2
+
+template<typename T>
+struct ST {
+ void f(T = []{return T() + 1;}()
+ + []{return T() + 2;}(),
+ T = []{return T(3);}());
+};
+
+// CHECK: define void @_Z7test_ST2STIdE
+void test_ST(ST<double> st) {
+ // CHECK: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv
+ // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv
+ // CHECK-NEXT: fadd double
+ // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv
+ // CHECK-NEXT: call void @_ZN2STIdE1fEdd
+ st.f();
+
+ // CHECK-NEXT: ret void
+}
+
+// Check the linkage of the lambda call operators used in test_ST.
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv
+// CHECK: ret double 1
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv
+// CHECK: ret double 2
+// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv
+// CHECK: ret double 3
+
+template<typename T>
+struct StaticMembers {
+ static T x;
+ static T y;
+ static T z;
+};
+
+template<typename T> int accept_lambda(T);
+
+template<typename T>
+T StaticMembers<T>::x = []{return 1;}() + []{return 2;}();
+
+template<typename T>
+T StaticMembers<T>::y = []{return 3;}();
+
+template<typename T>
+T StaticMembers<T>::z = accept_lambda([]{return 4;});
+
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK: call i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv
+// CHECK-NEXT: call i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv
+// CHECK-NEXT: add nsw
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1xMUlvE0_clEv
+// CHECK: ret i32 2
+template float StaticMembers<float>::x;
+
+// CHECK: define internal void @__cxx_global_var_init1()
+// CHECK: call i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv
+// CHECK: define linkonce_odr i32 @_ZNK13StaticMembersIfE1yMUlvE_clEv
+// CHECK: ret i32 3
+template float StaticMembers<float>::y;
+
+// CHECK: define internal void @__cxx_global_var_init2()
+// CHECK: call i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_
+// CHECK: declare i32 @_Z13accept_lambdaIN13StaticMembersIfE1zMUlvE_EEiT_()
+template float StaticMembers<float>::z;
+
+// CHECK: define internal void @__cxx_global_var_init3
+// CHECK: call i32 @"_ZNK13StaticMembersIdE3$_2clEv"
+// CHECK: define internal i32 @"_ZNK13StaticMembersIdE3$_2clEv"
+// CHECK: ret i32 42
+template<> double StaticMembers<double>::z = []{return 42; }();
+
+template<typename T>
+void func_template(T = []{ return T(); }());
+
+// CHECK: define void @_Z17use_func_templatev()
+void use_func_template() {
+ // CHECK: call i32 @"_ZZ13func_templateIiEvT_ENKS_IiE3$_3clEv"
+ func_template<int>();
+}
+
+// CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_
+
+struct Members {
+ int x = [] { return 1; }() + [] { return 2; }();
+ int y = [] { return 3; }();
+};
+
+void test_Members() {
+ // CHECK: define linkonce_odr void @_ZN7MembersC2Ev
+ // CHECK: call i32 @_ZNK7Members1xMUlvE_clEv
+ // CHECK-NEXT: call i32 @_ZNK7Members1xMUlvE0_clE
+ // CHECK-NEXT: add nsw i32
+ // CHECK: call i32 @_ZNK7Members1yMUlvE_clEv
+ Members members;
+ // CHECK: ret void
+}
+
+template<typename P> void f(P) { }
+
+struct TestNestedInstantiation {
+ void operator()() const {
+ []() -> void {
+ return f([]{});
+ }();
+ }
+};
+
+void test_NestedInstantiation() {
+ TestNestedInstantiation()();
+}
+
+// Check the linkage of the lambdas used in test_Members.
+// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZNK7Members1xMUlvE0_clEv
+// CHECK: ret i32 2
+// CHECK: define linkonce_odr i32 @_ZNK7Members1yMUlvE_clEv
+// CHECK: ret i32 3
+
+// Check linkage of the various lambdas.
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE_clEv
+// CHECK: ret i32 1
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE0_clEv
+// CHECK: ret i32
+// CHECK: define linkonce_odr double @_ZZ11inline_funciENKUlvE1_clEv
+// CHECK: ret double
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUliE_clEi
+// CHECK: ret i32
+// CHECK: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE2_clEv
+// CHECK: ret i32 17
diff --git a/test/CodeGenCXX/mangle-ms.cpp b/test/CodeGenCXX/mangle-ms.cpp
index d8d75b7..fe5fde1 100644
--- a/test/CodeGenCXX/mangle-ms.cpp
+++ b/test/CodeGenCXX/mangle-ms.cpp
@@ -28,7 +28,18 @@ protected:
public:
static const volatile char f;
int operator+(int a);
-};
+ foo(){}
+//CHECK: @"\01??0foo@@QAE@XZ"
+
+ ~foo(){}
+//CHECK: @"\01??1foo@@QAE@XZ"
+
+ foo(int i){}
+//CHECK: @"\01??0foo@@QAE@H@Z"
+
+ foo(char *q){}
+//CHECK: @"\01??0foo@@QAE@PAD@Z"
+}f,s1(1),s2((char*)0);
struct bar {
static int g;
diff --git a/test/CodeGenCXX/mangle-nullptr-arg.cpp b/test/CodeGenCXX/mangle-nullptr-arg.cpp
new file mode 100644
index 0000000..393de0b
--- /dev/null
+++ b/test/CodeGenCXX/mangle-nullptr-arg.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+template<int *ip> struct IP {};
+
+// CHECK: define void @_Z5test12IPILPi0EE
+void test1(IP<nullptr>) {}
+
+struct X{ };
+template<int X::*pm> struct PM {};
+
+// CHECK: define void @_Z5test22PMILM1Xi0EE
+void test2(PM<nullptr>) { }
+
diff --git a/test/CodeGenCXX/mangle-std-externc.cpp b/test/CodeGenCXX/mangle-std-externc.cpp
new file mode 100644
index 0000000..a478dee
--- /dev/null
+++ b/test/CodeGenCXX/mangle-std-externc.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -DNS=std -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-STD
+// RUN: %clang_cc1 %s -DNS=n -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-N
+
+// _ZNSt1DISt1CE1iE = std::D<std::C>::i
+// CHECK-STD: @_ZNSt1DISt1CE1iE =
+
+// _ZN1n1DINS_1CEE1iE == n::D<n::C>::i
+// CHECK-N: @_ZN1n1DINS_1CEE1iE =
+
+namespace NS {
+ extern "C" {
+ class C {
+ };
+ }
+
+ template <class T>
+ class D {
+ public:
+ static int i;
+ };
+
+}
+
+
+int f() {
+ return NS::D<NS::C>::i;
+}
diff --git a/test/CodeGenCXX/mangle-template.cpp b/test/CodeGenCXX/mangle-template.cpp
index f95e152..05c3a58 100644
--- a/test/CodeGenCXX/mangle-template.cpp
+++ b/test/CodeGenCXX/mangle-template.cpp
@@ -144,3 +144,29 @@ namespace test10 {
f(i, d);
}
}
+
+// Report from Jason Merrill on cxx-abi-dev, 2012.01.04.
+namespace test11 {
+ int cmp(char a, char b);
+ template <typename T, int (*cmp)(T, T)> struct A {};
+ template <typename T> void f(A<T,cmp> &) {}
+ template void f<char>(A<char,cmp> &);
+ // CHECK: @_ZN6test111fIcEEvRNS_1AIT_L_ZNS_3cmpEccEEE(
+}
+
+namespace test12 {
+ // Make sure we can mangle non-type template args with internal linkage.
+ static int f();
+ const int n = 10;
+ template<typename T, T v> void test() {}
+ void use() {
+ // CHECK: define internal void @_ZN6test124testIFivEXadL_ZNS_L1fEvEEEEvv(
+ test<int(), &f>();
+ // CHECK: define internal void @_ZN6test124testIRFivEXadL_ZNS_L1fEvEEEEvv(
+ test<int(&)(), f>();
+ // CHECK: define internal void @_ZN6test124testIPKiXadL_ZNS_L1nEEEEEvv(
+ test<const int*, &n>();
+ // CHECK: define internal void @_ZN6test124testIRKiXadL_ZNS_L1nEEEEEvv(
+ test<const int&, n>();
+ }
+}
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 47c42a7..ba1b3bf 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -76,9 +76,6 @@ void f(S3<true>) {}
// CHECK: define void @_Z1f2S3ILb0EE
void f(S3<false>) {}
-// CHECK: define void @_Z2f22S3ILb1EE
-void f2(S3<100>) {}
-
struct S;
// CHECK: define void @_Z1fM1SKFvvE
@@ -364,6 +361,14 @@ namespace test0 {
j<A>(buffer);
}
// CHECK: define linkonce_odr void @_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c(
+
+ template <class T> void k(char (&buffer)[sizeof(T() + 0.0f)]) {}
+ void test5() {
+ char buffer[sizeof(float)];
+ k<float>(buffer);
+ }
+ // CHECK: define linkonce_odr void @_ZN5test01kIfEEvRAszplcvT__ELf00000000E_c(
+
}
namespace test1 {
diff --git a/test/CodeGenCXX/member-function-pointer-calls.cpp b/test/CodeGenCXX/member-function-pointer-calls.cpp
index 6f0ef81..f8960aa 100644
--- a/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ b/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -9,16 +9,14 @@ int f(A* a, int (A::*fp)()) {
}
// CHECK: define i32 @_Z2g1v()
-// CHECK-NEXT: {{.*}}:
-// CHECK-NEXT: ret i32 1
+// CHECK: ret i32 1
int g1() {
A a;
return f(&a, &A::vf1);
}
// CHECK: define i32 @_Z2g2v()
-// CHECK-NEXT: {{.*}}:
-// CHECK-NEXT: ret i32 2
+// CHECK: ret i32 2
int g2() {
A a;
return f(&a, &A::vf2);
diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp
index 5ce5fbf..2417aa4 100644
--- a/test/CodeGenCXX/member-function-pointers.cpp
+++ b/test/CodeGenCXX/member-function-pointers.cpp
@@ -28,6 +28,16 @@ void (C::*pc2)() = &C::f;
// CHECK: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8
void (A::*pc3)() = &A::vf1;
+// Tests for test10.
+// CHECK: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8
+// CHECK: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// CHECK: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// CHECK: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8
+// CHECK-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
+// CHECK-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// CHECK-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// CHECK-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+
void f() {
// CHECK: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa
pa = 0;
@@ -232,3 +242,33 @@ namespace test9 {
static S array[] = { (fooptr) &B::foo };
}
}
+
+// rdar://problem/10815683 - Verify that we can emit reinterprets of
+// member pointers as constant initializers. For added trickiness,
+// we also add some non-trivial adjustments.
+namespace test10 {
+ struct A {
+ int nonEmpty;
+ void foo();
+ };
+ struct B : public A {
+ virtual void requireNonZeroAdjustment();
+ };
+ struct C {
+ int nonEmpty;
+ };
+ struct D : public C {
+ virtual void requireNonZeroAdjustment();
+ };
+
+ // Non-ARM tests at top of file.
+ void (A::*a)() = &A::foo;
+ void (B::*b)() = (void (B::*)()) &A::foo;
+ void (C::*c)() = (void (C::*)()) (void (B::*)()) &A::foo;
+ void (D::*d)() = (void (C::*)()) (void (B::*)()) &A::foo;
+}
+// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1.
+// CHECK-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
+// CHECK-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+// CHECK-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+// CHECK-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4
diff --git a/test/CodeGenCXX/new-array-init-exceptions.cpp b/test/CodeGenCXX/new-array-init-exceptions.cpp
new file mode 100644
index 0000000..5d9cc9fa
--- /dev/null
+++ b/test/CodeGenCXX/new-array-init-exceptions.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown -fexceptions -fcxx-exceptions %s -emit-llvm -o - | FileCheck %s
+// REQUIRES: asserts
+
+struct Throws {
+ Throws(int);
+ Throws();
+ ~Throws();
+};
+
+// CHECK: define void @_Z7cleanupi
+void cleanup(int n) {
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD:[^ ]+]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ev
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD]]
+ new Throws[n] { 1, 2, 3 };
+ // CHECK: [[LPAD]]:
+ // CHECK-NEXT: landingpad
+ // CHECK: call void @_ZN6ThrowsD1Ev
+ // CHECK: call void @_ZdaPv
+}
+
+
+// CHECK: define void @_Z7cleanupv
+void cleanup() {
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2:[^ ]+]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2]]
+ // CHECK: invoke void @_ZN6ThrowsC1Ei
+ // CHECK-NEXT: to label %{{[^ ]+}} unwind label %[[LPAD2]]
+ new Throws[3] { 1, 2, 3 };
+ // CHECK: [[LPAD2]]:
+ // CHECK-NEXT: landingpad
+ // CHECK: call void @_ZN6ThrowsD1Ev
+ // CHECK: call void @_ZdaPv
+}
diff --git a/test/CodeGenCXX/new-array-init.cpp b/test/CodeGenCXX/new-array-init.cpp
new file mode 100644
index 0000000..231df24
--- /dev/null
+++ b/test/CodeGenCXX/new-array-init.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define void @_Z2fni
+void fn(int n) {
+ // CHECK: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK: store i32 1
+ // CHECK: store i32 2
+ // CHECK: store i32 3
+ // CHECK: icmp eq i32*
+ // CHECK-NEXT: br i1
+ new int[n] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z15const_underflowv
+void const_underflow() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK: call noalias i8* @_Zna{{.}}(i{{32|64}} -1)
+ new int[2] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z11const_exactv
+void const_exact() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ // CHECK-NOT: icmp eq i32*
+ new int[3] { 1, 2, 3 };
+}
+
+// CHECK: define void @_Z16const_sufficientv
+void const_sufficient() {
+ // CHECK-NOT: icmp ult i{{32|64}} %{{[^ ]+}}, 3
+ new int[4] { 1, 2, 3 };
+ // CHECK: ret void
+}
diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp
index 3a72bb84..8d9f641 100644
--- a/test/CodeGenCXX/new.cpp
+++ b/test/CodeGenCXX/new.cpp
@@ -231,3 +231,22 @@ namespace PR10197 {
template void f<int>();
}
+
+namespace PR11523 {
+ class MyClass;
+ typedef int MyClass::* NewTy;
+ // CHECK: define i64* @_ZN7PR115231fEv
+ // CHECK: store i64 -1
+ NewTy* f() { return new NewTy[2](); }
+}
+
+namespace PR11757 {
+ // Make sure we elide the copy construction.
+ struct X { X(); X(const X&); };
+ X* a(X* x) { return new X(X()); }
+ // CHECK: define {{.*}} @_ZN7PR117571aEPNS_1XE
+ // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm
+ // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to
+ // CHECK-NEXT: call void @_ZN7PR117571XC1Ev({{.*}}* [[CASTED]])
+ // CHECK-NEXT: ret {{.*}} [[CASTED]]
+}
diff --git a/test/CodeGenCXX/nrvo.cpp b/test/CodeGenCXX/nrvo.cpp
index 57bf27a..2feaf68 100644
--- a/test/CodeGenCXX/nrvo.cpp
+++ b/test/CodeGenCXX/nrvo.cpp
@@ -147,3 +147,15 @@ X test5() {
}
}
#endif
+
+// rdar://problem/10430868
+// CHECK: define void @_Z5test6v
+X test6() {
+ X a __attribute__((aligned(8)));
+ return a;
+ // CHECK: [[A:%.*]] = alloca [[X:%.*]], align 8
+ // CHECK-NEXT: call {{.*}} @_ZN1XC1Ev([[X]]* [[A]])
+ // CHECK-NEXT: call {{.*}} @_ZN1XC1ERKS_([[X]]* {{%.*}}, [[X]]* [[A]])
+ // CHECK-NEXT: call {{.*}} @_ZN1XD1Ev([[X]]* [[A]])
+ // CHECK-NEXT: ret void
+}
diff --git a/test/CodeGenCXX/override-layout.cpp b/test/CodeGenCXX/override-layout.cpp
new file mode 100644
index 0000000..d432885
--- /dev/null
+++ b/test/CodeGenCXX/override-layout.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fdump-record-layouts-simple %s 2> %t.layouts
+// RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before 2>&1
+// RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
+// RUN: diff %t.before %t.after
+// RUN: FileCheck %s < %t.after
+
+// If not explicitly disabled, set PACKED to the packed attribute.
+#ifndef PACKED
+# define PACKED __attribute__((packed))
+#endif
+
+struct Empty1 { };
+struct Empty2 { };
+
+// CHECK: Type: struct X0
+struct X0 : public Empty1 {
+ int x[6] PACKED;
+};
+
+// CHECK: Type: struct X1
+struct X1 : public X0, public Empty2 {
+ char x[13];
+ struct X0 y;
+} PACKED;
+
+// CHECK: Type: struct X2
+struct PACKED X2 : public X1, public X0, public Empty1 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X3
+struct PACKED X3 : virtual public X1, public X0 {
+ short x;
+ int y;
+};
+
+// CHECK: Type: struct X4
+struct PACKED X4 {
+ unsigned int a : 1;
+ unsigned int b : 1;
+ unsigned int c : 1;
+ unsigned int d : 1;
+ unsigned int e : 1;
+ unsigned int f : 1;
+ unsigned int g : 1;
+ unsigned int h : 1;
+ unsigned int i : 1;
+ unsigned int j : 1;
+ unsigned int k : 1;
+ unsigned int l : 1;
+ unsigned int m : 1;
+ unsigned int n : 1;
+ X4();
+};
+
+void use_structs() {
+ X0 x0s[sizeof(X0)];
+ X1 x1s[sizeof(X1)];
+ X2 x2s[sizeof(X2)];
+ X3 x3s[sizeof(X3)];
+ X4 x4s[sizeof(X4)];
+ x4s[1].a = 1;
+}
diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp
index f0246c8..90024e4 100644
--- a/test/CodeGenCXX/pointers-to-data-members.cpp
+++ b/test/CodeGenCXX/pointers-to-data-members.cpp
@@ -230,3 +230,13 @@ namespace test4 {
// CHECK-GLOBAL: @_ZN5test41dE = global %"struct.test4::D" { %"struct.test4::C.base" zeroinitializer, i32* null, %"struct.test4::B.base" { i32 (...)** null, i64 -1 }, %"struct.test4::A" zeroinitializer }, align 8
D d;
}
+
+namespace PR11487 {
+ union U
+ {
+ int U::* mptr;
+ char x[16];
+ } x;
+ // CHECK-GLOBAL: @_ZN7PR114871xE = global %"union.PR11487::U" { i64 -1, [8 x i8] zeroinitializer }, align 8
+
+}
diff --git a/test/CodeGenCXX/pr11676.cpp b/test/CodeGenCXX/pr11676.cpp
new file mode 100644
index 0000000..896751a
--- /dev/null
+++ b/test/CodeGenCXX/pr11676.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm-only
+// CHECK that we don't crash.
+
+// PR11676's example is ill-formed:
+/*
+union _XEvent {
+};
+void ProcessEvent() {
+ _XEvent pluginEvent = _XEvent();
+}
+*/
+
+// Example from PR11665:
+void f() {
+ union U { int field; } u = U();
+ (void)U().field;
+}
diff --git a/test/CodeGenCXX/pr11797.cpp b/test/CodeGenCXX/pr11797.cpp
new file mode 100644
index 0000000..05221ac
--- /dev/null
+++ b/test/CodeGenCXX/pr11797.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fvisibility hidden -emit-llvm -o - | FileCheck %s
+
+namespace std __attribute__ ((__visibility__ ("default"))) {}
+#pragma GCC visibility push(default)
+void foo() {
+}
+#pragma GCC visibility pop
+// CHECK: define void @_Z3foov()
diff --git a/test/CodeGenCXX/pr12104.cpp b/test/CodeGenCXX/pr12104.cpp
new file mode 100644
index 0000000..a62f04b
--- /dev/null
+++ b/test/CodeGenCXX/pr12104.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -include %S/pr12104.h %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t %S/pr12104.h
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+template struct Patch<1>;
+
+// CHECK: _ZN5PatchILi1EE11no_neighborE
diff --git a/test/CodeGenCXX/pr12104.h b/test/CodeGenCXX/pr12104.h
new file mode 100644
index 0000000..f3e9363
--- /dev/null
+++ b/test/CodeGenCXX/pr12104.h
@@ -0,0 +1,9 @@
+template <int dimm> struct Patch {
+ static const unsigned int no_neighbor = 1;
+};
+template <int dim>
+const unsigned int Patch<dim>::no_neighbor;
+void f(const unsigned int);
+void g() {
+ f(Patch<1>::no_neighbor);
+}
diff --git a/test/CodeGenCXX/pr12251.cpp b/test/CodeGenCXX/pr12251.cpp
new file mode 100644
index 0000000..a9920c0
--- /dev/null
+++ b/test/CodeGenCXX/pr12251.cpp
@@ -0,0 +1,146 @@
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -fstrict-enums -std=c++11 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -std=c++11 -o - | FileCheck --check-prefix=NO-STRICT-ENUMS %s
+
+bool f(bool *x) {
+ return *x;
+}
+// CHECK: define zeroext i1 @_Z1fPb
+// CHECK: load i8* %{{.*}}, align 1, !range !0
+
+// Only enum-tests follow. Ensure that after the bool test, no further range
+// metadata shows up when strict enums are disabled.
+// NO-STRICT-ENUMS: define zeroext i1 @_Z1fPb
+// NO-STRICT-ENUMS: load i8* %{{.*}}, align 1, !range !0
+// NO-STRICT-ENUMS-NOT: !range
+
+enum e1 { };
+e1 g1(e1 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g1P2e1
+// CHECK: load i32* %x, align 4, !range !1
+
+enum e2 { e2_a = 0 };
+e2 g2(e2 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g2P2e2
+// CHECK: load i32* %x, align 4, !range !1
+
+enum e3 { e3_a = 16 };
+e3 g3(e3 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g3P2e3
+// CHECK: load i32* %x, align 4, !range !2
+
+enum e4 { e4_a = -16};
+e4 g4(e4 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g4P2e4
+// CHECK: load i32* %x, align 4, !range !3
+
+enum e5 { e5_a = -16, e5_b = 16};
+e5 g5(e5 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g5P2e5
+// CHECK: load i32* %x, align 4, !range !4
+
+enum e6 { e6_a = -1 };
+e6 g6(e6 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g6P2e6
+// CHECK: load i32* %x, align 4, !range !5
+
+enum e7 { e7_a = -16, e7_b = 2};
+e7 g7(e7 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g7P2e7
+// CHECK: load i32* %x, align 4, !range !3
+
+enum e8 { e8_a = -17};
+e8 g8(e8 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g8P2e8
+// CHECK: load i32* %x, align 4, !range !4
+
+enum e9 { e9_a = 17};
+e9 g9(e9 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z2g9P2e9
+// CHECK: load i32* %x, align 4, !range !2
+
+enum e10 { e10_a = -16, e10_b = 32};
+e10 g10(e10 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g10P3e10
+// CHECK: load i32* %x, align 4, !range !6
+
+enum e11 {e11_a = 4294967296 };
+enum e11 g11(enum e11 *x) {
+ return *x;
+}
+// CHECK: define i64 @_Z3g11P3e11
+// CHECK: load i64* %x, align {{[84]}}, !range !7
+
+enum e12 {e12_a = 9223372036854775808U };
+enum e12 g12(enum e12 *x) {
+ return *x;
+}
+// CHECK: define i64 @_Z3g12P3e12
+// CHECK: load i64* %x, align {{[84]}}
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e13 : char {e13_a = -1 };
+e13 g13(e13 *x) {
+ return *x;
+}
+// CHECK: define signext i8 @_Z3g13P3e13
+// CHECK: load i8* %x, align 1
+// CHECK-NOT: range
+// CHECK: ret
+
+enum class e14 {e14_a = 1};
+e14 g14(e14 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g14P3e14
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e15 { e15_a = 2147483648 };
+e15 g15(e15 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g15P3e15
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+enum e16 { e16_a = -2147483648 };
+e16 g16(e16 *x) {
+ return *x;
+}
+// CHECK: define i32 @_Z3g16P3e16
+// CHECK: load i32* %x, align 4
+// CHECK-NOT: range
+// CHECK: ret
+
+
+// CHECK: !0 = metadata !{i8 0, i8 2}
+// CHECK: !1 = metadata !{i32 0, i32 1}
+// CHECK: !2 = metadata !{i32 0, i32 32}
+// CHECK: !3 = metadata !{i32 -16, i32 16}
+// CHECK: !4 = metadata !{i32 -32, i32 32}
+// CHECK: !5 = metadata !{i32 -1, i32 1}
+// CHECK: !6 = metadata !{i32 -64, i32 64}
+// CHECK: !7 = metadata !{i64 0, i64 8589934592}
diff --git a/test/CodeGenCXX/pr9965.cpp b/test/CodeGenCXX/pr9965.cpp
index 145fd4e..0d267ff 100644
--- a/test/CodeGenCXX/pr9965.cpp
+++ b/test/CodeGenCXX/pr9965.cpp
@@ -1,8 +1,10 @@
// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s
+struct A { A(); };
template<typename T>
-struct X
+struct X : A // default constructor is not trivial
{
X() = default;
+ ~X() {} // not a literal type
};
X<int> x;
diff --git a/test/CodeGenCXX/pragma-pack-2.cpp b/test/CodeGenCXX/pragma-pack-2.cpp
new file mode 100644
index 0000000..9c09d5b
--- /dev/null
+++ b/test/CodeGenCXX/pragma-pack-2.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.2 %s -emit-llvm -o - | FileCheck %s
+// <rdar://problem/10551376>
+
+struct FOO {
+ unsigned int x;
+};
+
+#pragma pack(push, 2)
+
+// CHECK: %struct.BAR = type <{ %struct.FOO, i8, i8 }>
+struct BAR : FOO {
+ char y;
+};
+
+#pragma pack(pop)
+
+BAR* x = 0; \ No newline at end of file
diff --git a/test/CodeGenCXX/pragma-visibility.cpp b/test/CodeGenCXX/pragma-visibility.cpp
index 2dc8bcc..e54626e 100644
--- a/test/CodeGenCXX/pragma-visibility.cpp
+++ b/test/CodeGenCXX/pragma-visibility.cpp
@@ -55,20 +55,8 @@ namespace n __attribute((visibility("default"))) {
#pragma GCC visibility pop
namespace n __attribute((visibility("default"))) {
- extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma
- // gets to Sema before the namespace!
#pragma GCC visibility push(hidden)
void g() {}
// CHECK: define hidden void @_ZN1n1gEv
#pragma GCC visibility pop
}
-
-// We used to test this, but it's insane, so unless it happens in
-// headers, we should not support it.
-namespace n __attribute((visibility("hidden"))) {
- extern int foofoo; // FIXME: Shouldn't be necessary, but otherwise the pragma
- // gets to Sema before the namespace!
- #pragma GCC visibility pop
- void h() {}
- // CHECK disabled: define void @_ZN1n1hEv
-}
diff --git a/test/CodeGenCXX/predefined-expr-sizeof.cpp b/test/CodeGenCXX/predefined-expr-sizeof.cpp
index f74cfb3..b4712ad 100644
--- a/test/CodeGenCXX/predefined-expr-sizeof.cpp
+++ b/test/CodeGenCXX/predefined-expr-sizeof.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
-// CHECK: store i32 49, i32* %size
-// CHECK: store i32 52, i32* %size
+// CHECK: store i32 59, i32* %size
+// CHECK: store i32 65, i32* %size
template<typename T>
class TemplateClass {
public:
@@ -10,8 +10,8 @@ public:
}
};
-// CHECK: store i32 27, i32* %size
-// CHECK: store i32 30, i32* %size
+// CHECK: store i32 35, i32* %size
+// CHECK: store i32 38, i32* %size
template<typename T>
void functionTemplate(T t) {
int size = sizeof(__PRETTY_FUNCTION__);
diff --git a/test/CodeGenCXX/predefined-expr.cpp b/test/CodeGenCXX/predefined-expr.cpp
index 56270b5..1795ec8 100644
--- a/test/CodeGenCXX/predefined-expr.cpp
+++ b/test/CodeGenCXX/predefined-expr.cpp
@@ -1,15 +1,29 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s
// CHECK: private unnamed_addr constant [15 x i8] c"externFunction\00"
// CHECK: private unnamed_addr constant [26 x i8] c"void NS::externFunction()\00"
+// CHECK: private unnamed_addr constant [49 x i8] c"void functionTemplateExplicitSpecialization(int)\00"
+
+// CHECK: private unnamed_addr constant [95 x i8] c"void SpecializedClassTemplate<char>::memberFunctionTemplate(T, U) const [T = char, U = double]\00"
+// CHECK: private unnamed_addr constant [85 x i8] c"void SpecializedClassTemplate<int>::memberFunctionTemplate(int, U) const [U = float]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void NonTypeTemplateParam<42>::size() const [Count = 42]\00"
+// CHECK: private unnamed_addr constant [122 x i8] c"static void ClassWithTemplateTemplateParam<char, NS::ClassTemplate>::staticMember() [T = char, Param = NS::ClassTemplate]\00"
+// CHECK: private unnamed_addr constant [106 x i8] c"void OuterClass<int *>::MiddleClass::InnerClass<float>::memberFunction(T, U) const [T = int *, U = float]\00"
+// CHECK: private unnamed_addr constant [65 x i8] c"void functionTemplateWithUnnamedTemplateParameter(T) [T = float]\00"
+
+// CHECK: private unnamed_addr constant [60 x i8] c"void functionTemplateExplicitSpecialization(T) [T = double]\00"
+// CHECK: private unnamed_addr constant [52 x i8] c"T *functionTemplateWithCompoundTypes(T *) [T = int]\00"
+// CHECK: private unnamed_addr constant [54 x i8] c"T functionTemplateWithTemplateReturnType() [T = char]\00"
+// CHECK: private unnamed_addr constant [57 x i8] c"void functionTemplateWithoutParameterList() [T = double]\00"
+// CHECK: private unnamed_addr constant [62 x i8] c"void functionTemplateWithTwoParams(T, U) [T = int, U = float]\00"
// CHECK: private unnamed_addr constant [22 x i8] c"classTemplateFunction\00"
-// CHECK: private unnamed_addr constant [60 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction()\00"
-// CHECK: private unnamed_addr constant [53 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction()\00"
+// CHECK: private unnamed_addr constant [77 x i8] c"void NS::ClassTemplate<NS::Base *>::classTemplateFunction() [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [63 x i8] c"void NS::ClassTemplate<int>::classTemplateFunction() [T = int]\00"
// CHECK: private unnamed_addr constant [18 x i8] c"functionTemplate1\00"
-// CHECK: private unnamed_addr constant [45 x i8] c"void NS::Base::functionTemplate1(NS::Base *)\00"
-// CHECK: private unnamed_addr constant [38 x i8] c"void NS::Base::functionTemplate1(int)\00"
+// CHECK: private unnamed_addr constant [53 x i8] c"void NS::Base::functionTemplate1(T) [T = NS::Base *]\00"
+// CHECK: private unnamed_addr constant [46 x i8] c"void NS::Base::functionTemplate1(T) [T = int]\00"
// CHECK: private unnamed_addr constant [23 x i8] c"anonymousUnionFunction\00"
// CHECK: private unnamed_addr constant [83 x i8] c"void NS::ContainerForAnonymousRecords::<anonymous union>::anonymousUnionFunction()\00"
@@ -31,6 +45,10 @@
// CHECK: private unnamed_addr constant [16 x i8] c"virtualFunction\00"
// CHECK: private unnamed_addr constant [44 x i8] c"virtual void NS::Derived::virtualFunction()\00"
+// CHECK: private unnamed_addr constant [21 x i8] c"refQualifiedFunction\00"
+// CHECK: private unnamed_addr constant [41 x i8] c"void NS::Base::refQualifiedFunction() &&\00"
+// CHECK: private unnamed_addr constant [40 x i8] c"void NS::Base::refQualifiedFunction() &\00"
+
// CHECK: private unnamed_addr constant [22 x i8] c"constVolatileFunction\00"
// CHECK: private unnamed_addr constant [54 x i8] c"void NS::Base::constVolatileFunction() const volatile\00"
@@ -78,6 +96,8 @@
// CHECK: private unnamed_addr constant [19 x i8] c"localClassFunction\00"
// CHECK: private unnamed_addr constant [59 x i8] c"void NS::localClass(int)::LocalClass::localClassFunction()\00"
+
+
int printf(const char * _Format, ...);
class ClassInTopLevelNamespace {
@@ -203,11 +223,23 @@ public:
printf("__FUNCTION__ %s\n", __FUNCTION__);
printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
}
+
+ void refQualifiedFunction() & {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+
+ void refQualifiedFunction() && {
+ printf("__func__ %s\n", __func__);
+ printf("__FUNCTION__ %s\n", __FUNCTION__);
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
};
class Derived : public Base {
public:
- // Virtual function without being explicitally written.
+ // Virtual function without being explicitly written.
void virtualFunction() {
printf("__func__ %s\n", __func__);
printf("__FUNCTION__ %s\n", __FUNCTION__);
@@ -294,6 +326,116 @@ extern void externFunction() {
} // end NS namespace
+// additional tests for __PRETTY_FUNCTION__
+template <typename T, typename U>
+void functionTemplateWithTwoParams(T, U)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+void functionTemplateWithoutParameterList()
+{
+ T t = T();
+
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+T functionTemplateWithTemplateReturnType()
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+ return T();
+}
+
+template <typename T>
+T * functionTemplateWithCompoundTypes(T a[])
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+
+ return 0;
+}
+
+template <typename T>
+void functionTemplateExplicitSpecialization(T t)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <>
+void functionTemplateExplicitSpecialization<int>(int i)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename, typename T>
+void functionTemplateWithUnnamedTemplateParameter(T t)
+{
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+}
+
+template <typename T>
+class OuterClass
+{
+public:
+ class MiddleClass
+ {
+ public:
+ template <typename U>
+ class InnerClass
+ {
+ public:
+ void memberFunction(T x, U y) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+ };
+ };
+};
+
+template <typename T, template <typename> class Param = NS::ClassTemplate>
+class ClassWithTemplateTemplateParam
+{
+public:
+ static void staticMember()
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <int Count>
+class NonTypeTemplateParam
+{
+public:
+ void size() const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <typename T>
+class SpecializedClassTemplate
+{
+public:
+ template <typename U>
+ void memberFunctionTemplate(T t, U u) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
+template <>
+class SpecializedClassTemplate<int>
+{
+public:
+ template <typename U>
+ void memberFunctionTemplate(int i, U u) const
+ {
+ printf("__PRETTY_FUNCTION__ %s\n\n", __PRETTY_FUNCTION__);
+ }
+};
+
int main() {
ClassInAnonymousNamespace anonymousNamespace;
anonymousNamespace.anonymousNamespaceFunction();
@@ -319,6 +461,8 @@ int main() {
b.constFunction();
b.volatileFunction();
b.constVolatileFunction();
+ b.refQualifiedFunction();
+ NS::Base().refQualifiedFunction();
NS::Derived d;
d.virtualFunction();
@@ -345,5 +489,29 @@ int main() {
NS::externFunction();
+ // additional tests for __PRETTY_FUNCTION__
+
+ functionTemplateWithTwoParams(0, 0.0f);
+ functionTemplateWithoutParameterList<double>();
+ functionTemplateWithTemplateReturnType<char>();
+ int array[] = { 1, 2, 3 };
+ functionTemplateWithCompoundTypes(array);
+ functionTemplateExplicitSpecialization(0);
+ functionTemplateExplicitSpecialization(0.0);
+ functionTemplateWithUnnamedTemplateParameter<int, float>(0.0f);
+
+ OuterClass<int *>::MiddleClass::InnerClass<float> omi;
+ omi.memberFunction(0, 0.0f);
+
+ ClassWithTemplateTemplateParam<char>::staticMember();
+
+ NonTypeTemplateParam<42> ntt;
+ ntt.size();
+
+ SpecializedClassTemplate<int> sct1;
+ sct1.memberFunctionTemplate(0, 0.0f);
+ SpecializedClassTemplate<char> sct2;
+ sct2.memberFunctionTemplate('0', 0.0);
+
return 0;
}
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index 4bbc251..d315f71 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -1,10 +1,16 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -emit-llvm -o - %s | FileCheck %s
void t1() {
+ // CHECK: define void @_Z2t1v
+ // CHECK: [[REFLOAD:%.*]] = load i32** @a, align 8
+ // CHECK: load i32* [[REFLOAD]], align 4
extern int& a;
int b = a;
}
void t2(int& a) {
+ // CHECK: define void @_Z2t2Ri
+ // CHECK: [[REFLOAD2:%.*]] = load i32** {{.*}}, align 8
+ // CHECK: load i32* [[REFLOAD2]], align 4
int b = a;
}
@@ -297,3 +303,11 @@ namespace PR9565 {
// CHECK-NEXT: ret void
}
}
+
+namespace N6 {
+ extern struct x {char& x;}y;
+ int a() { return y.x; }
+ // CHECK: define i32 @_ZN2N61aEv
+ // CHECK: [[REFLOAD3:%.*]] = load i8** getelementptr inbounds (%"struct.N6::x"* @_ZN2N61yE, i32 0, i32 0), align 8
+ // CHECK: load i8* [[REFLOAD3]], align 1
+}
diff --git a/test/CodeGenCXX/regparm.cpp b/test/CodeGenCXX/regparm.cpp
new file mode 100644
index 0000000..f0ebd2b
--- /dev/null
+++ b/test/CodeGenCXX/regparm.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+
+
+// CHECK: _Z3fooRi(i32* inreg
+void __attribute__ ((regparm (1))) foo(int &a) {
+}
diff --git a/test/CodeGenCXX/static-data-member.cpp b/test/CodeGenCXX/static-data-member.cpp
index b19067a..4ad339d 100644
--- a/test/CodeGenCXX/static-data-member.cpp
+++ b/test/CodeGenCXX/static-data-member.cpp
@@ -5,6 +5,12 @@
// CHECK: @_ZN5test31AIiE1xE = weak_odr global i32 0, align 4
// CHECK: @_ZGVN5test31AIiE1xE = weak_odr global i64 0
+// CHECK: _ZN5test51U2k0E = global i32 0
+// CHECK: _ZN5test51U2k1E = global i32 0
+// CHECK: _ZN5test51U2k2E = constant i32 76
+// CHECK-NOT: test51U2k3E
+// CHECK-NOT: test51U2k4E
+
// PR5564.
namespace test1 {
struct A {
@@ -64,3 +70,35 @@ namespace test3 {
// CHECK-NEXT: br label
// CHECK: ret void
}
+
+// Test that we can fold member lookup expressions which resolve to static data
+// members.
+namespace test4 {
+ struct A {
+ static const int n = 76;
+ };
+
+ int f(A *a) {
+ // CHECK: define i32 @_ZN5test41fEPNS_1AE
+ // CHECK: ret i32 76
+ return a->n;
+ }
+}
+
+// Test that static data members in unions behave properly.
+namespace test5 {
+ union U {
+ static int k0;
+ static const int k1;
+ static const int k2 = 76;
+ static const int k3;
+ static const int k4 = 81;
+ };
+ int U::k0;
+ const int U::k1 = (k0 = 9, 42);
+ const int U::k2;
+
+ // CHECK: store i32 9, i32* @_ZN5test51U2k0E
+ // CHECK: store i32 {{.*}}, i32* @_ZN5test51U2k1E
+ // CHECK-NOT: store {{.*}} i32* @_ZN5test51U2k2E
+}
diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp
index 9e2673c..ed659de 100644
--- a/test/CodeGenCXX/static-init.cpp
+++ b/test/CodeGenCXX/static-init.cpp
@@ -1,7 +1,9 @@
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
// CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
+// CHECK: @base_req = global [4 x i8] c"foo\00", align 1
+// CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4
// CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
// CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0
// CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0
@@ -15,7 +17,7 @@ void f() {
// CHECK: load atomic i8* bitcast (i64* @_ZGVZ1fvE1a to i8*) acquire, align 1
// CHECK: call i32 @__cxa_guard_acquire
// CHECK: call void @_ZN1AC1Ev
- // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))
+ // CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.A*)* @_ZN1AD1Ev to void (i8*)*), i8* getelementptr inbounds (%struct.A* @_ZZ1fvE1a, i32 0, i32 0), i8* @__dso_handle)
// CHECK: call void @__cxa_guard_release
static A a;
}
@@ -59,3 +61,92 @@ namespace test1 {
void test() { (void) getvar(2); }
}
+
+// Make sure we emit the initializer correctly for the following:
+char base_req[] = { "foo" };
+
+namespace union_static_local {
+ // CHECK: define internal void @_ZZN18union_static_local4testEvEN1c4mainEv
+ // CHECK: call void @_ZN18union_static_local1fEPNS_1xE(%"union.union_static_local::x"* bitcast ({ [2 x i8*] }* @_ZZN18union_static_local4testEvE3foo to %"union.union_static_local::x"*))
+ union x { long double y; const char *x[2]; };
+ void f(union x*);
+ void test() {
+ static union x foo = { .x = { "a", "b" } };
+ struct c {
+ static void main() {
+ f(&foo);
+ }
+ };
+ c::main();
+ }
+}
+
+// rdar://problem/11091093
+// Static variables should be consistent across constructor
+// or destructor variants.
+namespace test2 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B : virtual A {
+ B();
+ ~B();
+ };
+
+ // If we ever implement this as a delegate ctor call, just change
+ // this to take variadic arguments or something.
+ extern int foo();
+ B::B() {
+ static int x = foo();
+ }
+ // CHECK: define void @_ZN5test21BC1Ev
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BC1EvE1x to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BC1EvE1x)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BC1EvE1x,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BC1EvE1x)
+
+ // CHECK: define void @_ZN5test21BC2Ev
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BC1EvE1x to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BC1EvE1x)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BC1EvE1x,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BC1EvE1x)
+
+ // This is just for completeness, because we actually emit this
+ // using a delegate dtor call.
+ B::~B() {
+ static int y = foo();
+ }
+ // CHECK: define void @_ZN5test21BD1Ev(
+ // CHECK: call void @_ZN5test21BD2Ev(
+
+ // CHECK: define void @_ZN5test21BD2Ev(
+ // CHECK: load atomic i8* bitcast (i64* @_ZGVZN5test21BD1EvE1y to i8*) acquire,
+ // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZN5test21BD1EvE1y)
+ // CHECK: [[T0:%.*]] = call i32 @_ZN5test23fooEv()
+ // CHECK: store i32 [[T0]], i32* @_ZZN5test21BD1EvE1y,
+ // CHECK: call void @__cxa_guard_release(i64* @_ZGVZN5test21BD1EvE1y)
+}
+
+// This shouldn't error out.
+namespace test3 {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B : virtual A {
+ B();
+ ~B();
+ };
+
+ B::B() {
+ union U { char x; int i; };
+ static U u = { 'a' };
+ }
+ // CHECK: define void @_ZN5test31BC1Ev(
+ // CHECK: define void @_ZN5test31BC2Ev(
+}
diff --git a/test/CodeGenCXX/static-mutable.cpp b/test/CodeGenCXX/static-mutable.cpp
new file mode 100644
index 0000000..6d51f24
--- /dev/null
+++ b/test/CodeGenCXX/static-mutable.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -triple=i686-linux-gnu -emit-llvm -o - | FileCheck %s
+
+struct S {
+ mutable int n;
+};
+int f() {
+ // The purpose of this test is to ensure that this variable is a global
+ // not a constant.
+ // CHECK: @_ZZ1fvE1s = internal global {{.*}} { i32 12 }
+ static const S s = { 12 };
+ return ++s.n;
+}
diff --git a/test/CodeGenCXX/switch-case-folding-1.cpp b/test/CodeGenCXX/switch-case-folding-1.cpp
new file mode 100644
index 0000000..1daeecf
--- /dev/null
+++ b/test/CodeGenCXX/switch-case-folding-1.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// CHECK that we don't crash.
+
+int test(int val){
+ int x = 12;
+ // Make sure we don't crash when constant folding the case 4
+ // statement due to the case 5 statement contained in the do loop
+ switch (val) {
+ case 4: do {
+ switch (6) {
+ case 6: {
+ case 5: x++;
+ };
+ };
+ } while (x < 100);
+ }
+ return x;
+}
+
+int main(void) {
+ return test(4);
+}
diff --git a/test/CodeGenCXX/switch-case-folding-2.cpp b/test/CodeGenCXX/switch-case-folding-2.cpp
new file mode 100644
index 0000000..7c0283f
--- /dev/null
+++ b/test/CodeGenCXX/switch-case-folding-2.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// CHECK that we don't crash.
+
+extern int printf(const char*, ...);
+int test(int val){
+ switch (val) {
+ case 4:
+ do {
+ switch (6) {
+ case 6: do { case 5: printf("bad\n"); } while (0);
+ };
+ } while (0);
+ }
+ return 0;
+}
+
+int main(void) {
+ return test(5);
+}
+
+// CHECK: call i32 (i8*, ...)* @_Z6printfPKcz
diff --git a/test/CodeGenCXX/switch-case-folding.cpp b/test/CodeGenCXX/switch-case-folding.cpp
new file mode 100644
index 0000000..d4444b1
--- /dev/null
+++ b/test/CodeGenCXX/switch-case-folding.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -emit-llvm-only
+// CHECK that we don't crash.
+
+int main(void){
+ int x = 12;
+ // Make sure we don't crash when constant folding the case 4
+ // statement due to the case 5 statement contained in the do loop
+ switch (4) {
+ case 4: do {
+ switch (6) {
+ case 6: {
+ case 5: x++;
+ };
+ };
+ } while (x < 100);
+ }
+ return x;
+}
diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp
index 98e5ae3..e90c947 100644
--- a/test/CodeGenCXX/temporaries.cpp
+++ b/test/CodeGenCXX/temporaries.cpp
@@ -519,3 +519,21 @@ namespace PR8623 {
b ? A(2) : A(3);
}
}
+
+namespace PR11365 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN7PR113653fooEv(
+ void foo() {
+ // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]]* {{.*}}, i32 0, i32 0
+ // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 3
+ // CHECK-NEXT: br label
+
+ // CHECK: [[PHI:%.*]] = phi
+ // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]]* [[PHI]], i64 -1
+ // CHECK-NEXT: call void @_ZN7PR113651AD1Ev([[A]]* [[ELEM]])
+ // CHECK-NEXT: icmp eq [[A]]* [[ELEM]], [[BEGIN]]
+ // CHECK-NEXT: br i1
+ (void) (A [3]) {};
+ }
+}
diff --git a/test/CodeGenCXX/thiscall-struct-return.cpp b/test/CodeGenCXX/thiscall-struct-return.cpp
new file mode 100644
index 0000000..ff53125
--- /dev/null
+++ b/test/CodeGenCXX/thiscall-struct-return.cpp
@@ -0,0 +1,41 @@
+// For MSVC ABI compatibility, all structures returned by value using the
+// thiscall calling convention must use the hidden parameter.
+//
+// RUN: %clang_cc1 -triple i386-PC-Win32 %s -fms-compatibility -O0 -emit-llvm -o - | FileCheck %s
+
+// This structure would normally be returned via EAX
+struct S {
+ int i;
+};
+
+// This structure would normally be returned via EAX/EDX
+struct M {
+ int i;
+ int j;
+};
+
+class C {
+public:
+ C() {}
+
+ struct S __attribute__((thiscall)) Small() const {
+ struct S s = { 0 };
+ return s;
+ }
+
+ struct M __attribute__((thiscall)) Medium() const {
+ struct M m = { 0 };
+ return m;
+ }
+};
+
+// CHECK: define void @_Z4testv()
+void test( void ) {
+// CHECK: call void @_ZN1CC1Ev(%class.C* [[C:%.+]])
+ C c;
+
+// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %{{.+}}, %class.C* [[C]])
+ (void)c.Small();
+// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %{{.+}}, %class.C* [[C]])
+ (void)c.Medium();
+}
diff --git a/test/CodeGenCXX/throw-expressions.cpp b/test/CodeGenCXX/throw-expressions.cpp
index 0fd32c4..2515acb 100644
--- a/test/CodeGenCXX/throw-expressions.cpp
+++ b/test/CodeGenCXX/throw-expressions.cpp
@@ -13,3 +13,8 @@ int test2() {
void test3() {
throw false;
}
+
+// PR10582
+int test4() {
+ return 1 ? throw val : val;
+}
diff --git a/test/CodeGenCXX/thunk-use-after-free.cpp b/test/CodeGenCXX/thunk-use-after-free.cpp
new file mode 100644
index 0000000..d70e902
--- /dev/null
+++ b/test/CodeGenCXX/thunk-use-after-free.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -emit-llvm-only -O1 %s
+// This used to crash under asan and valgrind.
+// PR12284
+
+template < typename _Tp > struct new_allocator
+{
+ typedef _Tp *pointer;
+ template < typename > struct rebind {
+ typedef new_allocator other;
+ };
+};
+template < typename _Tp > struct allocator:new_allocator < _Tp > {
+};
+template < typename _Tp, typename _Alloc > struct _Vector_base {
+ typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
+ struct _Vector_impl {
+ typename _Tp_alloc_type::pointer _M_end_of_storage;
+ };
+ _Vector_base () {
+ foo((int *) this->_M_impl._M_end_of_storage);
+ }
+ void foo(int *);
+ _Vector_impl _M_impl;
+};
+template < typename _Tp, typename _Alloc =
+allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
+
+
+template < class T> struct HHH {};
+struct DDD { int x_;};
+struct Data;
+struct X1;
+struct CCC:DDD { virtual void xxx (HHH < X1 >); };
+template < class SSS > struct EEE:vector < HHH < SSS > > { };
+template < class SSS, class = EEE < SSS > >class FFF { };
+template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
+class BBB:virtual CCC {
+ void xxx (HHH < X1 >);
+ vector < HHH < X1 > >aaa;
+};
+class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
+ZZZ * ZZZ::ppp () { return new ZZZ; }
diff --git a/test/CodeGenCXX/thunks.cpp b/test/CodeGenCXX/thunks.cpp
index 7c80b96..04d0820 100644
--- a/test/CodeGenCXX/thunks.cpp
+++ b/test/CodeGenCXX/thunks.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=HIDDEN %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -fhidden-weak-vtables -emit-llvm -o - | FileCheck -check-prefix=HIDDEN %s
namespace Test1 {
diff --git a/test/CodeGenCXX/typeid-cxx11.cpp b/test/CodeGenCXX/typeid-cxx11.cpp
new file mode 100644
index 0000000..940274e
--- /dev/null
+++ b/test/CodeGenCXX/typeid-cxx11.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck %s
+#include <typeinfo>
+
+namespace Test1 {
+
+struct Item {
+ const std::type_info &ti;
+ const char *name;
+ void *(*make)();
+};
+
+template<typename T> void *make_impl() { return new T; }
+template<typename T> constexpr Item item(const char *name) {
+ return { typeid(T), name, make_impl<T> };
+}
+
+struct A { virtual ~A(); };
+struct B : virtual A {};
+struct C { int n; };
+
+// FIXME: check we produce a constant array for this, once we support IRGen of
+// folded structs and arrays.
+constexpr Item items[] = {
+ item<A>("A"), item<B>("B"), item<C>("C"), item<int>("int")
+};
+
+// CHECK: @_ZN5Test11xE = constant %"class.std::type_info"* bitcast (i8** @_ZTIN5Test11AE to %"class.std::type_info"*), align 8
+constexpr auto &x = items[0].ti;
+
+}
diff --git a/test/CodeGenCXX/typeid.cpp b/test/CodeGenCXX/typeid.cpp
index 7ebf41c..fce3795 100644
--- a/test/CodeGenCXX/typeid.cpp
+++ b/test/CodeGenCXX/typeid.cpp
@@ -6,6 +6,27 @@ namespace Test1 {
// PR7400
struct A { virtual void f(); };
+// CHECK: @_ZN5Test16int_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), align 8
+const std::type_info &int_ti = typeid(int);
+
+// CHECK: @_ZN5Test14A_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIN5Test11AE to %"class.std::type_info"*), align 8
+const std::type_info &A_ti = typeid(const volatile A &);
+
+volatile char c;
+
+// CHECK: @_ZN5Test14c_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIc to %"class.std::type_info"*), align 8
+const std::type_info &c_ti = typeid(c);
+
+extern const double &d;
+
+// CHECK: @_ZN5Test14d_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTId to %"class.std::type_info"*), align 8
+const std::type_info &d_ti = typeid(d);
+
+extern A &a;
+
+// CHECK: @_ZN5Test14a_tiE = global
+const std::type_info &a_ti = typeid(a);
+
// CHECK: define i8* @_ZN5Test11fEv
const char *f() {
try {
diff --git a/test/CodeGenCXX/uncode-string.cpp b/test/CodeGenCXX/uncode-string.cpp
index e543149..1d83999 100644
--- a/test/CodeGenCXX/uncode-string.cpp
+++ b/test/CodeGenCXX/uncode-string.cpp
@@ -3,4 +3,4 @@
wchar_t s[] = L"\u2722";
-// CHECK: @s = global [8 x i8] c"\22'\00\00\00\00\00\00"
+// CHECK: @s = global [2 x i32] [i32 10018, i32 0], align 4
diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp
index fb981d1..6e60f80 100644
--- a/test/CodeGenCXX/value-init.cpp
+++ b/test/CodeGenCXX/value-init.cpp
@@ -134,8 +134,7 @@ namespace zeroinit {
// CHECK: define i32 @_ZN8zeroinit4testEv()
int test() {
// CHECK: call void @llvm.memset.p0i8.i64
- // CHECK: getelementptr
- // CHECK: ret i32
+ // CHECK: ret i32 0
return S().i;
}
diff --git a/test/CodeGenCXX/virtual-implicit-move-assignment.cpp b/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
new file mode 100644
index 0000000..d8ac1ed
--- /dev/null
+++ b/test/CodeGenCXX/virtual-implicit-move-assignment.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+struct D;
+struct B {
+ virtual D &operator=(D&&) = 0;
+};
+struct D : B { D(); virtual void a(); };
+void D::a() {}
+D d;
+
+// CHECK: @_ZTV1D = {{.*}} @_ZN1DaSEOS_
+// CHECK: define linkonce_odr {{.*}} @_ZN1DaSEOS_
diff --git a/test/CodeGenCXX/visibility-inlines-hidden.cpp b/test/CodeGenCXX/visibility-inlines-hidden.cpp
index f7fabed..d660b1b 100644
--- a/test/CodeGenCXX/visibility-inlines-hidden.cpp
+++ b/test/CodeGenCXX/visibility-inlines-hidden.cpp
@@ -97,3 +97,14 @@ namespace test2 {
// CHECK: define available_externally void @_ZN5test22ns3fooINS_1BINS_1AEEEEEvv()
}
+
+namespace PR11642 {
+ template <typename T>
+ class Foo {
+ public:
+ T foo(T x) { return x; }
+ };
+ extern template class Foo<int>;
+ template class Foo<int>;
+ // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi
+}
diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp
index 0f36a6a..59fd7c2 100644
--- a/test/CodeGenCXX/visibility.cpp
+++ b/test/CodeGenCXX/visibility.cpp
@@ -5,6 +5,29 @@
#define PROTECTED __attribute__((visibility("protected")))
#define DEFAULT __attribute__((visibility("default")))
+namespace test25 {
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct definition {
+ };
+ };
+
+ class DEFAULT A { };
+
+ X<int>::definition<A> a;
+ // CHECK: @_ZN6test251aE = global
+ // CHECK-HIDDEN: @_ZN6test251aE = hidden global
+}
+
+namespace test28 {
+ class DEFAULT foo {
+ };
+ foo myvec;
+ // CHECK: @_ZN6test285myvecE = global
+ // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global
+}
+
// CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10
// CHECK: @_ZN5Test71aE = hidden global
// CHECK: @_ZN5Test71bE = global
@@ -22,6 +45,26 @@
// CHECK-HIDDEN: @_ZN6Test143varE = external global
// CHECK: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
// CHECK-HIDDEN: @_ZN6Test154TempINS_1AEE5Inner6bufferE = external global [0 x i8]
+
+namespace test27 {
+ template<typename T>
+ class C {
+ class __attribute__((visibility("default"))) D {
+ void f();
+ };
+ };
+
+ template<>
+ class C<int>::D {
+ virtual void g();
+ };
+
+ void C<int>::D::g() {
+ }
+ // CHECK: _ZTVN6test271CIiE1DE = unnamed_addr constant
+ // CHECK-HIDDEN: _ZTVN6test271CIiE1DE = unnamed_addr constant
+}
+
// CHECK: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr global
// CHECK: @_ZGVZN6Test193fooIiEEvvE1a = linkonce_odr global i64
// CHECK-HIDDEN: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr hidden global
@@ -156,7 +199,7 @@ namespace Test9 {
namespace Test10 {
struct A;
- DEFAULT class B {
+ class DEFAULT B {
void foo(A*);
};
@@ -403,10 +446,7 @@ namespace Test20 {
B<A<2> >::test4();
}
- // CHECK: declare void @_ZN6Test201BINS_1AILj2EEEE5test5Ev()
- // (but explicit visibility on a template argument doesn't count as
- // explicit visibility for the template for purposes of deciding
- // whether an external symbol gets visibility)
+ // CHECK: declare hidden void @_ZN6Test201BINS_1AILj2EEEE5test5Ev()
void test5() {
B<A<2> >::test5();
}
@@ -454,3 +494,114 @@ namespace test22 {
// CHECK-HIDDEN: declare void @_ZN6test221BINS_2A2EE3fooEv()
// CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test221BINS_2A2EE3barEv()
}
+
+namespace PR10113 {
+ namespace foo DEFAULT {
+ template<typename T>
+ class bar {
+ void zed() {}
+ };
+ }
+ template class foo::bar<char>;
+ // CHECK: define weak_odr void @_ZN7PR101133foo3barIcE3zedEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barIcE3zedEv
+
+ struct zed {
+ };
+ template class foo::bar<zed>;
+ // CHECK: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv
+}
+
+namespace PR11690 {
+ template<class T> struct Class {
+ void size() const {
+ }
+ };
+ template class DEFAULT Class<char>;
+ // CHECK: define weak_odr void @_ZNK7PR116905ClassIcE4sizeEv
+ // CHECK-HIDDEN: define weak_odr void @_ZNK7PR116905ClassIcE4sizeEv
+
+ template<class T> void Method() {}
+ template DEFAULT void Method<char>();
+ // CHECK: define weak_odr void @_ZN7PR116906MethodIcEEvv
+ // CHECK-HIDDEN: define weak_odr void @_ZN7PR116906MethodIcEEvv
+}
+
+namespace PR11690_2 {
+ namespace foo DEFAULT {
+ class bar;
+ template<typename T1, typename T2 = bar>
+ class zed {
+ void bar() {
+ }
+ };
+ }
+ struct baz {
+ };
+ template class foo::zed<baz>;
+ // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
+ // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv
+}
+
+namespace test23 {
+ // Having a template argument that is explicitly visible should not make
+ // the template instantiation visible.
+ template <typename T>
+ struct X {
+ static void f() {
+ }
+ };
+
+ class DEFAULT A;
+
+ void g() {
+ X<A> y;
+ y.f();
+ }
+ // CHECK: define linkonce_odr void @_ZN6test231XINS_1AEE1fEv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test231XINS_1AEE1fEv
+}
+
+namespace PR12001 {
+ template <typename P1>
+ void Bind(const P1& p1) {
+ }
+
+ class DEFAULT Version { };
+
+ void f() {
+ Bind(Version());
+ }
+ // CHECK: define linkonce_odr void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN7PR120014BindINS_7VersionEEEvRKT_
+}
+
+namespace test24 {
+ class DEFAULT A { };
+
+ struct S {
+ template <typename T>
+ void mem() {}
+ };
+
+ void test() {
+ S s;
+ s.mem<A>();
+ }
+ // CHECK: define linkonce_odr void @_ZN6test241S3memINS_1AEEEvv
+ // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test241S3memINS_1AEEEvv
+}
+
+namespace test26 {
+ template<typename T>
+ class C {
+ __attribute__((visibility("default"))) void f();
+ };
+
+ template<>
+ void C<int>::f() { }
+
+ // CHECK: define void @_ZN6test261CIiE1fEv
+ // CHECK-HIDDEN: define void @_ZN6test261CIiE1fEv
+}
diff --git a/test/CodeGenCXX/vla.cpp b/test/CodeGenCXX/vla.cpp
index 58cdf79..b523c76 100644
--- a/test/CodeGenCXX/vla.cpp
+++ b/test/CodeGenCXX/vla.cpp
@@ -1,5 +1,19 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
+template<typename T>
+struct S {
+ static int n;
+};
+template<typename T> int S<T>::n = 5;
+
+int f() {
+ // Make sure that the reference here is enough to trigger the instantiation of
+ // the static data member.
+ // CHECK: @_ZN1SIiE1nE = weak_odr global i32 5
+ int a[S<int>::n];
+ return sizeof a;
+}
+
// rdar://problem/9506377
void test0(void *array, int n) {
// CHECK: define void @_Z5test0Pvi(
@@ -40,4 +54,3 @@ void test0(void *array, int n) {
// CHECK-NEXT: ret void
}
-
diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp
index bd69681..d7644b9 100644
--- a/test/CodeGenCXX/vtable-layout.cpp
+++ b/test/CodeGenCXX/vtable-layout.cpp
@@ -42,6 +42,7 @@
// RUN: FileCheck --check-prefix=CHECK-41 %s < %t
// RUN: FileCheck --check-prefix=CHECK-42 %s < %t
// RUN: FileCheck --check-prefix=CHECK-43 %s < %t
+// RUN: FileCheck --check-prefix=CHECK-44 %s < %t
// For now, just verify this doesn't crash.
namespace test0 {
@@ -1701,3 +1702,28 @@ struct C : B {
C* C::f() { return 0; }
}
+
+// rdar://problem/10959710
+namespace Test38 {
+ struct A {
+ virtual void *foo();
+ virtual const void *foo() const;
+ };
+
+ // CHECK-44: Vtable for 'Test38::B' (7 entries).
+ // CHECK-44-NEXT: 0 | vbase_offset (0)
+ // CHECK-44-NEXT: 1 | vcall_offset (0)
+ // CHECK-44-NEXT: 2 | vcall_offset (0)
+ // CHECK-44-NEXT: 3 | offset_to_top (0)
+ // CHECK-44-NEXT: 4 | Test38::B RTTI
+ // CHECK-44-NEXT: -- (Test38::A, 0) vtable address --
+ // CHECK-44-NEXT: -- (Test38::B, 0) vtable address --
+ // CHECK-44-NEXT: 5 | void *Test38::B::foo()
+ // CHECK-44-NEXT: 6 | const void *Test38::B::foo() const
+ class B : virtual public A {
+ void *foo();
+ const void *foo() const;
+ };
+
+ void *B::foo() { return 0; }
+}
diff --git a/test/CodeGenCXX/weak-extern-typeinfo.cpp b/test/CodeGenCXX/weak-extern-typeinfo.cpp
new file mode 100644
index 0000000..3c3406e
--- /dev/null
+++ b/test/CodeGenCXX/weak-extern-typeinfo.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar://10246395
+
+#define WEAK __attribute__ ((weak))
+
+class WEAK A {
+ virtual void foo();
+};
+
+class B : public A {
+ virtual void foo();
+};
+void A::foo() { }
+void B::foo() { }
+
+class T {};
+class T1 {};
+
+class C : public T1, public B, public T {
+ virtual void foo();
+};
+void C::foo() { }
+
+class V1 : public virtual A {
+ virtual void foo();
+};
+
+class V2 : public virtual V1 {
+ virtual void foo();
+};
+void V1::foo() { }
+void V2::foo() { }
+
+// CHECK: @_ZTS1A = weak_odr constant
+// CHECK: @_ZTI1A = weak_odr unnamed_addr constant
+// CHECK: @_ZTS1B = weak_odr constant
+// CHECK: @_ZTI1B = weak_odr unnamed_addr constant
+// CHECK: @_ZTS1C = weak_odr constant
+// CHECK: @_ZTS2T1 = linkonce_odr constant
+// CHECK: @_ZTI2T1 = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTS1T = linkonce_odr constant
+// CHECK: @_ZTI1T = linkonce_odr unnamed_addr constant
+// CHECK: @_ZTI1C = weak_odr unnamed_addr constant
+// CHECK: @_ZTS2V1 = weak_odr constant
+// CHECK: @_ZTI2V1 = weak_odr unnamed_addr constant
+// CHECK: @_ZTS2V2 = weak_odr constant
+// CHECK: @_ZTI2V2 = weak_odr unnamed_addr constant
diff --git a/test/CodeGenCXX/x86_32-arguments.cpp b/test/CodeGenCXX/x86_32-arguments.cpp
index 1cbeb71..4404de0 100644
--- a/test/CodeGenCXX/x86_32-arguments.cpp
+++ b/test/CodeGenCXX/x86_32-arguments.cpp
@@ -84,7 +84,7 @@ struct s4_1 { float x; };
struct s4_2 : s4_0, s4_1 { };
s4_2 f4() { return s4_2(); }
-// CHECK: define i32 @_Z2f5v()
+// CHECK: define i32* @_Z2f5v()
struct s5 { s5(); int &x; };
s5 f5() { return s5(); }
diff --git a/test/CodeGenObjC/2009-08-05-utf16.m b/test/CodeGenObjC/2009-08-05-utf16.m
index 38c9c82..06458e7 100644
--- a/test/CodeGenObjC/2009-08-05-utf16.m
+++ b/test/CodeGenObjC/2009-08-05-utf16.m
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -emit-llvm -w -x objective-c %s -o - | FileCheck %s
// rdar://7095855 rdar://7115749
-// CHECK: internal unnamed_addr constant [12 x i8]
+// CHECK: internal unnamed_addr constant [6 x i16] [i16 105, i16 80, i16 111, i16 100, i16 8482, i16 0], align 2
void *P = @"iPodâ„¢";
diff --git a/test/CodeGenObjC/Inputs/literal-support.h b/test/CodeGenObjC/Inputs/literal-support.h
new file mode 100644
index 0000000..5680a20
--- /dev/null
+++ b/test/CodeGenObjC/Inputs/literal-support.h
@@ -0,0 +1,35 @@
+#ifndef OBJC_LITERAL_SUPPORT_H
+#define OBJC_LITERAL_SUPPORT_H
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+#endif // OBJC_LITERAL_SUPPORT_H
diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m
new file mode 100644
index 0000000..06acf01
--- /dev/null
+++ b/test/CodeGenObjC/arc-blocks.m
@@ -0,0 +1,523 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+// This shouldn't crash.
+void test0(id (^maker)(void)) {
+ maker();
+}
+
+int (^test1(int x))(void) {
+ // CHECK: define i32 ()* @test1(
+ // CHECK: [[X:%.*]] = alloca i32,
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK-NEXT: store i32 {{%.*}}, i32* [[X]]
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to i32 ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast i32 ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]]) nounwind
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to i32 ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast i32 ()* [[T3]] to i8*
+ // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T4]]) nounwind
+ // CHECK-NEXT: [[T6:%.*]] = bitcast i8* [[T5]] to i32 ()*
+ // CHECK-NEXT: ret i32 ()* [[T6]]
+ return ^{ return x; };
+}
+
+void test2(id x) {
+// CHECK: define void @test2(
+// CHECK: [[X:%.*]] = alloca i8*,
+// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+// CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+// CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
+// CHECK-NEXT: [[SLOTREL:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]],
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]],
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call void @test2_helper(
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOTREL]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
+// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
+// CHECK-NEXT: ret void
+ extern void test2_helper(id (^)(void));
+ test2_helper(^{ return x; });
+}
+
+void test3(void (^sink)(id*)) {
+ __strong id strong;
+ sink(&strong);
+
+ // CHECK: define void @test3(
+ // CHECK: [[SINK:%.*]] = alloca void (i8**)*
+ // CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
+ // CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
+ // CHECK-NEXT: bitcast void (i8**)* {{%.*}} to i8*
+ // CHECK-NEXT: call i8* @objc_retain(
+ // CHECK-NEXT: bitcast i8*
+ // CHECK-NEXT: store void (i8**)* {{%.*}}, void (i8**)** [[SINK]]
+ // CHECK-NEXT: store i8* null, i8** [[STRONG]]
+
+ // CHECK-NEXT: load void (i8**)** [[SINK]]
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: [[BLOCK:%.*]] = bitcast
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP]]
+ // CHECK-NEXT: [[F0:%.*]] = load i8**
+ // CHECK-NEXT: [[F1:%.*]] = bitcast i8* [[F0]] to void (i8*, i8**)*
+ // CHECK-NEXT: call void [[F1]](i8* [[BLOCK]], i8** [[TEMP]])
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[TEMP]]
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: store i8* [[T1]], i8** [[STRONG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+
+ // CHECK-NEXT: load void (i8**)** [[SINK]]
+ // CHECK-NEXT: bitcast
+ // CHECK-NEXT: call void @objc_release
+ // CHECK-NEXT: ret void
+
+}
+
+void test4(void) {
+ id test4_source(void);
+ void test4_helper(void (^)(void));
+ __block id var = test4_source();
+ test4_helper(^{ var = 0; });
+
+ // CHECK: define void @test4()
+ // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
+ // 0x02000000 - has copy/dispose helpers
+ // CHECK-NEXT: store i32 33554432, i32* [[T0]]
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test4_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]]
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: store i8* [[T0]], i8**
+ // CHECK: call void @test4_helper(
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__Block_byref_object_copy_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T2:%.*]] = load i8** [[T1]]
+ // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
+ // CHECK-NEXT: store i8* null, i8** [[T1]]
+
+ // CHECK: define internal void @__Block_byref_object_dispose_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ // CHECK: define internal void @__test4_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8
+ // CHECK-NEXT: store i8* null, i8** [[SLOT]],
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
+}
+
+void test5(void) {
+ extern id test5_source(void);
+ void test5_helper(void (^)(void));
+ __unsafe_unretained id var = test5_source();
+ test5_helper(^{ (void) var; });
+
+ // CHECK: define void @test5()
+ // CHECK: [[VAR:%.*]] = alloca i8*
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = call i8* @test5_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[VAR]],
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // 0x40000000 - has signature but no copy/dispose
+ // CHECK: store i32 1073741824, i32*
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[VAR]]
+ // CHECK-NEXT: store i8* [[T0]], i8** [[CAPTURE]]
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to
+ // CHECK: call void @test5_helper
+ // CHECK-NEXT: ret void
+}
+
+void test6(void) {
+ id test6_source(void);
+ void test6_helper(void (^)(void));
+ __block __weak id var = test6_source();
+ test6_helper(^{ var = 0; });
+
+ // CHECK: define void @test6()
+ // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
+ // 0x02000000 - has copy/dispose helpers
+ // CHECK-NEXT: store i32 33554432, i32* [[T0]]
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @test6_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: store i8* [[T0]], i8**
+ // CHECK: call void @test6_helper(
+ // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[SLOT]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__Block_byref_object_copy_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: load i8**
+ // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
+ // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
+
+ // CHECK: define internal void @__Block_byref_object_dispose_
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
+
+ // CHECK: define internal void @__test6_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
+ // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
+ // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
+ // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
+}
+
+void test7(void) {
+ id test7_source(void);
+ void test7_helper(void (^)(void));
+ void test7_consume(id);
+ __weak id var = test7_source();
+ test7_helper(^{ test7_consume(var); });
+
+ // CHECK: define void @test7()
+ // CHECK: [[VAR:%.*]] = alloca i8*,
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+ // CHECK: [[T0:%.*]] = call i8* @test7_source()
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[VAR]], i8* [[T1]])
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+ // 0x42000000 - has signature, copy/dispose helpers
+ // CHECK: store i32 1107296256,
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[VAR]])
+ // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T0]])
+ // CHECK: call void @test7_helper(
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** {{%.*}})
+ // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__test7_block_invoke_
+ // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]])
+ // CHECK-NEXT: call void @test7_consume(i8* [[T0]])
+ // CHECK-NEXT: ret void
+
+ // CHECK: define internal void @__copy_helper_block_
+ // CHECK: getelementptr
+ // CHECK-NEXT: getelementptr
+ // CHECK-NEXT: call void @objc_copyWeak(
+
+ // CHECK: define internal void @__destroy_helper_block_
+ // CHECK: getelementptr
+ // CHECK-NEXT: call void @objc_destroyWeak(
+}
+
+@interface Test8 @end
+@implementation Test8
+- (void) test {
+// CHECK: define internal void @"\01-[Test8 test]"
+// CHECK: [[SELF:%.*]] = alloca [[TEST8:%.*]]*,
+// CHECK-NEXT: alloca i8*
+// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
+// CHECK: store
+// CHECK-NEXT: store
+// CHECK: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+// CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]** [[SELF]],
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]])
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST8]]*
+// CHECK-NEXT: store [[TEST8]]* [[T4]], [[TEST8]]** [[T0]]
+// CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to
+// CHECK: call void @test8_helper(
+// CHECK-NEXT: [[T1:%.*]] = load [[TEST8]]** [[D0]]
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST8]]* [[T1]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T2]])
+// CHECK-NEXT: ret void
+
+ extern void test8_helper(void (^)(void));
+ test8_helper(^{ (void) self; });
+}
+@end
+
+id test9(void) {
+ typedef id __attribute__((ns_returns_retained)) blocktype(void);
+ extern void test9_consume_block(blocktype^);
+ return ^blocktype {
+ extern id test9_produce(void);
+ return test9_produce();
+ }();
+
+// CHECK: define i8* @test9(
+// CHECK: load i8** getelementptr
+// CHECK-NEXT: bitcast i8*
+// CHECK-NEXT: call i8*
+// CHECK-NEXT: call i8* @objc_autoreleaseReturnValue
+// CHECK-NEXT: ret i8*
+
+// CHECK: call i8* @test9_produce()
+// CHECK-NEXT: call i8* @objc_retain
+// CHECK-NEXT: ret i8*
+}
+
+// rdar://problem/9814099
+// Test that we correctly initialize __block variables
+// when the initialization captures the variable.
+void test10a(void) {
+ __block void (^block)(void) = ^{ block(); };
+ // CHECK: define void @test10a()
+ // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
+
+ // Zero-initialization before running the initializer.
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
+
+ // Run the initializer as an assignment.
+ // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
+ // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
+ // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
+ // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
+ // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T7]])
+
+ // Destroy at end of function.
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: ret void
+}
+
+// <rdar://problem/10402698>: do this copy and dispose with
+// objc_retainBlock/release instead of _Block_object_assign/destroy.
+// We can also use _Block_object_assign/destroy with
+// BLOCK_FIELD_IS_BLOCK as long as we don't pass BLOCK_BYREF_CALLER.
+
+// CHECK: define internal void @__Block_byref_object_copy
+// CHECK: [[D0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[D1:%.*]] = bitcast i8* [[D0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[D2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[D1]], i32 0, i32 6
+// CHECK-NEXT: [[S0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[S1:%.*]] = bitcast i8* [[S0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[S2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[S1]], i32 0, i32 6
+// CHECK-NEXT: [[T0:%.*]] = load void ()** [[S2]], align 8
+// CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+// CHECK-NEXT: store void ()* [[T3]], void ()** [[D2]], align 8
+// CHECK-NEXT: ret void
+
+// CHECK: define internal void @__Block_byref_object_dispose
+// CHECK: [[T0:%.*]] = load i8** {{%.*}}
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BYREF_T]]*
+// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T1]], i32 0, i32 6
+// CHECK-NEXT: [[T3:%.*]] = load void ()** [[T2]], align 8
+// CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T4]])
+// CHECK-NEXT: ret void
+
+// Test that we correctly assign to __block variables when the
+// assignment captures the variable.
+void test10b(void) {
+ __block void (^block)(void);
+ block = ^{ block(); };
+
+ // CHECK: define void @test10b()
+ // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
+
+ // Zero-initialize.
+ // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+ // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
+
+ // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
+
+ // The assignment.
+ // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
+ // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
+ // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
+ // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
+ // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
+ // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
+ // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
+ // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T7]])
+
+ // Destroy at end of function.
+ // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
+ // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
+ // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
+ // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T2]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/10088932
+void test11_helper(id);
+void test11a(void) {
+ int x;
+ test11_helper(^{ (void) x; });
+
+ // CHECK: define void @test11a()
+ // CHECK: [[X:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: call void @test11_helper(i8* [[T4]])
+ // CHECK-NEXT: [[T5:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+ // CHECK-NEXT: ret void
+}
+void test11b(void) {
+ int x;
+ id b = ^{ (void) x; };
+
+ // CHECK: define void @test11b()
+ // CHECK: [[X:%.*]] = alloca i32, align 4
+ // CHECK-NEXT: [[B:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
+ // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
+ // CHECK-NEXT: store i8* [[T4]], i8** [[B]], align 8
+ // CHECK-NEXT: [[T5:%.*]] = load i8** [[B]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T5]])
+ // CHECK-NEXT: ret void
+}
+
+// rdar://problem/9979150
+@interface Test12
+@property (strong) void(^ablock)(void);
+@property (nonatomic, strong) void(^nblock)(void);
+@end
+@implementation Test12
+@synthesize ablock, nblock;
+// CHECK: define internal void ()* @"\01-[Test12 ablock]"(
+// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext true)
+
+// CHECK: define internal void @"\01-[Test12 setAblock:]"(
+// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext true, i1 zeroext true)
+
+// CHECK: define internal void ()* @"\01-[Test12 nblock]"(
+// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext false)
+
+// CHECK: define internal void @"\01-[Test12 setNblock:]"(
+// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext false, i1 zeroext true)
+@end
+
+// rdar://problem/10131784
+void test13(id x) {
+ extern void test13_helper(id);
+ extern void test13_use(void(^)(void));
+
+ void (^b)(void) = (x ? ^{test13_helper(x);} : 0);
+ test13_use(b);
+
+ // CHECK: define void @test13(
+ // CHECK: [[X:%.*]] = alloca i8*, align 8
+ // CHECK-NEXT: [[B:%.*]] = alloca void ()*, align 8
+ // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:.*]], align 8
+ // CHECK-NEXT: [[CLEANUP_ACTIVE:%.*]] = alloca i1
+ // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_retain(i8* {{%.*}})
+ // CHECK-NEXT: store i8* [[T0]], i8** [[X]], align 8
+ // CHECK-NEXT: [[CLEANUP_ADDR:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
+ // CHECK-NEXT: store i1 false, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T1]],
+
+ // CHECK-NOT: br
+ // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
+ // CHECK-NEXT: [[T0:%.*]] = load i8** [[X]], align 8
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
+ // CHECK-NEXT: store i8* [[T1]], i8** [[CAPTURE]], align 8
+ // CHECK-NEXT: store i1 true, i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
+ // CHECK-NEXT: br label
+ // CHECK: br label
+ // CHECK: [[T0:%.*]] = phi void ()*
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
+ // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
+ // CHECK-NEXT: store void ()* [[T3]], void ()** [[B]], align 8
+ // CHECK-NEXT: [[T0:%.*]] = load void ()** [[B]], align 8
+ // CHECK-NEXT: call void @test13_use(void ()* [[T0]])
+ // CHECK-NEXT: [[T0:%.*]] = load void ()** [[B]]
+ // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
+ // CHECK-NEXT: call void @objc_release(i8* [[T1]])
+
+ // CHECK-NEXT: [[T0:%.*]] = load i1* [[CLEANUP_ACTIVE]]
+ // CHECK-NEXT: br i1 [[T0]]
+ // CHECK: [[T0:%.*]] = load i8** [[CLEANUP_ADDR]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: br label
+
+ // CHECK: [[T0:%.*]] = load i8** [[X]]
+ // CHECK-NEXT: call void @objc_release(i8* [[T0]])
+ // CHECK-NEXT: ret void
+}
+
+// <rdar://problem/10907510>
+void test14() {
+ void (^const x[1])(void) = { ^{} };
+}
+
+// rdar://11149025
+// Don't make invalid ASTs and crash.
+void test15_helper(void (^block)(void), int x);
+void test15(int a) {
+ test15_helper(^{ (void) a; }, ({ a; }));
+}
diff --git a/test/CodeGenObjC/arc-cond-stmt.m b/test/CodeGenObjC/arc-cond-stmt.m
new file mode 100644
index 0000000..d8ee6bb
--- /dev/null
+++ b/test/CodeGenObjC/arc-cond-stmt.m
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s
+// rdar://10327068
+
+@class NSString;
+
+@interface NSAssertionHandler {
+}
+
++ (NSAssertionHandler *)currentHandler;
+
+- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(int)line ,...;
+
+@end
+
+typedef enum
+{
+ MWRaceOrder_MeetName,
+ MWRaceOrder_MeetPosition,
+ MWRaceOrder_MeetDistance,
+ MWRaceOrder_Name,
+ MWRaceOrder_Position,
+ MWRaceOrder_Distance,
+ MWRaceOrder_Default = MWRaceOrder_Name,
+ MWRaceOrder_MeetDefault = MWRaceOrder_MeetName,
+} MWRaceOrder;
+
+@interface MWViewMeetController
+@property (nonatomic, assign) MWRaceOrder raceOrder;
+@end
+
+@implementation MWViewMeetController
+
+- (int)orderSegment
+{
+ switch (self.raceOrder)
+ {
+
+ default:
+ { [(NSAssertionHandler *)0 handleFailureInMethod:_cmd object:self file:(NSString*)0 lineNumber:192 ]; };
+ break;
+ }
+
+ return 0;
+}
+
+@synthesize raceOrder;
+
+@end
diff --git a/test/CodeGenObjC/arc-exceptions.m b/test/CodeGenObjC/arc-exceptions.m
new file mode 100644
index 0000000..5ef5aba
--- /dev/null
+++ b/test/CodeGenObjC/arc-exceptions.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-runtime-has-weak -o - %s | FileCheck %s
+
+@class Ety;
+
+// These first two tests are all PR11732 / rdar://problem/10667070.
+
+void test0_helper(void);
+void test0(void) {
+ @try {
+ test0_helper();
+ } @catch (Ety *e) {
+ }
+}
+// CHECK: define void @test0()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @test0_helper()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test1_helper(void);
+void test1(void) {
+ @try {
+ test1_helper();
+ } @catch (__weak Ety *e) {
+ }
+}
+// CHECK: define void @test1()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @test1_helper()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
diff --git a/test/CodeGenObjC/arc-foreach.m b/test/CodeGenObjC/arc-foreach.m
index 9449b3d..67fad4d 100644
--- a/test/CodeGenObjC/arc-foreach.m
+++ b/test/CodeGenObjC/arc-foreach.m
@@ -60,13 +60,14 @@ void test0(NSArray *array) {
// CHECK-LP64-NEXT: [[T3:%.*]] = load i8** [[T2]]
// CHECK-LP64-NEXT: store i8* [[T3]], i8** [[X]]
+// CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
// CHECK-LP64-NEXT: [[T1:%.*]] = load i8** [[X]]
// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
// CHECK-LP64-NEXT: store i8* [[T2]], i8** [[T0]]
// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]]
// CHECK-LP64: call void @use_block(
-// CHECK-LP64-NEXT: [[T1:%.*]] = load i8** [[T0]]
+// CHECK-LP64-NEXT: [[T1:%.*]] = load i8** [[D0]]
// CHECK-LP64-NEXT: call void @objc_release(i8* [[T1]])
// CHECK-LP64: [[T0:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
@@ -108,12 +109,13 @@ void test1(NSArray *array) {
// CHECK-LP64-NEXT: [[T3:%.*]] = load i8** [[T2]]
// CHECK-LP64-NEXT: call i8* @objc_initWeak(i8** [[X]], i8* [[T3]])
+// CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
// CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
// CHECK-LP64-NEXT: [[T1:%.*]] = call i8* @objc_loadWeak(i8** [[X]])
// CHECK-LP64-NEXT: call i8* @objc_initWeak(i8** [[T0]], i8* [[T1]])
// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to
// CHECK-LP64: call void @use_block
-// CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[T0]])
+// CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[D0]])
// CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[X]])
// rdar://problem/9817306
diff --git a/test/CodeGenObjC/arc-ivar-layout.m b/test/CodeGenObjC/arc-ivar-layout.m
index 30c90fa..7f58a0c 100644
--- a/test/CodeGenObjC/arc-ivar-layout.m
+++ b/test/CodeGenObjC/arc-ivar-layout.m
@@ -42,3 +42,14 @@
// CHECK-LP64: L_OBJC_CLASS_NAME_15:
// CHECK-LP64-NEXT: .asciz "\022"
+@interface UnsafePerson {
+@public
+ __unsafe_unretained id name;
+ __unsafe_unretained id age;
+ id value;
+}
+@end
+
+@implementation UnsafePerson @end
+// CHECK-LP64: L_OBJC_CLASS_NAME_20:
+// CHECK-LP64-NEXT: .asciz "!"
diff --git a/test/CodeGenObjC/arc-literals.m b/test/CodeGenObjC/arc-literals.m
new file mode 100644
index 0000000..203c2ad
--- /dev/null
+++ b/test/CodeGenObjC/arc-literals.m
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#include "literal-support.h"
+
+// Check the various selector names we'll be using, in order.
+
+// CHECK: c"numberWithInt:\00"
+// CHECK: c"numberWithUnsignedInt:\00"
+// CHECK: c"numberWithUnsignedLongLong:\00"
+// CHECK: c"numberWithChar:\00"
+// CHECK: c"arrayWithObjects:count:\00"
+// CHECK: c"dictionaryWithObjects:forKeys:count:\00"
+// CHECK: c"prop\00"
+
+// CHECK: define void @test_numeric()
+void test_numeric() {
+ // CHECK: {{call.*objc_msgSend.*i32 17}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ilit = @17;
+ // CHECK: {{call.*objc_msgSend.*i32 25}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ulit = @25u;
+ // CHECK: {{call.*objc_msgSend.*i64 42}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id ulllit = @42ull;
+ // CHECK: {{call.*objc_msgSend.*i8 signext 97}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id charlit = @'a';
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @test_array
+void test_array(id a, id b) {
+ // Retaining parameters
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+
+ // Constructing the array
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK: store i8*
+
+ // CHECK: {{call i8*.*objc_msgSend.*i64 2}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[a, b];
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+// CHECK: define void @test_dictionary
+void test_dictionary(id k1, id o1, id k2, id o2) {
+ // Retaining parameters
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+ // CHECK: call i8* @objc_retain(i8*
+
+ // Constructing the arrays
+ // CHECK: getelementptr inbounds [2 x i8*]* [[KEYS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[KEYS]], i32 0, i32 1
+ // CHECK: store i8*
+ // CHECK: getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK: store i8*
+
+ // Constructing the dictionary
+ // CHECK: {{call i8.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id dict = @{ k1 : o1, k2 : o2 };
+
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
+
+@interface A
+@end
+
+@interface B
+@property (retain) A* prop;
+@end
+
+// CHECK: define void @test_property
+void test_property(B *b) {
+ // Retain parameter
+ // CHECK: call i8* @objc_retain
+
+ // Invoke 'prop'
+ // CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+ // CHECK: {{call.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+
+ // Invoke arrayWithObjects:count:
+ // CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+ // CHECK: {{call.*objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ b.prop ];
+
+ // Release b.prop
+ // CHECK: call void @objc_release
+
+ // Destroy arr
+ // CHECK: call void @objc_release
+
+ // Destroy b
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+}
diff --git a/test/CodeGenObjC/arc-no-arc-exceptions.m b/test/CodeGenObjC/arc-no-arc-exceptions.m
new file mode 100644
index 0000000..7ae061f
--- /dev/null
+++ b/test/CodeGenObjC/arc-no-arc-exceptions.m
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O0 -disable-llvm-optzns -o - %s | FileCheck -check-prefix=NO-METADATA %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s -fobjc-arc-exceptions | FileCheck -check-prefix=NO-METADATA %s
+
+// The front-end should emit clang.arc.no_objc_arc_exceptions in -fobjc-arc-exceptions
+// mode when optimization is enabled, and not otherwise.
+
+void thrower(void);
+void not(void) __attribute__((nothrow));
+
+// CHECK: define void @test0(
+// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
+// CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test0(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test0(void) {
+ thrower();
+ not();
+}
+
+// CHECK: define void @test1(
+// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
+// CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test1(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test1(id x) {
+ id y = x;
+ thrower();
+ not();
+}
+
+void NSLog(id, ...);
+
+// CHECK: define void @test2(
+// CHECK: invoke void (i8*, ...)* @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i32* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test2(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test2(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ NSLog(@"Address of x outside of block: %p", &x);
+ }
+}
+
+// CHECK: define void @test3(
+// CHECK: invoke void %{{.*}}(i8* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test3(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test3(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ ^{
+ NSLog(@"Address of x in non-assigned block: %p", &x);
+ }();
+ }
+}
+
+// CHECK: define void @test4(
+// CHECK: invoke void %{{.*}}(i8* %{{.*}})
+// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
+// NO-METADATA: define void @test4(
+// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
+// NO-METADATA: }
+void test4(void) {
+ @autoreleasepool {
+ __attribute__((__blocks__(byref))) int x;
+ void (^b)(void) = ^{
+ NSLog(@"Address of x in assigned block: %p", &x);
+ };
+ b();
+ }
+}
diff --git a/test/CodeGenObjC/arc-property.m b/test/CodeGenObjC/arc-property.m
new file mode 100644
index 0000000..6c5180b
--- /dev/null
+++ b/test/CodeGenObjC/arc-property.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -emit-llvm %s -o - | FileCheck %s
+
+// rdar://problem/10290317
+@interface Test0
+- (void) setValue: (id) x;
+@end
+void test0(Test0 *t0, id value) {
+ t0.value = value;
+}
+// CHECK: define void @test0(
+// CHECK: call i8* @objc_retain(
+// CHECK: call i8* @objc_retain(
+// CHECK: @objc_msgSend
+// CHECK: call void @objc_release(
+// CHECK: call void @objc_release(
diff --git a/test/CodeGenObjC/arc.m b/test/CodeGenObjC/arc.m
index e97e625..2a98b10 100644
--- a/test/CodeGenObjC/arc.m
+++ b/test/CodeGenObjC/arc.m
@@ -13,23 +13,20 @@ void test0(id x) {
// CHECK: define i8* @test1(i8*
id test1(id x) {
- // CHECK: [[RET:%.*]] = alloca i8*
- // CHECK-NEXT: [[X:%.*]] = alloca i8*
+ // CHECK: [[X:%.*]] = alloca i8*
// CHECK-NEXT: [[Y:%.*]] = alloca i8*
// CHECK-NEXT: alloca i32
// CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{%.*}})
// CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
// CHECK-NEXT: store i8* null, i8** [[Y]]
// CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
- // CHECK-NEXT: store i8* [[T1]], i8** [[RET]]
+ // CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T0]])
// CHECK-NEXT: store i32
// CHECK-NEXT: [[T0:%.*]] = load i8** [[Y]]
// CHECK-NEXT: call void @objc_release(i8* [[T0]])
// CHECK-NEXT: [[T1:%.*]] = load i8** [[X]]
// CHECK-NEXT: call void @objc_release(i8* [[T1]])
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[RET]]
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T0]])
+ // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[RET]])
// CHECK-NEXT: ret i8* [[T1]]
id y;
return y;
@@ -449,11 +446,6 @@ void test13(void) {
- (int) x { return super.x + 1; }
@end
-// This shouldn't crash.
-void test18(id (^maker)(void)) {
- maker();
-}
-
void test19() {
// CHECK: define void @test19()
// CHECK: [[X:%.*]] = alloca [5 x i8*], align 16
@@ -615,22 +607,6 @@ void test22(_Bool cond) {
@interface Test24 {} @end
@implementation Test24 @end
-int (^test25(int x))(void) {
- // CHECK: define i32 ()* @test25(
- // CHECK: [[X:%.*]] = alloca i32,
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
- // CHECK-NEXT: store i32 {{%.*}}, i32* [[X]]
- // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to i32 ()*
- // CHECK-NEXT: [[T1:%.*]] = bitcast i32 ()* [[T0]] to i8*
- // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]]) nounwind
- // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to i32 ()*
- // CHECK-NEXT: [[T4:%.*]] = bitcast i32 ()* [[T3]] to i8*
- // CHECK-NEXT: [[T5:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[T4]]) nounwind
- // CHECK-NEXT: [[T6:%.*]] = bitcast i8* [[T5]] to i32 ()*
- // CHECK-NEXT: ret i32 ()* [[T6]]
- return ^{ return x; };
-}
-
// rdar://problem/8941012
@interface Test26 { id x[4]; } @end
@implementation Test26 @end
@@ -657,24 +633,19 @@ int (^test25(int x))(void) {
@implementation Test27
- (id) init { return self; }
// CHECK: define internal i8* @"\01-[Test27 init]"
-// CHECK: [[RET:%.*]] = alloca i8*,
-// CHECK-NEXT: [[SELF:%.*]] = alloca [[TEST27:%.*]]*,
+// CHECK: [[SELF:%.*]] = alloca [[TEST27:%.*]]*,
// CHECK-NEXT: [[CMD:%.*]] = alloca i8*,
// CHECK-NEXT: [[DEST:%.*]] = alloca i32
// CHECK-NEXT: store [[TEST27]]* {{%.*}}, [[TEST27]]** [[SELF]]
// CHECK-NEXT: store i8* {{%.*}}, i8** [[CMD]]
// CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]** [[SELF]]
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
-// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
-// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]]
-// CHECK-NEXT: [[T2:%.*]] = bitcast
-// CHECK-NEXT: store i8* [[T2]], i8** [[RET]]
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]])
// CHECK-NEXT: store i32 {{[0-9]+}}, i32* [[DEST]]
// CHECK-NEXT: [[T0:%.*]] = load [[TEST27]]** [[SELF]]
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST27]]* [[T0]] to i8*
// CHECK-NEXT: call void @objc_release(i8* [[T1]])
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[RET]]
-// CHECK-NEXT: ret i8* [[T0]]
+// CHECK-NEXT: ret i8* [[RET]]
@end
@@ -705,8 +676,7 @@ int (^test25(int x))(void) {
static id _test29_allocator = 0;
- (id) init {
// CHECK: define internal i8* @"\01-[Test29 init]"([[TEST29:%.*]]* {{%.*}},
-// CHECK: [[RET:%.*]] = alloca i8*, align 8
-// CHECK-NEXT: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
+// CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
// CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
// CHECK-NEXT: [[CLEANUP:%.*]] = alloca i32
// CHECK-NEXT: store [[TEST29]]* {{%.*}}, [[TEST29]]** [[SELF]]
@@ -734,10 +704,7 @@ static id _test29_allocator = 0;
// Return statement.
// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[CALL]]
// CHECK-NEXT: [[CALL:%.*]] = bitcast
-// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[CALL]]) nounwind
-// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]]
-// CHECK-NEXT: [[T1:%.*]] = bitcast
-// CHECK-NEXT: store i8* [[T1]], i8** [[RET]]
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[CALL]]) nounwind
// CHECK-NEXT: store i32 1, i32* [[CLEANUP]]
// Cleanup.
@@ -746,14 +713,12 @@ static id _test29_allocator = 0;
// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
// Return.
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[RET]]
-// CHECK-NEXT: ret i8* [[T0]]
+// CHECK-NEXT: ret i8* [[RET]]
return [self initWithAllocator: _test29_allocator];
}
- (id) initWithAllocator: (id) allocator {
// CHECK: define internal i8* @"\01-[Test29 initWithAllocator:]"(
-// CHECK: [[RET:%.*]] = alloca i8*, align 8
-// CHECK-NEXT: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
+// CHECK: [[SELF:%.*]] = alloca [[TEST29]]*, align 8
// CHECK-NEXT: [[CMD:%.*]] = alloca i8*, align 8
// CHECK-NEXT: [[ALLOCATOR:%.*]] = alloca i8*, align 8
// CHECK-NEXT: alloca
@@ -793,10 +758,7 @@ static id _test29_allocator = 0;
// Return statement.
// CHECK-NEXT: [[T0:%.*]] = load [[TEST29]]** [[SELF]]
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST29]]* [[T0]] to i8*
-// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) nounwind
-// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]]
-// CHECK-NEXT: [[T2:%.*]] = bitcast
-// CHECK-NEXT: store i8* [[T2]], i8** [[RET]]
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]]) nounwind
// CHECK-NEXT: store i32 1, i32* [[CLEANUP]]
// Cleanup.
@@ -808,8 +770,7 @@ static id _test29_allocator = 0;
// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind, !clang.imprecise_release
// Return.
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[RET]]
-// CHECK-NEXT: ret i8* [[T0]]
+// CHECK-NEXT: ret i8* [[RET]]
self = [super initWithAllocator: allocator];
return self;
}
@@ -825,8 +786,7 @@ char *helper;
}
- (id) init {
// CHECK: define internal i8* @"\01-[Test30 init]"([[TEST30:%.*]]* {{%.*}},
-// CHECK: [[RET:%.*]] = alloca i8*
-// CHECK-NEXT: [[SELF:%.*]] = alloca [[TEST30]]*
+// CHECK: [[RET:%.*]] = alloca [[TEST30]]*
// CHECK-NEXT: alloca i8*
// CHECK-NEXT: alloca i32
// CHECK-NEXT: store [[TEST30]]* {{%.*}}, [[TEST30]]** [[SELF]]
@@ -853,10 +813,7 @@ char *helper;
// Return.
// CHECK-NEXT: [[T0:%.*]] = load [[TEST30]]** [[SELF]]
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST30]]* [[T0]] to i8*
-// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]])
-// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]]
-// CHECK-NEXT: [[T2:%.*]] = bitcast
-// CHECK-NEXT: store i8* [[T2]], i8** [[RET]]
+// CHECK-NEXT: [[RET:%.*]] = call i8* @objc_retain(i8* [[T1]])
// CHECK-NEXT: store i32 1
// Cleanup.
@@ -865,8 +822,7 @@ char *helper;
// CHECK-NEXT: call void @objc_release(i8* [[T1]])
// Epilogue.
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[RET]]
-// CHECK-NEXT: ret i8* [[T0]]
+// CHECK-NEXT: ret i8* [[RET]]
self->helper = [self initHelper];
return self;
}
@@ -882,27 +838,6 @@ char *helper;
@end
-void test31(id x) {
-// CHECK: define void @test31(
-// CHECK: [[X:%.*]] = alloca i8*,
-// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
-// CHECK-NEXT: [[PARM:%.*]] = call i8* @objc_retain(i8* {{%.*}})
-// CHECK-NEXT: store i8* [[PARM]], i8** [[X]]
-// CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]],
-// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
-// CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]],
-// CHECK-NEXT: bitcast
-// CHECK-NEXT: call void @test31_helper(
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]]
-// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
-// CHECK-NEXT: [[T0:%.*]] = load i8** [[X]]
-// CHECK-NEXT: call void @objc_release(i8* [[T0]]) nounwind, !clang.imprecise_release
-// CHECK-NEXT: ret void
- extern void test31_helper(id (^)(void));
- test31_helper(^{ return x; });
-}
-
__attribute__((ns_returns_retained)) id test32(void) {
// CHECK: define i8* @test32()
// CHECK: [[CALL:%.*]] = call i8* @test32_helper()
@@ -1060,45 +995,6 @@ void test34(int cond) {
// CHECK: ret void
}
-void test35(void (^sink)(id*)) {
- __strong id strong;
- sink(&strong);
-
- // CHECK: define void @test35(
- // CHECK: [[SINK:%.*]] = alloca void (i8**)*
- // CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
- // CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
- // CHECK-NEXT: bitcast void (i8**)* {{%.*}} to i8*
- // CHECK-NEXT: call i8* @objc_retain(
- // CHECK-NEXT: bitcast i8*
- // CHECK-NEXT: store void (i8**)* {{%.*}}, void (i8**)** [[SINK]]
- // CHECK-NEXT: store i8* null, i8** [[STRONG]]
-
- // CHECK-NEXT: load void (i8**)** [[SINK]]
- // CHECK-NEXT: bitcast
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: [[BLOCK:%.*]] = bitcast
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
- // CHECK-NEXT: store i8* [[T0]], i8** [[TEMP1]]
- // CHECK-NEXT: [[F0:%.*]] = load i8**
- // CHECK-NEXT: [[F1:%.*]] = bitcast i8* [[F0]] to void (i8*, i8**)*
- // CHECK-NEXT: call void [[F1]](i8* [[BLOCK]], i8** [[TEMP1]])
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[TEMP1]]
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retain(i8* [[T0]])
- // CHECK-NEXT: [[T2:%.*]] = load i8** [[STRONG]]
- // CHECK-NEXT: store i8* [[T1]], i8** [[STRONG]]
- // CHECK-NEXT: call void @objc_release(i8* [[T2]])
-
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[STRONG]]
- // CHECK-NEXT: call void @objc_release(i8* [[T0]])
-
- // CHECK-NEXT: load void (i8**)** [[SINK]]
- // CHECK-NEXT: bitcast
- // CHECK-NEXT: call void @objc_release
- // CHECK-NEXT: ret void
-
-}
-
// CHECK: define void @test36
void test36(id x) {
// CHECK: [[X:%.*]] = alloca i8*
@@ -1152,205 +1048,6 @@ void test37(void) {
// CHECK-NEXT: ret void
}
-void test38(void) {
- id test38_source(void);
- void test38_helper(void (^)(void));
- __block id var = test38_source();
- test38_helper(^{ var = 0; });
-
- // CHECK: define void @test38()
- // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
- // 0x02000000 - has copy/dispose helpers
- // CHECK-NEXT: store i32 33554432, i32* [[T0]]
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
- // CHECK-NEXT: [[T0:%.*]] = call i8* @test38_source()
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
- // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]]
- // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
- // 0x42000000 - has signature, copy/dispose helpers
- // CHECK: store i32 1107296256,
- // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
- // CHECK-NEXT: store i8* [[T0]], i8**
- // CHECK: call void @test38_helper(
- // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
- // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]]
- // CHECK-NEXT: call void @objc_release(i8* [[T0]])
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__Block_byref_object_copy_
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: load i8**
- // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
- // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: [[T2:%.*]] = load i8** [[T1]]
- // CHECK-NEXT: store i8* [[T2]], i8** [[T0]]
- // CHECK-NEXT: store i8* null, i8** [[T1]]
-
- // CHECK: define internal void @__Block_byref_object_dispose_
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]]
- // CHECK-NEXT: call void @objc_release(i8* [[T1]])
-
- // CHECK: define internal void @__test38_block_invoke_
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8
- // CHECK-NEXT: store i8* null, i8** [[SLOT]],
- // CHECK-NEXT: call void @objc_release(i8* [[T0]])
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__copy_helper_block_
- // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
-
- // CHECK: define internal void @__destroy_helper_block_
- // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
-}
-
-void test39(void) {
- extern id test39_source(void);
- void test39_helper(void (^)(void));
- __unsafe_unretained id var = test39_source();
- test39_helper(^{ (void) var; });
-
- // CHECK: define void @test39()
- // CHECK: [[VAR:%.*]] = alloca i8*
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
- // CHECK: [[T0:%.*]] = call i8* @test39_source()
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
- // CHECK-NEXT: store i8* [[T1]], i8** [[VAR]],
- // CHECK-NEXT: call void @objc_release(i8* [[T1]])
- // 0x40000000 - has signature but no copy/dispose
- // CHECK: store i32 1073741824, i32*
- // CHECK: [[CAPTURE:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
- // CHECK-NEXT: [[T0:%.*]] = load i8** [[VAR]]
- // CHECK-NEXT: store i8* [[T0]], i8** [[CAPTURE]]
- // CHECK-NEXT: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to
- // CHECK: call void @test39_helper
- // CHECK-NEXT: ret void
-}
-
-void test40(void) {
- id test40_source(void);
- void test40_helper(void (^)(void));
- __block __weak id var = test40_source();
- test40_helper(^{ var = 0; });
-
- // CHECK: define void @test40()
- // CHECK: [[VAR:%.*]] = alloca [[BYREF_T:%.*]],
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 2
- // 0x02000000 - has copy/dispose helpers
- // CHECK-NEXT: store i32 33554432, i32* [[T0]]
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
- // CHECK-NEXT: [[T0:%.*]] = call i8* @test40_source()
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
- // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T1]])
- // CHECK-NEXT: call void @objc_release(i8* [[T1]])
- // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[VAR]], i32 0, i32 6
- // 0x42000000 - has signature, copy/dispose helpers
- // CHECK: store i32 1107296256,
- // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
- // CHECK-NEXT: store i8* [[T0]], i8**
- // CHECK: call void @test40_helper(
- // CHECK: [[T0:%.*]] = bitcast [[BYREF_T]]* [[VAR]] to i8*
- // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
- // CHECK-NEXT: call void @objc_destroyWeak(i8** [[SLOT]])
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__Block_byref_object_copy_
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: load i8**
- // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]*
- // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]])
-
- // CHECK: define internal void @__Block_byref_object_dispose_
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6
- // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]])
-
- // CHECK: define internal void @__test40_block_invoke_
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6
- // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null)
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__copy_helper_block_
- // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
- // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8)
-
- // CHECK: define internal void @__destroy_helper_block_
- // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control)
- // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8)
-}
-
-void test41(void) {
- id test41_source(void);
- void test41_helper(void (^)(void));
- void test41_consume(id);
- __weak id var = test41_source();
- test41_helper(^{ test41_consume(var); });
-
- // CHECK: define void @test41()
- // CHECK: [[VAR:%.*]] = alloca i8*,
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
- // CHECK: [[T0:%.*]] = call i8* @test41_source()
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
- // CHECK-NEXT: call i8* @objc_initWeak(i8** [[VAR]], i8* [[T1]])
- // CHECK-NEXT: call void @objc_release(i8* [[T1]])
- // 0x42000000 - has signature, copy/dispose helpers
- // CHECK: store i32 1107296256,
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
- // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[VAR]])
- // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T0]])
- // CHECK: call void @test41_helper(
- // CHECK-NEXT: call void @objc_destroyWeak(i8** [[SLOT]])
- // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]])
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__test41_block_invoke_
- // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5
- // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]])
- // CHECK-NEXT: call void @test41_consume(i8* [[T0]])
- // CHECK-NEXT: ret void
-
- // CHECK: define internal void @__copy_helper_block_
- // CHECK: getelementptr
- // CHECK-NEXT: getelementptr
- // CHECK-NEXT: call void @objc_copyWeak(
-
- // CHECK: define internal void @__destroy_helper_block_
- // CHECK: getelementptr
- // CHECK-NEXT: call void @objc_destroyWeak(
-}
-
-@interface Test42 @end
-@implementation Test42
-- (void) test {
-// CHECK: define internal void @"\01-[Test42 test]"
-// CHECK: [[SELF:%.*]] = alloca [[TEST42:%.*]]*,
-// CHECK-NEXT: alloca i8*
-// CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
-// CHECK: store
-// CHECK-NEXT: store
-// CHECK: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5
-// CHECK-NEXT: [[T1:%.*]] = load [[TEST42]]** [[SELF]],
-// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST42]]* [[T1]] to i8*
-// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]])
-// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[TEST42]]*
-// CHECK-NEXT: store [[TEST42]]* [[T4]], [[TEST42]]** [[T0]]
-// CHECK-NEXT: bitcast [[BLOCK_T]]* [[BLOCK]] to
-// CHECK: call void @test42_helper(
-// CHECK-NEXT: [[T1:%.*]] = load [[TEST42]]** [[T0]]
-// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST42]]* [[T1]] to i8*
-// CHECK-NEXT: call void @objc_release(i8* [[T2]])
-// CHECK-NEXT: ret void
-
- extern void test42_helper(void (^)(void));
- test42_helper(^{ (void) self; });
-}
-@end
-
@interface Test43 @end
@implementation Test43
- (id) test __attribute__((ns_returns_retained)) {
@@ -1362,26 +1059,6 @@ void test41(void) {
}
@end
-id test44(void) {
- typedef id __attribute__((ns_returns_retained)) blocktype(void);
- extern test44_consume_block(blocktype^);
- return ^blocktype {
- extern id test44_produce(void);
- return test44_produce();
- }();
-
-// CHECK: define i8* @test44(
-// CHECK: load i8** getelementptr
-// CHECK-NEXT: bitcast i8*
-// CHECK-NEXT: call i8*
-// CHECK-NEXT: call i8* @objc_autoreleaseReturnValue
-// CHECK-NEXT: ret i8*
-
-// CHECK: call i8* @test44_produce()
-// CHECK-NEXT: call i8* @objc_retain
-// CHECK-NEXT: ret i8*
-}
-
@interface Test45
@property (retain) id x;
@end
@@ -1685,76 +1362,6 @@ void test59(void) {
// CHECK-NEXT: ret void
}
-// rdar://problem/9814099
-// Test that we correctly initialize __block variables
-// when the initialization captures the variable.
-void test60a(void) {
- __block void (^block)(void) = ^{ block(); };
- // CHECK: define void @test60a()
- // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
-
- // Zero-initialization before running the initializer.
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
- // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
-
- // Run the initializer as an assignment.
- // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
- // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
- // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
- // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
- // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
- // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
- // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
- // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
- // CHECK-NEXT: call void @objc_release(i8* [[T7]])
-
- // Destroy at end of function.
- // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
- // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
- // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
- // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
- // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
- // CHECK-NEXT: call void @objc_release(i8* [[T2]])
- // CHECK-NEXT: ret void
-}
-
-// Test that we correctly assign to __block variables when the
-// assignment captures the variable.
-void test60b(void) {
- __block void (^block)(void);
- block = ^{ block(); };
-
- // CHECK: define void @test60b()
- // CHECK: [[BYREF:%.*]] = alloca [[BYREF_T:%.*]],
-
- // Zero-initialize.
- // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
- // CHECK-NEXT: store void ()* null, void ()** [[T0]], align 8
-
- // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 6
-
- // The assignment.
- // CHECK: [[T0:%.*]] = bitcast void ()* {{%.*}} to i8*
- // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainBlock(i8* [[T0]])
- // CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to void ()*
- // CHECK-NEXT: [[T3:%.*]] = getelementptr inbounds [[BYREF_T]]* [[BYREF]], i32 0, i32 1
- // CHECK-NEXT: [[T4:%.*]] = load [[BYREF_T]]** [[T3]]
- // CHECK-NEXT: [[T5:%.*]] = getelementptr inbounds [[BYREF_T]]* [[T4]], i32 0, i32 6
- // CHECK-NEXT: [[T6:%.*]] = load void ()** [[T5]], align 8
- // CHECK-NEXT: store void ()* {{%.*}}, void ()** [[T5]], align 8
- // CHECK-NEXT: [[T7:%.*]] = bitcast void ()* [[T6]] to i8*
- // CHECK-NEXT: call void @objc_release(i8* [[T7]])
-
- // Destroy at end of function.
- // CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF_T]]* [[BYREF]] to i8*
- // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8)
- // CHECK-NEXT: [[T1:%.*]] = load void ()** [[SLOT]]
- // CHECK-NEXT: [[T2:%.*]] = bitcast void ()* [[T1]] to i8*
- // CHECK-NEXT: call void @objc_release(i8* [[T2]])
- // CHECK-NEXT: ret void
-}
-
// Verify that we don't try to reclaim the result of performSelector.
// rdar://problem/9887545
@interface Test61
@@ -1855,64 +1462,6 @@ void test62(void) {
// CHECK: call i8* @objc_getProperty
// CHECK: call void @objc_setProperty
-// rdar://problem/10088932
-void test64_helper(id);
-void test64a(void) {
- int x;
- test64_helper(^{ (void) x; });
-
- // CHECK: define void @test64a()
- // CHECK: [[X:%.*]] = alloca i32, align 4
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
- // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
- // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
- // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
- // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
- // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
- // CHECK-NEXT: call void @test64_helper(i8* [[T4]])
- // CHECK-NEXT: [[T5:%.*]] = bitcast void ()* [[T3]] to i8*
- // CHECK-NEXT: call void @objc_release(i8* [[T5]])
- // CHECK-NEXT: ret void
-}
-void test64b(void) {
- int x;
- id b = ^{ (void) x; };
-
- // CHECK: define void @test64b()
- // CHECK: [[X:%.*]] = alloca i32, align 4
- // CHECK-NEXT: [[B:%.*]] = alloca i8*, align 8
- // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], align 8
- // CHECK: [[T0:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to void ()*
- // CHECK-NEXT: [[T1:%.*]] = bitcast void ()* [[T0]] to i8*
- // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainBlock(i8* [[T1]])
- // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to void ()*
- // CHECK-NEXT: [[T4:%.*]] = bitcast void ()* [[T3]] to i8*
- // CHECK-NEXT: store i8* [[T4]], i8** [[B]], align 8
- // CHECK-NEXT: [[T5:%.*]] = load i8** [[B]]
- // CHECK-NEXT: call void @objc_release(i8* [[T5]])
- // CHECK-NEXT: ret void
-}
-
-// rdar://problem/9979150
-@interface Test65
-@property (strong) void(^ablock)(void);
-@property (nonatomic, strong) void(^nblock)(void);
-@end
-@implementation Test65
-@synthesize ablock, nblock;
-// CHECK: define internal void ()* @"\01-[Test65 ablock]"(
-// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext true)
-
-// CHECK: define internal void @"\01-[Test65 setAblock:]"(
-// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext true, i1 zeroext true)
-
-// CHECK: define internal void ()* @"\01-[Test65 nblock]"(
-// CHECK: call i8* @objc_getProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i1 zeroext false)
-
-// CHECK: define internal void @"\01-[Test65 setNblock:]"(
-// CHECK: call void @objc_setProperty(i8* {{%.*}}, i8* {{%.*}}, i64 {{%.*}}, i8* {{%.*}}, i1 zeroext false, i1 zeroext true)
-@end
-
// Verify that we successfully parse and preserve this attribute in
// this position.
@interface Test66
@@ -1932,7 +1481,59 @@ void test66(void) {
// CHECK-NEXT: [[T5:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T4]])
// CHECK-NEXT: [[T6:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES
// CHECK-NEXT: [[T7:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
-// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]])
-// CHECK-NEXT: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
+// CHECK-NEXT: [[SIX:%.*]] = icmp eq i8* [[T7]], null
+// CHECK-NEXT: br i1 [[SIX]], label [[NULINIT:%.*]], label [[CALL:%.*]]
+// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*)*)(i8* [[T7]], i8* [[T6]], i8* [[T5]])
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: call void @objc_release(i8* [[T5]]) nounwind
+// CHECK-NEXT: br label [[CONT:%.*]]
+// CHECK: [[T8:%.*]] = bitcast [[TEST66]]* [[T3]] to i8*
// CHECK-NEXT: call void @objc_release(i8* [[T8]])
// CHECK-NEXT: ret void
+
+// rdar://problem/9953540
+Class test67_helper(void);
+void test67(void) {
+ Class cl = test67_helper();
+}
+// CHECK: define void @test67()
+// CHECK: [[CL:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[T0:%.*]] = call i8* @test67_helper()
+// CHECK-NEXT: store i8* [[T0]], i8** [[CL]], align 8
+// CHECK-NEXT: ret void
+
+Class test68_helper(void);
+void test68(void) {
+ __strong Class cl = test67_helper();
+}
+// CHECK: define void @test68()
+// CHECK: [[CL:%.*]] = alloca i8*, align 8
+// CHECK-NEXT: [[T0:%.*]] = call i8* @test67_helper()
+// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T0]])
+// CHECK-NEXT: store i8* [[T1]], i8** [[CL]], align 8
+// CHECK-NEXT: [[T2:%.*]] = load i8** [[CL]]
+// CHECK-NEXT: call void @objc_release(i8* [[T2]])
+// CHECK-NEXT: ret void
+
+// rdar://problem/10564852
+@interface Test69 @end
+@implementation Test69
+- (id) foo { return self; }
+@end
+// CHECK: define internal i8* @"\01-[Test69 foo]"(
+// CHECK: [[SELF:%.*]] = alloca [[TEST69:%.*]]*, align 8
+// CHECK: [[T0:%.*]] = load [[TEST69]]** [[SELF]], align 8
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST69]]* [[T0]] to i8*
+// CHECK-NEXT: ret i8* [[T1]]
+
+// rdar://problem/10907547
+void test70(id i) {
+ // CHECK: define void @test70
+ // CHECK: store i8* null, i8**
+ // CHECK: store i8* null, i8**
+ // CHECK: [[ID:%.*]] = call i8* @objc_retain(i8*
+ // CHECK: store i8* [[ID]], i8**
+ id x[3] = {
+ [2] = i
+ };
+}
diff --git a/test/CodeGenObjC/auto-property-synthesize-protocol.m b/test/CodeGenObjC/auto-property-synthesize-protocol.m
new file mode 100644
index 0000000..49a4037
--- /dev/null
+++ b/test/CodeGenObjC/auto-property-synthesize-protocol.m
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-default-synthesize-properties -emit-llvm %s -o - | FileCheck %s
+// rdar://10907410
+
+@protocol P
+@optional
+@property int auto_opt_window;
+@property int no_auto_opt_window;
+@end
+
+@interface I<P>
+@property int auto_opt_window;
+@end
+
+@implementation I
+@end
+
+@protocol P1
+@property int auto_req_window;
+@property int no_auto_req_window; // expected-note {{property declared here}}
+@end
+
+@interface I1<P1>
+@property int auto_req_window;
+@end
+
+@implementation I1 // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}}
+@end
+
+// CHECK: define internal i32 @"\01-[I auto_opt_window]"(
+// CHECK: define internal void @"\01-[I setAuto_opt_window:]"(
+// CHECK: define internal i32 @"\01-[I1 auto_req_window]"(
+// CHECK: define internal void @"\01-[I1 setAuto_req_window:]"(
+
+// CHECK-NOT: define internal i32 @"\01-[I1 no_auto_opt_window]"(
+// CHECK-NOT: define internal void @"\01-[I1 setNo_auto_opt_window:]"(
+// CHECK-NOT: define internal i32 @"\01-[I no_auto_req_window]"(
+// CHECK-NOT: define internal void @"\01-[I setNo_auto_req_window:]"(
diff --git a/test/CodeGenObjC/catch-lexical-block.m b/test/CodeGenObjC/catch-lexical-block.m
new file mode 100644
index 0000000..f4a6a22
--- /dev/null
+++ b/test/CodeGenObjC/catch-lexical-block.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -g -fobjc-exceptions -emit-llvm %s -o - | FileCheck %s
+@interface Foo @end
+void f0() {
+ @try {
+ @throw @"a";
+ } @catch(Foo *e) {
+ }
+}
+
+// We should have 4 lexical blocks here at the moment, including one
+// for the catch block.
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: lexical_block
+// CHECK: auto_variable
+// CHECK: lexical_block
diff --git a/test/CodeGenObjC/complex-double-abi.m b/test/CodeGenObjC/complex-double-abi.m
new file mode 100644
index 0000000..08246d5
--- /dev/null
+++ b/test/CodeGenObjC/complex-double-abi.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 %s -o - | FileCheck %s
+// rdar://10331109
+
+@interface CNumber
+- (double _Complex)sum;
+@end
+
+double _Complex foo(CNumber *x) {
+ return [x sum];
+}
+
+// CHECK: [[T4:%.*]] = phi double [ 0.000000e+00, [[NULLINIT:%.*]] ], [ [[R1:%.*]], [[MSGCALL:%.*]] ]
+// CHECK: [[T5:%.*]] = phi double [ 0.000000e+00, [[NULLINIT:%.*]] ], [ [[I1:%.*]], [[MSGCALL:%.*]] ]
+
+// CHECK: store double [[T4]]
+// CHECK: store double [[T5]]
diff --git a/test/CodeGenObjC/constant-strings.m b/test/CodeGenObjC/constant-strings.m
index 3989813..c308d7a 100644
--- a/test/CodeGenObjC/constant-strings.m
+++ b/test/CodeGenObjC/constant-strings.m
@@ -8,11 +8,9 @@
// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o %t %s
// RUN: FileCheck --check-prefix=CHECK-GNU < %t %s
// CHECK-GNU: NXConstantString
-// CHECK-GNU-NOT: NXConstantString
// RUN: %clang_cc1 -fgnu-runtime -fconstant-string-class NSConstantString -emit-llvm -o %t %s
// RUN: FileCheck --check-prefix=CHECK-GNU-WITH-CLASS < %t %s
// CHECK-GNU-WITH-CLASS: NSConstantString
-// CHECK-GNU-WITH-CLASS-NOT: NSConstantString
id a = @"Hello World!";
diff --git a/test/CodeGenObjC/debug-info-block-helper.m b/test/CodeGenObjC/debug-info-block-helper.m
index 644e458..83db0c9 100644
--- a/test/CodeGenObjC/debug-info-block-helper.m
+++ b/test/CodeGenObjC/debug-info-block-helper.m
@@ -1,8 +1,8 @@
// REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 -masm-verbose -S -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s
extern void foo(void(^)(void));
-// CHECK: .ascii "__destroy_helper_block_" ## DW_AT_name
+// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !43, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !45, i32 24} ; [ DW_TAG_subprogram ]
@interface NSObject {
struct objc_object *isa;
diff --git a/test/CodeGenObjC/debug-info-fwddecl.m b/test/CodeGenObjC/debug-info-fwddecl.m
new file mode 100644
index 0000000..ebdc5f2
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-fwddecl.m
@@ -0,0 +1,5 @@
+// RUN: %clang -fverbose-asm -g -S -emit-llvm %s -o - | FileCheck %s
+@class ForwardObjcClass;
+ForwardObjcClass *ptr = 0;
+
+// CHECK: metadata !{i32 {{.*}}, null, metadata !"ForwardObjcClass", metadata !{{.*}}, i32 2, i32 0, i32 0, i32 0, i32 4, null, null, i32 16} ; [ DW_TAG_structure_type ]
diff --git a/test/CodeGenObjC/debug-info-getter-name.m b/test/CodeGenObjC/debug-info-getter-name.m
index e7d3a9a..3939f35 100644
--- a/test/CodeGenObjC/debug-info-getter-name.m
+++ b/test/CodeGenObjC/debug-info-getter-name.m
@@ -1,11 +1,7 @@
// REQUIRES: x86-64-registered-target
-// RUN: %clang_cc1 -fno-dwarf2-cfi-asm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -S -g %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -g %s -o - | FileCheck %s
-//CHECK: "-[InstanceVariablesEverywhereButTheInterface someString]":
-//CHECK: .quad "-[InstanceVariablesEverywhereButTheInterface someString]"
-//CHECK: .ascii "-[InstanceVariablesEverywhereButTheInterface someString]"
-//CHECK: .asciz "-[InstanceVariablesEverywhereButTheInterface someString]"
-//CHECK: "-[InstanceVariablesEverywhereButTheInterface someString].eh":
+// CHECK: {{.*}}, metadata !"-[InstanceVariablesEverywhereButTheInterface someString]", {{.*}}} ; [ DW_TAG_subprogram ]
//rdar: //8498026
diff --git a/test/CodeGenObjC/debug-info-impl.m b/test/CodeGenObjC/debug-info-impl.m
new file mode 100644
index 0000000..8ad5903
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-impl.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -S -emit-llvm %s -o - | FileCheck %s
+// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"Circle", metadata {{.*}}, i32 11, i64 64, i64 64, i32 0, i32 512, null, metadata {{.*}}, i32 16, i32 0} ; [ DW_TAG_structure_type ]
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+
+@interface Shape : NSObject
+
+@end
+@interface Circle : Shape
+
+@end
+@implementation Circle
+
+@end
diff --git a/test/CodeGenObjC/debug-info-property.m b/test/CodeGenObjC/debug-info-property.m
index d86b7c7..dd105a5 100644
--- a/test/CodeGenObjC/debug-info-property.m
+++ b/test/CodeGenObjC/debug-info-property.m
@@ -1,6 +1,8 @@
// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
@interface I1 {
int p1;
}
diff --git a/test/CodeGenObjC/debug-info-property3.m b/test/CodeGenObjC/debug-info-property3.m
new file mode 100644
index 0000000..f96ec44
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-property3.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -S -emit-llvm -g %s -o - | FileCheck %s
+
+// CHECK: metadata !"p1", metadata !6, i32 5, metadata !"", metadata !"", i32 2316, metadata !9} ; [ DW_TAG_APPLE_property ]
+@interface I1
+@property int p1;
+@end
+
+@implementation I1
+@synthesize p1;
+@end
+
+void foo(I1 *iptr) {}
diff --git a/test/CodeGenObjC/debug-info-property4.m b/test/CodeGenObjC/debug-info-property4.m
new file mode 100644
index 0000000..6d9973c
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-property4.m
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK-NOT: AT_APPLE_property_getter
+// CHECK-NOT: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+
+@interface I1
+@property int p1;
+@end
+
+@implementation I1
+@end
+
+void foo(I1 *ptr) {}
diff --git a/test/CodeGenObjC/debug-info-property5.m b/test/CodeGenObjC/debug-info-property5.m
new file mode 100644
index 0000000..3521574
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-property5.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_property_name
+// CHECK: AT_APPLE_property_getter
+// CHECK: AT_APPLE_property_setter
+// CHECK: AT_APPLE_property_attribute
+// CHECK: AT_APPLE_property
+
+@interface BaseClass2
+{
+ int _baseInt;
+}
+- (int) myGetBaseInt;
+- (void) mySetBaseInt: (int) in_int;
+@property(getter=myGetBaseInt,setter=mySetBaseInt:) int baseInt;
+@end
+
+@implementation BaseClass2
+
+- (int) myGetBaseInt
+{
+ return _baseInt;
+}
+
+- (void) mySetBaseInt: (int) in_int
+{
+ _baseInt = 2 * in_int;
+}
+@end
+
+
+void foo(BaseClass2 *ptr) {}
diff --git a/test/CodeGenObjC/debug-info-pubtypes.m b/test/CodeGenObjC/debug-info-pubtypes.m
index 744a366..658430d 100644
--- a/test/CodeGenObjC/debug-info-pubtypes.m
+++ b/test/CodeGenObjC/debug-info-pubtypes.m
@@ -1,12 +1,7 @@
// REQUIRES: x86-64-registered-target
-// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -S %s -o %t
-// RUN: FileCheck %s < %t
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o - | FileCheck %s
-//CHECK: .long Lset6
-//CHECK-NEXT: .long
-//CHECK-NEXT: .asciz "H"
-//CHECK-NEXT: .long 0
-//CHECK-NEXT: Lpubtypes_end1:
+// CHECK: !5 = metadata !{i32 {{.*}}, metadata !6, metadata !"H", metadata !6, i32 6, i64 0, i64 8, i32 0, i32 512, null, metadata !2, i32 16, i32 0} ; [ DW_TAG_structure_type ]
@interface H
-(void) foo;
diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m
index 1f281d0..c65e77c 100644
--- a/test/CodeGenObjC/debug-info-static-var.m
+++ b/test/CodeGenObjC/debug-info-static-var.m
@@ -3,9 +3,8 @@
// Radar 8801045
// Do not emit AT_MIPS_linkage_name for static variable i
-// CHECK: DW_TAG_variable
-// CHECK-NEXT: .byte 105 ## DW_AT_name
-// CHECK-NEXT: .byte 0
+// CHECK: Lset6 = Lstring3-Lsection_str ## DW_AT_name
+// CHECK-NEXT: .long Lset6
// CHECK-NEXT: DW_AT_type
// CHECK-NEXT: DW_AT_decl_file
// CHECK-NEXT: DW_AT_decl_line
diff --git a/test/CodeGenObjC/debug-info-synthesis.m b/test/CodeGenObjC/debug-info-synthesis.m
new file mode 100644
index 0000000..7e263cf
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-synthesis.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm -g -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+# 1 "foo.m" 1
+# 1 "foo.m" 2
+# 1 "./foo.h" 1
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+@class NSDictionary;
+
+@interface Foo : NSObject {}
+@property (strong, nonatomic) NSDictionary *dict;
+@end
+# 2 "foo.m" 2
+
+
+
+
+@implementation Foo
+@synthesize dict = _dict;
+
+- (void) bork {
+}
+@end
+
+int main(int argc, char *argv[]) {
+ @autoreleasepool {
+ Foo *f = [Foo new];
+ [f bork];
+ }
+}
+
+// CHECK: !7 = metadata !{i32 {{.*}}, metadata !"./foo.h"
+// CHECK: !31 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !32, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !34, i32 8} ; [ DW_TAG_subprogram ]
diff --git a/test/CodeGenObjC/debug-property-synth.m b/test/CodeGenObjC/debug-property-synth.m
index 05852b7..954620a 100644
--- a/test/CodeGenObjC/debug-property-synth.m
+++ b/test/CodeGenObjC/debug-property-synth.m
@@ -16,4 +16,5 @@ int main() {
return 0;
}
-// CHECK: .loc 2 10 0
+// FIXME: Make this test ir files.
+// CHECK: .loc 2 6 0
diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m
index 2472869..24fb657 100644
--- a/test/CodeGenObjC/exceptions.m
+++ b/test/CodeGenObjC/exceptions.m
@@ -53,11 +53,7 @@ int f2() {
// CHECK-NEXT: [[CAUGHT:%.*]] = icmp eq i32 [[SETJMP]], 0
// CHECK-NEXT: br i1 [[CAUGHT]]
@try {
- // If the optimizers ever figure out how to make this store 6,
- // that's okay.
- // CHECK: [[T1:%.*]] = load i32* [[X]]
- // CHECK-NEXT: [[T2:%.*]] = add nsw i32 [[T1]], 1
- // CHECK-NEXT: store i32 [[T2]], i32* [[X]]
+ // CHECK: store i32 6, i32* [[X]]
x++;
// CHECK-NEXT: call void asm sideeffect "", "*m,*m"(i32* [[X]]
// CHECK-NEXT: call void @foo()
diff --git a/test/CodeGenObjC/forward-class-impl-metadata.m b/test/CodeGenObjC/forward-class-impl-metadata.m
index e9e0858..371abf2 100644
--- a/test/CodeGenObjC/forward-class-impl-metadata.m
+++ b/test/CodeGenObjC/forward-class-impl-metadata.m
@@ -39,3 +39,9 @@ int f0(A *a) {
@implementation A
@synthesize p0 = _p0;
@end
+
+@interface B
+@end
+@class B;
+@implementation B
+@end
diff --git a/test/CodeGenObjC/fp2ret.m b/test/CodeGenObjC/fp2ret.m
new file mode 100644
index 0000000..9c956ae
--- /dev/null
+++ b/test/CodeGenObjC/fp2ret.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_32 %s
+//
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-X86_64 %s
+//
+// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ARMV7 %s
+
+@interface A
+-(_Complex long double) complexLongDoubleValue;
+@end
+
+
+// CHECK-X86_32: define void @t0()
+// CHECK-X86_32: call void bitcast {{.*}} @objc_msgSend_stret to
+// CHECK-X86_32: }
+//
+// CHECK-X86_64: define void @t0()
+// CHECK-X86_64: call { x86_fp80, x86_fp80 } bitcast {{.*}} @objc_msgSend_fp2ret to
+// CHECK-X86_64: }
+//
+// CHECK-ARMV7: define void @t0()
+// CHECK-ARMV7: call i128 bitcast {{.*}} @objc_msgSend to
+// CHECK-ARMV7: }
+void t0() {
+ [(A*)0 complexLongDoubleValue];
+}
diff --git a/test/CodeGenObjC/image-info.m b/test/CodeGenObjC/image-info.m
index 22f7229..613b272 100644
--- a/test/CodeGenObjC/image-info.m
+++ b/test/CodeGenObjC/image-info.m
@@ -4,5 +4,14 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s
-// CHECK-FRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__OBJC, __image_info,regular"
-// CHECK-NONFRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip"
+// CHECK-FRAGILE: !llvm.module.flags = !{!0, !1, !2, !3}
+// CHECK-FRAGILE: !0 = metadata !{i32 1, metadata !"Objective-C Version", i32 1}
+// CHECK-FRAGILE-NEXT: !1 = metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
+// CHECK-FRAGILE-NEXT: !2 = metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__OBJC, __image_info,regular"}
+// CHECK-FRAGILE-NEXT: !3 = metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 0}
+
+// CHECK-NONFRAGILE: !llvm.module.flags = !{!0, !1, !2, !3}
+// CHECK-NONFRAGILE: !0 = metadata !{i32 1, metadata !"Objective-C Version", i32 2}
+// CHECK-NONFRAGILE-NEXT: !1 = metadata !{i32 1, metadata !"Objective-C Image Info Version", i32 0}
+// CHECK-NONFRAGILE-NEXT: !2 = metadata !{i32 1, metadata !"Objective-C Image Info Section", metadata !"__DATA, __objc_imageinfo, regular, no_dead_strip"}
+// CHECK-NONFRAGILE-NEXT: !3 = metadata !{i32 4, metadata !"Objective-C Garbage Collection", i32 0}
diff --git a/test/CodeGenObjC/ivar-base-as-invariant-load.m b/test/CodeGenObjC/ivar-base-as-invariant-load.m
new file mode 100644
index 0000000..8b660cf
--- /dev/null
+++ b/test/CodeGenObjC/ivar-base-as-invariant-load.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -x objective-c %s -o - | FileCheck %s
+// rdar://10840980
+
+@interface A {
+ struct {
+ unsigned char a : 1;
+ unsigned char b : 1;
+ unsigned char c : 1;
+ } _flags;
+}
+
+@end
+
+@implementation A
+
+- (id)init {
+ _flags.a = 1;
+ _flags.b = 1;
+ _flags.c = 1;
+
+ return self;
+}
+
+@end
+
+// CHECK: [[T1:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T2:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+// CHECK: [[T3:%.*]] = load i64* @"OBJC_IVAR_$_A._flags", !invariant.load !4
+
diff --git a/test/CodeGenObjC/ns_consume_null_check.m b/test/CodeGenObjC/ns_consume_null_check.m
new file mode 100644
index 0000000..e3b6075
--- /dev/null
+++ b/test/CodeGenObjC/ns_consume_null_check.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-dispatch-method=mixed -o - %s | FileCheck %s
+// rdar://10444476
+
+@interface NSObject
+- (id) new;
+@end
+
+@interface MyObject : NSObject
+- (char)isEqual:(id) __attribute__((ns_consumed)) object;
+@end
+
+MyObject *x;
+
+void foo()
+{
+ id obj = [NSObject new];
+ [x isEqual : obj];
+}
+
+// CHECK: [[TMP:%.*]] = alloca i8
+// CHECK: [[FIVE:%.*]] = call i8* @objc_retain
+// CHECK-NEXT: [[SIX:%.*]] = bitcast
+// CHECK-NEXT: [[SEVEN:%.*]] = icmp eq i8* [[SIX]], null
+// CHECK-NEXT: br i1 [[SEVEN]], label [[NULLINIT:%.*]], label [[CALL_LABEL:%.*]]
+// CHECK: [[FN:%.*]] = load i8** getelementptr inbounds
+// CHECK-NEXT: [[EIGHT:%.*]] = bitcast i8* [[FN]]
+// CHECK-NEXT: [[CALL:%.*]] = call signext i8 [[EIGHT]]
+// CHECK-NEXT store i8 [[CALL]], i8* [[TMP]]
+// CHECK-NEXT br label [[CONT:%.*]]
+// CHECK: call void @objc_release(i8* [[FIVE]]) nounwind
+// CHECK-NEXT: call void @llvm.memset
+// CHECK-NEXT br label [[CONT]]
diff --git a/test/CodeGenObjC/objc-align.m b/test/CodeGenObjC/objc-align.m
index f072725..f3c586e 100644
--- a/test/CodeGenObjC/objc-align.m
+++ b/test/CodeGenObjC/objc-align.m
@@ -6,7 +6,6 @@
// RUN: grep '@"\\01L_OBJC_CLASS_A" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t
// RUN: grep '@"\\01L_OBJC_CLASS_C" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t
// RUN: grep '@"\\01L_OBJC_CLASS_PROTOCOLS_C" = internal global .*, section "__OBJC,__cat_cls_meth,regular,no_dead_strip", align 4' %t
-// RUN: grep '@"\\01L_OBJC_IMAGE_INFO" = internal constant .*, section "__OBJC, __image_info,regular"' %t
// RUN: grep '@"\\01L_OBJC_METACLASS_A" = internal global .*, section "__OBJC,__meta_class,regular,no_dead_strip", align 4' %t
// RUN: grep '@"\\01L_OBJC_METACLASS_C" = internal global .*, section "__OBJC,__meta_class,regular,no_dead_strip", align 4' %t
// RUN: grep '@"\\01L_OBJC_MODULES" = internal global .*, section "__OBJC,__module_info,regular,no_dead_strip", align 4' %t
@@ -20,7 +19,6 @@
// RUNX: grep '@"OBJC_METACLASS_$_A" = global' %t &&
// RUNX: grep '@"OBJC_METACLASS_$_C" = global' %t &&
// RUNX: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_0" = internal global .*, section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t &&
-// RUNX: grep '@"\\01L_OBJC_IMAGE_INFO" = internal constant .*, section "__DATA, __objc_imageinfo, regular, no_dead_strip"' %t &&
// RUNX: grep '@"\\01L_OBJC_LABEL_CATEGORY_$" = internal global .*, section "__DATA, __objc_catlist, regular, no_dead_strip", align 8' %t &&
// RUNX: grep '@"\\01L_OBJC_LABEL_CLASS_$" = internal global .*, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8' %t &&
// RUNX: grep '@"\\01l_OBJC_$_CATEGORY_A_$_Cat" = internal global .*, section "__DATA, __objc_const", align 8' %t &&
diff --git a/test/CodeGenObjC/objc-arc-container-subscripting.m b/test/CodeGenObjC/objc-arc-container-subscripting.m
new file mode 100644
index 0000000..8924916
--- /dev/null
+++ b/test/CodeGenObjC/objc-arc-container-subscripting.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fobjc-arc -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+id func() {
+ NSMutableArray *array;
+ array[3] = 0;
+ return array[3];
+}
+
+// CHECK: [[call:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[SIX:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[call]]) nounwind
+// CHECK: [[ARRAY:%.*]] = load %0**
+// CHECK: [[ARRAY_CASTED:%.*]] = bitcast{{.*}}[[ARRAY]] to i8*
+// CHECK: call void @objc_release(i8* [[ARRAY_CASTED]])
+// CHECK: [[EIGHT:%.*]] = call i8* @objc_autoreleaseReturnValue(i8* [[SIX]]) nounwind
+// CHECK: ret i8* [[EIGHT]]
+
diff --git a/test/CodeGenObjC/objc-container-subscripting-1.m b/test/CodeGenObjC/objc-container-subscripting-1.m
new file mode 100644
index 0000000..91b7f46
--- /dev/null
+++ b/test/CodeGenObjC/objc-container-subscripting-1.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+int main() {
+ NSMutableArray *array;
+ id val;
+
+ id oldObject = array[10];
+// CHECK: [[ARR:%.*]] = load {{%.*}} [[array:%.*]], align 8
+// CHECK-NEXT: [[SEL:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK-NEXT: [[ARRC:%.*]] = bitcast {{%.*}} [[ARR]] to i8*
+// CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ARRC]], i8* [[SEL]], i32 10)
+// CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8
+
+ val = (array[10] = oldObject);
+// CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
+// CHECK-NEXT: [[FOUR:%.*]] = load i8** [[oldObject:%.*]], align 8
+// CHECK-NEXT: [[FIVE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2"
+// CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8*
+// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10)
+// CHECK-NEXT: store i8* [[FOUR]], i8** [[val:%.*]]
+
+ NSMutableDictionary *dictionary;
+ id key;
+ id newObject;
+ oldObject = dictionary[key];
+// CHECK: [[SEVEN:%.*]] = load {{%.*}} [[DICTIONARY:%.*]], align 8
+// CHECK-NEXT: [[EIGHT:%.*]] = load i8** [[KEY:%.*]], align 8
+// CHECK-NEXT: [[TEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_4"
+// CHECK-NEXT: [[ELEVEN:%.*]] = bitcast {{%.*}} [[SEVEN]] to i8*
+// CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[ELEVEN]], i8* [[TEN]], i8* [[EIGHT]])
+// CHECK-NEXT: store i8* [[CALL1]], i8** [[oldObject:%.*]], align 8
+
+
+ val = (dictionary[key] = newObject);
+// CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
+// CHECK-NEXT: [[THIRTEEN:%.*]] = load i8** [[KEY]], align 8
+// CHECK-NEXT: [[FOURTEEN:%.*]] = load i8** [[NEWOBJECT:%.*]], align 8
+// CHECK-NEXT: [[SIXTEEN:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_6"
+// CHECK-NEXT: [[SEVENTEEN:%.*]] = bitcast {{%.*}} [[TWELVE]] to i8*
+// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i8*)*)(i8* [[SEVENTEEN]], i8* [[SIXTEEN]], i8* [[FOURTEEN]], i8* [[THIRTEEN]])
+// CHECK-NEXT: store i8* [[FOURTEEN]], i8** [[val:%.*]]
+}
+
diff --git a/test/CodeGenObjC/objc-container-subscripting.m b/test/CodeGenObjC/objc-container-subscripting.m
new file mode 100644
index 0000000..fd8f8ef
--- /dev/null
+++ b/test/CodeGenObjC/objc-container-subscripting.m
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin %s -o /dev/null
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+#if __has_feature(objc_subscripting)
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+#if __has_feature(objc_subscripting)
+@interface XNSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ id unknown_array;
+ oldObject = unknown_array[1];
+
+ unknown_array[1] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject; // replace oldObject with newObject
+
+}
+
diff --git a/test/CodeGenObjC/objc-dictionary-literal.m b/test/CodeGenObjC/objc-dictionary-literal.m
new file mode 100644
index 0000000..b335582
--- /dev/null
+++ b/test/CodeGenObjC/objc-dictionary-literal.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o /dev/null
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o /dev/null
+// rdar://10614657
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@protocol NSCopying @end
+typedef unsigned long NSUInteger;
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+int main() {
+ NSDictionary *dict = @{ @"name":@666 };
+ NSDictionary *dict1 = @{ @"name":@666 };
+ NSDictionary *dict2 = @{ @"name":@666 };
+ return 0;
+}
diff --git a/test/CodeGenObjC/objc-literal-debugger-test.m b/test/CodeGenObjC/objc-literal-debugger-test.m
new file mode 100644
index 0000000..389ef22
--- /dev/null
+++ b/test/CodeGenObjC/objc-literal-debugger-test.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s | FileCheck %s
+
+int main() {
+ id l = @'a';
+ l = @'a';
+ l = @42;
+ l = @-42;
+ l = @42u;
+ l = @3.141592654f;
+ l = @__objc_yes;
+ l = @__objc_no;
+ l = @{ @"name":@666 };
+ l = @[ @"foo", @"bar" ];
+}
+
+// CHECK: declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind
diff --git a/test/CodeGenObjC/objc-literal-tests.m b/test/CodeGenObjC/objc-literal-tests.m
new file mode 100644
index 0000000..c513d49
--- /dev/null
+++ b/test/CodeGenObjC/objc-literal-tests.m
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s
+// rdar://10111397
+
+#if __has_feature(objc_bool)
+#define YES __objc_yes
+#define NO __objc_no
+#else
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+#endif
+
+#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+#endif
+typedef signed char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
+#if __has_feature(objc_array_literals)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value ;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
+#endif
+@end
+
+@interface NSDate
++ (NSDate *) date;
+@end
+
+#if __has_feature(objc_dictionary_literals)
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt;
+@end
+#endif
+
+id NSUserName();
+
+// CHECK: define i32 @main() nounwind
+int main() {
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 97
+ NSNumber *aNumber = @'a';
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *fortyTwo = @42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 -42
+ NSNumber *negativeFortyTwo = @-42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *positiveFortyTwo = @+42;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42
+ NSNumber *fortyTwoUnsigned = @42u;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42
+ NSNumber *fortyTwoLong = @42l;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42
+ NSNumber *fortyTwoLongLong = @42ll;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}float 0x400921FB60000000
+ NSNumber *piFloat = @3.141592654f;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}double 0x400921FB54411744
+ NSNumber *piDouble = @3.1415926535;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1
+ NSNumber *yesNumber = @__objc_yes;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0
+ NSNumber *noNumber = @__objc_no;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1
+ NSNumber *yesNumber1 = @YES;
+ // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0
+ NSNumber *noNumber1 = @NO;
+NSDictionary *dictionary = @{@"name" : NSUserName(),
+ @"date" : [NSDate date] };
+ return __objc_yes == __objc_no;
+}
+
+// rdar://10579122
+typedef BOOL (^foo)(void);
+extern void bar(foo a);
+
+void baz(void) {
+ bar(^(void) { return YES; });
+}
diff --git a/test/CodeGenObjC/optimized-setter.m b/test/CodeGenObjC/optimized-setter.m
new file mode 100644
index 0000000..0e1b388
--- /dev/null
+++ b/test/CodeGenObjC/optimized-setter.m
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.8.0 -o - | FileCheck %s
+// rdar://10179974
+
+@interface I
+// void objc_setProperty_nonatomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., NO, NO)
+@property (nonatomic, retain) id nonatomicProperty;
+
+// void objc_setProperty_nonatomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., NO, YES)
+@property (nonatomic, copy) id nonatomicPropertyCopy;
+
+// void objc_setProperty_atomic(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., YES, NO)
+@property (retain) id atomicProperty;
+
+// void objc_setProperty_atomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset);
+// objc_setProperty(..., YES, YES)
+@property (copy) id atomicPropertyCopy;
+@end
+
+@implementation I
+@synthesize nonatomicProperty;
+@synthesize nonatomicPropertyCopy;
+@synthesize atomicProperty;
+@synthesize atomicPropertyCopy;
+@end
+
+// CHECK: call void @objc_setProperty_nonatomic
+// CHECK: call void @objc_setProperty_nonatomic_copy
+// CHECK: call void @objc_setProperty_atomic
+// CHECK: call void @objc_setProperty_atomic_copy
+
diff --git a/test/CodeGenObjC/property.m b/test/CodeGenObjC/property.m
index 3cc9200..16881d6 100644
--- a/test/CodeGenObjC/property.m
+++ b/test/CodeGenObjC/property.m
@@ -112,3 +112,57 @@ void test4(Test4 *t) {
@implementation Test5
@synthesize x = _x;
@end
+
+// rdar://problem/10410531
+@interface Test6
+@property void (*prop)(void);
+@end
+
+void test6_func(void);
+void test6(Test6 *a) {
+ a.prop = test6_func;
+}
+
+// rdar://problem/10507455
+@interface Test7
+@property unsigned char x;
+@end
+void test7(Test7 *t) {
+ t.x &= 2;
+ t.x |= 5;
+ t.x ^= 8;
+}
+// CHECK: define void @test7([[TEST7:%.*]]*
+// CHECK: [[T:%.*]] = alloca [[TEST7]]*,
+// CHECK-NEXT: store
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = and i32 [[T3]], 2
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = or i32 [[T3]], 5
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: [[T0:%.*]] = load [[TEST7]]** [[T]], align
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call zeroext i8 bitcast
+// CHECK-NEXT: [[T3:%.*]] = zext i8 [[T2]] to i32
+// CHECK-NEXT: [[T4:%.*]] = xor i32 [[T3]], 8
+// CHECK-NEXT: [[T5:%.*]] = trunc i32 [[T4]] to i8
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES
+// CHECK-NEXT: [[T6:%.*]] = bitcast [[TEST7]]* [[T0]] to i8*
+// CHECK-NEXT: call void bitcast
+// CHECK-NEXT: ret void
diff --git a/test/CodeGenObjC/selector-ref-invariance.m b/test/CodeGenObjC/selector-ref-invariance.m
new file mode 100644
index 0000000..e356419
--- /dev/null
+++ b/test/CodeGenObjC/selector-ref-invariance.m
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fblocks -o - %s | FileCheck %s
+
+// rdar://6027699
+
+void test(id x) {
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load
+// CHECK: @objc_msgSend
+ [x foo];
+}
diff --git a/test/CodeGenObjC/variadic-sends.m b/test/CodeGenObjC/variadic-sends.m
index 7e557b0..94d7baf 100644
--- a/test/CodeGenObjC/variadic-sends.m
+++ b/test/CodeGenObjC/variadic-sends.m
@@ -20,8 +20,8 @@ void f1(A *a) {
}
void f2(A *a) {
- // CHECK-X86-32: call void (i8*, i8*, i32, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, i32, ...)*)
- // CHECK-X86-64: call void (i8*, i8*, i32, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, i32, ...)*)
+ // CHECK-X86-32: call void (i8*, i8*, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, ...)*)
+ // CHECK-X86-64: call void (i8*, i8*, i32, ...)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32, ...)*)
[a im2: 1, 2];
}
@@ -33,8 +33,8 @@ void f2(A *a) {
[super im1: 1];
}
-(void) bar {
- // CHECK-X86-32: call void (%struct._objc_super*, i8*, i32, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, i32, ...)*)
- // CHECK-X86-64: call void (%struct._objc_super*, i8*, i32, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, i32, ...)*)
+ // CHECK-X86-32: call void (%struct._objc_super*, i8*, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, ...)*)
+ // CHECK-X86-64: call void (%struct._objc_super*, i8*, i32, ...)* bitcast (i8* (%struct._objc_super*, i8*, ...)* @objc_msgSendSuper to void (%struct._objc_super*, i8*, i32, ...)*)
[super im2: 1, 2];
}
diff --git a/test/CodeGenObjCXX/Inputs/literal-support.h b/test/CodeGenObjCXX/Inputs/literal-support.h
new file mode 100644
index 0000000..5680a20
--- /dev/null
+++ b/test/CodeGenObjCXX/Inputs/literal-support.h
@@ -0,0 +1,35 @@
+#ifndef OBJC_LITERAL_SUPPORT_H
+#define OBJC_LITERAL_SUPPORT_H
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+#endif // OBJC_LITERAL_SUPPORT_H
diff --git a/test/CodeGenObjCXX/address-safety-attr.mm b/test/CodeGenObjCXX/address-safety-attr.mm
new file mode 100644
index 0000000..a54ca99
--- /dev/null
+++ b/test/CodeGenObjCXX/address-safety-attr.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s
+
+@interface MyClass
++ (int) addressSafety:(int*)a;
+@end
+
+@implementation MyClass
+
+// CHECK-NOT: +[MyClass load]{{.*}} address_safety
+// CHECK: +[MyClass load]{{.*}}
+// ASAN: +[MyClass load]{{.*}} address_safety
++(void) load { }
+
+// CHECK-NOT: +[MyClass addressSafety:]{{.*}} address_safety
+// CHECK: +[MyClass addressSafety:]{{.*}}
+// ASAN: +[MyClass addressSafety:]{{.*}} address_safety
++ (int) addressSafety:(int*)a { return *a; }
+
+@end
diff --git a/test/CodeGenObjCXX/arc-exceptions.mm b/test/CodeGenObjCXX/arc-exceptions.mm
new file mode 100644
index 0000000..b1fa8ca
--- /dev/null
+++ b/test/CodeGenObjCXX/arc-exceptions.mm
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-runtime-has-weak -o - %s | FileCheck %s
+
+@class Ety;
+
+// These first four tests are all PR11732 / rdar://problem/10667070.
+
+void test0_helper(void);
+void test0(void) {
+ @try {
+ test0_helper();
+ } @catch (Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test0v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test0_helperv()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test1_helper(void);
+void test1(void) {
+ @try {
+ test1_helper();
+ } @catch (__weak Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test1v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test1_helperv()
+// CHECK: [[T0:%.*]] = call i8* @objc_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @objc_end_catch() nounwind
+
+void test2_helper(void);
+void test2(void) {
+ try {
+ test2_helper();
+ } catch (Ety *e) {
+ }
+}
+// CHECK: define void @_Z5test2v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test2_helperv()
+// CHECK: [[T0:%.*]] = call i8* @__cxa_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retain(i8* [[T2]]) nounwind
+// CHECK-NEXT: [[T4:%.*]] = bitcast i8* [[T3]] to [[ETY]]*
+// CHECK-NEXT: store [[ETY]]* [[T4]], [[ETY]]** [[E]]
+// CHECK-NEXT: [[T0:%.*]] = load [[ETY]]** [[E]]
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[ETY]]* [[T0]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T1]]) nounwind
+// CHECK-NEXT: call void @__cxa_end_catch() nounwind
+
+void test3_helper(void);
+void test3(void) {
+ try {
+ test3_helper();
+ } catch (Ety * __weak e) {
+ }
+}
+// CHECK: define void @_Z5test3v()
+// CHECK: [[E:%.*]] = alloca [[ETY:%.*]]*, align 8
+// CHECK-NEXT: invoke void @_Z12test3_helperv()
+// CHECK: [[T0:%.*]] = call i8* @__cxa_begin_catch(
+// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[ETY]]*
+// CHECK-NEXT: [[T2:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: [[T3:%.*]] = bitcast [[ETY]]* [[T1]] to i8*
+// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) nounwind
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[ETY]]** [[E]] to i8**
+// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) nounwind
+// CHECK-NEXT: call void @__cxa_end_catch() nounwind
diff --git a/test/CodeGenObjCXX/arc.mm b/test/CodeGenObjCXX/arc.mm
index 8f3aa71..45211a2 100644
--- a/test/CodeGenObjCXX/arc.mm
+++ b/test/CodeGenObjCXX/arc.mm
@@ -178,6 +178,8 @@ id test36(id z) {
// Template instantiation side of rdar://problem/9817306
@interface Test37
++ alloc;
+- init;
- (NSArray *) array;
@end
template <class T> void test37(T *a) {
@@ -188,24 +190,65 @@ template <class T> void test37(T *a) {
extern template void test37<Test37>(Test37 *a);
template void test37<Test37>(Test37 *a);
// CHECK: define weak_odr void @_Z6test37I6Test37EvPT_(
-// CHECK-LP64: [[T0:%.*]] = call [[NSARRAY]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to [[NSARRAY]]* (i8*, i8*)*)(
-// CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[NSARRAY]]* [[T0]] to i8*
-// CHECK-LP64-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
-// CHECK-LP64-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]*
+// CHECK: [[T0:%.*]] = call [[NSARRAY]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to [[NSARRAY]]* (i8*, i8*)*)(
+// CHECK-NEXT: [[T1:%.*]] = bitcast [[NSARRAY]]* [[T0]] to i8*
+// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
+// CHECK-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]*
// Make sure it's not immediately released before starting the iteration.
-// CHECK-LP64-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
-// CHECK-LP64-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
-// CHECK-LP64-NEXT: @objc_msgSend
+// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_msgSend
// This bitcast is for the mutation check.
-// CHECK-LP64: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
-// CHECK-LP64-NEXT: @objc_enumerationMutation
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_enumerationMutation
// This bitcast is for the 'next' message send.
-// CHECK-LP64: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
-// CHECK-LP64-NEXT: @objc_msgSend
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: @objc_msgSend
// This bitcast is for the final release.
-// CHECK-LP64: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
-// CHECK-LP64-NEXT: call void @objc_release(i8* [[T0]])
+// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
+// CHECK-NEXT: call void @objc_release(i8* [[T0]])
+
+template<typename T>
+void send_release() {
+ [Test37 array];
+}
+
+// CHECK: define weak_odr void @_Z12send_releaseIiEvv(
+// CHECK: call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call i8* @objc_retainAutoreleasedReturnValue
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: bitcast
+// CHECK-NEXT: call void @objc_release
+// CHECK-NEXT: ret void
+template void send_release<int>();
+
+template<typename T>
+Test37 *instantiate_init() {
+ Test37 *result = [[Test37 alloc] init];
+ return result;
+}
+
+// CHECK: define weak_odr %2* @_Z16instantiate_initIiEP6Test37v
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i8* @objc_retain
+// CHECK: call void @objc_release
+// CHECK: call i8* @objc_autoreleaseReturnValue
+template Test37* instantiate_init<int>();
+
+// Just make sure that the AST invariants hold properly here,
+// i.e. that we don't crash.
+// The block should get bound in the full-expression outside
+// the statement-expression.
+template <class T> class Test38 {
+ void test(T x) {
+ ^{ (void) x; }, ({ x; });
+ }
+};
+// CHECK: define weak_odr void @_ZN6Test38IiE4testEi(
+template class Test38<int>;
diff --git a/test/CodeGenObjCXX/copy.mm b/test/CodeGenObjCXX/copy.mm
index a61ccd4..9382ee8 100644
--- a/test/CodeGenObjCXX/copy.mm
+++ b/test/CodeGenObjCXX/copy.mm
@@ -14,8 +14,6 @@ namespace test0 {
// CHECK-NEXT: call noalias i8* @_Znwm(
// CHECK-NEXT: bitcast
// CHECK-NEXT: bitcast
- // CHECK-NEXT: call void @llvm.memset.p0i8.i64(
- // CHECK-NEXT: bitcast
// CHECK-NEXT: bitcast
// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(
// CHECK-NEXT: ret
diff --git a/test/CodeGenObjCXX/debug-info.mm b/test/CodeGenObjCXX/debug-info.mm
new file mode 100644
index 0000000..04cf66f
--- /dev/null
+++ b/test/CodeGenObjCXX/debug-info.mm
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o /dev/null
+
+// This test passes if clang doesn't crash.
+
+template <class C> class scoped_ptr {
+public:
+ C* operator->() const { return 0; }
+};
+
+@class NSWindow;
+@class NSImage;
+@interface NSWindow {
+ NSImage *_miniIcon;
+}
+-(id)windowController;
+@end
+
+class AutomationResourceTracker {
+public:
+ NSWindow* GetResource(int handle) { return 0; }
+};
+
+# 13 "automation/automation_window_tracker.h"
+class AutomationWindowTracker : public AutomationResourceTracker { };
+
+template<typename NST> class scoped_nsobject { };
+
+@interface TabStripController{
+ scoped_nsobject<NSImage> defaultFavicon_;
+}
+@end
+
+@interface BrowserWindowController {
+ TabStripController* tabStripController_;
+}
+@end
+
+void WindowGetViewBounds(scoped_ptr<AutomationWindowTracker> window_tracker_) {
+ NSWindow* window = window_tracker_->GetResource(42);
+ BrowserWindowController* controller = [window windowController];
+}
diff --git a/test/CodeGenObjCXX/lambda-expressions.mm b/test/CodeGenObjCXX/lambda-expressions.mm
new file mode 100644
index 0000000..858cb74
--- /dev/null
+++ b/test/CodeGenObjCXX/lambda-expressions.mm
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks -fobjc-arc | FileCheck -check-prefix=ARC %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks | FileCheck -check-prefix=MRC %s
+
+typedef int (^fp)();
+fp f() { auto x = []{ return 3; }; return x; }
+
+// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [5 x i8] c"copy\00"
+// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = internal global [12 x i8] c"autorelease\00"
+// MRC: define i32 ()* @_Z1fv(
+// MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
+// MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
+// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
+// MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*)
+// MRC: ret i32 ()*
+
+// ARC: define i32 ()* @_Z1fv(
+// ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv"
+// ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*)
+// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*)
+// ARC: call i8* @objc_retainBlock
+// ARC: call i8* @objc_autoreleaseReturnValue
+
+typedef int (^fp)();
+fp global;
+void f2() { global = []{ return 3; }; }
+
+// MRC: define void @_Z2f2v() nounwind {
+// MRC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// MRC-NOT: call
+// MRC: ret void
+// ("global" contains a dangling pointer after this function runs.)
+
+// ARC: define void @_Z2f2v() nounwind {
+// ARC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*),
+// ARC: call i8* @objc_retainBlock
+// ARC: call void @objc_release
+// ARC: define internal i32 @__f2_block_invoke_0
+// ARC: call i32 @"_ZZ2f2vENK3$_1clEv
diff --git a/test/CodeGenObjCXX/literals.mm b/test/CodeGenObjCXX/literals.mm
new file mode 100644
index 0000000..b8946fa
--- /dev/null
+++ b/test/CodeGenObjCXX/literals.mm
@@ -0,0 +1,111 @@
+// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
+
+#include "literal-support.h"
+
+struct X {
+ X();
+ ~X();
+ operator id() const;
+};
+
+struct Y {
+ Y();
+ ~Y();
+ operator id() const;
+};
+
+// CHECK: define void @_Z10test_arrayv
+void test_array() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+// CHECK: define weak_odr void @_Z24test_array_instantiationIiEvv
+template<typename T>
+void test_array_instantiation() {
+ // CHECK: [[OBJECTS:%[a-zA-Z0-9.]+]] = alloca [2 x i8*]
+
+ // Initializing first element
+ // CHECK: [[ELEMENT0:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 0
+ // CHECK-NEXT: call void @_ZN1XC1Ev
+ // CHECK-NEXT: [[OBJECT0:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1XcvP11objc_objectEv
+ // CHECK: [[RET0:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT0]])
+ // CHECK: store i8* [[RET0]], i8** [[ELEMENT0]]
+
+ // Initializing the second element
+ // CHECK: [[ELEMENT1:%[a-zA-Z0-9.]+]] = getelementptr inbounds [2 x i8*]* [[OBJECTS]], i32 0, i32 1
+ // CHECK-NEXT: invoke void @_ZN1YC1Ev
+ // CHECK: [[OBJECT1:%[a-zA-Z0-9.]+]] = invoke i8* @_ZNK1YcvP11objc_objectEv
+ // CHECK: [[RET1:%[a-zA-Z0-9.]+]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[OBJECT1]])
+ // CHECK: store i8* [[RET1]], i8** [[ELEMENT1]]
+
+ // Build the array
+ // CHECK: {{invoke.*@objc_msgSend}}
+ // CHECK: call i8* @objc_retainAutoreleasedReturnValue
+ id arr = @[ X(), Y() ];
+
+ // Destroy temporaries
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NOT: ret void
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: call void @_ZN1XD1Ev
+ // CHECK-NOT: ret void
+ // CHECK: call void @objc_release
+ // CHECK-NEXT: ret void
+
+ // Check cleanups
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1YD1Ev
+ // CHECK: call void @objc_release
+ // CHECK-NOT: call void @objc_release
+ // CHECK: invoke void @_ZN1XD1Ev
+ // CHECK-NOT: call void @objc_release
+ // CHECK: unreachable
+}
+
+template void test_array_instantiation<int>();
+
diff --git a/test/CodeGenObjCXX/lvalue-reference-getter.mm b/test/CodeGenObjCXX/lvalue-reference-getter.mm
new file mode 100644
index 0000000..83d3b93
--- /dev/null
+++ b/test/CodeGenObjCXX/lvalue-reference-getter.mm
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://10153365
+
+static int gint;
+struct SetSection {
+ int & at(int __n) { return gint; }
+ const int& at(int __n) const { return gint; }
+};
+
+static SetSection gSetSection;
+
+@interface SetShow
+- (SetSection&)sections;
+@end
+
+@implementation SetShow
+- (SetSection&) sections {
+// [self sections].at(100);
+ self.sections.at(100);
+ return gSetSection;
+}
+@end
+
+// CHECK: [[SELF:%.*]] = alloca [[T6:%.*]]*, align
+// CHECK: [[T0:%.*]] = load {{.*}}* [[SELF]], align
+// CHECK: [[T1:%.*]] = load {{.*}}* @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK: [[C:%.*]] = call %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]]
diff --git a/test/CodeGenObjCXX/objc-container-subscripting-1.mm b/test/CodeGenObjCXX/objc-container-subscripting-1.mm
new file mode 100644
index 0000000..c0dd0f8
--- /dev/null
+++ b/test/CodeGenObjCXX/objc-container-subscripting-1.mm
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+@protocol NSCopying @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+struct S {
+ operator unsigned int ();
+ operator id ();
+};
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id<NSCopying>)key;
+- (void)setObject:(id)object forKeyedSubscript:(id<NSCopying>)key;
+@end
+
+int main() {
+ NSMutableArray<P> * array;
+ S s;
+ id oldObject = array[(int)s];
+
+ NSMutableDictionary<P> *dict;
+ dict[(id)s] = oldObject;
+ oldObject = dict[(id)s];
+
+}
+
+template <class T> void test2(NSMutableArray *a) {
+ a[10] = 0;
+}
+template void test2<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test2IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+
+template <class T> void test3(NSMutableArray *a) {
+ a[sizeof(T)] = 0;
+}
+
+template void test3<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test3IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
diff --git a/test/CodeGenObjCXX/objc-container-subscripting.mm b/test/CodeGenObjCXX/objc-container-subscripting.mm
new file mode 100644
index 0000000..dfe48e9
--- /dev/null
+++ b/test/CodeGenObjCXX/objc-container-subscripting.mm
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+struct S {
+ operator unsigned int ();
+ operator id ();
+};
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+int main() {
+ NSMutableArray<P> * array;
+ S s;
+ id oldObject = array[(int)s];
+
+ NSMutableDictionary<P> *dict;
+ dict[(id)s] = oldObject;
+ oldObject = dict[(id)s];
+
+}
+
+template <class T> void test2(NSMutableArray *a) {
+ a[10] = 0;
+}
+template void test2<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test2IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+
+template <class T> void test3(NSMutableArray *a) {
+ a[sizeof(T)] = 0;
+}
+
+template void test3<int>(NSMutableArray*);
+// CHECK: define weak_odr void @_Z5test3IiEvP14NSMutableArray
+// CHECK: @objc_msgSend
+// CHECK: ret void
+
+// CHECK: define void @_Z11static_dataP14NSMutableArray
+void static_data(NSMutableArray *array) {
+ // CHECK: call i32 @__cxa_guard_acquire
+ // CHECK: {{call i8*.*@objc_msgSend }}
+ // CHECK: call void @__cxa_guard_release
+ static id x = array[4];
+ // CHECK: ret void
+}
diff --git a/test/CodeGenObjCXX/property-object-reference-1.mm b/test/CodeGenObjCXX/property-object-reference-1.mm
new file mode 100644
index 0000000..79bf9e4
--- /dev/null
+++ b/test/CodeGenObjCXX/property-object-reference-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar://6137845
+
+struct TCPPObject
+{
+ TCPPObject(const TCPPObject& inObj);
+ TCPPObject();
+ ~TCPPObject();
+ int filler[64];
+};
+
+
+@interface MyDocument
+{
+@private
+ TCPPObject _cppObject;
+}
+@property (atomic, assign, readwrite) const TCPPObject& cppObject;
+@end
+
+@implementation MyDocument
+
+@synthesize cppObject = _cppObject;
+
+@end
+
+// CHECK: [[cppObjectaddr:%.*]] = alloca %struct.TCPPObject*, align 8
+// CHECK: store %struct.TCPPObject* [[cppObject:%.*]], %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[cppObjectaddr]], align 8
+// CHECK: [[FOUR:%.*]] = bitcast %struct.TCPPObject* [[THREE]] to i8*
+// CHECK: call void @objc_copyStruct(i8* [[TWO:%.*]], i8* [[FOUR]], i64 256, i1 zeroext true, i1 zeroext false)
diff --git a/test/CodeGenObjCXX/property-object-reference-2.mm b/test/CodeGenObjCXX/property-object-reference-2.mm
new file mode 100644
index 0000000..b150a3e
--- /dev/null
+++ b/test/CodeGenObjCXX/property-object-reference-2.mm
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar://6137845
+
+extern int DEFAULT();
+
+struct TCPPObject
+{
+ TCPPObject();
+ ~TCPPObject();
+ TCPPObject(const TCPPObject& inObj, int i = DEFAULT());
+ TCPPObject& operator=(const TCPPObject& inObj);
+ int filler[64];
+};
+
+
+@interface MyDocument
+{
+@private
+ TCPPObject _cppObject;
+ TCPPObject _cppObject1;
+}
+@property (assign, readwrite, atomic) const TCPPObject MyProperty;
+@property (assign, readwrite, atomic) const TCPPObject MyProperty1;
+@end
+
+@implementation MyDocument
+ @synthesize MyProperty = _cppObject;
+ @synthesize MyProperty1 = _cppObject1;
+@end
+
+// CHECK: define internal void @__copy_helper_atomic_property_(
+// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
+// CHECK: [[CALL:%.*]] = call i32 @_Z7DEFAULTv()
+// CHECK: call void @_ZN10TCPPObjectC1ERKS_i(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]], i32 [[CALL]])
+// CHECK: ret void
+
+// CHECK: define internal void @"\01-[MyDocument MyProperty]"(
+// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDPTR:%.*]] to %struct.TCPPObject*
+// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
+// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[AGGRESULT:%.*]] to i8*
+// CHECK: call void @objc_copyCppObjectAtomic(i8* [[THREE]], i8* [[TWO]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__copy_helper_atomic_property_ to i8*))
+// CHECK: ret void
+
+// CHECK: define internal void @__assign_helper_atomic_property_(
+// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
+// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
+// CHECK: [[CALL:%.*]] = call %struct.TCPPObject* @_ZN10TCPPObjectaSERKS_(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]])
+// CHECK: ret void
+
+// CHECK: define internal void @"\01-[MyDocument setMyProperty:]"(
+// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDRPTR:%.*]] to %struct.TCPPObject*
+// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
+// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[MYPROPERTY:%.*]] to i8*
+// CHECK: call void @objc_copyCppObjectAtomic(i8* [[TWO]], i8* [[THREE]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__assign_helper_atomic_property_ to i8*))
+// CHECK: ret void
diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm
index b87ce23..0bd8fb8 100644
--- a/test/CodeGenObjCXX/property-object-reference.mm
+++ b/test/CodeGenObjCXX/property-object-reference.mm
@@ -2,9 +2,14 @@
// rdar://10188258
struct Foo {int i;};
+static Foo gFoo;
+
@interface ObjCTest { }
@property (nonatomic, readonly) Foo& FooRefProperty;
+@property (nonatomic) Foo FooProperty;
+- (Foo &) FooProperty;
+- (void)setFooProperty : (Foo &) arg;
@end
@@ -13,11 +18,18 @@ struct Foo {int i;};
-(void) test {
Foo& f = self.FooRefProperty;
+ Foo& f1 = self.FooProperty;
}
+- (Foo &) FooProperty { return gFoo; }
+- (void)setFooProperty : (Foo &) arg { };
@end
// CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]]
// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
// CHECK: [[T2:%.*]] = bitcast {{%.*}} [[T0]] to i8*
// CHECK: @objc_msgSend
+// CHECK: [[R0:%.*]] = load {{%.*}} [[U0:%.*]]
+// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_
+// CHECK: [[R2:%.*]] = bitcast {{%.*}} [[R0]] to i8*
+// CHECK: @objc_msgSend
diff --git a/test/CodeGenObjCXX/property-reference.mm b/test/CodeGenObjCXX/property-reference.mm
index bc3bb47..4897f6d 100644
--- a/test/CodeGenObjCXX/property-reference.mm
+++ b/test/CodeGenObjCXX/property-reference.mm
@@ -35,7 +35,7 @@ namespace test1 {
@interface Test1 {
test1::A ivar;
}
-@property const test1::A &prop1;
+@property (nonatomic) const test1::A &prop1;
@end
@implementation Test1
@synthesize prop1 = ivar;
@@ -52,3 +52,45 @@ namespace test1 {
// CHECK: call [[A]]* @_ZN5test11AaSERKS0_(
// CHECK-NEXT: ret void
+// rdar://problem/10497174
+@interface Test2
+@property int prop;
+@end
+
+// The fact that these are all non-dependent is critical.
+template <class T> void test2(Test2 *a) {
+ int x = a.prop;
+ a.prop = x;
+ a.prop += x;
+}
+template void test2<int>(Test2*);
+// CHECK: define weak_odr void @_Z5test2IiEvP5Test2(
+// CHECK: [[X:%.*]] = alloca i32,
+// CHECK: @objc_msgSend
+// CHECK: store i32 {{%.*}}, i32* [[X]],
+// CHECK: load i32* [[X]],
+// CHECK: @objc_msgSend
+// CHECK: @objc_msgSend
+// CHECK: load i32* [[X]],
+// CHECK-NEXT: add nsw
+// CHECK: @objc_msgSend
+// CHECK-NEXT: ret void
+
+// Same as the previous test, but instantiation-dependent.
+template <class T> void test3(Test2 *a) {
+ int x = (sizeof(T), a).prop;
+ a.prop = (sizeof(T), x);
+ a.prop += (sizeof(T), x);
+}
+template void test3<int>(Test2*);
+// CHECK: define weak_odr void @_Z5test3IiEvP5Test2(
+// CHECK: [[X:%.*]] = alloca i32,
+// CHECK: @objc_msgSend
+// CHECK: store i32 {{%.*}}, i32* [[X]],
+// CHECK: load i32* [[X]],
+// CHECK: @objc_msgSend
+// CHECK: @objc_msgSend
+// CHECK: load i32* [[X]],
+// CHECK-NEXT: add nsw
+// CHECK: @objc_msgSend
+// CHECK-NEXT: ret void
diff --git a/test/CodeGenOpenCL/fpaccuracy.cl b/test/CodeGenOpenCL/fpaccuracy.cl
new file mode 100644
index 0000000..d27316a
--- /dev/null
+++ b/test/CodeGenOpenCL/fpaccuracy.cl
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float spscalardiv(float a, float b) {
+ // CHECK: @spscalardiv
+ // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD:[0-9]+]]
+ return a / b;
+}
+
+float4 spvectordiv(float4 a, float4 b) {
+ // CHECK: @spvectordiv
+ // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD]]
+ return a / b;
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+double dpscalardiv(double a, double b) {
+ // CHECK: @dpscalardiv
+ // CHECK-NOT: !fpaccuracy
+ return a / b;
+}
+
+// CHECK: ![[MD]] = metadata !{float 2.500000e+00}
diff --git a/test/CodeGenOpenCL/vector_literals_nested.cl b/test/CodeGenOpenCL/vector_literals_nested.cl
new file mode 100644
index 0000000..b9013d0
--- /dev/null
+++ b/test/CodeGenOpenCL/vector_literals_nested.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -emit-llvm -O3 -o - | FileCheck %s
+
+typedef int int2 __attribute((ext_vector_type(2)));
+typedef int int4 __attribute((ext_vector_type(4)));
+
+__constant const int4 itest1 = (int4)(1, 2, ((int2)(3, 4)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 4>
+__constant const int4 itest2 = (int4)(1, 2, ((int2)(3)));
+// CHECK: constant <4 x i32> <i32 1, i32 2, i32 3, i32 3>
+
+typedef float float2 __attribute((ext_vector_type(2)));
+typedef float float4 __attribute((ext_vector_type(4)));
+
+void ftest1(float4 *p) {
+ *p = (float4)(1.1f, 1.2f, ((float2)(1.3f, 1.4f)));
+// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF6666660000000>
+}
+
+float4 ftest2(float4 *p) {
+ *p = (float4)(1.1f, 1.2f, ((float2)(1.3f)));
+// CHECK: store <4 x float> <float 0x3FF19999A0000000, float 0x3FF3333340000000, float 0x3FF4CCCCC0000000, float 0x3FF4CCCCC0000000>
+}
+
diff --git a/test/CodeGenOpenCL/vector_logops.cl b/test/CodeGenOpenCL/vector_logops.cl
new file mode 100644
index 0000000..388f1d7
--- /dev/null
+++ b/test/CodeGenOpenCL/vector_logops.cl
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -O3 %s -emit-llvm -o - | FileCheck %s
+
+typedef int int2 __attribute((ext_vector_type(2)));
+
+int test1()
+{
+ int2 a = (int2)(1,0);
+ int2 b = (int2)(1,1);
+ return (a&&b).x + (a||b).y;
+ // CHECK: ret i32 -2
+}
+
+int test2()
+{
+ int2 a = (int2)(1,0);
+ return (!a).y;
+ // CHECK: ret i32 -1
+}
+
diff --git a/test/Coverage/targets.c b/test/Coverage/targets.c
index d2a1112..7c05122 100644
--- a/test/Coverage/targets.c
+++ b/test/Coverage/targets.c
@@ -1,6 +1,5 @@
// RUN: %clang_cc1 -g -triple armv6-apple-darwin9 -emit-llvm -o %t %s
// RUN: %clang_cc1 -g -triple armv6-unknown-unknown -emit-llvm -o %t %s
-// RUN: %clang_cc1 -g -triple bfin-unknown-unknown -emit-llvm -o %t %s
// RUN: %clang_cc1 -g -triple i686-apple-darwin9 -emit-llvm -o %t %s
// RUN: %clang_cc1 -g -triple i686-pc-linux-gnu -emit-llvm -o %t %s
// RUN: %clang_cc1 -g -triple i686-unknown-dragonfly -emit-llvm -o %t %s
@@ -17,5 +16,5 @@
// RUN: %clang_cc1 -g -triple x86_64-unknown-unknown -emit-llvm -o %t %s
// <rdar://problem/7181838> clang 1.0 fails to compile Python 2.6
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4
+// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -mmacosx-version-min=10.4
diff --git a/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep b/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd64_tree/lib/.keep
diff --git a/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/.keep
diff --git a/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd64_tree/usr/lib32/.keep
diff --git a/test/Driver/Inputs/basic_freebsd_tree/lib/.keep b/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd_tree/lib/.keep
diff --git a/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep b/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd_tree/usr/lib/.keep
diff --git a/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o b/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd_tree/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep b/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/basic_freebsd_tree/usr/lib32/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/lib/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/lib/powerpc64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/lib/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/backward/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/powerpc64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/powerpc64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/powerpc64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/multiarch_freebsd64_tree/lib/.keep
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/.keep
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib/crt1.o
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/.keep
diff --git a/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/multiarch_freebsd64_tree/usr/lib32/crt1.o
diff --git a/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as b/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
new file mode 100755
index 0000000..d901134
--- /dev/null
+++ b/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-as
@@ -0,0 +1,2 @@
+#!/bin/sh
+# This file must be executable to be picked up by GetProgramPath
diff --git a/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld b/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
new file mode 100755
index 0000000..d901134
--- /dev/null
+++ b/test/Driver/Inputs/prefixed_tools_tree/x86_64--linux-ld
@@ -0,0 +1,2 @@
+#!/bin/sh
+# This file must be executable to be picked up by GetProgramPath
diff --git a/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep b/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/suse_10.3_ppc64_tree/lib/.keep
diff --git a/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep b/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/suse_10.3_ppc64_tree/lib64/.keep
diff --git a/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o
diff --git a/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib/gcc/powerpc64-suse-linux/4.1.2/crtbegin.o
diff --git a/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/suse_10.3_ppc64_tree/usr/lib64/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
diff --git a/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
diff --git a/test/Driver/Wp-args.c b/test/Driver/Wp-args.c
index e072263..0ab85b4 100644
--- a/test/Driver/Wp-args.c
+++ b/test/Driver/Wp-args.c
@@ -1,7 +1,7 @@
// Check that we extract -MD from '-Wp,-MD,FOO', which is used by a number of
// major projects (e.g., FireFox and the Linux Kernel).
-// RUN: %clang --ccc-host-triple i386-pc-linux-gnu -### \
+// RUN: %clang --target i386-pc-linux-gnu -### \
// RUN: -Wp,-MD,FOO.d -fsyntax-only %s 2> %t
// RUN: FileCheck < %t %s
//
diff --git a/test/Driver/Xarch.c b/test/Driver/Xarch.c
index b35bf6c..2523f5a 100644
--- a/test/Driver/Xarch.c
+++ b/test/Driver/Xarch.c
@@ -1,9 +1,9 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -O2 %s -S -### 2> %t.log
// RUN: grep ' "-O2" ' %t.log | count 1
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -m64 -Xarch_i386 -O2 %s -S -### 2> %t.log
// RUN: grep ' "-O2" ' %t.log | count 0
// RUN: grep "argument unused during compilation: '-Xarch_i386 -O2'" %t.log
-// RUN: not %clang -ccc-host-triple i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2> %t.log
+// RUN: not %clang -target i386-apple-darwin9 -m32 -Xarch_i386 -o -Xarch_i386 -S %s -S -Xarch_i386 -o 2> %t.log
// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -o'" %t.log | count 2
// RUN: grep "error: invalid Xarch argument: '-Xarch_i386 -S'" %t.log
diff --git a/test/Driver/Xlinker-args.c b/test/Driver/Xlinker-args.c
index b009bff..b4e5a9b 100644
--- a/test/Driver/Xlinker-args.c
+++ b/test/Driver/Xlinker-args.c
@@ -1,7 +1,7 @@
// Check that we extract --no-demangle from '-Xlinker' and '-Wl,', since that
// was a collect2 argument.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### \
+// RUN: %clang -target i386-apple-darwin9 -### \
// RUN: -Xlinker one -Xlinker --no-demangle \
// RUN: -Wl,two,--no-demangle,three -Xlinker four %s 2> %t
// RUN: FileCheck < %t %s
diff --git a/test/Driver/altivec.cpp b/test/Driver/altivec.cpp
new file mode 100644
index 0000000..6059ad0
--- /dev/null
+++ b/test/Driver/altivec.cpp
@@ -0,0 +1,14 @@
+// Check that we error when -faltivec is specified on non-ppc platforms.
+
+// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s
+// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
+
+// RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv6-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv7-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs mips64 -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -ccc-clang-archs sparc -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: invalid argument '-faltivec' only allowed with 'ppc/ppc64'
diff --git a/test/Driver/analyze.c b/test/Driver/analyze.c
index 359b0e0..68fa218 100644
--- a/test/Driver/analyze.c
+++ b/test/Driver/analyze.c
@@ -1,7 +1,7 @@
// Verify that the analyzer gets the same flags as normal compilation
// (at least for a few key ones).
-// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 %clang -ccc-host-triple i386-apple-darwin9 -### --analyze -o /dev/null %s -msse 2> %t.log
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 %clang -target i386-apple-darwin9 -### --analyze -o /dev/null %s -msse 2> %t.log
// RUN: FileCheck --input-file=%t.log %s
// CHECK: "-analyze"
diff --git a/test/Driver/apple-kext-i386.cpp b/test/Driver/apple-kext-i386.cpp
index 8ce9f87..c11a136 100644
--- a/test/Driver/apple-kext-i386.cpp
+++ b/test/Driver/apple-kext-i386.cpp
@@ -1,29 +1,29 @@
// Check that we transparently fallback to llvm-gcc for i386 kexts, we don't
// support the ABI they use (yet).
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: %clang -target i386-apple-darwin10 \
// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK < %t %s
// CHECK: cc1plus"
// CHECK: "-fapple-kext"
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: %clang -target i386-apple-darwin10 \
// RUN: -mkernel -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-MKERNEL < %t %s
// CHECK-MKERNEL: cc1plus"
// CHECK-MKERNEL: "-mkernel"
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
-// RUN: -Wno-self-assign -Wc++0x-extensions -Wno-microsoft -Wmicrosoft -Wvla \
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -Wno-self-assign -Wc++11-extensions -Wno-microsoft -Wmicrosoft -Wvla \
// RUN: -faltivec -mthumb -mcpu=G4 -mlongcall -mno-longcall -msoft-float \
// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-UNSUPPORTED < %t %s
// CHECK-UNSUPPORTED: cc1plus"
// CHECK-UNSUPPORTED-NOT: "-Wno-self-assign"
-// CHECK-UNSUPPORTED-NOT: "-Wc++0x-extensions"
+// CHECK-UNSUPPORTED-NOT: "-Wc++11-extensions"
// CHECK-UNSUPPORTED-NOT: "-Wno-microsoft"
// CHECK-UNSUPPORTED-NOT: "-Wmicrosoft"
// CHECK-UNSUPPORTED-NOT: "-Wvla"
@@ -33,10 +33,18 @@
// CHECK-UNSUPPORTED: "-mno-longcall"
// CHECK-UNSUPPORTED: "-msoft-float"
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: %clang -target i386-apple-darwin10 \
// RUN: -Wconstant-logical-operand -save-temps \
// RUN: -fapple-kext -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-UNSUPPORTED2 < %t %s
// CHECK-UNSUPPORTED2: cc1plus"
// CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand"
+
+// Check that --serialize-diagnostics does not cause an "argument unused" error.
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-UNUSED %s
+
+// CHECK-UNUSED-NOT: argument unused
+// CHECK-UNUSED: cc1plus
diff --git a/test/Driver/apple-kext-mkernel.c b/test/Driver/apple-kext-mkernel.c
index 82a6896..f8b7b90 100644
--- a/test/Driver/apple-kext-mkernel.c
+++ b/test/Driver/apple-kext-mkernel.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 \
+// RUN: %clang -target x86_64-apple-darwin10 \
// RUN: -mkernel -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-X86 < %t %s
@@ -7,7 +7,7 @@
// CHECK-X86: "-fno-rtti"
// CHECK-X86: "-fno-common"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 \
+// RUN: %clang -target x86_64-apple-darwin10 \
// RUN: -arch armv7 -mkernel -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
@@ -16,3 +16,7 @@
// CHECK-ARM: "-fno-builtin"
// CHECK-ARM: "-fno-rtti"
// CHECK-ARM: "-fno-common"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \
+// RUN: -mkernel -fsyntax-only %s
diff --git a/test/Driver/arc.c b/test/Driver/arc.c
index a4d4ed1..f2c1127 100644
--- a/test/Driver/arc.c
+++ b/test/Driver/arc.c
@@ -1,8 +1,9 @@
-// RUN: %clang -ObjC -ccc-host-triple i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x objective-c -ccc-host-triple i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x objective-c++ -ccc-host-triple i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
-// RUN: %clang -x c -ccc-host-triple i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
-// RUN: %clang -x c++ -ccc-host-triple i386-apple-darwin9 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -ObjC -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x objective-c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -x c -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x c++ -target i386-apple-darwin10 -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s
+// RUN: %clang -x objective-c -target x86_64-apple-darwin11 -mmacosx-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix UNSUPPORTED %s
// Just to test clang is working.
# foo
@@ -12,3 +13,5 @@
// NOTOBJC-NOT: error: -fobjc-arc is not supported with fragile abi
// NOTOBJC: invalid preprocessing directive
+
+// UNSUPPORTED: error: -fobjc-arc is not supported on current deployment target
diff --git a/test/Driver/arch.c b/test/Driver/arch.c
index 69693ee..df9a3e1 100644
--- a/test/Driver/arch.c
+++ b/test/Driver/arch.c
@@ -1,3 +1,3 @@
-// RUN: %clang -ccc-host-triple armv7a-unknown-linux-gnueabi -S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -target armv7a-unknown-linux-gnueabi -S -emit-llvm %s -o - | FileCheck %s
// CHECK: target triple = "armv7-unknown-linux-gnueabi"
diff --git a/test/Driver/arclite-link.c b/test/Driver/arclite-link.c
new file mode 100644
index 0000000..9cf1efe
--- /dev/null
+++ b/test/Driver/arclite-link.c
@@ -0,0 +1,8 @@
+// RUN: touch %t.o
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s
+// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
+// RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s
+
+// CHECK-ARCLITE-OSX: libarclite_macosx.a
+// CHECK-ARCLITE-OSX: -lobjc
+// CHECK-NOARCLITE-NOT: libarclite
diff --git a/test/Driver/arm-darwin-builtin.c b/test/Driver/arm-darwin-builtin.c
index 9d4cee0..41f13f3 100644
--- a/test/Driver/arm-darwin-builtin.c
+++ b/test/Driver/arm-darwin-builtin.c
@@ -1,14 +1,14 @@
// FIXME: Disable pending PR4941.
-// RUX: clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s 2> %t &&
+// RUX: clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s 2> %t &&
// RUX: grep -- "-fno-builtin-strcat" %t &&
// RUX: grep -- "-fno-builtin-strcpy" %t &&
// FIXME: Disable pending PR4941.
-// RUX: clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t &&
+// RUX: clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t &&
// RUX: not grep -- "-fno-builtin-strcat" %t &&
// RUX: not grep -- "-fno-builtin-strcpy" %t &&
-// RUN: %clang -ccc-no-clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t
+// RUN: %clang -ccc-no-clang -target x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t
// RUN: not grep -- "-fno-builtin-strcat" %t
// RUN: not grep -- "-fno-builtin-strcpy" %t
diff --git a/test/Driver/arm-mfpmath.c b/test/Driver/arm-mfpmath.c
new file mode 100644
index 0000000..0421046
--- /dev/null
+++ b/test/Driver/arm-mfpmath.c
@@ -0,0 +1,29 @@
+// Test different values of -mfpmath.
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP %s
+// CHECK-VFP: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp2 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP2 %s
+// CHECK-VFP2: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp3 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// CHECK-VFP3: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=vfp4 %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP4 %s
+// CHECK-VFP4: "-target-feature" "-neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=neon %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEON %s
+// CHECK-NEON: "-target-feature" "+neonfp"
+
+// RUN: %clang -target arm-apple-darwin10 -mfpmath=foo %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: clang compiler does not support '-mfpmath=foo'
+
+// RUN: %clang -target arm-apple-darwin10 -mcpu=arm1136j-s -mfpmath=neon %s -### -c -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MCPU-ERROR %s
+// CHECK-MCPU-ERROR: error: invalid feature '-mfpmath=neon' for CPU 'arm1136j-s'
diff --git a/test/Driver/arm-mfpu.c b/test/Driver/arm-mfpu.c
new file mode 100644
index 0000000..f51c41e
--- /dev/null
+++ b/test/Driver/arm-mfpu.c
@@ -0,0 +1,48 @@
+// Test that different values of -mfpu pick correct ARM FPU target-feature(s).
+
+// RUN: %clang -target arm-linux-eabi %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DEFAULT %s
+// CHECK-DEFAULT-NOT: "-target-feature" "+vfp2"
+// CHECK-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-DEFAULT-NOT: "-target-feature" "+neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=fpa %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpe2 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=fpe3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// RUN: %clang -target arm-linux-eabi -mfpu=maverick %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FPA %s
+// CHECK-FPA: "-target-feature" "-vfp2"
+// CHECK-FPA: "-target-feature" "-vfp3"
+// CHECK-FPA: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp3-d16 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3-D16 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=vfpv3-d16 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3-D16 %s
+// CHECK-VFP3-D16: "-target-feature" "+vfp3"
+// CHECK-VFP3-D16: "-target-feature" "+d16"
+// CHECK-VFP3-D16: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP %s
+// CHECK-VFP: "-target-feature" "+vfp2"
+// CHECK-VFP: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=vfp3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// RUN: %clang -target arm-linux-eabi -mfpu=vfpv3 %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-VFP3 %s
+// CHECK-VFP3: "-target-feature" "+vfp3"
+// CHECK-VFP3: "-target-feature" "-neon"
+
+// RUN: %clang -target arm-linux-eabi -mfpu=neon %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NEON %s
+// CHECK-NEON: "-target-feature" "+neon"
+
+// RUN: %clang -target arm-linux-eabi -msoft-float %s -### -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-FLOAT %s
+// CHECK-SOFT-FLOAT: "-target-feature" "-neon"
diff --git a/test/Driver/asan.c b/test/Driver/asan.c
new file mode 100644
index 0000000..4c9a1b6
--- /dev/null
+++ b/test/Driver/asan.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -target i386-unknown-unknown -faddress-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// Verify that -faddress-sanitizer invokes asan instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: __asan_init
diff --git a/test/Driver/ast.c b/test/Driver/ast.c
index e9fbb06..83dfcc3 100644
--- a/test/Driver/ast.c
+++ b/test/Driver/ast.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -emit-ast %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -emit-ast %s 2> %t
// RUN: echo 'END' >> %t
// RUN: FileCheck -check-prefix EMIT-AST-PHASES -input-file %t %s
@@ -10,7 +10,7 @@
// EMIT-AST-PHASES: END
// RUN: touch %t.ast
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -c %t.ast 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -c %t.ast 2> %t
// RUN: echo 'END' >> %t
// RUN: FileCheck -check-prefix COMPILE-AST-PHASES -input-file %t %s
diff --git a/test/Driver/bindings.c b/test/Driver/bindings.c
index b825420..a7cda19 100644
--- a/test/Driver/bindings.c
+++ b/test/Driver/bindings.c
@@ -1,48 +1,48 @@
// Basic binding.
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings %s 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang %s 2> %t
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -no-integrated-cpp %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -no-integrated-cpp %s 2> %t
// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t
// RUN: grep '"gcc::Compile", inputs: \[".*\.i"\], output: ".*\.s"' %t
// RUN: grep '"gcc::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
// RUN: grep '"gcc::Link", inputs: \[".*\.o"\], output: "a.out"' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -x c-header %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -x c-header %s 2> %t
// RUN: grep '"gcc::Precompile", inputs: \[".*bindings.c"\], output: ".*bindings.c.gch' %t
// Clang control options
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -fsyntax-only %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -fsyntax-only %s 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -fsyntax-only %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang -fsyntax-only %s 2> %t
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cxx -fsyntax-only -x c++ %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cxx -fsyntax-only -x c++ %s 2> %t
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: (nothing)' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-clang-cxx -fsyntax-only -x c++ %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-clang-cxx -fsyntax-only -x c++ %s 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: (nothing)' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cpp -fsyntax-only -no-integrated-cpp %s 2> %t
+// RUN: %clang -target i386-unknown-unknown -ccc-print-bindings -ccc-no-clang-cpp -fsyntax-only -no-integrated-cpp %s 2> %t
// RUN: grep '"gcc::Preprocess", inputs: \[".*bindings.c"\], output: ".*\.i"' %t
// RUN: grep '"clang", inputs: \[".*\.i"\], output: (nothing)' %t
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs i386 %s -S -arch ppc 2> %t
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs powerpc %s -S -arch ppc 2> %t
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-bindings -ccc-clang-archs powerpc %s -S -arch ppc 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
-// RUN: %clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t
+// RUN: %clang -target powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "" %s -S 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
-// RUN: %clang -ccc-host-triple powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "i386" %s -S 2> %t
+// RUN: %clang -target powerpc-unknown-unknown -ccc-print-bindings -ccc-clang-archs "i386" %s -S 2> %t
// RUN: grep '"gcc::Compile", inputs: \[".*bindings.c"\], output: "bindings.s"' %t
// Darwin bindings
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -no-integrated-as -ccc-print-bindings %s 2> %t
+// RUN: %clang -target i386-apple-darwin9 -no-integrated-as -ccc-print-bindings %s 2> %t
// RUN: grep '"clang", inputs: \[".*bindings.c"\], output: ".*\.s"' %t
// RUN: grep '"darwin::Assemble", inputs: \[".*\.s"\], output: ".*\.o"' %t
// RUN: grep '"darwin::Link", inputs: \[".*\.o"\], output: "a.out"' %t
diff --git a/test/Driver/cc-log-diagnostics.c b/test/Driver/cc-log-diagnostics.c
index 2fdbe51..88c99f5 100644
--- a/test/Driver/cc-log-diagnostics.c
+++ b/test/Driver/cc-log-diagnostics.c
@@ -1,7 +1,7 @@
// RUN: rm -f %t.log
// RUN: env RC_DEBUG_OPTIONS=1 \
// RUN: CC_LOG_DIAGNOSTICS=1 CC_LOG_DIAGNOSTICS_FILE=%t.log \
-// RUN: %clang -Wfoobar -no-canonical-prefixes -ccc-host-triple x86_64-apple-darwin10 -fsyntax-only %s
+// RUN: %clang -Wfoobar -no-canonical-prefixes -target x86_64-apple-darwin10 -fsyntax-only %s
// RUN: FileCheck %s < %t.log
int f0() {}
@@ -17,7 +17,7 @@ int f0() {}
// CHECK: <key>level</key>
// CHECK: <string>warning</string>
// CHECK: <key>message</key>
-// CHECK: <string>unknown warning option &apos;-Wfoobar&apos;</string>
+// CHECK: <string>unknown warning option &apos;-Wfoobar&apos;; did you mean &apos;-W{{.*}}&apos;?</string>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>level</key>
diff --git a/test/Driver/ccc-host-triple-no-integrated-as.c b/test/Driver/ccc-host-triple-no-integrated-as.c
index a94dea3..1677b71 100644
--- a/test/Driver/ccc-host-triple-no-integrated-as.c
+++ b/test/Driver/ccc-host-triple-no-integrated-as.c
@@ -1,9 +1,9 @@
-// Check that -no-integrated-as works when -ccc-host-triple i386-pc-win32-macho or
-// -ccc-host-triple x86_64-pc-win32-macho is specified.
+// Check that -no-integrated-as works when -target i386-pc-win32-macho or
+// -target x86_64-pc-win32-macho is specified.
-// RUN: %clang -### -c -ccc-host-triple i386-pc-win32-macho -no-integrated-as %s 2> %t1
+// RUN: %clang -### -c -target i386-pc-win32-macho -no-integrated-as %s 2> %t1
// RUN: FileCheck -check-prefix=X86 < %t1 %s
-// RUN: %clang -### -c -ccc-host-triple x86_64-pc-win32-macho -no-integrated-as %s 2> %t2
+// RUN: %clang -### -c -target x86_64-pc-win32-macho -no-integrated-as %s 2> %t2
// RUN: FileCheck -check-prefix=X86_64 < %t2 %s
//
// X86: "-cc1"
diff --git a/test/Driver/cfi.c b/test/Driver/cfi.c
index b5c0c03..c33d190 100644
--- a/test/Driver/cfi.c
+++ b/test/Driver/cfi.c
@@ -1,7 +1,8 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -static -### %s 2>&1 | \
+// RUN: %clang -target i386-apple-darwin10 \
+// RUN: -no-integrated-as -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-DARWIN %s
-// RUN: %clang -ccc-host-triple i386-pc-linux-gnu -static -### %s 2>&1 | \
+// RUN: %clang -target i386-pc-linux-gnu -static -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-LINUX %s
// CHECK-DARWIN: -fno-dwarf2-cfi-asm
diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c
index b2b358f..0e82de4 100644
--- a/test/Driver/clang-translation.c
+++ b/test/Driver/clang-translation.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -### -S -O0 -Os %s -o %t.s -fverbose-asm -funwind-tables -fvisibility=hidden 2> %t.log
+// RUN: %clang -target i386-unknown-unknown -### -S -O0 -Os %s -o %t.s -fverbose-asm -funwind-tables -fvisibility=hidden 2> %t.log
// RUN: grep '"-triple" "i386-unknown-unknown"' %t.log
// RUN: grep '"-S"' %t.log
// RUN: grep '"-disable-free"' %t.log
@@ -9,12 +9,12 @@
// RUN: grep '"-o" .*clang-translation.*' %t.log
// RUN: grep '"-masm-verbose"' %t.log
// RUN: grep '"-fvisibility" "hidden"' %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -S %s -o %t.s 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S %s -o %t.s 2> %t.log
// RUN: grep '"-target-cpu" "yonah"' %t.log
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 -### -S %s -o %t.s 2> %t.log
+// RUN: %clang -target x86_64-apple-darwin9 -### -S %s -o %t.s 2> %t.log
// RUN: grep '"-target-cpu" "core2"' %t.log
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
// RUN: -arch armv7
// RUN: FileCheck -check-prefix=ARMV7_DEFAULT %s < %t.log
// ARMV7_DEFAULT: clang
@@ -24,7 +24,7 @@
// ARMV7_DEFAULT-NOT: "-msoft-float"
// ARMV7_DEFAULT: "-x" "c"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
// RUN: -arch armv7 -msoft-float
// RUN: FileCheck -check-prefix=ARMV7_SOFTFLOAT %s < %t.log
// ARMV7_SOFTFLOAT: clang
@@ -35,7 +35,7 @@
// ARMV7_SOFTFLOAT: "-neon"
// ARMV7_SOFTFLOAT: "-x" "c"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### -S %s 2> %t.log \
+// RUN: %clang -target x86_64-apple-darwin10 -### -S %s 2> %t.log \
// RUN: -arch armv7 -mhard-float
// RUN: FileCheck -check-prefix=ARMV7_HARDFLOAT %s < %t.log
// ARMV7_HARDFLOAT: clang
diff --git a/test/Driver/cpath.c b/test/Driver/cpath.c
index 7caa014..bd7c8d0 100644
--- a/test/Driver/cpath.c
+++ b/test/Driver/cpath.c
@@ -1,20 +1,22 @@
-// RUN: mkdir -p %T/test1 %T/test2
+// RUN: mkdir -p %T/test1 %T/test2 %T/test3
-// RUN: env CPATH=%T/test1 %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=CPATH
+// RUN: env "CPATH=%T/test1%{pathsep}%T/test2" %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=CPATH
// CPATH: -I {{.*}}/test1
+// CPATH: -I {{.*}}/test2
// CPATH: search starts here
// CPATH: test1
+// CPATH: test2
-// RUN: env OBJC_INCLUDE_PATH=%T/test1 OBJCPLUS_INCLUDE_PATH=%T/test1 CPLUS_INCLUDE_PATH=%T/test1 C_INCLUDE_PATH=%T/test2 %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=C_INCLUDE_PATH
-// C_INCLUDE_PATH: -c-isystem {{"?.*}}/test2{{"?}} -cxx-isystem {{"?.*}}/test1{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objcxx-isystem {{"?.*}}/test1{{"?}}
+// RUN: env "OBJC_INCLUDE_PATH=%T/test1%{pathsep}%T/test2" OBJCPLUS_INCLUDE_PATH=%T/test1 "CPLUS_INCLUDE_PATH=%T/test1%{pathsep}%t/test2" C_INCLUDE_PATH=%T/test3 %clang -x c -E -v %s 2>&1 | FileCheck %s -check-prefix=C_INCLUDE_PATH
+// C_INCLUDE_PATH: -c-isystem {{"?.*}}/test3{{"?}} -cxx-isystem {{"?.*}}/test1{{"?}} -cxx-isystem {{"?.*}}/test2{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objc-isystem {{"?.*}}/test2{{"?}} -objcxx-isystem {{"?.*}}/test1{{"?}}
// C_INCLUDE_PATH: search starts here
// C_INCLUDE_PATH-NOT: test1
-// C_INCLUDE_PATH: test2
+// C_INCLUDE_PATH: test3
// C_INCLUDE_PATH-NOT: test1
-// RUN: env OBJC_INCLUDE_PATH=%T/test1 OBJCPLUS_INCLUDE_PATH=%T/test2 CPLUS_INCLUDE_PATH=%T/test2 C_INCLUDE_PATH=%T/test1 %clang -x objective-c++ -E -v %s 2>&1 | FileCheck %s -check-prefix=OBJCPLUS_INCLUDE_PATH
-// OBJCPLUS_INCLUDE_PATH: -c-isystem {{"?.*}}/test1{{"?}} -cxx-isystem {{"?.*}}/test2{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objcxx-isystem {{"?.*}}/test2{{"?}}
+// RUN: env OBJC_INCLUDE_PATH=%T/test1 OBJCPLUS_INCLUDE_PATH=%T/test3 CPLUS_INCLUDE_PATH=%T/test3 C_INCLUDE_PATH=%T/test1 %clang -x objective-c++ -E -v %s 2>&1 | FileCheck %s -check-prefix=OBJCPLUS_INCLUDE_PATH
+// OBJCPLUS_INCLUDE_PATH: -c-isystem {{"?.*}}/test1{{"?}} -cxx-isystem {{"?.*}}/test3{{"?}} -objc-isystem {{"?.*}}/test1{{"?}} -objcxx-isystem {{"?.*}}/test3{{"?}}
// OBJCPLUS_INCLUDE_PATH: search starts here
// OBJCPLUS_INCLUDE_PATH-NOT: test1
-// OBJCPLUS_INCLUDE_PATH: test2
+// OBJCPLUS_INCLUDE_PATH: test3
// OBJCPLUS_INCLUDE_PATH-NOT: test1
diff --git a/test/Driver/cpp-precomp.c b/test/Driver/cpp-precomp.c
new file mode 100644
index 0000000..a384a35
--- /dev/null
+++ b/test/Driver/cpp-precomp.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -cpp-precomp -fsyntax-only %s
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -no-cpp-precomp -fsyntax-only %s
diff --git a/test/Driver/darwin-as.c b/test/Driver/darwin-as.c
index 7d4cdbf..92c7641 100644
--- a/test/Driver/darwin-as.c
+++ b/test/Driver/darwin-as.c
@@ -1,16 +1,17 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -### -x assembler -c %s -static -dynamic 2>%t
+// RUN: %clang -target i386-apple-darwin10 -### -x assembler -c %s \
+// RUN: -no-integrated-as -static -dynamic 2>%t
// RUN: FileCheck -check-prefix=STATIC_AND_DYNAMIC-32 --input-file %t %s
//
// CHECK-STATIC_AND_DYNAMIC-32: as{{(.exe)?}}" "-arch" "i386" "-force_cpusubtype_ALL" "-static" "-o"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### -x assembler -c %s -static 2>%t
+// RUN: %clang -target x86_64-apple-darwin10 -### -x assembler -c %s \
+// RUN: -no-integrated-as -static 2>%t
// RUN: FileCheck -check-prefix=STATIC-64 --input-file %t %s
//
// CHECK-STATIC-64: as{{(.exe)?}}" "-arch" "x86_64" "-force_cpusubtype_ALL" "-o"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \
-// RUN: -arch armv6 -x assembler -c %s 2>%t
+// RUN: %clang -target x86_64-apple-darwin10 -### \
+// RUN: -arch armv6 -no-integrated-as -x assembler -c %s 2>%t
// RUN: FileCheck -check-prefix=ARMV6 --input-file %t %s
//
// CHECK-ARMV6: as{{(.exe)?}}" "-arch" "armv6" "-o"
-
diff --git a/test/Driver/darwin-cc.c b/test/Driver/darwin-cc.c
index 247b02b..85cdf12 100644
--- a/test/Driver/darwin-cc.c
+++ b/test/Driver/darwin-cc.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-no-clang -ccc-host-triple i386-apple-darwin10 -m32 -### -MD -g -fast -Q -dA -mkernel -ansi -aFOO -S -o /tmp/OUTPUTNAME -g0 -gfull -O2 -Werror -pedantic -Wmost -w -std=c99 -trigraphs -v -pg -fFOO -undef -Qn --param a=b -fmudflap -coverage -save-temps -nostdinc -I ARG0 -F ARG1 -I ARG2 -P -MF ARG3 -MG -MP -remap -g3 -H -D ARG4 -U ARG5 -A ARG6 -D ARG7 -U ARG8 -A ARG9 -include ARG10 -pthread %s 2> %t.log
+// RUN: %clang -ccc-no-clang -target i386-apple-darwin10 -m32 -### -MD -g -fast -Q -dA -mkernel -ansi -aFOO -S -o /tmp/OUTPUTNAME -g0 -gfull -O2 -Werror -pedantic -Wmost -w -std=c99 -trigraphs -v -pg -fFOO -undef -Qn --param a=b -fmudflap -coverage -save-temps -nostdinc -I ARG0 -F ARG1 -I ARG2 -P -MF ARG3 -MG -MP -remap -g3 -H -D ARG4 -U ARG5 -A ARG6 -D ARG7 -U ARG8 -A ARG9 -include ARG10 -pthread %s 2> %t.log
// RUN: FileCheck %s < %t.log
// CHECK: {{ ".*cc1.*" "-E" "-nostdinc" "-v" "-I" "ARG0" "-FARG1" "-I" "ARG2" "-P" "-MD" "[^"]*/OUTPUTNAME.d" "-MF" "ARG3" "-MG" "-MP" "-MQ" "[^"]*/OUTPUTNAME" "-remap" "-dD" "-H" "-D__STATIC__" "-D_REENTRANT" "-D" "ARG4" "-U" "ARG5" "-A" "ARG6" "-D" "ARG7" "-U" "ARG8" "-A" "ARG9" "-include" "ARG10" ".*darwin-cc.c" "-D_MUDFLAP" "-include" "mf-runtime.h" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-std=c99" "-trigraphs" "-Werror" "-pedantic" "-Wmost" "-w" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-O2" "-undef" "-fpch-preprocess" "-o" ".*darwin-cc.i"}}
// CHECK: {{ ".*cc1.*" "-fpreprocessed" ".*darwin-cc.i" "-O3" "-dumpbase" ".*darwin-cc.c" "-dA" "-m32" "-mkernel" "-mtune=core2" "-mmacosx-version-min=10.6.0" "-ansi" "-aFOO" "-auxbase-strip" "[^"]*/OUTPUTNAME" "-g" "-g0" "-g" "-g3" "-O2" "-Werror" "-pedantic" "-Wmost" "-w" "-ansi" "-std=c99" "-trigraphs" "-version" "-p" "-fast" "-fno-eliminate-unused-debug-symbols" "-fFOO" "-fmudflap" "-undef" "-fno-ident" "-o" "[^"]*/OUTPUTNAME" "--param" "a=b" "-fno-builtin" "-fno-merge-constants" "-fprofile-arcs" "-ftest-coverage"}}
diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c
index 326ca47..baf28475 100644
--- a/test/Driver/darwin-debug-flags.c
+++ b/test/Driver/darwin-debug-flags.c
@@ -1,5 +1,7 @@
-// RUN: env RC_DEBUG_OPTIONS=1 %clang -ccc-host-triple i386-apple-darwin9 -g -Os %s -emit-llvm -S -o - | FileCheck %s
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -target i386-apple-darwin9 -g -Os %s -emit-llvm -S -o - | FileCheck %s
// <rdar://problem/7256886>
+// RUN: touch %t.s
+// RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
// CHECK: !0 = metadata !{
// CHECK: -g -Os
@@ -7,3 +9,5 @@
// CHECK: [ DW_TAG_compile_unit ]
int x;
+
+// S: "-dwarf-debug-flags"
diff --git a/test/Driver/darwin-dsymutil.c b/test/Driver/darwin-dsymutil.c
index afb41a9..4409866 100644
--- a/test/Driver/darwin-dsymutil.c
+++ b/test/Driver/darwin-dsymutil.c
@@ -1,6 +1,6 @@
// Check that we run dsymutil properly with multiple -arch options.
//
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-phases \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-phases \
// RUN: -arch i386 -arch x86_64 %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
//
@@ -14,7 +14,7 @@
// CHECK-MULTIARCH-ACTIONS: 7: lipo, {5, 6}, image
// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
//
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -arch i386 -arch x86_64 %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s
//
@@ -23,7 +23,7 @@
// Check output name derivation.
//
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -o foo %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
//
@@ -33,12 +33,12 @@
// Check that we only use dsymutil when needed.
//
// RUN: touch %t.o
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -o foo %t.o -g 2> %t
// RUN: grep "Dsymutil" %t | count 0
// Check that we put the .dSYM in the right place.
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -o bar/foo %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-LOCATION < %t %s
diff --git a/test/Driver/darwin-iphone-defaults.m b/test/Driver/darwin-iphone-defaults.m
index 62a9403..bba0cc0 100644
--- a/test/Driver/darwin-iphone-defaults.m
+++ b/test/Driver/darwin-iphone-defaults.m
@@ -1,8 +1,6 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -flto -S -o - %s | FileCheck %s
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -flto -S -o - %s | FileCheck %s
-// CHECK: @f0
-// CHECK-NOT: ssp
-// CHECK: ) {
+// CHECK: @f0() ssp
// CHECK: @__f0_block_invoke
// CHECK: void @f1
// CHECK-NOT: msgSend_fixup_alloc
diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c
index 33b4858..3206f65 100644
--- a/test/Driver/darwin-ld.c
+++ b/test/Driver/darwin-ld.c
@@ -1,32 +1,19 @@
// Check that ld gets arch_multiple.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -arch i386 -arch x86_64 %s -### -o foo 2> %t.log
// RUN: grep '".*ld.*" .*"-arch_multiple" "-final_output" "foo"' %t.log
// Make sure we run dsymutil on source input files.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -g %s -o BAR 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -g %s -o BAR 2> %t.log
// RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -g -filelist FOO %s -o BAR 2> %t.log
// RUN: grep '".*dsymutil" "-o" "BAR.dSYM" "BAR"' %t.log
-// Splatter test case. This is gross, but it works for now. For the
-// driver, just getting coverage of the tool code and checking the
-// output options is nearly good enough. The main thing we are
-// protecting against here is unintended changes in the driver
-// output. Intended changes should add more reasonable test cases, and
-// just update this test to match the expected behavior.
-//
-// Note that at conception, this exactly matches gcc.
-
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -force_load ARG28 -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO -l FOO 2> %t.log
-// RUN: FileCheck -check-prefix=SPLATTER %s < %t.log
-// SPLATTER: {{".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-force_load" "ARG28" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-LARG2" "-lgomp".* "-filelist" "FOO" "-lFOO" "-allow_stack_execute" ".*/libprofile_rt.*" "-T" "ARG4" "-FARG1"}}
-
// Check linker changes that came with new linkedit format.
// RUN: touch %t.o
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
// LINK_IPHONE_3_0: {{ld(.exe)?"}}
@@ -41,9 +28,9 @@
// LINK_IPHONE_3_0: -lbundle1.o
// LINK_IPHONE_3_0: -lSystem
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
// LINK_IPHONE_3_1: {{ld(.exe)?"}}
@@ -58,26 +45,26 @@
// LINK_IPHONE_3_1-NOT: -lbundle1.o
// LINK_IPHONE_3_1: -lSystem
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fpie %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -fpie %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
//
// LINK_EXPLICIT_PIE: {{ld(.exe)?"}}
// LINK_EXPLICIT_PIE: "-pie"
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -fno-pie %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_EXPLICIT_NO_PIE %s < %t.log
//
// LINK_EXPLICIT_NO_PIE: {{ld(.exe)?"}}
// LINK_EXPLICIT_NO_PIE: "-no_pie"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
// RUN: -mlinker-version=100 2> %t.log
// RUN: FileCheck -check-prefix=LINK_NEWER_DEMANGLE %s < %t.log
//
// LINK_NEWER_DEMANGLE: {{ld(.exe)?"}}
// LINK_NEWER_DEMANGLE: "-demangle"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
// RUN: -mlinker-version=100 -Wl,--no-demangle 2> %t.log
// RUN: FileCheck -check-prefix=LINK_NEWER_NODEMANGLE %s < %t.log
//
@@ -85,7 +72,7 @@
// LINK_NEWER_NODEMANGLE-NOT: "-demangle"
// LINK_NEWER_NODEMANGLE: "-lSystem"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
// RUN: -mlinker-version=95 2> %t.log
// RUN: FileCheck -check-prefix=LINK_OLDER_NODEMANGLE %s < %t.log
//
@@ -93,7 +80,7 @@
// LINK_OLDER_NODEMANGLE-NOT: "-demangle"
// LINK_OLDER_NODEMANGLE: "-lSystem"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
// RUN: -mlinker-version=117 -flto 2> %t.log
// RUN: cat %t.log
// RUN: FileCheck -check-prefix=LINK_OBJECT_LTO_PATH %s < %t.log
@@ -101,10 +88,36 @@
// LINK_OBJECT_LTO_PATH: {{ld(.exe)?"}}
// LINK_OBJECT_LTO_PATH: "-object_path_lto"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### %t.o \
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
// RUN: -force_load a -force_load b 2> %t.log
// RUN: cat %t.log
// RUN: FileCheck -check-prefix=FORCE_LOAD %s < %t.log
//
// FORCE_LOAD: {{ld(.exe)?"}}
// FORCE_LOAD: "-force_load" "a" "-force_load" "b"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -lazy_framework Framework 2> %t.log
+//
+// RUN: FileCheck -check-prefix=LINK_LAZY_FRAMEWORK %s < %t.log
+// LINK_LAZY_FRAMEWORK: {{ld(.exe)?"}}
+// LINK_LAZY_FRAMEWORK: "-lazy_framework" "Framework"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o \
+// RUN: -lazy_library Library 2> %t.log
+//
+// RUN: FileCheck -check-prefix=LINK_LAZY_LIBRARY %s < %t.log
+// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
+// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
+
+// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
+// LINK_VERSION_MIN: {{ld(.exe)?"}}
+// LINK_VERSION_MIN: "-macosx_version_min" "10.7.0"
+
+// RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log
+// LINK_NO_CRT1-NOT: crt
diff --git a/test/Driver/darwin-objc-defaults.m b/test/Driver/darwin-objc-defaults.m
index dc062ae..49fe8f9 100644
--- a/test/Driver/darwin-objc-defaults.m
+++ b/test/Driver/darwin-objc-defaults.m
@@ -2,7 +2,7 @@
// i386
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch i386 -mmacosx-version-min=10.5 2> %t
// RUN: FileCheck --check-prefix CHECK-I386_OSX10_5 < %t %s
@@ -11,7 +11,7 @@
// CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-dispatch-method
// CHECK-CHECK-I386_OSX10_5: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch i386 -mmacosx-version-min=10.6 2> %t
// RUN: FileCheck --check-prefix CHECK-I386_OSX10_6 < %t %s
@@ -20,7 +20,7 @@
// CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-dispatch-method
// CHECK-CHECK-I386_OSX10_6: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch i386 -miphoneos-version-min=3.0 2> %t
// RUN: FileCheck --check-prefix CHECK-I386_IPHONE3_0 < %t %s
@@ -31,7 +31,7 @@
// x86_64
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch x86_64 -mmacosx-version-min=10.5 2> %t
// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_5 < %t %s
@@ -40,7 +40,7 @@
// CHECK-CHECK-X86_64_OSX10_5: -fobjc-dispatch-method=non-legacy
// CHECK-CHECK-X86_64_OSX10_5: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch x86_64 -mmacosx-version-min=10.6 2> %t
// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_6 < %t %s
@@ -49,7 +49,7 @@
// CHECK-CHECK-X86_64_OSX10_6: -fobjc-dispatch-method=mixed
// CHECK-CHECK-X86_64_OSX10_6: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch x86_64 -miphoneos-version-min=3.0 2> %t
// RUN: FileCheck --check-prefix CHECK-X86_64_IPHONE3_0 < %t %s
@@ -60,7 +60,7 @@
// armv7
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch armv7 -mmacosx-version-min=10.5 2> %t
// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_5 < %t %s
@@ -69,7 +69,7 @@
// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-dispatch-method
// CHECK-CHECK-ARMV7_OSX10_5: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch armv7 -mmacosx-version-min=10.6 2> %t
// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_6 < %t %s
@@ -78,7 +78,7 @@
// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-dispatch-method
// CHECK-CHECK-ARMV7_OSX10_6: darwin-objc-defaults
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch armv7 -miphoneos-version-min=3.0 2> %t
// RUN: FileCheck --check-prefix CHECK-ARMV7_IPHONE3_0 < %t %s
diff --git a/test/Driver/darwin-objc-gc.m b/test/Driver/darwin-objc-gc.m
index aecb9a6..06e3aea 100644
--- a/test/Driver/darwin-objc-gc.m
+++ b/test/Driver/darwin-objc-gc.m
@@ -1,6 +1,6 @@
// Check that we warn, but accept, -fobjc-gc for iPhone OS.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -miphoneos-version-min=3.0 -fobjc-gc -flto -S -o %t %s 2> %t.err
+// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -fobjc-gc -flto -S -o %t %s 2> %t.err
// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_LL %s < %t
// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_STDERR %s < %t.err
diff --git a/test/Driver/darwin-objc-options.m b/test/Driver/darwin-objc-options.m
index a62a62c..5b421d8 100644
--- a/test/Driver/darwin-objc-options.m
+++ b/test/Driver/darwin-objc-options.m
@@ -1,6 +1,6 @@
// Check miscellaneous Objective-C options.
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch x86_64 -fobjc-abi-version=1 2> %t
// RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s
@@ -9,7 +9,7 @@
// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method
// CHECK-CHECK-X86_64_ABI1: darwin-objc-options
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \
+// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \
// RUN: -arch i386 -fobjc-abi-version=2 2> %t
// RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s
diff --git a/test/Driver/darwin-verify-debug.c b/test/Driver/darwin-verify-debug.c
index 1e4eff8..677419a 100644
--- a/test/Driver/darwin-verify-debug.c
+++ b/test/Driver/darwin-verify-debug.c
@@ -1,7 +1,7 @@
// Check that we verify debug output properly with multiple -arch options.
//
// REQUIRES: asserts
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-phases \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-phases \
// RUN: -verify -arch i386 -arch x86_64 %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
//
@@ -9,7 +9,7 @@
// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
// CHECK-MULTIARCH-ACTIONS: 9: verify, {8}, none
//
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -verify -arch i386 -arch x86_64 %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-MULTIARCH-BINDINGS < %t %s
//
@@ -18,7 +18,7 @@
// Check output name derivation.
//
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -verify -o foo %s -g 2> %t
// RUN: FileCheck -check-prefix=CHECK-OUTPUT-NAME < %t %s
//
@@ -29,6 +29,6 @@
// Check that we only verify when needed.
//
// RUN: touch %t.o
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
// RUN: -verify -o foo %t.o -g 2> %t
// RUN: grep "Verify" %t | count 0
diff --git a/test/Driver/darwin-version.c b/test/Driver/darwin-version.c
index d9c5c5e..2478a99 100644
--- a/test/Driver/darwin-version.c
+++ b/test/Driver/darwin-version.c
@@ -1,5 +1,5 @@
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 \
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST0 -E %s
+// RUN: %clang -target i386-apple-darwin9 -DTEST0 -E %s
#ifdef TEST0
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
#error Invalid version
@@ -7,7 +7,7 @@
#endif
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST1 -E %s
+// RUN: %clang -target i386-apple-darwin9 -DTEST1 -E %s
#ifdef TEST1
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20000
#error Invalid version
@@ -15,7 +15,7 @@
#endif
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST2 -E %s
+// RUN: %clang -target i386-apple-darwin9 -DTEST2 -E %s
#ifdef TEST2
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20301
#error Invalid version
@@ -23,7 +23,7 @@
#endif
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.4.10 \
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST3 -E %s
+// RUN: %clang -target i386-apple-darwin9 -DTEST3 -E %s
#ifdef TEST3
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1049
#error Invalid version
diff --git a/test/Driver/darwin-xarch.c b/test/Driver/darwin-xarch.c
index 4c6689c..3014236 100644
--- a/test/Driver/darwin-xarch.c
+++ b/test/Driver/darwin-xarch.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \
+// RUN: %clang -target x86_64-apple-darwin10 -### \
// RUN: -arch i386 -Xarch_i386 -mmacosx-version-min=10.4 \
// RUN: -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 \
// RUN: -c %s 2> %t
@@ -7,13 +7,13 @@
// CHECK-COMPILE: clang{{.*}}" "-cc1" "-triple" "i386-apple-macosx10.4.0"
// CHECK-COMPILE: clang{{.*}}" "-cc1" "-triple" "x86_64-apple-macosx10.5.0"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \
+// RUN: %clang -target x86_64-apple-darwin10 -### \
// RUN: -arch i386 -Xarch_i386 -Wl,-some-linker-arg -filelist X 2> %t
// RUN: FileCheck --check-prefix=CHECK-LINK < %t %s
//
// CHECK-LINK: ld{{.*}} "-arch" "i386"{{.*}} "-some-linker-arg"
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -### \
+// RUN: %clang -target x86_64-apple-darwin10 -### \
// RUN: -arch armv7 -Xarch_armv7 -Wl,-some-linker-arg -filelist X 2> %t
// RUN: FileCheck --check-prefix=CHECK-ARMV7-LINK < %t %s
//
diff --git a/test/Driver/debug-options-as.c b/test/Driver/debug-options-as.c
new file mode 100644
index 0000000..a1dbe2e
--- /dev/null
+++ b/test/Driver/debug-options-as.c
@@ -0,0 +1,18 @@
+// cygming have not supported integrated-as yet.
+// XFAIL: cygwin,mingw32
+//
+// Check to make sure clang is somewhat picky about -g options.
+// (Delived from debug-options.c)
+// rdar://10383444
+// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s
+//
+// SAVE: "-cc1as"
+// SAVE-NOT: "-g"
+
+// Check to make sure clang with -g on a .s file gets passed.
+// rdar://9275556
+// RUN: touch %t.s
+// RUN: %clang -### -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+//
+// S: "-cc1as"
+// S: "-g"
diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c
new file mode 100644
index 0000000..5dad8e9
--- /dev/null
+++ b/test/Driver/debug-options.c
@@ -0,0 +1,27 @@
+// Check to make sure clang is somewhat picky about -g options.
+// rdar://10383444
+
+// RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s
+// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G2 %s
+// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s
+// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
+// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s
+// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
+//
+// G: "-cc1"
+// G: "-g"
+//
+// G2: "-cc1"
+// G2: "-g"
+//
+// G3: "-cc1"
+// G3: "-g"
+//
+// GANY: "-cc1"
+// GANY-NOT: "-g"
+//
+// GGDB: "-cc1"
+// GGDB: "-g"
+//
+// GFOO: "-cc1"
+// GFOO-NOT: "-g"
diff --git a/test/Driver/debug.c b/test/Driver/debug.c
new file mode 100644
index 0000000..ca1ca30
--- /dev/null
+++ b/test/Driver/debug.c
@@ -0,0 +1,11 @@
+// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
+// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
+
+// RUN: env PWD=/foo %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-FOO %s
+// CHECK-FOO: {{"-fdebug-compilation-dir" ".*foo"}}
+
+// "PWD=/foo gcc" wouldn't necessarily work. You would need to pick a different
+// path to the same directory (try a symlink).
+
+// This depends on host's behavior how $PWD would be set.
+// REQUIRES: shell
diff --git a/test/Driver/default-toolchain.c b/test/Driver/default-toolchain.c
index eeff763..b9111a6 100644
--- a/test/Driver/default-toolchain.c
+++ b/test/Driver/default-toolchain.c
@@ -1,8 +1,8 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -m64 -v 2> %t
+// RUN: %clang -target i386-unknown-unknown -m64 -v 2> %t
// RUN: grep 'Target: x86_64-unknown-unknown' %t
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch ppc -m64 -v 2> %t
+// RUN: %clang -target i386-apple-darwin9 -arch ppc -m64 -v 2> %t
// RUN: grep 'Target: powerpc64-apple-darwin9' %t
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
+// RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
// RUN: grep 'Target: powerpc-apple-darwin9' %t
diff --git a/test/Driver/diagnostics.c b/test/Driver/diagnostics.c
new file mode 100644
index 0000000..8500fad
--- /dev/null
+++ b/test/Driver/diagnostics.c
@@ -0,0 +1,9 @@
+// Parse diagnostic arguments in the driver
+// PR12181
+
+// RUN: not %clang -target x86_64-apple-darwin10 \
+// RUN: -fsyntax-only -fzyzzybalubah \
+// RUN: -Werror=unused-command-line-argument %s
+
+// RUN: not %clang -target x86_64-apple-darwin10 \
+// RUN: -fsyntax-only -fzyzzybalubah -Werror %s
diff --git a/test/Driver/dragonfly.c b/test/Driver/dragonfly.c
index d768fe6..8a629da 100644
--- a/test/Driver/dragonfly.c
+++ b/test/Driver/dragonfly.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple amd64-pc-dragonfly %s -### 2> %t.log
+// RUN: %clang -no-canonical-prefixes -target amd64-pc-dragonfly %s -### 2> %t.log
// RUN: FileCheck -input-file %t.log %s
// CHECK: clang{{.*}}" "-cc1" "-triple" "amd64-pc-dragonfly"
diff --git a/test/Driver/dwarf2-cfi-asm.c b/test/Driver/dwarf2-cfi-asm.c
new file mode 100644
index 0000000..a5c4878
--- /dev/null
+++ b/test/Driver/dwarf2-cfi-asm.c
@@ -0,0 +1,35 @@
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-DEFAULT %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-CFI %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-MC-NOCFI %s
+
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-DEFAULT %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-CFI %s
+// RUN: %clang -target x86_64-apple-darwin -### -S -no-integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-DARWIN-AS-NOCFI %s
+
+
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-DEFAULT %s
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-CFI %s
+// RUN: %clang -target x86_64-pc-linux -### -S -integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-MC-NOCFI %s
+
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-DEFAULT %s
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as -fdwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-CFI %s
+// RUN: %clang -target x86_64-pc-linux -### -S -no-integrated-as -fno-dwarf2-cfi-asm %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK-LINUX-AS-NOCFI %s
+
+
+
+// CHECK-DARWIN-MC-DEFAULT-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-MC-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-MC-NOCFI: -fno-dwarf2-cfi-asm
+
+// CHECK-DARWIN-AS-DEFAULT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-AS-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-DARWIN-AS-NOCFI: -fno-dwarf2-cfi-asm
+
+
+// CHECK-LINUX-MC-DEFAULT-NOT: -fno-dwarf2-cfi-asmx
+// CHECK-LINUX-MC-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-MC-NOCFI: -fno-dwarf2-cfi-asm
+
+// CHECK-LINUX-AS-DEFAULT-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-AS-CFI-NOT: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-AS-NOCFI: -fno-dwarf2-cfi-asm
diff --git a/test/Driver/exceptions.m b/test/Driver/exceptions.m
index 7d85fe3..9b747bb 100644
--- a/test/Driver/exceptions.m
+++ b/test/Driver/exceptions.m
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 \
+// RUN: %clang -target x86_64-apple-darwin9 \
// RUN: -fsyntax-only -fno-exceptions %s
void f1() {
diff --git a/test/Driver/fast-math.c b/test/Driver/fast-math.c
new file mode 100644
index 0000000..aef7cc3
--- /dev/null
+++ b/test/Driver/fast-math.c
@@ -0,0 +1,119 @@
+// Test that the GCC fast-math floating point flags get lowered to the correct
+// permutation of Clang frontend flags. This is non-trivial for a few reasons.
+// First, the GCC flags have many different and surprising effects. Second,
+// LLVM only supports three switches which is more coarse grained than GCC's
+// support.
+//
+// RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// CHECK-NO-INFS: "-cc1"
+// CHECK-NO-INFS: "-menable-no-infs"
+//
+// RUN: %clang -### -fno-honor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// CHECK-NO-NANS: "-cc1"
+// CHECK-NO-NANS: "-menable-no-nans"
+//
+// RUN: %clang -### -fmath-errno -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s
+// CHECK-MATH-ERRNO: "-cc1"
+// CHECK-MATH-ERRNO: "-fmath-errno"
+//
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+// CHECK-UNSAFE-MATH: "-cc1"
+// CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math"
+//
+// Check that various umbrella flags also enable these frontend options.
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s
+// RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s
+//
+// One umbrella flag is *really* weird and also changes the semantics of the
+// program by adding a special preprocessor macro. Check that the frontend flag
+// modeling this semantic change is provided. Also check that the semantic
+// impact remains even if every optimization is disabled.
+// RUN: %clang -### -ffast-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only \
+// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s
+// CHECK-FAST-MATH: "-cc1"
+// CHECK-FAST-MATH: "-ffast-math"
+//
+// Check various means of disabling these flags, including disabling them after
+// they've been enabled via an umbrella flag.
+// RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s
+// CHECK-NO-NO-INFS: "-cc1"
+// CHECK-NO-NO-INFS-NOT: "-menable-no-infs"
+// CHECK-NO-NO-INFS: "-o"
+//
+// RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s
+// CHECK-NO-NO-NANS: "-cc1"
+// CHECK-NO-NO-NANS-NOT: "-menable-no-nans"
+// CHECK-NO-NO-NANS: "-o"
+//
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \
+// RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \
+// RUN: -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s
+// CHECK-NO-UNSAFE-MATH: "-cc1"
+// CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math"
+// CHECK-NO-UNSAFE-MATH: "-o"
diff --git a/test/Driver/flags.c b/test/Driver/flags.c
index 6d80892..7a885b6 100644
--- a/test/Driver/flags.c
+++ b/test/Driver/flags.c
@@ -1,9 +1,9 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float %s 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S -msoft-float %s 2> %t.log
// RUN: grep '"-no-implicit-float"' %t.log
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float -mno-soft-float %s 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S -msoft-float -mno-soft-float %s 2> %t.log
// RUN: grep '"-no-implicit-float"' %t.log | count 0
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log
// RUN: grep '"-no-implicit-float"' %t.log
diff --git a/test/Driver/frame-pointer.c b/test/Driver/frame-pointer.c
new file mode 100644
index 0000000..6be395c
--- /dev/null
+++ b/test/Driver/frame-pointer.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target i386-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s
+// RUN: %clang -target i386-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s
+
+
+// RUN: %clang -target x86_64-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
+// RUN: %clang -target x86_64-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
+
+// CHECK0-32: -mdisable-fp-elim
+// CHECK1-32-NOT: -mdisable-fp-elim
+// CHECK2-32-NOT: -mdisable-fp-elim
+// CHECK3-32-NOT: -mdisable-fp-elim
+// CHECKs-32-NOT: -mdisable-fp-elim
+
+// CHECK0-64: -mdisable-fp-elim
+// CHECK1-64-NOT: -mdisable-fp-elim
+// CHECK2-64-NOT: -mdisable-fp-elim
+// CHECK3-64-NOT: -mdisable-fp-elim
+// CHECKs-64-NOT: -mdisable-fp-elim
diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c
index 87ac6d7..1fb84a0 100644
--- a/test/Driver/freebsd.c
+++ b/test/Driver/freebsd.c
@@ -1,19 +1,30 @@
-// RUN: %clang -ccc-clang-archs "" -ccc-host-triple powerpc64-pc-freebsd8 %s -### 2> %t
-// RUN: FileCheck --check-prefix=CHECK-PPC < %t %s
+// REQUIRES: ppc32-registered-target,ppc64-registered-target
+// RUN: %clang -ccc-clang-archs powerpc -no-canonical-prefixes \
+// RUN: -target powerpc-pc-freebsd8 %s \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PPC %s
+// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc-pc-freebsd8"
+// CHECK-PPC: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
+//
+// RUN: %clang -ccc-clang-archs powerpc64 -no-canonical-prefixes \
+// RUN: -target powerpc64-pc-freebsd8 %s \
+// RUN: --sysroot=%S/Inputs/basic_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
+// CHECK-PPC64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-PPC64: "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L[[SYSROOT]]/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
//
-// CHECK-PPC: clang{{.*}}" "-cc1" "-triple" "powerpc64-pc-freebsd8"
-// CHECK-PPC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "{{.*}}ld-elf{{.*}}" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "-L/usr/lib" "{{.*}}.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "{{.*}}crtend.o" "{{.*}}crtn.o"
-
-
-// Check that -m32 properly adjusts the toolchain flags.
//
-// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-LIB32 < %t %s
+// Check that -m32 properly adjusts the toolchain flags.
//
+// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LIB32 %s
// CHECK-LIB32: clang{{.*}}" "-cc1" "-triple" "i386-pc-freebsd8"
// CHECK-LIB32: ld{{.*}}" {{.*}} "-m" "elf_i386_fbsd"
//
-// RUN: %clang -ccc-host-triple x86_64-pc-freebsd8 -m32 -print-search-dirs %s > %t
-// RUN: FileCheck --check-prefix=CHECK-LIB32PATHS < %t %s
-//
+// RUN: %clang -target x86_64-pc-freebsd8 -m32 %s 2>&1 \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s
// CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32
diff --git a/test/Driver/gcc-toolchain.cpp b/test/Driver/gcc-toolchain.cpp
new file mode 100644
index 0000000..e122dac
--- /dev/null
+++ b/test/Driver/gcc-toolchain.cpp
@@ -0,0 +1,23 @@
+// Test that gcc-toolchain option is working correctly
+//
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: -gcc-toolchain %S/Inputs/ubuntu_11.04_multiarch_tree/usr \
+// RUN: | FileCheck %s
+//
+// Test for header search toolchain detection.
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN:[^"]+]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK: "-internal-isystem"
+// CHECK: "[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
+// CHECK: "-internal-isystem" "/usr/local/include"
+//
+// Test for linker toolchain detection. Note that only the '-L' flags will use
+// the same precise formatting of the path as the '-internal-system' flags
+// above, so we just blanket wildcard match the 'crtbegin.o'.
+// CHECK: "{{[^"]*}}ld{{(.exe)?}}"
+// CHECK: "{{[^"]*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK: "-L[[TOOLCHAIN]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
diff --git a/test/Driver/gcc_forward.c b/test/Driver/gcc_forward.c
index c584a4e..77f401b 100644
--- a/test/Driver/gcc_forward.c
+++ b/test/Driver/gcc_forward.c
@@ -1,6 +1,6 @@
// Check that we don't try to forward -Xclang or -mlinker-version to GCC.
//
-// RUN: %clang -ccc-host-triple powerpc-unknown-unknown \
+// RUN: %clang -target powerpc-unknown-unknown \
// RUN: -ccc-clang-archs i386 -c %s \
// RUN: -Xclang foo-bar \
// RUN: -mlinker-version=10 -### 2> %t
diff --git a/test/Driver/gnu-runtime.m b/test/Driver/gnu-runtime.m
index 5a3654c..12426d9 100644
--- a/test/Driver/gnu-runtime.m
+++ b/test/Driver/gnu-runtime.m
@@ -1,5 +1,5 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -### -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -### -x objective-c++ -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
+// RUN: %clang -target i386-apple-darwin10 -### -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
+// RUN: %clang -target i386-apple-darwin10 -### -x objective-c++ -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s
// CHECK: -fgnu-runtime
// CHECK: -fobjc-runtime-has-arc
// CHECK: -fobjc-runtime-has-weak
diff --git a/test/Driver/gold-lto.c b/test/Driver/gold-lto.c
new file mode 100644
index 0000000..05ac27a
--- /dev/null
+++ b/test/Driver/gold-lto.c
@@ -0,0 +1,6 @@
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-pc-linux-gnu -### %t.o -O4 -Wl,-plugin-opt=foo 2> %t.log
+// RUN: FileCheck %s < %t.log
+
+// CHECK: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK: "-plugin-opt=foo"
diff --git a/test/Driver/invalid-o-level.c b/test/Driver/invalid-o-level.c
new file mode 100644
index 0000000..d5242c7
--- /dev/null
+++ b/test/Driver/invalid-o-level.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -O900 2> %t.log
+// RUN: FileCheck %s -input-file=%t.log
+
+// CHECK: invalid value '900' in '-O900'
diff --git a/test/Driver/ios-simulator-arcruntime.c b/test/Driver/ios-simulator-arcruntime.c
index bec9f7b..9bf2091 100644
--- a/test/Driver/ios-simulator-arcruntime.c
+++ b/test/Driver/ios-simulator-arcruntime.c
@@ -1,5 +1,5 @@
-// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
-// RUN: %clang -### -x objective-c -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
+// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
//
// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak
diff --git a/test/Driver/le32-unknown-nacl.cpp b/test/Driver/le32-unknown-nacl.cpp
index bc31802..f68b220 100644
--- a/test/Driver/le32-unknown-nacl.cpp
+++ b/test/Driver/le32-unknown-nacl.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang -ccc-host-triple le32-unknown-nacl -ccc-clang-archs le32 -ccc-echo %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
-// RUN: %clang -ccc-host-triple le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -o - | FileCheck %s
-// RUN: %clang -ccc-host-triple le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 -ccc-echo %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -o - | FileCheck %s
+// RUN: %clang -target le32-unknown-nacl -ccc-clang-archs le32 %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS
// ECHO: {{.*}} -cc1 {{.*}}le32-unknown-nacl.c
@@ -40,6 +40,11 @@ int align_ld = __alignof(long double);
// CHECK: @align_vl = global i32 4
int align_vl = __alignof(va_list);
+// CHECK: __LITTLE_ENDIAN__defined
+#ifdef __LITTLE_ENDIAN__
+void __LITTLE_ENDIAN__defined() {}
+#endif
+
// CHECK: __native_client__defined
#ifdef __native_client__
void __native_client__defined() {}
diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c
new file mode 100644
index 0000000..d036dfd
--- /dev/null
+++ b/test/Driver/linker-opts.c
@@ -0,0 +1,5 @@
+// RUN: env LIBRARY_PATH=%T/test1 %clang -x c %s -### 2>&1 | FileCheck %s
+// CHECK: "-L" "{{.*}}/test1"
+
+// GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
+// XFAIL: cygwin,mingw32
diff --git a/test/Driver/linux-as.c b/test/Driver/linux-as.c
new file mode 100644
index 0000000..22eac0d
--- /dev/null
+++ b/test/Driver/linux-as.c
@@ -0,0 +1,31 @@
+// Check passing options to the assembler for ARM targets.
+//
+// RUN: %clang -target arm-linux -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM %s
+// CHECK-ARM: as{{(.exe)?}}"
+//
+// RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MCPU %s
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a8"
+//
+// RUN: %clang -target arm-linux -mfpu=neon -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MFPU %s
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfpu=neon"
+//
+// RUN: %clang -target arm-linux -march=armv7-a -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-MARCH %s
+// CHECK-ARM-MARCH: as{{(.exe)?}}" "-march=armv7-a"
+//
+// RUN: %clang -target arm-linux -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-ALL %s
+// CHECK-ARM-ALL: as{{(.exe)?}}" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon"
+//
+// RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=ARM-TARGET %s
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mcpu=cortex-a8"
diff --git a/test/Driver/linux-header-search.cpp b/test/Driver/linux-header-search.cpp
new file mode 100644
index 0000000..ea82660
--- /dev/null
+++ b/test/Driver/linux-header-search.cpp
@@ -0,0 +1,75 @@
+// General tests that the header search paths detected by the driver and passed
+// to CC1 are sane.
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-UBUNTU-11-04: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i686-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-X86-64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-X86-64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-X86-64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -ccc-clang-archs powerpc -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target powerpc-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// RUN: %clang -ccc-clang-archs powerpc64 -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target powerpc64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-PPC64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../../include/c++/4.5/backward"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-DEBIAN-PPC64: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-DEBIAN-PPC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
index 456f7ad..9a35d5d 100644
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -2,7 +2,7 @@
// sysroot to make these tests independent of the host system.
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux \
+// RUN: -target i386-unknown-linux \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -14,7 +14,7 @@
// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple x86_64-unknown-linux \
+// RUN: -target x86_64-unknown-linux \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -26,7 +26,7 @@
// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s
// CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -42,7 +42,7 @@
// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m64 \
+// RUN: -target i386-unknown-linux -m64 \
// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s
// CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -59,7 +59,7 @@
// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple x86_64-unknown-linux -m64 \
+// RUN: -target x86_64-unknown-linux -m64 \
// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-64-TO-64 %s
// CHECK-64-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -75,7 +75,7 @@
// CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple x86_64-unknown-linux -m32 \
+// RUN: -target x86_64-unknown-linux -m32 \
// RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-64-TO-32 %s
// CHECK-64-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
@@ -92,7 +92,21 @@
// CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib"
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target x86_64-unknown-linux -m32 \
+// RUN: -gcc-toolchain %S/Inputs/multilib_64bit_linux_tree/usr \
+// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-64-TO-32-SYSROOT %s
+// CHECK-64-TO-32-SYSROOT: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-64-TO-32-SYSROOT: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib/../lib32"
+// CHECK-64-TO-32-SYSROOT: "-L{{[^"]*}}/Inputs/multilib_64bit_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/lib"
+// CHECK-64-TO-32-SYSROOT: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s
@@ -103,7 +117,7 @@
// Check that with 64-bit builds, we don't actually use the install directory
// as its version of GCC is lower than our sysrooted version.
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple x86_64-unknown-linux -m64 \
+// RUN: -target x86_64-unknown-linux -m64 \
// RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s
@@ -114,7 +128,7 @@
// Check that we support unusual patch version formats, including missing that
// component.
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s
@@ -122,7 +136,7 @@
// CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o"
// CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s
@@ -130,7 +144,7 @@
// CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o"
// CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s
@@ -138,10 +152,119 @@
// CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o"
// CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -ccc-host-triple i386-unknown-linux -m32 \
+// RUN: -target i386-unknown-linux -m32 \
// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing4/bin \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION4 %s
// CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o"
// CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "{{.*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib"
+//
+// Test the setup that shipped in SUSE 10.3 on ppc64.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-suse-linux \
+// RUN: --sysroot=%S/Inputs/suse_10.3_ppc64_tree \
+// RUN: | FileCheck --check-prefix=CHECK-SUSE-10-3-PPC64 %s
+// CHECK-SUSE-10-3-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-SUSE-10-3-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64/crtbegin.o"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-suse-linux/4.1.2/../../../../lib64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/lib/../lib64"
+// CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64"
+//
+// Check that we do not pass --hash-style=gnu and --hash-style=both to linker
+// and provide correct path to the dynamic linker and emulation mode when build
+// for MIPS platforms.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -ccc-clang-archs mips \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS %s
+// CHECK-MIPS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS: "-m" "elf32btsmip"
+// CHECK-MIPS: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
+// CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mipsel-linux-gnu -ccc-clang-archs mipsel \
+// RUN: | FileCheck --check-prefix=CHECK-MIPSEL %s
+// CHECK-MIPSEL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPSEL: "-m" "elf32ltsmip"
+// CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/lib/ld.so.1"
+// CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips64-linux-gnu -ccc-clang-archs mips64 \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64 %s
+// CHECK-MIPS64: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64: "-m" "elf64btsmip"
+// CHECK-MIPS64: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
+// CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: -target mips64el-linux-gnu -ccc-clang-archs mips64el \
+// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL %s
+// CHECK-MIPS64EL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-MIPS64EL: "-m" "elf64ltsmip"
+// CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/lib64/ld.so.1"
+// CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
+//
+// Thoroughly exercise the Debian multiarch environment.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86 %s
+// CHECK-DEBIAN-X86: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86: "{{.*}}/usr/lib/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../../i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib/gcc/i686-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-X86-64 %s
+// CHECK-DEBIAN-X86-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-X86-64: "{{.*}}/usr/lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/x86_64-linux-gnu"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-X86-64: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC %s
+// CHECK-DEBIAN-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC: "{{.*}}/usr/lib/gcc/powerpc-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../../powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/powerpc-linux-gnu"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib/gcc/powerpc-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-PPC64 %s
+// CHECK-DEBIAN-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-PPC64: "{{.*}}/usr/lib/gcc/powerpc64-linux-gnu/4.5/crtbegin.o"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../../powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/powerpc64-linux-gnu"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib"
+//
diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c
new file mode 100644
index 0000000..44b8d8d
--- /dev/null
+++ b/test/Driver/mips-as.c
@@ -0,0 +1,31 @@
+// Check passing options to the assembler for MIPS targets.
+//
+// RUN: %clang -target mips-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s
+// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+//
+// RUN: %clang -target mipsel-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
+// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+//
+// RUN: %clang -target mips64-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s
+// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+//
+// RUN: %clang -target mips64el-linux-gnu -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
+// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+//
+// RUN: %clang -target mips-linux-gnu -mabi=eabi -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-EABI %s
+// CHECK-MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB"
+//
+// RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS-N32 %s
+// CHECK-MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB"
diff --git a/test/Driver/mips-float.c b/test/Driver/mips-float.c
new file mode 100644
index 0000000..c9e107f
--- /dev/null
+++ b/test/Driver/mips-float.c
@@ -0,0 +1,42 @@
+// Check handling -mhard-float / -msoft-float / -mfloat-abi options
+// when build for MIPS platforms.
+//
+// Default
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu \
+// RUN: | FileCheck --check-prefix=CHECK-DEF %s
+// CHECK-DEF: "-mfloat-abi" "hard"
+//
+// -mhard-float
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mhard-float \
+// RUN: | FileCheck --check-prefix=CHECK-HARD %s
+// CHECK-HARD: "-mfloat-abi" "hard"
+//
+// -msoft-float
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -msoft-float \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: "-msoft-float"
+// CHECK-SOFT: "-mfloat-abi" "soft"
+// CHECK-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=hard \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-HARD %s
+// CHECK-ABI-HARD: "-mfloat-abi" "hard"
+//
+// -mfloat-abi=soft
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=soft \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-SOFT %s
+// CHECK-ABI-SOFT: "-msoft-float"
+// CHECK-ABI-SOFT: "-mfloat-abi" "soft"
+// CHECK-ABI-SOFT: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=single
+// RUN: %clang -ccc-clang-archs mips -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=single \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-SINGLE %s
+// CHECK-ABI-SINGLE: "-target-feature" "+single-float"
diff --git a/test/Driver/mno-global-merge.c b/test/Driver/mno-global-merge.c
index b4d8f87..ec9f69e 100644
--- a/test/Driver/mno-global-merge.c
+++ b/test/Driver/mno-global-merge.c
@@ -1,10 +1,10 @@
-// RUN: %clang -ccc-host-triple armv7-apple-darwin10 \
+// RUN: %clang -target armv7-apple-darwin10 \
// RUN: -mno-global-merge -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NGM < %t %s
// CHECK-NGM: "-mno-global-merge"
-// RUN: %clang -ccc-host-triple armv7-apple-darwin10 \
+// RUN: %clang -target armv7-apple-darwin10 \
// RUN: -mglobal-merge -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-GM < %t %s
diff --git a/test/Driver/modules.m b/test/Driver/modules.m
new file mode 100644
index 0000000..b93054d
--- /dev/null
+++ b/test/Driver/modules.m
@@ -0,0 +1,6 @@
+// RUN: %clang -fmodules -fno-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// CHECK-NO-MODULES-NOT: -fmodules
+
+// RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// CHECK-HAS-MODULES: -fmodules
+
diff --git a/test/Driver/modules.mm b/test/Driver/modules.mm
new file mode 100644
index 0000000..b2948c4
--- /dev/null
+++ b/test/Driver/modules.mm
@@ -0,0 +1,6 @@
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s
+// CHECK-NO-MODULES-NOT: -fmodules
+
+// RUN: %clang -fcxx-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
+// CHECK-HAS-MODULES: -fmodules
diff --git a/test/Driver/no-objc-arr.m b/test/Driver/no-objc-arr.m
index 15fbdc2..e449393 100644
--- a/test/Driver/no-objc-arr.m
+++ b/test/Driver/no-objc-arr.m
@@ -1,4 +1,4 @@
-// RUN: %clang -Werror -fobjc-arc -fsyntax-only -fno-objc-arc -verify %s
+// RUN: %clang -Werror -fobjc-arc -fsyntax-only -fno-objc-arc -Xclang -verify %s
// rdar://8949617
void * FOO() {
diff --git a/test/Driver/no-objc-default-synthesize-properties.m b/test/Driver/no-objc-default-synthesize-properties.m
new file mode 100644
index 0000000..e380514
--- /dev/null
+++ b/test/Driver/no-objc-default-synthesize-properties.m
@@ -0,0 +1,10 @@
+// RUN: %clang -fsyntax-only -fno-objc-default-synthesize-properties -fobjc-default-synthesize-properties %s 2>&1 | FileCheck %s
+
+@interface I
+@property int P;
+@end
+
+@implementation I
+@end
+// CHECK: warning: argument unused during compilation: '-fno-objc-default-synthesize-properties'
+// CHECK: warning: argument unused during compilation: '-fobjc-default-synthesize-properties'
diff --git a/test/Driver/no-sibling-calls.c b/test/Driver/no-sibling-calls.c
new file mode 100644
index 0000000..c248990
--- /dev/null
+++ b/test/Driver/no-sibling-calls.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### %s -fno-optimize-sibling-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NOSC < %t %s
+// CHECK-NOSC: "-mdisable-tail-calls"
+
+// RUN: %clang -### -foptimize-sibling-calls %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-OSC < %t %s
+// CHECK-OSC-NOT: "-mdisable-tail-calls"
+
diff --git a/test/Driver/noinline.c b/test/Driver/noinline.c
new file mode 100644
index 0000000..e665b2f
--- /dev/null
+++ b/test/Driver/noinline.c
@@ -0,0 +1,10 @@
+// Make sure the driver is correctly passing -fno-inline-functions
+// rdar://10972766
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -fno-inline -fno-inline-functions -### -fsyntax-only %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK < %t %s
+
+// CHECK: clang
+// CHECK: "-fno-inline"
+// CHECK: "-fno-inline-functions"
diff --git a/test/Driver/nostdlib.c b/test/Driver/nostdlib.c
index c73212f..e9ada31 100644
--- a/test/Driver/nostdlib.c
+++ b/test/Driver/nostdlib.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple i686-pc-linux-gnu -### -nostdlib %s 2> %t
+// RUN: %clang -target i686-pc-linux-gnu -### -nostdlib %s 2> %t
// RUN: FileCheck < %t %s
//
// CHECK-NOT: start-group
diff --git a/test/Driver/nostdlibinc.c b/test/Driver/nostdlibinc.c
index f7ee712..5b6fab6 100644
--- a/test/Driver/nostdlibinc.c
+++ b/test/Driver/nostdlibinc.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple x86_64-unknown-unknown \
+// RUN: %clang -target x86_64-unknown-unknown \
// RUN: -nostdlibinc -ffreestanding -fsyntax-only %s
#if !__has_include("stddef.h")
diff --git a/test/Driver/openbsd.c b/test/Driver/openbsd.c
index 34f6988..911c452c 100644
--- a/test/Driver/openbsd.c
+++ b/test/Driver/openbsd.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-clang-archs "" -ccc-host-triple i686-pc-openbsd %s -### 2> %t.log
+// RUN: %clang -no-canonical-prefixes -ccc-clang-archs "" -target i686-pc-openbsd %s -### 2> %t.log
// RUN: FileCheck -input-file %t.log %s
// CHECK: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
diff --git a/test/Driver/output-file-cleanup.c b/test/Driver/output-file-cleanup.c
new file mode 100644
index 0000000..0a0c960
--- /dev/null
+++ b/test/Driver/output-file-cleanup.c
@@ -0,0 +1,25 @@
+// RUN: touch %t.o
+// RUN: not %clang -DCRASH -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test ! -f %t.d
+
+// RUN: touch %t.o
+// RUN: not %clang -DMISSING -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test ! -f %t.d
+
+// RUN: touch %t.o
+// RUN: not %clang -o %t.o -MMD -MF %t.d %s
+// RUN: test ! -f %t.o
+// RUN: test -f %t.d
+
+// REQUIRES: shell
+// REQUIRES: crash-recovery
+
+#ifdef CRASH
+#pragma clang __debug crash
+#elif defined(MISSING)
+#include "nonexistent.h"
+#else
+invalid C code
+#endif
diff --git a/test/Driver/parsing.c b/test/Driver/parsing.c
index ca3a7f4..eceba37 100644
--- a/test/Driver/parsing.c
+++ b/test/Driver/parsing.c
@@ -20,6 +20,3 @@
// RUN: %clang -ccc-print-options -Wally 2> %t
// RUN: grep 'Option 0 - Name: "-ccc-print-options", Values: {}' %t
// RUN: grep 'Option 1 - Name: "-W", Values: {"ally"}' %t
-
-
-
diff --git a/test/Driver/phases.c b/test/Driver/phases.c
index 7fe529c..4c480d5 100644
--- a/test/Driver/phases.c
+++ b/test/Driver/phases.c
@@ -1,5 +1,5 @@
// Basic compilation for various types of files.
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s 2>&1 | FileCheck -check-prefix=BASIC %s
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s 2>&1 | FileCheck -check-prefix=BASIC %s
// BASIC: 0: input, "{{.*}}phases.c", c
// BASIC: 1: preprocessor, {0}, cpp-output
// BASIC: 2: compiler, {1}, assembler
@@ -24,7 +24,7 @@
// BASIC: 21: linker, {3, 7, 11, 13, 16, 20}, image
// Universal linked image.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=ULI %s
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=ULI %s
// ULI: 0: input, "{{.*}}phases.c", c
// ULI: 1: preprocessor, {0}, cpp-output
// ULI: 2: compiler, {1}, assembler
@@ -35,7 +35,7 @@
// ULI: 7: lipo, {5, 6}, image
// Universal object file.
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=UOF %s
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=UOF %s
// UOF: 0: input, "{{.*}}phases.c", c
// UOF: 1: preprocessor, {0}, cpp-output
// UOF: 2: compiler, {1}, assembler
@@ -45,33 +45,33 @@
// UOF: 6: lipo, {4, 5}, object
// Arch defaulting
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH1 %s
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH1 %s
// ARCH1: 2: bind-arch, "i386", {1}, object
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c -x assembler %s -m32 -m64 2>&1 | FileCheck -check-prefix=ARCH2 %s
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x assembler %s -m32 -m64 2>&1 | FileCheck -check-prefix=ARCH2 %s
// ARCH2: 2: bind-arch, "x86_64", {1}, object
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH3 %s
+// RUN: %clang -target x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH3 %s
// ARCH3: 2: bind-arch, "x86_64", {1}, object
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s -m64 -m32 2>&1 | FileCheck -check-prefix=ARCH4 %s
+// RUN: %clang -target x86_64-apple-darwin9 -ccc-print-phases -c -x assembler %s -m64 -m32 2>&1 | FileCheck -check-prefix=ARCH4 %s
// ARCH4: 2: bind-arch, "i386", {1}, object
// Analyzer
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases --analyze %s 2>&1 | FileCheck -check-prefix=ANALYZE %s
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases --analyze %s 2>&1 | FileCheck -check-prefix=ANALYZE %s
// ANALYZE: 0: input, "{{.*}}phases.c", c
// ANALYZE: 1: preprocessor, {0}, cpp-output
// ANALYZE: 2: analyzer, {1}, plist
// Precompiler
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -x c-header %s 2>&1 | FileCheck -check-prefix=PCH %s
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -x c-header %s 2>&1 | FileCheck -check-prefix=PCH %s
// PCH: 0: input, "{{.*}}phases.c", c-header
// PCH: 1: preprocessor, {0}, c-header-cpp-output
// PCH: 2: precompiler, {1}, precompiled-header
// Darwin overrides the handling for .s
// RUN: touch %t.s
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN1 %s
+// RUN: %clang -target i386-unknown-unknown -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN1 %s
// DARWIN1: 0: input, "{{.*}}.s", assembler
// DARWIN1: 1: assembler, {0}, object
-// RUN: %clang -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN2 %s
+// RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c %t.s 2>&1 | FileCheck -check-prefix=DARWIN2 %s
// DARWIN2: 0: input, "{{.*}}.s", assembler-with-cpp
// DARWIN2: 1: preprocessor, {0}, assembler
// DARWIN2: 2: assembler, {1}, object
diff --git a/test/Driver/pic.c b/test/Driver/pic.c
new file mode 100644
index 0000000..3952f85
--- /dev/null
+++ b/test/Driver/pic.c
@@ -0,0 +1,81 @@
+// Test the driver's control over the PIC behavior. These consist of tests of
+// the relocation model flags and the pic level flags passed to CC1.
+//
+// CHECK-NO-PIC: "-mrelocation-model" "static"
+// CHECK-NO-PIC-NOT: "-pic-level"
+// CHECK-NO-PIC-NOT: "-pie-level"
+//
+// CHECK-DYNAMIC-NO-PIC1: "-mrelocation-model" "dynamic-no-pic"
+// CHECK-DYNAMIC-NO-PIC1: "-pic-level" "1"
+//
+// CHECK-DYNAMIC-NO-PIC2: "-mrelocation-model" "dynamic-no-pic"
+// CHECK-DYNAMIC-NO-PIC2: "-pic-level" "2"
+//
+// CHECK-PIC1-NOT: "-mrelocation-model"
+// CHECK-PIC1: "-pic-level" "1"
+//
+// CHECK-PIC2-NOT: "-mrelocation-model"
+// CHECK-PIC2: "-pic-level" "2"
+//
+// CHECK-PIE1-NOT: "-mrelocation-model"
+// CHECK-PIE1: "-pie-level" "1"
+//
+// CHECK-PIE2-NOT: "-mrelocation-model"
+// CHECK-PIE2: "-pie-level" "2"
+//
+// RUN: %clang -c %s -target i386-unknown-unknown -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-PIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-PIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIE -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fno-pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-unknown-unknown -fPIC -fpic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC1
+// RUN: %clang -c %s -target i386-unknown-unknown -fpic -fPIE -fpie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target i386-unknown-unknown -fpie -fPIC -fPIE -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
+//
+// Defaults change for Darwin.
+// RUN: %clang -c %s -target i386-apple-darwin -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s -target i386-apple-darwin -fno-pic -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-apple-darwin -fno-PIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+//
+// Disregard any of the PIC-specific flags if we have a trump-card flag.
+// RUN: %clang -c %s -target i386-unknown-unknown -mkernel -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -static -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
+// RUN: %clang -c %s -target i386-unknown-unknown -mdynamic-no-pic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC1
+// RUN: %clang -c %s -target i386-apple-darwin -mdynamic-no-pic -fPIC -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC2
diff --git a/test/Driver/prefixed-tools.c b/test/Driver/prefixed-tools.c
new file mode 100644
index 0000000..d7c342a
--- /dev/null
+++ b/test/Driver/prefixed-tools.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### -B%S/Inputs/prefixed_tools_tree -o %t.o -no-integrated-as \
+// RUN: -target x86_64--linux %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-M64 %s
+
+// RUN: %clang -### -B%S/Inputs/prefixed_tools_tree -o %t.o -no-integrated-as \
+// RUN: -m32 -target x86_64--linux %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-M32 %s
+
+// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
+// CHECK-M64: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
+// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-as"
+// CHECK-M32: "{{.*}}{{[/\\]}}prefixed_tools_tree{{[/\\]}}x86_64--linux-ld"
diff --git a/test/Driver/pth.c b/test/Driver/pth.c
index 9c47c55..4350f46 100644
--- a/test/Driver/pth.c
+++ b/test/Driver/pth.c
@@ -1,12 +1,12 @@
// Test transparent PTH support.
-// RUN: %clang -ccc-pch-is-pth -x c-header %s -o %t.h.pth -### 2> %t.log
+// RUN: %clang -no-canonical-prefixes -ccc-pch-is-pth -x c-header %s -o %t.h.pth -### 2> %t.log
// RUN: FileCheck -check-prefix CHECK1 -input-file %t.log %s
// CHECK1: "{{.*}}/clang{{.*}}" "-cc1" {{.*}} "-o" "{{.*}}.h.pth" "-x" "c-header" "{{.*}}pth.c"
// RUN: touch %t.h.pth
-// RUN: %clang -ccc-pch-is-pth -E -include %t.h %s -### 2> %t.log
+// RUN: %clang -no-canonical-prefixes -ccc-pch-is-pth -E -include %t.h %s -### 2> %t.log
// RUN: FileCheck -check-prefix CHECK2 -input-file %t.log %s
// CHECK2: "{{.*}}/clang{{.*}}" "-cc1" {{.*}}"-include-pth" "{{.*}}.h.pth" {{.*}}"-x" "c" "{{.*}}pth.c"
diff --git a/test/Driver/redundant-args.c b/test/Driver/redundant-args.c
new file mode 100644
index 0000000..7bf98e1
--- /dev/null
+++ b/test/Driver/redundant-args.c
@@ -0,0 +1,2 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -Werror -x c -x c -fsyntax-only %s
diff --git a/test/Driver/redzone.c b/test/Driver/redzone.c
index 9f117d0..7d6d424 100644
--- a/test/Driver/redzone.c
+++ b/test/Driver/redzone.c
@@ -1,6 +1,6 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -mno-red-zone %s -S -emit-llvm -o %t.log
+// RUN: %clang -target i386-unknown-unknown -mno-red-zone %s -S -emit-llvm -o %t.log
// RUN: grep 'noredzone' %t.log
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -mred-zone %s -S -emit-llvm -o %t.log
+// RUN: %clang -target i386-unknown-unknown -mred-zone %s -S -emit-llvm -o %t.log
// RUN: grep -v 'noredzone' %t.log
int foo() { return 42; }
diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m
new file mode 100644
index 0000000..af59ff6
--- /dev/null
+++ b/test/Driver/rewrite-legacy-objc.m
@@ -0,0 +1,15 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST0 %s
+// TEST0: clang{{.*}}" "-cc1"
+// TEST0: "-rewrite-objc"
+// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: rewrite-legacy-objc.m"
+
+// RUN: not %clang -ccc-no-clang -target unknown -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST1 %s
+// TEST1: invalid output type 'rewritten-legacy-objc' for use with gcc
+
+// RUN: not %clang -ccc-no-clang -target i386-apple-darwin10 -rewrite-legacy-objc %s -o - -### 2>&1 | \
+// RUN: FileCheck -check-prefix=TEST2 %s
+// TEST2: invalid output type 'rewritten-legacy-objc' for use with gcc
diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m
index 8019091..7b080fc 100644
--- a/test/Driver/rewrite-objc.m
+++ b/test/Driver/rewrite-objc.m
@@ -1,15 +1,15 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-macosx10.7.0 -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: %clang -no-canonical-prefixes -target x86_64-apple-macosx10.7.0 -rewrite-objc %s -o - -### 2>&1 | \
// RUN: FileCheck -check-prefix=TEST0 %s
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fobjc-fragile-abi" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m"
-// RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \
// RUN: FileCheck -check-prefix=TEST1 %s
// TEST1: invalid output type 'rewritten-objc' for use with gcc
-// RUN: not %clang -ccc-no-clang -ccc-host-triple i386-apple-darwin10 -rewrite-objc %s -o - -### 2>&1 | \
+// RUN: not %clang -ccc-no-clang -target i386-apple-darwin10 -rewrite-objc %s -o - -### 2>&1 | \
// RUN: FileCheck -check-prefix=TEST2 %s
// TEST2: invalid output type 'rewritten-objc' for use with gcc
diff --git a/test/Driver/stackrealign.c b/test/Driver/stackrealign.c
new file mode 100644
index 0000000..c5221d6
--- /dev/null
+++ b/test/Driver/stackrealign.c
@@ -0,0 +1,12 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NORMAL
+// NORMAL-NOT: -force-align-stack
+// NORMAL: -mstackrealign
+
+// RUN: %clang -### -mstackrealign %s 2>&1 | FileCheck %s -check-prefix=MREALIGN
+// MREALIGN: -force-align-stack
+// MREALIGN: -mstackrealign
+
+// RUN: %clang -### -mno-stackrealign %s 2>&1 | \
+// RUN: FileCheck %s -check-prefix=MNOREALIGN
+// MNOREALIGN-NOT: -force-align-stack
+// MNOREALIGN-NOT: -mstackrealign
diff --git a/test/Driver/sysroot-flags.c b/test/Driver/sysroot-flags.c
index 044a86f..b0a10bf 100644
--- a/test/Driver/sysroot-flags.c
+++ b/test/Driver/sysroot-flags.c
@@ -6,7 +6,7 @@
// Check that we get both isysroot for headers, and pass --sysroot on to GCC to
// produce the final binary.
-// RUN: %clang -### -ccc-host-triple x86_64-unknown-linux-gnu \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
// RUN: --sysroot=/foo/bar -o /dev/null %s 2>&1 | \
// RUN: FileCheck %s -check-prefix=SYSROOT_EQ
// SYSROOT_EQ: "-isysroot" "{{[^"]*}}/foo/bar"
@@ -14,14 +14,14 @@
// Check for overriding the header sysroot by providing both --sysroot and
// -isysroot.
-// RUN: %clang -### -ccc-host-triple x86_64-unknown-linux-gnu -isysroot /baz \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu -isysroot /baz \
// RUN: --sysroot=/foo/bar -o /dev/null %s 2>&1 | FileCheck %s \
// RUN: -check-prefix=ISYSROOT_AND_SYSROOT
// ISYSROOT_AND_SYSROOT: "-isysroot" "{{[^"]*}}/baz"
// ISYSROOT_AND_SYSROOT: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
// Check that omitting the equals works as well.
-// RUN: %clang -### -ccc-host-triple x86_64-unknown-linux-gnu \
+// RUN: %clang -### -target x86_64-unknown-linux-gnu \
// RUN: --sysroot /foo/bar -o /dev/null %s 2>&1 | \
// RUN: FileCheck %s -check-prefix=SYSROOT_SEPARATE
// SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar"
diff --git a/test/Driver/sysroot.c b/test/Driver/sysroot.c
index 79db900..3080f76 100644
--- a/test/Driver/sysroot.c
+++ b/test/Driver/sysroot.c
@@ -1,18 +1,18 @@
// Check that --sysroot= also applies to header search paths.
-// RUN: %clang -ccc-host-triple i386-unk-unk --sysroot=/FOO -### -E %s 2> %t1
+// RUN: %clang -target i386-unk-unk --sysroot=/FOO -### -E %s 2> %t1
// RUN: FileCheck --check-prefix=CHECK-SYSROOTEQ < %t1 %s
// CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "{{[^"]*}}/FOO"
// Apple Darwin uses -isysroot as the syslib root, too.
// RUN: touch %t2.o
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: %clang -target i386-apple-darwin10 \
// RUN: -isysroot /FOO -### %t2.o 2> %t2
// RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s
// CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "{{[^"]*}}/FOO"
// Check that honor --sysroot= over -isysroot, for Apple Darwin.
// RUN: touch %t3.o
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 \
+// RUN: %clang -target i386-apple-darwin10 \
// RUN: -isysroot /FOO --sysroot=/BAR -### %t3.o 2> %t3
// RUN: FileCheck --check-prefix=CHECK-APPLE-SYSROOT < %t3 %s
// CHECK-APPLE-SYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "{{[^"]*}}/BAR"
diff --git a/test/Driver/target.c b/test/Driver/target.c
new file mode 100644
index 0000000..59147e0
--- /dev/null
+++ b/test/Driver/target.c
@@ -0,0 +1,11 @@
+// RUN: %clang -no-canonical-prefixes -target unknown-unknown-unknown -c %s \
+// RUN: -o %t.o -### 2>&1 | FileCheck %s
+//
+// Ensure we get a crazy triple here as we asked for one.
+// CHECK: Target: unknown-unknown-unknown
+//
+// Also, ensure we don't blindly hand our target selection logic down to GCC.
+// CHECK: "{{.*gcc(\.[Ee][Xx][Ee])?}}"
+// CHECK-NOT: "-target"
+// CHECK-NOT: "unknown-unknown-unknown"
+// CHECK: "-x" "assembler"
diff --git a/test/Driver/tsan.c b/test/Driver/tsan.c
new file mode 100644
index 0000000..1dadb8e
--- /dev/null
+++ b/test/Driver/tsan.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O1 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O2 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// RUN: %clang -O3 -target i386-unknown-unknown -fthread-sanitizer %s -S -emit-llvm -o - | FileCheck %s
+// Verify that -fthread-sanitizer invokes tsan instrumentation.
+
+int foo(int *a) { return *a; }
+// CHECK: __tsan_init
diff --git a/test/Driver/unknown-arg.c b/test/Driver/unknown-arg.c
new file mode 100644
index 0000000..5d0f7af
--- /dev/null
+++ b/test/Driver/unknown-arg.c
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 %s -cake-is-lie 2> %t.log
+// RUN: FileCheck %s -input-file=%t.log
+
+// CHECK: unknown argument
diff --git a/test/Driver/unknown-gcc-arch.c b/test/Driver/unknown-gcc-arch.c
index 7018bf8..5e4746b 100644
--- a/test/Driver/unknown-gcc-arch.c
+++ b/test/Driver/unknown-gcc-arch.c
@@ -1,8 +1,8 @@
-// RUN: %clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log
// RUN: grep '.*gcc.*"-m64"' %t.log
-// RUN: %clang -ccc-host-triple x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log
// RUN: grep '.*gcc.*"-m32"' %t.log
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### 2> %t.log
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### 2> %t.log
// RUN: grep '.*gcc.*"-m32"' %t.log
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log
// RUN: grep '.*gcc.*"-m64"' %t.log
diff --git a/test/Driver/working-directory.c b/test/Driver/working-directory.c
new file mode 100644
index 0000000..38a87a6
--- /dev/null
+++ b/test/Driver/working-directory.c
@@ -0,0 +1,4 @@
+// RUN: %clang -ccc-print-options -working-directory "C:\Test" input 2>&1 | FileCheck %s
+// CHECK: Option 0 - Name: "-ccc-print-options", Values: {}
+// CHECK: Option 1 - Name: "-working-directory", Values: {"C:\Test"}
+// CHECK: Option 2 - Name: "<input>", Values: {"input"}
diff --git a/test/Driver/x86_features.c b/test/Driver/x86_features.c
index 0db372e..5c65e31 100644
--- a/test/Driver/x86_features.c
+++ b/test/Driver/x86_features.c
@@ -1,3 +1,3 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2> %t
+// RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2> %t
// RUN: grep '"pentium4" "-target-feature" "+sse4" "-target-feature" "-mmx" "-target-feature" "+sse"' %t
// Note that we filter out all but the last -m(no)sse.
diff --git a/test/FixIt/atomic-property.m b/test/FixIt/atomic-property.m
new file mode 100644
index 0000000..9ede7f1
--- /dev/null
+++ b/test/FixIt/atomic-property.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c -fobjc-arc %s 2>&1 | FileCheck %s
+
+@interface I
+@property id prop;
+@property (atomic) id atomic_prop;
+- (id) prop;
+- (id) atomic_prop;
+
+@property ( ) id prop1;
+
+@property (copy, atomic, readwrite) id atomic_prop1;
+
+@property (copy, readwrite) id prop2;
+@end
+
+@implementation I
+@synthesize prop, prop1, prop2;
+@synthesize atomic_prop, atomic_prop1;
+- (id) prop { return 0; }
+- (id) prop1 { return 0; }
+- (id) prop2 { return 0; }
+- (id) atomic_prop { return 0; }
+- (id) atomic_prop1 { return 0; }
+@end
+
+// CHECK: {4:1-4:10}:"@property (nonatomic) "
+// CHECK: {9:1-9:12}:"@property (nonatomic"
+// CHECK: {13:1-13:12}:"@property (nonatomic, "
+
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index 7331645..b6cc2c0 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -18,37 +18,93 @@ using ::T = void; // expected-error {{name defined in alias declaration must be
using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}}
-namespace Constexpr {
- extern constexpr int a; // expected-error {{must be a definition}}
- // -> extern const int a;
+namespace SemiCommaTypo {
+ int m {},
+ n [[]], // expected-error {{expected ';' at end of declaration}}
+ int o;
- extern constexpr int *b; // expected-error {{must be a definition}}
- // -> extern int *const b;
-
- extern constexpr int &c; // expected-error {{must be a definition}}
- // -> extern int &b;
-
- extern constexpr const int d; // expected-error {{must be a definition}}
- // -> extern const int d;
+ struct Base {
+ virtual void f2(), f3();
+ };
+ struct MemberDeclarator : Base {
+ int k : 4,
+ //[[]] : 1, FIXME: test this once we support attributes here
+ : 9, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ typedef void F(), // expected-error {{expected ';' at end of declaration}}
+ F f1,
+ f2 final,
+ f3 override, // expected-error {{expected ';' at end of declaration}}
+ };
+}
- int z;
- constexpr int a = 0;
- constexpr int *b = &z;
- constexpr int &c = z;
- constexpr int d = a;
+namespace ScopedEnum {
+ enum class E { a };
- // FIXME: Provide FixIts for static data members too.
-#if 0
+ enum class E b = E::a; // expected-error {{must use 'enum' not 'enum class'}}
struct S {
- static constexpr int b; // xpected-error {{requires an initializer}}
- // -> const int b;
+ friend enum class E; // expected-error {{must use 'enum' not 'enum class'}}
};
+}
- constexpr int S::b = 0;
-#endif
+struct S2 {
+ void f(int i);
+ void g(int i);
+};
- struct S {
- static char *const p = 0; // expected-error {{requires 'constexpr' specifier}}
- // -> constexpr static char *const p = 0;
- };
+void S2::f(int i) {
+ (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
+ (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
+ (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
+ (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
+ (void)[] -> int { }; // expected-error{{lambda requires '()' before return type}}
}
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-error {{requires a space between}}
+#define ord - '0'
+int k = '4'ord; // expected-error {{requires a space between}}
+
+void operator""_x(char); // expected-error {{requires a space}}
+void operator"x" _y(char); // expected-error {{must be '""'}}
+void operator L"" _z(char); // expected-error {{encoding prefix}}
+void operator "x" "y" U"z" ""_whoops "z" "y"(char); // expected-error {{must be '""'}}
+
+void f() {
+ 'a'_x;
+ 'b'_y;
+ 'c'_z;
+ 'd'_whoops;
+}
+
+template<typename ...Ts> struct MisplacedEllipsis {
+ int a(Ts ...(x)); // expected-error {{'...' must immediately precede declared identifier}}
+ int b(Ts ...&x); // expected-error {{'...' must immediately precede declared identifier}}
+ int c(Ts ...&); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int d(Ts ...(...&...)); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int e(Ts ...*[]); // expected-error {{'...' must be innermost component of anonymous pack declaration}}
+ int f(Ts ...(...*)()); // expected-error 2{{'...' must be innermost component of anonymous pack declaration}}
+ int g(Ts ...()); // ok
+};
+namespace TestMisplacedEllipsisRecovery {
+ MisplacedEllipsis<int, char> me;
+ int i; char k;
+ int *ip; char *kp;
+ int ifn(); char kfn();
+ int a = me.a(i, k);
+ int b = me.b(i, k);
+ int c = me.c(i, k);
+ int d = me.d(i, k);
+ int e = me.e(&ip, &kp);
+ int f = me.f(ifn, kfn);
+ int g = me.g(ifn, kfn);
+}
+
+template<template<typename> ...Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<template<template<typename>>>> // expected-error 3 {{template template parameter requires 'class' after the parameter list}}
+void func();
+
+template<int *ip> struct IP { }; // expected-note{{declared here}}
+IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
+
diff --git a/test/FixIt/fixit-cxx11-compat.cpp b/test/FixIt/fixit-cxx11-compat.cpp
new file mode 100644
index 0000000..39ae439
--- /dev/null
+++ b/test/FixIt/fixit-cxx11-compat.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -Wc++11-compat -verify -std=c++98 %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -Wc++11-compat -Werror -x c++ -std=c++98 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic-errors -Wc++11-compat -Werror -x c++ -std=c++98 %t
+
+// This is a test of the code modification hints for C++11-compatibility problems.
+
+#define bar "bar"
+const char *p = "foo"bar; // expected-warning {{will be treated as a reserved user-defined literal suffix}}
+#define _bar "_bar"
+const char *q = "foo"_bar; // expected-warning {{will be treated as a user-defined literal suffix}}
diff --git a/test/FixIt/fixit-missing-method-return-type.m b/test/FixIt/fixit-missing-method-return-type.m
index 027c895..769fbe8 100644
--- a/test/FixIt/fixit-missing-method-return-type.m
+++ b/test/FixIt/fixit-missing-method-return-type.m
@@ -1,12 +1,12 @@
// Objective-C recovery
// RUN: cp %s %t
-// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c -Wno-objc-root-class %t
// Objective-C++ recovery
// RUN: cp %s %t
-// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ -Wno-objc-root-class %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ -Wno-objc-root-class %t
// rdar://9615045
@interface I
diff --git a/test/FixIt/fixit-recompile.c b/test/FixIt/fixit-recompile.c
new file mode 100644
index 0000000..a2e62fb
--- /dev/null
+++ b/test/FixIt/fixit-recompile.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -E -o - | FileCheck %s
+// RUN: not %clang_cc1 -Werror -pedantic %s -fixit-recompile -fixit-to-temporary -fix-only-warnings
+
+_Complex cd;
+
+// CHECK: _Complex double cd;
diff --git a/test/FixIt/fixit-recursive-block.c b/test/FixIt/fixit-recursive-block.c
new file mode 100644
index 0000000..b276b41
--- /dev/null
+++ b/test/FixIt/fixit-recursive-block.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wuninitialized -fblocks -verify %s
+
+// rdar://10817031
+
+int main() {
+ void (^arc_fail)() = ^() { // expected-warning {{block pointer variable 'arc_fail' is uninitialized when captured by block}} \
+ // expected-note {{maybe you meant to use __block 'arc_fail'}}
+ arc_fail(); // BOOM
+ };
+}
+// CHECK: {7:12-7:12}:"__block "
diff --git a/test/FixIt/fixit-vexing-parse-cxx0x.cpp b/test/FixIt/fixit-vexing-parse-cxx0x.cpp
new file mode 100644
index 0000000..a870794
--- /dev/null
+++ b/test/FixIt/fixit-vexing-parse-cxx0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -verify -x c++ -std=c++11 %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
+
+struct X {
+ int i;
+};
+
+void func() {
+ // CHECK: fix-it:"{{.*}}":{10:6-10:8}:"{}"
+ X x(); // expected-warning {{function declaration}} expected-note{{replace parentheses with an initializer}}
+
+ typedef int *Ptr;
+ // CHECK: fix-it:"{{.*}}":{14:8-14:10}:" = nullptr"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{17:15-17:17}:" = u'\\0'"
+ char16_t u16(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{20:15-20:17}:" = U'\\0'"
+ char32_t u32(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+}
diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp
new file mode 100644
index 0000000..8450590
--- /dev/null
+++ b/test/FixIt/fixit-vexing-parse.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -verify -x c++ %s
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s
+
+struct S {
+ int n;
+};
+
+struct T {
+ T();
+ int n;
+};
+
+struct U {
+ ~U();
+ int n;
+};
+
+struct V {
+ ~V();
+};
+
+struct W : V {
+};
+
+struct X : U {
+};
+
+int F1();
+S F2();
+
+namespace N {
+ void test() {
+ // CHECK: fix-it:"{{.*}}":{34:9-34:11}:" = {}"
+ S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{38:9-38:10}:";"
+ // CHECK: fix-it:"{{.*}}":{39:7-39:9}:" = {}"
+ S s2, // expected-note {{change this ',' to a ';' to call 'F2'}}
+ F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{43:9-43:11}:""
+ // CHECK: fix-it:"{{.*}}":{44:9-44:11}:""
+ T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+ t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // CHECK: fix-it:"{{.*}}":{47:8-47:10}:" = {}"
+ U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{50:8-50:10}:""
+ V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // CHECK: fix-it:"{{.*}}":{53:8-53:10}:""
+ W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}}
+
+ // TODO: Removing the parens here would not initialize U::n.
+ // Maybe suggest an " = X()" initializer for this case?
+ // Maybe suggest removing the parens anyway?
+ X x(); // expected-warning {{function declaration}}
+
+ // CHECK: fix-it:"{{.*}}":{61:11-61:13}:" = 0"
+ int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{65:11-65:12}:";"
+ // CHECK: fix-it:"{{.*}}":{66:7-66:9}:" = 0"
+ int n2, // expected-note {{change this ',' to a ';' to call 'F1'}}
+ F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{69:13-69:15}:" = 0.0"
+ double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ typedef void *Ptr;
+
+ // CHECK: fix-it:"{{.*}}":{74:10-74:12}:" = 0"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+#define NULL 0
+ // CHECK: fix-it:"{{.*}}":{78:10-78:12}:" = NULL"
+ Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false"
+ bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'"
+ char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'"
+ wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+ }
+}
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index 5ba0aac..5e4947b 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -pedantic -Wunused-label -verify -x c %s
// RUN: cp %s %t
// RUN: not %clang_cc1 -pedantic -Wunused-label -fixit -x c %t
// RUN: grep -v CHECK %t > %t2
@@ -12,22 +13,24 @@
// FIXME: FIX-IT should add #include <string.h>?
int strcmp(const char *s1, const char *s2);
-void f0(void) { };
+void f0(void) { }; // expected-warning {{';'}}
struct s {
- int x, y;;
+ int x, y;; // expected-warning {{extra ';'}}
};
// CHECK: _Complex double cd;
-_Complex cd;
+_Complex cd; // expected-warning {{assuming '_Complex double'}}
// CHECK: struct s s0 = { .y = 5 };
-struct s s0 = { y: 5 };
+struct s s0 = { y: 5 }; // expected-warning {{GNU old-style}}
// CHECK: int array0[5] = { [3] = 3 };
-int array0[5] = { [3] 3 };
+int array0[5] = { [3] 3 }; // expected-warning {{GNU 'missing ='}}
-void f1(x, y)
+// CHECK: int x
+// CHECK: int y
+void f1(x, y) // expected-warning 2{{defaulting to type 'int'}}
{
}
@@ -36,16 +39,16 @@ int i0 = { 17 };
#define ONE 1
#define TWO 2
-int test_cond(int y, int fooBar) {
+int test_cond(int y, int fooBar) { // expected-note {{here}}
// CHECK: int x = y ? 1 : 4+fooBar;
- int x = y ? 1 4+foobar;
+ int x = y ? 1 4+foobar; // expected-error {{expected ':'}} expected-error {{undeclared identifier}} expected-note {{to match}}
// CHECK: x = y ? ONE : TWO;
- x = y ? ONE TWO;
+ x = y ? ONE TWO; // expected-error {{':'}} expected-note {{to match}}
return x;
}
-// CHECK: typedef int int_t;
-typedef typedef int int_t;
+// CHECK: const typedef int int_t;
+const typedef typedef int int_t; // expected-warning {{duplicate 'typedef'}}
// <rdar://problem/7159693>
enum Color {
@@ -61,12 +64,39 @@ struct test_struct {
};
void removeUnusedLabels(char c) {
- L0 /*removed comment*/: c++;
+ L0 /*removed comment*/: c++; // expected-warning {{unused label}}
removeUnusedLabels(c);
- L1:
+ L1: // expected-warning {{unused label}}
c++;
- /*preserved comment*/ L2 : c++;
- LL
+ /*preserved comment*/ L2 : c++; // expected-warning {{unused label}}
+ LL // expected-warning {{unused label}}
: c++;
- c = c + 3; L4: return;
+ c = c + 3; L4: return; // expected-warning {{unused label}}
+}
+
+int oopsAComma = 0, // expected-error {{';'}}
+void oopsMoreCommas() {
+ static int a[] = { 0, 1, 2 }, // expected-error {{';'}}
+ static int b[] = { 3, 4, 5 }, // expected-error {{';'}}
+ &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
+}
+
+int noSemiAfterLabel(int n) {
+ switch (n) {
+ default:
+ return n % 4;
+ case 0:
+ case 1:
+ case 2:
+ // CHECK: /*FOO*/ case 3: ;
+ /*FOO*/ case 3: // expected-error {{expected statement}}
+ }
+ switch (n) {
+ case 1:
+ case 2:
+ return 0;
+ // CHECK: /*BAR*/ default: ;
+ /*BAR*/ default: // expected-error {{expected statement}}
+ }
+ return 1;
}
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index 785b92b..7d531a5 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -1,6 +1,7 @@
+// RUN: %clang_cc1 -pedantic -Wall -Wno-comment -verify -fcxx-exceptions -x c++ %s
// RUN: cp %s %t
-// RUN: not %clang_cc1 -pedantic -Wall -fixit -x c++ %t
-// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ %t
+// RUN: not %clang_cc1 -pedantic -Wall -Wno-comment -fcxx-exceptions -fixit -x c++ %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -Wno-comment -fcxx-exceptions -x c++ %t
/* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
@@ -28,7 +29,7 @@ public:
struct CT<0> { }; // expected-error{{'template<>'}}
-template<> class CT<1> { }; // expected-error{{tag type}}
+template<> union CT<1> { }; // expected-error{{tag type}}
// Access declarations
class A {
@@ -40,7 +41,7 @@ class B : public A {
A::foo; // expected-warning{{access declarations are deprecated}}
};
-void f() throw();
+void f() throw(); // expected-note{{previous}}
void f(); // expected-warning{{missing exception specification}}
namespace rdar7853795 {
@@ -63,18 +64,72 @@ namespace rdar7796492 {
// extra qualification on member
class C {
- int C::foo();
+ int C::foo(); // expected-warning {{extra qualification}}
};
namespace rdar8488464 {
-int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+int x = 0;
+int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
void f() {
- int x == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+ int x = 0;
(void)x;
- if (int x == 0) { // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
- (void)x;
- }
+ int x1 &= 0; // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ (void)x1;
+ int x2 *= 0; // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ (void)x2;
+ int x3 += 0; // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ (void)x3;
+ int x4 -= 0; // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ (void)x4;
+ int x5 != 0; // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ (void)x5;
+ int x6 /= 0; // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ (void)x6;
+ int x7 %= 0; // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ (void)x7;
+ int x8 <= 0; // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ (void)x8;
+ int x9 <<= 0; // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ (void)x9;
+ int x10 >= 0; // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ (void)x10;
+ int x11 >>= 0; // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ (void)x11;
+ int x12 ^= 0; // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ (void)x12;
+ int x13 |= 0; // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ (void)x13;
+ int x14 == 0; // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
+ (void)x14;
+ if (int x = 0) { (void)x; }
+ if (int x1 &= 0) { (void)x1; } // expected-error {{invalid '&=' at end of declaration; did you mean '='?}}
+ if (int x2 *= 0) { (void)x2; } // expected-error {{invalid '*=' at end of declaration; did you mean '='?}}
+ if (int x3 += 0) { (void)x3; } // expected-error {{invalid '+=' at end of declaration; did you mean '='?}}
+ if (int x4 -= 0) { (void)x4; } // expected-error {{invalid '-=' at end of declaration; did you mean '='?}}
+ if (int x5 != 0) { (void)x5; } // expected-error {{invalid '!=' at end of declaration; did you mean '='?}}
+ if (int x6 /= 0) { (void)x6; } // expected-error {{invalid '/=' at end of declaration; did you mean '='?}}
+ if (int x7 %= 0) { (void)x7; } // expected-error {{invalid '%=' at end of declaration; did you mean '='?}}
+ if (int x8 <= 0) { (void)x8; } // expected-error {{invalid '<=' at end of declaration; did you mean '='?}}
+ if (int x9 <<= 0) { (void)x9; } // expected-error {{invalid '<<=' at end of declaration; did you mean '='?}}
+ if (int x10 >= 0) { (void)x10; } // expected-error {{invalid '>=' at end of declaration; did you mean '='?}}
+ if (int x11 >>= 0) { (void)x11; } // expected-error {{invalid '>>=' at end of declaration; did you mean '='?}}
+ if (int x12 ^= 0) { (void)x12; } // expected-error {{invalid '^=' at end of declaration; did you mean '='?}}
+ if (int x13 |= 0) { (void)x13; } // expected-error {{invalid '|=' at end of declaration; did you mean '='?}}
+ if (int x14 == 0) { (void)x14; } // expected-error {{invalid '==' at end of declaration; did you mean '='?}}
}
}
@@ -104,7 +159,48 @@ void test (BD &br) {
AD* aPtr;
BD b;
aPtr = b; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
- aPtr = br; // expected-error {{assigning to 'A *' from incompatible type 'B'; take the address with &}}
+ aPtr = br; // expected-error {{assigning to 'AD *' from incompatible type 'BD'; take the address with &}}
+}
+
+void foo1() const {} // expected-error {{non-member function cannot have 'const' qualifier}}
+void foo2() volatile {} // expected-error {{non-member function cannot have 'volatile' qualifier}}
+void foo3() const volatile {} // expected-error {{non-member function cannot have 'const volatile' qualifier}}
+
+struct S { void f(int, char); };
+int itsAComma,
+itsAComma2 = 0,
+oopsAComma(42), // expected-error {{expected ';' at end of declaration}}
+AD oopsMoreCommas() {
+ static int n = 0, // expected-error {{expected ';' at end of declaration}}
+ static char c,
+ &d = c, // expected-error {{expected ';' at end of declaration}}
+ S s, // expected-error {{expected ';' at end of declaration}}
+ s.f(n, d);
+ AD ad, // expected-error {{expected ';' at end of declaration}}
+ return ad;
}
+struct MoreAccidentalCommas {
+ int a : 5,
+ b : 7,
+ : 4, // expected-error {{expected ';' at end of declaration}}
+ char c, // expected-error {{expected ';' at end of declaration}}
+ double d, // expected-error {{expected ';' at end of declaration}}
+ MoreAccidentalCommas *next, // expected-error {{expected ';' at end of declaration}}
+public:
+ int k, // expected-error {{expected ';' at end of declaration}}
+ friend void f(MoreAccidentalCommas) {}
+ int k2, // expected-error {{expected ';' at end of declaration}}
+ virtual void g(), // expected-error {{expected ';' at end of declaration}}
+};
+template<class T> struct Mystery;
+template<class T> typedef Mystery<T>::type getMysteriousThing() { // \
+ expected-error {{function definition declared 'typedef'}} \
+ expected-error {{missing 'typename' prior to dependent}}
+ return Mystery<T>::get();
+}
+template<template<typename> Foo, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}}
+ template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}}
+void func();
diff --git a/test/FixIt/no-fixit.cpp b/test/FixIt/no-fixit.cpp
new file mode 100644
index 0000000..c95c867
--- /dev/null
+++ b/test/FixIt/no-fixit.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++11 %s 2>&1 | FileCheck %s
+
+// test that the diagnostics produced by this code do not include fixit hints
+
+// CHECK-NOT: fix-it:
+
+template<template<typename> +> void func();
diff --git a/test/FixIt/objc-literals.m b/test/FixIt/objc-literals.m
new file mode 100644
index 0000000..03d64b1
--- /dev/null
+++ b/test/FixIt/objc-literals.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t
+// RUN: grep arrayWithObjects %t
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+void fixes() {
+ id arr = @[
+ 17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}
+ 'a', // expected-error{{character literal must be prefixed by '@'}}
+ "blah" // expected-error{{string literal must be prefixed by '@'}}
+ ];
+}
diff --git a/test/FixIt/typo-crash.cpp b/test/FixIt/typo-crash.cpp
index 92d2037..c154e3b 100644
--- a/test/FixIt/typo-crash.cpp
+++ b/test/FixIt/typo-crash.cpp
@@ -10,3 +10,20 @@ template<typename T> void template_id1() { // expected-note {{'template_id1' dec
// expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} \
// expected-error {{use of undeclared identifier 't'}}
}
+
+// FIXME: It would be nice if we could get this correction right.
+namespace PR12297 {
+ namespace A {
+ typedef short T;
+
+ namespace B {
+ typedef short T;
+
+ T global(); // expected-note {{'A::B::global' declared here}}
+ }
+ }
+
+ using namespace A::B;
+
+ T A::global(); // expected-error {{out-of-line definition of 'global' does not match any declaration in namespace 'PR12297::A'; did you mean 'A::B::global'?}}
+}
diff --git a/test/FixIt/typo.c b/test/FixIt/typo.c
index 88d9dc6..0bafd1b 100644
--- a/test/FixIt/typo.c
+++ b/test/FixIt/typo.c
@@ -30,7 +30,7 @@ void test() {
r1.top_left.x = 0;
typedef struct Rectangle Rectangle; // expected-note{{'Rectangle' declared here}}
- rectangle *r2 = &r1; // expected-error{{ unknown type name 'rectangle'; did you mean 'Rectangle'?}}
+ rectangle *r2 = &r1; // expected-error{{unknown type name 'rectangle'; did you mean 'Rectangle'?}}
r2->top_left.y = 0;
unsinged *ptr = 0; // expected-error{{use of undeclared identifier 'unsinged'; did you mean 'unsigned'?}}
*ptr = 17;
diff --git a/test/FixIt/typo.m b/test/FixIt/typo.m
index a474035..381233f 100644
--- a/test/FixIt/typo.m
+++ b/test/FixIt/typo.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -DNON_FIXITS -verify -Wno-objc-root-class %s
// RUN: cp %s %t
-// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit %t
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror %t
+// RUN: not %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -fixit -Wno-objc-root-class %t
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -triple x86_64-apple-darwin10 -pedantic -Werror -Wno-objc-root-class %t
// RUN: grep "@implementation Sub3" %t
@interface NSString // expected-note 2{{'NSString' declared here}}
diff --git a/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h b/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h
new file mode 100644
index 0000000..49048ca
--- /dev/null
+++ b/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h
@@ -0,0 +1 @@
+static int f0(void) {}
diff --git a/test/Frontend/Wno-everything.c b/test/Frontend/Wno-everything.c
new file mode 100644
index 0000000..ca70ca4
--- /dev/null
+++ b/test/Frontend/Wno-everything.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify -Wno-everything -Wsign-compare %s
+
+int f0(int, unsigned);
+int f0(int x, unsigned y) {
+ if (x=3);
+ return x < y; // expected-warning {{comparison of integers}}
+}
diff --git a/test/Frontend/darwin-version.c b/test/Frontend/darwin-version.c
index 151d3a9f..f9ce54b 100644
--- a/test/Frontend/darwin-version.c
+++ b/test/Frontend/darwin-version.c
@@ -1,25 +1,25 @@
-// RUN: %clang -ccc-host-triple armv6-apple-darwin9 -dM -E -o %t %s
+// RUN: %clang -target armv6-apple-darwin9 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
-// RUN: %clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=3.0 -dM -E -o %t %s
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '30000' | count 1
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0
-// RUN: %clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20000' | count 1
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0
-// RUN: %clang -ccc-host-triple armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t %s
+// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20200' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin8 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin8 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin9 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin9 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin10 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin10 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1
-// RUN: %clang -ccc-host-triple i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s
+// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s
// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1
diff --git a/test/Frontend/dependency-gen.c b/test/Frontend/dependency-gen.c
index 49d3f28..5883ec5 100644
--- a/test/Frontend/dependency-gen.c
+++ b/test/Frontend/dependency-gen.c
@@ -5,7 +5,7 @@
// RUN: echo > %t.dir/a/b/x.h
// RUN: cd %t.dir
// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s
-// CHECK-ONE: {{ }}a/b/x.h
+// CHECK-ONE: {{ }}a/b{{[/\\]}}x.h
// PR8974 (-include flag)
// RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s
@@ -13,11 +13,11 @@
// rdar://problem/9734352 (paths involving ".")
// RUN: %clang -MD -MF - %s -fsyntax-only -I ./a/b | FileCheck -check-prefix=CHECK-THREE %s
-// CHECK-THREE: {{ }}a/b/x.h
+// CHECK-THREE: {{ }}a/b{{[/\\]}}x.h
// RUN: %clang -MD -MF - %s -fsyntax-only -I .//./a/b/ | FileCheck -check-prefix=CHECK-FOUR %s
-// CHECK-FOUR: {{ }}a/b/x.h
+// CHECK-FOUR: {{ }}a/b{{[/\\]}}x.h
// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b/. | FileCheck -check-prefix=CHECK-FIVE %s
-// CHECK-FIVE: {{ }}a/b/./x.h
+// CHECK-FIVE: {{ }}a/b/.{{[/\\]}}x.h
// RUN: cd a/b
// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s
// CHECK-SIX: {{ }}x.h
diff --git a/test/Frontend/diagnostic-name.c b/test/Frontend/diagnostic-name.c
deleted file mode 100644
index ae6cb0d..0000000
--- a/test/Frontend/diagnostic-name.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang -fsyntax-only -Wunused-parameter -fdiagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 1
-// RUN: %clang -fsyntax-only -Wunused-parameter -fno-diagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 0
-int main(int argc, char *argv[]) {
- return argc;
-}
diff --git a/test/Frontend/iframework.c b/test/Frontend/iframework.c
new file mode 100644
index 0000000..0c241fd
--- /dev/null
+++ b/test/Frontend/iframework.c
@@ -0,0 +1,3 @@
+// RUN: %clang -fsyntax-only -iframework%S/Inputs %s -Xclang -verify
+
+#include <TestFramework/TestFramework.h>
diff --git a/test/Frontend/ir-support-errors.ll b/test/Frontend/ir-support-errors.ll
index 98227d4..cb5913c 100644
--- a/test/Frontend/ir-support-errors.ll
+++ b/test/Frontend/ir-support-errors.ll
@@ -3,6 +3,6 @@
target triple = "x86_64-apple-darwin10"
define i32 @f0() nounwind ssp {
-; CHECK: {{.*}}ir-support-errors.ll:7:16: error: expected value token
- ret i32 x
+; CHECK: {{.*}}ir-support-errors.ll:7:16: error: use of undefined value '%x'
+ ret i32 %x
}
diff --git a/test/Frontend/rewrite-macros.c b/test/Frontend/rewrite-macros.c
index f44e545..bc74796 100644
--- a/test/Frontend/rewrite-macros.c
+++ b/test/Frontend/rewrite-macros.c
@@ -9,7 +9,7 @@ A(1,2)
_Pragma("mark")
// RUN: grep "//#warning eek" %t
-/* expected-warning {{#warning eek}} */ #warning eek
+/* expected-warning {{eek}} */ #warning eek
// RUN: grep "//#pragma mark mark" %t
#pragma mark mark
diff --git a/test/Headers/c89.c b/test/Headers/c89.c
index 9e01ff9..eea8d44 100644
--- a/test/Headers/c89.c
+++ b/test/Headers/c89.c
@@ -1,4 +1,4 @@
-// RUN: %clang -ccc-host-triple i386-apple-darwin10 -fsyntax-only -Xclang -verify -std=c89 %s
+// RUN: %clang -target i386-apple-darwin10 -fsyntax-only -Xclang -verify -std=c89 %s
// FIXME: Disable inclusion of mm_malloc.h, our current implementation is broken
// on win32 since we don't generally know how to find errno.h.
diff --git a/test/Headers/wmmintrin.c b/test/Headers/wmmintrin.c
new file mode 100644
index 0000000..6aa8be4
--- /dev/null
+++ b/test/Headers/wmmintrin.c
@@ -0,0 +1,4 @@
+// Check that wmmintrin.h is includable with just -maes.
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -verify %s -ffreestanding -target-feature +aes
+#include <wmmintrin.h>
diff --git a/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h b/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h
new file mode 100644
index 0000000..3e3830a
--- /dev/null
+++ b/test/Index/Inputs/Frameworks/Framework.framework/Headers/Framework.h
@@ -0,0 +1,2 @@
+int *getFrameworkVersion();
+
diff --git a/test/Index/Inputs/Headers/a.h b/test/Index/Inputs/Headers/a.h
new file mode 100644
index 0000000..33c3417
--- /dev/null
+++ b/test/Index/Inputs/Headers/a.h
@@ -0,0 +1,2 @@
+int *getA();
+
diff --git a/test/Index/Inputs/Headers/a_extensions.h b/test/Index/Inputs/Headers/a_extensions.h
new file mode 100644
index 0000000..2155787
--- /dev/null
+++ b/test/Index/Inputs/Headers/a_extensions.h
@@ -0,0 +1 @@
+int *getAExtensions();
diff --git a/test/Index/Inputs/Headers/crash.h b/test/Index/Inputs/Headers/crash.h
new file mode 100644
index 0000000..238359a
--- /dev/null
+++ b/test/Index/Inputs/Headers/crash.h
@@ -0,0 +1,6 @@
+// Produce a crash if CRASH is defined.
+#ifdef CRASH
+# pragma clang __debug crash
+#endif
+
+const char *getCrashString();
diff --git a/test/Index/Inputs/Headers/module.map b/test/Index/Inputs/Headers/module.map
new file mode 100644
index 0000000..55f8eb7
--- /dev/null
+++ b/test/Index/Inputs/Headers/module.map
@@ -0,0 +1,10 @@
+module LibA {
+ header "a.h"
+ module Extensions {
+ header "a_extensions.h"
+ }
+}
+
+module Crash {
+ header "crash.h"
+}
diff --git a/test/Index/Inputs/Headers/nested/module.map b/test/Index/Inputs/Headers/nested/module.map
new file mode 100644
index 0000000..bd239f1
--- /dev/null
+++ b/test/Index/Inputs/Headers/nested/module.map
@@ -0,0 +1,4 @@
+module nested {
+ header "nested.h"
+}
+
diff --git a/test/Index/Inputs/Headers/nested/nested.h b/test/Index/Inputs/Headers/nested/nested.h
new file mode 100644
index 0000000..01716d1
--- /dev/null
+++ b/test/Index/Inputs/Headers/nested/nested.h
@@ -0,0 +1 @@
+int *getNested();
diff --git a/test/Index/Inputs/pragma_disable_warning.h b/test/Index/Inputs/pragma_disable_warning.h
new file mode 100644
index 0000000..b40e9e7
--- /dev/null
+++ b/test/Index/Inputs/pragma_disable_warning.h
@@ -0,0 +1 @@
+#pragma clang diagnostic ignored "-Wunused-parameter"
diff --git a/test/Index/Inputs/redeclarations.h b/test/Index/Inputs/redeclarations.h
new file mode 100644
index 0000000..7f0d7ae
--- /dev/null
+++ b/test/Index/Inputs/redeclarations.h
@@ -0,0 +1,21 @@
+class X
+{
+ friend class A;
+};
+
+
+template <typename T1, typename T2>
+class B
+{
+};
+
+template <class T>
+struct C
+{
+};
+
+class D
+{
+ B<D, class A> x;
+ friend struct C<A>;
+};
diff --git a/test/Index/Inputs/reparse-instantiate.h b/test/Index/Inputs/reparse-instantiate.h
new file mode 100644
index 0000000..df90a6d
--- /dev/null
+++ b/test/Index/Inputs/reparse-instantiate.h
@@ -0,0 +1,14 @@
+template <typename T> struct S;
+
+template<typename T> void c(T)
+{
+}
+
+template <> struct S <int>
+{
+ void a()
+ {
+ c(&S<int>::b);
+ }
+ void b() {}
+};
diff --git a/test/Index/TestClassDecl.m b/test/Index/TestClassDecl.m
index e94a5c1..038353b 100644
--- a/test/Index/TestClassDecl.m
+++ b/test/Index/TestClassDecl.m
@@ -16,7 +16,7 @@ void function(Foo * arg)
}
// CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=[10:12]
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
// CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:10:12
// CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
// CHECK-scan: [10:1 - 11:5] ObjCInterfaceDecl=Foo:10:12
diff --git a/test/Index/TestClassForwardDecl.m b/test/Index/TestClassForwardDecl.m
index d3d720c..2f32d33 100644
--- a/test/Index/TestClassForwardDecl.m
+++ b/test/Index/TestClassForwardDecl.m
@@ -13,7 +13,7 @@ void function(Foo * arg)
}
// CHECK-scan: [1:1 - 8:1] Invalid Cursor => NoDeclFound
-// CHECK-scan: [8:1 - 8:8] UnexposedDecl=[8:8]
+// CHECK-scan: [8:1 - 8:8] ObjCInterfaceDecl=Foo:8:8
// CHECK-scan: [8:8 - 8:11] ObjCClassRef=Foo:8:8
// CHECK-scan: [8:11 - 10:1] Invalid Cursor => NoDeclFound
// CHECK-scan: [10:1 - 10:15] FunctionDecl=function:10:6 (Definition)
diff --git a/test/Index/annotate-attribute.cpp b/test/Index/annotate-attribute.cpp
index 6721371..d822210 100644
--- a/test/Index/annotate-attribute.cpp
+++ b/test/Index/annotate-attribute.cpp
@@ -17,17 +17,17 @@ protected:
};
// CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
-// CHECK: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
-// CHECK: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
-// CHECK: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43]
-// CHECK: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43]
-// CHECK: attribute(annotate)=works Extent=[7:23 - 7:40]
-// CHECK: CXXMethod=anotherMethod:8:8 Extent=[8:3 - 8:23]
-// CHECK: attribute(annotate)=works Extent=[7:23 - 7:40]
-// CHECK: CXXAccessSpecifier=:10:1 (Definition) Extent=[10:1 - 10:53]
-// CHECK: attribute(annotate)=investigations Extent=[10:24 - 10:50]
-// CHECK: CXXMethod=inlineMethod:12:8 (Definition) Extent=[12:3 - 12:25]
-// CHECK: attribute(annotate)=investigations Extent=[10:24 - 10:50]
-// CHECK: CompoundStmt= Extent=[12:23 - 12:25]
-// CHECK: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
-// CHECK: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
+// CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
+// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
+// CHECK-NEXT: attribute(annotate)=spiffy_method Extent=[5:18 - 5:43]
+// CHECK-NEXT: CXXAccessSpecifier=:7:1 (Definition) Extent=[7:1 - 7:43]
+// CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
+// CHECK-NEXT: CXXMethod=anotherMethod:8:8 Extent=[8:3 - 8:23]
+// CHECK-NEXT: attribute(annotate)=works Extent=[7:23 - 7:40]
+// CHECK-NEXT: CXXAccessSpecifier=:10:1 (Definition) Extent=[10:1 - 10:53]
+// CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
+// CHECK-NEXT: CXXMethod=inlineMethod:12:8 (Definition) Extent=[12:3 - 12:25]
+// CHECK-NEXT: attribute(annotate)=investigations Extent=[10:24 - 10:50]
+// CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
+// CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
+// CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
diff --git a/test/Index/annotate-literals.m b/test/Index/annotate-literals.m
new file mode 100644
index 0000000..20bfd2c
--- /dev/null
+++ b/test/Index/annotate-literals.m
@@ -0,0 +1,72 @@
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+void test_literals(id k1, id o1, id k2, id o2, id k3) {
+ id objects = @[ o1, o2 ];
+ id dict = @{ k1 : o1,
+ k2 : o2,
+ k3 : @17 };
+}
+
+
+// RUN: c-index-test -test-annotate-tokens=%s:33:1:37:1 %s | FileCheck -check-prefix=CHECK-LITERALS %s
+
+// CHECK-LITERALS: Identifier: "id" [33:3 - 33:5] TypeRef=id:0:0
+// CHECK-LITERALS: Identifier: "objects" [33:6 - 33:13] VarDecl=objects:33:6 (Definition)
+// CHECK-LITERALS: Punctuation: "=" [33:14 - 33:15] VarDecl=objects:33:6 (Definition)
+// CHECK-LITERALS: Punctuation: "@" [33:16 - 33:17] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "[" [33:17 - 33:18] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o1" [33:19 - 33:21] DeclRefExpr=o1:32:30
+// CHECK-LITERALS: Punctuation: "," [33:21 - 33:22] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o2" [33:23 - 33:25] DeclRefExpr=o2:32:44
+// CHECK-LITERALS: Punctuation: "]" [33:26 - 33:27] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: ";" [33:27 - 33:28] DeclStmt=
+// CHECK-LITERALS: Identifier: "id" [34:3 - 34:5] TypeRef=id:0:0
+// CHECK-LITERALS: Identifier: "dict" [34:6 - 34:10] VarDecl=dict:34:6 (Definition)
+// CHECK-LITERALS: Punctuation: "=" [34:11 - 34:12] VarDecl=dict:34:6 (Definition)
+// CHECK-LITERALS: Punctuation: "@" [34:13 - 34:14] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "{" [34:14 - 34:15] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k1" [34:16 - 34:18] DeclRefExpr=k1:32:23
+// CHECK-LITERALS: Punctuation: ":" [34:19 - 34:20] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o1" [34:21 - 34:23] DeclRefExpr=o1:32:30
+// CHECK-LITERALS: Punctuation: "," [34:23 - 34:24] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k2" [35:16 - 35:18] DeclRefExpr=k2:32:37
+// CHECK-LITERALS: Punctuation: ":" [35:19 - 35:20] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "o2" [35:21 - 35:23] DeclRefExpr=o2:32:44
+// CHECK-LITERALS: Punctuation: "," [35:23 - 35:24] UnexposedExpr=
+// CHECK-LITERALS: Identifier: "k3" [36:16 - 36:18] DeclRefExpr=k3:32:51
+// CHECK-LITERALS: Punctuation: ":" [36:19 - 36:20] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: "@" [36:21 - 36:22] UnexposedExpr=
+// CHECK-LITERALS: Literal: "17" [36:22 - 36:24] IntegerLiteral=
+// CHECK-LITERALS: Punctuation: "}" [36:25 - 36:26] UnexposedExpr=
+// CHECK-LITERALS: Punctuation: ";" [36:26 - 36:27] DeclStmt=
+// CHECK-LITERALS: Punctuation: "}" [37:1 - 37:2] CompoundStmt=
+
diff --git a/test/Index/annotate-macro-args.m b/test/Index/annotate-macro-args.m
index 6adfb8d..b92c0b2 100644
--- a/test/Index/annotate-macro-args.m
+++ b/test/Index/annotate-macro-args.m
@@ -9,15 +9,15 @@
// CHECK1: Identifier: "MACRO" [9:3 - 9:8] macro expansion=MACRO:6:9
// CHECK1: Punctuation: "(" [9:8 - 9:9]
-// CHECK1: Punctuation: "[" [9:9 - 9:10] ObjCMessageExpr=meth:2:1
+// CHECK1: Punctuation: "[" [9:9 - 9:10] ObjCMessageExpr=meth:2:8
// CHECK1: Identifier: "MyClass" [9:10 - 9:17] ObjCClassRef=MyClass:1:12
-// CHECK1: Identifier: "meth" [9:18 - 9:22] ObjCMessageExpr=meth:2:1
-// CHECK1: Punctuation: "]" [9:22 - 9:23] ObjCMessageExpr=meth:2:1
+// CHECK1: Identifier: "meth" [9:18 - 9:22] ObjCMessageExpr=meth:2:8
+// CHECK1: Punctuation: "]" [9:22 - 9:23] ObjCMessageExpr=meth:2:8
// CHECK1: Punctuation: ")" [9:23 - 9:24]
// CHECK2: Identifier: "INVOKE" [15:3 - 15:9] macro expansion=INVOKE:12:9
// CHECK2: Punctuation: "(" [15:9 - 15:10]
-// CHECK2: Identifier: "meth" [15:10 - 15:14] ObjCMessageExpr=meth:2:1
+// CHECK2: Identifier: "meth" [15:10 - 15:14] ObjCMessageExpr=meth:2:8
// CHECK2: Punctuation: "," [15:14 - 15:15]
// CHECK2: Identifier: "MyClass" [15:16 - 15:23] ObjCClassRef=MyClass:1:12
// CHECK2: Punctuation: ")" [15:23 - 15:24]
diff --git a/test/Index/annotate-subscripting.m b/test/Index/annotate-subscripting.m
new file mode 100644
index 0000000..cda1465
--- /dev/null
+++ b/test/Index/annotate-subscripting.m
@@ -0,0 +1,92 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+id testArray(int index, id p) {
+ NSMutableArray *array;
+ array[3] = 0;
+ NSArray *arr = @[ p, p ];
+ return array[index];
+}
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:22:1:36:1 -target x86_64-apple-macosx10.7 %s | FileCheck %s
+// CHECK: Identifier: "array" [24:3 - 24:8] DeclRefExpr=array:23:19
+// CHECK: Punctuation: "[" [24:8 - 24:9] UnexposedExpr=
+// CHECK: Literal: "3" [24:9 - 24:10] IntegerLiteral=
+// CHECK: Punctuation: "]" [24:10 - 24:11] UnexposedExpr=
+// CHECK: Punctuation: "=" [24:12 - 24:13] BinaryOperator=
+// CHECK: Literal: "0" [24:14 - 24:15] IntegerLiteral=
+// CHECK: Punctuation: ";" [24:15 - 24:16] CompoundStmt=
+// CHECK: Identifier: "NSArray" [25:3 - 25:10] ObjCClassRef=NSArray:1:12
+// CHECK: Punctuation: "*" [25:11 - 25:12] VarDecl=arr:25:12 (Definition)
+// CHECK: Identifier: "arr" [25:12 - 25:15] VarDecl=arr:25:12 (Definition)
+// CHECK: Punctuation: "=" [25:16 - 25:17] VarDecl=arr:25:12 (Definition)
+// CHECK: Punctuation: "@" [25:18 - 25:19] UnexposedExpr=
+// CHECK: Punctuation: "[" [25:19 - 25:20] UnexposedExpr=
+// CHECK: Identifier: "p" [25:21 - 25:22] DeclRefExpr=p:22:28
+// CHECK: Punctuation: "," [25:22 - 25:23] UnexposedExpr=
+// CHECK: Identifier: "p" [25:24 - 25:25] DeclRefExpr=p:22:28
+// CHECK: Punctuation: "]" [25:26 - 25:27] UnexposedExpr=
+// CHECK: Punctuation: ";" [25:27 - 25:28] DeclStmt=
+// CHECK: Keyword: "return" [26:3 - 26:9] ReturnStmt=
+// CHECK: Identifier: "array" [26:10 - 26:15] DeclRefExpr=array:23:19
+// CHECK: Punctuation: "[" [26:15 - 26:16] UnexposedExpr=
+// CHECK: Identifier: "index" [26:16 - 26:21] DeclRefExpr=index:22:18
+// CHECK: Punctuation: "]" [26:21 - 26:22] UnexposedExpr=
+// CHECK: Punctuation: ";" [26:22 - 26:23] CompoundStmt=
+
+// CHECK: Identifier: "oldObject" [33:3 - 33:12] DeclRefExpr=oldObject:32:17
+// CHECK: Punctuation: "=" [33:13 - 33:14] BinaryOperator=
+// CHECK: Identifier: "dictionary" [33:15 - 33:25] DeclRefExpr=dictionary:30:24
+// CHECK: Punctuation: "[" [33:25 - 33:26] UnexposedExpr=
+// CHECK: Identifier: "key" [33:26 - 33:29] DeclRefExpr=key:31:13
+// CHECK: Punctuation: "]" [33:29 - 33:30] UnexposedExpr=
+// CHECK: Punctuation: ";" [33:30 - 33:31] CompoundStmt=
+// CHECK: Identifier: "dictionary" [34:3 - 34:13] DeclRefExpr=dictionary:30:24
+// CHECK: Punctuation: "[" [34:13 - 34:14] UnexposedExpr=
+// CHECK: Identifier: "key" [34:14 - 34:17] DeclRefExpr=key:31:13
+// CHECK: Punctuation: "]" [34:17 - 34:18] UnexposedExpr=
+// CHECK: Punctuation: "=" [34:19 - 34:20] BinaryOperator=
+// CHECK: Identifier: "newObject" [34:21 - 34:30] DeclRefExpr=newObject:32:6
+// CHECK: Punctuation: ";" [34:30 - 34:31] CompoundStmt=
+// CHECK: Identifier: "NSDictionary" [35:3 - 35:15] ObjCClassRef=NSDictionary:11:12
+// CHECK: Punctuation: "*" [35:16 - 35:17] VarDecl=dict:35:17 (Definition)
+// CHECK: Identifier: "dict" [35:17 - 35:21] VarDecl=dict:35:17 (Definition)
+// CHECK: Punctuation: "=" [35:22 - 35:23] VarDecl=dict:35:17 (Definition)
+// CHECK: Punctuation: "@" [35:24 - 35:25] UnexposedExpr=
+// CHECK: Punctuation: "{" [35:25 - 35:26] UnexposedExpr=
+// CHECK: Identifier: "key" [35:27 - 35:30] DeclRefExpr=key:31:13
+// CHECK: Punctuation: ":" [35:30 - 35:31] UnexposedExpr=
+// CHECK: Identifier: "newObject" [35:32 - 35:41] DeclRefExpr=newObject:32:6
+// CHECK: Punctuation: "," [35:41 - 35:42] UnexposedExpr=
+// CHECK: Identifier: "key" [35:43 - 35:46] DeclRefExpr=key:31:13
+// CHECK: Punctuation: ":" [35:46 - 35:47] UnexposedExpr=
+// CHECK: Identifier: "oldObject" [35:48 - 35:57] DeclRefExpr=oldObject:32:17
+// CHECK: Punctuation: "}" [35:58 - 35:59] UnexposedExpr=
+// CHECK: Punctuation: ";" [35:59 - 35:60] DeclStmt=
diff --git a/test/Index/annotate-tokens-cxx0x.cpp b/test/Index/annotate-tokens-cxx0x.cpp
index 89876b2..a126b85 100644
--- a/test/Index/annotate-tokens-cxx0x.cpp
+++ b/test/Index/annotate-tokens-cxx0x.cpp
@@ -6,6 +6,11 @@ int f(Args ...args) {
void test() {
int a;
decltype(a) b;
+
+ typedef int Integer;
+ typedef float Float;
+ typedef bool Bool;
+ bool b2 = __is_trivially_constructible(Integer, Float, Bool);
}
// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
@@ -14,3 +19,9 @@ void test() {
// RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s
// CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7
+
+// RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s
+// CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15
+// CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17
+// CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16
+
diff --git a/test/Index/annotate-tokens-pp.c b/test/Index/annotate-tokens-pp.c
index 4598827..b37ab39 100644
--- a/test/Index/annotate-tokens-pp.c
+++ b/test/Index/annotate-tokens-pp.c
@@ -124,7 +124,7 @@ const char *fname = __FILE__;
// CHECK: Punctuation: "," [16:26 - 16:27]
// CHECK: Identifier: "z" [16:27 - 16:28] DeclRefExpr=z:14:7
// FIXME: The token below should really be annotated as "macro expansion=REVERSE_MACRO:10:9"
-// CHECK: Punctuation: ")" [16:28 - 16:29] VarDecl=k:16:7 (Definition)
+// CHECK: Punctuation: ")" [16:28 - 16:29] DeclStmt=
// CHECK: Punctuation: ";" [16:29 - 16:30] DeclStmt=
// CHECK: Keyword: "int" [17:3 - 17:6] VarDecl=j:17:7 (Definition)
// CHECK: Identifier: "j" [17:7 - 17:8] VarDecl=j:17:7 (Definition)
@@ -135,7 +135,7 @@ const char *fname = __FILE__;
// CHECK: Punctuation: "+" [17:25 - 17:26] BinaryOperator=
// CHECK: Identifier: "k" [17:27 - 17:28] DeclRefExpr=k:16:7
// FIXME: The token below should really be annotated as "macro expansion=TWICE_MACRO:11:9"
-// CHECK: Punctuation: ")" [17:28 - 17:29] VarDecl=j:17:7 (Definition)
+// CHECK: Punctuation: ")" [17:28 - 17:29] DeclStmt=
// CHECK: Punctuation: ";" [17:29 - 17:30] DeclStmt=
// CHECK: Keyword: "int" [18:3 - 18:6] VarDecl=w:18:7 (Definition)
// CHECK: Identifier: "w" [18:7 - 18:8] VarDecl=w:18:7 (Definition)
@@ -189,7 +189,8 @@ const char *fname = __FILE__;
// CHECK: Identifier: "z" [25:43 - 25:44] DeclRefExpr=z:25:3
// CHECK: Punctuation: ";" [25:44 - 25:45] CompoundStmt=
// CHECK: Punctuation: "}" [25:46 - 25:47] CompoundStmt=
-// CHECK: Punctuation: ")" [25:47 - 25:48] DoStmt=
+// FIXME: The token below should really be annotated as "macro expansion=fun_with_macro_bodies:21:9"
+// CHECK: Punctuation: ")" [25:47 - 25:48] CompoundStmt=
// CHECK: Punctuation: ";" [25:48 - 25:49] CompoundStmt=
// CHECK: Punctuation: "}" [26:1 - 26:2] CompoundStmt=
// CHECK: {{28:1.*inclusion directive=pragma-once.h.*multi-include guarded}}
diff --git a/test/Index/annotate-tokens.cpp b/test/Index/annotate-tokens.cpp
index 5a8f5e2..3062901 100644
--- a/test/Index/annotate-tokens.cpp
+++ b/test/Index/annotate-tokens.cpp
@@ -34,7 +34,7 @@ void test3(S2 s2) {
// CHECK: Punctuation: ")" [2:17 - 2:18] FunctionDecl=test:2:6 (Definition)
// CHECK: Punctuation: "{" [2:19 - 2:20] CompoundStmt=
// CHECK: Identifier: "X" [3:5 - 3:6] DeclRefExpr=X:2:16
-// CHECK: Punctuation: "=" [3:7 - 3:8] CallExpr=operator=:1:8
+// CHECK: Punctuation: "=" [3:7 - 3:8] DeclRefExpr=operator=:1:8
// CHECK: Identifier: "X" [3:9 - 3:10] DeclRefExpr=X:2:16
// CHECK: Punctuation: ";" [3:10 - 3:11] CompoundStmt=
// CHECK: Keyword: "__is_base_of" [4:5 - 4:17] UnexposedExpr=
@@ -78,7 +78,7 @@ void test3(S2 s2) {
// CHECK: Punctuation: "(" [13:3 - 13:4] ParenExpr=
// CHECK: Identifier: "x" [13:4 - 13:5] DeclRefExpr=x:11:14
// CHECK: Punctuation: ")" [13:5 - 13:6] ParenExpr=
-// CHECK: Punctuation: "++" [13:6 - 13:8] CallExpr=operator++:9:5
+// CHECK: Punctuation: "++" [13:6 - 13:8] DeclRefExpr=operator++:9:5
// CHECK: Punctuation: ";" [13:8 - 13:9] CompoundStmt=
// CHECK: Punctuation: "}" [14:1 - 14:2] CompoundStmt=
// CHECK: Keyword: "struct" [16:1 - 16:7] StructDecl=S1:16:8 (Definition)
@@ -111,7 +111,7 @@ void test3(S2 s2) {
// CHECK: Punctuation: ")" [18:17 - 18:18] FunctionDecl=test3:18:6 (Definition)
// CHECK: Punctuation: "{" [18:19 - 18:20] CompoundStmt=
// CHECK: Identifier: "s2" [19:3 - 19:5] DeclRefExpr=s2:18:15
-// CHECK: Punctuation: "->" [19:5 - 19:7] MemberRefExpr=f:16:18
+// CHECK: Punctuation: "->" [19:5 - 19:7] DeclRefExpr=operator->:17:17
// CHECK: Identifier: "f" [19:7 - 19:8] MemberRefExpr=f:16:18
// CHECK: Punctuation: "(" [19:8 - 19:9] CallExpr=f:16:18
// CHECK: Punctuation: ")" [19:9 - 19:10] CallExpr=f:16:18
diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m
index 34115d6..1a48293 100644
--- a/test/Index/annotate-tokens.m
+++ b/test/Index/annotate-tokens.m
@@ -146,30 +146,30 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12
// CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12
// CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12
-// CHECK: Punctuation: "-" [2:1 - 2:2] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Punctuation: "(" [2:3 - 2:4] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Keyword: "int" [2:4 - 2:7] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Punctuation: ")" [2:7 - 2:8] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Identifier: "compare" [2:8 - 2:15] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Punctuation: ":" [2:15 - 2:16] ObjCInstanceMethodDecl=compare::2:1
-// CHECK: Punctuation: "(" [2:16 - 2:17] ObjCInstanceMethodDecl=compare::2:1
+// CHECK: Punctuation: "-" [2:1 - 2:2] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: "(" [2:3 - 2:4] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Keyword: "int" [2:4 - 2:7] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: ")" [2:7 - 2:8] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Identifier: "compare" [2:8 - 2:15] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: ":" [2:15 - 2:16] ObjCInstanceMethodDecl=compare::2:8
+// CHECK: Punctuation: "(" [2:16 - 2:17] ObjCInstanceMethodDecl=compare::2:8
// CHECK: Identifier: "Foo" [2:17 - 2:20] ObjCClassRef=Foo:1:12
// CHECK: Punctuation: "*" [2:20 - 2:21] ParmDecl=other:2:22 (Definition)
// CHECK: Punctuation: ")" [2:21 - 2:22] ParmDecl=other:2:22 (Definition)
// CHECK: Identifier: "other" [2:22 - 2:27] ParmDecl=other:2:22 (Definition)
-// CHECK: Punctuation: ";" [2:27 - 2:28] ObjCInstanceMethodDecl=compare::2:1
+// CHECK: Punctuation: ";" [2:27 - 2:28] ObjCInstanceMethodDecl=compare::2:8
// CHECK: Punctuation: "@" [3:1 - 3:2] ObjCInterfaceDecl=Foo:1:12
// CHECK: Keyword: "end" [3:2 - 3:5] ObjCInterfaceDecl=Foo:1:12
// CHECK: Punctuation: "@" [5:1 - 5:2] ObjCImplementationDecl=Foo:5:17 (Definition)
// CHECK: Keyword: "implementation" [5:2 - 5:16] ObjCImplementationDecl=Foo:5:17 (Definition)
// CHECK: Identifier: "Foo" [5:17 - 5:20] ObjCImplementationDecl=Foo:5:17 (Definition)
-// CHECK: Punctuation: "-" [6:1 - 6:2] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Punctuation: "(" [6:3 - 6:4] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Keyword: "int" [6:4 - 6:7] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Punctuation: ")" [6:7 - 6:8] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Identifier: "compare" [6:8 - 6:15] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Punctuation: ":" [6:15 - 6:16] ObjCInstanceMethodDecl=compare::6:1 (Definition)
-// CHECK: Punctuation: "(" [6:16 - 6:17] ObjCInstanceMethodDecl=compare::6:1 (Definition)
+// CHECK: Punctuation: "-" [6:1 - 6:2] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: "(" [6:3 - 6:4] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Keyword: "int" [6:4 - 6:7] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: ")" [6:7 - 6:8] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Identifier: "compare" [6:8 - 6:15] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: ":" [6:15 - 6:16] ObjCInstanceMethodDecl=compare::6:8 (Definition)
+// CHECK: Punctuation: "(" [6:16 - 6:17] ObjCInstanceMethodDecl=compare::6:8 (Definition)
// CHECK: Identifier: "Foo" [6:17 - 6:20] ObjCClassRef=Foo:1:12
// CHECK: Punctuation: "*" [6:20 - 6:21] ParmDecl=other:6:22 (Definition)
// CHECK: Punctuation: ")" [6:21 - 6:22] ParmDecl=other:6:22 (Definition)
@@ -213,11 +213,11 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "@" [21:1 - 21:2] ObjCImplementationDecl=Bar:21:17 (Definition)
// CHECK: Keyword: "implementation" [21:2 - 21:16] ObjCImplementationDecl=Bar:21:17 (Definition)
// CHECK: Identifier: "Bar" [21:17 - 21:20] ObjCImplementationDecl=Bar:21:17 (Definition)
-// CHECK: Punctuation: "-" [22:1 - 22:2] ObjCInstanceMethodDecl=method:22:1 (Definition)
-// CHECK: Punctuation: "(" [22:3 - 22:4] ObjCInstanceMethodDecl=method:22:1 (Definition)
-// CHECK: Keyword: "void" [22:4 - 22:8] ObjCInstanceMethodDecl=method:22:1 (Definition)
-// CHECK: Punctuation: ")" [22:8 - 22:9] ObjCInstanceMethodDecl=method:22:1 (Definition)
-// CHECK: Identifier: "method" [22:10 - 22:16] ObjCInstanceMethodDecl=method:22:1 (Definition)
+// CHECK: Punctuation: "-" [22:1 - 22:2] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Punctuation: "(" [22:3 - 22:4] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Keyword: "void" [22:4 - 22:8] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Punctuation: ")" [22:8 - 22:9] ObjCInstanceMethodDecl=method:22:10 (Definition)
+// CHECK: Identifier: "method" [22:10 - 22:16] ObjCInstanceMethodDecl=method:22:10 (Definition)
// CHECK: Punctuation: "{" [23:1 - 23:2] CompoundStmt=
// CHECK: Identifier: "barType" [24:5 - 24:12] TypeRef=barType:14:15
// CHECK: Identifier: "local" [24:13 - 24:18] VarDecl=local:24:13 (Definition)
@@ -242,17 +242,17 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: ")" [33:33 - 33:34] ParmDecl=arg:33:34 (Definition)
// CHECK: Identifier: "arg" [33:34 - 33:37] ParmDecl=arg:33:34 (Definition)
// CHECK: Punctuation: ";" [33:37 - 33:38] ObjCInstanceMethodDecl=actionMethod::33:1
-// CHECK: Punctuation: "-" [34:1 - 34:2] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Punctuation: "(" [34:3 - 34:4] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Keyword: "void" [34:4 - 34:8] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Punctuation: ")" [34:8 - 34:9] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Identifier: "foo" [34:9 - 34:12] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Punctuation: ":" [34:12 - 34:13] ObjCInstanceMethodDecl=foo::34:1
-// CHECK: Punctuation: "(" [34:13 - 34:14] ObjCInstanceMethodDecl=foo::34:1
+// CHECK: Punctuation: "-" [34:1 - 34:2] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: "(" [34:3 - 34:4] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Keyword: "void" [34:4 - 34:8] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: ")" [34:8 - 34:9] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Identifier: "foo" [34:9 - 34:12] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: ":" [34:12 - 34:13] ObjCInstanceMethodDecl=foo::34:9
+// CHECK: Punctuation: "(" [34:13 - 34:14] ObjCInstanceMethodDecl=foo::34:9
// CHECK: Keyword: "int" [34:14 - 34:17] ParmDecl=x:34:18 (Definition)
// CHECK: Punctuation: ")" [34:17 - 34:18] ParmDecl=x:34:18 (Definition)
// CHECK: Identifier: "x" [34:18 - 34:19] ParmDecl=x:34:18 (Definition)
-// CHECK: Punctuation: ";" [34:19 - 34:20] ObjCInstanceMethodDecl=foo::34:1
+// CHECK: Punctuation: ";" [34:19 - 34:20] ObjCInstanceMethodDecl=foo::34:9
// CHECK: Punctuation: "@" [35:1 - 35:2] ObjCInterfaceDecl=IBActionTests:32:12
// CHECK: Keyword: "end" [35:2 - 35:5] ObjCInterfaceDecl=IBActionTests:32:12
// CHECK: Keyword: "extern" [36:1 - 36:7]
@@ -265,13 +265,13 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "@" [37:1 - 37:2] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
// CHECK: Keyword: "implementation" [37:2 - 37:16] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
// CHECK: Identifier: "IBActionTests" [37:17 - 37:30] ObjCImplementationDecl=IBActionTests:37:17 (Definition)
-// CHECK: Punctuation: "-" [38:1 - 38:2] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition)
-// CHECK: Punctuation: "(" [38:3 - 38:4] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition)
+// CHECK: Punctuation: "-" [38:1 - 38:2] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Punctuation: "(" [38:3 - 38:4] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
// CHECK: Identifier: "IBAction" [38:4 - 38:12] macro expansion=IBAction
-// CHECK: Punctuation: ")" [38:12 - 38:13] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition)
-// CHECK: Identifier: "actionMethod" [38:14 - 38:26] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition)
-// CHECK: Punctuation: ":" [38:26 - 38:27] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition)
-// CHECK: Keyword: "in" [38:28 - 38:30] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) [Overrides @33:1]
+// CHECK: Punctuation: ")" [38:12 - 38:13] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Identifier: "actionMethod" [38:14 - 38:26] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Punctuation: ":" [38:26 - 38:27] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
+// CHECK: Keyword: "in" [38:28 - 38:30] ObjCInstanceMethodDecl=actionMethod::38:14 (Definition)
// CHECK: Identifier: "id" [38:31 - 38:33] TypeRef=id:0:0
// CHECK: Punctuation: ")" [38:33 - 38:34] ParmDecl=arg:38:34 (Definition)
// CHECK: Identifier: "arg" [38:34 - 38:37] ParmDecl=arg:38:34 (Definition)
@@ -280,21 +280,21 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "(" [40:18 - 40:19] CallExpr=ibaction_test:36:12
// CHECK: Punctuation: ")" [40:19 - 40:20] CallExpr=ibaction_test:36:12
// CHECK: Punctuation: ";" [40:20 - 40:21] CompoundStmt=
-// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:1
+// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:9
// CHECK: Identifier: "self" [41:6 - 41:10] DeclRefExpr=self:0:0
-// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:1
-// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:1
+// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:9
+// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:9
// CHECK: Literal: "0" [41:15 - 41:16] IntegerLiteral=
-// CHECK: Punctuation: "]" [41:16 - 41:17] ObjCMessageExpr=foo::34:1
+// CHECK: Punctuation: "]" [41:16 - 41:17] ObjCMessageExpr=foo::34:9
// CHECK: Punctuation: ";" [41:17 - 41:18] CompoundStmt=
// CHECK: Punctuation: "}" [42:1 - 42:2] CompoundStmt=
-// CHECK: Punctuation: "-" [43:1 - 43:2] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Punctuation: "(" [43:3 - 43:4] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Keyword: "void" [43:4 - 43:8] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Punctuation: ")" [43:8 - 43:9] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Identifier: "foo" [43:10 - 43:13] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Punctuation: ":" [43:13 - 43:14] ObjCInstanceMethodDecl=foo::43:1 (Definition)
-// CHECK: Punctuation: "(" [43:14 - 43:15] ObjCInstanceMethodDecl=foo::43:1 (Definition)
+// CHECK: Punctuation: "-" [43:1 - 43:2] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: "(" [43:3 - 43:4] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Keyword: "void" [43:4 - 43:8] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: ")" [43:8 - 43:9] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Identifier: "foo" [43:10 - 43:13] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: ":" [43:13 - 43:14] ObjCInstanceMethodDecl=foo::43:10 (Definition)
+// CHECK: Punctuation: "(" [43:14 - 43:15] ObjCInstanceMethodDecl=foo::43:10 (Definition)
// CHECK: Keyword: "int" [43:15 - 43:18] ParmDecl=x:43:19 (Definition)
// CHECK: Punctuation: ")" [43:18 - 43:19] ParmDecl=x:43:19 (Definition)
// CHECK: Identifier: "x" [43:19 - 43:20] ParmDecl=x:43:19 (Definition)
@@ -344,35 +344,35 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "@" [65:1 - 65:2] ObjCInterfaceDecl=R7974151:65:12
// CHECK: Keyword: "interface" [65:2 - 65:11] ObjCInterfaceDecl=R7974151:65:12
// CHECK: Identifier: "R7974151" [65:12 - 65:20] ObjCInterfaceDecl=R7974151:65:12
-// CHECK: Punctuation: "-" [66:1 - 66:2] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Punctuation: "(" [66:3 - 66:4] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Keyword: "int" [66:4 - 66:7] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Punctuation: ")" [66:7 - 66:8] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Identifier: "foo" [66:9 - 66:12] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Punctuation: ":" [66:12 - 66:13] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Punctuation: "(" [66:13 - 66:14] ObjCInstanceMethodDecl=foo::66:1
+// CHECK: Punctuation: "-" [66:1 - 66:2] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "(" [66:3 - 66:4] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Keyword: "int" [66:4 - 66:7] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: ")" [66:7 - 66:8] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Identifier: "foo" [66:9 - 66:12] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: ":" [66:12 - 66:13] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "(" [66:13 - 66:14] ObjCInstanceMethodDecl=foo::66:9
// CHECK: Keyword: "int" [66:14 - 66:17] ParmDecl=arg:66:18 (Definition)
// CHECK: Punctuation: ")" [66:17 - 66:18] ParmDecl=arg:66:18 (Definition)
// CHECK: Identifier: "arg" [66:18 - 66:21] ParmDecl=arg:66:18 (Definition)
-// CHECK: Punctuation: ";" [66:21 - 66:22] ObjCInstanceMethodDecl=foo::66:1
-// CHECK: Punctuation: "-" [67:1 - 67:2] ObjCInstanceMethodDecl=method:67:1
-// CHECK: Punctuation: "(" [67:3 - 67:4] ObjCInstanceMethodDecl=method:67:1
-// CHECK: Keyword: "int" [67:4 - 67:7] ObjCInstanceMethodDecl=method:67:1
-// CHECK: Punctuation: ")" [67:7 - 67:8] ObjCInstanceMethodDecl=method:67:1
-// CHECK: Identifier: "method" [67:9 - 67:15] ObjCInstanceMethodDecl=method:67:1
-// CHECK: Punctuation: ";" [67:15 - 67:16] ObjCInstanceMethodDecl=method:67:1
+// CHECK: Punctuation: ";" [66:21 - 66:22] ObjCInstanceMethodDecl=foo::66:9
+// CHECK: Punctuation: "-" [67:1 - 67:2] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: "(" [67:3 - 67:4] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Keyword: "int" [67:4 - 67:7] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: ")" [67:7 - 67:8] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Identifier: "method" [67:9 - 67:15] ObjCInstanceMethodDecl=method:67:9
+// CHECK: Punctuation: ";" [67:15 - 67:16] ObjCInstanceMethodDecl=method:67:9
// CHECK: Punctuation: "@" [68:1 - 68:2] ObjCInterfaceDecl=R7974151:65:12
// CHECK: Keyword: "end" [68:2 - 68:5] ObjCInterfaceDecl=R7974151:65:12
// CHECK: Punctuation: "@" [70:1 - 70:2] ObjCImplementationDecl=R7974151:70:17 (Definition)
// CHECK: Keyword: "implementation" [70:2 - 70:16] ObjCImplementationDecl=R7974151:70:17 (Definition)
// CHECK: Identifier: "R7974151" [70:17 - 70:25] ObjCImplementationDecl=R7974151:70:17 (Definition)
-// CHECK: Punctuation: "-" [71:1 - 71:2] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Punctuation: "(" [71:3 - 71:4] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Keyword: "int" [71:4 - 71:7] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Punctuation: ")" [71:7 - 71:8] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Identifier: "foo" [71:9 - 71:12] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Punctuation: ":" [71:12 - 71:13] ObjCInstanceMethodDecl=foo::71:1 (Definition)
-// CHECK: Punctuation: "(" [71:13 - 71:14] ObjCInstanceMethodDecl=foo::71:1 (Definition)
+// CHECK: Punctuation: "-" [71:1 - 71:2] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: "(" [71:3 - 71:4] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Keyword: "int" [71:4 - 71:7] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: ")" [71:7 - 71:8] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Identifier: "foo" [71:9 - 71:12] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: ":" [71:12 - 71:13] ObjCInstanceMethodDecl=foo::71:9 (Definition)
+// CHECK: Punctuation: "(" [71:13 - 71:14] ObjCInstanceMethodDecl=foo::71:9 (Definition)
// CHECK: Keyword: "int" [71:14 - 71:17] ParmDecl=arg:71:18 (Definition)
// CHECK: Punctuation: ")" [71:17 - 71:18] ParmDecl=arg:71:18 (Definition)
// CHECK: Identifier: "arg" [71:18 - 71:21] ParmDecl=arg:71:18 (Definition)
@@ -381,43 +381,43 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Identifier: "arg" [72:10 - 72:13] DeclRefExpr=arg:71:18
// CHECK: Punctuation: ";" [72:13 - 72:14] CompoundStmt=
// CHECK: Punctuation: "}" [73:1 - 73:2] CompoundStmt=
-// CHECK: Punctuation: "-" [74:1 - 74:2] ObjCInstanceMethodDecl=method:74:1 (Definition)
-// CHECK: Punctuation: "(" [74:3 - 74:4] ObjCInstanceMethodDecl=method:74:1 (Definition)
-// CHECK: Keyword: "int" [74:4 - 74:7] ObjCInstanceMethodDecl=method:74:1 (Definition)
-// CHECK: Punctuation: ")" [74:7 - 74:8] ObjCInstanceMethodDecl=method:74:1 (Definition)
-// CHECK: Identifier: "method" [74:9 - 74:15] ObjCInstanceMethodDecl=method:74:1 (Definition)
+// CHECK: Punctuation: "-" [74:1 - 74:2] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Punctuation: "(" [74:3 - 74:4] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Keyword: "int" [74:4 - 74:7] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Punctuation: ")" [74:7 - 74:8] ObjCInstanceMethodDecl=method:74:9 (Definition)
+// CHECK: Identifier: "method" [74:9 - 74:15] ObjCInstanceMethodDecl=method:74:9 (Definition)
// CHECK: Punctuation: "{" [75:1 - 75:2] CompoundStmt=
// CHECK: Keyword: "int" [76:5 - 76:8] VarDecl=local:76:9 (Definition)
// CHECK: Identifier: "local" [76:9 - 76:14] VarDecl=local:76:9 (Definition)
// CHECK: Punctuation: "=" [76:15 - 76:16] VarDecl=local:76:9 (Definition)
-// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:1
+// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:9
// CHECK: Identifier: "self" [76:18 - 76:22] DeclRefExpr=self:0:0
-// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:1
-// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:1
+// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:9
// CHECK: Identifier: "VAL" [76:27 - 76:30] macro expansion=VAL:63:9
-// CHECK: Punctuation: "]" [76:30 - 76:31] ObjCMessageExpr=foo::66:1
+// CHECK: Punctuation: "]" [76:30 - 76:31] ObjCMessageExpr=foo::66:9
// CHECK: Punctuation: ";" [76:31 - 76:32] DeclStmt=
// CHECK: Keyword: "int" [77:5 - 77:8] VarDecl=second:77:9 (Definition)
// CHECK: Identifier: "second" [77:9 - 77:15] VarDecl=second:77:9 (Definition)
// CHECK: Punctuation: "=" [77:16 - 77:17] VarDecl=second:77:9 (Definition)
-// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:1
+// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:9
// CHECK: Identifier: "self" [77:19 - 77:23] DeclRefExpr=self:0:0
-// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:1
-// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:1
+// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:9
+// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:9
// CHECK: Literal: "0" [77:28 - 77:29] IntegerLiteral=
-// CHECK: Punctuation: "]" [77:29 - 77:30] ObjCMessageExpr=foo::66:1
+// CHECK: Punctuation: "]" [77:29 - 77:30] ObjCMessageExpr=foo::66:9
// CHECK: Punctuation: ";" [77:30 - 77:31] DeclStmt=
// CHECK: Keyword: "return" [78:5 - 78:11] ReturnStmt=
// CHECK: Identifier: "local" [78:12 - 78:17] DeclRefExpr=local:76:9
// CHECK: Punctuation: ";" [78:17 - 78:18] CompoundStmt=
// CHECK: Punctuation: "}" [79:1 - 79:2] CompoundStmt=
-// CHECK: Punctuation: "-" [80:1 - 80:2] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Punctuation: "(" [80:3 - 80:4] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Keyword: "int" [80:4 - 80:7] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Punctuation: ")" [80:7 - 80:8] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Identifier: "othermethod" [80:8 - 80:19] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Punctuation: ":" [80:19 - 80:20] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
-// CHECK: Punctuation: "(" [80:20 - 80:21] ObjCInstanceMethodDecl=othermethod::80:1 (Definition)
+// CHECK: Punctuation: "-" [80:1 - 80:2] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: "(" [80:3 - 80:4] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Keyword: "int" [80:4 - 80:7] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: ")" [80:7 - 80:8] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Identifier: "othermethod" [80:8 - 80:19] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: ":" [80:19 - 80:20] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
+// CHECK: Punctuation: "(" [80:20 - 80:21] ObjCInstanceMethodDecl=othermethod::80:8 (Definition)
// CHECK: Identifier: "IBOutletTests" [80:21 - 80:34] ObjCClassRef=IBOutletTests:51:12
// CHECK: Punctuation: "*" [80:35 - 80:36] ParmDecl=ibt:80:37 (Definition)
// CHECK: Punctuation: ")" [80:36 - 80:37] ParmDecl=ibt:80:37 (Definition)
@@ -452,8 +452,8 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: ")" [88:24 - 88:25] ObjCProtocolExpr=Proto:85:1
// CHECK: Punctuation: ";" [88:25 - 88:26] CompoundStmt=
// CHECK: Punctuation: "}" [89:1 - 89:2] CompoundStmt=
-// CHECK: Punctuation: "@" [93:1 - 93:2] UnexposedDecl=[93:8]
-// CHECK: Keyword: "class" [93:2 - 93:7] UnexposedDecl=[93:8]
+// CHECK: Punctuation: "@" [93:1 - 93:2] ObjCInterfaceDecl=Rdar8595462_A:93:8
+// CHECK: Keyword: "class" [93:2 - 93:7] ObjCInterfaceDecl=Rdar8595462_A:93:8
// CHECK: Identifier: "Rdar8595462_A" [93:8 - 93:21] ObjCClassRef=Rdar8595462_A:93:8
// CHECK: Punctuation: ";" [93:21 - 93:22]
// CHECK: Punctuation: "@" [94:1 - 94:2] ObjCInterfaceDecl=Rdar8595462_B:94:12
@@ -517,14 +517,14 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK-INSIDE_BLOCK: Keyword: "int" [127:5 - 127:8] VarDecl=result:127:9 (Definition)
// CHECK-INSIDE_BLOCK: Identifier: "result" [127:9 - 127:15] VarDecl=result:127:9 (Definition)
// CHECK-INSIDE_BLOCK: Punctuation: "=" [127:16 - 127:17] VarDecl=result:127:9 (Definition)
-// CHECK-INSIDE_BLOCK: Punctuation: "[" [127:18 - 127:19] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Punctuation: "[" [127:18 - 127:19] ObjCMessageExpr=blah::124:8
// CHECK-INSIDE_BLOCK: Identifier: "self" [127:19 - 127:23] DeclRefExpr=self:0:0
-// CHECK-INSIDE_BLOCK: Identifier: "blah" [127:24 - 127:28] ObjCMessageExpr=blah::124:1
-// CHECK-INSIDE_BLOCK: Punctuation: ":" [127:28 - 127:29] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Identifier: "blah" [127:24 - 127:28] ObjCMessageExpr=blah::124:8
+// CHECK-INSIDE_BLOCK: Punctuation: ":" [127:28 - 127:29] ObjCMessageExpr=blah::124:8
// CHECK-INSIDE_BLOCK: Literal: "5" [127:29 - 127:30] IntegerLiteral=
-// CHECK-INSIDE_BLOCK: Punctuation: "," [127:30 - 127:31] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Punctuation: "," [127:30 - 127:31] ObjCMessageExpr=blah::124:8
// CHECK-INSIDE_BLOCK: Identifier: "x" [127:32 - 127:33] DeclRefExpr=x:125:19
-// CHECK-INSIDE_BLOCK: Punctuation: "]" [127:33 - 127:34] ObjCMessageExpr=blah::124:1
+// CHECK-INSIDE_BLOCK: Punctuation: "]" [127:33 - 127:34] ObjCMessageExpr=blah::124:8
// CHECK-INSIDE_BLOCK: Punctuation: ";" [127:34 - 127:35] DeclStmt=
// CHECK-INSIDE_BLOCK: Identifier: "Rdar8778404" [128:5 - 128:16] ObjCClassRef=Rdar8778404:120:12
// CHECK-INSIDE_BLOCK: Punctuation: "*" [128:17 - 128:18] VarDecl=a:128:18 (Definition)
@@ -536,13 +536,13 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [134:1 - 134:2] ObjCInterfaceDecl=Rdar8062781:134:12
// CHECK-PROP-AFTER-METHOD: Keyword: "interface" [134:2 - 134:11] ObjCInterfaceDecl=Rdar8062781:134:12
// CHECK-PROP-AFTER-METHOD: Identifier: "Rdar8062781" [134:12 - 134:23] ObjCInterfaceDecl=Rdar8062781:134:12
-// CHECK-PROP-AFTER-METHOD: Punctuation: "+" [135:1 - 135:2] ObjCClassMethodDecl=getB:135:1
-// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [135:3 - 135:4] ObjCClassMethodDecl=getB:135:1
+// CHECK-PROP-AFTER-METHOD: Punctuation: "+" [135:1 - 135:2] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [135:3 - 135:4] ObjCClassMethodDecl=getB:135:9
// CHECK-PROP-AFTER-METHOD: Identifier: "Foo" [135:4 - 135:7] ObjCClassRef=Foo:1:12
-// CHECK-PROP-AFTER-METHOD: Punctuation: "*" [135:7 - 135:8] ObjCClassMethodDecl=getB:135:1
-// CHECK-PROP-AFTER-METHOD: Punctuation: ")" [135:8 - 135:9] ObjCClassMethodDecl=getB:135:1
-// CHECK-PROP-AFTER-METHOD: Identifier: "getB" [135:9 - 135:13] ObjCClassMethodDecl=getB:135:1
-// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [135:13 - 135:14] ObjCClassMethodDecl=getB:135:1
+// CHECK-PROP-AFTER-METHOD: Punctuation: "*" [135:7 - 135:8] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: ")" [135:8 - 135:9] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Identifier: "getB" [135:9 - 135:13] ObjCClassMethodDecl=getB:135:9
+// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [135:13 - 135:14] ObjCClassMethodDecl=getB:135:9
// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [136:1 - 136:2] ObjCPropertyDecl=blah:136:38
// CHECK-PROP-AFTER-METHOD: Keyword: "property" [136:2 - 136:10] ObjCPropertyDecl=blah:136:38
// CHECK-PROP-AFTER-METHOD: Punctuation: "(" [136:11 - 136:12] ObjCPropertyDecl=blah:136:38
@@ -567,7 +567,7 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK-PROP-AFTER-METHOD: Punctuation: ";" [137:39 - 137:40] ObjCInterfaceDecl=Rdar8062781:134:12
// CHECK-PROP-AFTER-METHOD: Punctuation: "@" [138:1 - 138:2] ObjCInterfaceDecl=Rdar8062781:134:12
-// RUN: c-index-test -test-annotate-tokens=%s:141:1:142:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' -ccc-host-triple x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
+// RUN: c-index-test -test-annotate-tokens=%s:141:1:142:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
// CHECK-WITH-WEAK: Identifier: "__weak" [141:3 - 141:9] macro expansion
// CHECK-WITH-WEAK: Identifier: "Foo" [141:10 - 141:13] ObjCClassRef=Foo:1:12
// CHECK-WITH-WEAK: Punctuation: "*" [141:14 - 141:15] ObjCIvarDecl=foo:141:15 (Definition)
diff --git a/test/Index/annotate-toplevel-in-objccontainer.m b/test/Index/annotate-toplevel-in-objccontainer.m
new file mode 100644
index 0000000..56b7871
--- /dev/null
+++ b/test/Index/annotate-toplevel-in-objccontainer.m
@@ -0,0 +1,33 @@
+@interface Foo
+void func1(int);
+void func2(int);
+
+-(void)meth1;
+-(void)meth2;
+@end
+
+@implementation Foo
+void func(int);
+static int glob1;
+static int glob2;
+
+-(void)meth1 {}
+-(void)meth2 {}
+@end
+
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c-header %s.h
+
+// RUN: c-index-test -test-annotate-tokens=%s:5:1:7:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=INTER %s
+// CHECK-INTER: Identifier: "meth1" [5:8 - 5:13] ObjCInstanceMethodDecl=meth1:5:8
+// CHECK-INTER: Identifier: "meth2" [6:8 - 6:13] ObjCInstanceMethodDecl=meth2:6:8
+
+// RUN: c-index-test -test-annotate-tokens=%s:14:1:16:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=IMPL %s
+// CHECK-IMPL: Identifier: "meth1" [14:8 - 14:13] ObjCInstanceMethodDecl=meth1:14:8 (Definition)
+// CHECK-IMPL: Identifier: "meth2" [15:8 - 15:13] ObjCInstanceMethodDecl=meth2:15:8 (Definition)
+
+// RUN: c-index-test -test-annotate-tokens=%s.h:7:1:9:1 %s -include %t.h \
+// RUN: | FileCheck -check-prefix=PCH %s
+// CHECK-PCH: Identifier: "meth1" [7:8 - 7:13] ObjCInstanceMethodDecl=meth1:7:8
+// CHECK-PCH: Identifier: "meth2" [8:8 - 8:13] ObjCInstanceMethodDecl=meth2:8:8
diff --git a/test/Index/annotate-toplevel-in-objccontainer.m.h b/test/Index/annotate-toplevel-in-objccontainer.m.h
new file mode 100644
index 0000000..fe507fc
--- /dev/null
+++ b/test/Index/annotate-toplevel-in-objccontainer.m.h
@@ -0,0 +1,9 @@
+@interface FooPCH
+void funcPCH1(int);
+void funcPCH2(int);
+
+enum E { Cake };
+
+-(void)meth1;
+-(void)meth2;
+@end
diff --git a/test/Index/asm-attribute.c b/test/Index/asm-attribute.c
new file mode 100644
index 0000000..f952459
--- /dev/null
+++ b/test/Index/asm-attribute.c
@@ -0,0 +1,6 @@
+int foo(int x) __asm__("_foo_");
+
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
+// CHECK: asm-attribute.c:1:5: FunctionDecl=foo:1:5 Extent=[1:1 - 1:32]
+// FIXME: Location below.
+// CHECK: <invalid loc>:0:0: asm label=_foo_ Extent=[1:24 - 1:31]
diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m
index 62cc4d4..251d73b 100644
--- a/test/Index/c-index-api-loadTU-test.m
+++ b/test/Index/c-index-api-loadTU-test.m
@@ -79,29 +79,29 @@ struct X0 {};
// CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:3 - 6:40]
// CHECK: <invalid loc>:0:0: attribute(iboutlet)=
// CHECK: c-index-api-loadTU-test.m:6:29: TypeRef=id:0:0 Extent=[6:29 - 6:31]
-// CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=myMessage::8:1 Extent=[8:1 - 8:54]
+// CHECK: c-index-api-loadTU-test.m:8:36: ObjCInstanceMethodDecl=myMessage::8:36 Extent=[8:1 - 8:54]
// CHECK: <invalid loc>:0:0: attribute(ibaction)=
// CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53]
// CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49]
-// CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 (deprecated) Extent=[9:1 - 9:35]
-// CHECK: c-index-api-loadTU-test.m:10:1: ObjCClassMethodDecl=fooC:10:1 Extent=[10:1 - 10:8]
+// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) Extent=[9:1 - 9:35]
+// CHECK: c-index-api-loadTU-test.m:10:3: ObjCClassMethodDecl=fooC:10:3 Extent=[10:1 - 10:8]
// CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5]
// CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21]
// CHECK: c-index-api-loadTU-test.m:20:12: ObjCCategoryDecl=FooCat:20:12 Extent=[20:1 - 23:5]
// CHECK: c-index-api-loadTU-test.m:20:12: ObjCClassRef=Foo:4:12 Extent=[20:12 - 20:15]
-// CHECK: c-index-api-loadTU-test.m:21:1: ObjCInstanceMethodDecl=catMethodWithFloat::21:1 Extent=[21:1 - 21:41]
+// CHECK: c-index-api-loadTU-test.m:21:9: ObjCInstanceMethodDecl=catMethodWithFloat::21:9 Extent=[21:1 - 21:41]
// CHECK: c-index-api-loadTU-test.m:21:36: ParmDecl=fArg:21:36 (Definition) Extent=[21:29 - 21:40]
-// CHECK: c-index-api-loadTU-test.m:22:1: ObjCInstanceMethodDecl=floatMethod:22:1 Extent=[22:1 - 22:23]
+// CHECK: c-index-api-loadTU-test.m:22:11: ObjCInstanceMethodDecl=floatMethod:22:11 Extent=[22:1 - 22:23]
// CHECK: c-index-api-loadTU-test.m:25:11: ObjCProtocolDecl=Proto:25:11 (Definition) Extent=[25:1 - 27:5]
-// CHECK: c-index-api-loadTU-test.m:26:1: ObjCInstanceMethodDecl=pMethod:26:1 Extent=[26:1 - 26:11]
+// CHECK: c-index-api-loadTU-test.m:26:3: ObjCInstanceMethodDecl=pMethod:26:3 Extent=[26:1 - 26:11]
// CHECK: c-index-api-loadTU-test.m:29:11: ObjCProtocolDecl=SubP:29:11 (Definition) Extent=[29:1 - 31:5]
// CHECK: c-index-api-loadTU-test.m:29:17: ObjCProtocolRef=Proto:25:11 Extent=[29:17 - 29:22]
-// CHECK: c-index-api-loadTU-test.m:30:1: ObjCInstanceMethodDecl=spMethod:30:1 Extent=[30:1 - 30:12]
+// CHECK: c-index-api-loadTU-test.m:30:3: ObjCInstanceMethodDecl=spMethod:30:3 Extent=[30:1 - 30:12]
// CHECK: c-index-api-loadTU-test.m:33:12: ObjCInterfaceDecl=Baz:33:12 Extent=[33:1 - 40:5]
// CHECK: c-index-api-loadTU-test.m:33:18: ObjCSuperClassRef=Bar:14:12 Extent=[33:18 - 33:21]
// CHECK: c-index-api-loadTU-test.m:33:23: ObjCProtocolRef=SubP:29:11 Extent=[33:23 - 33:27]
// CHECK: c-index-api-loadTU-test.m:35:9: ObjCIvarDecl=_anIVar:35:9 (Definition) Extent=[35:5 - 35:16]
-// CHECK: c-index-api-loadTU-test.m:38:1: ObjCInstanceMethodDecl=bazMethod:38:1 Extent=[38:1 - 38:21]
+// CHECK: c-index-api-loadTU-test.m:38:11: ObjCInstanceMethodDecl=bazMethod:38:11 Extent=[38:1 - 38:21]
// CHECK: c-index-api-loadTU-test.m:38:4: ObjCClassRef=Foo:4:12 Extent=[38:4 - 38:7]
// CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=:42:1 (Definition) Extent=[42:1 - 44:2]
// CHECK: c-index-api-loadTU-test.m:43:3: EnumConstantDecl=someEnum:43:3 (Definition) Extent=[43:3 - 43:11]
@@ -112,13 +112,13 @@ struct X0 {};
// CHECK: c-index-api-loadTU-test.m:47:2: ObjCClassRef=Baz:33:12 Extent=[47:2 - 47:5]
// CHECK: c-index-api-loadTU-test.m:48:5: VarDecl=a:48:5 (Definition) Extent=[48:2 - 48:18]
// CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 Extent=[48:2 - 48:4]
-// CHECK: c-index-api-loadTU-test.m:48:9: ObjCMessageExpr=foo:9:1 Extent=[48:9 - 48:18]
+// CHECK: c-index-api-loadTU-test.m:48:9: ObjCMessageExpr=foo:9:3 Extent=[48:9 - 48:18]
// CHECK: c-index-api-loadTU-test.m:48:10: DeclRefExpr=bee:47:8 Extent=[48:10 - 48:13]
// CHECK: c-index-api-loadTU-test.m:49:12: VarDecl=c:49:12 (Definition) Extent=[49:2 - 49:26]
// CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 Extent=[49:2 - 49:4]
// CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=SubP:29:11 Extent=[49:6 - 49:10]
-// CHECK: c-index-api-loadTU-test.m:49:16: UnexposedExpr=fooC:10:1 Extent=[49:16 - 49:26]
-// CHECK: c-index-api-loadTU-test.m:49:16: ObjCMessageExpr=fooC:10:1 Extent=[49:16 - 49:26]
+// CHECK: c-index-api-loadTU-test.m:49:16: UnexposedExpr=fooC:10:3 Extent=[49:16 - 49:26]
+// CHECK: c-index-api-loadTU-test.m:49:16: ObjCMessageExpr=fooC:10:3 Extent=[49:16 - 49:26]
// CHECK: c-index-api-loadTU-test.m:49:17: ObjCClassRef=Foo:4:12 Extent=[49:17 - 49:20]
// CHECK: c-index-api-loadTU-test.m:50:13: VarDecl=d:50:13 (Definition) Extent=[50:2 - 50:14]
// CHECK: c-index-api-loadTU-test.m:50:2: TypeRef=id:0:0 Extent=[50:2 - 50:4]
@@ -127,11 +127,11 @@ struct X0 {};
// CHECK: c-index-api-loadTU-test.m:51:2: DeclRefExpr=d:50:13 Extent=[51:2 - 51:3]
// CHECK: c-index-api-loadTU-test.m:51:6: UnexposedExpr=c:49:12 Extent=[51:6 - 51:7]
// CHECK: c-index-api-loadTU-test.m:51:6: DeclRefExpr=c:49:12 Extent=[51:6 - 51:7]
-// CHECK: c-index-api-loadTU-test.m:52:2: ObjCMessageExpr=pMethod:26:1 Extent=[52:2 - 52:13]
+// CHECK: c-index-api-loadTU-test.m:52:2: ObjCMessageExpr=pMethod:26:3 Extent=[52:2 - 52:13]
// CHECK: c-index-api-loadTU-test.m:52:3: DeclRefExpr=d:50:13 Extent=[52:3 - 52:4]
-// CHECK: c-index-api-loadTU-test.m:53:2: ObjCMessageExpr=catMethodWithFloat::21:1 Extent=[53:2 - 53:44]
+// CHECK: c-index-api-loadTU-test.m:53:2: ObjCMessageExpr=catMethodWithFloat::21:9 Extent=[53:2 - 53:44]
// CHECK: c-index-api-loadTU-test.m:53:3: DeclRefExpr=bee:47:8 Extent=[53:3 - 53:6]
-// CHECK: c-index-api-loadTU-test.m:53:26: ObjCMessageExpr=floatMethod:22:1 Extent=[53:26 - 53:43]
+// CHECK: c-index-api-loadTU-test.m:53:26: ObjCMessageExpr=floatMethod:22:11 Extent=[53:26 - 53:43]
// CHECK: c-index-api-loadTU-test.m:53:27: DeclRefExpr=bee:47:8 Extent=[53:27 - 53:30]
// CHECK: c-index-api-loadTU-test.m:54:3: CallExpr=main:46:5 Extent=[54:3 - 54:37]
// CHECK: c-index-api-loadTU-test.m:54:3: UnexposedExpr=main:46:5 Extent=[54:3 - 54:7]
@@ -145,7 +145,7 @@ struct X0 {};
// CHECK: c-index-api-loadTU-test.m:64:29: ObjCIvarDecl=anOutletCollection:64:29 (Definition) Extent=[59:39 - 64:47]
// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= [IBOutletCollection=ObjCObjectPointer]
// CHECK: c-index-api-loadTU-test.m:64:26: TypeRef=id:0:0 Extent=[64:26 - 64:28]
-// CHECK: c-index-api-loadTU-test.m:66:1: ObjCInstanceMethodDecl=actionMethod::66:1 Extent=[66:1 - 66:35]
+// CHECK: c-index-api-loadTU-test.m:66:14: ObjCInstanceMethodDecl=actionMethod::66:14 Extent=[66:1 - 66:35]
// CHECK: <invalid loc>:0:0: attribute(ibaction)=
// CHECK: c-index-api-loadTU-test.m:66:31: ParmDecl=arg:66:31 (Definition) Extent=[66:28 - 66:34]
// CHECK: c-index-api-loadTU-test.m:66:28: TypeRef=id:0:0 Extent=[66:28 - 66:30]
diff --git a/test/Index/c-index-getCursor-test.m b/test/Index/c-index-getCursor-test.m
index c7410c9..bae5979 100644
--- a/test/Index/c-index-getCursor-test.m
+++ b/test/Index/c-index-getCursor-test.m
@@ -61,9 +61,9 @@ void f() {
// CHECK: [1:1 - 3:1] Invalid Cursor => NoDeclFound
// CHECK: [3:1 - 7:1] ObjCInterfaceDecl=Foo:3:12
-// CHECK: [7:1 - 7:7] ObjCInstanceMethodDecl=foo:7:1
+// CHECK: [7:1 - 7:7] ObjCInstanceMethodDecl=foo:7:3
// CHECK: [7:7 - 8:1] ObjCInterfaceDecl=Foo:3:12
-// CHECK: [8:1 - 8:8] ObjCClassMethodDecl=fooC:8:1
+// CHECK: [8:1 - 8:8] ObjCClassMethodDecl=fooC:8:3
// CHECK: [8:8 - 10:5] ObjCInterfaceDecl=Foo:3:12
// CHECK: [10:5 - 12:1] Invalid Cursor => NoDeclFound
// CHECK: [12:1 - 12:18] ObjCInterfaceDecl=Bar:12:12
@@ -73,21 +73,21 @@ void f() {
// CHECK: [18:1 - 18:12] ObjCCategoryDecl=FooCat:18:12
// CHECK: [18:12 - 18:15] ObjCClassRef=Foo:3:12
// CHECK: [18:15 - 19:1] ObjCCategoryDecl=FooCat:18:12
-// CHECK: [19:1 - 19:29] ObjCInstanceMethodDecl=catMethodWithFloat::19:1
+// CHECK: [19:1 - 19:29] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
// CHECK: [19:29 - 19:40] ParmDecl=fArg:19:36 (Definition)
-// CHECK: [19:40 - 19:41] ObjCInstanceMethodDecl=catMethodWithFloat::19:1
+// CHECK: [19:40 - 19:41] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
// CHECK: [19:41 - 20:1] ObjCCategoryDecl=FooCat:18:12
-// CHECK: [20:1 - 20:23] ObjCInstanceMethodDecl=floatMethod:20:1
+// CHECK: [20:1 - 20:23] ObjCInstanceMethodDecl=floatMethod:20:11
// CHECK: [20:23 - 21:5] ObjCCategoryDecl=FooCat:18:12
// CHECK: [21:5 - 23:1] Invalid Cursor => NoDeclFound
// CHECK: [23:1 - 24:1] ObjCProtocolDecl=Proto:23:11 (Definition)
-// CHECK: [24:1 - 24:11] ObjCInstanceMethodDecl=pMethod:24:1
+// CHECK: [24:1 - 24:11] ObjCInstanceMethodDecl=pMethod:24:3
// CHECK: [24:11 - 25:5] ObjCProtocolDecl=Proto:23:11 (Definition)
// CHECK: [25:5 - 27:1] Invalid Cursor => NoDeclFound
// CHECK: [27:1 - 27:17] ObjCProtocolDecl=SubP:27:11 (Definition)
// CHECK: [27:17 - 27:22] ObjCProtocolRef=Proto:23:1
// CHECK: [27:22 - 28:1] ObjCProtocolDecl=SubP:27:11 (Definition)
-// CHECK: [28:1 - 28:12] ObjCInstanceMethodDecl=spMethod:28:1
+// CHECK: [28:1 - 28:12] ObjCInstanceMethodDecl=spMethod:28:3
// CHECK: [28:12 - 29:5] ObjCProtocolDecl=SubP:27:11 (Definition)
// CHECK: [29:5 - 31:1] Invalid Cursor => NoDeclFound
// CHECK: [31:1 - 31:18] ObjCInterfaceDecl=Baz:31:12
@@ -118,18 +118,18 @@ void f() {
// CHECK: [45:12 - 46:2] CompoundStmt=
// CHECK: [46:2 - 46:4] TypeRef=id:0:0
// CHECK: [46:4 - 46:9] VarDecl=a:46:5 (Definition)
-// CHECK: [46:9 - 46:10] ObjCMessageExpr=foo:7:1
+// CHECK: [46:9 - 46:10] ObjCMessageExpr=foo:7:3
// CHECK: [46:10 - 46:13] DeclRefExpr=bee:45:8
-// CHECK: [46:13 - 46:18] ObjCMessageExpr=foo:7:1
+// CHECK: [46:13 - 46:18] ObjCMessageExpr=foo:7:3
// CHECK: [46:18 - 46:19] DeclStmt=
// CHECK: [46:19 - 47:2] CompoundStmt=
// CHECK: [47:2 - 47:4] TypeRef=id:0:0
// CHECK: [47:4 - 47:6] VarDecl=c:47:12 (Definition)
// CHECK: [47:6 - 47:10] ObjCProtocolRef=SubP:27:1
// CHECK: [47:10 - 47:16] VarDecl=c:47:12 (Definition)
-// CHECK: [47:16 - 47:17] ObjCMessageExpr=fooC:8:1
+// CHECK: [47:16 - 47:17] ObjCMessageExpr=fooC:8:3
// CHECK: [47:17 - 47:20] ObjCClassRef=Foo:3:12
-// CHECK: [47:20 - 47:26] ObjCMessageExpr=fooC:8:1
+// CHECK: [47:20 - 47:26] ObjCMessageExpr=fooC:8:3
// CHECK: [47:26 - 47:27] DeclStmt=
// CHECK: [47:27 - 48:2] CompoundStmt=
// CHECK: [48:2 - 48:4] TypeRef=id:0:0
@@ -142,17 +142,17 @@ void f() {
// CHECK: [49:3 - 49:6] BinaryOperator=
// CHECK: [49:6 - 49:7] DeclRefExpr=c:47:12
// CHECK: [49:7 - 50:2] CompoundStmt=
-// CHECK: [50:2 - 50:3] ObjCMessageExpr=pMethod:24:1
+// CHECK: [50:2 - 50:3] ObjCMessageExpr=pMethod:24:3
// CHECK: [50:3 - 50:4] DeclRefExpr=d:48:13
-// CHECK: [50:4 - 50:13] ObjCMessageExpr=pMethod:24:1
+// CHECK: [50:4 - 50:13] ObjCMessageExpr=pMethod:24:3
// CHECK: [50:13 - 51:2] CompoundStmt=
-// CHECK: [51:2 - 51:3] ObjCMessageExpr=catMethodWithFloat::19:1
+// CHECK: [51:2 - 51:3] ObjCMessageExpr=catMethodWithFloat::19:9
// CHECK: [51:3 - 51:6] DeclRefExpr=bee:45:8
-// CHECK: [51:6 - 51:26] ObjCMessageExpr=catMethodWithFloat::19:1
+// CHECK: [51:6 - 51:26] ObjCMessageExpr=catMethodWithFloat::19:9
// CHECK: [51:26 - 51:27] ObjCMessageExpr=floatMethod:20:1
// CHECK: [51:27 - 51:30] DeclRefExpr=bee:45:8
// CHECK: [51:30 - 51:43] ObjCMessageExpr=floatMethod:20:1
-// CHECK: [51:43 - 51:44] ObjCMessageExpr=catMethodWithFloat::19:1
+// CHECK: [51:43 - 51:44] ObjCMessageExpr=catMethodWithFloat::19:9
// CHECK: [51:44 - 52:3] CompoundStmt=
// CHECK: [52:3 - 52:7] DeclRefExpr=main:44:5
// CHECK: [52:7 - 52:8] CallExpr=main:44:5
diff --git a/test/Index/cindex-on-invalid-usrs.m b/test/Index/cindex-on-invalid-usrs.m
index 01002bc..6414761 100644
--- a/test/Index/cindex-on-invalid-usrs.m
+++ b/test/Index/cindex-on-invalid-usrs.m
@@ -4,4 +4,4 @@
@interface Rdar8452791 () - (void)rdar8452791;
// CHECK: error: cannot find interface declaration for 'Rdar8452791'
-// CHECK: missing @end
+// CHECK: missing '@end'
diff --git a/test/Index/complete-at-exprstmt.m b/test/Index/complete-at-exprstmt.m
index 7532bbb..a6d7675 100644
--- a/test/Index/complete-at-exprstmt.m
+++ b/test/Index/complete-at-exprstmt.m
@@ -31,9 +31,9 @@ void f() {
// CHECK-CC2: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
// CHECK-CC2: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )}
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:3 %s | FileCheck -check-prefix=CHECK-CC3 %s
-// CHECK-CC3: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
-// CHECK-CC3: NotImplemented:{TypedText @protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
-// CHECK-CC3: NotImplemented:{TypedText @selector}{LeftParen (}{Placeholder selector}{RightParen )}
+// CHECK-CC3: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC3: NotImplemented:{ResultType Protocol *}{TypedText @protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )}
+// CHECK-CC3: NotImplemented:{ResultType SEL}{TypedText @selector}{LeftParen (}{Placeholder selector}{RightParen )}
// CHECK-CC3: NotImplemented:{TypedText @synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}
// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression}
// CHECK-CC3: NotImplemented:{TypedText @try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }}
diff --git a/test/Index/complete-blocks.m b/test/Index/complete-blocks.m
index e7919ef..cb507e2 100644
--- a/test/Index/complete-blocks.m
+++ b/test/Index/complete-blocks.m
@@ -26,14 +26,22 @@ void test_B(B *b) {
}
@interface C
-- method4:(void(^)(void))arg { };
-- method5:(void(^)())arg5 { };
+- method4:(void(^)(void))arg;
+- method5:(void(^)())arg5;
@end
void test_C(C *c) {
[c method4:^{}];
}
+@interface D
+- method6:(void(^)(block_t block))arg;
+@end
+
+void test_D(D *d) {
+ [d method6:0];
+}
+
// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50)
@@ -51,3 +59,6 @@ void test_C(C *c) {
// CHECK-CC5-NOT: test_A
// CHECK-CC5: {TypedText union} (50)
+// RUN: c-index-test -code-completion-at=%s:42:6 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText method6:}{Placeholder ^(block_t block)arg} (35)
+
diff --git a/test/Index/complete-cxx-inline-methods.cpp b/test/Index/complete-cxx-inline-methods.cpp
index e25949d..d441972 100644
--- a/test/Index/complete-cxx-inline-methods.cpp
+++ b/test/Index/complete-cxx-inline-methods.cpp
@@ -1,3 +1,4 @@
+namespace {
class MyCls {
void in_foo() {
vec.x = 0;
@@ -12,8 +13,18 @@ void MyCls::out_foo() {
vec.x = 0;
}
-// RUN: c-index-test -code-completion-at=%s:3:9 %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:12:7 %s | FileCheck %s
+class OtherClass : public MyCls {
+public:
+ OtherClass(const OtherClass &other) : MyCls(other), value(value) { }
+
+private:
+ int value;
+ MyCls *object;
+};
+}
+
+// RUN: c-index-test -code-completion-at=%s:4:9 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck %s
// CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
// CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
// CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
@@ -22,3 +33,12 @@ void MyCls::out_foo() {
// CHECK-NEXT: Completion contexts:
// CHECK-NEXT: Dot member access
// CHECK-NEXT: Container Kind: StructDecl
+
+// RUN: c-index-test -code-completion-at=%s:18:41 %s | FileCheck -check-prefix=CHECK-CTOR-INIT %s
+// CHECK-CTOR-INIT: NotImplemented:{TypedText MyCls}{LeftParen (}{Placeholder args}{RightParen )} (7)
+// CHECK-CTOR-INIT: MemberRef:{TypedText object}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CTOR-INIT: MemberRef:{TypedText value}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// RUN: c-index-test -code-completion-at=%s:18:55 %s | FileCheck -check-prefix=CHECK-CTOR-INIT-2 %s
+// CHECK-CTOR-INIT-2-NOT: NotImplemented:{TypedText MyCls}{LeftParen (}{Placeholder args}{RightParen )}
+// CHECK-CTOR-INIT-2: MemberRef:{TypedText object}{LeftParen (}{Placeholder args}{RightParen )} (35)
+// CHECK-CTOR-INIT-2: MemberRef:{TypedText value}{LeftParen (}{Placeholder args}{RightParen )} (7)
diff --git a/test/Index/complete-declarators.m b/test/Index/complete-declarators.m
index 747da01..071df60 100644
--- a/test/Index/complete-declarators.m
+++ b/test/Index/complete-declarators.m
@@ -39,12 +39,12 @@
// CHECK-CC3-NOT: VarDecl:{ResultType int}{TypedText q2}
// CHECK-CC3-NOT: VarDecl:{ResultType id}{TypedText q}
// CHECK-CC3: NotImplemented:{ResultType A *}{TypedText self} (34)
-// CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: ParmDecl:{ResultType id}{TypedText param1} (34)
// CHECK-CC4-NOT: VarDecl:{ResultType int}{TypedText q2}
// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
-// CHECK-CC4: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC4: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: c-index-test -code-completion-at=%s:23:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
// CHECK-CC5: NotImplemented:{TypedText _Bool} (50)
// CHECK-CC5: NotImplemented:{TypedText _Complex} (50)
diff --git a/test/Index/complete-enums.c b/test/Index/complete-enums.c
index 33a4cd4..713e24f 100644
--- a/test/Index/complete-enums.c
+++ b/test/Index/complete-enums.c
@@ -1,22 +1,22 @@
// Note: the run lines follow their respective tests, since line/column
// matter in this test.
-enum Color {
+enum __attribute__((deprecated)) Color {
Color_Red = 17,
Color_Green,
Color_Blue
};
int Greeby();
-void f(Color color) {
+void f(enum Color color) {
switch (color) {
case Red:
}
}
// RUN: c-index-test -code-completion-at=%s:11:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red}
+// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red} (65) (deprecated)
// RUN: c-index-test -code-completion-at=%s:12:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Blue} (7)
-// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Green} (7)
-// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red} (7)
+// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Blue} (7) (deprecated)
+// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Green} (7) (deprecated)
+// CHECK-CC2-NEXT: EnumConstantDecl:{ResultType enum Color}{TypedText Color_Red} (7) (deprecated)
diff --git a/test/Index/complete-enums.cpp b/test/Index/complete-enums.cpp
new file mode 100644
index 0000000..49a8932
--- /dev/null
+++ b/test/Index/complete-enums.cpp
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+enum class Color {
+ Red = 17,
+ Green,
+ Blue
+};
+int Greeby();
+void f(Color color) {
+ switch (color) {
+ case Color::Green:
+ case Color::Red;
+ }
+}
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Green} (7)
+// CHECK-CC1: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
+
+// RUN: c-index-test -code-completion-at=%s:13:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Blue} (7)
+// CHECK-CC2-NOT: Green
+// CHECK-CC2: EnumConstantDecl:{ResultType Color}{Text Color::}{TypedText Red} (7)
diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c
index aa22e77..afb6219 100644
--- a/test/Index/complete-exprs.c
+++ b/test/Index/complete-exprs.c
@@ -31,7 +31,7 @@ void f5(float f) {
// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
// CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
// CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
-// CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
// RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
@@ -39,7 +39,7 @@ void f5(float f) {
// CHECK-CC3: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
// CHECK-CC3-NOT: NotImplemented:{TypedText float}
// CHECK-CC3: ParmDecl:{ResultType int}{TypedText j} (34)
-// CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expressio
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expressio
// RUN: c-index-test -code-completion-at=%s:7:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
// RUN: c-index-test -code-completion-at=%s:7:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
@@ -48,7 +48,7 @@ void f5(float f) {
// CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
// CHECK-CC2: NotImplemented:{TypedText float} (50)
// CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (34)
-// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated)
diff --git a/test/Index/complete-exprs.cpp b/test/Index/complete-exprs.cpp
index a810065..de3aac5 100644
--- a/test/Index/complete-exprs.cpp
+++ b/test/Index/complete-exprs.cpp
@@ -26,8 +26,30 @@ void g() {
vector<int>(foo(), foo());
}
-// RUN: c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+struct X {
+ void f() const;
+};
+
+void X::f() const {
+
+}
+
+namespace N {
+ int x;
+ class C {
+ int member;
+
+ int f(int param) {
+ return member;
+ }
+ };
+}
+
+// RUN: c-index-test -code-completion-at=%s:20:2 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC1 %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:20:2 -std=c++0x %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText alignof}{LeftParen (}{Placeholder type}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType bool}{TypedText noexcept}{LeftParen (}{Placeholder expression}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType std::nullptr_t}{TypedText nullptr} (40)
// CHECK-CC1: NotImplemented:{TypedText operator} (40)
// CHECK-CC1-NOT: push_back
// CHECK-CC1: ClassDecl:{TypedText string} (50)
@@ -51,3 +73,12 @@ void g() {
// CHECK-CC3: ClassTemplate:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
// CHECK-CC3: CXXConstructor:{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder const T &}{Comma , }{Placeholder unsigned int n}{RightParen )} (50)
// CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText vector}{LeftAngle <}{Placeholder typename T}{RightAngle >}{LeftParen (}{Placeholder InputIterator first}{Comma , }{Placeholder InputIterator last}{RightParen )} (50)
+
+// RUN: c-index-test -code-completion-at=%s:34:1 %s -std=c++0x | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{ResultType const X *}{TypedText this} (40)
+
+// RUN: c-index-test -code-completion-at=%s:43:14 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// CHECK-CC5: FieldDecl:{ResultType int}{TypedText member} (8) (parent: ClassDecl 'N::C')
+// CHECK-CC5: ParmDecl:{ResultType int}{TypedText param} (8)
+// CHECK-CC5: StructDecl:{TypedText X} (50) (parent: TranslationUnit '(null)')
+// CHECK-CC5: VarDecl:{ResultType int}{TypedText x} (12) (parent: Namespace 'N')
diff --git a/test/Index/complete-exprs.m b/test/Index/complete-exprs.m
index 08ec019..c3ff63b 100644
--- a/test/Index/complete-exprs.m
+++ b/test/Index/complete-exprs.m
@@ -2,9 +2,9 @@ typedef signed char BOOL;
#define YES ((BOOL)1)
#define NO ((BOOL)0)
#define bool _Bool
+@interface NSArray + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; @end
@interface A
- (int)method:(id)param1;
-
@property int prop1;
@end
__strong id global;
@@ -12,10 +12,14 @@ __strong id global;
- (int)method:(id)param1 {
void foo(bool (^block)(id x, A* y));
for(BOOL B = YES; ; ) { }
+ @[ global ];
+ @{ global : global };
}
@end
// RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
// CHECK-CC1: TypedefDecl:{TypedText BOOL} (50)
// CHECK-CC1: macro definition:{TypedText bool} (51)
@@ -26,9 +30,20 @@ __strong id global;
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: TypedefDecl:{TypedText BOOL} (50)
// CHECK-CC2: NotImplemented:{TypedText char} (50)
-// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText foo}{LeftParen (}{Placeholder ^bool(id x, A *y)block}{RightParen )} (34)
// CHECK-CC3: VarDecl:{ResultType id}{TypedText global} (50)
// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (34)
+
+// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
+// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
+// CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
+// CHECK-CC4: macro definition:{TypedText bool} (51)
+// CHECK-CC4: macro definition:{TypedText NO} (65)
+// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
+// CHECK-CC4: macro definition:{TypedText YES} (65)
diff --git a/test/Index/complete-in-invalid-method.m b/test/Index/complete-in-invalid-method.m
new file mode 100644
index 0000000..0e6c8e6
--- /dev/null
+++ b/test/Index/complete-in-invalid-method.m
@@ -0,0 +1,19 @@
+@interface I
+-(void)foo;
+@end
+
+struct S {
+ int x,y;
+};
+
+@implementation I
+-(void) foo {
+ struct S s;
+ if (1) {
+ s.
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:13:7 -fobjc-nonfragile-abi %s | FileCheck %s
+// CHECK: FieldDecl:{ResultType int}{TypedText x}
+// CHECK: FieldDecl:{ResultType int}{TypedText y}
diff --git a/test/Index/complete-ivar-access.m b/test/Index/complete-ivar-access.m
new file mode 100644
index 0000000..13b43d8
--- /dev/null
+++ b/test/Index/complete-ivar-access.m
@@ -0,0 +1,69 @@
+@interface Other {
+@private
+ int other_private;
+@protected
+ int other_protected;
+@public
+ int other_public;
+}
+@end
+
+@interface Super {
+@private
+ int super_private;
+@protected
+ int super_protected;
+@public
+ int super_public;
+}
+@end
+
+@interface Super () {
+@private
+ int super_ext_private;
+@protected
+ int super_ext_protected;
+@public
+ int super_ext_public;
+}
+@end
+
+@interface Sub : Super {
+@private
+ int sub_private;
+@protected
+ int sub_protected;
+@public
+ int sub_public;
+}
+@end
+
+@implementation Sub
+- (void)method:(Sub *)sub with:(Other *)other {
+ sub->super_protected = 1;
+ other->other_public = 1;
+}
+
+void f(Sub *sub, Other *other) {
+ sub->super_protected = 1;
+ other->other_public = 1;
+}
+@end
+
+// RUN: c-index-test -code-completion-at=%s:43:8 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-SUB %s
+// RUN: c-index-test -code-completion-at=%s:48:8 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-SUB %s
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_private} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_protected} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText sub_public} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_private} (35) (inaccessible)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_protected} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_ext_public} (35)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_private} (37) (inaccessible)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_protected} (37)
+// CHECK-SUB: ObjCIvarDecl:{ResultType int}{TypedText super_public} (37)
+
+// RUN: c-index-test -code-completion-at=%s:44:10 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-OTHER %s
+// RUN: c-index-test -code-completion-at=%s:49:10 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-OTHER %s
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_private} (35) (inaccessible)
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_protected} (35) (inaccessible)
+// CHECK-OTHER: ObjCIvarDecl:{ResultType int}{TypedText other_public} (35)
diff --git a/test/Index/complete-lambdas.cpp b/test/Index/complete-lambdas.cpp
new file mode 100644
index 0000000..ba337e4
--- /dev/null
+++ b/test/Index/complete-lambdas.cpp
@@ -0,0 +1,43 @@
+// This test is line- and column-sensitive. See below for run lines.
+
+int global;
+
+struct X {
+ static int member;
+ void f(int zed) {
+ int local;
+ static int local_static;
+ [=] {
+ int inner_local;
+ [local, this, inner_local] {
+ }
+ }();
+ }
+};
+
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC1-NEXT: VarDecl:{ResultType int}{TypedText local} (34)
+// CHECK-CC1-NEXT: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC1-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:15 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC2-NEXT: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC2-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:21 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC3-NEXT: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:8 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: TypedefDecl:{TypedText Class} (50)
+// CHECK-CC4: TypedefDecl:{TypedText id} (50)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText inner_local} (34)
+// CHECK-CC4: VarDecl:{ResultType int}{TypedText local} (34)
+// CHECK-CC4: NotImplemented:{ResultType X *}{TypedText this} (40)
+// CHECK-CC4: ParmDecl:{ResultType int}{TypedText zed} (34)
+
+// RUN: c-index-test -code-completion-at=%s:12:15 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: c-index-test -code-completion-at=%s:12:21 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s
diff --git a/test/Index/complete-macros.c b/test/Index/complete-macros.c
index f1c1346..df798a8 100644
--- a/test/Index/complete-macros.c
+++ b/test/Index/complete-macros.c
@@ -19,6 +19,7 @@ void f2() {
#define variadic2(args...)
#define variadic3(args, ...)
#define variadic4(first, second, args, ...)
+#define variadic5(first, second, args ...)
void test_variadic() {
@@ -34,8 +35,9 @@ void test_variadic() {
// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: macro definition:{TypedText nil} (65)
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:24:2 %s | FileCheck -check-prefix=CHECK-VARIADIC %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:25:2 %s | FileCheck -check-prefix=CHECK-VARIADIC %s
// CHECK-VARIADIC: macro definition:{TypedText variadic1}{LeftParen (}{Placeholder ...}{RightParen )} (70)
// CHECK-VARIADIC: macro definition:{TypedText variadic2}{LeftParen (}{Placeholder args...}{RightParen )} (70)
// CHECK-VARIADIC: macro definition:{TypedText variadic3}{LeftParen (}{Placeholder args, ...}{RightParen )} (70)
-// CHECK-VARIADIC: macro definition:{TypedText variadic4}{LeftParen (}{Placeholder first}{Comma , }{Placeholder second...}{Placeholder first, second...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic4}{LeftParen (}{Placeholder first}{Comma , }{Placeholder second}{Comma , }{Placeholder args, ...}{RightParen )} (70)
+// CHECK-VARIADIC: macro definition:{TypedText variadic5}{LeftParen (}{Placeholder first}{Comma , }{Placeholder second}{Comma , }{Placeholder args...}{RightParen )} (70)
diff --git a/test/Index/complete-member-access.m b/test/Index/complete-member-access.m
index 48156d9..5e40be1 100644
--- a/test/Index/complete-member-access.m
+++ b/test/Index/complete-member-access.m
@@ -34,6 +34,14 @@ int test_more_props(Sub *s) {
return s.myOtherPropLikeThing;
}
+@interface Other
+@property Sub *sub;
+@end
+
+int test_two_levels(Other *other) {
+ return other.sub.myProp;
+}
+
// RUN: c-index-test -code-completion-at=%s:21:7 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText prop1}
// CHECK-CC1: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp}
@@ -59,4 +67,11 @@ int test_more_props(Sub *s) {
// CHECK-CC3-NEXT: Objective-C property access
// CHECK-CC3-NEXT: Container Kind: ObjCInterfaceDecl
// CHECK-CC3-NEXT: Container is complete
-// CHECK-CC3-NEXT: Container USR: c:objc(cs)Sub \ No newline at end of file
+// CHECK-CC3-NEXT: Container USR: c:objc(cs)Sub
+
+// RUN: c-index-test -code-completion-at=%s:42:20 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText myOtherPropLikeThing} (37)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText myProp} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText prop1} (35)
+// CHECK-CC4-NEXT: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp} (35)
+
diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m
index 2ab1197..becb7de 100644
--- a/test/Index/complete-method-decls.m
+++ b/test/Index/complete-method-decls.m
@@ -4,7 +4,7 @@
@protocol P1
- (id)abc;
- (id)initWithInt:(int)x;
-- (id)initWithTwoInts:(int)x second:(int)y;
+- (id)initWithTwoInts:(inout int)x second:(int)y;
- (int)getInt;
- (id)getSelf;
@end
@@ -57,7 +57,7 @@
@end
@interface Passing
-- (oneway void)method:(in id x);
+- (oneway void)method:(in id)x;
@end
@interface Gaps
@@ -65,44 +65,48 @@
@end
@implementation Gaps
-- (void)method:(int)x :(int)y;
+- (void)method:(int)x :(int)y {}
+@end
+
+@implementation Passing
+- (oneway void)method:(in id x) {}
@end
// RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40) (parent: ObjCProtocolDecl 'P1')
// RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
// RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
-// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
-// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s
-// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace
-// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42) (parent: ObjCProtocolDecl 'P1')
+// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40) (parent: ObjCInterfaceDecl 'B')
// CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s
// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
-// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s
// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
@@ -174,3 +178,7 @@
// <rdar://problem/8939352>
// RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s
// CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
+
+
+// RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s
+// CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method}{TypedText :}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40) (parent: ObjCInterfaceDecl 'Passing')
diff --git a/test/Index/complete-modules.m b/test/Index/complete-modules.m
new file mode 100644
index 0000000..b82430d
--- /dev/null
+++ b/test/Index/complete-modules.m
@@ -0,0 +1,14 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@__experimental_modules_import LibA.Extensions;
+
+// RUN: rm -rf %t
+// RUN: c-index-test -code-completion-at=%s:4:32 -fmodule-cache-path %t -fmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck -check-prefix=CHECK-TOP-LEVEL %s
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText Framework} (50)
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText LibA} (50)
+// CHECK-TOP-LEVEL: NotImplemented:{TypedText nested} (50)
+
+// RUN: c-index-test -code-completion-at=%s:4:37 -fmodule-cache-path %t -fmodules -F %S/Inputs/Frameworks -I %S/Inputs/Headers %s | FileCheck -check-prefix=CHECK-LIBA %s
+// CHECK-LIBA: NotImplemented:{TypedText Extensions} (50)
+
diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m
index 955ab6f..1835c3e 100644
--- a/test/Index/complete-objc-message.m
+++ b/test/Index/complete-objc-message.m
@@ -190,11 +190,11 @@ void test_DO(DO *d, A* a) {
}
// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: {TypedText categoryClassMethod}
-// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)}
-// CHECK-CC1: {TypedText classMethod2}
-// CHECK-CC1: {TypedText new}
-// CHECK-CC1: {TypedText protocolClassMethod}
+// CHECK-CC1: {TypedText categoryClassMethod} (35) (parent: ObjCCategoryDecl 'Foo(FooTestCategory)')
+// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText classMethod2} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText new} (35) (parent: ObjCInterfaceDecl 'Foo')
+// CHECK-CC1: {TypedText protocolClassMethod} (37) (parent: ObjCProtocolDecl 'FooTestProtocol')
// CHECK-CC1: Completion contexts:
// CHECK-CC1-NEXT: Objective-C class method
// CHECK-CC1-NEXT: Container Kind: ObjCInterfaceDecl
@@ -309,7 +309,7 @@ void test_DO(DO *d, A* a) {
// RUN: c-index-test -code-completion-at=%s:170:16 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s
// CHECK-CLASS-RESULT: ObjCClassMethodDecl:{ResultType void}{TypedText class_method3} (35)
-// CHECK-CLASS-RESULT: ObjCClassMethodDecl:{ResultType void}{TypedText class_method4} (35)
+// CHECK-CLASS-RESULT: ObjCClassMethodDecl:{ResultType void}{TypedText class_method4} (35) (parent: ObjCCategoryDecl 'A(Cat)')
// RUN: c-index-test -code-completion-at=%s:181:4 %s | FileCheck -check-prefix=CHECK-BLOCK-RECEIVER %s
// CHECK-BLOCK-RECEIVER: ObjCInterfaceDecl:{TypedText A} (50)
@@ -333,4 +333,4 @@ void test_DO(DO *d, A* a) {
// RUN: c-index-test -code-completion-at=%s:175:12 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s
// RUN: c-index-test -code-completion-at=%s:189:6 %s | FileCheck -check-prefix=CHECK-DISTRIB-OBJECTS %s
-// CHECK-DISTRIB-OBJECTS: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (in bycopyA *)}{HorizontalSpace }{TypedText result:}{Placeholder (out byrefA **)} (35)
+// CHECK-DISTRIB-OBJECTS: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (in bycopy A *)}{HorizontalSpace }{TypedText result:}{Placeholder (out byref A **)} (35)
diff --git a/test/Index/complete-qualified.cpp b/test/Index/complete-qualified.cpp
index 20f5105..f5c032c 100644
--- a/test/Index/complete-qualified.cpp
+++ b/test/Index/complete-qualified.cpp
@@ -14,7 +14,7 @@ void foo()
Foo::
// RUN: c-index-test -code-completion-at=%s:14:8 %s -o - | FileCheck -check-prefix=CC1 %s
-// CHECK-CC1: FieldDecl:{ResultType C<Foo, class Bar>}{TypedText c} (35)
-// CHECK-CC1: ClassDecl:{TypedText Foo} (35)
-// CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )} (35)
-// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35)
+// CHECK-CC1: FieldDecl:{ResultType C<Foo, class Bar>}{TypedText c} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: ClassDecl:{TypedText Foo} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )} (35) (parent: ClassDecl 'Foo')
+// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35) (parent: ClassDecl 'Foo')
diff --git a/test/Index/complete-recovery.m b/test/Index/complete-recovery.m
index 9300a79..19de0fb 100644
--- a/test/Index/complete-recovery.m
+++ b/test/Index/complete-recovery.m
@@ -18,16 +18,19 @@
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s 2>%t | FileCheck -check-prefix=CHECK-CC1 %s
// RUN: not grep error %t
-// CHECK-CC1: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC1: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
// CHECK-CC1-NOT: NotImplemented:{TypedText _Bool}
// CHECK-CC1: VarDecl:{ResultType A *}{TypedText a}
-// CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+
+// Test case for fix comitted in r145441.
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s -fms-compatibility | FileCheck -check-prefix=CHECK-CC1 %s
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:24 %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
+// CHECK-CC2: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
// CHECK-CC2: NotImplemented:{TypedText _Bool}
// CHECK-CC2: VarDecl:{ResultType A *}{TypedText a}
-// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )}
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:12:11 %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (int)} (32)
// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:13:22 %s | FileCheck -check-prefix=CHECK-CC3 %s
diff --git a/test/Index/complete-stmt.c b/test/Index/complete-stmt.c
index 98fa9df..e39431e 100644
--- a/test/Index/complete-stmt.c
+++ b/test/Index/complete-stmt.c
@@ -7,6 +7,10 @@ void f(int x) {
}
}
-// RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE %s
// CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Placeholder statements}{VerticalSpace }{RightBrace }} (40)
// CHECK-IF-ELSE: NotImplemented:{TypedText else}{HorizontalSpace }{Text if}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Placeholder statements}{VerticalSpace }{RightBrace }} (40)
+
+// RUN: c-index-test -code-completion-at=%s:7:4 %s | FileCheck -check-prefix=CHECK-IF-ELSE-SIMPLE %s
+// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else} (40)
+// CHECK-IF-ELSE-SIMPLE: NotImplemented:{TypedText else}{HorizontalSpace }{Text if}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )} (40)
diff --git a/test/Index/complete-super.cpp b/test/Index/complete-super.cpp
index 71c22ad..9ffa7c8 100644
--- a/test/Index/complete-super.cpp
+++ b/test/Index/complete-super.cpp
@@ -31,3 +31,12 @@ void B::bar(float real) {
// RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s
// CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (20)
+// RUN: c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS %s
+// CHECK-ACCESS: NotImplemented:{TypedText private} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText protected} (40)
+// CHECK-ACCESS: NotImplemented:{TypedText public} (40)
+
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:5:1 %s | FileCheck -check-prefix=CHECK-ACCESS-PATTERN %s
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText private}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText protected}{Colon :} (40)
+// CHECK-ACCESS-PATTERN: NotImplemented:{TypedText public}{Colon :} (40)
diff --git a/test/Index/complete-synthesized.m b/test/Index/complete-synthesized.m
index 81f1ba1..8c848fc 100644
--- a/test/Index/complete-synthesized.m
+++ b/test/Index/complete-synthesized.m
@@ -35,12 +35,12 @@
}
@end
-// RUN: c-index-test -code-completion-at=%s:24:1 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:30:2 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:34:2 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:24:1 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:30:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:34:2 -target x86_64-apple-macosx10.7 -fobjc-nonfragile-abi %s | FileCheck %s
// CHECK: NotImplemented:{TypedText _Bool} (50)
// CHECK: ObjCIvarDecl:{ResultType float}{TypedText _prop2} (35)
// CHECK-NOT: prop2
// CHECK-NOT: prop3
-// CHECK: ObjCIvarDecl:{ResultType double}{TypedText _prop4} (37)
+// CHECK: ObjCIvarDecl:{ResultType double}{TypedText _prop4} (35)
diff --git a/test/Index/complete-type-factors.m b/test/Index/complete-type-factors.m
index b7bafb4..e5aa893 100644
--- a/test/Index/complete-type-factors.m
+++ b/test/Index/complete-type-factors.m
@@ -44,7 +44,7 @@ void test2(A *a) {
// CHECK-CC1: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (32)
// CHECK-CC1: ParmDecl:{ResultType enum Priority}{TypedText priority} (17)
// CHECK-CC1: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (32)
-// CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC1: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// CHECK-CC1: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (25)
// RUN: c-index-test -code-completion-at=%s:17:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
@@ -59,7 +59,7 @@ void test2(A *a) {
// CHECK-CC2: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
// CHECK-CC2: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
// CHECK-CC2: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
-// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC2: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// CHECK-CC2: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
// RUN: c-index-test -code-completion-at=%s:18:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s
// CHECK-CC3: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (65)
@@ -75,7 +75,7 @@ void test2(A *a) {
// CHECK-CC3: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (16)
// CHECK-CC3: ParmDecl:{ResultType enum Priority}{TypedText priority} (8)
// CHECK-CC3: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (65)
-// CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC3: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// CHECK-CC3: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (12)
// RUN: c-index-test -code-completion-at=%s:19:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Blue} (16)
@@ -91,7 +91,7 @@ void test2(A *a) {
// CHECK-CC4: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
// CHECK-CC4: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
// CHECK-CC4: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
-// CHECK-CC4: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC4: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// CHECK-CC4: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
// RUN: c-index-test -code-completion-at=%s:21:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: c-index-test -code-completion-at=%s:22:7 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s
@@ -109,7 +109,7 @@ void test2(A *a) {
// CHECK-CC6: EnumConstantDecl:{ResultType enum Priority}{TypedText Low} (65)
// CHECK-CC6: ParmDecl:{ResultType enum Priority}{TypedText priority} (34)
// CHECK-CC6: EnumConstantDecl:{ResultType enum Color}{TypedText Red} (16)
-// CHECK-CC6: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
+// CHECK-CC6: NotImplemented:{ResultType size_t}{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// CHECK-CC6: FunctionDecl:{ResultType enum Priority}{TypedText test1}{LeftParen (}{Placeholder enum Priority priority}{Comma , }{Placeholder enum Color color}{Comma , }{Placeholder int integer}{RightParen )} (50)
// RUN: c-index-test -code-completion-at=%s:31:13 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
// RUN: c-index-test -code-completion-at=%s:32:13 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s
diff --git a/test/Index/crash-recovery-code-complete.c b/test/Index/crash-recovery-code-complete.c
index 9cad985..dde90bc 100644
--- a/test/Index/crash-recovery-code-complete.c
+++ b/test/Index/crash-recovery-code-complete.c
@@ -3,9 +3,10 @@
// RUN: "-remap-file=%s;%S/Inputs/crash-recovery-code-complete-remap.c" \
// RUN: %s 2> %t.err
// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s
-// RUN: rm %t-preamble.pch
+// RUN: test ! -e %t-preamble.pch
// CHECK-CODE-COMPLETE-CRASH: Unable to perform code completion!
//
// REQUIRES: crash-recovery
+// REQUIRES: shell
#warning parsing original file
diff --git a/test/Index/crash-recovery-modules.m b/test/Index/crash-recovery-modules.m
new file mode 100644
index 0000000..212923f
--- /dev/null
+++ b/test/Index/crash-recovery-modules.m
@@ -0,0 +1,20 @@
+// Clear out the module cache entirely, so we start from nothing.
+// RUN: rm -rf %t
+
+// Parse the file, such that building the module will cause Clang to crash.
+// RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s
+// CHECK-CRASH: crash-recovery-modules.m:16:32:{16:2-16:37}: fatal error: could not build module 'Crash'
+
+// Parse the file again, without crashing, to make sure that
+// subsequent parses do the right thing.
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodule-cache-path %t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s
+
+// REQUIRES: crash-recovery
+// REQUIRES: shell
+
+@__experimental_modules_import Crash;
+
+void test() {
+ const char* error = getCrashString();
+}
diff --git a/test/Index/crash-recovery-reparse.c b/test/Index/crash-recovery-reparse.c
index 243a914..06bb76b 100644
--- a/test/Index/crash-recovery-reparse.c
+++ b/test/Index/crash-recovery-reparse.c
@@ -3,9 +3,10 @@
// RUN: -remap-file="%s;%S/Inputs/crash-recovery-reparse-remap.c" \
// RUN: %s 2> %t.err
// RUN: FileCheck < %t.err -check-prefix=CHECK-REPARSE-SOURCE-CRASH %s
-// RUN: rm %t-preamble.pch
+// RUN: test ! -e $t-preamble.pch
// CHECK-REPARSE-SOURCE-CRASH: Unable to reparse translation unit
//
// REQUIRES: crash-recovery
+// REQUIRES: shell
#warning parsing original file
diff --git a/test/Index/cxx11-lambdas.cpp b/test/Index/cxx11-lambdas.cpp
new file mode 100644
index 0000000..93db022
--- /dev/null
+++ b/test/Index/cxx11-lambdas.cpp
@@ -0,0 +1,33 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+ void f() {
+ int localA, localB;
+ auto lambda = [&localA, localB] (Integer x) -> Integer {
+ return localA + localB + x;
+ };
+ }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++11 %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx11-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:21: VariableRef=localA:6:9 Extent=[7:21 - 7:27]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:29: VariableRef=localB:6:17 Extent=[7:29 - 7:35]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:52: TypeRef=Integer:3:13 Extent=[7:52 - 7:59]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:46: ParmDecl=x:7:46 (Definition) Extent=[7:38 - 7:47]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:38: TypeRef=Integer:3:13 Extent=[7:38 - 7:45]
+// CHECK-LOAD: cxx11-lambdas.cpp:7:60: CompoundStmt= Extent=[7:60 - 9:6]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:33]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:14: DeclRefExpr=localA:6:9 Extent=[8:14 - 8:20]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:23: DeclRefExpr=localB:6:17 Extent=[8:23 - 8:29]
+// CHECK-LOAD: cxx11-lambdas.cpp:8:32: DeclRefExpr=x:7:46 Extent=[8:32 - 8:33]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++11 %s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: VariableRef=localA:6:9 | loc: 7:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: VariableRef=localB:6:17 | loc: 7:29
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:52
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 7:38
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: DeclRefExpr=localA:6:9 | loc: 8:14
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: DeclRefExpr=localB:6:17 | loc: 8:23
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: c:cxx11-lambdas.cpp@157@S@X@F@f#@Ca@F@operator()#I#1@x | lang: C | cursor: DeclRefExpr=x:7:46 | loc: 8:32
diff --git a/test/Index/error-on-deserialized.c b/test/Index/error-on-deserialized.c
new file mode 100644
index 0000000..8ba8283
--- /dev/null
+++ b/test/Index/error-on-deserialized.c
@@ -0,0 +1,13 @@
+
+#include "targeted-top.h"
+
+// This tests that we will correctly error out on the deserialized decl.
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 not c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK: error: NestedVar1 was deserialized
diff --git a/test/Index/file-macro-refs.c b/test/Index/file-macro-refs.c
new file mode 100644
index 0000000..ed01cf5
--- /dev/null
+++ b/test/Index/file-macro-refs.c
@@ -0,0 +1,12 @@
+#define FOO
+
+FOO
+FOO
+
+// RUN: c-index-test -file-refs-at=%s:3:2 %s | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -file-refs-at=%s:3:2 %s | FileCheck %s
+
+// CHECK: macro expansion=FOO:1:9
+// CHECK-NEXT: macro definition=FOO =[1:9 - 1:12]
+// CHECK-NEXT: macro expansion=FOO:1:9 =[3:1 - 3:4]
+// CHECK-NEXT: macro expansion=FOO:1:9 =[4:1 - 4:4]
diff --git a/test/Index/file-refs-subscripting.m b/test/Index/file-refs-subscripting.m
new file mode 100644
index 0000000..493d93d
--- /dev/null
+++ b/test/Index/file-refs-subscripting.m
@@ -0,0 +1,65 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+id testArray(int index, id p) {
+ NSMutableArray *array;
+ array[3] = 0;
+ NSArray *arr = @[ p, p ];
+ return array[index];
+}
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test \
+
+// RUN: -file-refs-at=%s:22:21 \
+// CHECK: ParmDecl=index:22:18
+// CHECK-NEXT: ParmDecl=index:22:18 (Definition) =[22:18 - 22:23]
+// CHECK-NEXT: DeclRefExpr=index:22:18 =[26:16 - 26:21]
+
+// RUN: -file-refs-at=%s:22:28 \
+// CHECK-NEXT: ParmDecl=p:22:28
+// CHECK-NEXT: ParmDecl=p:22:28 (Definition) =[22:28 - 22:29]
+// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:21 - 25:22]
+// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:24 - 25:25]
+
+// RUN: -file-refs-at=%s:34:16 \
+// CHECK-NEXT: DeclRefExpr=key:31:13
+// CHECK-NEXT: VarDecl=key:31:13 (Definition) =[31:13 - 31:16]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[33:26 - 33:29]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[34:14 - 34:17]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:27 - 35:30]
+// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:43 - 35:46]
+
+// RUN: -file-refs-at=%s:35:35 \
+// CHECK-NEXT: DeclRefExpr=newObject:32:6
+// CHECK-NEXT: VarDecl=newObject:32:6 (Definition) =[32:6 - 32:15]
+// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[34:21 - 34:30]
+// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[35:32 - 35:41]
+
+// RUN: -target x86_64-apple-macosx10.7 %s | FileCheck %s
diff --git a/test/Index/file-refs.m b/test/Index/file-refs.m
index 2267259..3f21c9e 100644
--- a/test/Index/file-refs.m
+++ b/test/Index/file-refs.m
@@ -43,24 +43,28 @@ void test2(Sub *s, id<Prot1> p) {
// RUN: -file-refs-at=%s:7:18 \
// CHECK: ObjCImplementationDecl=Foo:7:17 (Definition)
+
+// FIXME: There should not be 2 for the same range.
+// CHECK-NEXT: ObjCInterfaceDecl=Foo:1:8 =[1:8 - 1:11]
// CHECK-NEXT: ObjCClassRef=Foo:3:12 =[1:8 - 1:11]
+
// CHECK-NEXT: ObjCInterfaceDecl=Foo:3:12 =[3:12 - 3:15]
// CHECK-NEXT: ObjCImplementationDecl=Foo:7:17 (Definition) =[7:17 - 7:20]
// CHECK-NEXT: ObjCClassRef=Foo:3:12 =[13:11 - 13:14]
// RUN: -file-refs-at=%s:4:10 \
-// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:1
-// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:1 =[4:6 - 4:16]
-// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:1 (Definition) [Overrides @4:1] =[8:6 - 8:16]
-// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:1 =[14:8 - 14:18]
-// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:1 =[15:8 - 15:18]
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6 =[4:6 - 4:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:6 (Definition) =[8:6 - 8:16]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[14:8 - 14:18]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[15:8 - 15:18]
// RUN: -file-refs-at=%s:15:27 \
-// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:1
-// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:1 =[4:24 - 4:32]
-// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:1 (Definition) [Overrides @4:1] =[8:24 - 8:32]
-// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:1 =[14:21 - 14:29]
-// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:1 =[15:22 - 15:30]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::4:6 =[4:24 - 4:32]
+// CHECK-NEXT: ObjCInstanceMethodDecl=setWithInt:andFloat::8:6 (Definition) =[8:24 - 8:32]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[14:21 - 14:29]
+// CHECK-NEXT: ObjCMessageExpr=setWithInt:andFloat::4:6 =[15:22 - 15:30]
// RUN: -file-refs-at=%s:18:13 \
// CHECK-NEXT: ObjCProtocolDecl=Prot1:18:11 (Definition)
@@ -69,19 +73,19 @@ void test2(Sub *s, id<Prot1> p) {
// CHECK-NEXT: ObjCProtocolRef=Prot1:18:11 =[36:23 - 36:28]
// RUN: -file-refs-at=%s:38:10 \
-// CHECK-NEXT: ObjCMessageExpr=protMeth:19:1
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:1 =[19:8 - 19:16]
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:1 [Overrides @19:1] =[29:8 - 29:16]
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:1 (Definition) [Overrides @29:1] =[33:8 - 33:16]
-// CHECK-NEXT: ObjCMessageExpr=protMeth:29:1 =[37:6 - 37:14]
-// CHECK-NEXT: ObjCMessageExpr=protMeth:19:1 =[38:6 - 38:14]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:8 =[19:8 - 19:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:8 [Overrides @19:8] =[29:8 - 29:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8] =[33:8 - 33:16]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:29:8 =[37:6 - 37:14]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8 =[38:6 - 38:14]
// RUN: -file-refs-at=%s:33:12 \
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:1 (Definition) [Overrides @29:1]
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:1 =[19:8 - 19:16]
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:1 [Overrides @19:1] =[29:8 - 29:16]
-// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:1 (Definition) [Overrides @29:1] =[33:8 - 33:16]
-// CHECK-NEXT: ObjCMessageExpr=protMeth:29:1 =[37:6 - 37:14]
-// CHECK-NEXT: ObjCMessageExpr=protMeth:19:1 =[38:6 - 38:14]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:19:8 =[19:8 - 19:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:29:8 [Overrides @19:8] =[29:8 - 29:16]
+// CHECK-NEXT: ObjCInstanceMethodDecl=protMeth:33:8 (Definition) [Overrides @19:8] =[33:8 - 33:16]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:29:8 =[37:6 - 37:14]
+// CHECK-NEXT: ObjCMessageExpr=protMeth:19:8 =[38:6 - 38:14]
// RUN: %s | FileCheck %s
diff --git a/test/Index/fix-its.c b/test/Index/fix-its.c
index d82f2998..d5cb1af 100644
--- a/test/Index/fix-its.c
+++ b/test/Index/fix-its.c
@@ -8,7 +8,7 @@ struct X {
void f(struct X *x) {
// CHECK: error: no member named 'wobble' in 'struct X'; did you mean 'wibble'?
- // CHECK-NOT: FIX-IT
+ // CHECK: FIX-IT: Replace [13:12 - 13:18] with "wibble"
// CHECK: note: 'wibble' declared here
MACRO(x->wobble = 17);
// CHECK: error: no member named 'wabble' in 'struct X'; did you mean 'wibble'?
@@ -16,3 +16,12 @@ void f(struct X *x) {
// CHECK: note: 'wibble' declared here
x->wabble = 17;
}
+
+int printf(const char *restrict, ...);
+
+void f2() {
+ unsigned long index;
+ // CHECK: warning: format specifies type 'int' but the argument has type 'unsigned long'
+ // CHECK: FIX-IT: Replace [26:17 - 26:19] with "%ld"
+ MACRO(printf("%d", index));
+}
diff --git a/test/Index/get-cursor-macro-args.m b/test/Index/get-cursor-macro-args.m
index 4e0ac78..4945fd3 100644
--- a/test/Index/get-cursor-macro-args.m
+++ b/test/Index/get-cursor-macro-args.m
@@ -14,6 +14,6 @@
// RUN: %s -include-pch %t.pch | FileCheck %s
// CHECK: ObjCClassRef=MyClass:1:12
-// CHECK-NEXT: ObjCMessageExpr=meth:2:1
-// CHECK-NEXT: ObjCMessageExpr=meth:2:1
+// CHECK-NEXT: ObjCMessageExpr=meth:2:8
+// CHECK-NEXT: ObjCMessageExpr=meth:2:8
// CHECK-NEXT: ObjCClassRef=MyClass:1:12
diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp
index 441ed1c..e1e6835 100644
--- a/test/Index/get-cursor.cpp
+++ b/test/Index/get-cursor.cpp
@@ -33,6 +33,11 @@ struct YDerived : Y {
void test() {
X foo;
+
+ try {
+ } catch (X e) {
+ X x;
+ }
}
// RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
@@ -80,3 +85,11 @@ void test() {
// RUN: c-index-test -cursor-at=%s:21:3 %s | FileCheck -check-prefix=CHECK-MEMBER %s
// CHECK-MEMBER: FieldDecl=member:21:7 (Definition)
// CHECK-MEMBER-NEXT: Completion string: {ResultType int}{TypedText member}
+
+// RUN: c-index-test -cursor-at=%s:38:12 -cursor-at=%s:39:5 %s | FileCheck -check-prefix=CHECK-CXXCATCH %s
+// CHECK-CXXCATCH: TypeRef=struct X:3:8
+// CHECK-CXXCATCH-NEXT: TypeRef=struct X:3:8
+
+// RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
+// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15]
+// CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8]
diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m
index 69e4f25..60e35ee 100644
--- a/test/Index/get-cursor.m
+++ b/test/Index/get-cursor.m
@@ -26,12 +26,62 @@
@synthesize name = _name;
@end
+@interface rdar10902015
+@end
+
+@implementation rdar10902015
+
+struct S { int x; };
+
+-(void)mm:(struct S*)s {
+ rdar10902015 *i = 0;
+ s->x = 0;
+ Test1 *test1;
+ test1.name = 0;
+}
+@end
+
+@interface Test2
+-(int)implicitProp;
+-(void)setImplicitProp:(int)x;
+@end
+
+void foo1(Test2 *test2) {
+ int x = test2.implicitProp;
+ test2.implicitProp = x;
+ ++test2.implicitProp;
+}
+
+@interface Test3
+-(void)setFoo:(int)x withBar:(int)y;
+@end
+
+void foo3(Test3 *test3) {
+ [test3 setFoo:2 withBar:4];
+}
+
// RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
// CHECK-PROP: ObjCPropertyDecl=foo1:4:26
// CHECK-PROP: ObjCPropertyDecl=foo2:5:27
-// RUN: c-index-test -cursor-at=%s:11:11 %s -ccc-host-triple x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
+// RUN: c-index-test -cursor-at=%s:11:11 %s -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
// CHECK-WITH-WEAK: ObjCClassRef=Foo:8:8
// RUN: c-index-test -cursor-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-METHOD %s
-// CHECK-METHOD: ObjCInstanceMethodDecl=name:20:1
+// CHECK-METHOD: 20:7 ObjCInstanceMethodDecl=name:20:7 Extent=[20:1 - 20:12]
+
+// RUN: c-index-test -cursor-at=%s:37:17 %s | FileCheck -check-prefix=CHECK-IN-IMPL %s
+// CHECK-IN-IMPL: VarDecl=i:37:17
+
+// RUN: c-index-test -cursor-at=%s:38:6 -cursor-at=%s:40:11 \
+// RUN: -cursor-at=%s:50:20 -cursor-at=%s:51:15 -cursor-at=%s:52:20 %s | FileCheck -check-prefix=CHECK-MEMBERREF %s
+// CHECK-MEMBERREF: 38:6 MemberRefExpr=x:34:16 SingleRefName=[38:6 - 38:7] RefName=[38:6 - 38:7] Extent=[38:3 - 38:7]
+// CHECK-MEMBERREF: 40:9 MemberRefExpr=name:23:21 Extent=[40:3 - 40:13] Spelling=name ([40:9 - 40:13])
+// CHECK-MEMBERREF: 50:17 MemberRefExpr=implicitProp:45:7 Extent=[50:11 - 50:29] Spelling=implicitProp ([50:17 - 50:29])
+// CHECK-MEMBERREF: 51:9 MemberRefExpr=setImplicitProp::46:8 Extent=[51:3 - 51:21] Spelling=setImplicitProp: ([51:9 - 51:21])
+// CHECK-MEMBERREF: 52:11 MemberRefExpr=setImplicitProp::46:8 Extent=[52:5 - 52:23] Spelling=setImplicitProp: ([52:11 - 52:23])
+
+// RUN: c-index-test -cursor-at=%s:56:24 -cursor-at=%s:60:14 \
+// RUN: %s | FileCheck -check-prefix=CHECK-SPELLRANGE %s
+// CHECK-SPELLRANGE: 56:8 ObjCInstanceMethodDecl=setFoo:withBar::56:8 Extent=[56:1 - 56:37] Spelling=setFoo:withBar: ([56:8 - 56:14][56:22 - 56:29]) Selector index=1
+// CHECK-SPELLRANGE: 60:3 ObjCMessageExpr=setFoo:withBar::56:8 Extent=[60:3 - 60:29] Spelling=setFoo:withBar: ([60:10 - 60:16][60:19 - 60:26]) Selector index=0
diff --git a/test/Index/index-attrs.m b/test/Index/index-attrs.m
new file mode 100644
index 0000000..09c52ba
--- /dev/null
+++ b/test/Index/index-attrs.m
@@ -0,0 +1,17 @@
+@class Foo;
+@interface Bar
+@property (retain) __attribute__((iboutletcollection(Foo))) Foo *prop;
+@end
+
+@interface I
+-(id)prop __attribute__((annotate("anno")));
+-(void)setProp:(id)p __attribute__((annotate("anno")));
+@property (assign) id prop __attribute__((annotate("anno")));
+@end
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: <attribute>: attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface]
+
+// CHECK: <attribute>: attribute(annotate)=anno
+// CHECK: <getter>: kind: objc-instance-method | name: prop | {{.*}} <attribute>: attribute(annotate)=anno
+// CHECK: <setter>: kind: objc-instance-method | name: setProp: | {{.*}} <attribute>: attribute(annotate)=anno
diff --git a/test/Index/index-decls.m b/test/Index/index-decls.m
new file mode 100644
index 0000000..9e4e620
--- /dev/null
+++ b/test/Index/index-decls.m
@@ -0,0 +1,30 @@
+@interface I
+@property (readonly) id prop;
+ -(id)prop;
+@end
+
+@interface I()
+@property (assign,readwrite) id prop;
+@end
+
+@implementation I
+@synthesize prop = _prop;
+@end
+
+rdar://11015325
+@interface I1
+__attribute__((something)) @interface I2 @end
+@end
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+// CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2
+// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 2:25
+// CHECK: [indexDeclaration]: kind: objc-category | name: | {{.*}} | loc: 6:12
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 7:33
+// CHECK: [indexDeclaration]: kind: objc-property | name: prop | {{.*}} | loc: 7:33
+
+// CHECK: [indexDeclaration]: kind: objc-ivar | name: _prop | {{.*}} | loc: 11:20
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
+// CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17]
diff --git a/test/Index/index-invalid-code.m b/test/Index/index-invalid-code.m
new file mode 100644
index 0000000..9084533
--- /dev/null
+++ b/test/Index/index-invalid-code.m
@@ -0,0 +1,8 @@
+struct S {
+ int {
+};
+typedef struct S S;
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: struct | name: S |
+// CHECK-NOT: [indexDeclaration]: kind: struct | name: S |
diff --git a/test/Index/index-many-logical-ops.c b/test/Index/index-many-logical-ops.c
new file mode 100644
index 0000000..67017de
--- /dev/null
+++ b/test/Index/index-many-logical-ops.c
@@ -0,0 +1,2011 @@
+// RUN: c-index-test -index-file %s | FileCheck %s
+
+// rdar://10941790
+// Check that we don't get stack overflow trying to index a huge number of
+// logical operators.
+
+// CHECK: [indexDeclaration]: kind: function | name: foo
+int foo(int x) {
+ return
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x;
+}
diff --git a/test/Index/index-refs.cpp b/test/Index/index-refs.cpp
new file mode 100644
index 0000000..77e2af7
--- /dev/null
+++ b/test/Index/index-refs.cpp
@@ -0,0 +1,121 @@
+
+namespace NS {
+ extern int gx;
+ typedef int MyInt;
+}
+
+enum {
+ EnumVal = 1
+};
+
+NS::MyInt NS::gx = EnumVal;
+
+void foo() {
+ NS::MyInt x;
+}
+
+enum {
+ SecondVal = EnumVal
+};
+
+struct S {
+ S& operator++();
+ int operator*();
+ S& operator=(int x);
+ S& operator!=(int x);
+ S& operator()(int x);
+};
+
+void foo2(S &s) {
+ (void)++s;
+ (void)*s;
+ s = 3;
+ (void)(s != 3);
+ s(3);
+}
+
+namespace NS {
+ namespace Inn {}
+ typedef int Foo;
+}
+
+using namespace NS;
+using namespace NS::Inn;
+using NS::Foo;
+
+template <typename T1, typename T2>
+struct TS { };
+
+template <typename T>
+struct TS<T, int> {
+ typedef int MyInt;
+};
+
+void foo3() {
+ TS<int, int> s;
+}
+
+const int array_size = 3;
+typedef int some_arr[array_size];
+
+const int default_param = 3;
+void foo4(int p = default_param);
+
+struct S2 {
+ int x,y;
+};
+
+void foo5() {
+ struct S2 s = { .y = 1, .x = 4};
+}
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: namespace | name: NS
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: enum
+// CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: EnumVal
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: enum
+// CHECK-NEXT: [indexDeclaration]: kind: enumerator | name: SecondVal
+// CHECK-NEXT: [indexEntityReference]: kind: enumerator | name: EnumVal
+
+// CHECK: [indexDeclaration]: kind: function | name: foo2
+// CHECK: [indexEntityReference]: kind: c++-instance-method | name: operator++
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator*
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator=
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator!=
+// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: operator()
+
+// CHECK: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 42:17
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 43:17
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: Inn | {{.*}} | loc: 43:21
+// CHECK-NEXT: [indexEntityReference]: kind: namespace | name: NS | {{.*}} | loc: 44:7
+// CHECK-NEXT: [indexEntityReference]: kind: typedef | name: Foo | {{.*}} | loc: 44:11
+
+// CHECK: [indexDeclaration]: kind: c++-class-template | name: TS | {{.*}} | loc: 47:8
+// CHECK-NEXT: [indexDeclaration]: kind: struct-template-partial-spec | name: TS | USR: c:@SP>1#T@TS>#t0.0#I | {{.*}} | loc: 50:8
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@SP>1#T@TS>#t0.0#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+/* when indexing implicit instantiations
+ [indexDeclaration]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 50:8
+ [indexDeclaration]: kind: typedef | name: MyInt | USR: c:index-refs.cpp@593@S@TS>#I@T@MyInt | {{.*}} | loc: 51:15 | semantic-container: [TS:50:8] | lexical-container: [TS:50:8]
+ */
+// CHECK-NEXT: [indexDeclaration]: kind: function | name: foo3
+/* when indexing implicit instantiations
+ [indexEntityReference]: kind: struct-template-spec | name: TS | USR: c:@S@TS>#I | {{.*}} | loc: 55:3
+*/
+// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: TS | USR: c:@ST>2#T#T@TS | {{.*}} | loc: 55:3
+
+// CHECK: [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
+// CHECK: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+// CHECK-NOT: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
+
+// CHECK: [indexEntityReference]: kind: field | name: y | {{.*}} | loc: 69:20
+// CHECK-NEXT: [indexEntityReference]: kind: field | name: x | {{.*}} | loc: 69:28
diff --git a/test/Index/index-subscripting-literals.m b/test/Index/index-subscripting-literals.m
new file mode 100644
index 0000000..4ecad0b
--- /dev/null
+++ b/test/Index/index-subscripting-literals.m
@@ -0,0 +1,66 @@
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int idx;
+id p;
+
+id testArray() {
+ NSMutableArray *array;
+ array[idx] = p;
+ NSArray *arr = @[ p, p ];
+ return array[idx];
+}
+
+NSString *key;
+id newObject, oldObject;
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+// RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck %s
+
+// CHECK: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 27:9
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 27:16 | <parent>:: kind: function | name: testArray | USR: c:@F@testArray | lang: C | container: [testArray:25:4] | refkind: direct
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:atIndexedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSArray
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: arrayWithObjects:count:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:21
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:24
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 29:16
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectAtIndexedSubscript:
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: key
+
+// CHECK: [indexEntityReference]: kind: variable | name: oldObject
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 37:26
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectForKeyedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 38:14
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 38:21
+// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:forKeyedSubscript:
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSDictionary
+// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: dictionaryWithObjects:forKeys:count:
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:27
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 39:32
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:43
+// CHECK-NEXT: [indexEntityReference]: kind: variable | name: oldObject | USR: c:@oldObject | lang: C | cursor: DeclRefExpr=oldObject:33:15 | loc: 39:48
diff --git a/test/Index/index-suppress-refs.cpp b/test/Index/index-suppress-refs.cpp
new file mode 100644
index 0000000..113dd40
--- /dev/null
+++ b/test/Index/index-suppress-refs.cpp
@@ -0,0 +1,12 @@
+
+#include "index-suppress-refs.hpp"
+
+class Sub : B1, B2 {
+ typedef B1 Base1;
+ typedef B2 Base2;
+};
+
+// RUN: env CINDEXTEST_SUPPRESSREFS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: c++-class | name: Sub
+// CHECK-NOT: [indexEntityReference]: kind: c++-class | name: B1
+// CHECK-NOT: [indexEntityReference]: kind: c++-class | name: B2
diff --git a/test/Index/index-suppress-refs.h b/test/Index/index-suppress-refs.h
new file mode 100644
index 0000000..03c5624
--- /dev/null
+++ b/test/Index/index-suppress-refs.h
@@ -0,0 +1,9 @@
+
+@interface I
+@end
+
+@interface B
+@end
+
+@protocol P
+@end
diff --git a/test/Index/index-suppress-refs.hpp b/test/Index/index-suppress-refs.hpp
new file mode 100644
index 0000000..4aab08b
--- /dev/null
+++ b/test/Index/index-suppress-refs.hpp
@@ -0,0 +1,3 @@
+
+class B1 {};
+class B2 {};
diff --git a/test/Index/index-suppress-refs.m b/test/Index/index-suppress-refs.m
new file mode 100644
index 0000000..46420ee
--- /dev/null
+++ b/test/Index/index-suppress-refs.m
@@ -0,0 +1,44 @@
+
+#include "index-suppress-refs.h"
+
+#define TYPEDEF(x) typedef int x
+TYPEDEF(MyInt);
+
+MyInt gx;
+
+@class I;
+
+@interface I(cat)
+-(I*)meth;
+@end
+
+@class I;
+
+@interface S : B<P>
+-(void)meth:(B*)b :(id<P>)p;
+@end
+
+// RUN: env CINDEXTEST_SUPPRESSREFS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: B
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: objc-protocol | name: P
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: [indexDeclaration]: kind: typedef | name: MyInt
+// CHECK-NEXT: [indexDeclaration]: kind: variable | name: gx
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: <ObjCContainerInfo>: kind: forward-ref
+// CHECK-NEXT: [indexDeclaration]: kind: objc-category | name: cat
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: <ObjCCategoryInfo>: class: kind: objc-class | name: I
+// CHECK-NEXT: [indexDeclaration]: kind: objc-instance-method | name: meth
+// CHECK-NOT: [indexEntityReference]: kind: objc-class | name: I
+// CHECK-NOT: [indexDeclaration]: kind: objc-class | name: I
+// CHECK-NEXT: [indexDeclaration]: kind: objc-class | name: S
+// CHECK-NEXT: <ObjCContainerInfo>: kind: interface
+// CHECK-NEXT: <base>: kind: objc-class | name: B
+// CHECK-NEXT: <protocol>: kind: objc-protocol | name: P
+// CHECK-NEXT: [indexDeclaration]: kind: objc-instance-method | name: meth::
+// CHECK-NOT: [indexEntityReference]: kind: objc-class | name: B
+// CHECK-NOT: [indexEntityReference]: kind: objc-protocol | name: P \ No newline at end of file
diff --git a/test/Index/invalid-code-rdar10451854.m b/test/Index/invalid-code-rdar10451854.m
new file mode 100644
index 0000000..1562671
--- /dev/null
+++ b/test/Index/invalid-code-rdar10451854.m
@@ -0,0 +1,15 @@
+struct {
+
+@implementation Foo
+
+- (void)finalize {
+ NSLog(@"bar");
+}
+
+- (NSArray *)graphics {
+}
+
+@end
+
+// Test that we don't crash
+// RUN: c-index-test -test-load-source-reparse 3 local %s
diff --git a/test/Index/invalid-rdar-8236270.cpp b/test/Index/invalid-rdar-8236270.cpp
index 4593b51..85a0eaa 100644
--- a/test/Index/invalid-rdar-8236270.cpp
+++ b/test/Index/invalid-rdar-8236270.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source all %s | FileCheck %s
// This test case previously just crashed the frontend.
diff --git a/test/Index/linkage.c b/test/Index/linkage.c
index d1f1c5b..41a1fbd 100644
--- a/test/Index/linkage.c
+++ b/test/Index/linkage.c
@@ -11,6 +11,8 @@ void bar(int y) {
extern int n;
static int wibble(int);
+void ena(int (*dio)(int tria));
+
// CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External
// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External
// CHECK: VarDecl=x:4:5linkage=External
@@ -22,5 +24,7 @@ static int wibble(int);
// CHECK: VarDecl=k:9:7 (Definition)linkage=NoLinkage
// CHECK: VarDecl=n:11:12linkage=External
// CHECK: FunctionDecl=wibble:12:12linkage=Internal
-// CHECL: ParmDecl=:12:22 (Definition)linkage=NoLinkage
-
+// CHECK: ParmDecl=:12:22 (Definition)linkage=NoLinkage
+// CHECK: FunctionDecl=ena:14:6linkage=External
+// CHECK: ParmDecl=dio:14:16 (Definition)linkage=NoLinkage
+// CHECK: ParmDecl=tria:14:25 (Definition)linkage=NoLinkage
diff --git a/test/Index/local-symbols.m b/test/Index/local-symbols.m
index 01c8305..b4eb262 100644
--- a/test/Index/local-symbols.m
+++ b/test/Index/local-symbols.m
@@ -29,10 +29,10 @@
// CHECK: local-symbols.m:6:12: ObjCInterfaceDecl=Foo:6:12 Extent=[6:1 - 10:5]
// CHECK: local-symbols.m:7:6: ObjCIvarDecl=x:7:6 (Definition) Extent=[7:3 - 7:7]
// CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5]
-// CHECK: local-symbols.m:9:1: ObjCInstanceMethodDecl=bar:9:1 Extent=[9:1 - 9:12]
+// CHECK: local-symbols.m:9:8: ObjCInstanceMethodDecl=bar:9:8 Extent=[9:1 - 9:12]
// CHECK: local-symbols.m:9:4: TypeRef=id:0:0 Extent=[9:4 - 9:6]
// CHECK: local-symbols.m:12:17: ObjCImplementationDecl=Foo:12:17 (Definition) Extent=[12:1 - 16:2]
-// CHECK: local-symbols.m:13:1: ObjCInstanceMethodDecl=bar:13:1 (Definition) [Overrides @9:1] Extent=[13:1 - 15:2]
+// CHECK: local-symbols.m:13:8: ObjCInstanceMethodDecl=bar:13:8 (Definition) Extent=[13:1 - 15:2]
// CHECK: local-symbols.m:13:4: TypeRef=id:0:0 Extent=[13:4 - 13:6]
// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11]
// CHECK: local-symbols.m:14:10: IntegerLiteral= Extent=[14:10 - 14:11]
diff --git a/test/Index/ms-if-exists.cpp b/test/Index/ms-if-exists.cpp
new file mode 100644
index 0000000..0815a03
--- /dev/null
+++ b/test/Index/ms-if-exists.cpp
@@ -0,0 +1,24 @@
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:3:1:11:3 -fms-extensions -fno-ms-compatibility -fno-delayed-template-parsing %s | FileCheck %s
+
+// CHECK: Identifier: "T" [3:15 - 3:16] TypeRef=T:1:19
+// CHECK: Punctuation: "}" [4:7 - 4:8] CompoundStmt=
+// CHECK: Identifier: "t" [5:5 - 5:6] DeclRefExpr=t:2:10
+// CHECK: Punctuation: "." [5:6 - 5:7] MemberRefExpr=
+// CHECK: Identifier: "foo" [5:7 - 5:10] MemberRefExpr=
+// CHECK: Keyword: "int" [9:5 - 9:8] VarDecl=i:9:10 (Definition)
+// CHECK: Punctuation: "*" [9:9 - 9:10] VarDecl=i:9:10 (Definition)
+// CHECK: Identifier: "i" [9:10 - 9:11] VarDecl=i:9:10 (Definition)
+// CHECK: Punctuation: "=" [9:12 - 9:13] VarDecl=i:9:10 (Definition)
diff --git a/test/Index/nested-macro-instantiations.cpp b/test/Index/nested-macro-instantiations.cpp
deleted file mode 100644
index 0ed84dd..0000000
--- a/test/Index/nested-macro-instantiations.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#define FOO(x) x
-#define BAR(x) FOO(x)
-#define WIBBLE(x) BAR(x)
-
-WIBBLE(int x);
-
-// RUN: env CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_NESTED_MACROS=1 c-index-test -test-load-source-reparse 5 all %s | FileCheck -check-prefix CHECK-WITH-NESTED %s
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:5:1: macro expansion=WIBBLE:3:9 Extent=[5:1 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:3:19: macro expansion=BAR:2:9 Extent=[3:19 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:2:16: macro expansion=FOO:1:9 Extent=[2:16 - 5:14]
-// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:5:1: VarDecl=x:5:1 (Definition) Extent=[5:1 - 5:14]
-
-// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 all %s | FileCheck -check-prefix CHECK-WITHOUT-NESTED %s
-// CHECK-WITHOUT-NESTED: nested-macro-instantiations.cpp:5:1: macro expansion=WIBBLE:3:9 Extent=[5:1 - 5:14]
-// CHECK-WITHOUT-NESTED-NOT: nested-macro-instantiations.cpp:3:19: macro expansion=BAR:2:9 Extent=[3:19 - 5:14]
-// CHECK-WITHOUT-NESTED: nested-macro-instantiations.cpp:5:1: VarDecl=x:5:1 (Definition) Extent=[5:1 - 5:14]
diff --git a/test/Index/overrides.m b/test/Index/overrides.m
index 2197aaa..6908754 100644
--- a/test/Index/overrides.m
+++ b/test/Index/overrides.m
@@ -14,6 +14,7 @@
@interface A
- (void)method;
+- (void)protoMethod;
+ (void)methodWithParam:(int)param;
@end
@@ -27,9 +28,34 @@
+ (void)methodWithParam:(int)param { }
@end
+@protocol P4 <P3>
+- (void)protoMethod;
+@end
+
+@interface B(cat) <P4>
+- (void)protoMethod;
+@end
+
+@interface B2
+@end
+
+@interface B2(cat)
+-(void)meth;
+@end
+
+@interface I2 : B2
+@end
+
+@implementation I2
+-(void)meth { }
+@end
+
// RUN: c-index-test -test-load-source local %s | FileCheck %s
-// CHECK: overrides.m:12:1: ObjCInstanceMethodDecl=protoMethod:12:1 [Overrides @3:1] Extent=[12:1 - 12:21]
-// CHECK: overrides.m:21:1: ObjCInstanceMethodDecl=method:21:1 [Overrides @16:1] Extent=[21:1 - 21:16]
-// CHECK: overrides.m:22:1: ObjCInstanceMethodDecl=protoMethod:22:1 [Overrides @12:1, @8:1] Extent=[22:1 - 22:21]
-// CHECK: overrides.m:26:1: ObjCInstanceMethodDecl=method:26:1 (Definition) [Overrides @21:1] Extent=[26:1 - 26:19]
-// CHECK: overrides.m:27:1: ObjCClassMethodDecl=methodWithParam::27:1 (Definition) [Overrides @17:1] Extent=[27:1 - 27:39]
+// CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9]
+// CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9]
+// CHECK: overrides.m:23:9: ObjCInstanceMethodDecl=protoMethod:23:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:27:9: ObjCInstanceMethodDecl=method:27:9 (Definition) [Overrides @16:9]
+// CHECK: overrides.m:28:9: ObjCClassMethodDecl=methodWithParam::28:9 (Definition) [Overrides @18:9]
+// CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9]
+// CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9]
+// CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8]
diff --git a/test/Index/pch-opaque-value.cpp b/test/Index/pch-opaque-value.cpp
new file mode 100644
index 0000000..ae6b6dc
--- /dev/null
+++ b/test/Index/pch-opaque-value.cpp
@@ -0,0 +1,16 @@
+struct S {
+ S();
+ S(int);
+ S(const S &);
+ ~S();
+};
+
+void f() {
+ try {
+ } catch (S e) {
+ }
+}
+
+// RUN: c-index-test -write-pch %t.pch %s
+// RUN: c-index-test -test-load-tu-usrs %t.pch local | FileCheck %s
+// CHECK: pch-opaque-value.cpp c:pch-opaque-value.cpp@86@F@f#@e Extent=[10:12 - 10:15]
diff --git a/test/Index/pch-with-errors.c b/test/Index/pch-with-errors.c
new file mode 100644
index 0000000..be8728e
--- /dev/null
+++ b/test/Index/pch-with-errors.c
@@ -0,0 +1,42 @@
+#ifndef HEADER
+#define HEADER
+
+#include "blahblah.h"
+void erroneous(int);
+void erroneous(float);
+
+struct bar;
+struct zed {
+ bar g;
+};
+struct baz {
+ zed h;
+};
+
+void errparm(zed e);
+
+struct S {
+ {
+;
+
+#else
+
+void foo(void) {
+ erroneous(0);
+}
+
+#endif
+
+// RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s
+// RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
+
+// CHECK-PARSE: pch-with-errors.c:{{.*}}:6: FunctionDecl=foo
+// CHECK-PARSE: pch-with-errors.c:{{.*}}:3: CallExpr=erroneous
+
+// CHECK-INDEX: [indexDeclaration]: kind: function | name: foo
+// CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous
+
+// RUN: %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s
+
+// PCH-ERR: error: PCH file contains compiler errors
diff --git a/test/Index/pch-with-errors.m b/test/Index/pch-with-errors.m
new file mode 100644
index 0000000..cc42cd3
--- /dev/null
+++ b/test/Index/pch-with-errors.m
@@ -0,0 +1,28 @@
+#ifndef HEADER
+#define HEADER
+
+@interface I(cat)
+-(void)meth;
+@end
+
+@interface I2
+-(void)meth;
+@end
+
+#else
+
+void foo(I2 *i) {
+ [i meth];
+}
+
+#endif
+
+// RUN: c-index-test -write-pch %t.h.pch %s -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -test-load-source local %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-PARSE %s
+// RUN: c-index-test -index-file %s -include %t.h -Xclang -detailed-preprocessing-record | FileCheck -check-prefix=CHECK-INDEX %s
+
+// CHECK-PARSE: pch-with-errors.m:{{.*}} FunctionDecl=foo
+// CHECK-PARSE: pch-with-errors.m:{{.*}} ObjCMessageExpr=meth
+
+// CHECK-INDEX: [indexDeclaration]: kind: function | name: foo
+// CHECK-INDEX: [indexEntityReference]: kind: objc-instance-method | name: meth
diff --git a/test/Index/pragma-diag-reparse.c b/test/Index/pragma-diag-reparse.c
index efe59b1..71d0618 100644
--- a/test/Index/pragma-diag-reparse.c
+++ b/test/Index/pragma-diag-reparse.c
@@ -1,13 +1,20 @@
-// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local %s | FileCheck %s
+#pragma clang diagnostic ignored "-Wtautological-compare"
+#include "pragma_disable_warning.h"
int main (int argc, const char * argv[])
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- int x;
+ int x=0;
#pragma clang diagnostic pop
- return 0;
+ return x;
}
-// CHECK: pragma-diag-reparse.c:7:7: VarDecl=x:7:7 (Definition) Extent=[7:3 - 7:8]
+void foo() { int b=0; while (b==b); }
+
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source-reparse 5 local \
+// RUN: -I%S/Inputs \
+// RUN: %s -Wall -Werror | FileCheck %s
+
+// CHECK: pragma-diag-reparse.c:8:7: VarDecl=x:8:7 (Definition) Extent=[8:3 - 8:10]
diff --git a/test/Index/preamble-reparse-import.m b/test/Index/preamble-reparse-import.m
new file mode 100644
index 0000000..9bdb89a
--- /dev/null
+++ b/test/Index/preamble-reparse-import.m
@@ -0,0 +1,12 @@
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c %s-2.h
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 \
+// RUN: c-index-test -test-load-source-reparse 3 local %s -include %t.h
+// RUN: c-index-test -write-pch %t.h.pch -x objective-c %s-3.h
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_FAILONERROR=1 \
+// RUN: c-index-test -test-load-source-reparse 3 local %s -include %t.h
+
+#import "preamble-reparse-import.m-1.h"
+
+void foo();
+#import "preamble-reparse-import.m-2.h"
+#import "preamble-reparse-import.m-1.h"
diff --git a/test/Index/preamble-reparse-import.m-1.h b/test/Index/preamble-reparse-import.m-1.h
new file mode 100644
index 0000000..0d15823
--- /dev/null
+++ b/test/Index/preamble-reparse-import.m-1.h
@@ -0,0 +1,5 @@
+#ifdef PARSED2
+#error parsed twice
+#endif
+
+#define PARSED2 1
diff --git a/test/Index/preamble-reparse-import.m-2.h b/test/Index/preamble-reparse-import.m-2.h
new file mode 100644
index 0000000..8acc5c3
--- /dev/null
+++ b/test/Index/preamble-reparse-import.m-2.h
@@ -0,0 +1,5 @@
+#ifdef PARSED
+#error parsed twice
+#endif
+
+#define PARSED 1
diff --git a/test/Index/preamble-reparse-import.m-3.h b/test/Index/preamble-reparse-import.m-3.h
new file mode 100644
index 0000000..5369c1b
--- /dev/null
+++ b/test/Index/preamble-reparse-import.m-3.h
@@ -0,0 +1 @@
+#import "preamble-reparse-import.m-2.h"
diff --git a/test/Index/print-typekind.c b/test/Index/print-typekind.c
index c6583db..294aea7 100644
--- a/test/Index/print-typekind.c
+++ b/test/Index/print-typekind.c
@@ -10,7 +10,7 @@ typedef int ArrayType[5];
// RUN: c-index-test -test-print-typekind %s | FileCheck %s
// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
// CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1]
-// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [isPOD=0]
+// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [args= Pointer Pointer Typedef] [isPOD=0]
// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1]
// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1]
// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1]
diff --git a/test/Index/print-typekind.m b/test/Index/print-typekind.m
index 68827fb..9db1929 100644
--- a/test/Index/print-typekind.m
+++ b/test/Index/print-typekind.m
@@ -1,10 +1,10 @@
@interface Foo
@property (readonly) id x;
-(int) mymethod;
+-(int) mymethod2:(int)x blah:(float)y;
@end
// RUN: c-index-test -test-print-typekind %s | FileCheck %s
// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer]
-// CHECK: ObjCInstanceMethodDecl=mymethod:3:1 typekind=Invalid [result=Int]
-
-
+// CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float]
diff --git a/test/Index/properties-class-extensions.m b/test/Index/properties-class-extensions.m
index 7b1e90f..aa99207 100644
--- a/test/Index/properties-class-extensions.m
+++ b/test/Index/properties-class-extensions.m
@@ -58,7 +58,7 @@
// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=b:9:15 Extent=[9:15 - 9:16]
// CHECK: properties-class-extensions.m:9:15: ObjCInstanceMethodDecl=setB::9:15 Extent=[9:15 - 9:16]
// CHECK: properties-class-extensions.m:9:15: ParmDecl=b:9:15 (Definition) Extent=[9:15 - 9:16]
-// CHECK: properties-class-extensions.m:10:1: ObjCInstanceMethodDecl=bar:10:1 Extent=[10:1 - 10:14]
+// CHECK: properties-class-extensions.m:10:10: ObjCInstanceMethodDecl=bar:10:10 Extent=[10:1 - 10:14]
// CHECK: properties-class-extensions.m:15:12: ObjCInterfaceDecl=Bar:15:12 Extent=[15:1 - 17:5]
// CHECK: properties-class-extensions.m:16:25: ObjCPropertyDecl=bar:16:25 Extent=[16:1 - 16:28]
// CHECK: properties-class-extensions.m:16:22: TypeRef=id:0:0 Extent=[16:22 - 16:24]
@@ -70,7 +70,7 @@
// CHECK-NOT: properties-class-extensions.m:16:25: ObjCInstanceMethodDecl=bar:16:25 Extent=[16:25 - 16:28]
// CHECK: properties-class-extensions.m:19:26: ObjCInstanceMethodDecl=setBar::19:26 Extent=[19:26 - 19:29]
// CHECK: properties-class-extensions.m:19:26: ParmDecl=bar:19:26 (Definition) Extent=[19:26 - 19:29]
-// CHECK: properties-class-extensions.m:24:1: UnexposedDecl=[24:8] Extent=[24:1 - 24:23]
+// CHECK: properties-class-extensions.m:24:8: ObjCInterfaceDecl=Rdar8467189_Bar:24:8 Extent=[24:1 - 24:23]
// CHECK: properties-class-extensions.m:24:8: ObjCClassRef=Rdar8467189_Bar:24:8 Extent=[24:8 - 24:23]
// CHECK: properties-class-extensions.m:25:11: ObjCProtocolDecl=Rdar8467189_FooProtocol:25:11 (Definition) Extent=[25:1 - 27:5]
// CHECK: properties-class-extensions.m:26:39: ObjCPropertyDecl=Rdar8467189_Bar:26:39 Extent=[26:1 - 26:54]
diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp
index adaaae9..b80cbf4 100644
--- a/test/Index/recursive-cxx-member-calls.cpp
+++ b/test/Index/recursive-cxx-member-calls.cpp
@@ -933,7 +933,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK-tokens: Punctuation: ")" [102:58 - 102:59] CallExpr=endswith:56:8
// CHECK-tokens: Punctuation: ")" [102:59 - 102:60] IfStmt=
// CHECK-tokens: Identifier: "AttrName" [103:5 - 103:13] DeclRefExpr=AttrName:101:19
-// CHECK-tokens: Punctuation: "=" [103:14 - 103:15] CallExpr=operator=:38:7
+// CHECK-tokens: Punctuation: "=" [103:14 - 103:15] DeclRefExpr=operator=:38:7
// CHECK-tokens: Identifier: "AttrName" [103:16 - 103:24] DeclRefExpr=AttrName:101:19
// CHECK-tokens: Punctuation: "." [103:24 - 103:25] MemberRefExpr=substr:60:13
// CHECK-tokens: Identifier: "substr" [103:25 - 103:31] MemberRefExpr=substr:60:13
diff --git a/test/Index/redeclarations.cpp b/test/Index/redeclarations.cpp
new file mode 100644
index 0000000..11dc932
--- /dev/null
+++ b/test/Index/redeclarations.cpp
@@ -0,0 +1,21 @@
+#include "redeclarations.h"
+
+class A
+{
+};
+
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 2 all -I%S/Inputs -fno-delayed-template-parsing -fno-ms-compatibility -fno-ms-extensions %s | FileCheck %s
+
+// CHECK: redeclarations.h:1:7: ClassDecl=X:1:7 (Definition) Extent=[1:1 - 4:2]
+// CHECK: redeclarations.h:8:7: ClassTemplate=B:8:7 (Definition) Extent=[7:1 - 10:2]
+// CHECK: redeclarations.h:7:20: TemplateTypeParameter=T1:7:20 (Definition) Extent=[7:11 - 7:22]
+// CHECK: redeclarations.h:7:33: TemplateTypeParameter=T2:7:33 (Definition) Extent=[7:24 - 7:35]
+// CHECK: redeclarations.h:13:8: ClassTemplate=C:13:8 (Definition) Extent=[12:1 - 15:2]
+// CHECK: redeclarations.h:12:17: TemplateTypeParameter=T:12:17 (Definition) Extent=[12:11 - 12:18]
+// CHECK: redeclarations.h:17:7: ClassDecl=D:17:7 (Definition) Extent=[17:1 - 21:2]
+// CHECK: redeclarations.h:19:16: ClassDecl=A:19:16 Extent=[19:10 - 19:17]
+// CHECK: redeclarations.h:19:19: FieldDecl=x:19:19 (Definition) Extent=[19:5 - 19:20]
+// CHECK: redeclarations.h:19:5: TemplateRef=B:8:7 Extent=[19:5 - 19:6]
+// CHECK: redeclarations.h:19:7: TypeRef=class D:17:7 Extent=[19:7 - 19:8]
+// CHECK: redeclarations.h:19:16: TypeRef=class A:3:7 Extent=[19:16 - 19:17]
+// CHECK: redeclarations.cpp:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 5:2]
diff --git a/test/Index/reparse-instantiate.cpp b/test/Index/reparse-instantiate.cpp
new file mode 100644
index 0000000..84e5860
--- /dev/null
+++ b/test/Index/reparse-instantiate.cpp
@@ -0,0 +1,7 @@
+int main()
+{
+ return 0;
+}
+
+// RUN: c-index-test -write-pch %t.pch -fno-delayed-template-parsing -x c++-header %S/Inputs/reparse-instantiate.h
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -fno-delayed-template-parsing -I %S/Inputs -include %t %s
diff --git a/test/Index/retain-target-options.c b/test/Index/retain-target-options.c
index d616bc2..2fba476 100644
--- a/test/Index/retain-target-options.c
+++ b/test/Index/retain-target-options.c
@@ -1,8 +1,8 @@
-// RUN: c-index-test -test-load-source all -ccc-host-triple x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
-// RUN: c-index-test -test-load-source-reparse 1 all -ccc-host-triple x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
-// RUN: c-index-test -test-load-source-reparse 5 all -ccc-host-triple x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 1 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 5 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
-// CHECK: error: #error SSE4_1 used
+// CHECK: error: SSE4_1 used
#if defined(__SSE4_1__)
#error SSE4_1 used
#endif
diff --git a/test/Index/targeted-annotation.c b/test/Index/targeted-annotation.c
new file mode 100644
index 0000000..cfa1046
--- /dev/null
+++ b/test/Index/targeted-annotation.c
@@ -0,0 +1,99 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+int LocalVar1;
+int LocalVar2;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:7:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// LOCAL: Punctuation: "#" [2:1 - 2:2] inclusion directive=targeted-top.h
+// LOCAL: Identifier: "include" [2:2 - 2:9] inclusion directive=targeted-top.h
+// LOCAL: Literal: ""targeted-top.h"" [2:10 - 2:26] inclusion directive=targeted-top.h
+// LOCAL: Punctuation: "#" [3:1 - 3:2] inclusion directive=targeted-preamble.h
+// LOCAL: Identifier: "include" [3:2 - 3:9] inclusion directive=targeted-preamble.h
+// LOCAL: Literal: ""targeted-preamble.h"" [3:10 - 3:31] inclusion directive=targeted-preamble.h
+// LOCAL: Keyword: "int" [5:1 - 5:4] VarDecl=LocalVar1:5:5
+// LOCAL: Identifier: "LocalVar1" [5:5 - 5:14] VarDecl=LocalVar1:5:5
+// LOCAL: Punctuation: ";" [5:14 - 5:15]
+// LOCAL: Keyword: "int" [6:1 - 6:4] VarDecl=LocalVar2:6:5
+// LOCAL: Identifier: "LocalVar2" [6:5 - 6:14] VarDecl=LocalVar2:6:5
+// LOCAL: Punctuation: ";" [6:14 - 6:15]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-fields.h:1:1:4:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD
+
+// FIELD: Keyword: "int" [2:3 - 2:6] FieldDecl=z:2:7 (Definition)
+// FIELD: Identifier: "z" [2:7 - 2:8] FieldDecl=z:2:7 (Definition)
+// FIELD: Punctuation: ";" [2:8 - 2:9] StructDecl=:13:9 (Definition)
+// FIELD: Keyword: "int" [3:3 - 3:6] FieldDecl=w:3:7 (Definition)
+// FIELD: Identifier: "w" [3:7 - 3:8] FieldDecl=w:3:7 (Definition)
+// FIELD: Punctuation: ";" [3:8 - 3:9] StructDecl=:13:9 (Definition)
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-nested1.h:1:1:3:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// NESTED: Keyword: "extern" [2:1 - 2:7]
+// NESTED: Keyword: "int" [2:8 - 2:11] VarDecl=NestedVar1:2:12
+// NESTED: Identifier: "NestedVar1" [2:12 - 2:22] VarDecl=NestedVar1:2:12
+// NESTED: Punctuation: ";" [2:22 - 2:23]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -test-annotate-tokens=%S/targeted-top.h:1:1:12:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// TOP: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
+// TOP: Identifier: "ifndef" [2:2 - 2:8] preprocessing directive=
+// TOP: Identifier: "TARGETED_TOP_H" [2:9 - 2:23] preprocessing directive=
+// TOP: Punctuation: "#" [3:1 - 3:2] preprocessing directive=
+// TOP: Identifier: "define" [3:2 - 3:8] preprocessing directive=
+// TOP: Identifier: "TARGETED_TOP_H" [3:9 - 3:23] preprocessing directive=
+// TOP: Punctuation: "#" [5:1 - 5:2] preprocessing directive=
+// TOP: Identifier: "include" [5:2 - 5:9] preprocessing directive=
+// TOP: Literal: ""targeted-nested1.h"" [5:10 - 5:30] preprocessing directive=
+// TOP: Keyword: "enum" [7:1 - 7:5] EnumDecl=:7:1 (Definition)
+// TOP: Punctuation: "{" [7:6 - 7:7] EnumDecl=:7:1 (Definition)
+// TOP: Identifier: "VALUE" [8:3 - 8:8] EnumConstantDecl=VALUE:8:3 (Definition)
+// TOP: Punctuation: "=" [8:9 - 8:10] EnumConstantDecl=VALUE:8:3 (Definition)
+// TOP: Literal: "3" [8:11 - 8:12] IntegerLiteral=
+// TOP: Punctuation: "}" [9:1 - 9:2] EnumDecl=:7:1 (Definition)
+// TOP: Punctuation: ";" [9:2 - 9:3]
+// TOP: Keyword: "extern" [11:1 - 11:7]
+// TOP: Keyword: "int" [11:8 - 11:11] VarDecl=TopVar:11:12
+// TOP: Identifier: "TopVar" [11:12 - 11:18] VarDecl=TopVar:11:12
+// TOP: Punctuation: ";" [11:18 - 11:19]
diff --git a/test/Index/targeted-cursor.c b/test/Index/targeted-cursor.c
new file mode 100644
index 0000000..7efc07f
--- /dev/null
+++ b/test/Index/targeted-cursor.c
@@ -0,0 +1,65 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+int LocalVar1;
+int LocalVar2;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:2:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-fields.h:1:1 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=FIELD-CURSOR2
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=PREAMBLE-CURSOR1
+
+// LOCAL-CURSOR1: VarDecl=LocalVar1:5:5
+// TOP-CURSOR1: VarDecl=TopVar:11:12
+// NESTED-CURSOR1: VarDecl=NestedVar1:2:12
+// PREAMBLE-CURSOR1: VarDecl=PreambleVar:2:12
+
+// FIELD-CURSOR1: FieldDecl=z:2:7 (Definition)
+// FIELD-CURSOR2: StructDecl=:13:9 (Definition)
diff --git a/test/Index/targeted-cursor.m b/test/Index/targeted-cursor.m
new file mode 100644
index 0000000..a53ebf6
--- /dev/null
+++ b/test/Index/targeted-cursor.m
@@ -0,0 +1,6 @@
+
+// rdar://10920009
+// RUN: c-index-test -write-pch %t.h.pch -target x86_64-apple-macosx10.7 -x objective-c-header %S/targeted-cursor.m.h -Xclang -detailed-preprocessing-record
+// RUN: c-index-test -cursor-at=%S/targeted-cursor.m.h:5:13 %s -target x86_64-apple-macosx10.7 -include %t.h | FileCheck %s
+
+// CHECK: ObjCClassRef=I:2:12
diff --git a/test/Index/targeted-cursor.m.h b/test/Index/targeted-cursor.m.h
new file mode 100644
index 0000000..735c7bd
--- /dev/null
+++ b/test/Index/targeted-cursor.m.h
@@ -0,0 +1,7 @@
+
+@interface I
+
+-(void)mm:(void (^)(I*))block;
+-(void)mm2:(I*)i;
+
+@end
diff --git a/test/Index/targeted-fields.h b/test/Index/targeted-fields.h
new file mode 100644
index 0000000..7da57f3
--- /dev/null
+++ b/test/Index/targeted-fields.h
@@ -0,0 +1,3 @@
+
+ int z;
+ int w;
diff --git a/test/Index/targeted-file-refs.c b/test/Index/targeted-file-refs.c
new file mode 100644
index 0000000..195cd86
--- /dev/null
+++ b/test/Index/targeted-file-refs.c
@@ -0,0 +1,59 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+extern int LocalVar;
+int LocalVar;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h -Xclang -detailed-preprocessing-record
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%s:5:17 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%s:5:17 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL
+
+// LOCAL: VarDecl=LocalVar:5:12
+// LOCAL: VarDecl=LocalVar:5:12 =[5:12 - 5:20]
+// LOCAL: VarDecl=LocalVar:6:5 =[6:5 - 6:13]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%S/targeted-top.h:14:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-top.h:14:7 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: | FileCheck %s -check-prefix=TOP
+
+// TOP: FieldDecl=x:14:7 (Definition)
+// TOP: FieldDecl=x:14:7 (Definition) =[14:7 - 14:8]
+// TOP: MemberRefExpr=x:14:7 SingleRefName=[20:13 - 20:14] RefName=[20:13 - 20:14] =[20:13 - 20:14]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -file-refs-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED
+
+// NESTED: VarDecl=NestedVar1:2:12
+// NESTED: VarDecl=NestedVar1:2:12 =[2:12 - 2:22]
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -file-refs-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=PREAMBLE
+
+// PREAMBLE: VarDecl=PreambleVar:2:12
+// PREAMBLE: VarDecl=PreambleVar:2:12 =[2:12 - 2:23]
diff --git a/test/Index/targeted-nested1.h b/test/Index/targeted-nested1.h
new file mode 100644
index 0000000..d5a019b
--- /dev/null
+++ b/test/Index/targeted-nested1.h
@@ -0,0 +1,2 @@
+
+extern int NestedVar1;
diff --git a/test/Index/targeted-preamble.h b/test/Index/targeted-preamble.h
new file mode 100644
index 0000000..19b9539
--- /dev/null
+++ b/test/Index/targeted-preamble.h
@@ -0,0 +1,2 @@
+
+extern int PreambleVar;
diff --git a/test/Index/targeted-top.h b/test/Index/targeted-top.h
new file mode 100644
index 0000000..0f3c975
--- /dev/null
+++ b/test/Index/targeted-top.h
@@ -0,0 +1,24 @@
+
+#ifndef TARGETED_TOP_H
+#define TARGETED_TOP_H
+
+#include "targeted-nested1.h"
+
+enum {
+ VALUE = 3
+};
+
+extern int TopVar;
+
+typedef struct {
+ int x;
+ int y;
+#include "targeted-fields.h"
+} Vector;
+
+static inline int vector_get_x(Vector v) {
+ int x = v.x;
+ return x;
+}
+
+#endif
diff --git a/test/Index/unmatched-braces.c b/test/Index/unmatched-braces.c
new file mode 100644
index 0000000..b994605
--- /dev/null
+++ b/test/Index/unmatched-braces.c
@@ -0,0 +1,9 @@
+void foo() {
+ int x;
+ if (x) {
+}
+
+// RUN: c-index-test -cursor-at=%s:2:7 %s > %t
+// RUN: FileCheck %s -input-file %t
+
+// CHECK: VarDecl=x:2:7
diff --git a/test/Index/unmatched-braces.m b/test/Index/unmatched-braces.m
new file mode 100644
index 0000000..84fe82a
--- /dev/null
+++ b/test/Index/unmatched-braces.m
@@ -0,0 +1,11 @@
+@implementation I
+-(void)meth {
+ int x;
+ if (x) {
+}
+@end
+
+// RUN: c-index-test -cursor-at=%s:3:7 %s > %t
+// RUN: FileCheck %s -input-file %t
+
+// CHECK: VarDecl=x:3:7
diff --git a/test/Index/usrs.m b/test/Index/usrs.m
index 826abb5..95a5388 100644
--- a/test/Index/usrs.m
+++ b/test/Index/usrs.m
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
+
static inline int my_helper(int x, int y) { return x + y; }
@@ -80,6 +80,15 @@ int test_multi_declaration(void) {
- (void)method;
@end
+@interface CWithExt2
+@end
+@interface CWithExt2 () {
+ id var_ext;
+}
+@property (assign) id pro_ext;
+@end
+
+// RUN: c-index-test -test-load-source-usrs all -target x86_64-apple-macosx10.7 %s | FileCheck %s
// CHECK: usrs.m c:usrs.m@67@F@my_helper Extent=[3:1 - 3:60]
// CHECK: usrs.m c:usrs.m@95@F@my_helper@x Extent=[3:29 - 3:34]
// CHECK: usrs.m c:usrs.m@102@F@my_helper@y Extent=[3:36 - 3:41]
@@ -137,6 +146,12 @@ int test_multi_declaration(void) {
// CHECK: usrs.m c:usrs.m@980@F@test_multi_declaration@baz Extent=[74:25 - 74:32]
// CHECK: usrs.m c:objc(pl)P1 Extent=[79:1 - 81:5]
// CHECK: usrs.m c:objc(pl)P1(im)method Extent=[80:1 - 80:16]
+// CHECK: usrs.m c:objc(cs)CWithExt2 Extent=[83:1 - 84:5]
+// CHECK: usrs.m c:objc(ext)CWithExt2@usrs.m@1111 Extent=[85:1 - 89:5]
+// CHECK: usrs.m c:objc(cs)CWithExt2@var_ext Extent=[86:3 - 86:13]
+// CHECK: usrs.m c:objc(cs)CWithExt2(py)pro_ext Extent=[88:1 - 88:30]
+// CHECK: usrs.m c:objc(cs)CWithExt2(im)pro_ext Extent=[88:23 - 88:30]
+// CHECK: usrs.m c:objc(cs)CWithExt2(im)setPro_ext: Extent=[88:23 - 88:30]
// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-source %s
// CHECK-source: usrs.m:3:19: FunctionDecl=my_helper:3:19 (Definition) Extent=[3:1 - 3:60]
@@ -165,16 +180,16 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:26:3: TypeRef=id:0:0 Extent=[26:3 - 26:5]
// CHECK-source: usrs.m:27:6: ObjCIvarDecl=y:27:6 (Definition) Extent=[27:3 - 27:7]
// CHECK-source: usrs.m:27:3: TypeRef=id:0:0 Extent=[27:3 - 27:5]
-// CHECK-source: usrs.m:29:1: ObjCInstanceMethodDecl=godzilla:29:1 Extent=[29:1 - 29:17]
+// CHECK-source: usrs.m:29:8: ObjCInstanceMethodDecl=godzilla:29:8 Extent=[29:1 - 29:17]
// CHECK-source: usrs.m:29:4: TypeRef=id:0:0 Extent=[29:4 - 29:6]
-// CHECK-source: usrs.m:30:1: ObjCClassMethodDecl=kingkong:30:1 Extent=[30:1 - 30:17]
+// CHECK-source: usrs.m:30:8: ObjCClassMethodDecl=kingkong:30:8 Extent=[30:1 - 30:17]
// CHECK-source: usrs.m:30:4: TypeRef=id:0:0 Extent=[30:4 - 30:6]
// CHECK-source: usrs.m:31:15: ObjCPropertyDecl=d1:31:15 Extent=[31:1 - 31:17]
// CHECK-source: usrs.m:31:15: ObjCInstanceMethodDecl=d1:31:15 Extent=[31:15 - 31:17]
// CHECK-source: usrs.m:31:15: ObjCInstanceMethodDecl=setD1::31:15 Extent=[31:15 - 31:17]
// CHECK-source: usrs.m:31:15: ParmDecl=d1:31:15 (Definition) Extent=[31:15 - 31:17]
// CHECK-source: usrs.m:34:17: ObjCImplementationDecl=Foo:34:17 (Definition) Extent=[34:1 - 45:2]
-// CHECK-source: usrs.m:35:1: ObjCInstanceMethodDecl=godzilla:35:1 (Definition) [Overrides @29:1] Extent=[35:1 - 39:2]
+// CHECK-source: usrs.m:35:8: ObjCInstanceMethodDecl=godzilla:35:8 (Definition) Extent=[35:1 - 39:2]
// CHECK-source: usrs.m:35:4: TypeRef=id:0:0 Extent=[35:4 - 35:6]
// CHECK-source: usrs.m:35:17: CompoundStmt= Extent=[35:17 - 39:2]
// CHECK-source: usrs.m:36:3: DeclStmt= Extent=[36:3 - 36:20]
@@ -185,7 +200,7 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:38:3: ReturnStmt= Extent=[38:3 - 38:11]
// CHECK-source: usrs.m:38:10: UnexposedExpr= Extent=[38:10 - 38:11]
// CHECK-source: usrs.m:38:10: IntegerLiteral= Extent=[38:10 - 38:11]
-// CHECK-source: usrs.m:40:1: ObjCClassMethodDecl=kingkong:40:1 (Definition) [Overrides @30:1] Extent=[40:1 - 43:2]
+// CHECK-source: usrs.m:40:8: ObjCClassMethodDecl=kingkong:40:8 (Definition) Extent=[40:1 - 43:2]
// CHECK-source: usrs.m:40:4: TypeRef=id:0:0 Extent=[40:4 - 40:6]
// CHECK-source: usrs.m:40:17: CompoundStmt= Extent=[40:17 - 43:2]
// CHECK-source: usrs.m:41:3: DeclStmt= Extent=[41:3 - 41:17]
@@ -202,34 +217,34 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:49:32: ReturnStmt= Extent=[49:32 - 49:40]
// CHECK-source: usrs.m:49:39: DeclRefExpr=x:49:27 Extent=[49:39 - 49:40]
// CHECK-source: usrs.m:51:12: ObjCInterfaceDecl=CWithExt:51:12 Extent=[51:1 - 53:5]
-// CHECK-source: usrs.m:52:1: ObjCInstanceMethodDecl=meth1:52:1 Extent=[52:1 - 52:14]
+// CHECK-source: usrs.m:52:8: ObjCInstanceMethodDecl=meth1:52:8 Extent=[52:1 - 52:14]
// CHECK-source: usrs.m:52:4: TypeRef=id:0:0 Extent=[52:4 - 52:6]
// CHECK-source: usrs.m:54:12: ObjCCategoryDecl=:54:12 Extent=[54:1 - 56:5]
// CHECK-source: usrs.m:54:12: ObjCClassRef=CWithExt:51:12 Extent=[54:12 - 54:20]
-// CHECK-source: usrs.m:55:1: ObjCInstanceMethodDecl=meth2:55:1 Extent=[55:1 - 55:14]
+// CHECK-source: usrs.m:55:8: ObjCInstanceMethodDecl=meth2:55:8 Extent=[55:1 - 55:14]
// CHECK-source: usrs.m:55:4: TypeRef=id:0:0 Extent=[55:4 - 55:6]
// CHECK-source: usrs.m:57:12: ObjCCategoryDecl=:57:12 Extent=[57:1 - 59:5]
// CHECK-source: usrs.m:57:12: ObjCClassRef=CWithExt:51:12 Extent=[57:12 - 57:20]
-// CHECK-source: usrs.m:58:1: ObjCInstanceMethodDecl=meth3:58:1 Extent=[58:1 - 58:14]
+// CHECK-source: usrs.m:58:8: ObjCInstanceMethodDecl=meth3:58:8 Extent=[58:1 - 58:14]
// CHECK-source: usrs.m:58:4: TypeRef=id:0:0 Extent=[58:4 - 58:6]
// CHECK-source: usrs.m:60:12: ObjCCategoryDecl=Bar:60:12 Extent=[60:1 - 62:5]
// CHECK-source: usrs.m:60:12: ObjCClassRef=CWithExt:51:12 Extent=[60:12 - 60:20]
-// CHECK-source: usrs.m:61:1: ObjCInstanceMethodDecl=meth4:61:1 Extent=[61:1 - 61:14]
+// CHECK-source: usrs.m:61:8: ObjCInstanceMethodDecl=meth4:61:8 Extent=[61:1 - 61:14]
// CHECK-source: usrs.m:61:4: TypeRef=id:0:0 Extent=[61:4 - 61:6]
// CHECK-source: usrs.m:63:17: ObjCImplementationDecl=CWithExt:63:17 (Definition) Extent=[63:1 - 67:2]
-// CHECK-source: usrs.m:64:1: ObjCInstanceMethodDecl=meth1:64:1 (Definition) [Overrides @52:1] Extent=[64:1 - 64:27]
+// CHECK-source: usrs.m:64:8: ObjCInstanceMethodDecl=meth1:64:8 (Definition) Extent=[64:1 - 64:27]
// CHECK-source: usrs.m:64:4: TypeRef=id:0:0 Extent=[64:4 - 64:6]
// CHECK-source: usrs.m:64:14: CompoundStmt= Extent=[64:14 - 64:27]
// CHECK-source: usrs.m:64:16: ReturnStmt= Extent=[64:16 - 64:24]
// CHECK-source: usrs.m:64:23: UnexposedExpr= Extent=[64:23 - 64:24]
// CHECK-source: usrs.m:64:23: IntegerLiteral= Extent=[64:23 - 64:24]
-// CHECK-source: usrs.m:65:1: ObjCInstanceMethodDecl=meth2:65:1 (Definition) [Overrides @55:1] Extent=[65:1 - 65:27]
+// CHECK-source: usrs.m:65:8: ObjCInstanceMethodDecl=meth2:65:8 (Definition) Extent=[65:1 - 65:27]
// CHECK-source: usrs.m:65:4: TypeRef=id:0:0 Extent=[65:4 - 65:6]
// CHECK-source: usrs.m:65:14: CompoundStmt= Extent=[65:14 - 65:27]
// CHECK-source: usrs.m:65:16: ReturnStmt= Extent=[65:16 - 65:24]
// CHECK-source: usrs.m:65:23: UnexposedExpr= Extent=[65:23 - 65:24]
// CHECK-source: usrs.m:65:23: IntegerLiteral= Extent=[65:23 - 65:24]
-// CHECK-source: usrs.m:66:1: ObjCInstanceMethodDecl=meth3:66:1 (Definition) [Overrides @58:1] Extent=[66:1 - 66:27]
+// CHECK-source: usrs.m:66:8: ObjCInstanceMethodDecl=meth3:66:8 (Definition) Extent=[66:1 - 66:27]
// CHECK-source: usrs.m:66:4: TypeRef=id:0:0 Extent=[66:4 - 66:6]
// CHECK-source: usrs.m:66:14: CompoundStmt= Extent=[66:14 - 66:27]
// CHECK-source: usrs.m:66:16: ReturnStmt= Extent=[66:16 - 66:24]
@@ -237,7 +252,7 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:66:23: IntegerLiteral= Extent=[66:23 - 66:24]
// CHECK-source: usrs.m:68:17: ObjCCategoryImplDecl=Bar:68:17 (Definition) Extent=[68:1 - 70:2]
// CHECK-source: usrs.m:68:17: ObjCClassRef=CWithExt:51:12 Extent=[68:17 - 68:25]
-// CHECK-source: usrs.m:69:1: ObjCInstanceMethodDecl=meth4:69:1 (Definition) [Overrides @61:1] Extent=[69:1 - 69:27]
+// CHECK-source: usrs.m:69:8: ObjCInstanceMethodDecl=meth4:69:8 (Definition) Extent=[69:1 - 69:27]
// CHECK-source: usrs.m:69:4: TypeRef=id:0:0 Extent=[69:4 - 69:6]
// CHECK-source: usrs.m:69:14: CompoundStmt= Extent=[69:14 - 69:27]
// CHECK-source: usrs.m:69:16: ReturnStmt= Extent=[69:16 - 69:24]
@@ -265,5 +280,5 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:76:3: ReturnStmt= Extent=[76:3 - 76:11]
// CHECK-source: usrs.m:76:10: IntegerLiteral= Extent=[76:10 - 76:11]
// CHECK-source: usrs.m:79:11: ObjCProtocolDecl=P1:79:11 (Definition) Extent=[79:1 - 81:5]
-// CHECK-source: usrs.m:80:1: ObjCInstanceMethodDecl=method:80:1 Extent=[80:1 - 80:16]
+// CHECK-source: usrs.m:80:9: ObjCInstanceMethodDecl=method:80:9 Extent=[80:1 - 80:16]
diff --git a/test/Index/vector-types.c b/test/Index/vector-types.c
new file mode 100644
index 0000000..404e4a5
--- /dev/null
+++ b/test/Index/vector-types.c
@@ -0,0 +1,6 @@
+int __attribute__((vector_size(16))) x;
+typedef int __attribute__((vector_size(16))) int4_t;
+
+// RUN: c-index-test -test-print-typekind %s | FileCheck %s
+// CHECK: VarDecl=x:1:38 typekind=Vector [isPOD=1]
+// CHECK: TypedefDecl=int4_t:2:46 (Definition) typekind=Typedef [canonical=Vector] [isPOD=1]
diff --git a/test/Index/werror.c b/test/Index/werror.c
index 150095d..98b602a 100644
--- a/test/Index/werror.c
+++ b/test/Index/werror.c
@@ -7,9 +7,6 @@ void fatal(int);
void fatal(float);
#endif
-// CHECK-FATAL: translation errors
-
// RUN: c-index-test -write-pch %t.pch -Werror %s
-// RUN: not c-index-test -write-pch %t.pch -DFATAL -Werror %s 2>%t.err
-// RUN: FileCheck -check-prefix=CHECK-FATAL %s < %t.err
+// RUN: c-index-test -write-pch %t.pch -DFATAL -Werror %s
diff --git a/test/Lexer/char-literal-encoding-error.c b/test/Lexer/char-literal-encoding-error.c
new file mode 100644
index 0000000..e752de2
--- /dev/null
+++ b/test/Lexer/char-literal-encoding-error.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+
+// This file is encoded using ISO-8859-1
+
+int main() {
+ (void)'é'; // expected-warning {{illegal character encoding in character literal}}
+ (void)u'é'; // expected-error {{illegal character encoding in character literal}}
+ (void)U'é'; // expected-error {{illegal character encoding in character literal}}
+ (void)L'é'; // expected-error {{illegal character encoding in character literal}}
+
+ // For narrow character literals, since there is no error, make sure the
+ // encoding is correct
+ static_assert((unsigned char)'é' == 0xE9, ""); // expected-warning {{illegal character encoding in character literal}}
+ static_assert('éé' == 0xE9E9, ""); // expected-warning {{illegal character encoding in character literal}} expected-warning {{multi-character character constant}}
+}
diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp
new file mode 100644
index 0000000..5dc5360
--- /dev/null
+++ b/test/Lexer/char-literal.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -Wfour-char-constants -fsyntax-only -verify %s
+
+int a = 'ab'; // expected-warning {{multi-character character constant}}
+int b = '\xFF\xFF'; // expected-warning {{multi-character character constant}}
+int c = 'APPS'; // expected-warning {{multi-character character constant}}
+
+char d = '⌘'; // expected-error {{character too large for enclosing character literal type}}
+char e = '\u2318'; // expected-error {{character too large for enclosing character literal type}}
+
+auto f = '\xE2\x8C\x98'; // expected-warning {{multi-character character constant}}
+
+char16_t g = u'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t h = u'\U0010FFFD'; // expected-error {{character too large for enclosing character literal type}}
+
+wchar_t i = L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
+wchar_t j = L'\U0010FFFD';
+
+char32_t k = U'\U0010FFFD';
+
+char l = 'Ø'; // expected-error {{character too large for enclosing character literal type}}
+char m = '👿'; // expected-error {{character too large for enclosing character literal type}}
+
+char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}}
+char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}}
diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c
index 013103b..2903885 100644
--- a/test/Lexer/constants.c
+++ b/test/Lexer/constants.c
@@ -66,4 +66,4 @@ double t1[] = {
// PR7888
double g = 1e100000000; // expected-warning {{too large}}
-char h = '\u1234'; // expected-warning {{character unicode escape sequence too long for its type}}
+char h = '\u1234'; // expected-error {{character too large for enclosing character literal type}}
diff --git a/test/Lexer/cxx0x_keyword_as_cxx98.cpp b/test/Lexer/cxx0x_keyword_as_cxx98.cpp
index d87d3dc..5d16810 100644
--- a/test/Lexer/cxx0x_keyword_as_cxx98.cpp
+++ b/test/Lexer/cxx0x_keyword_as_cxx98.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wc++11-compat
#define constexpr const
constexpr int x = 0;
diff --git a/test/Lexer/cxx0x_raw_string_delim_length.cpp b/test/Lexer/cxx0x_raw_string_delim_length.cpp
index e7d5c6f..b9f6d13 100644
--- a/test/Lexer/cxx0x_raw_string_delim_length.cpp
+++ b/test/Lexer/cxx0x_raw_string_delim_length.cpp
@@ -1,3 +1,7 @@
-// RUN: %clang_cc1 -std=c++11 -E %s 2>&1 | grep 'error: raw string delimiter longer than 16 characters'
+// RUN: %clang_cc1 -std=c++11 -verify %s
-const char *str = R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz";
+const char *str1 = R"(abcdef)"; // ok
+const char *str2 = R"foo()foo"; // ok
+const char *str3 = R"()"; // ok
+// FIXME: recover better than this.
+const char *str4 = R"abcdefghijkmnopqrstuvwxyz(abcdef)abcdefghijkmnopqrstuvwxyz"; // expected-error {{raw string delimiter longer than 16 characters}} expected-error {{expected expression}}
diff --git a/test/Lexer/escape_newline.c b/test/Lexer/escape_newline.c
index 43ba417..d0f27df 100644
--- a/test/Lexer/escape_newline.c
+++ b/test/Lexer/escape_newline.c
@@ -1,7 +1,11 @@
// RUN: %clang_cc1 -E -trigraphs %s | grep -- ' ->'
// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'backslash and newline separated by space'
// RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'trigraph converted'
+// RUN: %clang_cc1 -E -CC -trigraphs %s
// This is an ugly way to spell a -> token.
-??/
>
+
+// \
+
diff --git a/test/Lexer/has_attribute.cpp b/test/Lexer/has_attribute.cpp
deleted file mode 100644
index 9a58a30..0000000
--- a/test/Lexer/has_attribute.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -E %s -o - | FileCheck %s
-
-// CHECK: always_inline
-#if __has_attribute(always_inline)
-int always_inline();
-#endif
-
-// CHECK: no_dummy_attribute
-#if !__has_attribute(dummy_attribute)
-int no_dummy_attribute();
-#endif
-
diff --git a/test/Lexer/has_extension.c b/test/Lexer/has_extension.c
index 4c322c7..3b08510 100644
--- a/test/Lexer/has_extension.c
+++ b/test/Lexer/has_extension.c
@@ -36,3 +36,9 @@ int has_c_alignas();
int no_c_alignas();
#endif
+// Arbitrary feature to test that the extension name can be surrounded with
+// double underscores.
+// CHECK-PED-NONE: has_double_underscores
+#if __has_extension(__c_alignas__)
+int has_double_underscores();
+#endif
diff --git a/test/Lexer/has_extension_cxx.cpp b/test/Lexer/has_extension_cxx.cpp
index 5481b59..6ffeebd 100644
--- a/test/Lexer/has_extension_cxx.cpp
+++ b/test/Lexer/has_extension_cxx.cpp
@@ -39,3 +39,11 @@ int has_reference_qualified_functions();
#if __has_extension(cxx_rvalue_references)
int has_rvalue_references();
#endif
+
+#if __has_extension(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK: has_local_type_template_args
diff --git a/test/Lexer/has_feature_address_sanitizer.cpp b/test/Lexer/has_feature_address_sanitizer.cpp
new file mode 100644
index 0000000..69acc39
--- /dev/null
+++ b/test/Lexer/has_feature_address_sanitizer.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -faddress-sanitizer %s -o - | FileCheck --check-prefix=CHECK-ASAN %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-ASAN %s
+
+#if __has_feature(address_sanitizer)
+int AddressSanitizerEnabled();
+#else
+int AddressSanitizerDisabled();
+#endif
+
+// CHECK-ASAN: AddressSanitizerEnabled
+// CHECK-NO-ASAN: AddressSanitizerDisabled
diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c
index ca4e9b9..c9a5f56 100644
--- a/test/Lexer/has_feature_c1x.c
+++ b/test/Lexer/has_feature_c1x.c
@@ -1,6 +1,15 @@
// RUN: %clang_cc1 -E -std=c1x %s -o - | FileCheck --check-prefix=CHECK-1X %s
// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-1X %s
+#if __has_feature(c_atomic)
+int has_atomic();
+#else
+int no_atomic();
+#endif
+
+// CHECK-1X: has_atomic
+// CHECK-NO-1X: no_atomic
+
#if __has_feature(c_static_assert)
int has_static_assert();
#else
@@ -27,3 +36,12 @@ int no_alignas();
// CHECK-1X: has_alignas
// CHECK-NO-1X: no_alignas
+
+#if __STDC_VERSION__ > 199901L
+int is_c1x();
+#else
+int is_not_c1x();
+#endif
+
+// CHECK-1X: is_c1x
+// CHECK-NO-1X: is_not_c1x
diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp
index f2b4576..8e0222d 100644
--- a/test/Lexer/has_feature_cxx0x.cpp
+++ b/test/Lexer/has_feature_cxx0x.cpp
@@ -1,13 +1,22 @@
// RUN: %clang_cc1 -E -std=c++11 %s -o - | FileCheck --check-prefix=CHECK-0X %s
// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-0X %s
+#if __has_feature(cxx_atomic)
+int has_atomic();
+#else
+int no_atomic();
+#endif
+
+// CHECK-0X: has_atomic
+// CHECK-NO-0X: no_atomic
+
#if __has_feature(cxx_lambdas)
int has_lambdas();
#else
int no_lambdas();
#endif
-// CHECK-0X: no_lambdas
+// CHECK-0X: has_lambdas
// CHECK-NO-0X: no_lambdas
@@ -31,6 +40,16 @@ int no_decltype();
// CHECK-NO-0X: no_decltype
+#if __has_feature(cxx_decltype_incomplete_return_types)
+int has_decltype_incomplete_return_types();
+#else
+int no_decltype_incomplete_return_types();
+#endif
+
+// CHECK-0X: has_decltype_incomplete_return_types
+// CHECK-NO-0X: no_decltype_incomplete_return_types
+
+
#if __has_feature(cxx_auto_type)
int has_auto_type();
#else
@@ -79,6 +98,14 @@ int no_deleted_functions();
// CHECK-0X: has_deleted_functions
// CHECK-NO-0X: no_deleted_functions
+#if __has_feature(cxx_defaulted_functions)
+int has_defaulted_functions();
+#else
+int no_defaulted_functions();
+#endif
+
+// CHECK-0X: has_defaulted_functions
+// CHECK-NO-0X: no_defaulted_functions
#if __has_feature(cxx_rvalue_references)
int has_rvalue_references();
@@ -182,3 +209,66 @@ int no_alignas();
// CHECK-0X: has_alignas
// CHECK-NO-0X: no_alignas
+
+#if __has_feature(cxx_raw_string_literals)
+int has_raw_string_literals();
+#else
+int no_raw_string_literals();
+#endif
+
+// CHECK-0X: has_raw_string_literals
+// CHECK-NO-0X: no_raw_string_literals
+
+#if __has_feature(cxx_unicode_literals)
+int has_unicode_literals();
+#else
+int no_unicode_literals();
+#endif
+
+// CHECK-0X: has_unicode_literals
+// CHECK-NO-0X: no_unicode_literals
+
+#if __has_feature(cxx_constexpr)
+int has_constexpr();
+#else
+int no_constexpr();
+#endif
+
+// CHECK-0X: has_constexpr
+// CHECK-NO-0X: no_constexpr
+
+#if __has_feature(cxx_generalized_initializers)
+int has_generalized_initializers();
+#else
+int no_generalized_initializers();
+#endif
+
+// CHECK-0X: has_generalized_initializers
+// CHECK-NO-0X: no_generalized_initializers
+
+#if __has_feature(cxx_unrestricted_unions)
+int has_unrestricted_unions();
+#else
+int no_unrestricted_unions();
+#endif
+
+// CHECK-0X: has_unrestricted_unions
+// CHECK-NO-0X: no_unrestricted_unions
+
+#if __has_feature(cxx_user_literals)
+int has_user_literals();
+#else
+int no_user_literals();
+#endif
+
+// CHECK-0X: has_user_literals
+// CHECK-NO-0X: no_user_literals
+
+#if __has_feature(cxx_local_type_template_args)
+int has_local_type_template_args();
+#else
+int no_local_type_template_args();
+#endif
+
+// CHECK-0X: has_local_type_template_args
+// CHECK-NO-0X: no_local_type_template_args
diff --git a/test/Lexer/has_feature_modules.m b/test/Lexer/has_feature_modules.m
new file mode 100644
index 0000000..6cea324
--- /dev/null
+++ b/test/Lexer/has_feature_modules.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-OBJC-MODULES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-NO-OBJC-MODULES %s
+
+// RUN: %clang_cc1 -E -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-MODULES %s
+// RUN: %clang_cc1 -E -x c -fmodules %s -o - | FileCheck --check-prefix=CHECK-HAS-MODULES %s
+
+#if __has_feature(modules)
+int has_modules();
+#else
+int no_modules();
+#endif
+
+// CHECK-HAS-MODULES: has_modules
+// CHECK-NO-MODULES: no_modules
+
+#if __has_feature(objc_modules)
+int has_objc_modules();
+#else
+int no_objc_modules();
+#endif
+
+// CHECK-HAS-OBJC-MODULES: has_objc_modules
+// CHECK-NO-OBJC-MODULES: no_objc_modules
diff --git a/test/Lexer/has_feature_type_traits.cpp b/test/Lexer/has_feature_type_traits.cpp
index 53056a0..0c2cfa5 100644
--- a/test/Lexer/has_feature_type_traits.cpp
+++ b/test/Lexer/has_feature_type_traits.cpp
@@ -70,6 +70,11 @@ int is_enum();
#endif
// CHECK: int is_enum();
+#if __has_feature(is_final)
+int is_final();
+#endif
+// CHECK: int is_final();
+
#if __has_feature(is_pod)
int is_pod();
#endif
diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp
index 23daa49..6566933 100644
--- a/test/Lexer/hexfloat.cpp
+++ b/test/Lexer/hexfloat.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s
float f = 0x1p+1; // expected-warning{{hexadecimal floating constants are a C99 feature}}
-
+double e = 0x.p0; //expected-error{{hexadecimal floating constants require a significand}}
+double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
+double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}}
diff --git a/test/Lexer/ms-extensions.c b/test/Lexer/ms-extensions.c
index 9cd868e..377d2d5 100644
--- a/test/Lexer/ms-extensions.c
+++ b/test/Lexer/ms-extensions.c
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility %s
__int8 x1 = 3i8;
__int16 x2 = 4i16;
diff --git a/test/Lexer/ms-extensions.cpp b/test/Lexer/ms-extensions.cpp
new file mode 100644
index 0000000..7e18a6c
--- /dev/null
+++ b/test/Lexer/ms-extensions.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-user-defined-literal -fms-extensions -fms-compatibility %s
+
+#define bar(x) #x
+const char * f() {
+ return "foo"bar("bar")"baz"; /*expected-warning {{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}} */
+}
diff --git a/test/Lexer/newline-eof-c++11.cpp b/test/Lexer/newline-eof-c++11.cpp
new file mode 100644
index 0000000..3c45f28
--- /dev/null
+++ b/test/Lexer/newline-eof-c++11.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wnewline-eof -verify %s
+
+// The following line isn't terminated, don't fix it.
+void foo() {} \ No newline at end of file
diff --git a/test/Lexer/newline-eof-c++98-compat.cpp b/test/Lexer/newline-eof-c++98-compat.cpp
new file mode 100644
index 0000000..7f7eebb
--- /dev/null
+++ b/test/Lexer/newline-eof-c++98-compat.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang -cc1 -fsyntax-only -Wc++98-compat-pedantic -std=c++11 -verify %s
+
+// The following line isn't terminated, don't fix it.
+void foo() {} // expected-warning{{C++98 requires newline at end of file}} \ No newline at end of file
diff --git a/test/Lexer/newline-eof.c b/test/Lexer/newline-eof.c
index 2f95dc7..12087b2 100644
--- a/test/Lexer/newline-eof.c
+++ b/test/Lexer/newline-eof.c
@@ -1,5 +1,5 @@
-// RUN: %clang -fsyntax-only -Wnewline-eof -verify %s
+// RUN: %clang -cc1 -fsyntax-only -Wnewline-eof -verify %s
// rdar://9133072
// The following line isn't terminated, don't fix it.
-void foo() {} // expected-warning{{No newline at end of file}} \ No newline at end of file
+void foo() {} // expected-warning{{no newline at end of file}} \ No newline at end of file
diff --git a/test/Lexer/rdr-6096838-2.c b/test/Lexer/rdr-6096838-2.c
index 68aa5e6..e64acc9 100644
--- a/test/Lexer/rdr-6096838-2.c
+++ b/test/Lexer/rdr-6096838-2.c
@@ -2,4 +2,4 @@
rdar://6096838
*/
-long double d = 0x0.0000003ffffffff00000p-16357L; /* expected-warning {{ hexadecimal floating constants are a C99 feature }} */
+long double d = 0x0.0000003ffffffff00000p-16357L; /* expected-warning {{hexadecimal floating constants are a C99 feature}} */
diff --git a/test/Lexer/string-literal-encoding.c b/test/Lexer/string-literal-encoding.c
new file mode 100644
index 0000000..57097dc
--- /dev/null
+++ b/test/Lexer/string-literal-encoding.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x c++ -std=c++0x -fsyntax-only -verify %s
+
+// This file should be encoded using ISO-8859-1, the string literals should
+// contain the ISO-8859-1 encoding for the code points U+00C0 U+00E9 U+00EE
+// U+00F5 U+00FC
+
+void f() {
+ wchar_t const *a = L"Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+
+ char16_t const *b = u"Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *c = U"Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ wchar_t const *d = LR"(Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+ char16_t const *e = uR"(Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *f = UR"(Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+
+ char const *g = "Àéîõü"; // expected-warning {{illegal character encoding in string literal}}
+ char const *h = u8"Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ char const *i = R"(Àéîõü)"; // expected-warning {{illegal character encoding in string literal}}
+}
+
+void g() {
+ wchar_t const *a = L"foo Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+
+ char16_t const *b = u"foo Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *c = U"foo Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ wchar_t const *d = LR"(foo Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+ char16_t const *e = uR"(foo Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+ char32_t const *f = UR"(foo Àéîõü)"; // expected-error {{illegal character encoding in string literal}}
+
+ char const *g = "foo Àéîõü"; // expected-warning {{illegal character encoding in string literal}}
+ char const *h = u8"foo Àéîõü"; // expected-error {{illegal character encoding in string literal}}
+ char const *i = R"(foo Àéîõü)"; // expected-warning {{illegal character encoding in string literal}}
+}
diff --git a/test/Lexer/string_concat.cpp b/test/Lexer/string_concat.cpp
index 43782bc..7e78a63 100644
--- a/test/Lexer/string_concat.cpp
+++ b/test/Lexer/string_concat.cpp
@@ -2,32 +2,32 @@
void f() {
- const char* a = u8"abc" u"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char* b = u8"abc" U"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char* c = u8"abc" L"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char* d = u8"abc" uR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char* e = u8"abc" UR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char* f = u8"abc" LR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
+ const char* a = u8"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* b = u8"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* c = u8"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* d = u8"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* e = u8"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char* f = u8"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
- const char16_t* g = u"abc" u8"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char16_t* h = u"abc" U"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char16_t* i = u"abc" L"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char16_t* j = u"abc" u8R"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char16_t* k = u"abc" UR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char16_t* l = u"abc" LR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
+ const char16_t* g = u"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* h = u"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* i = u"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* j = u"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* k = u"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char16_t* l = u"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
- const char32_t* m = U"abc" u8"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char32_t* n = U"abc" u"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char32_t* o = U"abc" L"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char32_t* p = U"abc" u8R"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char32_t* q = U"abc" uR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const char32_t* r = U"abc" LR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
+ const char32_t* m = U"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* n = U"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* o = U"abc" L"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* p = U"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* q = U"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const char32_t* r = U"abc" LR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
- const wchar_t* s = L"abc" u8"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const wchar_t* t = L"abc" u"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const wchar_t* u = L"abc" U"abc"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const wchar_t* v = L"abc" u8R"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const wchar_t* w = L"abc" uR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
- const wchar_t* x = L"abc" UR"(abc)"; // expected-error {{ unsupported non-standard concatenation of string literals }}
+ const wchar_t* s = L"abc" u8"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* t = L"abc" u"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* u = L"abc" U"abc"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* v = L"abc" u8R"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* w = L"abc" uR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
+ const wchar_t* x = L"abc" UR"(abc)"; // expected-error {{unsupported non-standard concatenation of string literals}}
}
diff --git a/test/Lexer/token-concat.cpp b/test/Lexer/token-concat.cpp
new file mode 100644
index 0000000..57dbae0
--- /dev/null
+++ b/test/Lexer/token-concat.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -E -std=c++11 -o - %s | FileCheck %s
+
+#define id(x) x
+id("s")_x // CHECK: "s" _x
+id(L"s")_x // CHECK: L"s" _x
+id(u8"s")_x // CHECK: u8"s" _x
+id(u"s")_x // CHECK: u"s" _x
+id(U"s")_x // CHECK: U"s" _x
+id('s')_x // CHECK: 's' _x
+id(L's')_x // CHECK: L's' _x
+id(u's')_x // CHECK: u's' _x
+id(U's')_x // CHECK: U's' _x
+id("s"_x)_y // CHECK: "s"_x _y
+id(1.0_)f // CHECK: 1.0_ f
+id(1.0)_f // CHECK: 1.0 _f
+id(0xface+)b_count // CHECK: 0xface+ b_count
+id("s")1 // CHECK: "s"1
+id("s"_x)1 // CHECK: "s"_x 1
+id(1)_2_x // CHECK: 1 _2_x
diff --git a/test/Lexer/utf8-char-literal.cpp b/test/Lexer/utf8-char-literal.cpp
index c4ea5fc..12b001e 100644
--- a/test/Lexer/utf8-char-literal.cpp
+++ b/test/Lexer/utf8-char-literal.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -fsyntax-only -verify %s
-int array0[u'ñ' == u'\xf1'? 1 : -1];
-int array1['ñ' != u'\xf1'? 1 : -1];
+int array0[u'ñ' == u'\xf1'? 1 : -1];
+int array1['\xF1' != u'\xf1'? 1 : -1];
+int array1['ñ' != u'\xf1'? 1 : -1]; // expected-error {{character too large for enclosing character literal type}}
diff --git a/test/Lexer/wchar.c b/test/Lexer/wchar.c
index 648a38e..de00c02 100644
--- a/test/Lexer/wchar.c
+++ b/test/Lexer/wchar.c
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -fshort-wchar -verify %s
void f() {
- (void)L"\U00010000"; // expected-warning {{character unicode escape sequence too long for its type}}
+ (void)L"\U00010000"; // unicode escape produces UTF-16 sequence, so no warning
- (void)L'\U00010000'; // expected-warning {{character unicode escape sequence too long for its type}}
+ (void)L'\U00010000'; // expected-error {{character too large for enclosing character literal type}}
(void)L'ab'; // expected-warning {{extraneous characters in character constant ignored}}
diff --git a/test/Misc/caret-diags-macros.c b/test/Misc/caret-diags-macros.c
index 3d2e576..de1ee76 100644
--- a/test/Misc/caret-diags-macros.c
+++ b/test/Misc/caret-diags-macros.c
@@ -6,8 +6,8 @@ void foo() {
M1(
M2);
// CHECK: :7:{{[0-9]+}}: warning: expression result unused
- // CHECK: :4:{{[0-9]+}}: note: expanded from:
- // CHECK: :3:{{[0-9]+}}: note: expanded from:
+ // CHECK: :4:{{[0-9]+}}: note: expanded from macro 'M2'
+ // CHECK: :3:{{[0-9]+}}: note: expanded from macro 'M1'
}
#define A 1
@@ -16,9 +16,9 @@ void foo() {
void bar() {
C;
// CHECK: :17:3: warning: expression result unused
- // CHECK: :15:11: note: expanded from:
- // CHECK: :14:11: note: expanded from:
- // CHECK: :13:11: note: expanded from:
+ // CHECK: :15:11: note: expanded from macro 'C'
+ // CHECK: :14:11: note: expanded from macro 'B'
+ // CHECK: :13:11: note: expanded from macro 'A'
}
// rdar://7597492
@@ -46,28 +46,28 @@ void test() {
// its easy to FileCheck.
// CHECK-NEXT: macro_args3(1);
// CHECK-NEXT: ~~~~~~~~~~~~^~
- // CHECK: {{.*}}:36:36: note: expanded from:
- // CHECK: {{.*}}:35:36: note: expanded from:
- // CHECK: {{.*}}:34:24: note: expanded from:
+ // CHECK: {{.*}}:36:36: note: expanded from macro 'macro_args3'
+ // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+ // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
macro_many_args3(
1,
2,
3);
// CHECK: {{.*}}:55:5: warning: expression result unused
- // CHECK: {{.*}}:40:55: note: expanded from:
- // CHECK: {{.*}}:39:55: note: expanded from:
- // CHECK: {{.*}}:38:35: note: expanded from:
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
macro_many_args3(
1,
M2,
3);
// CHECK: {{.*}}:64:5: warning: expression result unused
- // CHECK: {{.*}}:4:12: note: expanded from:
- // CHECK: {{.*}}:40:55: note: expanded from:
- // CHECK: {{.*}}:39:55: note: expanded from:
- // CHECK: {{.*}}:38:35: note: expanded from:
+ // CHECK: {{.*}}:4:12: note: expanded from macro 'M2'
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
macro_many_args3(
1,
@@ -78,11 +78,11 @@ void test() {
// arguments.
// CHECK-NEXT: macro_args2(2),
// CHECK-NEXT: ~~~~~~~~~~~~^~~
- // CHECK: {{.*}}:35:36: note: expanded from:
- // CHECK: {{.*}}:34:24: note: expanded from:
- // CHECK: {{.*}}:40:55: note: expanded from:
- // CHECK: {{.*}}:39:55: note: expanded from:
- // CHECK: {{.*}}:38:35: note: expanded from:
+ // CHECK: {{.*}}:35:36: note: expanded from macro 'macro_args2'
+ // CHECK: {{.*}}:34:24: note: expanded from macro 'macro_args1'
+ // CHECK: {{.*}}:40:55: note: expanded from macro 'macro_many_args3'
+ // CHECK: {{.*}}:39:55: note: expanded from macro 'macro_many_args2'
+ // CHECK: {{.*}}:38:35: note: expanded from macro 'macro_many_args1'
}
#define variadic_args1(x, y, ...) y
@@ -94,9 +94,9 @@ void test2() {
// CHECK: {{.*}}:93:21: warning: expression result unused
// CHECK-NEXT: variadic_args3(1, 2, 3, 4);
// CHECK-NEXT: ~~~~~~~~~~~~~~~~~~^~~~~~~~
- // CHECK: {{.*}}:90:53: note: expanded from:
- // CHECK: {{.*}}:89:50: note: expanded from:
- // CHECK: {{.*}}:88:35: note: expanded from:
+ // CHECK: {{.*}}:90:53: note: expanded from macro 'variadic_args3'
+ // CHECK: {{.*}}:89:50: note: expanded from macro 'variadic_args2'
+ // CHECK: {{.*}}:88:35: note: expanded from macro 'variadic_args1'
}
#define variadic_pasting_args1(x, y, z) y
@@ -108,13 +108,13 @@ void test2() {
void test3() {
variadic_pasting_args3(1, 2, 3, 4);
// CHECK: {{.*}}:109:32: warning: expression result unused
- // CHECK: {{.*}}:105:72: note: expanded from:
- // CHECK: {{.*}}:103:68: note: expanded from:
- // CHECK: {{.*}}:102:41: note: expanded from:
+ // CHECK: {{.*}}:105:72: note: expanded from macro 'variadic_pasting_args3'
+ // CHECK: {{.*}}:103:68: note: expanded from macro 'variadic_pasting_args2'
+ // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
variadic_pasting_args3a(1, 2, 3, 4);
// CHECK: {{.*}}:115:30: warning: expression result unused
- // CHECK: {{.*}}:106:71: note: expanded from:
- // CHECK: {{.*}}:104:70: note: expanded from:
- // CHECK: {{.*}}:102:41: note: expanded from:
+ // CHECK: {{.*}}:106:71: note: expanded from macro 'variadic_pasting_args3a'
+ // CHECK: {{.*}}:104:70: note: expanded from macro 'variadic_pasting_args2a'
+ // CHECK: {{.*}}:102:41: note: expanded from macro 'variadic_pasting_args1'
}
diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp
index 0339b7b..4c9a731 100644
--- a/test/Misc/diag-aka-types.cpp
+++ b/test/Misc/diag-aka-types.cpp
@@ -27,7 +27,7 @@ namespace bar {
}
void test(Foo::foo* x) {
- bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *')}}
+ bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}}
}
// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
@@ -50,3 +50,19 @@ namespace std {
f(v); // expected-error{{no matching function for call to 'f'}}
}
}
+
+namespace ns {
+ struct str {
+ static void method(struct data *) {}
+ };
+}
+
+struct data { int i; };
+
+typedef void (*callback)(struct data *);
+
+void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}}
+
+void test() {
+ helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}}
+}
diff --git a/test/Misc/diag-format.c b/test/Misc/diag-format.c
index 39760b1..959177b 100644
--- a/test/Misc/diag-format.c
+++ b/test/Misc/diag-format.c
@@ -1,10 +1,10 @@
// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
-// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -ccc-host-triple x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
//
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc %s 2>&1 | FileCheck %s -check-prefix=MSVC
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -ccc-host-triple x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
-// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -ccc-host-triple x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
//
// RUN: %clang -fsyntax-only -fdiagnostics-format=vi %s 2>&1 | FileCheck %s -check-prefix=VI
//
diff --git a/test/Misc/diag-macro-backtrace.c b/test/Misc/diag-macro-backtrace.c
new file mode 100644
index 0000000..ea40cbe
--- /dev/null
+++ b/test/Misc/diag-macro-backtrace.c
@@ -0,0 +1,53 @@
+// RUN: %clang -fsyntax-only -fmacro-backtrace-limit=0 %s 2>&1 | FileCheck %s
+
+#define FOO 1+"hi"
+#define BAR FOO
+#define BAZ BAR
+#define QUZ BAZ
+#define TAZ QUZ
+#define ABA TAZ
+#define BAB ABA
+#define ZAZ BAB
+#define WAZ ZAZ
+#define DROOL WAZ
+#define FOOL DROOL
+
+FOOL
+
+// CHECK: :15:1: error: expected identifier or '('
+// CHECK: FOOL
+// CHECK: ^
+// CHECK: :13:14: note: expanded from macro 'FOOL'
+// CHECK: #define FOOL DROOL
+// CHECK: ^
+// CHECK: :12:15: note: expanded from macro 'DROOL'
+// CHECK: #define DROOL WAZ
+// CHECK: ^
+// CHECK: :11:13: note: expanded from macro 'WAZ'
+// CHECK: #define WAZ ZAZ
+// CHECK: ^
+// CHECK: :10:13: note: expanded from macro 'ZAZ'
+// CHECK: #define ZAZ BAB
+// CHECK: ^
+// CHECK: :9:13: note: expanded from macro 'BAB'
+// CHECK: #define BAB ABA
+// CHECK: ^
+// CHECK: :8:13: note: expanded from macro 'ABA'
+// CHECK: #define ABA TAZ
+// CHECK: ^
+// CHECK: :7:13: note: expanded from macro 'TAZ'
+// CHECK: #define TAZ QUZ
+// CHECK: ^
+// CHECK: :6:13: note: expanded from macro 'QUZ'
+// CHECK: #define QUZ BAZ
+// CHECK: ^
+// CHECK: :5:13: note: expanded from macro 'BAZ'
+// CHECK: #define BAZ BAR
+// CHECK: ^
+// CHECK: :4:13: note: expanded from macro 'BAR'
+// CHECK: #define BAR FOO
+// CHECK: ^
+// CHECK: :3:13: note: expanded from macro 'FOO'
+// CHECK: #define FOO 1+"hi"
+// CHECK: ^
+// CHECK: 1 error generated.
diff --git a/test/Misc/diag-verify.cpp b/test/Misc/diag-verify.cpp
new file mode 100644
index 0000000..895bc3f
--- /dev/null
+++ b/test/Misc/diag-verify.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s 2>&1 | FileCheck %s
+
+// Test the -verify flag. Each of the "x = y;" lines will produce a
+// "use of undeclared identifier 'y'" error message.
+
+void test() {
+ int x;
+ // Proper matches here.
+ x = y; // expected-error{{use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier}}
+ x = y; // expected-error{{undeclared identifier 'y'}}
+ x = y; // expected-error{{use of}}
+ x = y; // expected-error{{undeclared identifier}}
+ x = y; // expected-error{{'y'}}
+
+ // Bad matches here.
+ x = y; // expected-error{{use of undeclared identifier 'y' is fine}}
+ x = y; // expected-error{{abuse of undeclared identifier 'y'}}
+ x = y; // expected-error{{good use of undeclared identifier 'y' in code}}
+ x = y; // expected-error{{ use of undeclared identifier 'y' }}
+ x = y; // expected-error{{use of undeclared identifier 'y' is disallowed}}
+ x = y; // expected-error{{please don't use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier 'y'; please declare y before use}}
+ x = y; // expected-error{{use of use of undeclared identifier 'y'}}
+ x = y; // expected-error{{use of undeclared identifier 'y' identifier 'y'}}
+}
+
+//CHECK: error: 'error' diagnostics expected but not seen:
+//CHECK: Line 17: use of undeclared identifier 'y' is fine
+//CHECK: Line 18: abuse of undeclared identifier 'y'
+//CHECK: Line 19: good use of undeclared identifier 'y' in code
+//CHECK: Line 20: use of undeclared identifier 'y'
+//CHECK: Line 21: use of undeclared identifier 'y' is disallowed
+//CHECK: Line 22: please don't use of undeclared identifier 'y'
+//CHECK: Line 23: use of undeclared identifier 'y'; please declare y before use
+//CHECK: Line 24: use of use of undeclared identifier 'y'
+//CHECK: Line 25: use of undeclared identifier 'y' identifier 'y'
+//CHECK: error: 'error' diagnostics seen but not expected:
+//CHECK: Line 17: use of undeclared identifier 'y'
+//CHECK: Line 18: use of undeclared identifier 'y'
+//CHECK: Line 19: use of undeclared identifier 'y'
+//CHECK: Line 20: use of undeclared identifier 'y'
+//CHECK: Line 21: use of undeclared identifier 'y'
+//CHECK: Line 22: use of undeclared identifier 'y'
+//CHECK: Line 23: use of undeclared identifier 'y'
+//CHECK: Line 24: use of undeclared identifier 'y'
+//CHECK: Line 25: use of undeclared identifier 'y'
+//CHECK: 18 errors generated.
diff --git a/test/Misc/include-stack-for-note-flag.cpp b/test/Misc/include-stack-for-note-flag.cpp
index cfec506..b41284f 100644
--- a/test/Misc/include-stack-for-note-flag.cpp
+++ b/test/Misc/include-stack-for-note-flag.cpp
@@ -18,11 +18,11 @@ bool macro(int x, int y) {
// STACK: note: candidate function not viable
// STACK: error: comparison between pointer and integer
// STACK: In file included from
-// STACK: note: expanded from:
+// STACK: note: expanded from macro
// STACKLESS: error: no matching function for call to 'foo'
// STACKLESS-NOT: In file included from
// STACKLESS: note: candidate function not viable
// STACKLESS: error: comparison between pointer and integer
// STACKLESS-NOT: In file included from
-// STACKLESS: note: expanded from:
+// STACKLESS: note: expanded from macro
diff --git a/test/Misc/integer-literal-printing.cpp b/test/Misc/integer-literal-printing.cpp
new file mode 100644
index 0000000..d751730
--- /dev/null
+++ b/test/Misc/integer-literal-printing.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// PR11179
+template <short T> class Type1 {};
+template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type1<-42>' to 'Type1<-42> &' for 1st argument;}}
+
+template <unsigned short T> class Type2 {};
+template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type2<42>' to 'Type2<42> &' for 1st argument;}}
+
+void Function() {
+ Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}}
+ Function2(Type2<42>()); // expected-error{{no matching function for call to 'Function2'}}
+}
diff --git a/test/Misc/macro-backtrace-limit.c b/test/Misc/macro-backtrace-limit.c
deleted file mode 100644
index ee73c61..0000000
--- a/test/Misc/macro-backtrace-limit.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s > %t 2>&1
-// RUN: FileCheck %s < %t
-
-#define M1(A, B) ((A) < (B))
-#define M2(A, B) M1(A, B)
-#define M3(A, B) M2(A, B)
-#define M4(A, B) M3(A, B)
-#define M5(A, B) M4(A, B)
-#define M6(A, B) M5(A, B)
-#define M7(A, B) M6(A, B)
-#define M8(A, B) M7(A, B)
-#define M9(A, B) M8(A, B)
-#define M10(A, B) M9(A, B)
-#define M11(A, B) M10(A, B)
-#define M12(A, B) M11(A, B)
-
-void f(int *ip, float *fp) {
- // CHECK: macro-backtrace-limit.c:31:7: warning: comparison of distinct pointer types ('int *' and 'float *')
- // CHECK: if (M12(ip, fp)) { }
- // CHECK: macro-backtrace-limit.c:15:19: note: expanded from:
- // CHECK: #define M12(A, B) M11(A, B)
- // CHECK: macro-backtrace-limit.c:14:19: note: expanded from:
- // CHECK: #define M11(A, B) M10(A, B)
- // CHECK: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
- // CHECK: macro-backtrace-limit.c:6:18: note: expanded from:
- // CHECK: #define M3(A, B) M2(A, B)
- // CHECK: macro-backtrace-limit.c:5:18: note: expanded from:
- // CHECK: #define M2(A, B) M1(A, B)
- // CHECK: macro-backtrace-limit.c:4:23: note: expanded from:
- // CHECK: #define M1(A, B) ((A) < (B))
- if (M12(ip, fp)) { }
-}
diff --git a/test/Misc/macro-backtrace.c b/test/Misc/macro-backtrace.c
new file mode 100644
index 0000000..7aeaf21
--- /dev/null
+++ b/test/Misc/macro-backtrace.c
@@ -0,0 +1,57 @@
+// Tests for macro expansion backtraces. The RUN and CHECK lines are grouped
+// below the test code to reduce noise when updating them.
+
+#define M1(A, B) ((A) < (B))
+#define M2(A, B) M1(A, B)
+#define M3(A, B) M2(A, B)
+#define M4(A, B) M3(A, B)
+#define M5(A, B) M4(A, B)
+#define M6(A, B) M5(A, B)
+#define M7(A, B) M6(A, B)
+#define M8(A, B) M7(A, B)
+#define M9(A, B) M8(A, B)
+#define M10(A, B) M9(A, B)
+#define M11(A, B) M10(A, B)
+#define M12(A, B) M11(A, B)
+
+void f(int *ip, float *fp) {
+ if (M12(ip, fp)) { }
+ // RUN: %clang_cc1 -fsyntax-only -fmacro-backtrace-limit 5 %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-LIMIT
+ // CHECK-LIMIT: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
+ // CHECK-LIMIT: if (M12(ip, fp)) { }
+ // CHECK-LIMIT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
+ // CHECK-LIMIT: #define M12(A, B) M11(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
+ // CHECK-LIMIT: #define M11(A, B) M10(A, B)
+ // CHECK-LIMIT: note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+ // CHECK-LIMIT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
+ // CHECK-LIMIT: #define M3(A, B) M2(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
+ // CHECK-LIMIT: #define M2(A, B) M1(A, B)
+ // CHECK-LIMIT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
+ // CHECK-LIMIT: #define M1(A, B) ((A) < (B))
+
+ // RUN: %clang_cc1 -fsyntax-only -fno-caret-diagnostics %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-NO-CARETS
+ // CHECK-NO-CARETS: macro-backtrace.c:18:7: warning: comparison of distinct pointer types ('int *' and 'float *')
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:15:19: note: expanded from macro 'M12'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:14:19: note: expanded from macro 'M11'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:13:19: note: expanded from macro 'M10'
+ // CHECK-NO-CARETS-NEXT: note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:6:18: note: expanded from macro 'M3'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:5:18: note: expanded from macro 'M2'
+ // CHECK-NO-CARETS-NEXT: macro-backtrace.c:4:23: note: expanded from macro 'M1'
+
+ // Check that the expansion notes respect the same formatting options as
+ // other diagnostics.
+ // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-format vi %s 2>&1 \
+ // RUN: | FileCheck %s -check-prefix=CHECK-NOTE-FORMAT
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +18:7: warning:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +15:19: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +14:19: note:
+ // CHECK-NOTE-FORMAT: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +6:18: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +5:18: note:
+ // CHECK-NOTE-FORMAT: macro-backtrace.c +4:23: note:
+}
diff --git a/test/Misc/pubnames.c b/test/Misc/pubnames.c
new file mode 100644
index 0000000..0304897
--- /dev/null
+++ b/test/Misc/pubnames.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -pubnames-dump %s | FileCheck %s
+#define FOO
+#define BAR
+#undef FOO
+#define WIBBLE
+
+int foo();
+int bar(float);
+int wibble;
+
+// CHECK: BAR
+// CHECK-NOT: FOO
+// CHECK: WIBBLE
+// CHECK-NOT: __clang_major__
+// CHECK: bar
+// CHECK: foo
+// CHECK: wibble
+
+
diff --git a/test/Misc/serialized-diags-no-category.c b/test/Misc/serialized-diags-no-category.c
new file mode 100644
index 0000000..3074892
--- /dev/null
+++ b/test/Misc/serialized-diags-no-category.c
@@ -0,0 +1,12 @@
+#error foo
+#error bar
+
+// RUN: rm -f %t
+// RUN: %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+
+// This test case tests that we can handle both fatal errors and errors without categories.
+
+// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo []
+// CHECK: Number of diagnostics: 2
+
diff --git a/test/Misc/serialized-diags-no-issue.c b/test/Misc/serialized-diags-no-issue.c
new file mode 100644
index 0000000..5c7da82
--- /dev/null
+++ b/test/Misc/serialized-diags-no-issue.c
@@ -0,0 +1,10 @@
+void foo();
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// NOTE: it is important that this test case contains no issues. It tests
+// that serialize diagnostics work in the absence of any issues.
+
+// CHECK: Number of diagnostics: 0
diff --git a/test/Misc/serialized-diags-single-issue.c b/test/Misc/serialized-diags-single-issue.c
new file mode 100644
index 0000000..938dda3
--- /dev/null
+++ b/test/Misc/serialized-diags-single-issue.c
@@ -0,0 +1,36 @@
+void foo() {
+ int voodoo;
+ voodoo = voodoo + 1;
+}
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// NOTE: it is important that this test case only contain a single issue. This test case checks
+// if we can handle serialized diagnostics that contain only one diagnostic.
+
+// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] [Semantic Issue]
+// CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// Test that we handle serializing diagnostics for multiple source files
+// RUN: %clang_cc1 -Wall -fsyntax-only %s %s -serialize-diagnostic-file %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck -check-prefix=CHECK-MULT %s
+// RUN: rm -f %t
+
+// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// CHECK-MULT: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK-MULT: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK-MULT: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK-MULT: +-Range: {{.*}}serialized-diags-single-issue.c:2:13 {{.*}}serialized-diags-single-issue.c:2:13
+// CHECK-MULT: +-FIXIT: ({{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
+
+// CHECK-MULT: Number of diagnostics: 2
diff --git a/test/Misc/serialized-diags.c b/test/Misc/serialized-diags.c
new file mode 100644
index 0000000..ae4611b
--- /dev/null
+++ b/test/Misc/serialized-diags.c
@@ -0,0 +1,67 @@
+void foo() {
+ int voodoo;
+ voodoo = voodoo + 1;
+}
+
+void bar() {
+ int dragon;
+ dragon = dragon + 1
+}
+
+// Test handling of FixIts that only remove text.
+int baz();
+void qux(int x) {
+ if ((x == baz()))
+ return;
+}
+
+// Test handling of macros.
+void taz(int x, int y);
+#define false 0
+void testMacro() {
+ taz(0, 0, false);
+}
+
+// Test handling of issues from #includes.
+#include "serialized-diags.h"
+
+// Test handling of warnings that have empty fixits.
+void rdar11040133() {
+ unsigned x;
+}
+
+// RUN: rm -f %t
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 || true
+// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+// This test case tests that we can handle multiple diagnostics which contain
+// FIXITs at different levels (one at the note, another at the main diagnostic).
+
+// CHECK: {{.*[/\\]}}serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:3:12 {{.*[/\\]}}serialized-diags.c:3:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0"
+// CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression []
+// CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";"
+// CHECK: {{.*[/\\]}}serialized-diags.c:14:10: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:14:8 {{.*[/\\]}}serialized-diags.c:14:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: remove extraneous parentheses around the comparison to silence this warning []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:7 - {{.*[/\\]}}serialized-diags.c:14:8): ""
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:18 - {{.*[/\\]}}serialized-diags.c:14:19): ""
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: use '=' to turn this equality comparison into an assignment []
+// CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:10 - {{.*[/\\]}}serialized-diags.c:14:12): "="
+// CHECK: {{.*[/\\]}}serialized-diags.c:22:13: error: too many arguments to function call, expected 2, have 3 []
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
+// CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 {{.*[/\\]}}serialized-diags.c:22:18
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' []
+// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6
+// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here []
+// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
+// CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17
+// CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: []
+// CHECK: Number FIXITs = 0
+// CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x'
+// CHECK: Number FIXITs = 0
+// CHECK: Number of diagnostics: 6
diff --git a/test/Misc/serialized-diags.h b/test/Misc/serialized-diags.h
new file mode 100644
index 0000000..d38a352
--- /dev/null
+++ b/test/Misc/serialized-diags.h
@@ -0,0 +1,5 @@
+// This file intentionally has a bug. It is intended
+// to be used with serialized-diagnostics.c to show
+// how errors are handled with #includes in serialized
+// diagnostics.
+char *badStr = 1;
diff --git a/test/Misc/warn-in-system-header.c b/test/Misc/warn-in-system-header.c
index 7e4615e..6e0237d 100644
--- a/test/Misc/warn-in-system-header.c
+++ b/test/Misc/warn-in-system-header.c
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify
#include <warn-in-system-header.h>
-// expected-warning {{#warning}}
+// expected-warning {{the cake is a lie}}
diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c
index 2f7103a..bc0c941 100644
--- a/test/Misc/warning-flags.c
+++ b/test/Misc/warning-flags.c
@@ -17,28 +17,14 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (297):
-CHECK-NEXT: backslash_newline_space
-CHECK-NEXT: charize_microsoft_ext
-CHECK-NEXT: ext_anon_param_requires_type_specifier
+CHECK: Warnings without flags (253):
CHECK-NEXT: ext_anonymous_struct_union_qualified
-CHECK-NEXT: ext_array_init_copy
-CHECK-NEXT: ext_auto_storage_class
CHECK-NEXT: ext_binary_literal
-CHECK-NEXT: ext_c99_array_usage
-CHECK-NEXT: ext_c99_compound_literal
-CHECK-NEXT: ext_c99_variable_decl_in_for_loop
-CHECK-NEXT: ext_c99_whitespace_required_after_macro_name
CHECK-NEXT: ext_cast_fn_obj
-CHECK-NEXT: ext_catch_incomplete_ptr
-CHECK-NEXT: ext_catch_incomplete_ref
CHECK-NEXT: ext_delete_void_ptr_operand
CHECK-NEXT: ext_designated_init
-CHECK-NEXT: ext_designated_init_cxx
-CHECK-NEXT: ext_dollar_in_identifier
CHECK-NEXT: ext_duplicate_declspec
CHECK-NEXT: ext_ellipsis_exception_spec
-CHECK-NEXT: ext_embedded_directive
CHECK-NEXT: ext_empty_fnmacro_arg
CHECK-NEXT: ext_empty_source_file
CHECK-NEXT: ext_enum_friend
@@ -47,11 +33,8 @@ CHECK-NEXT: ext_enumerator_list_comma
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_explicit_instantiation_without_qualified_id
CHECK-NEXT: ext_explicit_specialization_storage_class
-CHECK-NEXT: ext_expr_not_ice
CHECK-NEXT: ext_extra_ivar_semi
CHECK-NEXT: ext_extra_struct_semi
-CHECK-NEXT: ext_flexible_array_in_array
-CHECK-NEXT: ext_flexible_array_in_struct
CHECK-NEXT: ext_forward_ref_enum
CHECK-NEXT: ext_freestanding_complex
CHECK-NEXT: ext_hexconstant_invalid
@@ -68,15 +51,12 @@ CHECK-NEXT: ext_missing_varargs_arg
CHECK-NEXT: ext_missing_whitespace_after_macro_name
CHECK-NEXT: ext_new_paren_array_nonconst
CHECK-NEXT: ext_nonstandard_escape
-CHECK-NEXT: ext_offsetof_extended_field_designator
CHECK-NEXT: ext_param_not_declared
-CHECK-NEXT: ext_param_promoted_not_compatible_with_prototype
CHECK-NEXT: ext_paste_comma
CHECK-NEXT: ext_plain_complex
CHECK-NEXT: ext_pp_bad_vaargs_use
CHECK-NEXT: ext_pp_comma_expr
CHECK-NEXT: ext_pp_ident_directive
-CHECK-NEXT: ext_pp_import_directive
CHECK-NEXT: ext_pp_include_next_directive
CHECK-NEXT: ext_pp_line_too_big
CHECK-NEXT: ext_pp_macro_redef
@@ -96,8 +76,6 @@ CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer
CHECK-NEXT: ext_typecheck_cond_incompatible_operands
CHECK-NEXT: ext_typecheck_cond_incompatible_operands_nonstandard
CHECK-NEXT: ext_typecheck_cond_one_void
-CHECK-NEXT: ext_typecheck_convert_int_pointer
-CHECK-NEXT: ext_typecheck_convert_pointer_int
CHECK-NEXT: ext_typecheck_convert_pointer_void_func
CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers
CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_and_zero
@@ -106,9 +84,6 @@ CHECK-NEXT: ext_typecheck_zero_array_size
CHECK-NEXT: ext_unknown_escape
CHECK-NEXT: ext_using_undefined_std
CHECK-NEXT: ext_vla_folded_to_constant
-CHECK-NEXT: null_in_char
-CHECK-NEXT: null_in_file
-CHECK-NEXT: null_in_string
CHECK-NEXT: pp_include_next_absolute_path
CHECK-NEXT: pp_include_next_in_primary
CHECK-NEXT: pp_invalid_string_literal
@@ -126,7 +101,6 @@ CHECK-NEXT: warn_attribute_iboutlet
CHECK-NEXT: warn_attribute_ignored
CHECK-NEXT: warn_attribute_ignored_for_field_of_type
CHECK-NEXT: warn_attribute_malloc_pointer_only
-CHECK-NEXT: warn_attribute_method_def
CHECK-NEXT: warn_attribute_nonnull_no_pointers
CHECK-NEXT: warn_attribute_precede_definition
CHECK-NEXT: warn_attribute_sentinel_named_arguments
@@ -145,7 +119,6 @@ CHECK-NEXT: warn_bad_receiver_type
CHECK-NEXT: warn_bitfield_width_exceeds_type_size
CHECK-NEXT: warn_bool_switch_condition
CHECK-NEXT: warn_braces_around_scalar_init
-CHECK-NEXT: warn_builtin_unknown
CHECK-NEXT: warn_c_kext
CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor
CHECK-NEXT: warn_call_wrong_number_of_arguments
@@ -161,24 +134,18 @@ CHECK-NEXT: warn_conv_to_base_not_used
CHECK-NEXT: warn_conv_to_self_not_used
CHECK-NEXT: warn_conv_to_void_not_used
CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg
-CHECK-NEXT: warn_decl_in_param_list
CHECK-NEXT: warn_delete_array_type
-CHECK-NEXT: warn_delete_incomplete
CHECK-NEXT: warn_division_by_zero
CHECK-NEXT: warn_double_const_requires_fp64
CHECK-NEXT: warn_drv_assuming_mfloat_abi_is
CHECK-NEXT: warn_drv_clang_unsupported
-CHECK-NEXT: warn_drv_conflicting_deployment_targets
CHECK-NEXT: warn_drv_input_file_unused
CHECK-NEXT: warn_drv_not_using_clang_arch
CHECK-NEXT: warn_drv_not_using_clang_cpp
CHECK-NEXT: warn_drv_not_using_clang_cxx
CHECK-NEXT: warn_drv_objc_gc_unsupported
CHECK-NEXT: warn_drv_pch_not_first_include
-CHECK-NEXT: warn_drv_pipe_ignored_with_save_temps
CHECK-NEXT: warn_drv_preprocessed_input_file_unused
-CHECK-NEXT: warn_drv_unsupported_option_argument
-CHECK-NEXT: warn_drv_unused_argument
CHECK-NEXT: warn_dup_category_def
CHECK-NEXT: warn_duplicate_protocol_def
CHECK-NEXT: warn_enum_too_large
@@ -201,8 +168,6 @@ CHECK-NEXT: warn_hex_escape_too_large
CHECK-NEXT: warn_ignoring_ftabstop_value
CHECK-NEXT: warn_illegal_constant_array_size
CHECK-NEXT: warn_implements_nscopying
-CHECK-NEXT: warn_implicit_decl_requires_setjmp
-CHECK-NEXT: warn_implicit_decl_requires_stdio
CHECK-NEXT: warn_incompatible_qualified_id
CHECK-NEXT: warn_initializer_string_for_char_array_too_long
CHECK-NEXT: warn_inline_namespace_reopened_noninline
@@ -211,7 +176,6 @@ CHECK-NEXT: warn_instance_method_on_class_found
CHECK-NEXT: warn_integer_too_large
CHECK-NEXT: warn_integer_too_large_for_signed
CHECK-NEXT: warn_invalid_asm_cast_lvalue
-CHECK-NEXT: warn_label_attribute_not_unused
CHECK-NEXT: warn_many_braces_around_scalar_init
CHECK-NEXT: warn_maynot_respond
CHECK-NEXT: warn_member_extra_qualification
@@ -236,7 +200,6 @@ CHECK-NEXT: warn_octal_escape_too_large
CHECK-NEXT: warn_odr_tag_type_inconsistent
CHECK-NEXT: warn_on_superclass_use
CHECK-NEXT: warn_param_default_argument_redefinition
-CHECK-NEXT: warn_parens_disambiguated_as_function_decl
CHECK-NEXT: warn_partial_specs_not_deducible
CHECK-NEXT: warn_pointer_attribute_wrong_type
CHECK-NEXT: warn_pp_convert_lhs_to_positive
@@ -258,7 +221,6 @@ CHECK-NEXT: warn_pragma_options_align_unsupported_option
CHECK-NEXT: warn_pragma_options_expected_align
CHECK-NEXT: warn_pragma_pack_invalid_action
CHECK-NEXT: warn_pragma_pack_invalid_alignment
-CHECK-NEXT: warn_pragma_pack_invalid_constant
CHECK-NEXT: warn_pragma_pack_malformed
CHECK-NEXT: warn_pragma_pack_pop_failed
CHECK-NEXT: warn_pragma_pack_pop_identifer_and_alignment
@@ -286,8 +248,6 @@ CHECK-NEXT: warn_remainder_by_zero
CHECK-NEXT: warn_root_inst_method_not_found
CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument
CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible
-CHECK-NEXT: warn_setter_getter_impl_required
-CHECK-NEXT: warn_setter_getter_impl_required_in_category
CHECK-NEXT: warn_standalone_specifier
CHECK-NEXT: warn_static_inline_explicit_inst_ignored
CHECK-NEXT: warn_static_non_static
@@ -298,16 +258,12 @@ CHECK-NEXT: warn_transparent_union_attribute_field_size_align
CHECK-NEXT: warn_transparent_union_attribute_floating
CHECK-NEXT: warn_transparent_union_attribute_not_definition
CHECK-NEXT: warn_transparent_union_attribute_zero_fields
-CHECK-NEXT: warn_transparent_union_nonpointer
CHECK-NEXT: warn_typecheck_function_qualifiers
-CHECK-NEXT: warn_ucn_escape_too_large
-CHECK-NEXT: warn_ucn_not_valid_in_c89
CHECK-NEXT: warn_unavailable_fwdclass_message
CHECK-NEXT: warn_undef_interface
CHECK-NEXT: warn_undef_interface_suggest
CHECK-NEXT: warn_undef_protocolref
CHECK-NEXT: warn_undefined_internal
-CHECK-NEXT: warn_uninit_val
CHECK-NEXT: warn_unknown_analyzer_checker
CHECK-NEXT: warn_unknown_method_family
CHECK-NEXT: warn_unterminated_char
diff --git a/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h b/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
new file mode 100644
index 0000000..1417e0c
--- /dev/null
+++ b/test/Modules/Inputs/AlsoDependsOnModule.framework/Headers/AlsoDependsOnModule.h
@@ -0,0 +1,2 @@
+#import <Module/Module.h> // expected-warning{{treating #import as an import of module 'Module'}}
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
new file mode 100644
index 0000000..69f9e8e
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/Other.h
@@ -0,0 +1 @@
+double *sub_framework_other;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..e6e835e
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,2 @@
+#include "SubFramework/Other.h"
+float *sub_framework;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
index fa40697..9425f48 100644
--- a/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/DependsOnModule.h
@@ -1,3 +1,5 @@
-#include <Module/Module.h>
+#include <Module/Module.h> //expected-warning{{treating #include as an import of module 'Module'}}
#define DEPENDS_ON_MODULE 1
+#__private_macro DEPENDS_ON_MODULE
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
new file mode 100644
index 0000000..724d798
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/cxx_other.h
@@ -0,0 +1,5 @@
+class CXXOnly {
+ public:
+ CXXOnly();
+ ~CXXOnly();
+};
diff --git a/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h b/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
new file mode 100644
index 0000000..5ee3f92
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/Headers/other.h
@@ -0,0 +1 @@
+int depends_on_module_other;
diff --git a/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h b/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
new file mode 100644
index 0000000..4b3c30c
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/PrivateHeaders/DependsOnModulePrivate.h
@@ -0,0 +1,2 @@
+int depends_on_module_private;
+
diff --git a/test/Modules/Inputs/DependsOnModule.framework/module.map b/test/Modules/Inputs/DependsOnModule.framework/module.map
new file mode 100644
index 0000000..2a3dd80
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -0,0 +1,19 @@
+framework module DependsOnModule {
+ umbrella header "DependsOnModule.h"
+ header "other.h"
+ module * {
+ export *
+ }
+ explicit module CXX {
+ requires cplusplus
+ header "cxx_other.h"
+ }
+
+ explicit framework module SubFramework {
+ umbrella header "SubFramework.h"
+
+ module * {
+ export *
+ }
+ }
+}
diff --git a/test/Modules/Inputs/DependsOnModule.framework/module_private.map b/test/Modules/Inputs/DependsOnModule.framework/module_private.map
new file mode 100644
index 0000000..5ed0029
--- /dev/null
+++ b/test/Modules/Inputs/DependsOnModule.framework/module_private.map
@@ -0,0 +1,6 @@
+explicit module DependsOnModule.Private {
+ explicit module DependsOnModule {
+ header "DependsOnModulePrivate.h"
+ }
+}
+
diff --git a/test/Modules/Inputs/MethodPoolA.h b/test/Modules/Inputs/MethodPoolA.h
new file mode 100644
index 0000000..6af24a9
--- /dev/null
+++ b/test/Modules/Inputs/MethodPoolA.h
@@ -0,0 +1,8 @@
+
+
+
+
+@interface A
++ (int)method1;
+- (int)method2:(int)param;
+@end
diff --git a/test/Modules/Inputs/MethodPoolB.h b/test/Modules/Inputs/MethodPoolB.h
new file mode 100644
index 0000000..e1e86ed
--- /dev/null
+++ b/test/Modules/Inputs/MethodPoolB.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+@interface B
+- (int)method1;
+- (int)method2:(float)param;
+@end
diff --git a/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
new file mode 100644
index 0000000..f7f9fb6
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h
@@ -0,0 +1,5 @@
+#ifndef MODULE_SUBFRAMEWORK_H
+#define MODULE_SUBFRAMEWORK_H
+#__private_macro MODULE_SUBFRAMEWORK_H
+char *module_subframework;
+#endif
diff --git a/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h b/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
new file mode 100644
index 0000000..6e81adc
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Buried/Treasure.h
@@ -0,0 +1 @@
+unsigned *Buried_Treasure;
diff --git a/test/Modules/Inputs/Module.framework/Headers/Module.h b/test/Modules/Inputs/Module.framework/Headers/Module.h
index 7c7ef6e..738b222 100644
--- a/test/Modules/Inputs/Module.framework/Headers/Module.h
+++ b/test/Modules/Inputs/Module.framework/Headers/Module.h
@@ -1,3 +1,7 @@
+// expected-warning{{umbrella header}}
+
+#ifndef MODULE_H
+#define MODULE_H
const char *getModuleVersion(void);
#ifdef FOO
@@ -10,3 +14,9 @@ const char *getModuleVersion(void);
@end
#define MODULE_H_MACRO 1
+#__private_macro MODULE_H_MACRO
+
+#include <Module/Sub.h>
+#include <Module/Buried/Treasure.h>
+
+#endif // MODULE_H
diff --git a/test/Modules/Inputs/Module.framework/Headers/NotInModule.h b/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
new file mode 100644
index 0000000..6b15791
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/NotInModule.h
@@ -0,0 +1 @@
+int not_in_module;
diff --git a/test/Modules/Inputs/Module.framework/Headers/Sub.h b/test/Modules/Inputs/Module.framework/Headers/Sub.h
new file mode 100644
index 0000000..dea76e7
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Sub.h
@@ -0,0 +1,3 @@
+#include <Module/Sub2.h>
+int *Module_Sub;
+
diff --git a/test/Modules/Inputs/Module.framework/Headers/Sub2.h b/test/Modules/Inputs/Module.framework/Headers/Sub2.h
new file mode 100644
index 0000000..beed4a8
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/Headers/Sub2.h
@@ -0,0 +1 @@
+int *Module_Sub2;
diff --git a/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
new file mode 100644
index 0000000..0782336
--- /dev/null
+++ b/test/Modules/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h
@@ -0,0 +1 @@
+int module_private;
diff --git a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
index 2a8282c..5142f56 100644
--- a/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
+++ b/test/Modules/Inputs/MutuallyRecursive1.framework/Headers/MutuallyRecursive1.h
@@ -1,3 +1,3 @@
-__import_module__ MutuallyRecursive2;
+@__experimental_modules_import MutuallyRecursive2;
diff --git a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
index 9800853..8a3cc33 100644
--- a/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
+++ b/test/Modules/Inputs/MutuallyRecursive2.framework/Headers/MutuallyRecursive2.h
@@ -1,6 +1,6 @@
-__import_module__ MutuallyRecursive1;
+@__experimental_modules_import MutuallyRecursive1;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
new file mode 100644
index 0000000..73f32bf
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/A.h
@@ -0,0 +1,8 @@
+int no_umbrella_A;
+
+inline int has_warning(int x) {
+ if (x > 0)
+ return x;
+ // Note: warning here is suppressed because this module is considered a
+ // "system" module.
+}
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
new file mode 100644
index 0000000..dc6770f
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/B.h
@@ -0,0 +1 @@
+int no_umbrella_B;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
new file mode 100644
index 0000000..ac4a14a
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/Boom.h
@@ -0,0 +1 @@
+this is gibberish
diff --git a/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h b/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
new file mode 100644
index 0000000..4a9351a
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/Headers/SubDir/C.h
@@ -0,0 +1 @@
+int no_umbrella_C;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
new file mode 100644
index 0000000..bd606d2
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h
@@ -0,0 +1 @@
+int no_umbrella_A_private;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
new file mode 100644
index 0000000..442be2d
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/PrivateHeaders/B_Private.h
@@ -0,0 +1 @@
+int no_umbrella_B_private;
diff --git a/test/Modules/Inputs/NoUmbrella.framework/module.map b/test/Modules/Inputs/NoUmbrella.framework/module.map
new file mode 100644
index 0000000..4a4d970
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/module.map
@@ -0,0 +1,9 @@
+framework module NoUmbrella [system] {
+ umbrella "Headers"
+ module * { }
+
+ module unavailable {
+ requires unavailable
+ header "Boom.h"
+ }
+}
diff --git a/test/Modules/Inputs/NoUmbrella.framework/module_private.map b/test/Modules/Inputs/NoUmbrella.framework/module_private.map
new file mode 100644
index 0000000..0507ba0
--- /dev/null
+++ b/test/Modules/Inputs/NoUmbrella.framework/module_private.map
@@ -0,0 +1,4 @@
+explicit module NoUmbrella.Private {
+ umbrella "PrivateHeaders"
+ explicit module * { }
+}
diff --git a/test/Modules/Inputs/System/usr/include/module.map b/test/Modules/Inputs/System/usr/include/module.map
new file mode 100644
index 0000000..884b59c
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/module.map
@@ -0,0 +1,21 @@
+module cstd [system] {
+ // Only in compiler support directory
+ module float_constants {
+ header "float.h"
+ }
+
+ // Only in system headers directory
+ module stdio {
+ header "stdio.h"
+ }
+
+ // In both directories (compiler support version wins, does not forward)
+ module stdbool {
+ header "stdbool.h"
+ }
+
+ // In both directories (compiler support version wins, forwards)
+ module stdint {
+ header "stdint.h"
+ }
+}
diff --git a/test/Modules/Inputs/System/usr/include/stdbool.h b/test/Modules/Inputs/System/usr/include/stdbool.h
new file mode 100644
index 0000000..760d7dc
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdbool.h
@@ -0,0 +1 @@
+// Testing hack: does not define bool/true/false.
diff --git a/test/Modules/Inputs/System/usr/include/stdint.h b/test/Modules/Inputs/System/usr/include/stdint.h
new file mode 100644
index 0000000..e8e50f9
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdint.h
@@ -0,0 +1 @@
+typedef int my_awesome_nonstandard_integer_type;
diff --git a/test/Modules/Inputs/System/usr/include/stdio.h b/test/Modules/Inputs/System/usr/include/stdio.h
new file mode 100644
index 0000000..9a7b106
--- /dev/null
+++ b/test/Modules/Inputs/System/usr/include/stdio.h
@@ -0,0 +1,3 @@
+typedef struct { int id; } FILE;
+int fprintf(FILE*restrict, const char* restrict format, ...);
+
diff --git a/test/Modules/Inputs/category_bottom.h b/test/Modules/Inputs/category_bottom.h
new file mode 100644
index 0000000..b53d9c3
--- /dev/null
+++ b/test/Modules/Inputs/category_bottom.h
@@ -0,0 +1,11 @@
+@__experimental_modules_import category_left;
+
+@interface Foo(Bottom)
+-(void)bottom;
+@end
+
+@__experimental_modules_import category_right;
+
+@interface LeftFoo(Bottom)
+-(void)bottom;
+@end
diff --git a/test/Modules/Inputs/category_left.h b/test/Modules/Inputs/category_left.h
new file mode 100644
index 0000000..736fa43
--- /dev/null
+++ b/test/Modules/Inputs/category_left.h
@@ -0,0 +1,15 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Left)
+-(void)left;
+@end
+
+@interface LeftFoo
+-(void)left;
+@end
+
+@interface Foo(Duplicate)
+@end
+
+@interface Foo(Duplicate)
+@end
diff --git a/test/Modules/Inputs/category_other.h b/test/Modules/Inputs/category_other.h
new file mode 100644
index 0000000..1bb5a91
--- /dev/null
+++ b/test/Modules/Inputs/category_other.h
@@ -0,0 +1,6 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Other)
+-(void)other;
+@end
+
diff --git a/test/Modules/Inputs/category_right.h b/test/Modules/Inputs/category_right.h
new file mode 100644
index 0000000..d993b50
--- /dev/null
+++ b/test/Modules/Inputs/category_right.h
@@ -0,0 +1,12 @@
+@__experimental_modules_import category_top;
+
+@interface Foo(Right1)
+-(void)right1;
+@end
+
+@interface Foo(Right2)
+-(void)right2;
+@end
+
+@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
+@end
diff --git a/test/Modules/Inputs/category_top.h b/test/Modules/Inputs/category_top.h
new file mode 100644
index 0000000..c9558b6
--- /dev/null
+++ b/test/Modules/Inputs/category_top.h
@@ -0,0 +1,14 @@
+@interface Foo
+@end
+
+@interface Foo(Top)
+-(void)top;
+@end
+
+@interface Foo(Top2)
+-(void)top2;
+@end
+
+@interface Foo(Top3)
+-(void)top3;
+@end
diff --git a/test/Modules/Inputs/decl.h b/test/Modules/Inputs/decl.h
new file mode 100644
index 0000000..8dbe11e
--- /dev/null
+++ b/test/Modules/Inputs/decl.h
@@ -0,0 +1,2 @@
+@class A;
+typedef struct B B;
diff --git a/test/Modules/Inputs/decl2.h b/test/Modules/Inputs/decl2.h
new file mode 100644
index 0000000..decf6e0
--- /dev/null
+++ b/test/Modules/Inputs/decl2.h
@@ -0,0 +1 @@
+@class A;
diff --git a/test/Modules/Inputs/def-include.h b/test/Modules/Inputs/def-include.h
new file mode 100644
index 0000000..9e0e575
--- /dev/null
+++ b/test/Modules/Inputs/def-include.h
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+struct B {
+ int b1;
+};
diff --git a/test/Modules/Inputs/def.h b/test/Modules/Inputs/def.h
new file mode 100644
index 0000000..6d06b08
--- /dev/null
+++ b/test/Modules/Inputs/def.h
@@ -0,0 +1,11 @@
+#include "def-include.h"
+
+
+
+@interface A {
+@public
+ int ivar;
+}
+@end
+
+
diff --git a/test/Modules/Inputs/diamond.h b/test/Modules/Inputs/diamond.h
new file mode 100644
index 0000000..15b5290
--- /dev/null
+++ b/test/Modules/Inputs/diamond.h
@@ -0,0 +1 @@
+@__experimental_modules_import diamond_bottom;
diff --git a/test/Modules/Inputs/diamond_bottom.h b/test/Modules/Inputs/diamond_bottom.h
index e0b06d6..b45fa93 100644
--- a/test/Modules/Inputs/diamond_bottom.h
+++ b/test/Modules/Inputs/diamond_bottom.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_left;
-__import_module__ diamond_right;
+@__experimental_modules_import diamond_left;
+@__experimental_modules_import diamond_right;
char bottom(char *x);
diff --git a/test/Modules/Inputs/diamond_left.h b/test/Modules/Inputs/diamond_left.h
index 88cbf60..cc406ab 100644
--- a/test/Modules/Inputs/diamond_left.h
+++ b/test/Modules/Inputs/diamond_left.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@__experimental_modules_import diamond_top;
float left(float *);
diff --git a/test/Modules/Inputs/diamond_right.h b/test/Modules/Inputs/diamond_right.h
index 6f8bb82..2ba1d77 100644
--- a/test/Modules/Inputs/diamond_right.h
+++ b/test/Modules/Inputs/diamond_right.h
@@ -1,4 +1,4 @@
-__import_module__ diamond_top;
+@__experimental_modules_import diamond_top;
double right(double *);
diff --git a/test/Modules/Inputs/irgen.h b/test/Modules/Inputs/irgen.h
new file mode 100644
index 0000000..9936bf6
--- /dev/null
+++ b/test/Modules/Inputs/irgen.h
@@ -0,0 +1 @@
+static inline int triple(int x) { return x * 3; }
diff --git a/test/Modules/Inputs/macros.h b/test/Modules/Inputs/macros.h
new file mode 100644
index 0000000..4f53556
--- /dev/null
+++ b/test/Modules/Inputs/macros.h
@@ -0,0 +1,10 @@
+#define MODULE
+#define INTEGER(X) int
+#define FLOAT float
+#define DOUBLE double
+
+#__public_macro INTEGER
+#__private_macro FLOAT
+#__private_macro MODULE
+
+int (INTEGER);
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
new file mode 100644
index 0000000..e8d1f2c
--- /dev/null
+++ b/test/Modules/Inputs/module.map
@@ -0,0 +1,86 @@
+module diamond_top { header "diamond_top.h" }
+module diamond_left {
+ header "diamond_left.h"
+ export diamond_top
+}
+module diamond_right {
+ header "diamond_right.h"
+ export diamond_top
+}
+module diamond_bottom {
+ header "diamond_bottom.h"
+ export *
+}
+module irgen { header "irgen.h" }
+module lookup_left_objc { header "lookup_left.h" }
+module lookup_right_objc { header "lookup_right.h" }
+module lookup_left_cxx { header "lookup_left.hpp" }
+module lookup_right_cxx { header "lookup_right.hpp" }
+module module_private_left { header "module_private_left.h" }
+module module_private_right { header "module_private_right.h" }
+module macros { header "macros.h" }
+module category_top { header "category_top.h" }
+module category_left {
+ header "category_left.h"
+ export category_top
+}
+module category_right {
+ header "category_right.h"
+ export category_top
+}
+module category_bottom {
+ header "category_bottom.h"
+ export category_left
+ export category_right
+}
+module category_other { header "category_other.h" }
+module redeclarations_left { header "redeclarations_left.h" }
+module redeclarations_right { header "redeclarations_right.h" }
+module redecl_namespaces_left { header "redecl_namespaces_left.h" }
+module redecl_namespaces_right { header "redecl_namespaces_right.h" }
+module load_failure { header "load_failure.h" }
+
+module decldef {
+ explicit module Decl { header "decl.h" }
+ explicit module Decl2 { header "decl2.h" }
+ explicit module Def { header "def.h" }
+}
+
+module redecl_merge_top {
+ header "redecl-merge-top.h"
+ explicit module Explicit { header "redecl-merge-top-explicit.h" }
+}
+module redecl_merge_left {
+ header "redecl-merge-left.h"
+ export *
+}
+module redecl_merge_left_left {
+ header "redecl-merge-left-left.h"
+ export *
+}
+module redecl_merge_right {
+ header "redecl-merge-right.h"
+ export *
+}
+module redecl_merge_bottom {
+ header "redecl-merge-bottom.h"
+ export *
+}
+module namespaces_top {
+ header "namespaces-top.h"
+ export *
+}
+module namespaces_left {
+ header "namespaces-left.h"
+ export *
+}
+module namespaces_right {
+ header "namespaces-right.h"
+ export *
+}
+module MethodPoolA {
+ header "MethodPoolA.h"
+}
+module MethodPoolB {
+ header "MethodPoolB.h"
+}
diff --git a/test/Modules/Inputs/module_private_left.h b/test/Modules/Inputs/module_private_left.h
new file mode 100644
index 0000000..ff33999
--- /dev/null
+++ b/test/Modules/Inputs/module_private_left.h
@@ -0,0 +1,26 @@
+__module_private__ struct HiddenStruct;
+
+__module_private__ struct HiddenStruct {
+};
+
+
+int &f0(int);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ void f1(T*);
+
+template<typename T>
+__module_private__ class vector;
+
+template<typename T>
+__module_private__ class vector {
+};
+
+vector<float> vec_float;
+
+typedef __module_private__ int Integer;
+typedef __module_private__ int Integer;
+
diff --git a/test/Modules/Inputs/module_private_right.h b/test/Modules/Inputs/module_private_right.h
new file mode 100644
index 0000000..53efe25
--- /dev/null
+++ b/test/Modules/Inputs/module_private_right.h
@@ -0,0 +1,13 @@
+__module_private__ double &f0(double);
+__module_private__ double &f0(double);
+
+__module_private__ int hidden_var;
+
+inline void test_f0_in_right() {
+ double &dr = f0(hidden_var);
+}
+
+struct VisibleStruct {
+ __module_private__ int field;
+ __module_private__ virtual void setField(int f);
+};
diff --git a/test/Modules/Inputs/namespaces-left.h b/test/Modules/Inputs/namespaces-left.h
new file mode 100644
index 0000000..d253fed
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-left.h
@@ -0,0 +1,53 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N1 { }
+
+namespace N1 {
+ float& f(float);
+}
+
+namespace N2 {
+ float& f(float);
+}
+
+
+
+
+
+namespace N5 {
+ int &f(int);
+}
+
+namespace N6 {
+ int &f(int);
+}
+
+namespace N7 {
+ int &f(int);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ Foo *getFoo();
+}
diff --git a/test/Modules/Inputs/namespaces-right.h b/test/Modules/Inputs/namespaces-right.h
new file mode 100644
index 0000000..7e7286e
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-right.h
@@ -0,0 +1,61 @@
+@__experimental_modules_import namespaces_top;
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 { }
+
+namespace N2 {
+ double& f(double);
+}
+
+namespace N3 {
+ double& f(double);
+}
+
+namespace N5 {
+ double &f(double);
+}
+
+namespace N6 {
+ double &f(double);
+}
+
+namespace N7 {
+ double &f(double);
+}
+
+namespace N8 {
+ int &f(int);
+}
+
+namespace N9 {
+ int &f(int);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+
+
+
+
+
+
+namespace N11 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
+
+namespace N12 {
+ namespace {
+ class Foo;
+ }
+ void consumeFoo(Foo*);
+}
diff --git a/test/Modules/Inputs/namespaces-top.h b/test/Modules/Inputs/namespaces-top.h
new file mode 100644
index 0000000..0c607f5
--- /dev/null
+++ b/test/Modules/Inputs/namespaces-top.h
@@ -0,0 +1,14 @@
+namespace N1 {
+ int& f(int);
+}
+
+namespace N2 {
+ int& f(int);
+}
+
+namespace N3 {
+ int& f(int);
+}
+
+namespace N12 { }
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
new file mode 100644
index 0000000..7462376
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/Umbrella.h
@@ -0,0 +1,4 @@
+int umbrella;
+
+#include "umbrella_sub.h"
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/module.map b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
new file mode 100644
index 0000000..611cf9f
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/module.map
@@ -0,0 +1,3 @@
+module Umbrella {
+ umbrella header "Umbrella.h"
+} \ No newline at end of file
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h b/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
new file mode 100644
index 0000000..9fdccd1
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella/umbrella_sub.h
@@ -0,0 +1,2 @@
+int umbrella_sub;
+
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h b/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
new file mode 100644
index 0000000..36110d8
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella2/Umbrella2.h
@@ -0,0 +1 @@
+int umbrella2;
diff --git a/test/Modules/Inputs/normal-module-map/Umbrella2/module.map b/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
new file mode 100644
index 0000000..1e57704
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/Umbrella2/module.map
@@ -0,0 +1,3 @@
+module Umbrella2 {
+ umbrella header "Umbrella2.h"
+}
diff --git a/test/Modules/Inputs/normal-module-map/a1.h b/test/Modules/Inputs/normal-module-map/a1.h
new file mode 100644
index 0000000..f2d5a49
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/a1.h
@@ -0,0 +1 @@
+int a1;
diff --git a/test/Modules/Inputs/normal-module-map/a2.h b/test/Modules/Inputs/normal-module-map/a2.h
new file mode 100644
index 0000000..5c4e7ff
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/a2.h
@@ -0,0 +1 @@
+int a2;
diff --git a/test/Modules/Inputs/normal-module-map/b1.h b/test/Modules/Inputs/normal-module-map/b1.h
new file mode 100644
index 0000000..2ed1112
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/b1.h
@@ -0,0 +1,2 @@
+int b1;
+
diff --git a/test/Modules/Inputs/normal-module-map/module.map b/test/Modules/Inputs/normal-module-map/module.map
new file mode 100644
index 0000000..e17f44a
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/module.map
@@ -0,0 +1,13 @@
+module libA {
+ module a1 { header "a1.h" }
+ header "a2.h"
+}
+
+module libB {
+ header "b1.h"
+}
+
+module nested_umbrella {
+ umbrella "nested_umbrella"
+ module * { }
+}
diff --git a/test/Modules/Inputs/normal-module-map/nested/module.map b/test/Modules/Inputs/normal-module-map/nested/module.map
new file mode 100644
index 0000000..fd463c2
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/module.map
@@ -0,0 +1,4 @@
+module libNested {
+ header "nested1.h"
+ header "nested2.h"
+} \ No newline at end of file
diff --git a/test/Modules/Inputs/normal-module-map/nested/nested1.h b/test/Modules/Inputs/normal-module-map/nested/nested1.h
new file mode 100644
index 0000000..3790d1a
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/nested1.h
@@ -0,0 +1 @@
+int nested1;
diff --git a/test/Modules/Inputs/normal-module-map/nested/nested2.h b/test/Modules/Inputs/normal-module-map/nested/nested2.h
new file mode 100644
index 0000000..d56d601
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested/nested2.h
@@ -0,0 +1 @@
+int nested2;
diff --git a/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h b/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
new file mode 100644
index 0000000..ab180fe
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested_umbrella/a.h
@@ -0,0 +1,2 @@
+int nested_umbrella_a;
+
diff --git a/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h b/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
new file mode 100644
index 0000000..a903f5d
--- /dev/null
+++ b/test/Modules/Inputs/normal-module-map/nested_umbrella/b.h
@@ -0,0 +1,2 @@
+int nested_umbrella_b;
+
diff --git a/test/Modules/Inputs/redecl-merge-bottom.h b/test/Modules/Inputs/redecl-merge-bottom.h
new file mode 100644
index 0000000..40a9404
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-bottom.h
@@ -0,0 +1,28 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+@class C4;
+@protocol P4;
+@protocol P4;
+@protocol P4;
+@__experimental_modules_import redecl_merge_right;
+
+@class B;
+
+@class A;
+
+@protocol P1;
+
+struct S1;
+struct S3;
+
+void refers_to_C4(C4*);
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
diff --git a/test/Modules/Inputs/redecl-merge-left-left.h b/test/Modules/Inputs/redecl-merge-left-left.h
new file mode 100644
index 0000000..5f48883
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-left-left.h
@@ -0,0 +1,7 @@
+@__experimental_modules_import redecl_merge_left;
+
+@class C4;
+void accept_a_C4(C4*);
+
+@class ClassWithDef;
+
diff --git a/test/Modules/Inputs/redecl-merge-left.h b/test/Modules/Inputs/redecl-merge-left.h
new file mode 100644
index 0000000..b3a7ba8
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-left.h
@@ -0,0 +1,90 @@
+@__experimental_modules_import redecl_merge_top;
+
+@class A;
+
+@class A;
+
+@interface B
++ (B*) create_a_B;
+@end
+
+@class A;
+
+@protocol P1;
+@protocol P2
+- (void)protoMethod2;
+@end
+
+struct S1;
+struct S2 {
+ int field;
+};
+
+struct S1 *produce_S1(void);
+void consume_S2(struct S2*);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+void accept_a_C(C*);
+
+@class C2;
+void accept_a_C2(C2*);
+
+@class C3;
+void accept_a_C3(C3*);
+@class C3;
+
+@class C4;
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P3, P4;
+
+@protocol P3;
+
+struct S3;
+struct S3;
+struct S4 {
+ int field;
+};
+
+struct S3 *produce_S3(void);
+void consume_S4(struct S4*);
+
+typedef int T1;
+typedef float T2;
+
+int func0(int);
+int func1(int);
+int func2(int);
+
+
+
+
+
+
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern float var2;
+
+extern double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+
+template<typename T> class Vector;
+#endif
+
+// Make sure this doesn't introduce an ambiguity-creating 'id' at the
+// top level.
+typedef void funcptr_with_id(int id);
+
diff --git a/test/Modules/Inputs/redecl-merge-right.h b/test/Modules/Inputs/redecl-merge-right.h
new file mode 100644
index 0000000..de7aa08
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-right.h
@@ -0,0 +1,94 @@
+@__experimental_modules_import redecl_merge_top;
+
+@interface Super
+@end
+
+@interface A : Super
+- (Super*)init;
+@end
+
+@class B;
+
+@protocol P1
+- (void)protoMethod1;
+@end
+
+@protocol P1;
+
+@protocol P2;
+
+@protocol P2;
+
+@protocol P2;
+
+struct S1;
+struct S2;
+
+void consume_S1(struct S1*);
+struct S2 *produce_S2(void);
+
+// Test declarations in different modules with no common initial
+// declaration.
+@class C;
+C *get_a_C(void);
+@class C2;
+C2 *get_a_C2(void);
+@class C3;
+C3 *get_a_C3(void);
+
+@class C4;
+@class C4;
+@class C4;
+@class C4;
+C4 *get_a_C4(void);
+
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct;
+
+@protocol P4, P3;
+@protocol P3;
+@protocol P3;
+@protocol P3;
+
+struct S3;
+struct S4;
+
+void consume_S3(struct S3*);
+struct S4 *produce_S4(void);
+
+typedef int T1;
+typedef double T2;
+
+int func0(int);
+int func1(int);
+int func1(int);
+int func1(int);
+int func1(int);
+static int func2(int);
+
+
+
+
+// Spacing matters!
+extern int var1;
+extern int var2;
+
+static double var3;
+
+#ifdef __cplusplus
+template<typename T> class Vector {
+public:
+ void push_back(const T&);
+};
+#endif
+
+int ONE;
+@__experimental_modules_import redecl_merge_top.Explicit;
+const int one = ONE;
+
+@interface ClassWithDef
+- (void)method;
+@end
diff --git a/test/Modules/Inputs/redecl-merge-top-explicit.h b/test/Modules/Inputs/redecl-merge-top-explicit.h
new file mode 100644
index 0000000..e06ff7a
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-top-explicit.h
@@ -0,0 +1,9 @@
+@class Explicit;
+
+int *explicit_func(void);
+
+struct explicit_struct { int member; };
+
+#define ONE 1
+
+typedef struct my_struct_type *my_struct_ref;
diff --git a/test/Modules/Inputs/redecl-merge-top.h b/test/Modules/Inputs/redecl-merge-top.h
new file mode 100644
index 0000000..519254c
--- /dev/null
+++ b/test/Modules/Inputs/redecl-merge-top.h
@@ -0,0 +1,20 @@
+@class A;
+
+@class A;
+
+@class A;
+
+@class B;
+
+@protocol P1;
+
+@protocol P2;
+@protocol P2;
+
+struct S1;
+struct S2;
+struct S2;
+
+#ifdef __cplusplus
+template<typename T> class Vector;
+#endif
diff --git a/test/Modules/Inputs/redecl_namespaces_left.h b/test/Modules/Inputs/redecl_namespaces_left.h
new file mode 100644
index 0000000..49595ea
--- /dev/null
+++ b/test/Modules/Inputs/redecl_namespaces_left.h
@@ -0,0 +1,3 @@
+namespace A {
+ int i;
+}
diff --git a/test/Modules/Inputs/redecl_namespaces_right.h b/test/Modules/Inputs/redecl_namespaces_right.h
new file mode 100644
index 0000000..fdf65ba
--- /dev/null
+++ b/test/Modules/Inputs/redecl_namespaces_right.h
@@ -0,0 +1,3 @@
+namespace A {
+ int j;
+}
diff --git a/test/Modules/Inputs/redeclarations_left.h b/test/Modules/Inputs/redeclarations_left.h
new file mode 100644
index 0000000..4dfbf1d
--- /dev/null
+++ b/test/Modules/Inputs/redeclarations_left.h
@@ -0,0 +1,2 @@
+@class NSObject;
+
diff --git a/test/Modules/Inputs/redeclarations_right.h b/test/Modules/Inputs/redeclarations_right.h
new file mode 100644
index 0000000..d3861fe
--- /dev/null
+++ b/test/Modules/Inputs/redeclarations_right.h
@@ -0,0 +1,2 @@
+@interface NSObject
+@end
diff --git a/test/Modules/Inputs/subdir/module.map b/test/Modules/Inputs/subdir/module.map
new file mode 100644
index 0000000..4cd0215
--- /dev/null
+++ b/test/Modules/Inputs/subdir/module.map
@@ -0,0 +1,3 @@
+module subdir {
+ header "subdir.h"
+}
diff --git a/test/Modules/Inputs/subdir/subdir.h b/test/Modules/Inputs/subdir/subdir.h
new file mode 100644
index 0000000..0fb3d21
--- /dev/null
+++ b/test/Modules/Inputs/subdir/subdir.h
@@ -0,0 +1 @@
+const char *getSubdir();
diff --git a/test/Modules/Inputs/submodules/hash_map.h b/test/Modules/Inputs/submodules/hash_map.h
new file mode 100644
index 0000000..ce85984
--- /dev/null
+++ b/test/Modules/Inputs/submodules/hash_map.h
@@ -0,0 +1,4 @@
+template<typename Key, typename Data> class hash_map { };
+
+#define HAVE_HASH_MAP
+
diff --git a/test/Modules/Inputs/submodules/module.map b/test/Modules/Inputs/submodules/module.map
new file mode 100644
index 0000000..16cedac
--- /dev/null
+++ b/test/Modules/Inputs/submodules/module.map
@@ -0,0 +1,5 @@
+module std {
+ module vector { header "vector.h" }
+ module type_traits { header "type_traits.h" }
+ explicit module hash_map { header "hash_map.h" }
+}
diff --git a/test/Modules/Inputs/submodules/type_traits.h b/test/Modules/Inputs/submodules/type_traits.h
new file mode 100644
index 0000000..4dad090
--- /dev/null
+++ b/test/Modules/Inputs/submodules/type_traits.h
@@ -0,0 +1,12 @@
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+#define HAVE_TYPE_TRAITS
+
diff --git a/test/Modules/Inputs/submodules/vector.h b/test/Modules/Inputs/submodules/vector.h
new file mode 100644
index 0000000..8e1cdc8
--- /dev/null
+++ b/test/Modules/Inputs/submodules/vector.h
@@ -0,0 +1,3 @@
+template<typename T> class vector { };
+
+#define HAVE_VECTOR
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/A_one.h b/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
new file mode 100644
index 0000000..4a2c239
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/A_one.h
@@ -0,0 +1 @@
+int *A1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/A_two.h b/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
new file mode 100644
index 0000000..1b08599
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/A_two.h
@@ -0,0 +1 @@
+unsigned int *A2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/B_one.h b/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
new file mode 100644
index 0000000..0f44a56
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/B_one.h
@@ -0,0 +1 @@
+short *B1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/B_two.h b/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
new file mode 100644
index 0000000..0e51242
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/B_two.h
@@ -0,0 +1 @@
+unsigned short *B2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_one.h b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
new file mode 100644
index 0000000..fb1c7de
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_one.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.One;
+@__experimental_modules_import B.One;
+
+long *C1;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/C_two.h b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
new file mode 100644
index 0000000..050a8f3
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/C_two.h
@@ -0,0 +1,4 @@
+@__experimental_modules_import A.Two;
+@__experimental_modules_import B.Two;
+
+unsigned long *C2;
diff --git a/test/Modules/Inputs/wildcard-submodule-exports/module.map b/test/Modules/Inputs/wildcard-submodule-exports/module.map
new file mode 100644
index 0000000..64b0d89
--- /dev/null
+++ b/test/Modules/Inputs/wildcard-submodule-exports/module.map
@@ -0,0 +1,20 @@
+module A {
+ module One { header "A_one.h" }
+ module Two { header "A_two.h" }
+}
+
+module B {
+ module One { header "B_one.h" }
+ module Two { header "B_two.h" }
+}
+
+module C {
+ module One {
+ header "C_one.h"
+ export A.*
+ }
+ module Two {
+ header "C_two.h"
+ export *
+ }
+}
diff --git a/test/Modules/auto-module-import.c b/test/Modules/auto-module-import.c
deleted file mode 100644
index 0187174..0000000
--- a/test/Modules/auto-module-import.c
+++ /dev/null
@@ -1,13 +0,0 @@
-
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -fauto-module-import -F %S/Inputs -verify %s
-
-#include <DependsOnModule/DependsOnModule.h>
-
-#ifdef MODULE_H_MACRO
-# error MODULE_H_MACRO should have been hidden
-#endif
-
-#ifdef DEPENDS_ON_MODULE
-# error DEPENDS_ON_MODULE should have been hidden
-#endif
diff --git a/test/Modules/auto-module-import.m b/test/Modules/auto-module-import.m
new file mode 100644
index 0000000..fbd0a54
--- /dev/null
+++ b/test/Modules/auto-module-import.m
@@ -0,0 +1,73 @@
+// other file: expected-note{{'no_umbrella_A_private' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}}
+
+#ifdef MODULE_H_MACRO
+# error MODULE_H_MACRO should have been hidden
+#endif
+
+#ifdef DEPENDS_ON_MODULE
+# error DEPENDS_ON_MODULE should have been hidden
+#endif
+
+Module *mod; // expected-error{{unknown type name 'Module'}}
+
+#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}}
+Module *mod2;
+
+int getDependsOther() { return depends_on_module_other; }
+
+void testSubframeworkOther() {
+ double *sfo1 = sub_framework_other; // expected-error{{use of undeclared identifier 'sub_framework_other'}}
+}
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}}
+int getNoUmbrellaA() { return no_umbrella_A; }
+
+// Test umbrella-less submodule includes
+#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}}
+int getNoUmbrellaC() { return no_umbrella_C; }
+
+// Test header cross-subframework include pattern.
+#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}}
+
+void testSubframeworkOtherAgain() {
+ double *sfo1 = sub_framework_other;
+}
+
+void testModuleSubFramework() {
+ char *msf = module_subframework;
+}
+
+#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}}
+
+void testModuleSubFrameworkAgain() {
+ char *msf = module_subframework;
+}
+
+// Test inclusion of private headers.
+#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}}
+
+int getDependsOnModulePrivate() { return depends_on_module_private; }
+
+#include <Module/ModulePrivate.h> // includes the header
+
+int getModulePrivate() { return module_private; }
+
+#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}}
+int getNoUmbrellaAPrivate() { return no_umbrella_A_private; }
+
+int getNoUmbrellaBPrivateFail() { return no_umbrella_B_private; } // expected-error{{use of undeclared identifier 'no_umbrella_B_private'; did you mean 'no_umbrella_A_private'?}}
+
+// Test inclusion of headers that are under an umbrella directory but
+// not actually part of the module.
+#include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \
+ // expected-warning{{missing submodule 'Module.NotInModule'}}
+
+int getNotInModule() {
+ return not_in_module;
+}
diff --git a/test/Modules/compiler_builtins.m b/test/Modules/compiler_builtins.m
new file mode 100644
index 0000000..de6f57b
--- /dev/null
+++ b/test/Modules/compiler_builtins.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -fmodules -fmodule-cache-path %t -D__need_wint_t %s -Xclang -verify
+
+#ifdef __SSE__
+@__experimental_modules_import _Builtin_intrinsics.intel.sse;
+#endif
+
+#ifdef __AVX2__
+@__experimental_modules_import _Builtin_intrinsics.intel.avx2;
+#endif
diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m
new file mode 100644
index 0000000..1752cd3
--- /dev/null
+++ b/test/Modules/cstd.m
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -fmodules -fmodule-cache-path %t -D__need_wint_t -Werror=implicit-function-declaration %s
+
+// Supplied by compiler, but referenced from the "/usr/include" module map.
+@__experimental_modules_import cstd.float_constants;
+
+float getFltMax() { return FLT_MAX; }
+
+// Supplied by the "/usr/include" module map.
+@__experimental_modules_import cstd.stdio;
+
+void test_fprintf(FILE *file) {
+ fprintf(file, "Hello, modules\n");
+}
+
+// Supplied by compiler, which forwards to the the "/usr/include" version.
+@__experimental_modules_import cstd.stdint;
+
+my_awesome_nonstandard_integer_type value;
+
+// Supplied by the compiler; that version wins.
+@__experimental_modules_import cstd.stdbool;
+
+#ifndef bool
+# error "bool was not defined!"
+#endif
+
+
+
diff --git a/test/Modules/cycles.c b/test/Modules/cycles.c
index 8e3e9c6..256f118 100644
--- a/test/Modules/cycles.c
+++ b/test/Modules/cycles.c
@@ -1,12 +1,12 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
-
-__import_module__ MutuallyRecursive1;
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -F %S/Inputs %s 2>&1 | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
+@__experimental_modules_import MutuallyRecursive1;
// FIXME: Lots of redundant diagnostics here, because the preprocessor
// can't currently tell the parser not to try to load the module again.
-// CHECK: MutuallyRecursive2.h:3:19: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
-// CHECK: MutuallyRecursive1.h:2:19: fatal error: could not build module 'MutuallyRecursive2'
-// CHECK: cycles.c:4:19: fatal error: could not build module 'MutuallyRecursive1'
+// CHECK: MutuallyRecursive2.h:3:32: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1
+// CHECK: MutuallyRecursive1.h:2:32: fatal error: could not build module 'MutuallyRecursive2'
+// CHECK: cycles.c:4:32: fatal error: could not build module 'MutuallyRecursive1'
diff --git a/test/Modules/decldef.mm b/test/Modules/decldef.mm
new file mode 100644
index 0000000..64a66d5
--- /dev/null
+++ b/test/Modules/decldef.mm
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -I %S/Inputs -fmodule-cache-path %t %s -verify
+
+
+// in other file: expected-note{{previous definition is here}}
+
+
+
+
+
+// in other file: expected-note{{previous definition is here}}
+
+@__experimental_modules_import decldef;
+A *a1; // expected-error{{unknown type name 'A'}}
+B *b1; // expected-error{{unknown type name 'B'}}
+@__experimental_modules_import decldef.Decl;
+
+A *a2;
+B *b;
+
+void testA(A *a) {
+ a->ivar = 17; // expected-error{{definition of 'A' must be imported before it is required}}
+}
+
+void testB() {
+ B b; // expected-error{{definition of 'B' must be imported before it is required}}
+ B b2; // Note: the reundant error was silenced.
+}
diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c
new file mode 100644
index 0000000..4397c19
--- /dev/null
+++ b/test/Modules/diamond-pch.c
@@ -0,0 +1,28 @@
+
+
+
+// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
+
+void test_diamond(int i, float f, double d, char c) {
+ top(&i);
+ left(&f);
+ right(&d);
+ bottom(&c);
+ bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}}
+
+ // Names in multiple places in the diamond.
+ top_left(&c);
+
+ left_and_right(&i);
+ struct left_and_right lr;
+ lr.left = 17;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodule-cache-path %t -o %t.pch %S/Inputs/diamond.h
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -include-pch %t.pch %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c
index 482836c..076eec4 100644
--- a/test/Modules/diamond.c
+++ b/test/Modules/diamond.c
@@ -3,7 +3,7 @@
// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}}
-__import_module__ diamond_bottom;
+@__experimental_modules_import diamond_bottom;
void test_diamond(int i, float f, double d, char c) {
top(&i);
@@ -20,8 +20,10 @@ void test_diamond(int i, float f, double d, char c) {
lr.left = 17;
}
-// RUN: %clang_cc1 -emit-module -o %T/diamond_top.pcm %S/Inputs/diamond_top.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_left.pcm %S/Inputs/diamond_left.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_right.pcm %S/Inputs/diamond_right.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash -emit-module -o %T/diamond_bottom.pcm %S/Inputs/diamond_bottom.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_top %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=diamond_bottom %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/header-import.m b/test/Modules/header-import.m
index 9996dc7..5444854 100644
--- a/test/Modules/header-import.m
+++ b/test/Modules/header-import.m
@@ -1,7 +1,7 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
#import "point.h"
-__import_module__ Module;
+@__experimental_modules_import Module;
#import "point.h"
diff --git a/test/Modules/inferred-submodules.m b/test/Modules/inferred-submodules.m
new file mode 100644
index 0000000..bee1cec
--- /dev/null
+++ b/test/Modules/inferred-submodules.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import Module.Sub;
+
+void test_Module_Sub() {
+ int *ip = Module_Sub;
+}
+
+@__experimental_modules_import Module.Buried.Treasure;
+
+void dig() {
+ unsigned *up = Buried_Treasure;
+}
+
diff --git a/test/Modules/irgen.c b/test/Modules/irgen.c
index 0debf05..4a080db 100644
--- a/test/Modules/irgen.c
+++ b/test/Modules/irgen.c
@@ -1,10 +1,9 @@
-// RUN: %clang_cc1 -emit-module -triple x86_64-apple-darwin10 -o %t/module.pcm -DBUILD_MODULE %s
-// RUN: %clang_cc1 -fmodule-cache-path %t -triple x86_64-apple-darwin10 -fdisable-module-hash -emit-llvm -o - %s | FileCheck %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=irgen -triple x86_64-apple-darwin10 %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// FIXME: When we have a syntax for modules in C, use that.
-#ifdef BUILD_MODULE
-static inline int triple(int x) { return x * 3; }
-#else
-__import_module__ module;
+@__experimental_modules_import irgen;
// CHECK: define void @triple_value
void triple_value(int *px) {
@@ -12,4 +11,3 @@ void triple_value(int *px) {
}
// CHECK: define internal i32 @triple(i32
-#endif
diff --git a/test/Modules/load_failure.c b/test/Modules/load_failure.c
index d16bba7..3a96301 100644
--- a/test/Modules/load_failure.c
+++ b/test/Modules/load_failure.c
@@ -1,19 +1,21 @@
#ifdef NONEXISTENT
-__import_module__ load_nonexistent;
+@__experimental_modules_import load_nonexistent;
#endif
#ifdef FAILURE
-__import_module__ load_failure;
+@__experimental_modules_import load_failure;
#endif
-// RUN: %clang_cc1 -x c++ -emit-module -o %T/load_failure.pcm %S/Inputs/load_failure.h
-// RUN: %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
-// CHECK-NONEXISTENT: load_failure.c:2:19: fatal error: module 'load_nonexistent' not found
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fdisable-module-hash -emit-module -fmodule-name=load_failure %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DNONEXISTENT 2>&1 | FileCheck -check-prefix=CHECK-NONEXISTENT %s
+// CHECK-NONEXISTENT: load_failure.c:2:32: fatal error: module 'load_nonexistent' not found
-// RUN: not %clang_cc1 -fmodule-cache-path %T -fdisable-module-hash %s -DFAILURE 2> %t
-// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -fdisable-module-hash %s -DFAILURE 2> %t.out
+// RUN: FileCheck -check-prefix=CHECK-FAILURE %s < %t.out
// FIXME: Clean up diagnostic text below and give it a location
// CHECK-FAILURE: error: C99 was disabled in PCH file but is currently enabled
+// FIXME: When we have a syntax for modules in C, use that.
diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp
index d3245f2..9839035 100644
--- a/test/Modules/lookup.cpp
+++ b/test/Modules/lookup.cpp
@@ -1,7 +1,8 @@
-#define import __import_module__
+#define import @__experimental_modules_import
import lookup_left_cxx;
-#define IMPORT(X) __import_module__ X
+#undef import
+#define IMPORT(X) @__experimental_modules_import X
IMPORT(lookup_right_cxx);
void test(int i, float f) {
@@ -14,10 +15,18 @@ void test(int i, float f) {
::f0(&f);
}
-// RUN: %clang_cc1 -emit-module -x c++ -verify -o %T/lookup_left_cxx.pcm %S/Inputs/lookup_left.hpp
-// RUN: %clang_cc1 -emit-module -x c++ -o %T/lookup_right_cxx.pcm %S/Inputs/lookup_right.hpp
-// RUN: %clang_cc1 -x c++ -fmodule-cache-path %T -fdisable-module-hash %s -verify
-// RUN: %clang_cc1 -ast-print -x c++ -fmodule-cache-path %T -fdisable-module-hash %s | FileCheck -check-prefix=CHECK-PRINT %s
+int import;
+
+void f() {
+ int import;
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_left_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -emit-module -fmodule-cache-path %t -fmodule-name=lookup_right_cxx %S/Inputs/module.map -verify
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c++ -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
+// FIXME: When we have a syntax for modules in C++, use that.
// CHECK-PRINT: int *f0(int *);
// CHECK-PRINT: float *f0(float *);
diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m
index d45f936..c82503f 100644
--- a/test/Modules/lookup.m
+++ b/test/Modules/lookup.m
@@ -1,17 +1,18 @@
// lookup_left.h: expected-note{{using}}
// lookup_right.h: expected-note{{also found}}
-__import_module__ lookup_left_objc;
-__import_module__ lookup_right_objc;
+@__experimental_modules_import lookup_left_objc;
+@__experimental_modules_import lookup_right_objc;
void test(id x) {
[x method]; // expected-warning{{multiple methods named 'method' found}}
}
-// RUN: %clang_cc1 -emit-module -x objective-c -o %T/lookup_left_objc.pcm %S/Inputs/lookup_left.h
-// RUN: %clang_cc1 -emit-module -x objective-c -o %T/lookup_right_objc.pcm %S/Inputs/lookup_right.h
-// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %T -fdisable-module-hash -verify %s
-// RUN: %clang_cc1 -ast-print -x objective-c -fmodule-cache-path %T -fdisable-module-hash %s | FileCheck -check-prefix=CHECK-PRINT %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -verify %s
+// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix=CHECK-PRINT %s
// CHECK-PRINT: - (int) method;
// CHECK-PRINT: - (double) method
diff --git a/test/Modules/macros.c b/test/Modules/macros.c
index 899c19b..83e1c66 100644
--- a/test/Modules/macros.c
+++ b/test/Modules/macros.c
@@ -1,20 +1,10 @@
-// RUN: %clang_cc1 -emit-module -o %t/macros.pcm -DMODULE %s
-// RUN: %clang_cc1 -verify -fmodule-cache-path %t -fdisable-module-hash %s
-// RUN: %clang_cc1 -E -fmodule-cache-path %t -fdisable-module-hash %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s
+// RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
+// FIXME: When we have a syntax for modules in C, use that.
-#if defined(MODULE)
-#define INTEGER(X) int
-#define FLOAT float
-#define DOUBLE double
-
-#__export_macro__ INTEGER
-#__export_macro__ DOUBLE
-
-int (INTEGER);
-
-#else
-
-__import_module__ macros;
+@__experimental_modules_import macros;
#ifndef INTEGER
# error INTEGER macro should be visible
@@ -32,10 +22,9 @@ __import_module__ macros;
double d;
DOUBLE *dp = &d;
-#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
+#__public_macro WIBBLE // expected-error{{no macro named 'WIBBLE'}}
void f() {
// CHECK-PREPROCESSED: int i = INTEGER;
int i = INTEGER; // the value was exported, the macro was not.
}
-#endif
diff --git a/test/Modules/method_pool.m b/test/Modules/method_pool.m
new file mode 100644
index 0000000..25582ca
--- /dev/null
+++ b/test/Modules/method_pool.m
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodule-cache-path %t -fmodules -I %S/Inputs %s -verify
+
+@__experimental_modules_import MethodPoolA;
+
+
+// in other file: // expected-note{{using}}
+
+
+
+
+// in other file: expected-note{{also found}}
+
+void testMethod1(id object) {
+ [object method1];
+}
+
+void testMethod2(id object) {
+ [object method2:1];
+}
+
+@__experimental_modules_import MethodPoolB;
+
+void testMethod1Again(id object) {
+ [object method1];
+}
+
+void testMethod2Again(id object) {
+ [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
+}
diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp
index 7bd2a20..246dcaf 100644
--- a/test/Modules/module-private.cpp
+++ b/test/Modules/module-private.cpp
@@ -1,54 +1,11 @@
-// RUN: mkdir -p %t
-// RUN: %clang_cc1 -x c++ -emit-module -o %t/left.pcm %s -D MODULE_LEFT
-// RUN: %clang_cc1 -x c++ -emit-module -o %t/right.pcm %s -D MODULE_RIGHT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -fmodule-name=module_private_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
-#if defined(MODULE_LEFT)
-
-__module_private__ struct HiddenStruct;
-
-struct HiddenStruct {
-};
-
-
-int &f0(int);
-
-template<typename T>
-__module_private__ void f1(T*);
-
-template<typename T>
-void f1(T*);
-
-template<typename T>
-__module_private__ class vector;
-
-template<typename T>
-class vector {
-};
-
-vector<float> vec_float;
-
-typedef __module_private__ int Integer;
-typedef int Integer;
-
-#elif defined(MODULE_RIGHT)
-__module_private__ double &f0(double);
-double &f0(double);
-
-__module_private__ int hidden_var;
-
-inline void test_f0_in_right() {
- double &dr = f0(hidden_var);
-}
-
-struct VisibleStruct {
- __module_private__ int field;
- __module_private__ virtual void setField(int f);
-};
-
-#else
-__import_module__ left;
-__import_module__ right;
+@__experimental_modules_import module_private_left;
+@__experimental_modules_import module_private_right;
void test() {
int &ir = f0(1.0); // okay: f0() from 'right' is not visible
@@ -75,28 +32,28 @@ int test_broken() {
// Check for private redeclarations of public entities.
template<typename T>
-class public_class_template; // expected-note{{previous declaration is here}}
+class public_class_template;
template<typename T>
-__module_private__ class public_class_template; // expected-error{{__module_private__ declaration of 'public_class_template' follows public declaration}}
+__module_private__ class public_class_template;
-typedef int public_typedef; // expected-note{{previous declaration is here}}
-typedef __module_private__ int public_typedef; // expected-error{{__module_private__ declaration of 'public_typedef' follows public declaration}}
+typedef int public_typedef;
+typedef __module_private__ int public_typedef;
-extern int public_var; // expected-note{{previous declaration is here}}
-extern __module_private__ int public_var; // expected-error{{__module_private__ declaration of 'public_var' follows public declaration}}
+extern int public_var;
+extern __module_private__ int public_var;
-void public_func(); // expected-note{{previous declaration is here}}
-__module_private__ void public_func(); // expected-error{{__module_private__ declaration of 'public_func' follows public declaration}}
+void public_func();
+__module_private__ void public_func();
template<typename T>
-void public_func_template(); // expected-note{{previous declaration is here}}
+void public_func_template();
template<typename T>
-__module_private__ void public_func_template(); // expected-error{{__module_private__ declaration of 'public_func_template' follows public declaration}}
+__module_private__ void public_func_template();
-struct public_struct; // expected-note{{previous declaration is here}}
-__module_private__ struct public_struct; // expected-error{{__module_private__ declaration of 'public_struct' follows public declaration}}
+struct public_struct;
+__module_private__ struct public_struct;
// Check for attempts to make specializations private
template<> __module_private__ void public_func_template<int>(); // expected-error{{template specialization cannot be declared __module_private__}}
@@ -137,4 +94,3 @@ struct LikeVisibleStruct {
};
int check_struct_size[sizeof(VisibleStruct) == sizeof(LikeVisibleStruct)? 1 : -1];
-#endif
diff --git a/test/Modules/namespaces.cpp b/test/Modules/namespaces.cpp
new file mode 100644
index 0000000..19e0c5a
--- /dev/null
+++ b/test/Modules/namespaces.cpp
@@ -0,0 +1,64 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
+
+// Importing modules which add declarations to a pre-existing non-imported
+// overload set does not currently work.
+// XFAIL: *
+
+namespace N6 {
+ char &f(char);
+}
+
+namespace N8 { }
+
+@__experimental_modules_import namespaces_left;
+@__experimental_modules_import namespaces_right;
+
+void test() {
+ int &ir1 = N1::f(1);
+ int &ir2 = N2::f(1);
+ int &ir3 = N3::f(1);
+ float &fr1 = N1::f(1.0f);
+ float &fr2 = N2::f(1.0f);
+ double &dr1 = N2::f(1.0);
+ double &dr2 = N3::f(1.0);
+}
+
+// Test namespaces merged without a common first declaration.
+namespace N5 {
+ char &f(char);
+}
+
+namespace N10 {
+ int &f(int);
+}
+
+void testMerged() {
+ int &ir1 = N5::f(17);
+ int &ir2 = N6::f(17);
+ int &ir3 = N7::f(17);
+ double &fr1 = N5::f(1.0);
+ double &fr2 = N6::f(1.0);
+ double &fr3 = N7::f(1.0);
+ char &cr1 = N5::f('a');
+ char &cr2 = N6::f('b');
+}
+
+// Test merging of declarations within namespaces that themselves were
+// merged without a common first declaration.
+void testMergedMerged() {
+ int &ir1 = N8::f(17);
+ int &ir2 = N9::f(17);
+ int &ir3 = N10::f(17);
+}
+
+// Test merging when using anonymous namespaces, which does not
+// actually perform any merging.
+// other file: expected-note{{passing argument to parameter here}}
+void testAnonymousNotMerged() {
+ N11::consumeFoo(N11::getFoo()); // expected-error{{cannot initialize a parameter of type 'N11::<anonymous>::Foo *' with an rvalue of type 'N11::<anonymous>::Foo *'}}
+ N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}}
+}
+
+
+// other file: expected-note{{passing argument to parameter here}}
diff --git a/test/Modules/normal-module-map.cpp b/test/Modules/normal-module-map.cpp
new file mode 100644
index 0000000..7cd4482
--- /dev/null
+++ b/test/Modules/normal-module-map.cpp
@@ -0,0 +1,35 @@
+// Note: inside the module. expected-note{{'nested_umbrella_a' declared here}}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodule-cache-path %t -fmodules -I %S/Inputs/normal-module-map %s -verify
+#include "Umbrella/umbrella_sub.h"
+
+int getUmbrella() {
+ return umbrella + umbrella_sub;
+}
+
+@__experimental_modules_import Umbrella2;
+
+#include "a1.h"
+#include "b1.h"
+#include "nested/nested2.h"
+
+int test() {
+ return a1 + b1 + nested2;
+}
+
+@__experimental_modules_import nested_umbrella.a;
+
+int testNestedUmbrellaA() {
+ return nested_umbrella_a;
+}
+
+int testNestedUmbrellaBFail() {
+ return nested_umbrella_b; // expected-error{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}}
+}
+
+@__experimental_modules_import nested_umbrella.b;
+
+int testNestedUmbrellaB() {
+ return nested_umbrella_b;
+}
diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m
index 87aaa5c..340f279 100644
--- a/test/Modules/objc-categories.m
+++ b/test/Modules/objc-categories.m
@@ -1,77 +1,20 @@
-// RUN: mkdir -p %t
-// RUN: %clang_cc1 -emit-module -o %t/diamond_top.pcm %s -D MODULE_TOP
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_left.pcm %s -D MODULE_LEFT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_right.pcm %s -D MODULE_RIGHT
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash -emit-module -o %t/diamond_bottom.pcm %s -D MODULE_BOTTOM
-// RUN: %clang_cc1 -fmodule-cache-path %t -fdisable-module-hash %s -verify
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_top -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_left -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_right -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_bottom -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -x objective-c -fmodule-name=category_other -emit-module %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
-/*============================================================================*/
-#ifdef MODULE_TOP
+@__experimental_modules_import category_bottom;
-@interface Foo
-@end
-
-@interface Foo(Top)
--(void)top;
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_LEFT)
-__import_module__ diamond_top;
-@interface Foo(Left)
--(void)left;
-@end
-
-@interface LeftFoo
--(void)left;
-@end
-@interface Foo(Duplicate) // expected-note {{previous definition}}
-@end
-
-@interface Foo(Duplicate)
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_RIGHT)
-
-__import_module__ diamond_top;
-
-@interface Foo(Right1)
--(void)right1;
-@end
-
-@interface Foo(Right2)
--(void)right2;
-@end
-
-@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}}
-@end
-
-/*============================================================================*/
-#elif defined(MODULE_BOTTOM)
-
-__import_module__ diamond_left;
-
-@interface Foo(Bottom)
--(void)bottom;
-@end
-
-__import_module__ diamond_right;
-
-@interface LeftFoo(Bottom)
--(void)bottom;
-@end
-
-/*============================================================================*/
-#else
-
-__import_module__ diamond_bottom;
+// in category_left.h: expected-note {{previous definition}}
@interface Foo(Source)
--(void)source;
+-(void)source;
@end
void test(Foo *foo, LeftFoo *leftFoo) {
@@ -81,9 +24,17 @@ void test(Foo *foo, LeftFoo *leftFoo) {
[foo right1];
[foo right2];
[foo top];
+ [foo top2];
+ [foo top3];
[leftFoo left];
[leftFoo bottom];
}
-#endif
+// Load another module that also adds categories to Foo, verify that
+// we see those categories.
+@__experimental_modules_import category_other;
+
+void test_other(Foo *foo) {
+ [foo other];
+}
diff --git a/test/Modules/on-demand-build-warnings.m b/test/Modules/on-demand-build-warnings.m
index aa122db..24975c0 100644
--- a/test/Modules/on-demand-build-warnings.m
+++ b/test/Modules/on-demand-build-warnings.m
@@ -1,5 +1,5 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Wmodule-build -fmodule-cache-path %t -F %S/Inputs -verify %s
-__import_module__ Module; // expected-warning{{building module 'Module' from source}}
+@__experimental_modules_import Module; // expected-warning{{building module 'Module' from source}}
diff --git a/test/Modules/on-demand-build.m b/test/Modules/on-demand-build.m
index 649caa8..cf1ae99 100644
--- a/test/Modules/on-demand-build.m
+++ b/test/Modules/on-demand-build.m
@@ -1,11 +1,15 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -verify %s
-// RUN: %clang_cc1 -fno-objc-infer-related-result-type -Werror -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -x objective-c++ -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fno-objc-infer-related-result-type -Werror -Wno-error=incomplete-umbrella -fmodule-cache-path %t -F %S/Inputs -I %S/Inputs -verify %s
#define FOO
-__import_module__ Module;
+@__experimental_modules_import Module;
@interface OtherClass
@end
+
+
+
+
// in module: expected-note{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}}
void test_getModuleVersion() {
const char *version = getModuleVersion();
@@ -14,4 +18,10 @@ void test_getModuleVersion() {
OtherClass *other = [Module alloc]; // expected-error{{init}}
}
+#ifdef MODULE_SUBFRAMEWORK_H
+# error MODULE_SUBFRAMEWORK_H should be hidden
+#endif
+
+@__experimental_modules_import subdir;
+const char *getSubdirTest() { return getSubdir(); }
diff --git a/test/Modules/on-demand-macros.m b/test/Modules/on-demand-macros.m
index 96abb23..2b8c545 100644
--- a/test/Modules/on-demand-macros.m
+++ b/test/Modules/on-demand-macros.m
@@ -1,8 +1,8 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
-// RUN: %clang_cc1 -fmodule-cache-path %t -F %S/Inputs -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -DFOO_RETURNS_INT_PTR -verify %s
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -F %S/Inputs -verify %s
-__import_module__ CmdLine;
+@__experimental_modules_import CmdLine;
void test() {
#ifdef FOO_RETURNS_INT_PTR
diff --git a/test/Modules/redecl-merge.m b/test/Modules/redecl-merge.m
new file mode 100644
index 0000000..d7930ac
--- /dev/null
+++ b/test/Modules/redecl-merge.m
@@ -0,0 +1,158 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify -Wno-objc-root-class
+@class C2;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_left;
+typedef struct my_struct_type *my_struct_ref;
+@protocol P4;
+@class C3;
+@class C3;
+@__experimental_modules_import redecl_merge_right;
+
+@implementation A
+- (Super*)init { return self; }
+@end
+
+void f(A *a) {
+ [a init];
+}
+
+@class A;
+
+B *f1() {
+ return [B create_a_B];
+}
+
+@class B;
+
+void testProtoMerge(id<P1> p1, id<P2> p2) {
+ [p1 protoMethod1];
+ [p2 protoMethod2];
+}
+
+struct S1 {
+ int s1_field;
+};
+
+struct S3 {
+ int s3_field;
+};
+
+void testTagMerge() {
+ consume_S1(produce_S1());
+ struct S2 s2;
+ s2.field = 0;
+ consume_S2(produce_S2());
+ struct S1 s1;
+ s1.s1_field = 0;
+ consume_S3(produce_S3());
+ struct S4 s4;
+ s4.field = 0;
+ consume_S4(produce_S4());
+ struct S3 s3;
+ s3.s3_field = 0;
+}
+
+void testTypedefMerge(int i, double d) {
+ T1 *ip = &i;
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // FIXME: Typedefs aren't actually merged in the sense of other merges, because
+ // we should only merge them when the types are identical.
+ // in other file: expected-note{{candidate found by name lookup is 'T2'}}
+ // in other file: expected-note{{candidate function}}
+ T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}}
+}
+
+void testFuncMerge(int i) {
+ func0(i);
+ // in other file: expected-note{{candidate function}}
+ func1(i);
+ func2(i); // expected-error{{call to 'func2' is ambiguous}}
+}
+
+void testVarMerge(int i) {
+ var1 = i;
+ // in other files: expected-note 2{{candidate found by name lookup is 'var2'}}
+ var2 = i; // expected-error{{reference to 'var2' is ambiguous}}
+ // in other files: expected-note 2{{candidate found by name lookup is 'var3'}}
+ var3 = i; // expected-error{{reference to 'var3' is ambiguous}}
+}
+
+// Test redeclarations of entities in explicit submodules, to make
+// sure we're maintaining the declaration chains even when normal name
+// lookup can't see what we're looking for.
+void testExplicit() {
+ Explicit *e;
+ int *(*fp)(void) = &explicit_func;
+ int *ip = explicit_func();
+
+ // FIXME: Should complain about definition not having been imported.
+ struct explicit_struct es = { 0 };
+}
+
+// Test resolution of declarations from multiple modules with no
+// common original declaration.
+void test_C(C *c) {
+ c = get_a_C();
+ accept_a_C(c);
+}
+
+void test_C2(C2 *c2) {
+ c2 = get_a_C2();
+ accept_a_C2(c2);
+}
+
+void test_C3(C3 *c3) {
+ c3 = get_a_C3();
+ accept_a_C3(c3);
+}
+
+C4 *global_C4;
+
+ClassWithDef *cwd1;
+
+@__experimental_modules_import redecl_merge_left_left;
+
+void test_C4a(C4 *c4) {
+ global_C4 = c4 = get_a_C4();
+ accept_a_C4(c4);
+}
+
+void test_ClassWithDef(ClassWithDef *cwd) {
+ [cwd method];
+}
+
+@__experimental_modules_import redecl_merge_bottom;
+
+void test_C4b() {
+ if (&refers_to_C4) {
+ }
+}
+
+@implementation B
++ (B*)create_a_B { return 0; }
+@end
+
+void g(A *a) {
+ [a init];
+}
+
+@protocol P3
+- (void)p3_method;
+@end
+
+id<P4> p4;
+id<P3> p3;
+
+#ifdef __cplusplus
+void testVector() {
+ Vector<int> vec_int;
+ vec_int.push_back(0);
+}
+#endif
+
+// Make sure we don't get conflicts with 'id'.
+funcptr_with_id fid;
+id id_global;
diff --git a/test/Modules/redecl-namespaces.mm b/test/Modules/redecl-namespaces.mm
new file mode 100644
index 0000000..e338821
--- /dev/null
+++ b/test/Modules/redecl-namespaces.mm
@@ -0,0 +1,13 @@
+@__experimental_modules_import redecl_namespaces_left;
+@__experimental_modules_import redecl_namespaces_right;
+
+void test() {
+ A::i;
+ A::j;
+ A::k; // expected-error {{no member named 'k' in namespace 'A'}}
+}
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c++ -fmodule-cache-path %t -emit-module -fmodule-name=redecl_namespaces_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -w %s -verify
diff --git a/test/Modules/redeclarations.m b/test/Modules/redeclarations.m
new file mode 100644
index 0000000..3f3e695
--- /dev/null
+++ b/test/Modules/redeclarations.m
@@ -0,0 +1,11 @@
+@__experimental_modules_import redeclarations_left;
+@__experimental_modules_import redeclarations_right;
+
+@interface MyObject : NSObject
+@end
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_left %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -x objective-c -fmodule-cache-path %t -emit-module -fmodule-name=redeclarations_right %S/Inputs/module.map
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t %s -verify
+
diff --git a/test/Modules/requires.m b/test/Modules/requires.m
new file mode 100644
index 0000000..ce2537c
--- /dev/null
+++ b/test/Modules/requires.m
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+@__experimental_modules_import DependsOnModule.CXX; // expected-error{{module 'DependsOnModule.CXX' requires feature 'cplusplus'}}
+
diff --git a/test/Modules/subframeworks.m b/test/Modules/subframeworks.m
new file mode 100644
index 0000000..09298c4
--- /dev/null
+++ b/test/Modules/subframeworks.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+// RUN: %clang_cc1 -x objective-c++ -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify
+
+@__experimental_modules_import DependsOnModule;
+
+void testSubFramework() {
+ float *sf1 = sub_framework; // expected-error{{use of undeclared identifier 'sub_framework'}}
+}
+
+@__experimental_modules_import DependsOnModule.SubFramework;
+
+void testSubFrameworkAgain() {
+ float *sf2 = sub_framework;
+ double *sfo1 = sub_framework_other;
+}
+
+#ifdef __cplusplus
+@__experimental_modules_import DependsOnModule.CXX;
+
+CXXOnly cxxonly;
+#endif
diff --git a/test/Modules/submodules-preprocess.cpp b/test/Modules/submodules-preprocess.cpp
new file mode 100644
index 0000000..8d6c2cd
--- /dev/null
+++ b/test/Modules/submodules-preprocess.cpp
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -x objective-c++ -Eonly -fmodule-cache-path %t -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifdef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is available (but shouldn't be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifdef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is available (but shouldn't be)
+#endif
+
+@__experimental_modules_import std.hash_map;
+
+#ifndef HAVE_VECTOR
+# error HAVE_VECTOR macro is not available (but should be)
+#endif
+
+#ifndef HAVE_TYPE_TRAITS
+# error HAVE_TYPE_TRAITS_MAP macro is not available (but should be)
+#endif
+
+#ifndef HAVE_HASH_MAP
+# error HAVE_HASH_MAP macro is not available (but should be)
+#endif
diff --git a/test/Modules/submodules.cpp b/test/Modules/submodules.cpp
new file mode 100644
index 0000000..60d5ae0
--- /dev/null
+++ b/test/Modules/submodules.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/submodules %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import std.vector;
+
+vector<int> vi;
+
+// Note: remove_reference is not visible yet.
+remove_reference<int&>::type *int_ptr = 0; // expected-error{{unknown type name 'remove_reference'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.typetraits; // expected-error{{no submodule named 'typetraits' in module 'std'; did you mean 'type_traits'?}}
+
+vector<float> vf;
+remove_reference<int&>::type *int_ptr2 = 0;
+
+@__experimental_modules_import std.vector.compare; // expected-error{{no submodule named 'compare' in module 'std.vector'}}
+
+@__experimental_modules_import std; // import everything in 'std'
+
+// hash_map still isn't available.
+hash_map<int, float> ints_to_floats; // expected-error{{unknown type name 'hash_map'}} \
+// expected-error{{expected unqualified-id}}
+
+@__experimental_modules_import std.hash_map;
+
+hash_map<int, float> ints_to_floats2;
+
diff --git a/test/Modules/submodules.m b/test/Modules/submodules.m
new file mode 100644
index 0000000..e014bea
--- /dev/null
+++ b/test/Modules/submodules.m
@@ -0,0 +1,11 @@
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Wauto-import -fmodule-cache-path %t -fmodules -F %S/Inputs %s -verify
+
+// Note: transitively imports Module.Sub2.
+@__experimental_modules_import Module.Sub;
+
+int getValue() {
+ return *Module_Sub + *Module_Sub2;
+}
+
diff --git a/test/Modules/wildcard-submodule-exports.cpp b/test/Modules/wildcard-submodule-exports.cpp
new file mode 100644
index 0000000..6b4f02c
--- /dev/null
+++ b/test/Modules/wildcard-submodule-exports.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c++ -fmodule-cache-path %t -fmodules -I %S/Inputs/wildcard-submodule-exports %s -verify
+// FIXME: When we have a syntax for modules in C++, use that.
+
+@__experimental_modules_import C.One;
+
+void test_C_One() {
+ int *A1_ptr = A1;
+ long *C1_ptr = C1;
+ (void)B1; // expected-error{{use of undeclared identifier 'B1'}}
+}
+
+@__experimental_modules_import C.Two;
+
+void test_C_Two() {
+ unsigned int *A2_ptr = A2;
+ unsigned short *B2_ptr = B2;
+ unsigned long *C2_ptr = C2;
+}
+
+@__experimental_modules_import B.One;
+
+void test_B_One() {
+ short *B1_ptr = B1;
+}
+
diff --git a/test/PCH/Inputs/arc.h b/test/PCH/Inputs/arc.h
index 793fc64..304e612 100644
--- a/test/PCH/Inputs/arc.h
+++ b/test/PCH/Inputs/arc.h
@@ -14,7 +14,13 @@ CFStringRef CFGetString();
id CreateSomething();
NSString *CreateNSString();
-typedef int array0[sizeof((__bridge id)CFCreateSomething())];
-typedef int array1[sizeof((__bridge CFTypeRef)CreateSomething())];
+#if __has_feature(objc_arc)
+#define BRIDGE __bridge
+#else
+#define BRIDGE
+#endif
+
+typedef int array0[sizeof((BRIDGE id)CFCreateSomething())];
+typedef int array1[sizeof((BRIDGE CFTypeRef)CreateSomething())];
diff --git a/test/PCH/chain-categories2.m b/test/PCH/chain-categories2.m
new file mode 100644
index 0000000..f230bf9
--- /dev/null
+++ b/test/PCH/chain-categories2.m
@@ -0,0 +1,57 @@
+// Test that infinite loop in rdar://10418538 was fixed.
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -include %s -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header
+
+@class I;
+
+@interface I2
+@property (readonly) id prop1;
+@end
+
+//===----------------------------------------------------------------------===//
+#elif !defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header
+
+@interface I
+@end
+
+@interface I(Cat1)
+@end
+
+@interface I(Cat2)
+@end
+
+@interface I2()
+@property (readwrite,assign) id prop1;
+@property (copy) id prop2;
+@end
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void f(I* i) {
+ [i meth]; // expected-warning {{not found}}
+}
+
+@implementation I2
+@synthesize prop1, prop2;
+@end
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/test/PCH/chain-class-extension.m b/test/PCH/chain-class-extension.m
new file mode 100644
index 0000000..c99d6d4
--- /dev/null
+++ b/test/PCH/chain-class-extension.m
@@ -0,0 +1,42 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 -fobjc-arc %s -include %s -include %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 -fobjc-arc %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+//===----------------------------------------------------------------------===//
+// Primary header
+
+@interface I
++(void)meth;
+@end
+
+//===----------------------------------------------------------------------===//
+#elif !defined(HEADER2)
+#define HEADER2
+#if !defined(HEADER1)
+#error Header inclusion order messed up
+#endif
+
+//===----------------------------------------------------------------------===//
+// Dependent header
+
+@interface I()
+@property (assign) id prop;
++(void)meth2;
+@end
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+void foo(I *i) {
+ [I meth];
+ [I meth2];
+ i.prop = 0;
+}
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/test/PCH/chain-cxx.cpp b/test/PCH/chain-cxx.cpp
index af0a23a..0d50e61 100644
--- a/test/PCH/chain-cxx.cpp
+++ b/test/PCH/chain-cxx.cpp
@@ -38,12 +38,17 @@ template<typename T> struct TestBaseSpecifiers2 : TestBaseSpecifiers<T> { };
template <typename T>
struct TS3 {
static const int value = 0;
+ static const int value2;
};
template <typename T>
const int TS3<T>::value;
+template <typename T>
+const int TS3<T>::value2 = 1;
// Instantiate struct, but not value.
struct instantiate : TS3<int> {};
+// Typedef
+typedef int Integer;
//===----------------------------------------------------------------------===//
#elif not defined(HEADER2)
@@ -94,8 +99,12 @@ struct TestBaseSpecifiers4 : TestBaseSpecifiers3 { };
struct A { };
struct B : A { };
-// Instantiate TS3's member.
+// Instantiate TS3's members.
static const int ts3m1 = TS3<int>::value;
+extern int arr[TS3<int>::value2];
+
+// Redefinition of typedef
+typedef int Integer;
//===----------------------------------------------------------------------===//
#else
@@ -122,10 +131,12 @@ void test() {
TS2int ts2;
B b;
+ Integer i = 17;
}
// Should have remembered that there is a definition.
static const int ts3m2 = TS3<int>::value;
+int arr[TS3<int>::value2];
//===----------------------------------------------------------------------===//
#endif
diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m
index c543b71..7eae094 100644
--- a/test/PCH/chain-selectors.m
+++ b/test/PCH/chain-selectors.m
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t1 %S/Inputs/chain-selectors1.h
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s -Wselector -include-pch %t2
@implementation X
-(void)f {}
diff --git a/test/PCH/cocoa.m b/test/PCH/cocoa.m
new file mode 100644
index 0000000..0159b32
--- /dev/null
+++ b/test/PCH/cocoa.m
@@ -0,0 +1,7 @@
+// RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch
+// RUN: touch %t.empty.m
+// RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang -ast-dump 2>&1 > /dev/null
+#ifdef __APPLE__
+#include <Cocoa/Cocoa.h>
+#endif
+
diff --git a/test/PCH/cxx-constexpr.cpp b/test/PCH/cxx-constexpr.cpp
new file mode 100644
index 0000000..8fe48f7
--- /dev/null
+++ b/test/PCH/cxx-constexpr.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++98 -include-pch %t -verify %s
+
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+extern const int a;
+const int b = a;
+
+#else
+
+const int a = 5;
+typedef int T[b]; // expected-error {{variable length array}} expected-error {{must be an integer constant expression}}
+typedef int T[5];
+
+#endif
diff --git a/test/PCH/cxx-exprs.cpp b/test/PCH/cxx-exprs.cpp
new file mode 100644
index 0000000..9cd3194
--- /dev/null
+++ b/test/PCH/cxx-exprs.cpp
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++11 %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s
+
+#ifndef HEADER
+#define HEADER
+
+template<typename T>
+class New {
+ New(const New&);
+
+public:
+ New *clone() {
+ return new New(*this);
+ }
+};
+
+#else
+
+New<int> *clone_new(New<int> *n) {
+ return n->clone();
+}
+
+#endif
diff --git a/test/PCH/cxx-functions.cpp b/test/PCH/cxx-functions.cpp
new file mode 100644
index 0000000..74df01a
--- /dev/null
+++ b/test/PCH/cxx-functions.cpp
@@ -0,0 +1,10 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-functions.h -fsyntax-only -verify %s
+
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-functions.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+
+void test_foo() {
+ foo();
+}
diff --git a/test/PCH/cxx-functions.h b/test/PCH/cxx-functions.h
new file mode 100644
index 0000000..8aa4986
--- /dev/null
+++ b/test/PCH/cxx-functions.h
@@ -0,0 +1 @@
+void foo() throw( int, short, char, float, double );
diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp
index 982fc67..7ce2477 100644
--- a/test/PCH/cxx-templates.cpp
+++ b/test/PCH/cxx-templates.cpp
@@ -62,3 +62,9 @@ namespace Test1 {
}
};
}
+
+template< typename D >
+Foo< D >& Foo< D >::operator=( const Foo& other )
+{
+ return *this;
+}
diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h
index c45e02d..152e8ce 100644
--- a/test/PCH/cxx-templates.h
+++ b/test/PCH/cxx-templates.h
@@ -205,3 +205,13 @@ namespace NonTypeTemplateParmContext {
template<int inlineCapacity>
inline bool equalIgnoringNullity(const Vector<char, inlineCapacity>& a, const String& b) { return false; }
}
+
+// <rdar://problem/11112464>
+template< typename > class Foo;
+
+template< typename T >
+class Foo : protected T
+{
+ public:
+ Foo& operator=( const Foo& other );
+};
diff --git a/test/PCH/cxx-trailing-return.cpp b/test/PCH/cxx-trailing-return.cpp
new file mode 100644
index 0000000..ff85f6d
--- /dev/null
+++ b/test/PCH/cxx-trailing-return.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+typedef auto f() -> int; // expected-note {{here}}
+typedef int g(); // expected-note {{here}}
+
+#else
+
+typedef void f; // expected-error {{typedef redefinition with different types ('void' vs 'auto () -> int')}}
+typedef void g; // expected-error {{typedef redefinition with different types ('void' vs 'int ()')}}
+
+#endif
diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp
index 69c6475..3df3479 100644
--- a/test/PCH/cxx-traits.cpp
+++ b/test/PCH/cxx-traits.cpp
@@ -1,8 +1,11 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-traits.h -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-traits.h
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h
+// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s
bool _Is_pod_comparator = __is_pod<int>::__value;
bool _Is_empty_check = __is_empty<int>::__value;
+
+bool default_construct_int = is_trivially_constructible<int>::value;
+bool copy_construct_int = is_trivially_constructible<int, const int&>::value;
diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h
index 62722ab..8b62002 100644
--- a/test/PCH/cxx-traits.h
+++ b/test/PCH/cxx-traits.h
@@ -9,3 +9,8 @@ template<typename _Tp>
struct __is_empty {
enum { __value };
};
+
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+ static const bool value = __is_trivially_constructible(T, Args...);
+};
diff --git a/test/PCH/cxx0x-default-delete.cpp b/test/PCH/cxx0x-default-delete.cpp
index 3ecb19c..6eb65d6 100644
--- a/test/PCH/cxx0x-default-delete.cpp
+++ b/test/PCH/cxx0x-default-delete.cpp
@@ -12,6 +12,14 @@ struct foo {
void bar() = delete; // expected-note{{deleted here}}
};
+struct baz {
+ ~baz() = delete; // expected-note{{deleted here}}
+};
+
+class quux {
+ ~quux() = default; // expected-note{{private here}}
+};
+
#else
foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
@@ -20,4 +28,7 @@ void fn() {
f.bar(); // expected-error{{deleted function}}
}
+baz bz; // expected-error{{deleted function}}
+quux qx; // expected-error{{private destructor}}
+
#endif
diff --git a/test/PCH/cxx11-constexpr.cpp b/test/PCH/cxx11-constexpr.cpp
new file mode 100644
index 0000000..338543e
--- /dev/null
+++ b/test/PCH/cxx11-constexpr.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+struct B {
+ B(); // expected-note {{here}}
+ constexpr B(char) {}
+};
+
+struct C { // expected-note {{not an aggregate and has no constexpr constructors}}
+ B b;
+ double d = 0.0;
+};
+
+struct D : B {
+ constexpr D(int n) : B('x'), k(2*n+1) {}
+ int k;
+};
+
+#else
+
+static_assert(D(4).k == 9, "");
+constexpr int f(C c) { return 0; } // expected-error {{not a literal type}}
+constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}}
+
+#endif
diff --git a/test/PCH/cxx11-enum-template.cpp b/test/PCH/cxx11-enum-template.cpp
new file mode 100644
index 0000000..70b0ff9
--- /dev/null
+++ b/test/PCH/cxx11-enum-template.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<typename T> struct S {
+ enum class E {
+ e = T() // expected-error {{conversion from 'double' to 'int'}}
+ };
+};
+
+S<int> a;
+S<long>::E b;
+S<double>::E c;
+template struct S<char>;
+
+#else
+
+int k1 = (int)S<int>::E::e;
+int k2 = (int)decltype(b)::e;
+int k3 = (int)decltype(c)::e; // expected-note {{here}}
+int k4 = (int)S<char>::E::e;
+
+#endif
diff --git a/test/PCH/cxx11-lambdas.mm b/test/PCH/cxx11-lambdas.mm
new file mode 100644
index 0000000..c00ec63
--- /dev/null
+++ b/test/PCH/cxx11-lambdas.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++11 -emit-pch %s -o %t-cxx11
+// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++11 -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+template<typename T>
+T add_slowly(const T& x, const T &y) {
+ return [=, &y] { return x + y; }();
+};
+
+inline int add_int_slowly_twice(int x, int y) {
+ int i = add_slowly(x, y);
+ auto lambda = [&](int z) { return x + z; };
+ return i + lambda(y);
+}
+
+inline int sum_array(int n) {
+ int array[5] = { 1, 2, 3, 4, 5};
+ auto lambda = [=](int N) -> int {
+ int sum = 0;
+ for (unsigned I = 0; I < N; ++I)
+ sum += array[N];
+ return sum;
+ };
+
+ return lambda(n);
+}
+
+inline int to_block_pointer(int n) {
+ auto lambda = [=](int m) { return n + m; };
+ int (^block)(int) = lambda;
+ return block(17);
+}
+
+#else
+
+// CHECK-PRINT: T add_slowly
+// CHECK-PRINT: return [=, &y]
+template float add_slowly(const float&, const float&);
+
+int add(int x, int y) {
+ return add_int_slowly_twice(x, y) + sum_array(4) + to_block_pointer(5);
+}
+
+// CHECK-PRINT: inline int add_int_slowly_twice
+// CHECK-PRINT: lambda = [&] (int z)
+#endif
diff --git a/test/PCH/cxx11-user-defined-literals.cpp b/test/PCH/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..4a7c24b
--- /dev/null
+++ b/test/PCH/cxx11-user-defined-literals.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+using size_t = decltype(sizeof(int));
+int operator"" _foo(const char *p, size_t);
+
+template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } // expected-note {{substitution failure}}
+
+#else
+
+int j = ""_foo;
+int k = f(0);
+int *l = f(&k);
+struct S {};
+int m = f(S()); // expected-error {{no matching}}
+
+#endif
diff --git a/test/PCH/designated-init.c b/test/PCH/designated-init.c
new file mode 100644
index 0000000..beb4dff
--- /dev/null
+++ b/test/PCH/designated-init.c
@@ -0,0 +1,7 @@
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s.h -emit-llvm -o %t.withoutpch.ll
+
+// Test with pch.
+// RUN: %clang_cc1 %s.h -emit-pch -o %t.pch
+// RUN: %clang_cc1 %s -include-pch %t.pch -emit-llvm -o %t.withpch.ll
+// RUN: diff %t.withoutpch.ll %t.withpch.ll
diff --git a/test/PCH/designated-init.c.h b/test/PCH/designated-init.c.h
new file mode 100644
index 0000000..63b1f79
--- /dev/null
+++ b/test/PCH/designated-init.c.h
@@ -0,0 +1,42 @@
+static void *FooToken = &FooToken;
+static void *FooTable[256] = {
+ [0x3] = (void *[256]) { // 1
+ [0x5b] = (void *[256]) { // 2
+ [0x81] = (void *[256]) { // 3
+ [0x42] = (void *[256]) { // 4
+ [0xa2] = (void *[256]) { // 5
+ [0xe] = (void *[256]) { // 6
+ [0x20] = (void *[256]) { // 7
+ [0xd7] = (void *[256]) { // 8
+ [0x39] = (void *[256]) { // 9
+ [0xf1] = (void *[256]) { // 10
+ [0xa4] = (void *[256]) { // 11
+ [0xa8] = (void *[256]) { // 12
+ [0x21] = (void *[256]) { // 13
+ [0x86] = (void *[256]) { // 14
+ [0x1d] = (void *[256]) { // 15
+ [0xdc] = (void *[256]) { // 16
+ [0xa5] = (void *[256]) { // 17
+ [0xef] = (void *[256]) { // 18
+ [0x9] = (void *[256]) { // 19
+ [0x34] = &FooToken,
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+};
diff --git a/test/PCH/exprs.h b/test/PCH/exprs.h
index 3495b8b..09a5013 100644
--- a/test/PCH/exprs.h
+++ b/test/PCH/exprs.h
@@ -86,7 +86,9 @@ double double_array[3] = { 1.0, 2.0 };
struct {
int x;
float y;
-} designated_inits[3] = { [0].y = 17, [2].x = 12.3, 3.5 };
+} designated_inits[3] = { [0].y = 17,
+ [2].x = 12.3, // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ 3.5 };
// TypesCompatibleExpr
typedef typeof(__builtin_types_compatible_p(float, double)) types_compatible;
diff --git a/test/PCH/method-redecls.m b/test/PCH/method-redecls.m
index a11bf5a..9d02b6a 100644
--- a/test/PCH/method-redecls.m
+++ b/test/PCH/method-redecls.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t -D IMPL
+// RUN: %clang_cc1 -x objective-c %s -emit-pch -o %t
+// RUN: %clang_cc1 -x objective-c %s -emit-pch -o %t -D IMPL
// Avoid infinite loop because of method redeclarations.
diff --git a/test/PCH/method_pool.m b/test/PCH/method_pool.m
index ee53784..20010fb 100644
--- a/test/PCH/method_pool.m
+++ b/test/PCH/method_pool.m
@@ -1,9 +1,9 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/method_pool.h -fsyntax-only -verify %s
+// RUN: %clang_cc1 -include %S/method_pool.h -fsyntax-only -verify -Wno-objc-root-class %s
// Test with pch.
-// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/method_pool.h
-// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c -Wno-objc-root-class -emit-pch -o %t %S/method_pool.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify -Wno-objc-root-class %s
int message_id(id x) {
return [x instMethod:17]; // expected-warning{{multiple methods}}
diff --git a/test/PCH/modified-header-error.c b/test/PCH/modified-header-error.c
index 34f04bf..ef92494 100644
--- a/test/PCH/modified-header-error.c
+++ b/test/PCH/modified-header-error.c
@@ -9,5 +9,4 @@
#include "header2.h"
// CHECK: fatal error: file {{.*}} has been modified since the precompiled header was built
-// DISABLE: win32
-
+// REQUIRES: shell
diff --git a/test/PCH/ms-if-exists.cpp b/test/PCH/ms-if-exists.cpp
new file mode 100644
index 0000000..4bea198
--- /dev/null
+++ b/test/PCH/ms-if-exists.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -fms-extensions -fsyntax-only -include-pch %t %s -verify
+
+#ifndef HEADER
+#define HEADER
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+}
+#else
+struct HasFoo {
+ void foo();
+};
+struct HasBar {
+ void bar(int);
+ void bar(float);
+};
+
+template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
+template void f(HasBar);
+#endif
diff --git a/test/PCH/objc_container.h b/test/PCH/objc_container.h
new file mode 100644
index 0000000..c83f902
--- /dev/null
+++ b/test/PCH/objc_container.h
@@ -0,0 +1,26 @@
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(unsigned int)index;
+- (void)setObject:(id)object atIndexedSubscript:(unsigned int)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+void all() {
+ NSMutableArray *array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ id key;
+ id newObject;
+ oldObject = dictionary[key];
+
+ dictionary[key] = newObject;
+}
+
diff --git a/test/PCH/objc_container.m b/test/PCH/objc_container.m
new file mode 100644
index 0000000..1e59054
--- /dev/null
+++ b/test/PCH/objc_container.m
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/objc_container.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_container.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// RUN: %clang -cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+// CHECK-PRINT: id oldObject = array[10];
+// CHECK-PRINT: array[10] = oldObject;
+// CHECK-PRINT: oldObject = dictionary[key];
+// CHECK-PRINT: dictionary[key] = newObject;
+
+// CHECK-IR: define void @all() nounwind
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: {{call.*objc_msgSend}}
+// CHECK-IR: ret void
diff --git a/test/PCH/objc_exprs.h b/test/PCH/objc_exprs.h
index b811430..807304c 100644
--- a/test/PCH/objc_exprs.h
+++ b/test/PCH/objc_exprs.h
@@ -16,3 +16,11 @@ typedef typeof(id<foo>) objc_id_protocol_ty;
typedef typeof(itf*) objc_interface_ty;
typedef typeof(itf<foo>*) objc_qual_interface_ty;
+
+@interface PP
+@property (assign) id prop;
+@end
+
+static inline id getPseudoObject(PP *p) {
+ return p.prop;
+}
diff --git a/test/PCH/objc_exprs.m b/test/PCH/objc_exprs.m
index c37968b..1f971e7 100644
--- a/test/PCH/objc_exprs.m
+++ b/test/PCH/objc_exprs.m
@@ -6,7 +6,7 @@
// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s
// Expressions
-int *A1 = (objc_string)0; // expected-warning {{aka 'id'}}
+int *A1 = (objc_string)0; // expected-warning {{aka 'NSString *'}}
char A2 = (objc_encode){}; // expected-error {{not a compile-time constant}} \
expected-warning {{char [2]}}
diff --git a/test/PCH/objc_literals.m b/test/PCH/objc_literals.m
new file mode 100644
index 0000000..cce3173
--- /dev/null
+++ b/test/PCH/objc_literals.m
@@ -0,0 +1,66 @@
+// RUN: %clang -cc1 -emit-pch -o %t %s
+// RUN: %clang -cc1 -include-pch %t -verify %s
+// RUN: %clang -cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+// CHECK-IR: define internal void @test_numeric_literals()
+static inline void test_numeric_literals() {
+ // CHECK-PRINT: id intlit = @17
+ // CHECK-IR: {{call.*17}}
+ id intlit = @17;
+ // CHECK-PRINT: id floatlit = @17.45
+ // CHECK-IR: {{call.*1.745}}
+ id floatlit = @17.45;
+}
+
+static inline void test_array_literals() {
+ // CHECK-PRINT: id arraylit = @[ @17, @17.45
+ id arraylit = @[@17, @17.45];
+}
+
+static inline void test_dictionary_literals() {
+ // CHECK-PRINT: id dictlit = @{ @17 : {{@17.45[^,]*}}, @"hello" : @"world" };
+ id dictlit = @{@17 : @17.45, @"hello" : @"world" };
+}
+
+#else
+void test_all() {
+ test_numeric_literals();
+ test_array_literals();
+ test_dictionary_literals();
+}
+#endif
diff --git a/test/PCH/objc_literals.mm b/test/PCH/objc_literals.mm
new file mode 100644
index 0000000..8ef3351
--- /dev/null
+++ b/test/PCH/objc_literals.mm
@@ -0,0 +1,65 @@
+// RUN: %clang -cc1 -emit-pch -x objective-c++ -std=c++0x -o %t %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -verify %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=PRINT %s
+// RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef unsigned char BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+template<typename T, typename U>
+struct pair {
+ T first;
+ U second;
+};
+
+template<typename T, typename U>
+pair<T, U> make_pair(const T& first, const U& second) {
+ return { first, second };
+}
+
+// CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E
+template<typename ...Ts, typename ... Us>
+void variadic_dictionary_expansion(pair<Ts, Us>... key_values) {
+ // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... };
+ // CHECK-IR: {{call.*objc_msgSend}}
+ // CHECK-IR: ret void
+ id dict = @{ key_values.first : key_values.second ... };
+}
+
+#else
+void test_all() {
+ variadic_dictionary_expansion(make_pair(@"Seventeen", @17),
+ make_pair(@"YES", @true));
+}
+#endif
diff --git a/test/PCH/pending-ids.m b/test/PCH/pending-ids.m
new file mode 100644
index 0000000..b612d89
--- /dev/null
+++ b/test/PCH/pending-ids.m
@@ -0,0 +1,33 @@
+// Test for rdar://10278815
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 -emit-llvm-only -verify %s -include-pch %t -g
+
+#ifndef HEADER
+#define HEADER
+//===----------------------------------------------------------------------===//
+// Header
+
+typedef char BOOL;
+
+@interface NSString
++ (BOOL)meth;
+@end
+
+static NSString * const cake = @"cake";
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+@interface Foo {
+ BOOL ivar;
+}
+@end
+
+//===----------------------------------------------------------------------===//
+#endif
diff --git a/test/PCH/rdar10830559.cpp b/test/PCH/rdar10830559.cpp
new file mode 100644
index 0000000..b9b6437
--- /dev/null
+++ b/test/PCH/rdar10830559.cpp
@@ -0,0 +1,35 @@
+// Test this without pch.
+// RUN: %clang_cc1 -fsyntax-only -emit-llvm-only %s
+
+// Test with pch.
+// RUN: touch %t.empty.cpp
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm-only %t.empty.cpp
+
+// rdar://10830559
+
+#pragma ms_struct on
+
+template< typename T >
+class Templated
+{
+public:
+ struct s;
+};
+
+
+class Foo
+{
+private:
+
+ class Bar
+ {
+ private:
+ class BarTypes { public: virtual void Func(); };
+ class BarImpl {};
+ friend class Foo;
+ };
+
+
+ friend class Templated< Bar::BarImpl >::s;
+};
diff --git a/test/PCH/reloc.c b/test/PCH/reloc.c
index 5d51eee..4c426e4 100644
--- a/test/PCH/reloc.c
+++ b/test/PCH/reloc.c
@@ -1,8 +1,8 @@
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 --relocatable-pch -o %t \
+// RUN: %clang -target x86_64-apple-darwin10 --relocatable-pch -o %t \
// RUN: -isysroot %S/libroot %S/libroot/usr/include/reloc.h
-// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -fsyntax-only \
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only \
// RUN: -include-pch %t -isysroot %S/libroot %s -Xclang -verify
-// RUN: not %clang -ccc-host-triple x86_64-apple-darwin10 -include-pch %t %s
+// RUN: not %clang -target x86_64-apple-darwin10 -include-pch %t %s
#include <reloc.h>
diff --git a/test/PCH/replaced-decl.m b/test/PCH/replaced-decl.m
new file mode 100644
index 0000000..b9fee95
--- /dev/null
+++ b/test/PCH/replaced-decl.m
@@ -0,0 +1,22 @@
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -include %s -include %s
+
+// With PCH
+// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
+
+#ifndef HEADER1
+#define HEADER1
+
+@class I;
+
+#elif !defined(HEADER2)
+#define HEADER2
+
+@interface I // expected-note {{previous}}
+@end
+
+#else
+
+typedef int I; // expected-error {{redefinition}}
+
+#endif
diff --git a/test/PCH/single-token-macro.c b/test/PCH/single-token-macro.c
new file mode 100644
index 0000000..29edb75
--- /dev/null
+++ b/test/PCH/single-token-macro.c
@@ -0,0 +1,24 @@
+// rdar://10588825
+
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#define __stdcall
+#define STDCALL __stdcall
+
+void STDCALL Foo(void);
+
+#else
+
+void STDCALL Foo(void)
+{
+}
+
+#endif
diff --git a/test/PCH/subscripting-literals.m b/test/PCH/subscripting-literals.m
new file mode 100644
index 0000000..1675373
--- /dev/null
+++ b/test/PCH/subscripting-literals.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.nopch.ll %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-pch -o %t.pch %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t.pch.ll %s -include-pch %t.pch
+// RUN: diff %t.nopch.ll %t.pch.ll
+
+#ifndef HEADER
+#define HEADER
+
+@interface NSArray
+- (id)objectAtIndexedSubscript:(int)index;
++ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary
+- (id)objectForKeyedSubscript:(id)key;
++ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@class NSString;
+
+id testArray(int idx, id p) {
+ NSMutableArray *array;
+ array[idx] = p;
+ NSArray *arr = @[ p, @7 ];
+ return array[idx];
+}
+
+void testDict(NSString *key, id newObject, id oldObject) {
+ NSMutableDictionary *dictionary;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject;
+ NSDictionary *dict = @{ key: newObject, key: oldObject };
+}
+
+#endif
diff --git a/test/PCH/typo.cpp b/test/PCH/typo.cpp
index 4c88614..f8161d1 100644
--- a/test/PCH/typo.cpp
+++ b/test/PCH/typo.cpp
@@ -1,8 +1,8 @@
-// In header: expected-note{{ 'boost::function' declared here}}
+// In header: expected-note{{'boost::function' declared here}}
-// In header: expected-note{{ 'boost::graph::adjacency_list' declared here}}
+// In header: expected-note{{'boost::graph::adjacency_list' declared here}}
diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp
index b02c402..9737c73 100644
--- a/test/Parser/DelayedTemplateParsing.cpp
+++ b/test/Parser/DelayedTemplateParsing.cpp
@@ -12,6 +12,10 @@ template <class T>
class B {
void foo4() { } // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
void foo4() { } // expected-error {{class member cannot be redeclared}} expected-error {{redefinition of 'foo4'}} expected-note {{previous definition is here}}
+
+ friend void foo3() {
+ undeclared();
+ }
};
@@ -59,3 +63,30 @@ public:
}
+
+namespace PR11931 {
+
+template <typename RunType>
+struct BindState;
+
+ template<>
+struct BindState<void(void*)> {
+ static void Run() { }
+};
+
+class Callback {
+public:
+ typedef void RunType();
+
+ template <typename RunType>
+ Callback(BindState<RunType> bind_state) {
+ BindState<RunType>::Run();
+ }
+};
+
+
+Callback Bind() {
+ return Callback(BindState<void(void*)>());
+}
+
+}
diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c
index a0f15e9d..1ef326a 100644
--- a/test/Parser/MicrosoftExtensions.c
+++ b/test/Parser/MicrosoftExtensions.c
@@ -49,9 +49,16 @@ char x = FOO(a);
typedef enum E { e1 };
+enum __declspec(deprecated) E2 { i, j, k };
+__declspec(deprecated) enum E3 { a, b, c } e;
-
-
+void deprecated_enum_test(void)
+{
+ // Test to make sure the deprecated warning follows the right thing
+ enum E2 e1; // expected-warning {{'E2' is deprecated}}
+ enum E3 e2; // No warning expected, the deprecation follows the variable
+ enum E3 e3 = e; // expected-warning {{'e' is deprecated}}
+}
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index 3a72ea0..89394c3 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -165,6 +165,11 @@ __interface MicrosoftInterface {
virtual void foo2() = 0;
};
+void interface_test() {
+ MicrosoftInterface* a;
+ a->foo1();
+}
+
__int64 x7 = __int64(0);
@@ -210,6 +215,35 @@ __if_not_exists(IF_EXISTS::Type_not) {
int var244;
}
+int __if_exists_init_list() {
+
+ int array1[] = {
+ 0,
+ __if_exists(IF_EXISTS::Type) {2, }
+ 3
+ };
+
+ int array2[] = {
+ 0,
+ __if_exists(IF_EXISTS::Type_not) { this wont compile }
+ 3
+ };
+
+ int array3[] = {
+ 0,
+ __if_not_exists(IF_EXISTS::Type_not) {2, }
+ 3
+ };
+
+ int array4[] = {
+ 0,
+ __if_not_exists(IF_EXISTS::Type) { this wont compile }
+ 3
+ };
+
+}
+
+
class IF_EXISTS_CLASS_TEST {
__if_exists(IF_EXISTS::Type) {
// __if_exists, __if_not_exists can nest
diff --git a/test/Parser/asm.c b/test/Parser/asm.c
index 9081826..23052c3 100644
--- a/test/Parser/asm.c
+++ b/test/Parser/asm.c
@@ -14,3 +14,6 @@ void f2() {
// rdar://5952468
__asm ; // expected-error {{expected '(' after 'asm'}}
+// <rdar://problem/10465079> - Don't crash on wide string literals in 'asm'.
+int foo asm (L"bar"); // expected-error {{cannot use wide string literal in 'asm'}}
+
diff --git a/test/Parser/asm.cpp b/test/Parser/asm.cpp
new file mode 100644
index 0000000..35a497c
--- /dev/null
+++ b/test/Parser/asm.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+int foo1 asm ("bar1");
+int foo2 asm (L"bar2"); // expected-error {{cannot use wide string literal in 'asm'}}
+int foo3 asm (u8"bar3"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo4 asm (u"bar4"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo5 asm (U"bar5"); // expected-error {{cannot use unicode string literal in 'asm'}}
+int foo6 asm ("bar6"_x); // expected-error {{string literal with user-defined suffix cannot be used here}}
diff --git a/test/Parser/attr-availability.c b/test/Parser/attr-availability.c
index 269f908..b9ff31c 100644
--- a/test/Parser/attr-availability.c
+++ b/test/Parser/attr-availability.c
@@ -16,5 +16,13 @@ void f4() __attribute__((availability(macosx,introduced=10.5), availability(ios,
void f5() __attribute__((availability(macosx,introduced=10.5), availability(ios,unavailable, unavailable))); // expected-error{{redundant 'unavailable' availability change; only the last specified change will be used}}
-void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{warning: 'unavailable' availability overrides all other availability information}}
+void f6() __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
+// rdar://10095131
+enum E{
+ gorf __attribute__((availability(macosx,introduced=8.5, message = 10.0))), // expected-error {{expected string literal}}
+ garf __attribute__((availability(macosx,introduced=8.5, message))), // expected-error {{expected '=' after 'message'}}
+
+ foo __attribute__((availability(macosx,introduced=8.5,deprecated=9.0, message="Use CTFontCopyPostScriptName()", deprecated=10.0))) // expected-error {{expected ')'}} \
+ // expected-note {{to match this '('}}
+};
diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c
index b287363..347cb9c 100644
--- a/test/Parser/attributes.c
+++ b/test/Parser/attributes.c
@@ -56,3 +56,43 @@ void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
// PR6287
void __attribute__((returns_twice)) returns_twice_test();
+
+int aligned(int);
+int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error {{expected ')'}}
+int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}}
+int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}}
+
+
+
+int testFundef1(int *a) __attribute__((nonnull(1))) { // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ return *a;
+}
+
+// noreturn is lifted to type qualifier
+void testFundef2() __attribute__((noreturn)) { // \
+ // expected-warning {{GCC does not allow noreturn attribute in this position on a function definition}}
+ testFundef2();
+}
+
+int testFundef3(int *a) __attribute__((nonnull(1), // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+int testFundef4(int *a) __attribute__((nonnull(1))) // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ __attribute((pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+// GCC allows these
+void testFundef5() __attribute__(()) { }
+
+__attribute__((pure)) int testFundef6(int a) { return a; }
+
+
+
diff --git a/test/Parser/bracket-crash.cpp b/test/Parser/bracket-crash.cpp
index fd18e0e..bcc6eab 100644
--- a/test/Parser/bracket-crash.cpp
+++ b/test/Parser/bracket-crash.cpp
@@ -1,6 +1,6 @@
-// RUN: not %clang_cc1 -fsyntax-only %s
+// RUN: not %clang_cc1 -fsyntax-only -std=c++11 %s
// PR7481
+decltype(;
struct{
a
}
-
diff --git a/test/Parser/check-syntax-1.m b/test/Parser/check-syntax-1.m
index db37793..0ae0c5d 100644
--- a/test/Parser/check-syntax-1.m
+++ b/test/Parser/check-syntax-1.m
@@ -6,7 +6,7 @@ int @interface bla ; // expected-error {{cannot combine with previous 'int' dec
typedef float CGFloat;
@interface XNSNumber
+ (XNSNumber *) numberWithCGFloat : (CGFloat) float; // expected-error {{expected identifier}} \
- // expected-error {{ expected ';' after method prototype}}
+ // expected-error {{expected ';' after method prototype}}
@end
// rdar: // 7822196
diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp
index 4d92450..9b2b1af 100644
--- a/test/Parser/cxx-altivec.cpp
+++ b/test/Parser/cxx-altivec.cpp
@@ -67,7 +67,7 @@ __vector double vv_d1; // expected-error {{cannot use 'double' wit
vector double v_d2; // expected-error {{cannot use 'double' with '__vector'}}
__vector long double vv_ld3; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
vector long double v_ld4; // expected-warning {{Use of 'long' with '__vector' is deprecated}} expected-error {{cannot use 'double' with '__vector'}}
-vector bool v_b; // expected-error {{error: C++ requires a type specifier for all declarations}}
+vector bool v_b; // expected-error {{C++ requires a type specifier for all declarations}}
vector bool float v_bf; // expected-error {{cannot use 'float' with '__vector bool'}}
vector bool double v_bd; // expected-error {{cannot use 'double' with '__vector bool'}}
vector bool pixel v_bp; // expected-error {{cannot use '__pixel' with '__vector bool'}}
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 1c0d862..1b3dd41 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -54,6 +54,36 @@ public; // expected-error{{expected ':'}}
int i;
};
+class F {
+ int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
+ void F2 {} // expected-error{{function definition does not declare parameters}}
+ typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
+ typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
+};
+
+namespace ctor_error {
+ class Foo {};
+ // By [class.qual]p2, this is a constructor declaration.
+ Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}}
+
+ class Ctor { // expected-note{{not complete until the closing '}'}}
+ Ctor(f)(int); // ok
+ Ctor(g(int)); // ok
+ Ctor(x[5]); // expected-error{{incomplete type}}
+
+ Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
+ void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
+ };
+
+ Ctor::Ctor (x) = { 0 }; // \
+ // expected-error{{qualified reference to 'Ctor' is a constructor name}}
+
+ Ctor::Ctor(UnknownType *) {} // \
+ // expected-error{{unknown type name 'UnknownType'}}
+ void Ctor::operator+(UnknownType*) {} // \
+ // expected-error{{unknown type name 'UnknownType'}}
+}
+
// PR11109 must appear at the end of the source file
class pr11109r3 { // expected-note{{to match this '{'}}
public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}
diff --git a/test/Parser/cxx-condition.cpp b/test/Parser/cxx-condition.cpp
index 552d823..5672eea 100644
--- a/test/Parser/cxx-condition.cpp
+++ b/test/Parser/cxx-condition.cpp
@@ -1,11 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+struct S { S(int); operator bool(); };
+
void f() {
int a;
while (a) ;
- while (int x) ; // expected-error {{expected '=' after declarator}}
+ while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
while (float x = 0) ;
- if (const int x = a) ; // expected-warning{{empty body}}
+ if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
switch (int x = a+10) {}
for (; int x = ++a; ) ;
+
+ if (S a(42)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
}
diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp
index 70eff97..57f33d8 100644
--- a/test/Parser/cxx-decl.cpp
+++ b/test/Parser/cxx-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux %s
int x(*g); // expected-error {{use of undeclared identifier 'g'}}
@@ -66,6 +66,36 @@ struct test4 {
int z // expected-error {{expected ';' at end of declaration list}}
};
+// Make sure we know these are legitimate commas and not typos for ';'.
+namespace Commas {
+ struct S {
+ static int a;
+ int c,
+ operator()();
+ };
+
+ int global1,
+ __attribute__(()) global2,
+ (global5),
+ *global6,
+ &global7 = global1,
+ &&global8 = static_cast<int&&>(global1), // expected-warning 2{{rvalue reference}}
+ S::a,
+ global9,
+ global10 = 0,
+ global11 == 0, // expected-error {{did you mean '='}}
+ global12 __attribute__(()),
+ global13(0),
+ global14[2],
+ global15;
+
+ void g() {
+ static int a,
+ b __asm__("ebx"), // expected-error {{expected ';' at end of declaration}}
+ Statics:return;
+ }
+}
+
// PR5825
struct test5 {};
::new(static_cast<void*>(0)) test5; // expected-error {{expected unqualified-id}}
diff --git a/test/Parser/cxx-default-delete.cpp b/test/Parser/cxx-default-delete.cpp
index f34f6fb..df24b3d 100644
--- a/test/Parser/cxx-default-delete.cpp
+++ b/test/Parser/cxx-default-delete.cpp
@@ -3,8 +3,12 @@
int i = delete; // expected-error{{only functions}}
int j = default; // expected-error{{special member functions}}
-int f() = delete, g; // expected-error{{standalone}}
-int o, p() = delete; // expected-error{{standalone}}
+int f() = delete, g; // expected-error{{'= delete' is a function definition}}
+int o, p() = delete; // expected-error{{'= delete' is a function definition}}
+
+int q() = default, r; // expected-error{{only special member functions}} \
+ // expected-error{{'= default' is a function definition}}
+int s, t() = default; // expected-error{{'= default' is a function definition}}
struct foo {
foo() = default;
@@ -13,3 +17,7 @@ struct foo {
};
void baz() = delete;
+
+struct quux {
+ int quux() = default; // expected-error{{constructor cannot have a return type}} expected-error {{member 'quux' has the same name as its class}}
+};
diff --git a/test/Parser/cxx-ext-delete-default.cpp b/test/Parser/cxx-ext-delete-default.cpp
index be6efee..af8b6d6 100644
--- a/test/Parser/cxx-ext-delete-default.cpp
+++ b/test/Parser/cxx-ext-delete-default.cpp
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
struct A {
- A(const A&) = delete; // expected-warning {{accepted as a C++11 extension}}
- A& operator=(const A&) = delete; // expected-warning {{accepted as a C++11 extension}}
- A() = default; // expected-warning {{accepted as a C++11 extension}}
+ A(const A&) = delete; // expected-warning {{C++11 extension}}
+ A& operator=(const A&) = delete; // expected-warning {{C++11 extension}}
+ A() = default; // expected-warning {{C++11 extension}}
~A();
};
-void f() = delete; // expected-warning {{accepted as a C++11 extension}}
-A::~A() = default; //expected-warning {{accepted as a C++11 extension}}
+void f() = delete; // expected-warning {{C++11 extension}}
+A::~A() = default; //expected-warning {{C++11 extension}}
diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp
index 4717dbb..7e931a3 100644
--- a/test/Parser/cxx-template-decl.cpp
+++ b/test/Parser/cxx-template-decl.cpp
@@ -6,15 +6,20 @@ template x; // expected-error {{C++ requires a type specifier for al
// expected-error {{does not refer}}
export template x; // expected-error {{expected '<' after 'template'}}
export template<class T> class x0; // expected-warning {{exported templates are unsupported}}
-template < ; // expected-error {{parse error}} \
+template < ; // expected-error {{expected template parameter}} \
// expected-error{{expected ',' or '>' in template-parameter-list}} \
// expected-warning {{declaration does not declare anything}}
+template <int +> struct x1; // expected-error {{expected ',' or '>' in template-parameter-list}}
+
+// verifies that we only walk to the ',' & still produce errors on the rest of the template parameters
+template <int +, T> struct x2; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+ expected-error {{expected unqualified-id}}
+template<template<int+>> struct x3; // expected-error {{expected ',' or '>' in template-parameter-list}} \
+ expected-error {{template template parameter requires 'class' after the parameter list}}
template <template X> struct Err1; // expected-error {{expected '<' after 'template'}} \
// expected-error{{extraneous}}
-template <template <typename> > struct Err2; // expected-error {{expected 'class' before '>'}} \
-// expected-error{{extraneous}}
-template <template <typename> Foo> struct Err3; // expected-error {{expected 'class' before 'Foo'}} \
-// expected-error{{extraneous}}
+template <template <typename> > struct Err2; // expected-error {{template template parameter requires 'class' after the parameter list}}
+template <template <typename> Foo> struct Err3; // expected-error {{template template parameter requires 'class' after the parameter list}}
// Template function declarations
template <typename T> void foo();
diff --git a/test/Parser/cxx-typeid.cpp b/test/Parser/cxx-typeid.cpp
index a825dc3..e726665 100644
--- a/test/Parser/cxx-typeid.cpp
+++ b/test/Parser/cxx-typeid.cpp
@@ -9,5 +9,5 @@ void f()
{
(void)typeid(int);
(void)typeid(0);
- (void)typeid 1; // expected-error {{error: expected '(' after 'typeid'}}
+ (void)typeid 1; // expected-error {{expected '(' after 'typeid'}}
}
diff --git a/test/Parser/cxx-typeof.cpp b/test/Parser/cxx-typeof.cpp
index 4c598e9..1ec6e29 100644
--- a/test/Parser/cxx-typeof.cpp
+++ b/test/Parser/cxx-typeof.cpp
@@ -9,5 +9,5 @@ static void test() {
// Part of rdar://problem/8347416; from the gcc test suite.
struct S {
int i;
- __typeof(S::i) foo(); // expected-error {{invalid use of nonstatic data member 'i'}}
+ __typeof(S::i) foo(); // expected-error {{invalid use of non-static data member 'i'}}
};
diff --git a/test/Parser/cxx-using-directive.cpp b/test/Parser/cxx-using-directive.cpp
index 1e91899..1d781fb 100644
--- a/test/Parser/cxx-using-directive.cpp
+++ b/test/Parser/cxx-using-directive.cpp
@@ -3,7 +3,7 @@
class A {};
namespace B {
- namespace A {}
+ namespace A {} // expected-note{{namespace '::B::A' defined here}}
using namespace A ;
}
@@ -19,8 +19,7 @@ namespace D {
namespace B {}
using namespace C ;
- using namespace B::A ; // expected-error{{expected namespace name}}
- //FIXME: would be nice to note, that A is not member of D::B
+ using namespace B::A ; // expected-error{{no namespace named 'A' in namespace 'D::B'; did you mean '::B::A'?}}
using namespace ::B::A ;
using namespace ::D::C ; // expected-error{{expected namespace name}}
}
@@ -37,4 +36,3 @@ void test_nslookup() {
using namespace B;
using namespace C;
}
-
diff --git a/test/Parser/cxx0x-ambig.cpp b/test/Parser/cxx0x-ambig.cpp
new file mode 100644
index 0000000..98757b4
--- /dev/null
+++ b/test/Parser/cxx0x-ambig.cpp
@@ -0,0 +1,127 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// New exciting ambiguities in C++11
+
+// final 'context sensitive' mess.
+namespace final {
+ struct S { int n; };
+ struct T { int n; };
+ namespace N {
+ int n;
+ // These declare variables named final..
+ extern struct S final;
+ extern struct S final [[]];
+ extern struct S final, foo;
+ struct S final = S();
+
+ // This defines a class, not a variable, even though it would successfully
+ // parse as a variable but not as a class. DR1318's wording suggests that
+ // this disambiguation is only performed on an ambiguity, but that was not
+ // the intent.
+ struct S final { // expected-note {{here}}
+ int(n) // expected-error {{expected ';'}}
+ };
+ // This too.
+ struct T final : S {}; // expected-error {{base 'S' is marked 'final'}}
+ struct T bar : S {}; // expected-error {{expected ';' after top level declarator}} expected-error {{expected unqualified-id}}
+ }
+}
+
+// enum versus bitfield mess.
+namespace bitfield {
+ enum E {};
+
+ struct T {
+ constexpr T() {}
+ constexpr T(int) {}
+ constexpr T(T, T, T, T) {}
+ constexpr T operator=(T) { return *this; }
+ constexpr operator int() { return 4; }
+ };
+ constexpr T a, b, c, d;
+
+ struct S1 {
+ enum E : T ( a = 1, b = 2, c = 3, 4 ); // ok, declares a bitfield
+ };
+ // This could be a bit-field.
+ struct S2 {
+ enum E : T { a = 1, b = 2, c = 3, 4 }; // expected-error {{non-integral type}} expected-error {{expected '}'}} expected-note {{to match}}
+ };
+ struct S3 {
+ enum E : int { a = 1, b = 2, c = 3, d }; // ok, defines an enum
+ };
+ // Ambiguous.
+ struct S4 {
+ enum E : int { a = 1 }; // ok, defines an enum
+ };
+ // This could be a bit-field, but would be ill-formed due to the anonymous
+ // member being initialized.
+ struct S5 {
+ enum E : int { a = 1 } { b = 2 }; // expected-error {{expected member name}}
+ };
+ // This could be a bit-field.
+ struct S6 {
+ enum E : int { 1 }; // expected-error {{expected '}'}} expected-note {{to match}}
+ };
+
+ struct U {
+ constexpr operator T() { return T(); } // expected-note 2{{candidate}}
+ };
+ // This could be a bit-field.
+ struct S7 {
+ enum E : int { a = U() }; // expected-error {{no viable conversion}}
+ };
+ // This could be a bit-field, and does not conform to the grammar of an
+ // enum definition, because 'id(U())' is not a constant-expression.
+ constexpr const U &id(const U &u) { return u; }
+ struct S8 {
+ enum E : int { a = id(U()) }; // expected-error {{no viable conversion}}
+ };
+}
+
+namespace trailing_return {
+ typedef int n;
+ int a;
+
+ struct S {
+ S(int);
+ S *operator()() const;
+ int n;
+ };
+
+ namespace N {
+ void f() {
+ // This parses as a function declaration, but DR1223 makes the presence of
+ // 'auto' be used for disambiguation.
+ S(a)()->n; // ok, expression; expected-warning{{expression result unused}}
+ auto(a)()->n; // ok, function declaration
+ using T = decltype(a);
+ using T = auto() -> n;
+ }
+ }
+}
+
+namespace ellipsis {
+ template<typename...T>
+ struct S {
+ void e(S::S());
+ void f(S(...args[sizeof(T)])); // expected-note {{here}}
+ void f(S(...args)[sizeof(T)]); // expected-error {{redeclared}} expected-note {{here}}
+ void f(S ...args[sizeof(T)]); // expected-error {{redeclared}}
+ void g(S(...[sizeof(T)])); // expected-note {{here}}
+ void g(S(...)[sizeof(T)]); // expected-error {{function cannot return array type}}
+ void g(S ...[sizeof(T)]); // expected-error {{redeclared}}
+ void h(T(...)); // function type, expected-error {{unexpanded parameter pack}}
+ void h(T...); // pack expansion, ok
+ void i(int(T...)); // expected-note {{here}}
+ void i(int(T...a)); // expected-error {{redeclared}}
+ void i(int(T, ...)); // function type, expected-error {{unexpanded parameter pack}}
+ void i(int(T, ...a)); // expected-error {{expected ')'}} expected-note {{to match}} expected-error {{unexpanded parameter pack}}
+ void j(int(int...)); // function type, ok
+ void j(int(int...a)); // expected-error {{does not contain any unexpanded parameter packs}}
+ void j(T(int...)); // expected-error {{unexpanded parameter pack}}
+ void j(T(T...)); // expected-error {{unexpanded parameter pack}}
+ void k(int(...)(T)); // expected-error {{cannot return function type}}
+ void k(int ...(T));
+ };
+}
diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp
index e762b57..f97995e 100644
--- a/test/Parser/cxx0x-attributes.cpp
+++ b/test/Parser/cxx0x-attributes.cpp
@@ -5,26 +5,35 @@
int [[]] between_attr;
int after_attr [[]];
int * [[]] ptr_attr;
+int & [[]] ref_attr = after_attr;
+int && [[]] rref_attr = 0;
int array_attr [1] [[]];
alignas(8) int aligned_attr;
[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
int garbage_attr;
+[[,,,static, class, namespace,, inline, constexpr, mutable,, bi\
+tand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr;
+[[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}}
void fn_attr () [[]];
+void noexcept_fn_attr () noexcept [[]];
+struct MemberFnOrder {
+ virtual void f() const volatile && noexcept [[]] final = 0;
+};
class [[]] class_attr {};
extern "C++" [[]] int extern_attr;
template <typename T> [[]] void template_attr ();
[[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
-int comma_attr [[,]]; // expected-error {{expected identifier}}
+int comma_attr [[,]];
int scope_attr [[foo::]]; // expected-error {{expected identifier}}
+int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}}
unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
-int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
class foo {
- void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}} expected-error {{array has incomplete element type 'void'}}
+ void const_after_attr () [[]] const; // expected-error {{expected ';'}}
};
extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
-[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}}
+[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
@@ -33,7 +42,7 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
// Argument tests
alignas int aligned_no_params; // expected-error {{expected '('}}
-alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
+alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
// Statement tests
void foo () {
@@ -58,6 +67,17 @@ void foo () {
[[]] try {
} [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
}
-
+ struct S { int arr[2]; } s;
+ (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+ int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}}
+
+ void bar [[noreturn]] ([[]] int i, [[]] int j);
+ using FuncType = void ([[]] int);
+ void baz([[]]...); // expected-error {{expected parameter declarator}}
+
[[]] return;
}
+
+template<typename...Ts> void variadic() {
+ void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}}
+}
diff --git a/test/Parser/cxx0x-condition.cpp b/test/Parser/cxx0x-condition.cpp
new file mode 100644
index 0000000..e45cd86
--- /dev/null
+++ b/test/Parser/cxx0x-condition.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct S { S(int); operator bool(); };
+
+void f() {
+ int a;
+ typedef int n;
+
+ while (a) ;
+ while (int x) ; // expected-error {{variable declaration in condition must have an initializer}}
+ while (float x = 0) ;
+ if (const int x = a) ; // expected-warning{{empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ switch (int x = a+10) {}
+ for (; int x = ++a; ) ;
+
+ if (S(a)) {} // ok
+ if (S(a) = 0) {} // ok
+ if (S(a) == 0) {} // ok
+
+ if (S(n)) {} // expected-error {{unexpected type name 'n': expected expression}}
+ if (S(n) = 0) {} // ok
+ if (S(n) == 0) {} // expected-error {{unexpected type name 'n': expected expression}}
+
+ if (S b(a)) {} // expected-error {{variable declaration in condition cannot have a parenthesized initializer}}
+
+ if (S b(n)) {} // expected-error {{a function type is not allowed here}} expected-error {{must have an initializer}}
+ if (S b(n) = 0) {} // expected-error {{a function type is not allowed here}}
+ if (S b(n) == 0) {} // expected-error {{a function type is not allowed here}} expected-error {{did you mean '='?}}
+
+ if (S{a}) {} // ok
+ if (S a{a}) {} // ok
+ if (S a = {a}) {} // ok
+ if (S a == {a}) {} // expected-error {{did you mean '='?}}
+
+ if (S(b){a}) {} // ok
+ if (S(b) = {a}) {} // ok
+}
diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp
new file mode 100644
index 0000000..b9f5141
--- /dev/null
+++ b/test/Parser/cxx0x-decl.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++0x %s
+
+// Make sure we know these are legitimate commas and not typos for ';'.
+namespace Commas {
+ int a,
+ b [[ ]],
+ c alignas(double);
+}
+
+struct S {};
+enum E { e };
+
+auto f() -> struct S {
+ return S();
+}
+auto g() -> enum E {
+ return E();
+}
diff --git a/test/Parser/cxx0x-for-range.cpp b/test/Parser/cxx0x-for-range.cpp
new file mode 100644
index 0000000..f920ef9
--- /dev/null
+++ b/test/Parser/cxx0x-for-range.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template<typename T, typename U>
+struct pair {};
+
+template<typename T, typename U>
+struct map {
+ typedef pair<T,U> *iterator;
+ iterator begin();
+ iterator end();
+};
+
+template<typename T, typename U>
+pair<T,U> &tie(T &, U &);
+
+int foo(map<char*,int> &m) {
+ char *p;
+ int n;
+
+ for (pair<char*,int> x : m) {
+ (void)x;
+ }
+
+ for (tie(p, n) : m) { // expected-error {{for range declaration must declare a variable}}
+ (void)p;
+ (void)n;
+ }
+
+ return n;
+}
diff --git a/test/Parser/cxx0x-in-cxx98.cpp b/test/Parser/cxx0x-in-cxx98.cpp
index 9e41a70..b4bda89 100644
--- a/test/Parser/cxx0x-in-cxx98.cpp
+++ b/test/Parser/cxx0x-in-cxx98.cpp
@@ -8,3 +8,16 @@ struct X {
};
}
+struct B {
+ virtual void f();
+ virtual void g();
+};
+struct D final : B { // expected-warning {{'final' keyword is a C++11 extension}}
+ virtual void f() override; // expected-warning {{'override' keyword is a C++11 extension}}
+ virtual void g() final; // expected-warning {{'final' keyword is a C++11 extension}}
+};
+
+void NewBracedInitList() {
+ // A warning on this would be sufficient once we can handle it correctly.
+ new int {}; // expected-error {{}}
+}
diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp
index b4fe4cc..9c71941 100644
--- a/test/Parser/cxx0x-lambda-expressions.cpp
+++ b/test/Parser/cxx0x-lambda-expressions.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s
+
+enum E { e };
class C {
@@ -10,18 +12,32 @@ class C {
[foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
[foo,&this] {}; // expected-error {{'this' cannot be captured by reference}}
[&this] {}; // expected-error {{'this' cannot be captured by reference}}
- [&,] {}; // expected-error {{ expected variable name or 'this' in lambda capture list}}
- [=,] {}; // expected-error {{ expected variable name or 'this' in lambda capture list}}
- [] {};
- [=] (int i) {};
- [&] (int) mutable -> void {};
- [foo,bar] () { return 3; };
- [=,&foo] () {};
- [&,foo] () {};
- [this] () {};
+ [&,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+ [=,] {}; // expected-error {{expected variable name or 'this' in lambda capture list}}
+ [] {};
+ [=] (int i) {};
+ [&] (int) mutable -> void {};
+ [foo,bar] () { return 3; };
+ [=,&foo] () {};
+ [&,foo] () {};
+ [this] () {};
+ [] () -> class C { return C(); };
+ [] () -> enum E { return e; };
+ [] -> int { return 0; }; // expected-error{{lambda requires '()' before return type}}
+ [] mutable -> int { return 0; }; // expected-error{{lambda requires '()' before 'mutable'}}
return 1;
}
+ void designator_or_lambda() {
+ typedef int T;
+ const int b = 0;
+ const int c = 1;
+ int a1[1] = {[b] (T()) {}}; // expected-error{{no viable conversion from 'C::<lambda}}
+ int a2[1] = {[b] = 1 };
+ int a3[1] = {[b,c] = 1 }; // expected-error{{expected body of lambda expression}}
+ int a4[1] = {[&b] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'const int *'}}
+ int a5[3] = { []{return 0;}() };
+ int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}}
+ }
};
-
diff --git a/test/Parser/cxx0x-literal-operators.cpp b/test/Parser/cxx0x-literal-operators.cpp
index 4fcbad4..1881fcb 100644
--- a/test/Parser/cxx0x-literal-operators.cpp
+++ b/test/Parser/cxx0x-literal-operators.cpp
@@ -1,6 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
void operator "" (const char *); // expected-error {{expected identifier}}
-void operator "k" foo(const char *); // expected-error {{string literal after 'operator' must be '""'}} \
-// expected-warning{{user-defined literal with suffix 'foo' is preempted by C99 hexfloat extension}}
-void operator "" tester (const char *); // expected-warning{{user-defined literal with suffix 'tester' is preempted by C99 hexfloat extension}}
+void operator "k" foo(const char *); // \
+ expected-error {{string literal after 'operator' must be '""'}} \
+ expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
+void operator "" tester (const char *); // \
+ expected-warning{{user-defined literal suffixes not starting with '_' are reserved}}
diff --git a/test/Parser/cxx11-type-specifier.cpp b/test/Parser/cxx11-type-specifier.cpp
new file mode 100644
index 0000000..2e629f3
--- /dev/null
+++ b/test/Parser/cxx11-type-specifier.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify %s -std=c++11 -fcxx-exceptions
+
+// Tests for parsing of type-specifier-seq
+
+struct S {
+ operator constexpr int(); // expected-error{{type name does not allow constexpr}}
+};
+enum E { e };
+
+void f() {
+ try {
+ (void) new constexpr int; // expected-error{{type name does not allow constexpr}}
+ } catch (constexpr int) { // expected-error{{type name does not allow constexpr}}
+ }
+
+ // These parse as type definitions, not as type references with braced
+ // initializers. Sad but true...
+ (void) new struct S {}; // expected-error{{'S' can not be defined in a type specifier}}
+ (void) new enum E { e }; // expected-error{{'E' can not be defined in a type specifier}}
+}
diff --git a/test/Parser/cxx11-user-defined-literals.cpp b/test/Parser/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..49fea01
--- /dev/null
+++ b/test/Parser/cxx11-user-defined-literals.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0
+
+// A ud-suffix cannot be used on string literals in a whole bunch of contexts:
+
+#include "foo"_bar // expected-error {{expected "FILENAME" or <FILENAME>}}
+#line 1 "foo"_bar // expected-error {{user-defined suffix cannot be used here}}
+# 1 "foo"_bar 1 // expected-error {{user-defined suffix cannot be used here}}
+#ident "foo"_bar // expected-error {{user-defined suffix cannot be used here}}
+_Pragma("foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#pragma comment(lib, "foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+_Pragma("comment(lib, \"foo\"_bar)") // expected-error {{user-defined suffix cannot be used here}}
+#pragma message "hi"_there // expected-error {{user-defined suffix cannot be used here}} expected-warning {{hi}}
+#pragma push_macro("foo"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#if __has_warning("-Wan-island-to-discover"_bar) // expected-error {{user-defined suffix cannot be used here}}
+#elif __has_include("foo"_bar) // expected-error {{expected "FILENAME" or <FILENAME>}}
+#endif
+
+extern "C++"_x {} // expected-error {{user-defined suffix cannot be used here}} expected-error {{unknown linkage language}}
+
+int f() {
+ asm("mov %eax, %rdx"_foo); // expected-error {{user-defined suffix cannot be used here}}
+}
+
+static_assert(true, "foo"_bar); // expected-error {{user-defined suffix cannot be used here}}
+
+int cake() __attribute__((availability(macosx, unavailable, message = "is a lie"_x))); // expected-error {{user-defined suffix cannot be used here}}
+
+// A ud-suffix cannot be used on character literals in preprocessor constant
+// expressions:
+#if 'x'_y - u'x'_z // expected-error 2{{character literal with user-defined suffix cannot be used in preprocessor constant expression}}
+#error error
+#endif
+
+// A ud-suffix cannot be used on integer literals in preprocessor constant
+// expressions:
+#if 0_foo // expected-error {{integer literal with user-defined suffix cannot be used in preprocessor constant expression}}
+#error error
+#endif
+
+// But they can appear in expressions.
+constexpr char operator"" _id(char c) { return c; }
+constexpr wchar_t operator"" _id(wchar_t c) { return c; }
+constexpr char16_t operator"" _id(char16_t c) { return c; }
+constexpr char32_t operator"" _id(char32_t c) { return c; }
+
+using size_t = decltype(sizeof(int));
+constexpr const char operator"" _id(const char *p, size_t n) { return *p; }
+constexpr const wchar_t operator"" _id(const wchar_t *p, size_t n) { return *p; }
+constexpr const char16_t operator"" _id(const char16_t *p, size_t n) { return *p; }
+constexpr const char32_t operator"" _id(const char32_t *p, size_t n) { return *p; }
+
+constexpr unsigned long long operator"" _id(unsigned long long n) { return n; }
+constexpr long double operator"" _id(long double d) { return d; }
+
+template<int n> struct S {};
+S<"a"_id> sa;
+S<L"b"_id> sb;
+S<u8"c"_id> sc;
+S<u"d"_id> sd;
+S<U"e"_id> se;
+
+S<'w'_id> sw;
+S<L'x'_id> sx;
+S<u'y'_id> sy;
+S<U'z'_id> sz;
+
+S<100_id> sn;
+S<(int)1.3_id> sf;
+
+void h() {
+ (void)"test"_id "test" L"test";
+}
+
+// Test source location for suffix is known
+const char *p =
+ "foo\nbar" R"x(
+ erk
+ flux
+ )x" "eep\x1f"\
+_no_such_suffix // expected-error {{'operator "" _no_such_suffix'}}
+"and a bit more"
+"and another suffix"_no_such_suffix;
+
+char c =
+ '\x14'\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+int &r =
+1234567\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+int k =
+1234567.89\
+_no_such_suffix; // expected-error {{'operator "" _no_such_suffix'}}
+
+// Make sure we handle more interesting ways of writing a string literal which
+// is "" in translation phase 7.
+void operator "\
+" _foo(unsigned long long); // ok
+
+void operator R"xyzzy()xyzzy" _foo(long double); // ok
+
+void operator"" "" R"()" "" _foo(const char *); // ok
+
+// Ensure we diagnose the bad cases.
+void operator "\0" _non_empty(const char *); // expected-error {{must be '""'}}
+void operator ""_no_space(const char *); // expected-error {{C++11 requires a space}}
+void operator L"" _not_char(const char *); // expected-error {{cannot have an encoding prefix}}
+void operator "" ""
+U"" // expected-error {{cannot have an encoding prefix}}
+"" _also_not_char(const char *);
+void operator "" u8"" "\u0123" "hello"_all_of_the_things ""(const char*); // expected-error {{must be '""'}}
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c
index e245adb..a7a01d8 100644
--- a/test/Parser/declarators.c
+++ b/test/Parser/declarators.c
@@ -97,3 +97,6 @@ void *test14b = (void*)test14a; // Make sure test14a didn't get skipped.
// rdar://problem/8358508
long struct X { int x; } test15(); // expected-error {{'long struct' is invalid}}
+
+void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}}
+void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}}
diff --git a/test/Parser/enhanced-proto-1.m b/test/Parser/enhanced-proto-1.m
index a3819f3..fa6e413 100644
--- a/test/Parser/enhanced-proto-1.m
+++ b/test/Parser/enhanced-proto-1.m
@@ -4,7 +4,7 @@
@optional
- (void) FOO;
@optional
-- (void) FOO;
+- (void) FOO1;
@required
- (void) REQ;
@optional
diff --git a/test/Parser/method-def-in-class.m b/test/Parser/method-def-in-class.m
index 490c055..476ab9b 100644
--- a/test/Parser/method-def-in-class.m
+++ b/test/Parser/method-def-in-class.m
@@ -7,19 +7,8 @@
}
@end
-@interface B
--(id) f0 { // expected-error {{expected ';' after method prototype}}
- assert(0);
-@end
-
@interface C
- (id) f0 { // expected-error {{expected ';' after method prototype}}
assert(0);
};
@end
-
-@interface D
-- (id) f0 { // expected-error {{expected ';' after method prototype}}
- assert(0);
-@property int P;
-@end
diff --git a/test/Parser/missing-end-2.m b/test/Parser/missing-end-2.m
index 63dc965..e89f28e 100644
--- a/test/Parser/missing-end-2.m
+++ b/test/Parser/missing-end-2.m
@@ -1,19 +1,19 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar: //7824372
-@interface A
+@interface A // expected-note {{class started here}}
-(void) im0;
-@implementation A // expected-error {{missing @end}}
+@implementation A // expected-error {{missing '@end'}}
@end
-@interface B {
+@interface B { // expected-note {{class started here}}
}
-@implementation B // expected-error {{missing @end}}
+@implementation B // expected-error {{missing '@end'}}
@end
-@interface C
+@interface C // expected-note 2 {{class started here}}
@property int P;
-@implementation C // expected-error 2 {{missing @end}}
+@implementation C // expected-error 2 {{missing '@end'}}
diff --git a/test/Parser/missing-end-3.m b/test/Parser/missing-end-3.m
index 3b22637..4875ecd 100644
--- a/test/Parser/missing-end-3.m
+++ b/test/Parser/missing-end-3.m
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://8283484
-@interface blah {
+@interface blah { // expected-note {{class started here}}
@private
}
// since I forgot the @end here it should say something
-@interface blah // expected-error {{missing @end}}
+@interface blah // expected-error {{missing '@end'}}
@end // and Unknown type name 'end' here
diff --git a/test/Parser/missing-end-4.m b/test/Parser/missing-end-4.m
new file mode 100644
index 0000000..8a96e64
--- /dev/null
+++ b/test/Parser/missing-end-4.m
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface X1
+@end
+@implementation X1 // expected-note {{implementation started here}}
+@interface Y1 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X2
+@end
+@implementation X2 // expected-note {{implementation started here}}
+@protocol Y2 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X6 // expected-note {{class started here}}
+@interface X7 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@protocol P1 // expected-note {{protocol started here}}
+@interface P2 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface X4 // expected-note {{class started here}}
+@implementation X4 // expected-error {{missing '@end'}}
+@end
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@interface I
+@end
+@implementation I
+@protocol P; // forward declarations of protocols in @implementations is allowed
+@class C; // forward declarations of classes in @implementations is allowed
+- (C<P>*) MyMeth {}
+@end
+
+@interface I2 {}
+@protocol P2; // expected-error {{illegal interface qualifier}}
+@class C2; // expected-error {{illegal interface qualifier}}
+@end
+
+@interface I3
+@end
+@implementation I3
+- Meth {}
++ Cls {}
+@protocol P3;
+@end
diff --git a/test/Parser/missing-end.m b/test/Parser/missing-end.m
index fb26461..d66ea64 100644
--- a/test/Parser/missing-end.m
+++ b/test/Parser/missing-end.m
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-@interface AAA
+@interface AAA // expected-note {{class started here}}
{
}
@ x// expected-error{{expected an Objective-C directive after '@'}}
-// expected-error{{missing @end}}
+// expected-error{{missing '@end'}}
diff --git a/test/Parser/objc-category-neg-1.m b/test/Parser/objc-category-neg-1.m
index 5799db0..4aa8bae 100644
--- a/test/Parser/objc-category-neg-1.m
+++ b/test/Parser/objc-category-neg-1.m
@@ -3,6 +3,6 @@
void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__));
static __inline__ int __inline_isfinitef (float ) __attribute__ ((always_inline));
-@interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{ "cannot find interface declaration for 'NSATSTypesetter'" }}
+@interface NSATSTypesetter (NSPantherCompatibility) // expected-error {{cannot find interface declaration for 'NSATSTypesetter'}}
- (id)lineFragmentRectForProposedRect:(id)proposedRect remainingRect:(id)remainingRect __attribute__((deprecated));
@end
diff --git a/test/Parser/objc-forcollection-neg-2.m b/test/Parser/objc-forcollection-neg-2.m
index 6aa74c9..f95dd13 100644
--- a/test/Parser/objc-forcollection-neg-2.m
+++ b/test/Parser/objc-forcollection-neg-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef struct objc_class *Class;
struct __objcFastEnumerationState;
@@ -30,7 +30,7 @@ typedef struct objc_object {
for (id el in self)
++i;
MyList<P> ***p;
- for (p in self) // expected-error {{selector element type 'MyList<P> ***' is not a valid object type}}
+ for (p in self) // expected-error {{selector element type 'MyList<P> ***' is not a valid object}}
++i;
}
diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m
index d896c35..1a989a1 100644
--- a/test/Parser/objc-forcollection-neg.m
+++ b/test/Parser/objc-forcollection-neg.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
struct __objcFastEnumerationState;
typedef struct objc_class *Class;
diff --git a/test/Parser/objc-foreach-syntax.m b/test/Parser/objc-foreach-syntax.m
index cc82725..5d83dc6 100644
--- a/test/Parser/objc-foreach-syntax.m
+++ b/test/Parser/objc-foreach-syntax.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
struct __objcFastEnumerationState;
@implementation MyList // expected-warning {{cannot find interface declaration for 'MyList'}}
diff --git a/test/Parser/objc-init.m b/test/Parser/objc-init.m
index 0748205..efa1266 100644
--- a/test/Parser/objc-init.m
+++ b/test/Parser/objc-init.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify %s -pedantic
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -pedantic -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ -Wno-objc-root-class %s
// rdar://5707001
@interface NSNumber;
@@ -15,7 +15,7 @@ void test1() {
id objects[] = {[NSNumber METH]};
}
-void test2(NSNumber x) { // expected-error {{Objective-C interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
+void test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
id objects[] = {[x METH]};
}
diff --git a/test/Parser/objc-missing-impl.m b/test/Parser/objc-missing-impl.m
index e9c37ab..791b9f80 100644
--- a/test/Parser/objc-missing-impl.m
+++ b/test/Parser/objc-missing-impl.m
@@ -1,2 +1,2 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-@end // expected-error {{@end must appear in an @implementation context}}
+@end // expected-error {{'@end' must appear in an Objective-C context}}
diff --git a/test/Parser/objc-property-syntax.m b/test/Parser/objc-property-syntax.m
index 6ef2ad7..38d12d5 100644
--- a/test/Parser/objc-property-syntax.m
+++ b/test/Parser/objc-property-syntax.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MyClass {
int prop;
diff --git a/test/Parser/objc-quirks.m b/test/Parser/objc-quirks.m
index 591bca2..0bdeb46 100644
--- a/test/Parser/objc-quirks.m
+++ b/test/Parser/objc-quirks.m
@@ -5,9 +5,9 @@ int @"s" = 5; // expected-error {{prefix attribute must be}}
// rdar://6480479
-@interface A
-}; // expected-error {{missing @end}} \
-// expected-error {{expected external declaration}} \
+@interface A // expected-note {{class started here}}
+}; // expected-error {{missing '@end'}} \
+// expected-error {{extraneous closing brace ('}')}} \
// expected-warning{{extra ';' outside of a function}}
diff --git a/test/Parser/objc-synthesized-recover.m b/test/Parser/objc-synthesized-recover.m
index 3f04a8c..c281c21 100644
--- a/test/Parser/objc-synthesized-recover.m
+++ b/test/Parser/objc-synthesized-recover.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface I1
{
diff --git a/test/Parser/objcxx-lambda-expressions-neg.mm b/test/Parser/objcxx-lambda-expressions-neg.mm
index 864cc6b..7cdb1a2 100644
--- a/test/Parser/objcxx-lambda-expressions-neg.mm
+++ b/test/Parser/objcxx-lambda-expressions-neg.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
int main() {
[]{}; // expected-error {{expected expression}}
diff --git a/test/Parser/objcxx0x-lambda-expressions.mm b/test/Parser/objcxx0x-lambda-expressions.mm
index 9374649..1eab15b 100644
--- a/test/Parser/objcxx0x-lambda-expressions.mm
+++ b/test/Parser/objcxx0x-lambda-expressions.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++11 %s
class C {
@@ -11,15 +11,12 @@ class C {
[]; // expected-error {{expected body of lambda expression}}
[=,foo+] {}; // expected-error {{expected ',' or ']' in lambda capture list}}
[&this] {}; // expected-error {{address expression must be an lvalue}}
- [] {};
- [=] (int i) {};
- [&] (int) mutable -> void {};
- // FIXME: this error occurs because we do not yet handle lambda scopes
- // properly. I did not anticipate it because I thought it was a semantic (not
- // syntactic) check.
- [foo,bar] () { return 3; }; // expected-error {{void function 'f' should not return a value}}
- [=,&foo] () {};
- [this] () {};
+ [] {};
+ [=] (int i) {};
+ [&] (int) mutable -> void {};
+ [foo,bar] () { return 3; };
+ [=,&foo] () {};
+ [this] () {};
}
};
diff --git a/test/Parser/objcxx11-attributes.mm b/test/Parser/objcxx11-attributes.mm
new file mode 100644
index 0000000..0875b66
--- /dev/null
+++ b/test/Parser/objcxx11-attributes.mm
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+@interface X {}
++ (X*) alloc;
+- (X*) init;
+- (int) getSize;
+- (void) setSize: (int) size;
+- (X*) getSelf;
+@end
+
+void f(X *noreturn) {
+ // An array size which is computed by a message send is OK.
+ int a[ [noreturn getSize] ];
+
+ // ... but is interpreted as an attribute where possible.
+ int b[ [noreturn] ]; // expected-warning {{'noreturn' only applies to function types}}
+
+ int c[ [noreturn getSize] + 1 ];
+
+ // An array size which is computed by a lambda is not OK.
+ int d[ [noreturn] { return 3; } () ]; // expected-error {{expected ']'}} expected-warning {{'noreturn' only applies}}
+
+ // A message send which contains a message send is OK.
+ [ [ X alloc ] init ];
+ [ [ int(), noreturn getSelf ] getSize ]; // expected-warning {{unused}}
+
+ // A message send which contains a lambda is OK.
+ [ [noreturn] { return noreturn; } () setSize: 4 ];
+ [ [bitand] { return noreturn; } () setSize: 5 ];
+ [[[[] { return [ X alloc ]; } () init] getSelf] getSize];
+
+ // An attribute is OK.
+ [[]];
+ [[int(), noreturn]];
+ [[class, test(foo 'x' bar),,,]];
+ [[bitand, noreturn]];
+
+ [[noreturn]]int(e)();
+
+ // A function taking a noreturn function.
+ int(f)([[noreturn]] int());
+ f(e);
+
+ // Variables initialized by a message send.
+ int(g)([[noreturn getSelf] getSize]);
+ int(h)([[noreturn]{return noreturn;}() getSize]);
+
+ int i = g + h;
+}
+
+template<typename...Ts> void f(Ts ...x) {
+ [[test::foo(bar, baz)...]];
+ [[used(x)...]];
+ [[x...] { return [ X alloc ]; }() init];
+}
diff --git a/test/Parser/objcxx11-user-defined-literal.mm b/test/Parser/objcxx11-user-defined-literal.mm
new file mode 100644
index 0000000..a5f1397
--- /dev/null
+++ b/test/Parser/objcxx11-user-defined-literal.mm
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+id x = @"foo"_bar; // expected-error{{user-defined suffix cannot be used here}}
diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c
index 0747aec..3916acf 100644
--- a/test/Parser/recovery.c
+++ b/test/Parser/recovery.c
@@ -16,7 +16,7 @@ static void f (char * (*g) (char **, int), char **p, ...) {
// PR3172
-} // expected-error {{expected external declaration}}
+} // expected-error {{extraneous closing brace ('}')}}
// rdar://6094870
@@ -49,7 +49,7 @@ void test(int a) {
char (((( /* expected-note {{to match this '('}} */
*X x ] )))); /* expected-error {{expected ')'}} */
-; // expected-warning {{ISO C does not allow an extra ';' outside of a function}}
+; // expected-warning {{extra ';' outside of a function}}
diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp
new file mode 100644
index 0000000..ffa1bab
--- /dev/null
+++ b/test/Parser/recovery.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang -cc1 -verify -std=c++11 %s
+
+8gi///===--- recovery.cpp ---===// // expected-error {{unqualified-id}}
+namespace Std { // expected-note {{here}}
+ typedef int Important;
+}
+
+/ redeclare as an inline namespace // expected-error {{unqualified-id}}
+inline namespace Std { // expected-error {{cannot be reopened as inline}}
+ Important n;
+} / end namespace Std // expected-error {{unqualified-id}}
+int x;
+Std::Important y;
+
+// FIXME: Recover as if the typo correction were applied.
+extenr "C" { // expected-error {{did you mean 'extern'}} expected-error {{unqualified-id}}
+ void f();
+}
+void g() {
+ z = 1; // expected-error {{undeclared}}
+ f(); // expected-error {{undeclared}}
+}
+
+struct S {
+ int a, b, c;
+ S();
+};
+8S::S() : a{ 5 }, b{ 6 }, c{ 2 } { // expected-error {{unqualified-id}}
+ return;
+}
+int k;
+int l = k;
+
+5int m = { l }, n = m; // expected-error {{unqualified-id}}
+
+namespace N {
+ int
+} // expected-error {{unqualified-id}}
+
+// FIXME: Recover as if the typo correction were applied.
+strcut U { // expected-error {{did you mean 'struct'}}
+} *u[3]; // expected-error {{expected ';'}}
diff --git a/test/Parser/skip-function-bodies.mm b/test/Parser/skip-function-bodies.mm
new file mode 100644
index 0000000..8462f69
--- /dev/null
+++ b/test/Parser/skip-function-bodies.mm
@@ -0,0 +1,45 @@
+// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s | FileCheck %s
+
+class A {
+ class B {};
+
+public:
+ A() {
+ struct C {
+ void d() {}
+ };
+ }
+
+ typedef B E;
+};
+
+@interface F
+- (void) G;
+@end
+@implementation F
+- (void) G {
+ typedef A H;
+ class I {};
+}
+@end
+
+void J() {
+ class K {};
+}
+
+// CHECK: skip-function-bodies.mm:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 14:2]
+// CHECK: skip-function-bodies.mm:4:9: ClassDecl=B:4:9 (Definition) Extent=[4:3 - 4:13]
+// CHECK: skip-function-bodies.mm:6:1: CXXAccessSpecifier=:6:1 (Definition) Extent=[6:1 - 6:8]
+// CHECK: skip-function-bodies.mm:7:3: CXXConstructor=A:7:3 Extent=[7:3 - 7:6]
+// CHECK-NOT: skip-function-bodies.mm:8:12: StructDecl=C:8:12 (Definition) Extent=[8:5 - 10:6]
+// CHECK-NOT: skip-function-bodies.mm:9:12: CXXMethod=d:9:12 (Definition) Extent=[9:7 - 9:18]
+// CHECK: skip-function-bodies.mm:13:13: TypedefDecl=E:13:13 (Definition) Extent=[13:3 - 13:14]
+// CHECK: skip-function-bodies.mm:13:11: TypeRef=class A::B:4:9 Extent=[13:11 - 13:12]
+// CHECK: skip-function-bodies.mm:16:12: ObjCInterfaceDecl=F:16:12 Extent=[16:1 - 18:5]
+// CHECK: skip-function-bodies.mm:17:10: ObjCInstanceMethodDecl=G:17:10 Extent=[17:1 - 17:12]
+// CHECK: skip-function-bodies.mm:19:17: ObjCImplementationDecl=F:19:17 (Definition) Extent=[19:1 - 24:2]
+// CHECK: skip-function-bodies.mm:20:10: ObjCInstanceMethodDecl=G:20:10 Extent=[20:1 - 20:13]
+// CHECK-NOT: skip-function-bodies.mm:21:13: TypedefDecl=H:21:13 (Definition) Extent=[21:3 - 21:14]
+// CHECK-NOT: skip-function-bodies.mm:21:11: TypeRef=class A:3:7 Extent=[21:11 - 21:12]
+// CHECK: skip-function-bodies.mm:26:6: FunctionDecl=J:26:6 Extent=[26:1 - 26:9]
+// CHECK-NOT: skip-function-bodies.mm:27:9: ClassDecl=K:27:9 (Definition) Extent=[27:3 - 27:13]
diff --git a/test/Parser/statements.c b/test/Parser/statements.c
index bc7192a..3a123d6 100644
--- a/test/Parser/statements.c
+++ b/test/Parser/statements.c
@@ -31,20 +31,20 @@ void test3() {
}
void test4() {
- if (0); // expected-warning {{if statement has empty body}}
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
int X; // declaration in a block.
-foo: if (0); // expected-warning {{if statement has empty body}}
+foo: if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
}
typedef int t;
void test5() {
- if (0); // expected-warning {{if statement has empty body}}
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
t x = 0;
- if (0); // expected-warning {{if statement has empty body}}
+ if (0); // expected-warning {{if statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
}
diff --git a/test/Parser/warn-dangling-else.cpp b/test/Parser/warn-dangling-else.cpp
new file mode 100644
index 0000000..e91af98
--- /dev/null
+++ b/test/Parser/warn-dangling-else.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wdangling-else %s
+
+void f(int a, int b, int c, int d, int e) {
+
+ // should warn
+ { if (a) if (b) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) while (b) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) switch (b) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) for (;;) if (c) d++; else e++; } // expected-warning {{add explicit braces to avoid dangling else}}
+ { if (a) if (b) if (d) d++; else e++; else d--; } // expected-warning {{add explicit braces to avoid dangling else}}
+
+ if (a)
+ if (b) {
+ d++;
+ } else e++; // expected-warning {{add explicit braces to avoid dangling else}}
+
+ // shouldn't
+ { if (a) if (b) d++; }
+ { if (a) if (b) if (c) d++; }
+ { if (a) if (b) d++; else e++; else d--; }
+ { if (a) if (b) if (d) d++; else e++; else d--; else e--; }
+ { if (a) do if (b) d++; else e++; while (c); }
+
+ if (a) {
+ if (b) d++;
+ else e++;
+ }
+
+ if (a) {
+ if (b) d++;
+ } else e++;
+}
+
+// Somewhat more elaborate case that shouldn't warn.
+class A {
+ public:
+ void operator<<(const char* s) {}
+};
+
+void HandleDisabledThing() {}
+A GetThing() { return A(); }
+
+#define FOO(X) \
+ switch (0) default: \
+ if (!(X)) \
+ HandleDisabledThing(); \
+ else \
+ GetThing()
+
+void f(bool cond) {
+ int x = 0;
+ if (cond)
+ FOO(x) << "hello"; // no warning
+}
+
diff --git a/test/Preprocessor/Inputs/TestFramework.framework/.system_framework b/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Preprocessor/Inputs/TestFramework.framework/.system_framework
diff --git a/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h b/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
new file mode 100644
index 0000000..489f17a
--- /dev/null
+++ b/test/Preprocessor/Inputs/TestFramework.framework/Frameworks/AnotherTestFramework.framework/Headers/AnotherTestFramework.h
@@ -0,0 +1,3 @@
+static inline int another_test_framework_func(unsigned a) {
+ return a;
+}
diff --git a/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h b/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
new file mode 100644
index 0000000..06f9ab5
--- /dev/null
+++ b/test/Preprocessor/Inputs/TestFramework.framework/Headers/TestFramework.h
@@ -0,0 +1,6 @@
+// Include a subframework header.
+#include <AnotherTestFramework/AnotherTestFramework.h>
+
+static inline int test_framework_func(unsigned a) {
+ return a;
+}
diff --git a/test/Preprocessor/_Pragma-in-macro-arg.c b/test/Preprocessor/_Pragma-in-macro-arg.c
new file mode 100644
index 0000000..2877bcb
--- /dev/null
+++ b/test/Preprocessor/_Pragma-in-macro-arg.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -verify -Wconversion
+
+// Don't crash (rdar://11168596)
+#define A(desc) _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wparentheses\"") _Pragma("clang diagnostic pop")
+#define B(desc) A(desc)
+B(_Pragma("clang diagnostic ignored \"-Wparentheses\""))
+
+
+#define EMPTY(x)
+#define INACTIVE(x) EMPTY(x)
+
+#define ID(x) x
+#define ACTIVE(x) ID(x)
+
+// This should be ignored..
+INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
+
+#define IGNORE_CONV _Pragma("clang diagnostic ignored \"-Wconversion\"") _Pragma("clang diagnostic ignored \"-Wconversion\"")
+
+// ..as should this.
+INACTIVE(IGNORE_CONV)
+
+#define IGNORE_POPPUSH(Pop, Push, W, D) Push W D Pop
+IGNORE_POPPUSH(_Pragma("clang diagnostic pop"), _Pragma("clang diagnostic push"),
+ _Pragma("clang diagnostic ignored \"-Wconversion\""), int q = (double)1.0);
+
+int x1 = (double)1.0; // expected-warning {{implicit conversion}}
+
+ACTIVE(_Pragma) ("clang diagnostic ignored \"-Wconversion\"")) // expected-error {{_Pragma takes a parenthesized string literal}} \
+ expected-error {{expected identifier or '('}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+
+// This should disable the warning.
+ACTIVE(IGNORE_CONV)
+
+int x2 = (double)1.0;
diff --git a/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp b/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp
new file mode 100644
index 0000000..1c6ef90
--- /dev/null
+++ b/test/Preprocessor/cxx_oper_keyword_ms_compat.cpp
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 %s -E -fms-compatibility
+
+bool f() {
+ // Check that operators still work before redefining them.
+#if compl 0 bitand 1
+ return true and false;
+#endif
+}
+
+// All c++ keywords should be #define-able in ms mode.
+// (operators like "and" aren't normally, the rest always is.)
+#define and
+#define and_eq
+#define alignas
+#define alignof
+#define asm
+#define auto
+#define bitand
+#define bitor
+#define bool
+#define break
+#define case
+#define catch
+#define char
+#define char16_t
+#define char32_t
+#define class
+#define compl
+#define const
+#define constexpr
+#define const_cast
+#define continue
+#define decltype
+#define default
+#define delete
+#define double
+#define dynamic_cast
+#define else
+#define enum
+#define explicit
+#define export
+#define extern
+#define false
+#define float
+#define for
+#define friend
+#define goto
+#define if
+#define inline
+#define int
+#define long
+#define mutable
+#define namespace
+#define new
+#define noexcept
+#define not
+#define not_eq
+#define nullptr
+#define operator
+#define or
+#define or_eq
+#define private
+#define protected
+#define public
+#define register
+#define reinterpret_cast
+#define return
+#define short
+#define signed
+#define sizeof
+#define static
+#define static_assert
+#define static_cast
+#define struct
+#define switch
+#define template
+#define this
+#define thread_local
+#define throw
+#define true
+#define try
+#define typedef
+#define typeid
+#define typename
+#define union
+#define unsigned
+#define using
+#define virtual
+#define void
+#define volatile
+#define wchar_t
+#define while
+#define xor
+#define xor_eq
+
+// Check this is all properly defined away.
+and
+and_eq
+alignas
+alignof
+asm
+auto
+bitand
+bitor
+bool
+break
+case
+catch
+char
+char16_t
+char32_t
+class
+compl
+const
+constexpr
+const_cast
+continue
+decltype
+default
+delete
+double
+dynamic_cast
+else
+enum
+explicit
+export
+extern
+false
+float
+for
+friend
+goto
+if
+inline
+int
+long
+mutable
+namespace
+new
+noexcept
+not
+not_eq
+nullptr
+operator
+or
+or_eq
+private
+protected
+public
+register
+reinterpret_cast
+return
+short
+signed
+sizeof
+static
+static_assert
+static_cast
+struct
+switch
+template
+this
+thread_local
+throw
+true
+try
+typedef
+typeid
+typename
+union
+unsigned
+using
+virtual
+void
+volatile
+wchar_t
+while
+xor
+xor_eq
diff --git a/test/Preprocessor/feature_tests.c b/test/Preprocessor/feature_tests.c
index 35592bd..b78a251 100644
--- a/test/Preprocessor/feature_tests.c
+++ b/test/Preprocessor/feature_tests.c
@@ -12,6 +12,7 @@
#if !__has_builtin(__builtin_huge_val) || \
!__has_builtin(__builtin_shufflevector) || \
!__has_builtin(__builtin_trap) || \
+ !__has_builtin(__c11_atomic_init) || \
!__has_feature(attribute_analyzer_noreturn) || \
!__has_feature(attribute_overloadable)
#error Clang should have these
@@ -21,7 +22,9 @@
#error Clang should not have this
#endif
-
+#if !__has_feature(__attribute_deprecated_with_message__)
+#error Feature name in double underscores does not work
+#endif
// Make sure we have x86 builtins only (forced with target triple).
diff --git a/test/Preprocessor/has_attribute.c b/test/Preprocessor/has_attribute.c
new file mode 100644
index 0000000..80f53a5
--- /dev/null
+++ b/test/Preprocessor/has_attribute.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+// CHECK: always_inline
+#if __has_attribute(always_inline)
+int always_inline();
+#endif
+
+// CHECK: __always_inline__
+#if __has_attribute(__always_inline__)
+int __always_inline__();
+#endif
+
+// CHECK: no_dummy_attribute
+#if !__has_attribute(dummy_attribute)
+int no_dummy_attribute();
+#endif
+
+// CHECK: has_has_attribute
+#ifdef __has_attribute
+int has_has_attribute();
+#endif
+
+// CHECK: has_something_we_dont_have
+#if !__has_attribute(something_we_dont_have)
+int has_something_we_dont_have();
+#endif
diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c
index 1121815..e0f45f1 100644
--- a/test/Preprocessor/init.c
+++ b/test/Preprocessor/init.c
@@ -212,111 +212,14 @@
// ARM:#define __THUMB_INTERWORK__ 1
// ARM:#define __UINTMAX_TYPE__ long long unsigned int
// ARM:#define __USER_LABEL_PREFIX__ _
-// ARM:#define __WCHAR_MAX__ 2147483647
-// ARM:#define __WCHAR_TYPE__ int
+// ARM:#define __WCHAR_MAX__ 4294967295U
+// ARM:#define __WCHAR_TYPE__ unsigned int
// ARM:#define __WCHAR_WIDTH__ 32
// ARM:#define __WINT_TYPE__ int
// ARM:#define __WINT_WIDTH__ 32
// ARM:#define __arm 1
// ARM:#define __arm__ 1
//
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=bfin-none-none < /dev/null | FileCheck -check-prefix BFIN %s
-//
-// BFIN:#define BFIN 1
-// BFIN:#define __ADSPBLACKFIN__ 1
-// BFIN:#define __ADSPLPBLACKFIN__ 1
-// BFIN:#define __BFIN 1
-// BFIN:#define __BFIN__ 1
-// BFIN:#define __CHAR16_TYPE__ unsigned short
-// BFIN:#define __CHAR32_TYPE__ unsigned int
-// BFIN:#define __CHAR_BIT__ 8
-// BFIN:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// BFIN:#define __DBL_DIG__ 15
-// BFIN:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// BFIN:#define __DBL_HAS_DENORM__ 1
-// BFIN:#define __DBL_HAS_INFINITY__ 1
-// BFIN:#define __DBL_HAS_QUIET_NAN__ 1
-// BFIN:#define __DBL_MANT_DIG__ 53
-// BFIN:#define __DBL_MAX_10_EXP__ 308
-// BFIN:#define __DBL_MAX_EXP__ 1024
-// BFIN:#define __DBL_MAX__ 1.7976931348623157e+308
-// BFIN:#define __DBL_MIN_10_EXP__ (-307)
-// BFIN:#define __DBL_MIN_EXP__ (-1021)
-// BFIN:#define __DBL_MIN__ 2.2250738585072014e-308
-// BFIN:#define __DECIMAL_DIG__ 17
-// BFIN:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// BFIN:#define __FLT_DIG__ 6
-// BFIN:#define __FLT_EPSILON__ 1.19209290e-7F
-// BFIN:#define __FLT_EVAL_METHOD__ 0
-// BFIN:#define __FLT_HAS_DENORM__ 1
-// BFIN:#define __FLT_HAS_INFINITY__ 1
-// BFIN:#define __FLT_HAS_QUIET_NAN__ 1
-// BFIN:#define __FLT_MANT_DIG__ 24
-// BFIN:#define __FLT_MAX_10_EXP__ 38
-// BFIN:#define __FLT_MAX_EXP__ 128
-// BFIN:#define __FLT_MAX__ 3.40282347e+38F
-// BFIN:#define __FLT_MIN_10_EXP__ (-37)
-// BFIN:#define __FLT_MIN_EXP__ (-125)
-// BFIN:#define __FLT_MIN__ 1.17549435e-38F
-// BFIN:#define __FLT_RADIX__ 2
-// BFIN:#define __INT16_TYPE__ short
-// BFIN:#define __INT32_TYPE__ int
-// BFIN:#define __INT64_C_SUFFIX__ LL
-// BFIN:#define __INT64_TYPE__ long long int
-// BFIN:#define __INT8_TYPE__ char
-// BFIN:#define __INTMAX_MAX__ 9223372036854775807LL
-// BFIN:#define __INTMAX_TYPE__ long long int
-// BFIN:#define __INTMAX_WIDTH__ 64
-// BFIN:#define __INTPTR_TYPE__ long int
-// BFIN:#define __INTPTR_WIDTH__ 32
-// BFIN:#define __INT_MAX__ 2147483647
-// BFIN:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// BFIN:#define __LDBL_DIG__ 15
-// BFIN:#define __LDBL_EPSILON__ 2.2204460492503131e-16
-// BFIN:#define __LDBL_HAS_DENORM__ 1
-// BFIN:#define __LDBL_HAS_INFINITY__ 1
-// BFIN:#define __LDBL_HAS_QUIET_NAN__ 1
-// BFIN:#define __LDBL_MANT_DIG__ 53
-// BFIN:#define __LDBL_MAX_10_EXP__ 308
-// BFIN:#define __LDBL_MAX_EXP__ 1024
-// BFIN:#define __LDBL_MAX__ 1.7976931348623157e+308
-// BFIN:#define __LDBL_MIN_10_EXP__ (-307)
-// BFIN:#define __LDBL_MIN_EXP__ (-1021)
-// BFIN:#define __LDBL_MIN__ 2.2250738585072014e-308
-// BFIN:#define __LONG_LONG_MAX__ 9223372036854775807LL
-// BFIN:#define __LONG_MAX__ 2147483647L
-// BFIN:#define __NO_INLINE__ 1
-// BFIN:#define __POINTER_WIDTH__ 32
-// BFIN:#define __PTRDIFF_TYPE__ long int
-// BFIN:#define __PTRDIFF_WIDTH__ 32
-// BFIN:#define __SCHAR_MAX__ 127
-// BFIN:#define __SHRT_MAX__ 32767
-// BFIN:#define __SIG_ATOMIC_WIDTH__ 32
-// BFIN:#define __SIZEOF_DOUBLE__ 8
-// BFIN:#define __SIZEOF_FLOAT__ 4
-// BFIN:#define __SIZEOF_INT__ 4
-// BFIN:#define __SIZEOF_LONG_DOUBLE__ 8
-// BFIN:#define __SIZEOF_LONG_LONG__ 8
-// BFIN:#define __SIZEOF_LONG__ 4
-// BFIN:#define __SIZEOF_POINTER__ 4
-// BFIN:#define __SIZEOF_PTRDIFF_T__ 4
-// BFIN:#define __SIZEOF_SHORT__ 2
-// BFIN:#define __SIZEOF_SIZE_T__ 4
-// BFIN:#define __SIZEOF_WCHAR_T__ 4
-// BFIN:#define __SIZEOF_WINT_T__ 4
-// BFIN:#define __SIZE_TYPE__ long unsigned int
-// BFIN:#define __SIZE_WIDTH__ 32
-// BFIN:#define __UINTMAX_TYPE__ long long unsigned int
-// BFIN:#define __USER_LABEL_PREFIX__ _
-// BFIN:#define __WCHAR_MAX__ 2147483647
-// BFIN:#define __WCHAR_TYPE__ int
-// BFIN:#define __WCHAR_WIDTH__ 32
-// BFIN:#define __WINT_TYPE__ int
-// BFIN:#define __WINT_WIDTH__ 32
-// BFIN:#define __bfin 1
-// BFIN:#define __bfin__ 1
-// BFIN:#define bfin 1
-//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-none-none < /dev/null | FileCheck -check-prefix I386 %s
//
// I386:#define __CHAR16_TYPE__ unsigned short
@@ -339,7 +242,7 @@
// I386:#define __FLT_DENORM_MIN__ 1.40129846e-45F
// I386:#define __FLT_DIG__ 6
// I386:#define __FLT_EPSILON__ 1.19209290e-7F
-// I386:#define __FLT_EVAL_METHOD__ 0
+// I386:#define __FLT_EVAL_METHOD__ 2
// I386:#define __FLT_HAS_DENORM__ 1
// I386:#define __FLT_HAS_INFINITY__ 1
// I386:#define __FLT_HAS_QUIET_NAN__ 1
@@ -412,7 +315,7 @@
// I386:#define __i386__ 1
// I386:#define i386 1
//
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu < /dev/null | FileCheck -check-prefix I386-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck -check-prefix I386-LINUX %s
//
// I386-LINUX:#define __CHAR16_TYPE__ unsigned short
// I386-LINUX:#define __CHAR32_TYPE__ unsigned int
@@ -507,6 +410,462 @@
// I386-LINUX:#define __i386__ 1
// I386-LINUX:#define i386 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips-none-none < /dev/null | FileCheck -check-prefix MIPS32BE %s
+//
+// MIPS32BE:#define MIPSEB 1
+// MIPS32BE:#define _ABIO32 1
+// MIPS32BE:#define _MIPSEB 1
+// MIPS32BE:#define _MIPS_SIM _ABIO32
+// MIPS32BE:#define _MIPS_SZINT 32
+// MIPS32BE:#define _MIPS_SZLONG 32
+// MIPS32BE:#define _MIPS_SZPTR 32
+// MIPS32BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS32BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS32BE:#define __CHAR_BIT__ 8
+// MIPS32BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __DBL_DIG__ 15
+// MIPS32BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __DBL_HAS_DENORM__ 1
+// MIPS32BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __DBL_MANT_DIG__ 53
+// MIPS32BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __DBL_MAX_EXP__ 1024
+// MIPS32BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __DECIMAL_DIG__ 17
+// MIPS32BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32BE:#define __FLT_DIG__ 6
+// MIPS32BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS32BE:#define __FLT_HAS_DENORM__ 1
+// MIPS32BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS32BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __FLT_MANT_DIG__ 24
+// MIPS32BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS32BE:#define __FLT_MAX_EXP__ 128
+// MIPS32BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS32BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32BE:#define __FLT_RADIX__ 2
+// MIPS32BE:#define __INT16_TYPE__ short
+// MIPS32BE:#define __INT32_TYPE__ int
+// MIPS32BE:#define __INT64_C_SUFFIX__ LL
+// MIPS32BE:#define __INT64_TYPE__ long long int
+// MIPS32BE:#define __INT8_TYPE__ char
+// MIPS32BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __INTMAX_TYPE__ long long int
+// MIPS32BE:#define __INTMAX_WIDTH__ 64
+// MIPS32BE:#define __INTPTR_TYPE__ long int
+// MIPS32BE:#define __INTPTR_WIDTH__ 32
+// MIPS32BE:#define __INT_MAX__ 2147483647
+// MIPS32BE:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32BE:#define __LDBL_DIG__ 15
+// MIPS32BE:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS32BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32BE:#define __LDBL_MANT_DIG__ 53
+// MIPS32BE:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32BE:#define __LDBL_MAX_EXP__ 1024
+// MIPS32BE:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32BE:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32BE:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32BE:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32BE:#define __LONG_MAX__ 2147483647L
+// MIPS32BE:#define __MIPSEB 1
+// MIPS32BE:#define __MIPSEB__ 1
+// MIPS32BE:#define __NO_INLINE__ 1
+// MIPS32BE:#define __POINTER_WIDTH__ 32
+// MIPS32BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32BE:#define __PTRDIFF_TYPE__ int
+// MIPS32BE:#define __PTRDIFF_WIDTH__ 32
+// MIPS32BE:#define __REGISTER_PREFIX__
+// MIPS32BE:#define __SCHAR_MAX__ 127
+// MIPS32BE:#define __SHRT_MAX__ 32767
+// MIPS32BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_FLOAT__ 4
+// MIPS32BE:#define __SIZEOF_INT__ 4
+// MIPS32BE:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32BE:#define __SIZEOF_LONG__ 4
+// MIPS32BE:#define __SIZEOF_POINTER__ 4
+// MIPS32BE:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32BE:#define __SIZEOF_SHORT__ 2
+// MIPS32BE:#define __SIZEOF_SIZE_T__ 4
+// MIPS32BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32BE:#define __SIZEOF_WINT_T__ 4
+// MIPS32BE:#define __SIZE_TYPE__ unsigned int
+// MIPS32BE:#define __SIZE_WIDTH__ 32
+// MIPS32BE:#define __STDC_HOSTED__ 0
+// MIPS32BE:#define __STDC_VERSION__ 199901L
+// MIPS32BE:#define __STDC__ 1
+// MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32BE:#define __USER_LABEL_PREFIX__ _
+// MIPS32BE:#define __WCHAR_MAX__ 2147483647
+// MIPS32BE:#define __WCHAR_TYPE__ int
+// MIPS32BE:#define __WCHAR_WIDTH__ 32
+// MIPS32BE:#define __WINT_TYPE__ int
+// MIPS32BE:#define __WINT_WIDTH__ 32
+// MIPS32BE:#define __clang__ 1
+// MIPS32BE:#define __llvm__ 1
+// MIPS32BE:#define __mips 1
+// MIPS32BE:#define __mips__ 1
+// MIPS32BE:#define __mips_hard_float 1
+// MIPS32BE:#define __mips_o32 1
+// MIPS32BE:#define _mips 1
+// MIPS32BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mipsel-none-none < /dev/null | FileCheck -check-prefix MIPS32EL %s
+//
+// MIPS32EL:#define MIPSEL 1
+// MIPS32EL:#define _ABIO32 1
+// MIPS32EL:#define _MIPSEL 1
+// MIPS32EL:#define _MIPS_SIM _ABIO32
+// MIPS32EL:#define _MIPS_SZINT 32
+// MIPS32EL:#define _MIPS_SZLONG 32
+// MIPS32EL:#define _MIPS_SZPTR 32
+// MIPS32EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS32EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS32EL:#define __CHAR_BIT__ 8
+// MIPS32EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS32EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __DBL_DIG__ 15
+// MIPS32EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __DBL_HAS_DENORM__ 1
+// MIPS32EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __DBL_MANT_DIG__ 53
+// MIPS32EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __DBL_MAX_EXP__ 1024
+// MIPS32EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __DECIMAL_DIG__ 17
+// MIPS32EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS32EL:#define __FLT_DIG__ 6
+// MIPS32EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS32EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS32EL:#define __FLT_HAS_DENORM__ 1
+// MIPS32EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS32EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __FLT_MANT_DIG__ 24
+// MIPS32EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS32EL:#define __FLT_MAX_EXP__ 128
+// MIPS32EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS32EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS32EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS32EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS32EL:#define __FLT_RADIX__ 2
+// MIPS32EL:#define __INT16_TYPE__ short
+// MIPS32EL:#define __INT32_TYPE__ int
+// MIPS32EL:#define __INT64_C_SUFFIX__ LL
+// MIPS32EL:#define __INT64_TYPE__ long long int
+// MIPS32EL:#define __INT8_TYPE__ char
+// MIPS32EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __INTMAX_TYPE__ long long int
+// MIPS32EL:#define __INTMAX_WIDTH__ 64
+// MIPS32EL:#define __INTPTR_TYPE__ long int
+// MIPS32EL:#define __INTPTR_WIDTH__ 32
+// MIPS32EL:#define __INT_MAX__ 2147483647
+// MIPS32EL:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS32EL:#define __LDBL_DIG__ 15
+// MIPS32EL:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// MIPS32EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS32EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS32EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS32EL:#define __LDBL_MANT_DIG__ 53
+// MIPS32EL:#define __LDBL_MAX_10_EXP__ 308
+// MIPS32EL:#define __LDBL_MAX_EXP__ 1024
+// MIPS32EL:#define __LDBL_MAX__ 1.7976931348623157e+308
+// MIPS32EL:#define __LDBL_MIN_10_EXP__ (-307)
+// MIPS32EL:#define __LDBL_MIN_EXP__ (-1021)
+// MIPS32EL:#define __LDBL_MIN__ 2.2250738585072014e-308
+// MIPS32EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS32EL:#define __LONG_MAX__ 2147483647L
+// MIPS32EL:#define __MIPSEL 1
+// MIPS32EL:#define __MIPSEL__ 1
+// MIPS32EL:#define __NO_INLINE__ 1
+// MIPS32EL:#define __POINTER_WIDTH__ 32
+// MIPS32EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS32EL:#define __PTRDIFF_TYPE__ int
+// MIPS32EL:#define __PTRDIFF_WIDTH__ 32
+// MIPS32EL:#define __REGISTER_PREFIX__
+// MIPS32EL:#define __SCHAR_MAX__ 127
+// MIPS32EL:#define __SHRT_MAX__ 32767
+// MIPS32EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS32EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_FLOAT__ 4
+// MIPS32EL:#define __SIZEOF_INT__ 4
+// MIPS32EL:#define __SIZEOF_LONG_DOUBLE__ 8
+// MIPS32EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS32EL:#define __SIZEOF_LONG__ 4
+// MIPS32EL:#define __SIZEOF_POINTER__ 4
+// MIPS32EL:#define __SIZEOF_PTRDIFF_T__ 4
+// MIPS32EL:#define __SIZEOF_SHORT__ 2
+// MIPS32EL:#define __SIZEOF_SIZE_T__ 4
+// MIPS32EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS32EL:#define __SIZEOF_WINT_T__ 4
+// MIPS32EL:#define __SIZE_TYPE__ unsigned int
+// MIPS32EL:#define __SIZE_WIDTH__ 32
+// MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS32EL:#define __USER_LABEL_PREFIX__ _
+// MIPS32EL:#define __WCHAR_MAX__ 2147483647
+// MIPS32EL:#define __WCHAR_TYPE__ int
+// MIPS32EL:#define __WCHAR_WIDTH__ 32
+// MIPS32EL:#define __WINT_TYPE__ int
+// MIPS32EL:#define __WINT_WIDTH__ 32
+// MIPS32EL:#define __clang__ 1
+// MIPS32EL:#define __llvm__ 1
+// MIPS32EL:#define __mips 1
+// MIPS32EL:#define __mips__ 1
+// MIPS32EL:#define __mips_hard_float 1
+// MIPS32EL:#define __mips_o32 1
+// MIPS32EL:#define _mips 1
+// MIPS32EL:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-none-none < /dev/null | FileCheck -check-prefix MIPS64BE %s
+//
+// MIPS64BE:#define MIPSEB 1
+// MIPS64BE:#define _ABI64 3
+// MIPS64BE:#define _MIPSEB 1
+// MIPS64BE:#define _MIPS_SIM _ABI64
+// MIPS64BE:#define _MIPS_SZINT 32
+// MIPS64BE:#define _MIPS_SZLONG 64
+// MIPS64BE:#define _MIPS_SZPTR 64
+// MIPS64BE:#define __CHAR16_TYPE__ unsigned short
+// MIPS64BE:#define __CHAR32_TYPE__ unsigned int
+// MIPS64BE:#define __CHAR_BIT__ 8
+// MIPS64BE:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64BE:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64BE:#define __DBL_DIG__ 15
+// MIPS64BE:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64BE:#define __DBL_HAS_DENORM__ 1
+// MIPS64BE:#define __DBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __DBL_MANT_DIG__ 53
+// MIPS64BE:#define __DBL_MAX_10_EXP__ 308
+// MIPS64BE:#define __DBL_MAX_EXP__ 1024
+// MIPS64BE:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64BE:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64BE:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64BE:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64BE:#define __DECIMAL_DIG__ 36
+// MIPS64BE:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64BE:#define __FLT_DIG__ 6
+// MIPS64BE:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64BE:#define __FLT_EVAL_METHOD__ 0
+// MIPS64BE:#define __FLT_HAS_DENORM__ 1
+// MIPS64BE:#define __FLT_HAS_INFINITY__ 1
+// MIPS64BE:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __FLT_MANT_DIG__ 24
+// MIPS64BE:#define __FLT_MAX_10_EXP__ 38
+// MIPS64BE:#define __FLT_MAX_EXP__ 128
+// MIPS64BE:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64BE:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64BE:#define __FLT_MIN_EXP__ (-125)
+// MIPS64BE:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64BE:#define __FLT_RADIX__ 2
+// MIPS64BE:#define __INT16_TYPE__ short
+// MIPS64BE:#define __INT32_TYPE__ int
+// MIPS64BE:#define __INT64_C_SUFFIX__ LL
+// MIPS64BE:#define __INT64_TYPE__ long long int
+// MIPS64BE:#define __INT8_TYPE__ char
+// MIPS64BE:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __INTMAX_TYPE__ long long int
+// MIPS64BE:#define __INTMAX_WIDTH__ 64
+// MIPS64BE:#define __INTPTR_TYPE__ long int
+// MIPS64BE:#define __INTPTR_WIDTH__ 64
+// MIPS64BE:#define __INT_MAX__ 2147483647
+// MIPS64BE:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64BE:#define __LDBL_DIG__ 33
+// MIPS64BE:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64BE:#define __LDBL_HAS_DENORM__ 1
+// MIPS64BE:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64BE:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64BE:#define __LDBL_MANT_DIG__ 113
+// MIPS64BE:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64BE:#define __LDBL_MAX_EXP__ 16384
+// MIPS64BE:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64BE:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64BE:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64BE:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64BE:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64BE:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64BE:#define __MIPSEB 1
+// MIPS64BE:#define __MIPSEB__ 1
+// MIPS64BE:#define __NO_INLINE__ 1
+// MIPS64BE:#define __POINTER_WIDTH__ 64
+// MIPS64BE:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64BE:#define __PTRDIFF_TYPE__ long int
+// MIPS64BE:#define __PTRDIFF_WIDTH__ 64
+// MIPS64BE:#define __REGISTER_PREFIX__
+// MIPS64BE:#define __SCHAR_MAX__ 127
+// MIPS64BE:#define __SHRT_MAX__ 32767
+// MIPS64BE:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64BE:#define __SIZEOF_DOUBLE__ 8
+// MIPS64BE:#define __SIZEOF_FLOAT__ 4
+// MIPS64BE:#define __SIZEOF_INT__ 4
+// MIPS64BE:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64BE:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64BE:#define __SIZEOF_LONG__ 8
+// MIPS64BE:#define __SIZEOF_POINTER__ 8
+// MIPS64BE:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64BE:#define __SIZEOF_SHORT__ 2
+// MIPS64BE:#define __SIZEOF_SIZE_T__ 8
+// MIPS64BE:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64BE:#define __SIZEOF_WINT_T__ 4
+// MIPS64BE:#define __SIZE_TYPE__ long unsigned int
+// MIPS64BE:#define __SIZE_WIDTH__ 64
+// MIPS64BE:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64BE:#define __USER_LABEL_PREFIX__ _
+// MIPS64BE:#define __WCHAR_MAX__ 2147483647
+// MIPS64BE:#define __WCHAR_TYPE__ int
+// MIPS64BE:#define __WCHAR_WIDTH__ 32
+// MIPS64BE:#define __WINT_TYPE__ int
+// MIPS64BE:#define __WINT_WIDTH__ 32
+// MIPS64BE:#define __clang__ 1
+// MIPS64BE:#define __llvm__ 1
+// MIPS64BE:#define __mips 1
+// MIPS64BE:#define __mips__ 1
+// MIPS64BE:#define __mips_hard_float 1
+// MIPS64BE:#define __mips_n64 1
+// MIPS64BE:#define _mips 1
+// MIPS64BE:#define mips 1
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-none-none < /dev/null | FileCheck -check-prefix MIPS64EL %s
+//
+// MIPS64EL:#define MIPSEL 1
+// MIPS64EL:#define _ABI64 3
+// MIPS64EL:#define _MIPSEL 1
+// MIPS64EL:#define _MIPS_SIM _ABI64
+// MIPS64EL:#define _MIPS_SZINT 32
+// MIPS64EL:#define _MIPS_SZLONG 64
+// MIPS64EL:#define _MIPS_SZPTR 64
+// MIPS64EL:#define __CHAR16_TYPE__ unsigned short
+// MIPS64EL:#define __CHAR32_TYPE__ unsigned int
+// MIPS64EL:#define __CHAR_BIT__ 8
+// MIPS64EL:#define __CONSTANT_CFSTRINGS__ 1
+// MIPS64EL:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// MIPS64EL:#define __DBL_DIG__ 15
+// MIPS64EL:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// MIPS64EL:#define __DBL_HAS_DENORM__ 1
+// MIPS64EL:#define __DBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __DBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __DBL_MANT_DIG__ 53
+// MIPS64EL:#define __DBL_MAX_10_EXP__ 308
+// MIPS64EL:#define __DBL_MAX_EXP__ 1024
+// MIPS64EL:#define __DBL_MAX__ 1.7976931348623157e+308
+// MIPS64EL:#define __DBL_MIN_10_EXP__ (-307)
+// MIPS64EL:#define __DBL_MIN_EXP__ (-1021)
+// MIPS64EL:#define __DBL_MIN__ 2.2250738585072014e-308
+// MIPS64EL:#define __DECIMAL_DIG__ 36
+// MIPS64EL:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// MIPS64EL:#define __FLT_DIG__ 6
+// MIPS64EL:#define __FLT_EPSILON__ 1.19209290e-7F
+// MIPS64EL:#define __FLT_EVAL_METHOD__ 0
+// MIPS64EL:#define __FLT_HAS_DENORM__ 1
+// MIPS64EL:#define __FLT_HAS_INFINITY__ 1
+// MIPS64EL:#define __FLT_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __FLT_MANT_DIG__ 24
+// MIPS64EL:#define __FLT_MAX_10_EXP__ 38
+// MIPS64EL:#define __FLT_MAX_EXP__ 128
+// MIPS64EL:#define __FLT_MAX__ 3.40282347e+38F
+// MIPS64EL:#define __FLT_MIN_10_EXP__ (-37)
+// MIPS64EL:#define __FLT_MIN_EXP__ (-125)
+// MIPS64EL:#define __FLT_MIN__ 1.17549435e-38F
+// MIPS64EL:#define __FLT_RADIX__ 2
+// MIPS64EL:#define __INT16_TYPE__ short
+// MIPS64EL:#define __INT32_TYPE__ int
+// MIPS64EL:#define __INT64_C_SUFFIX__ LL
+// MIPS64EL:#define __INT64_TYPE__ long long int
+// MIPS64EL:#define __INT8_TYPE__ char
+// MIPS64EL:#define __INTMAX_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __INTMAX_TYPE__ long long int
+// MIPS64EL:#define __INTMAX_WIDTH__ 64
+// MIPS64EL:#define __INTPTR_TYPE__ long int
+// MIPS64EL:#define __INTPTR_WIDTH__ 64
+// MIPS64EL:#define __INT_MAX__ 2147483647
+// MIPS64EL:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// MIPS64EL:#define __LDBL_DIG__ 33
+// MIPS64EL:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// MIPS64EL:#define __LDBL_HAS_DENORM__ 1
+// MIPS64EL:#define __LDBL_HAS_INFINITY__ 1
+// MIPS64EL:#define __LDBL_HAS_QUIET_NAN__ 1
+// MIPS64EL:#define __LDBL_MANT_DIG__ 113
+// MIPS64EL:#define __LDBL_MAX_10_EXP__ 4932
+// MIPS64EL:#define __LDBL_MAX_EXP__ 16384
+// MIPS64EL:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// MIPS64EL:#define __LDBL_MIN_10_EXP__ (-4931)
+// MIPS64EL:#define __LDBL_MIN_EXP__ (-16381)
+// MIPS64EL:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// MIPS64EL:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// MIPS64EL:#define __LONG_MAX__ 9223372036854775807L
+// MIPS64EL:#define __MIPSEL 1
+// MIPS64EL:#define __MIPSEL__ 1
+// MIPS64EL:#define __NO_INLINE__ 1
+// MIPS64EL:#define __POINTER_WIDTH__ 64
+// MIPS64EL:#define __PRAGMA_REDEFINE_EXTNAME 1
+// MIPS64EL:#define __PTRDIFF_TYPE__ long int
+// MIPS64EL:#define __PTRDIFF_WIDTH__ 64
+// MIPS64EL:#define __REGISTER_PREFIX__
+// MIPS64EL:#define __SCHAR_MAX__ 127
+// MIPS64EL:#define __SHRT_MAX__ 32767
+// MIPS64EL:#define __SIG_ATOMIC_WIDTH__ 32
+// MIPS64EL:#define __SIZEOF_DOUBLE__ 8
+// MIPS64EL:#define __SIZEOF_FLOAT__ 4
+// MIPS64EL:#define __SIZEOF_INT__ 4
+// MIPS64EL:#define __SIZEOF_LONG_DOUBLE__ 16
+// MIPS64EL:#define __SIZEOF_LONG_LONG__ 8
+// MIPS64EL:#define __SIZEOF_LONG__ 8
+// MIPS64EL:#define __SIZEOF_POINTER__ 8
+// MIPS64EL:#define __SIZEOF_PTRDIFF_T__ 8
+// MIPS64EL:#define __SIZEOF_SHORT__ 2
+// MIPS64EL:#define __SIZEOF_SIZE_T__ 8
+// MIPS64EL:#define __SIZEOF_WCHAR_T__ 4
+// MIPS64EL:#define __SIZEOF_WINT_T__ 4
+// MIPS64EL:#define __SIZE_TYPE__ long unsigned int
+// MIPS64EL:#define __SIZE_WIDTH__ 64
+// MIPS64EL:#define __UINTMAX_TYPE__ long long unsigned int
+// MIPS64EL:#define __USER_LABEL_PREFIX__ _
+// MIPS64EL:#define __WCHAR_MAX__ 2147483647
+// MIPS64EL:#define __WCHAR_TYPE__ int
+// MIPS64EL:#define __WCHAR_WIDTH__ 32
+// MIPS64EL:#define __WINT_TYPE__ int
+// MIPS64EL:#define __WINT_WIDTH__ 32
+// MIPS64EL:#define __clang__ 1
+// MIPS64EL:#define __llvm__ 1
+// MIPS64EL:#define __mips 1
+// MIPS64EL:#define __mips__ 1
+// MIPS64EL:#define __mips_hard_float 1
+// MIPS64EL:#define __mips_n64 1
+// MIPS64EL:#define _mips 1
+// MIPS64EL:#define mips 1
+//
+// Check MIPS float ABI macros
+//
+// RUN: %clang_cc1 -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-HARD %s
+// MIPS-FABI-HARD:#define __mips_hard_float 1
+//
+// RUN: %clang_cc1 -target-feature +soft-float -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-SOFT %s
+// MIPS-FABI-SOFT:#define __mips_soft_float 1
+//
+// RUN: %clang_cc1 -target-feature +single-float -E -dM -ffreestanding \
+// RUN: -triple=mips-none-none < /dev/null \
+// RUN: | FileCheck -check-prefix MIPS-FABI-SINGLE %s
+// MIPS-FABI-SINGLE:#define __mips_single_float 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s
//
// MSP430:#define MSP430 1
@@ -622,7 +981,7 @@
// PPC64:#define __DBL_MIN_10_EXP__ (-307)
// PPC64:#define __DBL_MIN_EXP__ (-1021)
// PPC64:#define __DBL_MIN__ 2.2250738585072014e-308
-// PPC64:#define __DECIMAL_DIG__ 17
+// PPC64:#define __DECIMAL_DIG__ 33
// PPC64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
// PPC64:#define __FLT_DIG__ 6
// PPC64:#define __FLT_EPSILON__ 1.19209290e-7F
@@ -649,19 +1008,19 @@
// PPC64:#define __INTPTR_TYPE__ long int
// PPC64:#define __INTPTR_WIDTH__ 64
// PPC64:#define __INT_MAX__ 2147483647
-// PPC64:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// PPC64:#define __LDBL_DIG__ 15
-// PPC64:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// PPC64:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64:#define __LDBL_DIG__ 31
+// PPC64:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
// PPC64:#define __LDBL_HAS_DENORM__ 1
// PPC64:#define __LDBL_HAS_INFINITY__ 1
// PPC64:#define __LDBL_HAS_QUIET_NAN__ 1
-// PPC64:#define __LDBL_MANT_DIG__ 53
+// PPC64:#define __LDBL_MANT_DIG__ 106
// PPC64:#define __LDBL_MAX_10_EXP__ 308
// PPC64:#define __LDBL_MAX_EXP__ 1024
-// PPC64:#define __LDBL_MAX__ 1.7976931348623157e+308
-// PPC64:#define __LDBL_MIN_10_EXP__ (-307)
-// PPC64:#define __LDBL_MIN_EXP__ (-1021)
-// PPC64:#define __LDBL_MIN__ 2.2250738585072014e-308
+// PPC64:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64:#define __LDBL_MIN_EXP__ (-968)
+// PPC64:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
// PPC64:#define __LONG_DOUBLE_128__ 1
// PPC64:#define __LONG_LONG_MAX__ 9223372036854775807LL
// PPC64:#define __LONG_MAX__ 9223372036854775807L
@@ -679,7 +1038,7 @@
// PPC64:#define __SIZEOF_DOUBLE__ 8
// PPC64:#define __SIZEOF_FLOAT__ 4
// PPC64:#define __SIZEOF_INT__ 4
-// PPC64:#define __SIZEOF_LONG_DOUBLE__ 8
+// PPC64:#define __SIZEOF_LONG_DOUBLE__ 16
// PPC64:#define __SIZEOF_LONG_LONG__ 8
// PPC64:#define __SIZEOF_LONG__ 8
// PPC64:#define __SIZEOF_POINTER__ 8
@@ -700,6 +1059,111 @@
// PPC64:#define __ppc64__ 1
// PPC64:#define __ppc__ 1
//
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64-LINUX %s
+//
+// PPC64-LINUX:#define _ARCH_PPC 1
+// PPC64-LINUX:#define _ARCH_PPC64 1
+// PPC64-LINUX:#define _BIG_ENDIAN 1
+// PPC64-LINUX:#define _LP64 1
+// PPC64-LINUX:#define __BIG_ENDIAN__ 1
+// PPC64-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC64-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC64-LINUX:#define __CHAR_BIT__ 8
+// PPC64-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC64-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC64-LINUX:#define __DBL_DIG__ 15
+// PPC64-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC64-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC64-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC64-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC64-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC64-LINUX:#define __DECIMAL_DIG__ 33
+// PPC64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC64-LINUX:#define __FLT_DIG__ 6
+// PPC64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC64-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC64-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC64-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC64-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC64-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC64-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC64-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC64-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC64-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC64-LINUX:#define __FLT_RADIX__ 2
+// PPC64-LINUX:#define __INT16_TYPE__ short
+// PPC64-LINUX:#define __INT32_TYPE__ int
+// PPC64-LINUX:#define __INT64_C_SUFFIX__ L
+// PPC64-LINUX:#define __INT64_TYPE__ long int
+// PPC64-LINUX:#define __INT8_TYPE__ char
+// PPC64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __INTMAX_TYPE__ long int
+// PPC64-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC64-LINUX:#define __INTPTR_TYPE__ long int
+// PPC64-LINUX:#define __INTPTR_WIDTH__ 64
+// PPC64-LINUX:#define __INT_MAX__ 2147483647
+// PPC64-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_DIG__ 31
+// PPC64-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC64-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC64-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC64-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC64-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC64-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC64-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC64-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC64-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC64-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC64-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC64-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC64-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC64-LINUX:#define __LONG_MAX__ 9223372036854775807L
+// PPC64-LINUX:#define __LP64__ 1
+// PPC64-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC64-LINUX:#define __NO_INLINE__ 1
+// PPC64-LINUX:#define __POINTER_WIDTH__ 64
+// PPC64-LINUX:#define __POWERPC__ 1
+// PPC64-LINUX:#define __PTRDIFF_TYPE__ long int
+// PPC64-LINUX:#define __PTRDIFF_WIDTH__ 64
+// PPC64-LINUX:#define __REGISTER_PREFIX__
+// PPC64-LINUX:#define __SCHAR_MAX__ 127
+// PPC64-LINUX:#define __SHRT_MAX__ 32767
+// PPC64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC64-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC64-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC64-LINUX:#define __SIZEOF_INT__ 4
+// PPC64-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC64-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_LONG__ 8
+// PPC64-LINUX:#define __SIZEOF_POINTER__ 8
+// PPC64-LINUX:#define __SIZEOF_PTRDIFF_T__ 8
+// PPC64-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC64-LINUX:#define __SIZEOF_SIZE_T__ 8
+// PPC64-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC64-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC64-LINUX:#define __SIZE_TYPE__ long unsigned int
+// PPC64-LINUX:#define __SIZE_WIDTH__ 64
+// PPC64-LINUX:#define __UINTMAX_TYPE__ long unsigned int
+// PPC64-LINUX:#define __USER_LABEL_PREFIX__
+// PPC64-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC64-LINUX:#define __WCHAR_TYPE__ int
+// PPC64-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC64-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC64-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC64-LINUX:#define __WINT_WIDTH__ 32
+// PPC64-LINUX:#define __powerpc64__ 1
+// PPC64-LINUX:#define __powerpc__ 1
+// PPC64-LINUX:#define __ppc64__ 1
+// PPC64-LINUX:#define __ppc__ 1
+//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC %s
//
// PPC:#define _ARCH_PPC 1
@@ -722,7 +1186,7 @@
// PPC:#define __DBL_MIN_10_EXP__ (-307)
// PPC:#define __DBL_MIN_EXP__ (-1021)
// PPC:#define __DBL_MIN__ 2.2250738585072014e-308
-// PPC:#define __DECIMAL_DIG__ 17
+// PPC:#define __DECIMAL_DIG__ 33
// PPC:#define __FLT_DENORM_MIN__ 1.40129846e-45F
// PPC:#define __FLT_DIG__ 6
// PPC:#define __FLT_EPSILON__ 1.19209290e-7F
@@ -749,19 +1213,19 @@
// PPC:#define __INTPTR_TYPE__ long int
// PPC:#define __INTPTR_WIDTH__ 32
// PPC:#define __INT_MAX__ 2147483647
-// PPC:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// PPC:#define __LDBL_DIG__ 15
-// PPC:#define __LDBL_EPSILON__ 2.2204460492503131e-16
+// PPC:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC:#define __LDBL_DIG__ 31
+// PPC:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
// PPC:#define __LDBL_HAS_DENORM__ 1
// PPC:#define __LDBL_HAS_INFINITY__ 1
// PPC:#define __LDBL_HAS_QUIET_NAN__ 1
-// PPC:#define __LDBL_MANT_DIG__ 53
+// PPC:#define __LDBL_MANT_DIG__ 106
// PPC:#define __LDBL_MAX_10_EXP__ 308
// PPC:#define __LDBL_MAX_EXP__ 1024
-// PPC:#define __LDBL_MAX__ 1.7976931348623157e+308
-// PPC:#define __LDBL_MIN_10_EXP__ (-307)
-// PPC:#define __LDBL_MIN_EXP__ (-1021)
-// PPC:#define __LDBL_MIN__ 2.2250738585072014e-308
+// PPC:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC:#define __LDBL_MIN_EXP__ (-968)
+// PPC:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
// PPC:#define __LONG_DOUBLE_128__ 1
// PPC:#define __LONG_LONG_MAX__ 9223372036854775807LL
// PPC:#define __LONG_MAX__ 2147483647L
@@ -778,7 +1242,7 @@
// PPC:#define __SIZEOF_DOUBLE__ 8
// PPC:#define __SIZEOF_FLOAT__ 4
// PPC:#define __SIZEOF_INT__ 4
-// PPC:#define __SIZEOF_LONG_DOUBLE__ 8
+// PPC:#define __SIZEOF_LONG_DOUBLE__ 16
// PPC:#define __SIZEOF_LONG_LONG__ 8
// PPC:#define __SIZEOF_LONG__ 4
// PPC:#define __SIZEOF_POINTER__ 4
@@ -798,97 +1262,105 @@
// PPC:#define __WINT_WIDTH__ 32
// PPC:#define __ppc__ 1
//
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix S390X %s
-//
-// S390X:#define __CHAR16_TYPE__ unsigned short
-// S390X:#define __CHAR32_TYPE__ unsigned int
-// S390X:#define __CHAR_BIT__ 8
-// S390X:#define __CHAR_UNSIGNED__ 1
-// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __DBL_DIG__ 15
-// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __DBL_HAS_DENORM__ 1
-// S390X:#define __DBL_HAS_INFINITY__ 1
-// S390X:#define __DBL_HAS_QUIET_NAN__ 1
-// S390X:#define __DBL_MANT_DIG__ 53
-// S390X:#define __DBL_MAX_10_EXP__ 308
-// S390X:#define __DBL_MAX_EXP__ 1024
-// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __DBL_MIN_10_EXP__ (-307)
-// S390X:#define __DBL_MIN_EXP__ (-1021)
-// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __DECIMAL_DIG__ 17
-// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// S390X:#define __FLT_DIG__ 6
-// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
-// S390X:#define __FLT_HAS_DENORM__ 1
-// S390X:#define __FLT_HAS_INFINITY__ 1
-// S390X:#define __FLT_HAS_QUIET_NAN__ 1
-// S390X:#define __FLT_MANT_DIG__ 24
-// S390X:#define __FLT_MAX_10_EXP__ 38
-// S390X:#define __FLT_MAX_EXP__ 128
-// S390X:#define __FLT_MAX__ 3.40282347e+38F
-// S390X:#define __FLT_MIN_10_EXP__ (-37)
-// S390X:#define __FLT_MIN_EXP__ (-125)
-// S390X:#define __FLT_MIN__ 1.17549435e-38F
-// S390X:#define __FLT_RADIX__ 2
-// S390X:#define __INT16_TYPE__ short
-// S390X:#define __INT32_TYPE__ int
-// S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_TYPE__ long long int
-// S390X:#define __INT8_TYPE__ char
-// S390X:#define __INTMAX_MAX__ 9223372036854775807LL
-// S390X:#define __INTMAX_TYPE__ long long int
-// S390X:#define __INTMAX_WIDTH__ 64
-// S390X:#define __INTPTR_TYPE__ long int
-// S390X:#define __INTPTR_WIDTH__ 64
-// S390X:#define __INT_MAX__ 2147483647
-// S390X:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __LDBL_DIG__ 15
-// S390X:#define __LDBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __LDBL_HAS_DENORM__ 1
-// S390X:#define __LDBL_HAS_INFINITY__ 1
-// S390X:#define __LDBL_HAS_QUIET_NAN__ 1
-// S390X:#define __LDBL_MANT_DIG__ 53
-// S390X:#define __LDBL_MAX_10_EXP__ 308
-// S390X:#define __LDBL_MAX_EXP__ 1024
-// S390X:#define __LDBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __LDBL_MIN_10_EXP__ (-307)
-// S390X:#define __LDBL_MIN_EXP__ (-1021)
-// S390X:#define __LDBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __LONG_LONG_MAX__ 9223372036854775807LL
-// S390X:#define __LONG_MAX__ 9223372036854775807L
-// S390X:#define __NO_INLINE__ 1
-// S390X:#define __POINTER_WIDTH__ 64
-// S390X:#define __PTRDIFF_TYPE__ long int
-// S390X:#define __PTRDIFF_WIDTH__ 64
-// S390X:#define __SCHAR_MAX__ 127
-// S390X:#define __SHRT_MAX__ 32767
-// S390X:#define __SIG_ATOMIC_WIDTH__ 32
-// S390X:#define __SIZEOF_DOUBLE__ 8
-// S390X:#define __SIZEOF_FLOAT__ 4
-// S390X:#define __SIZEOF_INT__ 4
-// S390X:#define __SIZEOF_LONG_DOUBLE__ 8
-// S390X:#define __SIZEOF_LONG_LONG__ 8
-// S390X:#define __SIZEOF_LONG__ 8
-// S390X:#define __SIZEOF_POINTER__ 8
-// S390X:#define __SIZEOF_PTRDIFF_T__ 8
-// S390X:#define __SIZEOF_SHORT__ 2
-// S390X:#define __SIZEOF_SIZE_T__ 8
-// S390X:#define __SIZEOF_WCHAR_T__ 4
-// S390X:#define __SIZEOF_WINT_T__ 4
-// S390X:#define __SIZE_TYPE__ long unsigned int
-// S390X:#define __SIZE_WIDTH__ 64
-// S390X:#define __UINTMAX_TYPE__ long long unsigned int
-// S390X:#define __USER_LABEL_PREFIX__ _
-// S390X:#define __WCHAR_MAX__ 2147483647
-// S390X:#define __WCHAR_TYPE__ int
-// S390X:#define __WCHAR_WIDTH__ 32
-// S390X:#define __WINT_TYPE__ int
-// S390X:#define __WINT_WIDTH__ 32
-// S390X:#define __s390__ 1
-// S390X:#define __s390x__ 1
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -check-prefix PPC-LINUX %s
+//
+// PPC-LINUX:#define _ARCH_PPC 1
+// PPC-LINUX:#define _BIG_ENDIAN 1
+// PPC-LINUX:#define __BIG_ENDIAN__ 1
+// PPC-LINUX:#define __CHAR16_TYPE__ unsigned short
+// PPC-LINUX:#define __CHAR32_TYPE__ unsigned int
+// PPC-LINUX:#define __CHAR_BIT__ 8
+// PPC-LINUX:#define __CHAR_UNSIGNED__ 1
+// PPC-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// PPC-LINUX:#define __DBL_DIG__ 15
+// PPC-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// PPC-LINUX:#define __DBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __DBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __DBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __DBL_MANT_DIG__ 53
+// PPC-LINUX:#define __DBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __DBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308
+// PPC-LINUX:#define __DBL_MIN_10_EXP__ (-307)
+// PPC-LINUX:#define __DBL_MIN_EXP__ (-1021)
+// PPC-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308
+// PPC-LINUX:#define __DECIMAL_DIG__ 33
+// PPC-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// PPC-LINUX:#define __FLT_DIG__ 6
+// PPC-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F
+// PPC-LINUX:#define __FLT_EVAL_METHOD__ 0
+// PPC-LINUX:#define __FLT_HAS_DENORM__ 1
+// PPC-LINUX:#define __FLT_HAS_INFINITY__ 1
+// PPC-LINUX:#define __FLT_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __FLT_MANT_DIG__ 24
+// PPC-LINUX:#define __FLT_MAX_10_EXP__ 38
+// PPC-LINUX:#define __FLT_MAX_EXP__ 128
+// PPC-LINUX:#define __FLT_MAX__ 3.40282347e+38F
+// PPC-LINUX:#define __FLT_MIN_10_EXP__ (-37)
+// PPC-LINUX:#define __FLT_MIN_EXP__ (-125)
+// PPC-LINUX:#define __FLT_MIN__ 1.17549435e-38F
+// PPC-LINUX:#define __FLT_RADIX__ 2
+// PPC-LINUX:#define __INT16_TYPE__ short
+// PPC-LINUX:#define __INT32_TYPE__ int
+// PPC-LINUX:#define __INT64_C_SUFFIX__ LL
+// PPC-LINUX:#define __INT64_TYPE__ long long int
+// PPC-LINUX:#define __INT8_TYPE__ char
+// PPC-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __INTMAX_TYPE__ long long int
+// PPC-LINUX:#define __INTMAX_WIDTH__ 64
+// PPC-LINUX:#define __INTPTR_TYPE__ int
+// PPC-LINUX:#define __INTPTR_WIDTH__ 32
+// PPC-LINUX:#define __INT_MAX__ 2147483647
+// PPC-LINUX:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_DIG__ 31
+// PPC-LINUX:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L
+// PPC-LINUX:#define __LDBL_HAS_DENORM__ 1
+// PPC-LINUX:#define __LDBL_HAS_INFINITY__ 1
+// PPC-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1
+// PPC-LINUX:#define __LDBL_MANT_DIG__ 106
+// PPC-LINUX:#define __LDBL_MAX_10_EXP__ 308
+// PPC-LINUX:#define __LDBL_MAX_EXP__ 1024
+// PPC-LINUX:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L
+// PPC-LINUX:#define __LDBL_MIN_10_EXP__ (-291)
+// PPC-LINUX:#define __LDBL_MIN_EXP__ (-968)
+// PPC-LINUX:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L
+// PPC-LINUX:#define __LONG_DOUBLE_128__ 1
+// PPC-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// PPC-LINUX:#define __LONG_MAX__ 2147483647L
+// PPC-LINUX:#define __NATURAL_ALIGNMENT__ 1
+// PPC-LINUX:#define __NO_INLINE__ 1
+// PPC-LINUX:#define __POINTER_WIDTH__ 32
+// PPC-LINUX:#define __POWERPC__ 1
+// PPC-LINUX:#define __PTRDIFF_TYPE__ int
+// PPC-LINUX:#define __PTRDIFF_WIDTH__ 32
+// PPC-LINUX:#define __REGISTER_PREFIX__
+// PPC-LINUX:#define __SCHAR_MAX__ 127
+// PPC-LINUX:#define __SHRT_MAX__ 32767
+// PPC-LINUX:#define __SIG_ATOMIC_WIDTH__ 32
+// PPC-LINUX:#define __SIZEOF_DOUBLE__ 8
+// PPC-LINUX:#define __SIZEOF_FLOAT__ 4
+// PPC-LINUX:#define __SIZEOF_INT__ 4
+// PPC-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16
+// PPC-LINUX:#define __SIZEOF_LONG_LONG__ 8
+// PPC-LINUX:#define __SIZEOF_LONG__ 4
+// PPC-LINUX:#define __SIZEOF_POINTER__ 4
+// PPC-LINUX:#define __SIZEOF_PTRDIFF_T__ 4
+// PPC-LINUX:#define __SIZEOF_SHORT__ 2
+// PPC-LINUX:#define __SIZEOF_SIZE_T__ 4
+// PPC-LINUX:#define __SIZEOF_WCHAR_T__ 4
+// PPC-LINUX:#define __SIZEOF_WINT_T__ 4
+// PPC-LINUX:#define __SIZE_TYPE__ unsigned int
+// PPC-LINUX:#define __SIZE_WIDTH__ 32
+// PPC-LINUX:#define __UINTMAX_TYPE__ long long unsigned int
+// PPC-LINUX:#define __USER_LABEL_PREFIX__
+// PPC-LINUX:#define __WCHAR_MAX__ 2147483647
+// PPC-LINUX:#define __WCHAR_TYPE__ int
+// PPC-LINUX:#define __WCHAR_WIDTH__ 32
+// PPC-LINUX:#define __WINT_TYPE__ unsigned int
+// PPC-LINUX:#define __WINT_UNSIGNED__ 1
+// PPC-LINUX:#define __WINT_WIDTH__ 32
+// PPC-LINUX:#define __powerpc__ 1
+// PPC-LINUX:#define __ppc__ 1
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -check-prefix SPARC %s
//
diff --git a/test/Preprocessor/line-directive.c b/test/Preprocessor/line-directive.c
index 878d067..28e9302 100644
--- a/test/Preprocessor/line-directive.c
+++ b/test/Preprocessor/line-directive.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: #error ABC'
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: #error DEF'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
#line 'a' // expected-error {{#line directive requires a positive integer argument}}
#line 0 // expected-error {{#line directive requires a positive integer argument}}
@@ -41,7 +41,7 @@
# 192 "glomp.h" // not a system header.
typedef int x; // expected-note {{previous definition is here}}
-typedef int x; // expected-error {{redefinition of typedef 'x' is invalid in C}}
+typedef int x; // expected-warning {{redefinition of typedef 'x' is a C11 feature}}
# 192 "glomp.h" 3 // System header.
typedef int y; // ok
@@ -62,7 +62,7 @@ typedef int z1; // ok
# 42 "blonk.h" // DOES change system headerness.
typedef int w; // expected-note {{previous definition is here}}
-typedef int w; // expected-error {{redefinition of typedef 'w' is invalid in C}}
+typedef int w; // expected-warning {{redefinition of typedef 'w' is a C11 feature}}
typedef int q; // original definition in system header, should not diagnose.
diff --git a/test/Preprocessor/macro_arg_directive.c b/test/Preprocessor/macro_arg_directive.c
new file mode 100644
index 0000000..5c9943d
--- /dev/null
+++ b/test/Preprocessor/macro_arg_directive.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+
+// header1.h
+void fail(const char *);
+#define MUNCH(...) \
+ ({ int result = 0; __VA_ARGS__; if (!result) { fail(#__VA_ARGS__); }; result })
+
+static inline int f(int k) {
+ return MUNCH( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{returning 'void'}}
+ if (k < 3)
+ result = 24;
+ else if (k > 4)
+ result = k - 4;
+}
+
+#include "macro_arg_directive.h" // expected-error {{embedding a #include directive within macro arguments is not supported}}
+
+int g(int k) {
+ return f(k) + f(k-1));
+}
diff --git a/test/Preprocessor/macro_arg_directive.h b/test/Preprocessor/macro_arg_directive.h
new file mode 100644
index 0000000..892dbf2
--- /dev/null
+++ b/test/Preprocessor/macro_arg_directive.h
@@ -0,0 +1,9 @@
+// Support header for macro_arg_directive.c
+
+int n;
+
+struct S {
+ int k;
+};
+
+void g(int);
diff --git a/test/Preprocessor/macro_paste_c_block_comment.c b/test/Preprocessor/macro_paste_c_block_comment.c
index 3441f27..c690a4c 100644
--- a/test/Preprocessor/macro_paste_c_block_comment.c
+++ b/test/Preprocessor/macro_paste_c_block_comment.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -Eonly 2>&1 | grep error
-// RUN: %clang_cc1 %s -Eonly 2>&1 | not grep unterminated
-// RUN: %clang_cc1 %s -Eonly 2>&1 | not grep scratch
+// RUN: %clang_cc1 %s -Eonly -verify
#define COMM / ## *
-COMM
+COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}}
diff --git a/test/Preprocessor/microsoft-import.c b/test/Preprocessor/microsoft-import.c
new file mode 100644
index 0000000..8835c7a
--- /dev/null
+++ b/test/Preprocessor/microsoft-import.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:100:2: error: #import of type library is an unsupported Microsoft feature'
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:200:2: error: #import of type library is an unsupported Microsoft feature'
+// RUN: %clang_cc1 -E -fms-compatibility %s 2>&1 | grep 'doh.c:300:2: error: #import of type library is an unsupported Microsoft feature'
+
+#line 100 "doh.c"
+#import "pp-record.h" // expected-error {{#import of type library is an unsupported Microsoft feature}}
+
+// Test attributes
+#line 200 "doh.c"
+#import "pp-record.h" no_namespace, auto_rename // expected-error {{#import of type library is an unsupported Microsoft feature}}
+
+// This will also fire the "#import of type library is an unsupported Microsoft feature"
+// error, but we can't use -verify because there's no way to put the comment on the proper line
+#line 300 "doh.c"
+#import "pp-record.h" no_namespace \
+ auto_rename \
+ auto_search
diff --git a/test/Preprocessor/mmx.c b/test/Preprocessor/mmx.c
new file mode 100644
index 0000000..2613cb6
--- /dev/null
+++ b/test/Preprocessor/mmx.c
@@ -0,0 +1,13 @@
+// RUN: %clang -march=i386 -m32 -E -dM %s -msse -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_AND_MMX
+// RUN: %clang -march=i386 -m32 -E -dM %s -msse -mno-mmx -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_NO_MMX
+// RUN: %clang -march=i386 -m32 -E -dM %s -mno-mmx -msse -o - 2>&1 \
+// RUN: | FileCheck %s -check-prefix=SSE_NO_MMX
+
+// SSE_AND_MMX: #define __MMX__
+// SSE_AND_MMX: #define __SSE__
+
+// SSE_NO_MMX-NOT: __MMX__
+// SSE_NO_MMX: __SSE__
+// SSE_NO_MMX-NOT: __MMX__
diff --git a/test/Preprocessor/optimize.c b/test/Preprocessor/optimize.c
index c820ded..97f841a 100644
--- a/test/Preprocessor/optimize.c
+++ b/test/Preprocessor/optimize.c
@@ -23,7 +23,7 @@
#ifndef __OPTIMIZE__
#error "__OPTIMIZE__ not defined"
#endif
- #ifdef __OPTIMIZE_SIZE__
+ #ifndef __OPTIMIZE_SIZE__
#error "__OPTIMIZE_SIZE__ not defined"
#endif
#endif
diff --git a/test/Preprocessor/pic.c b/test/Preprocessor/pic.c
index 886beb7..3e649ee 100644
--- a/test/Preprocessor/pic.c
+++ b/test/Preprocessor/pic.c
@@ -1,9 +1,34 @@
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -static -dM -E -o %t %s
-// RUN: grep '#define __PIC__' %t | count 0
-// RUN: grep '#define __pic__' %t | count 0
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -fpic -dM -E -o %t %s
-// RUN: grep '#define __PIC__ 1' %t | count 1
-// RUN: grep '#define __pic__ 1' %t | count 1
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -fPIC -dM -E -o %t %s
-// RUN: grep '#define __PIC__ 2' %t | count 1
-// RUN: grep '#define __pic__ 2' %t | count 1
+// RUN: %clang_cc1 -dM -E -o - %s \
+// RUN: | FileCheck %s
+// CHECK-NOT: #define __PIC__
+// CHECK-NOT: #define __PIE__
+// CHECK-NOT: #define __pic__
+// CHECK-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 1 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIC1 %s
+// CHECK-PIC1: #define __PIC__ 1
+// CHECK-PIC1-NOT: #define __PIE__
+// CHECK-PIC1: #define __pic__ 1
+// CHECK-PIC1-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pic-level 2 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIC2 %s
+// CHECK-PIC2: #define __PIC__ 2
+// CHECK-PIC2-NOT: #define __PIE__
+// CHECK-PIC2: #define __pic__ 2
+// CHECK-PIC2-NOT: #define __pie__
+//
+// RUN: %clang_cc1 -pie-level 1 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIE1 %s
+// CHECK-PIE1-NOT: #define __PIC__
+// CHECK-PIE1: #define __PIE__ 1
+// CHECK-PIE1-NOT: #define __pic__
+// CHECK-PIE1: #define __pie__ 1
+//
+// RUN: %clang_cc1 -pie-level 2 -dM -E -o - %s \
+// RUN: | FileCheck --check-prefix=CHECK-PIE2 %s
+// CHECK-PIE2-NOT: #define __PIC__
+// CHECK-PIE2: #define __PIE__ 2
+// CHECK-PIE2-NOT: #define __pic__
+// CHECK-PIE2: #define __pie__ 2
diff --git a/test/Preprocessor/pp-record.c b/test/Preprocessor/pp-record.c
index dcb52b5..f098683 100644
--- a/test/Preprocessor/pp-record.c
+++ b/test/Preprocessor/pp-record.c
@@ -2,8 +2,11 @@
// http://llvm.org/PR11120
-#define FILE_HEADER_NAME "pp-record.h"
+#define STRINGIZE(text) STRINGIZE_I(text)
+#define STRINGIZE_I(text) #text
-#if defined(FILE_HEADER_NAME)
-#include FILE_HEADER_NAME
-#endif
+#define INC pp-record.h
+
+#include STRINGIZE(INC)
+
+CAKE;
diff --git a/test/Preprocessor/pp-record.h b/test/Preprocessor/pp-record.h
index 34158bd..b39a174 100644
--- a/test/Preprocessor/pp-record.h
+++ b/test/Preprocessor/pp-record.h
@@ -1 +1,3 @@
// Only useful for #inclusion.
+
+#define CAKE extern int is_a_lie
diff --git a/test/Preprocessor/pragma_microsoft.c b/test/Preprocessor/pragma_microsoft.c
index b68d6e3..e461c70 100644
--- a/test/Preprocessor/pragma_microsoft.c
+++ b/test/Preprocessor/pragma_microsoft.c
@@ -38,3 +38,46 @@ void f()
// this warning should go away.
MACRO_WITH__PRAGMA // expected-warning {{expression result unused}}
}
+
+
+// This should include macro_arg_directive even though the include
+// is looking for test.h This allows us to assign to "n"
+#pragma include_alias("test.h", "macro_arg_directive.h" )
+#include "test.h"
+void test( void ) {
+ n = 12;
+}
+
+#pragma include_alias(<bar.h>, "bar.h") // expected-warning {{angle-bracketed include <bar.h> cannot be aliased to double-quoted include "bar.h"}}
+#pragma include_alias("foo.h", <bar.h>) // expected-warning {{double-quoted include "foo.h" cannot be aliased to angle-bracketed include <bar.h>}}
+#pragma include_alias("test.h") // expected-warning {{pragma include_alias expected ','}}
+
+// Make sure that the names match exactly for a replacement, including path information. If
+// this were to fail, we would get a file not found error
+#pragma include_alias(".\pp-record.h", "does_not_exist.h")
+#include "pp-record.h"
+
+#pragma include_alias(12) // expected-warning {{pragma include_alias expected include filename}}
+
+// It's expected that we can map "bar" and <bar> separately
+#define test
+// We can't actually look up stdio.h because we're using cc1 without header paths, but this will ensure
+// that we get the right bar.h, because the "bar.h" will undef test for us, where <bar.h> won't
+#pragma include_alias(<bar.h>, <stdio.h>)
+#pragma include_alias("bar.h", "pr2086.h") // This should #undef test
+
+#include "bar.h"
+#if defined(test)
+// This should not warn because test should not be defined
+#pragma include_alias("test.h")
+#endif
+
+// Test to make sure there are no use-after-free problems
+#define B "pp-record.h"
+#pragma include_alias("quux.h", B)
+void g() {}
+#include "quux.h"
+
+// Make sure that empty includes don't work
+#pragma include_alias("", "foo.h") // expected-error {{empty filename}}
+#pragma include_alias(<foo.h>, <>) // expected-error {{empty filename}}
diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c
index 85a0cb8..5c11c3b 100644
--- a/test/Preprocessor/predefined-macros.c
+++ b/test/Preprocessor/predefined-macros.c
@@ -1,12 +1,15 @@
-// This test verifies that the correct macros are predefined. It currently
-// only checks for Microsoft macros.
-
-// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fmsc-version=1300 -o - | FileCheck %s
-
-
-// CHECK: #define _INTEGRAL_MAX_BITS 64
-// CHECK: #define _MSC_EXTENSIONS 1
-// CHECK: #define _MSC_VER 1300
-// CHECK: #define _M_IX86 600
-// CHECK: #define _M_IX86_FP
-// CHECK: #define _WIN32 1
+// This test verifies that the correct macros are predefined.
+//
+// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fms-compatibility \
+// RUN: -fmsc-version=1300 -o - | FileCheck %s --check-prefix=CHECK-MS
+// CHECK-MS: #define _INTEGRAL_MAX_BITS 64
+// CHECK-MS: #define _MSC_EXTENSIONS 1
+// CHECK-MS: #define _MSC_VER 1300
+// CHECK-MS: #define _M_IX86 600
+// CHECK-MS: #define _M_IX86_FP
+// CHECK-MS: #define _WIN32 1
+// CHECK-MS-NOT: #define __GNUC__
+//
+// RUN: %clang_cc1 %s -E -dM -ffast-math -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-FAST-MATH
+// CHECK-FAST-MATH: #define __FAST_MATH__
diff --git a/test/Preprocessor/stdint.c b/test/Preprocessor/stdint.c
index ee8e3c2..70c106b 100644
--- a/test/Preprocessor/stdint.c
+++ b/test/Preprocessor/stdint.c
@@ -90,8 +90,8 @@
// ARM:WINT_MIN_ (-2147483647 -1)
// ARM:WINT_MAX_ 2147483647
//
-// ARM:WCHAR_MAX_ 2147483647
-// ARM:WCHAR_MIN_ (-2147483647 -1)
+// ARM:WCHAR_MAX_ 4294967295U
+// ARM:WCHAR_MIN_ 0U
//
// ARM:INT8_C_(0) 0
// ARM:UINT8_C_(0) 0U
@@ -106,114 +106,6 @@
// ARM:UINTMAX_C_(0) 0ULL
//
//
-// RUN: %clang_cc1 -E -ffreestanding -triple=bfin-none-none %s | FileCheck -check-prefix BFIN %s
-//
-// BFIN:typedef signed long long int int64_t;
-// BFIN:typedef unsigned long long int uint64_t;
-// BFIN:typedef int64_t int_least64_t;
-// BFIN:typedef uint64_t uint_least64_t;
-// BFIN:typedef int64_t int_fast64_t;
-// BFIN:typedef uint64_t uint_fast64_t;
-//
-// BFIN:typedef signed int int32_t;
-// BFIN:typedef unsigned int uint32_t;
-// BFIN:typedef int32_t int_least32_t;
-// BFIN:typedef uint32_t uint_least32_t;
-// BFIN:typedef int32_t int_fast32_t;
-// BFIN:typedef uint32_t uint_fast32_t;
-//
-// BFIN:typedef signed short int16_t;
-// BFIN:typedef unsigned short uint16_t;
-// BFIN:typedef int16_t int_least16_t;
-// BFIN:typedef uint16_t uint_least16_t;
-// BFIN:typedef int16_t int_fast16_t;
-// BFIN:typedef uint16_t uint_fast16_t;
-//
-// BFIN:typedef signed char int8_t;
-// BFIN:typedef unsigned char uint8_t;
-// BFIN:typedef int8_t int_least8_t;
-// BFIN:typedef uint8_t uint_least8_t;
-// BFIN:typedef int8_t int_fast8_t;
-// BFIN:typedef uint8_t uint_fast8_t;
-//
-// BFIN:typedef int32_t intptr_t;
-// BFIN:typedef uint32_t uintptr_t;
-//
-// BFIN:typedef long long int intmax_t;
-// BFIN:typedef long long unsigned int uintmax_t;
-//
-// BFIN:INT8_MAX_ 127
-// BFIN:INT8_MIN_ (-127 -1)
-// BFIN:UINT8_MAX_ 255
-// BFIN:INT_LEAST8_MIN_ (-127 -1)
-// BFIN:INT_LEAST8_MAX_ 127
-// BFIN:UINT_LEAST8_MAX_ 255
-// BFIN:INT_FAST8_MIN_ (-127 -1)
-// BFIN:INT_FAST8_MAX_ 127
-// BFIN:UINT_FAST8_MAX_ 255
-//
-// BFIN:INT16_MAX_ 32767
-// BFIN:INT16_MIN_ (-32767 -1)
-// BFIN:UINT16_MAX_ 65535
-// BFIN:INT_LEAST16_MIN_ (-32767 -1)
-// BFIN:INT_LEAST16_MAX_ 32767
-// BFIN:UINT_LEAST16_MAX_ 65535
-// BFIN:INT_FAST16_MIN_ (-32767 -1)
-// BFIN:INT_FAST16_MAX_ 32767
-// BFIN:UINT_FAST16_MAX_ 65535
-//
-// BFIN:INT32_MAX_ 2147483647
-// BFIN:INT32_MIN_ (-2147483647 -1)
-// BFIN:UINT32_MAX_ 4294967295U
-// BFIN:INT_LEAST32_MIN_ (-2147483647 -1)
-// BFIN:INT_LEAST32_MAX_ 2147483647
-// BFIN:UINT_LEAST32_MAX_ 4294967295U
-// BFIN:INT_FAST32_MIN_ (-2147483647 -1)
-// BFIN:INT_FAST32_MAX_ 2147483647
-// BFIN:UINT_FAST32_MAX_ 4294967295U
-//
-// BFIN:INT64_MAX_ 9223372036854775807LL
-// BFIN:INT64_MIN_ (-9223372036854775807LL -1)
-// BFIN:UINT64_MAX_ 18446744073709551615ULL
-// BFIN:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
-// BFIN:INT_LEAST64_MAX_ 9223372036854775807LL
-// BFIN:UINT_LEAST64_MAX_ 18446744073709551615ULL
-// BFIN:INT_FAST64_MIN_ (-9223372036854775807LL -1)
-// BFIN:INT_FAST64_MAX_ 9223372036854775807LL
-// BFIN:UINT_FAST64_MAX_ 18446744073709551615ULL
-//
-// BFIN:INTPTR_MIN_ (-2147483647 -1)
-// BFIN:INTPTR_MAX_ 2147483647
-// BFIN:UINTPTR_MAX_ 4294967295U
-// BFIN:PTRDIFF_MIN_ (-2147483647 -1)
-// BFIN:PTRDIFF_MAX_ 2147483647
-// BFIN:SIZE_MAX_ 4294967295U
-//
-// BFIN:INTMAX_MIN_ (-9223372036854775807LL -1)
-// BFIN:INTMAX_MAX_ 9223372036854775807LL
-// BFIN:UINTMAX_MAX_ 18446744073709551615ULL
-//
-// BFIN:SIG_ATOMIC_MIN_ (-2147483647 -1)
-// BFIN:SIG_ATOMIC_MAX_ 2147483647
-// BFIN:WINT_MIN_ (-2147483647 -1)
-// BFIN:WINT_MAX_ 2147483647
-//
-// BFIN:WCHAR_MAX_ 2147483647
-// BFIN:WCHAR_MIN_ (-2147483647 -1)
-//
-// BFIN:INT8_C_(0) 0
-// BFIN:UINT8_C_(0) 0U
-// BFIN:INT16_C_(0) 0
-// BFIN:UINT16_C_(0) 0U
-// BFIN:INT32_C_(0) 0
-// BFIN:UINT32_C_(0) 0U
-// BFIN:INT64_C_(0) 0LL
-// BFIN:UINT64_C_(0) 0ULL
-//
-// BFIN:INTMAX_C_(0) 0LL
-// BFIN:UINTMAX_C_(0) 0ULL
-//
-//
// RUN: %clang_cc1 -E -ffreestanding -triple=i386-none-none %s | FileCheck -check-prefix I386 %s
//
// I386:typedef signed long long int int64_t;
@@ -636,113 +528,6 @@
// PPC:INTMAX_C_(0) 0LL
// PPC:UINTMAX_C_(0) 0ULL
//
-// RUN: %clang_cc1 -E -ffreestanding -triple=s390x-none-none %s | FileCheck -check-prefix S390X %s
-//
-// S390X:typedef signed long long int int64_t;
-// S390X:typedef unsigned long long int uint64_t;
-// S390X:typedef int64_t int_least64_t;
-// S390X:typedef uint64_t uint_least64_t;
-// S390X:typedef int64_t int_fast64_t;
-// S390X:typedef uint64_t uint_fast64_t;
-//
-// S390X:typedef signed int int32_t;
-// S390X:typedef unsigned int uint32_t;
-// S390X:typedef int32_t int_least32_t;
-// S390X:typedef uint32_t uint_least32_t;
-// S390X:typedef int32_t int_fast32_t;
-// S390X:typedef uint32_t uint_fast32_t;
-//
-// S390X:typedef signed short int16_t;
-// S390X:typedef unsigned short uint16_t;
-// S390X:typedef int16_t int_least16_t;
-// S390X:typedef uint16_t uint_least16_t;
-// S390X:typedef int16_t int_fast16_t;
-// S390X:typedef uint16_t uint_fast16_t;
-//
-// S390X:typedef signed char int8_t;
-// S390X:typedef unsigned char uint8_t;
-// S390X:typedef int8_t int_least8_t;
-// S390X:typedef uint8_t uint_least8_t;
-// S390X:typedef int8_t int_fast8_t;
-// S390X:typedef uint8_t uint_fast8_t;
-//
-// S390X:typedef int64_t intptr_t;
-// S390X:typedef uint64_t uintptr_t;
-//
-// S390X:typedef long long int intmax_t;
-// S390X:typedef long long unsigned int uintmax_t;
-//
-// S390X:INT8_MAX_ 127
-// S390X:INT8_MIN_ (-127 -1)
-// S390X:UINT8_MAX_ 255
-// S390X:INT_LEAST8_MIN_ (-127 -1)
-// S390X:INT_LEAST8_MAX_ 127
-// S390X:UINT_LEAST8_MAX_ 255
-// S390X:INT_FAST8_MIN_ (-127 -1)
-// S390X:INT_FAST8_MAX_ 127
-// S390X:UINT_FAST8_MAX_ 255
-//
-// S390X:INT16_MAX_ 32767
-// S390X:INT16_MIN_ (-32767 -1)
-// S390X:UINT16_MAX_ 65535
-// S390X:INT_LEAST16_MIN_ (-32767 -1)
-// S390X:INT_LEAST16_MAX_ 32767
-// S390X:UINT_LEAST16_MAX_ 65535
-// S390X:INT_FAST16_MIN_ (-32767 -1)
-// S390X:INT_FAST16_MAX_ 32767
-// S390X:UINT_FAST16_MAX_ 65535
-//
-// S390X:INT32_MAX_ 2147483647
-// S390X:INT32_MIN_ (-2147483647 -1)
-// S390X:UINT32_MAX_ 4294967295U
-// S390X:INT_LEAST32_MIN_ (-2147483647 -1)
-// S390X:INT_LEAST32_MAX_ 2147483647
-// S390X:UINT_LEAST32_MAX_ 4294967295U
-// S390X:INT_FAST32_MIN_ (-2147483647 -1)
-// S390X:INT_FAST32_MAX_ 2147483647
-// S390X:UINT_FAST32_MAX_ 4294967295U
-//
-// S390X:INT64_MAX_ 9223372036854775807L
-// S390X:INT64_MIN_ (-9223372036854775807LL -1)
-// S390X:UINT64_MAX_ 18446744073709551615UL
-// S390X:INT_LEAST64_MIN_ (-9223372036854775807LL -1)
-// S390X:INT_LEAST64_MAX_ 9223372036854775807L
-// S390X:UINT_LEAST64_MAX_ 18446744073709551615UL
-// S390X:INT_FAST64_MIN_ (-9223372036854775807LL -1)
-// S390X:INT_FAST64_MAX_ 9223372036854775807L
-// S390X:UINT_FAST64_MAX_ 18446744073709551615UL
-//
-// S390X:INTPTR_MIN_ (-9223372036854775807LL -1)
-// S390X:INTPTR_MAX_ 9223372036854775807L
-// S390X:UINTPTR_MAX_ 18446744073709551615UL
-// S390X:PTRDIFF_MIN_ (-9223372036854775807LL -1)
-// S390X:PTRDIFF_MAX_ 9223372036854775807L
-// S390X:SIZE_MAX_ 18446744073709551615UL
-//
-// S390X:INTMAX_MIN_ (-9223372036854775807LL -1)
-// S390X:INTMAX_MAX_ 9223372036854775807L
-// S390X:UINTMAX_MAX_ 18446744073709551615UL
-//
-// S390X:SIG_ATOMIC_MIN_ (-2147483647 -1)
-// S390X:SIG_ATOMIC_MAX_ 2147483647
-// S390X:WINT_MIN_ (-2147483647 -1)
-// S390X:WINT_MAX_ 2147483647
-//
-// S390X:WCHAR_MAX_ 2147483647
-// S390X:WCHAR_MIN_ (-2147483647 -1)
-//
-// S390X:INT8_C_(0) 0
-// S390X:UINT8_C_(0) 0U
-// S390X:INT16_C_(0) 0
-// S390X:UINT16_C_(0) 0U
-// S390X:INT32_C_(0) 0
-// S390X:UINT32_C_(0) 0U
-// S390X:INT64_C_(0) 0L
-// S390X:UINT64_C_(0) 0UL
-//
-// S390X:INTMAX_C_(0) 0L
-// S390X:UINTMAX_C_(0) 0UL
-//
// RUN: %clang_cc1 -E -ffreestanding -triple=sparc-none-none %s | FileCheck -check-prefix SPARC %s
//
// SPARC:typedef signed long long int int64_t;
diff --git a/test/Preprocessor/user_defined_system_framework.c b/test/Preprocessor/user_defined_system_framework.c
new file mode 100644
index 0000000..8e3db56
--- /dev/null
+++ b/test/Preprocessor/user_defined_system_framework.c
@@ -0,0 +1,8 @@
+// RUN: %clang -cc1 -fsyntax-only -F %S/Inputs -Wsign-conversion -verify %s
+
+// Check that TestFramework is treated as a system header.
+#include <TestFramework/TestFramework.h>
+
+int f1() {
+ return test_framework_func(1) + another_test_framework_func(2);
+}
diff --git a/test/Preprocessor/warn-disabled-macro-expansion.c b/test/Preprocessor/warn-disabled-macro-expansion.c
new file mode 100644
index 0000000..fe8e90c
--- /dev/null
+++ b/test/Preprocessor/warn-disabled-macro-expansion.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -E -Wdisabled-macro-expansion -verify
+
+#define p p
+
+#define a b
+#define b a
+
+#define f(a) a
+
+#define g(b) a
+
+#define h(x) i(x)
+#define i(y) i(y)
+
+#define c(x) x(0)
+
+p // expected-warning {{recursive macro}}
+
+a // expected-warning {{recursive macro}}
+
+f(2)
+
+g(3) // expected-warning {{recursive macro}}
+
+h(0) // expected-warning {{recursive macro}}
+
+c(c) // expected-warning {{recursive macro}}
diff --git a/test/Preprocessor/x86_target_features.c b/test/Preprocessor/x86_target_features.c
index f39c220..ad7ee85 100644
--- a/test/Preprocessor/x86_target_features.c
+++ b/test/Preprocessor/x86_target_features.c
@@ -1,6 +1,4 @@
-// FIXME: Use -triple, not -ccc-host-triple.
-
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -march=core2 -msse4 -x c -E -dM -o %t %s
+// RUN: %clang -target i386-unknown-unknown -march=core2 -msse4 -x c -E -dM -o %t %s
// RUN: grep '#define __SSE2_MATH__ 1' %t
// RUN: grep '#define __SSE2__ 1' %t
// RUN: grep '#define __SSE3__ 1' %t
@@ -10,7 +8,7 @@
// RUN: grep '#define __SSE__ 1' %t
// RUN: grep '#define __SSSE3__ 1' %t
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -march=core2 -msse4 -mno-sse2 -x c -E -dM -o %t %s
+// RUN: %clang -target i386-unknown-unknown -march=core2 -msse4 -mno-sse2 -x c -E -dM -o %t %s
// RUN: grep '#define __SSE2_MATH__ 1' %t | count 0
// RUN: grep '#define __SSE2__ 1' %t | count 0
// RUN: grep '#define __SSE3__ 1' %t | count 0
@@ -20,7 +18,7 @@
// RUN: grep '#define __SSE__ 1' %t
// RUN: grep '#define __SSSE3__ 1' %t | count 0
-// RUN: %clang -ccc-host-triple i386-unknown-unknown -march=pentium-m -x c -E -dM -o %t %s
+// RUN: %clang -target i386-unknown-unknown -march=pentium-m -x c -E -dM -o %t %s
// RUN: grep '#define __SSE2_MATH__ 1' %t
// RUN: grep '#define __SSE2__ 1' %t
// RUN: grep '#define __SSE3__ 1' %t | count 0
diff --git a/test/Rewriter/blockcast3.mm b/test/Rewriter/blockcast3.mm
index 97f417c..8b35528 100644
--- a/test/Rewriter/blockcast3.mm
+++ b/test/Rewriter/blockcast3.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// radar 7607781
diff --git a/test/Rewriter/blockstruct.m b/test/Rewriter/blockstruct.m
index 977e0d6..ef85c58 100644
--- a/test/Rewriter/blockstruct.m
+++ b/test/Rewriter/blockstruct.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar://8918702
diff --git a/test/Rewriter/crash.m b/test/Rewriter/crash.m
index 107b7a5..c61100e 100644
--- a/test/Rewriter/crash.m
+++ b/test/Rewriter/crash.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc -o - %s
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s
// rdar://5950938
@interface NSArray {}
+ (id)arrayWithObjects:(id)firstObj, ...;
diff --git a/test/Rewriter/finally.m b/test/Rewriter/finally.m
index ab5d838..8fd475c 100644
--- a/test/Rewriter/finally.m
+++ b/test/Rewriter/finally.m
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -rewrite-objc -fobjc-exceptions -verify %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -verify %s -o -
int main() {
@try {
- printf("executing try"); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
+ printf("executing try"); // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
} @finally {
diff --git a/test/Rewriter/func-in-impl.m b/test/Rewriter/func-in-impl.m
new file mode 100644
index 0000000..350a726
--- /dev/null
+++ b/test/Rewriter/func-in-impl.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fobjc-fragile-abi -rewrite-objc %t.m -o - | FileCheck %s
+
+@interface I {
+ id _delegate;
+}
+-(void)foo;
+@end
+
+@implementation I
+
+static void KKKK(int w);
+
+-(void) foo {
+ KKKK(0);
+}
+
+static void KKKK(int w) {
+ I *self = (I *)0;
+ if ([self->_delegate respondsToSelector:@selector(handlePortMessage:)]) {
+ }
+}
+
+-(void) foo2 {
+ KKKK(0);
+}
+
+@end
+
+// CHECK: if (((id (*)(id, SEL, ...))(void *)objc_msgSend)((id)((struct I_IMPL *)self)->_delegate, sel_registerName("respondsToSelector:"), sel_registerName("handlePortMessage:")))
diff --git a/test/Rewriter/id-test-3.m b/test/Rewriter/id-test-3.m
index 8557f2b..d7a7bf3 100644
--- a/test/Rewriter/id-test-3.m
+++ b/test/Rewriter/id-test-3.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol P
- (id<P>) Meth: (id<P>) Arg;
diff --git a/test/Rewriter/inner-block-helper-funcs.mm b/test/Rewriter/inner-block-helper-funcs.mm
index 33567bc..d30e1dc 100644
--- a/test/Rewriter/inner-block-helper-funcs.mm
+++ b/test/Rewriter/inner-block-helper-funcs.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// rdar://9846759
diff --git a/test/Rewriter/instancetype-test.mm b/test/Rewriter/instancetype-test.mm
index 97fbe09..a92a3f7 100644
--- a/test/Rewriter/instancetype-test.mm
+++ b/test/Rewriter/instancetype-test.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
void *sel_registerName(const char *);
diff --git a/test/Rewriter/ivar-encoding-1.m b/test/Rewriter/ivar-encoding-1.m
index af11ce2..d294943 100644
--- a/test/Rewriter/ivar-encoding-1.m
+++ b/test/Rewriter/ivar-encoding-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface Intf
{
diff --git a/test/Rewriter/ivar-encoding-2.m b/test/Rewriter/ivar-encoding-2.m
index 4650bde..da60c79 100644
--- a/test/Rewriter/ivar-encoding-2.m
+++ b/test/Rewriter/ivar-encoding-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@implementation Intf
{
diff --git a/test/Rewriter/metadata-test-1.m b/test/Rewriter/metadata-test-1.m
index 5dc1a33..b2d6e8d 100644
--- a/test/Rewriter/metadata-test-1.m
+++ b/test/Rewriter/metadata-test-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface Intf
@end
diff --git a/test/Rewriter/metadata-test-2.m b/test/Rewriter/metadata-test-2.m
index 0fd0429..90399f7 100644
--- a/test/Rewriter/metadata-test-2.m
+++ b/test/Rewriter/metadata-test-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
typedef struct _NSPoint {
float x;
diff --git a/test/Rewriter/method-encoding-1.m b/test/Rewriter/method-encoding-1.m
index 08ee24b..27abea5 100644
--- a/test/Rewriter/method-encoding-1.m
+++ b/test/Rewriter/method-encoding-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol P1
- (void) MyProtoMeth : (int **) arg1 : (void*) arg2;
diff --git a/test/Rewriter/objc-bool-literal-check-modern.mm b/test/Rewriter/objc-bool-literal-check-modern.mm
new file mode 100644
index 0000000..b28e594
--- /dev/null
+++ b/test/Rewriter/objc-bool-literal-check-modern.mm
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11124775
+
+typedef signed char BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
+
+// CHECK: return ((signed char)1);
+// CHECK: return ((signed char)0);
+// CHECK: which (((signed char)1));
+// CHECK: which (((signed char)0));
+// CHECK: return ((signed char)1);
diff --git a/test/Rewriter/objc-bool-literal-modern-1.mm b/test/Rewriter/objc-bool-literal-modern-1.mm
new file mode 100644
index 0000000..7825172
--- /dev/null
+++ b/test/Rewriter/objc-bool-literal-modern-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"__declspec(X)=" %t-rw.cpp
+// rdar://11231426
+
+typedef bool BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
+
+void y(BOOL (^foo)());
+
+void x() {
+ y(^{
+ return __objc_yes;
+ });
+}
diff --git a/test/Rewriter/objc-bool-literal-modern.mm b/test/Rewriter/objc-bool-literal-modern.mm
new file mode 100644
index 0000000..6bbbb44
--- /dev/null
+++ b/test/Rewriter/objc-bool-literal-modern.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -D"__declspec(X)=" %t-rw.cpp
+// rdar://11124775
+
+typedef signed char BOOL;
+
+BOOL yes() {
+ return __objc_yes;
+}
+
+BOOL no() {
+ return __objc_no;
+}
+
+BOOL which (int flag) {
+ return flag ? yes() : no();
+}
+
+int main() {
+ which (__objc_yes);
+ which (__objc_no);
+ return __objc_yes;
+}
diff --git a/test/Rewriter/objc-encoding-bug-1.m b/test/Rewriter/objc-encoding-bug-1.m
index 5605b66..083b570 100644
--- a/test/Rewriter/objc-encoding-bug-1.m
+++ b/test/Rewriter/objc-encoding-bug-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
typedef struct NSMethodFrameArgInfo {
struct NSMethodFrameArgInfo *subInfo;
diff --git a/test/Rewriter/objc-ivar-receiver-1.m b/test/Rewriter/objc-ivar-receiver-1.m
index 5fb028e..5195042 100644
--- a/test/Rewriter/objc-ivar-receiver-1.m
+++ b/test/Rewriter/objc-ivar-receiver-1.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
-// RUN: %clang_cc1 -rewrite-objc %s -o - | grep 'newInv->_container'
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep 'newInv->_container'
@interface NSMutableArray
- (void)addObject:(id)addObject;
diff --git a/test/Rewriter/objc-modern-class-init-hooks.mm b/test/Rewriter/objc-modern-class-init-hooks.mm
new file mode 100644
index 0000000..c294c79
--- /dev/null
+++ b/test/Rewriter/objc-modern-class-init-hooks.mm
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar:// 11124354
+
+@interface Root @end
+
+@interface Super : Root
+@end
+
+@interface Sub : Super
+@end
+
+@implementation Sub @end
+
+@implementation Root @end
+
+@interface Root(Cat) @end
+
+@interface Sub(Cat) @end
+
+@implementation Root(Cat) @end
+
+@implementation Sub(Cat) @end
+
+
+// CHECK: #pragma section(".objc_inithooks$B", long, read, write)
+// CHECK: __declspec(allocate(".objc_inithooks$B")) static void *OBJC_CLASS_SETUP[] = {
+// CHECK: (void *)&OBJC_CLASS_SETUP_$_Sub,
+// CHECK: (void *)&OBJC_CLASS_SETUP_$_Root,
+// CHECK: };
+
+// CHECK: #pragma section(".objc_inithooks$B", long, read, write)
+// CHECK: __declspec(allocate(".objc_inithooks$B")) static void *OBJC_CATEGORY_SETUP[] = {
+// CHECK: (void *)&OBJC_CATEGORY_SETUP_$_Root_$_Cat,
+// CHECK: (void *)&OBJC_CATEGORY_SETUP_$_Sub_$_Cat,
+// CHECK: };
diff --git a/test/Rewriter/objc-modern-class-init.mm b/test/Rewriter/objc-modern-class-init.mm
new file mode 100644
index 0000000..b0326a4
--- /dev/null
+++ b/test/Rewriter/objc-modern-class-init.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar:// 11076938
+
+@interface Root @end
+
+@interface Super : Root
+@end
+
+@interface Sub : Super
+@end
+
+@implementation Sub @end
+
+@implementation Root @end
+
+@interface Root(Cat) @end
+
+@interface Sub(Cat) @end
+
+@implementation Root(Cat) @end
+
+@implementation Sub(Cat) @end
diff --git a/test/Rewriter/objc-modern-container-subscript.mm b/test/Rewriter/objc-modern-container-subscript.mm
new file mode 100644
index 0000000..d6bb9c2
--- /dev/null
+++ b/test/Rewriter/objc-modern-container-subscript.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11203853
+
+void *sel_registerName(const char *);
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+#if __has_feature(objc_subscripting)
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+#if __has_feature(objc_subscripting)
+@interface XNSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+#endif
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@class NSString;
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10];
+
+ array[10] = oldObject;
+
+ id unknown_array;
+ oldObject = unknown_array[1];
+
+ unknown_array[1] = oldObject;
+
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject;
+ oldObject = dictionary[key];
+ dictionary[key] = newObject; // replace oldObject with newObject
+}
+
diff --git a/test/Rewriter/objc-modern-implicit-cast.mm b/test/Rewriter/objc-modern-implicit-cast.mm
new file mode 100644
index 0000000..e612199
--- /dev/null
+++ b/test/Rewriter/objc-modern-implicit-cast.mm
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11202764
+
+typedef void(^BL)(void);
+
+id return_id(void(^block)(void)) {
+ return block;
+}
+
+BL return_block(id obj) {
+ return obj;
+}
+
+int main()
+{
+ void(^block)(void);
+ id obj;
+ block = obj; // AnyPointerToBlockPointerCast
+ obj = block; // BlockPointerToObjCPointerCast
+
+ id obj1 = block;
+
+ void(^block1)(void) = obj1;
+
+ return_id(block1);
+
+ return_id(obj1);
+
+ return_block(block1);
+
+ return_block(obj1);
+}
diff --git a/test/Rewriter/objc-modern-ivar-receiver-1.mm b/test/Rewriter/objc-modern-ivar-receiver-1.mm
new file mode 100644
index 0000000..a5c17a6
--- /dev/null
+++ b/test/Rewriter/objc-modern-ivar-receiver-1.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+void *sel_registerName(const char *);
+
+@interface NSMutableArray
+- (void)addObject:(id)addObject;
+@end
+
+@interface NSInvocation {
+@private
+ id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+@end
+
+@implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+ NSInvocation *newInv;
+ id obj = newInv->_container;
+ [newInv->_container addObject:0];
+ return 0;
+}
+@end
+
+// CHECK: id obj = (*(id *)((char *)newInv + OBJC_IVAR_$_NSInvocation$_container));
+// rdar://11076938
+// CHECK: struct _class_t *superclass;
+// CHECK: extern "C" __declspec(dllimport) struct objc_cache _objc_empty_cache;
diff --git a/test/Rewriter/objc-modern-linkage-spec.mm b/test/Rewriter/objc-modern-linkage-spec.mm
new file mode 100644
index 0000000..028d787
--- /dev/null
+++ b/test/Rewriter/objc-modern-linkage-spec.mm
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-attributes -D"__declspec(X)=" %t-rw.cpp
+// rdar://11169733
+
+extern "C" __declspec(dllexport)
+@interface Test @end
+
+@implementation Test @end
+
+extern "C" {
+__declspec(dllexport)
+@interface Test1 @end
+
+@implementation Test1 @end
+
+__declspec(dllexport)
+@interface Test2 @end
+
+@implementation Test2 @end
+};
+
diff --git a/test/Rewriter/objc-modern-metadata-visibility.mm b/test/Rewriter/objc-modern-metadata-visibility.mm
new file mode 100644
index 0000000..42adf86
--- /dev/null
+++ b/test/Rewriter/objc-modern-metadata-visibility.mm
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://11144048
+
+@class NSString;
+
+@interface NSObject {
+ Class isa;
+}
+@end
+
+@interface Sub : NSObject {
+ int subIvar;
+ NSString *nsstring;
+@private
+ id PrivateIvar;
+}
+@end
+
+@implementation Sub
+- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
+@end
+
+@interface NSString @end
+@implementation NSString @end
+
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long OBJC_IVAR_$_Sub$PrivateIvar;
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
+// CHECK: #pragma warning(disable:4273)
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
+// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int OBJC_IVAR_$_Sub$PrivateIvar
+// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_NSObject;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
+// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_CLASS_$_NSObject;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString;
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_NSString
+// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString
diff --git a/test/Rewriter/objc-modern-numeric-literal.mm b/test/Rewriter/objc-modern-numeric-literal.mm
new file mode 100644
index 0000000..d27d03d
--- /dev/null
+++ b/test/Rewriter/objc-modern-numeric-literal.mm
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://10803676
+
+extern "C" void *sel_registerName(const char *);
+
+typedef signed char BOOL;
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
+#if __has_feature(objc_bool)
+#define YES __objc_yes
+#define NO __objc_no
+#else
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+#endif
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value ;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
+@end
+
+int main(int argc, const char *argv[]) {
+ // character literals.
+ NSNumber *theLetterZ = @'Z'; // equivalent to [NSNumber numberWithChar:'Z']
+
+ // integral literals.
+ NSNumber *fortyTwo = @42; // equivalent to [NSNumber numberWithInt:42]
+ NSNumber *fortyTwoUnsigned = @42U; // equivalent to [NSNumber numberWithUnsignedInt:42U]
+ NSNumber *fortyTwoLong = @42L; // equivalent to [NSNumber numberWithLong:42L]
+ NSNumber *fortyTwoLongLong = @42LL; // equivalent to [NSNumber numberWithLongLong:42LL]
+
+ // floating point literals.
+ NSNumber *piFloat = @3.141592654F; // equivalent to [NSNumber numberWithFloat:3.141592654F]
+ NSNumber *piDouble = @3.1415926535; // equivalent to [NSNumber numberWithDouble:3.1415926535]
+
+ // BOOL literals.
+ NSNumber *yesNumber = @YES; // equivalent to [NSNumber numberWithBool:YES]
+ NSNumber *noNumber = @NO; // equivalent to [NSNumber numberWithBool:NO]
+
+ NSNumber *trueNumber = @true; // equivalent to [NSNumber numberWithBool:(BOOL)true]
+ NSNumber *falseNumber = @false; // equivalent to [NSNumber numberWithBool:(BOOL)false]
+}
+
+// CHECK: NSNumber *theLetterZ = ((NSNumber *(*)(id, SEL, char))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithChar:"), 'Z');
+// CHECK: NSNumber *fortyTwo = ((NSNumber *(*)(id, SEL, int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithInt:"), 42);
+// CHECK: NSNumber *fortyTwoUnsigned = ((NSNumber *(*)(id, SEL, unsigned int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithUnsignedInt:"), 42U);
+// CHECK: NSNumber *fortyTwoLong = ((NSNumber *(*)(id, SEL, long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLong:"), 42L);
+// CHECK: NSNumber *fortyTwoLongLong = ((NSNumber *(*)(id, SEL, long long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLongLong:"), 42LL);
+// CHECK: NSNumber *piFloat = ((NSNumber *(*)(id, SEL, float))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithFloat:"), 3.1415927);
+// CHECK: NSNumber *piDouble = ((NSNumber *(*)(id, SEL, double))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithDouble:"), 3.1415926535);
+// CHECK: NSNumber *yesNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)true);
+// CHECK: NSNumber *noNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)false);
+// CHECK: NSNumber *trueNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)true);
+// CHECK: NSNumber *falseNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)false);
diff --git a/test/Rewriter/objc-modern-property-attributes.mm b/test/Rewriter/objc-modern-property-attributes.mm
new file mode 100644
index 0000000..7d74a95
--- /dev/null
+++ b/test/Rewriter/objc-modern-property-attributes.mm
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+// rdar://11095151
+
+typedef void (^void_block_t)(void);
+
+@interface PropertyClass {
+ int q;
+ void_block_t __completion;
+ PropertyClass* YVAR;
+ id ID;
+}
+@property int q;
+@property int r;
+
+@property (copy) void_block_t completionBlock;
+@property (retain) PropertyClass* Yblock;
+@property (copy) id ID;
+
+@end
+
+@implementation PropertyClass
+@synthesize q; // attributes should be "Ti,Vq"
+@dynamic r; // attributes should be "Ti,D"
+@synthesize completionBlock=__completion; // "T@?,C,V__completion"
+@synthesize Yblock = YVAR; // "T@\"PropertyClass\",&,VYVAR"
+@synthesize ID; // "T@,C,VID"
+@end
+
+// CHECK: Ti,Vq
+// CHECK: Ti,D
+// CHECK: T@?,C,V__completion
+// CHECK: T@\"PropertyClass\",&,VYVAR
+
diff --git a/test/Rewriter/objc-string-concat-1.m b/test/Rewriter/objc-string-concat-1.m
index 32b2526..80a9f04 100644
--- a/test/Rewriter/objc-string-concat-1.m
+++ b/test/Rewriter/objc-string-concat-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@class NSString;
diff --git a/test/Rewriter/objc-super-test.m b/test/Rewriter/objc-super-test.m
index 38f68b9..fa95ad2 100644
--- a/test/Rewriter/objc-super-test.m
+++ b/test/Rewriter/objc-super-test.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o - | grep objc_msgSendSuper | grep MainMethod
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep objc_msgSendSuper | grep MainMethod
typedef struct objc_selector *SEL;
typedef struct objc_object *id;
diff --git a/test/Rewriter/objc-synchronized-1.m b/test/Rewriter/objc-synchronized-1.m
index 27f2a0a..df55536 100644
--- a/test/Rewriter/objc-synchronized-1.m
+++ b/test/Rewriter/objc-synchronized-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
id SYNCH_EXPR();
void SYNCH_BODY();
diff --git a/test/Rewriter/properties.m b/test/Rewriter/properties.m
index ca4a199..493fc3f 100644
--- a/test/Rewriter/properties.m
+++ b/test/Rewriter/properties.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
void *sel_registerName(const char *);
diff --git a/test/Rewriter/property-dot-syntax.mm b/test/Rewriter/property-dot-syntax.mm
index 846bd82..c8ee723 100644
--- a/test/Rewriter/property-dot-syntax.mm
+++ b/test/Rewriter/property-dot-syntax.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 8520727
diff --git a/test/Rewriter/protocol-rewrite-1.m b/test/Rewriter/protocol-rewrite-1.m
index 440527b..687a259 100644
--- a/test/Rewriter/protocol-rewrite-1.m
+++ b/test/Rewriter/protocol-rewrite-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
typedef struct MyWidget {
int a;
diff --git a/test/Rewriter/protocol-rewrite-2.m b/test/Rewriter/protocol-rewrite-2.m
index b3eb16a..e0ec4f9 100644
--- a/test/Rewriter/protocol-rewrite-2.m
+++ b/test/Rewriter/protocol-rewrite-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o %t.cpp
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o %t.cpp
// RUN: %clang_cc1 -fsyntax-only %t.cpp
// rdar://10234024
diff --git a/test/Rewriter/rewrite-anonymous-union.m b/test/Rewriter/rewrite-anonymous-union.m
index 579a068..339524f 100644
--- a/test/Rewriter/rewrite-anonymous-union.m
+++ b/test/Rewriter/rewrite-anonymous-union.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc -o - %s
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s
// rdar://6948022
typedef unsigned int uint32_t;
diff --git a/test/Rewriter/rewrite-api-bug.m b/test/Rewriter/rewrite-api-bug.m
index 03fc89f..ebaa0be 100644
--- a/test/Rewriter/rewrite-api-bug.m
+++ b/test/Rewriter/rewrite-api-bug.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface MyDerived
- (void) instanceMethod;
diff --git a/test/Rewriter/rewrite-block-argument.m b/test/Rewriter/rewrite-block-argument.m
index 4ebbef9..898f983 100644
--- a/test/Rewriter/rewrite-block-argument.m
+++ b/test/Rewriter/rewrite-block-argument.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp
// radar 7987817
diff --git a/test/Rewriter/rewrite-block-consts.mm b/test/Rewriter/rewrite-block-consts.mm
index c74873f..fca10ed 100644
--- a/test/Rewriter/rewrite-block-consts.mm
+++ b/test/Rewriter/rewrite-block-consts.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 8243071
diff --git a/test/Rewriter/rewrite-block-ivar-call.mm b/test/Rewriter/rewrite-block-ivar-call.mm
index 80e8caa..2ec27b3 100644
--- a/test/Rewriter/rewrite-block-ivar-call.mm
+++ b/test/Rewriter/rewrite-block-ivar-call.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -o - %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s
@interface Foo {
void (^_block)(void);
diff --git a/test/Rewriter/rewrite-block-literal-1.mm b/test/Rewriter/rewrite-block-literal-1.mm
index 04302d1..5213f50 100644
--- a/test/Rewriter/rewrite-block-literal-1.mm
+++ b/test/Rewriter/rewrite-block-literal-1.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 9254348
diff --git a/test/Rewriter/rewrite-block-literal.c b/test/Rewriter/rewrite-block-literal.mm
index be9c06f..732d0b9 100644
--- a/test/Rewriter/rewrite-block-literal.c
+++ b/test/Rewriter/rewrite-block-literal.mm
@@ -1,4 +1,9 @@
-// RUN: %clang_cc1 -rewrite-objc %s -fblocks -o -
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+// rdar: // 11006566
void I( void (^)(void));
void (^noop)(void);
@@ -36,11 +41,6 @@ void test2() {
}
}
-
-void (^test3())(void) {
- return ^{};
-}
-
void test4() {
void (^noop)(void) = ^{};
void (*noop2)() = 0;
@@ -61,18 +61,12 @@ void test5() {
void *X;
-void test_arguments() {
- int y;
- int (^c)(char);
- (1 ? c : 0)('x');
- (1 ? 0 : c)('x');
-
- (1 ? c : c)('x');
-}
-
static int global_x = 10;
void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
+// CHECK: static __global_block_block_impl_0 __global_global_block_block_impl_0((void *)__global_block_block_func_0, &__global_block_block_desc_0_DATA);
+// CHECK: void (*global_block)(void) = (void (*)())&__global_global_block_block_impl_0;
+
typedef void (^void_block_t)(void);
static const void_block_t myBlock = ^{ };
diff --git a/test/Rewriter/rewrite-block-pointer.mm b/test/Rewriter/rewrite-block-pointer.mm
index d010a22..4838b74 100644
--- a/test/Rewriter/rewrite-block-pointer.mm
+++ b/test/Rewriter/rewrite-block-pointer.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7638400
diff --git a/test/Rewriter/rewrite-block-property.m b/test/Rewriter/rewrite-block-property.m
index 505e04b..5c44b7d 100644
--- a/test/Rewriter/rewrite-block-property.m
+++ b/test/Rewriter/rewrite-block-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar://9055596
diff --git a/test/Rewriter/rewrite-byref-in-nested-blocks.mm b/test/Rewriter/rewrite-byref-in-nested-blocks.mm
index a8f5b14..b1ff46b 100644
--- a/test/Rewriter/rewrite-byref-in-nested-blocks.mm
+++ b/test/Rewriter/rewrite-byref-in-nested-blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7692350
diff --git a/test/Rewriter/rewrite-byref-vars.mm b/test/Rewriter/rewrite-byref-vars.mm
index 007ab43..14a182a 100644
--- a/test/Rewriter/rewrite-byref-vars.mm
+++ b/test/Rewriter/rewrite-byref-vars.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7540194
@@ -53,5 +53,5 @@ __declspec(dllexport) extern "C" __declspec(dllexport) void XXXXBreakTheRewriter
- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; }
@end
-// $CLANG -cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks bug.mm
+// $CLANG -cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks bug.mm
// g++ -c -D"__declspec(X)=" bug.cpp
diff --git a/test/Rewriter/rewrite-cast-ivar-access.mm b/test/Rewriter/rewrite-cast-ivar-access.mm
index c04cbab..ccc1cde 100644
--- a/test/Rewriter/rewrite-cast-ivar-access.mm
+++ b/test/Rewriter/rewrite-cast-ivar-access.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// radar 7575882
diff --git a/test/Rewriter/rewrite-cast-ivar-modern-access.mm b/test/Rewriter/rewrite-cast-ivar-modern-access.mm
new file mode 100644
index 0000000..4a6cb32
--- /dev/null
+++ b/test/Rewriter/rewrite-cast-ivar-modern-access.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface F {
+ int supervar;
+}
+@end
+
+@interface G : F {
+@public
+ int ivar;
+}
+@end
+
+@implementation G
+- (void)foo:(F *)arg {
+ int q = arg->supervar;
+ int v = ((G *)arg)->ivar;
+}
+@end
+
+void objc_assign_strongCast(id);
+void __CFAssignWithWriteBarrier(void **location, void *value) {
+ objc_assign_strongCast((id)value);
+}
+
+// radar 7607605
+@interface RealClass {
+ @public
+ int f;
+}
+@end
+
+@implementation RealClass
+@end
+
+@interface Foo {
+ id reserved;
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ ((RealClass*)reserved)->f = 99;
+}
+@end
diff --git a/test/Rewriter/rewrite-cast-to-bool.mm b/test/Rewriter/rewrite-cast-to-bool.mm
index 0e9f364..b3272b6 100644
--- a/test/Rewriter/rewrite-cast-to-bool.mm
+++ b/test/Rewriter/rewrite-cast-to-bool.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 9899834
diff --git a/test/Rewriter/rewrite-category-property.mm b/test/Rewriter/rewrite-category-property.mm
index 6b8f076..b54bb67 100644
--- a/test/Rewriter/rewrite-category-property.mm
+++ b/test/Rewriter/rewrite-category-property.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// radar 7630636
diff --git a/test/Rewriter/rewrite-constructor-init.mm b/test/Rewriter/rewrite-constructor-init.mm
index 534e7fa..f12de1f 100644
--- a/test/Rewriter/rewrite-constructor-init.mm
+++ b/test/Rewriter/rewrite-constructor-init.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar : // 8213998
diff --git a/test/Rewriter/rewrite-eh.m b/test/Rewriter/rewrite-eh.m
index 9045f7f..46d1930 100644
--- a/test/Rewriter/rewrite-eh.m
+++ b/test/Rewriter/rewrite-eh.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc -fobjc-exceptions -o - %s
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -o - %s
// rdar://7522880
@interface NSException
diff --git a/test/Rewriter/rewrite-elaborated-type.mm b/test/Rewriter/rewrite-elaborated-type.mm
index 9867b4d..bef56b9 100644
--- a/test/Rewriter/rewrite-elaborated-type.mm
+++ b/test/Rewriter/rewrite-elaborated-type.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 8143056
diff --git a/test/Rewriter/rewrite-extern-c.mm b/test/Rewriter/rewrite-extern-c.mm
index 1c8e90f..c610493 100644
--- a/test/Rewriter/rewrite-extern-c.mm
+++ b/test/Rewriter/rewrite-extern-c.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -o - %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s
// radar 7546096
extern "C" {
diff --git a/test/Rewriter/rewrite-foreach-1.m b/test/Rewriter/rewrite-foreach-1.m
index e68b45d..f57e13c 100644
--- a/test/Rewriter/rewrite-foreach-1.m
+++ b/test/Rewriter/rewrite-foreach-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol P @end
diff --git a/test/Rewriter/rewrite-foreach-2.m b/test/Rewriter/rewrite-foreach-2.m
index 5ed15a3..228612a 100644
--- a/test/Rewriter/rewrite-foreach-2.m
+++ b/test/Rewriter/rewrite-foreach-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol P @end
diff --git a/test/Rewriter/rewrite-foreach-3.m b/test/Rewriter/rewrite-foreach-3.m
index ffe8295..ef3803f 100644
--- a/test/Rewriter/rewrite-foreach-3.m
+++ b/test/Rewriter/rewrite-foreach-3.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol P @end
diff --git a/test/Rewriter/rewrite-foreach-4.m b/test/Rewriter/rewrite-foreach-4.m
index 5b66e97..42cb2fb 100644
--- a/test/Rewriter/rewrite-foreach-4.m
+++ b/test/Rewriter/rewrite-foreach-4.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface MyList
- (id) allKeys;
diff --git a/test/Rewriter/rewrite-foreach-5.m b/test/Rewriter/rewrite-foreach-5.m
index 7baccc3..2940f45 100644
--- a/test/Rewriter/rewrite-foreach-5.m
+++ b/test/Rewriter/rewrite-foreach-5.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
void *sel_registerName(const char *);
diff --git a/test/Rewriter/rewrite-foreach-6.m b/test/Rewriter/rewrite-foreach-6.m
index 96b472a..968c6f4 100644
--- a/test/Rewriter/rewrite-foreach-6.m
+++ b/test/Rewriter/rewrite-foreach-6.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar://5716356
// FIXME: Should be able to pipe into clang, but code is not
diff --git a/test/Rewriter/rewrite-foreach-7.m b/test/Rewriter/rewrite-foreach-7.m
index 9fa6a1a..8c9293f 100644
--- a/test/Rewriter/rewrite-foreach-7.m
+++ b/test/Rewriter/rewrite-foreach-7.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@class NSArray;
int main() {
diff --git a/test/Rewriter/rewrite-foreach-in-block.mm b/test/Rewriter/rewrite-foreach-in-block.mm
index 971330c..d0a8728 100644
--- a/test/Rewriter/rewrite-foreach-in-block.mm
+++ b/test/Rewriter/rewrite-foreach-in-block.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 9878420
diff --git a/test/Rewriter/rewrite-foreach-protocol-id.m b/test/Rewriter/rewrite-foreach-protocol-id.m
index 85d0d0d..034fb7a 100644
--- a/test/Rewriter/rewrite-foreach-protocol-id.m
+++ b/test/Rewriter/rewrite-foreach-protocol-id.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 9039342
diff --git a/test/Rewriter/rewrite-forward-class.m b/test/Rewriter/rewrite-forward-class.m
index 1d3af6f..0ac620a 100644
--- a/test/Rewriter/rewrite-forward-class.m
+++ b/test/Rewriter/rewrite-forward-class.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar://6969189
diff --git a/test/Rewriter/rewrite-forward-class.mm b/test/Rewriter/rewrite-forward-class.mm
index 74c0508..8e4eda6 100644
--- a/test/Rewriter/rewrite-forward-class.mm
+++ b/test/Rewriter/rewrite-forward-class.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
extern "C" {
diff --git a/test/Rewriter/rewrite-function-decl.mm b/test/Rewriter/rewrite-function-decl.mm
index 023e55d..883d393 100644
--- a/test/Rewriter/rewrite-function-decl.mm
+++ b/test/Rewriter/rewrite-function-decl.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s
extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
__block int aBlockVariable = 0;
diff --git a/test/Rewriter/rewrite-implementation.mm b/test/Rewriter/rewrite-implementation.mm
index c1d89a3..2cc3387 100644
--- a/test/Rewriter/rewrite-implementation.mm
+++ b/test/Rewriter/rewrite-implementation.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7649577
@@ -11,3 +11,6 @@
@implementation b
@end
+@interface NSArray @end
+@class NSArray;
+@implementation NSArray @end
diff --git a/test/Rewriter/rewrite-ivar-use.m b/test/Rewriter/rewrite-ivar-use.m
index 82cff5b..53b07c4 100644
--- a/test/Rewriter/rewrite-ivar-use.m
+++ b/test/Rewriter/rewrite-ivar-use.m
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -rewrite-objc -fms-extensions %s -o -
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7490331
+void *sel_registerName(const char *);
+
@interface Foo {
int a;
id b;
diff --git a/test/Rewriter/rewrite-local-externs-in-block.mm b/test/Rewriter/rewrite-local-externs-in-block.mm
index d1a56a8..35d282b 100644
--- a/test/Rewriter/rewrite-local-externs-in-block.mm
+++ b/test/Rewriter/rewrite-local-externs-in-block.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7735987
diff --git a/test/Rewriter/rewrite-local-static-id.mm b/test/Rewriter/rewrite-local-static-id.mm
index a0b85f4..b002b6e 100644
--- a/test/Rewriter/rewrite-local-static-id.mm
+++ b/test/Rewriter/rewrite-local-static-id.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp
// radar 7946975
diff --git a/test/Rewriter/rewrite-message-expr.mm b/test/Rewriter/rewrite-message-expr.mm
index d909f3e..dafb31b 100644
--- a/test/Rewriter/rewrite-message-expr.mm
+++ b/test/Rewriter/rewrite-message-expr.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// radar 7617047
diff --git a/test/Rewriter/rewrite-modern-array-literal.mm b/test/Rewriter/rewrite-modern-array-literal.mm
new file mode 100644
index 0000000..208e646
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-array-literal.mm
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://10803676
+
+extern "C" void *sel_registerName(const char *);
+@class NSString;
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+typedef unsigned long NSUInteger;
+
+@interface NSArray
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+int i;
+int main() {
+ NSArray *array = @[ @"Hello", @1234 ];
+ if (i) {
+ NSArray *array = @[ @"Hello", @1234 ];
+ }
+ NSArray *array1 = @[ @"Hello", @1234, @[ @"Hello", @1234 ] ];
+}
+
diff --git a/test/Rewriter/rewrite-modern-block-ivar-call.mm b/test/Rewriter/rewrite-modern-block-ivar-call.mm
new file mode 100644
index 0000000..1bafbdd
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-block-ivar-call.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.m -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface Foo {
+ void (^_block)(void);
+}
+@end
+
+@implementation Foo
+- (void)bar {
+ _block();
+}
+@end
+
+// CHECK: ((void (*)(struct __block_impl *))((struct __block_impl *)(*(void (**)(void))((char *)self + OBJC_IVAR_$_Foo$_block)))->FuncPtr)((struct __block_impl *)(*(void (**)(void))((char *)self + OBJC_IVAR_$_Foo$_block)));
diff --git a/test/Rewriter/rewrite-modern-block.mm b/test/Rewriter/rewrite-modern-block.mm
new file mode 100644
index 0000000..8da723d
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-block.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://11230308
+
+typedef struct {
+ char byte0;
+ char byte1;
+} CFUUIDBytes;
+
+void x(void *);
+
+void y() {
+ __block CFUUIDBytes bytes;
+
+ void (^bar)() = ^{
+ x(&bytes);
+ };
+}
+
+// rdar://11236342
+int foo() {
+ __block int hello;
+}
diff --git a/test/Rewriter/rewrite-modern-catch.m b/test/Rewriter/rewrite-modern-catch.m
new file mode 100644
index 0000000..1900301
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-catch.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+void foo(id arg);
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ } @catch (NSException *e) {
+ foo(e);
+ }
+ @catch (Foo *f) {
+ }
+ @catch (...) {
+ @try {
+ }
+ @catch (Foo *f1) {
+ foo(f1);
+ }
+ @catch (id pid) {
+ foo(pid);
+ }
+ }
+}
+@end
diff --git a/test/Rewriter/rewrite-modern-class.mm b/test/Rewriter/rewrite-modern-class.mm
new file mode 100644
index 0000000..b6be98a
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-class.mm
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol PROTO @end
+
+@interface empty_root @end
+
+@interface root_with_ivars
+{
+ id ROOT_IVAR;
+ id ROOT1_IVAR;
+}
+@end
+
+@interface MAXIMAL : root_with_ivars<PROTO>
+{
+ double D_IVAR;
+ double D_PROPERTY;
+}
+- (void) V_METH;
+@end
+
+@implementation MAXIMAL
+- (void) V_METH {}
+@end
+//=========================================
+@interface empty_class @end
+
+@implementation empty_class @end
+//=========================================
+@interface class_empty_root : empty_root @end
+
+@implementation class_empty_root @end
+//=========================================
+@interface class_with_ivars : empty_root
+{
+ int class_with_ivars_IVAR;
+}
+@end
+
+@implementation class_with_ivars @end
+//=========================================
+@interface class_has_no_ivar : root_with_ivars @end
+
+@implementation class_has_no_ivar @end
+
+//============================class needs to be synthesized here=====================
+@interface SUPER {
+@public
+ double divar;
+ SUPER *p_super;
+}
+@end
+
+@interface INTF @end
+
+@implementation INTF
+- (SUPER *) Meth : (SUPER *)arg {
+ return arg->p_super;
+}
+@end
+
+@class FORM_CLASS;
+@interface INTF_DECL {
+}
+@end
+
+double Meth(INTF_DECL *p, FORM_CLASS *f) {
+ return 1.34;
+}
diff --git a/test/Rewriter/rewrite-modern-container-literal.mm b/test/Rewriter/rewrite-modern-container-literal.mm
new file mode 100644
index 0000000..87b9b89
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-container-literal.mm
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// rdar://10803676
+
+void *sel_registerName(const char *);
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+typedef signed char BOOL;
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value ;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
+@end
+
+@protocol NSCopying @end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSArray
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+id NSUserName();
+
+@interface NSDate
++ (id)date;
+@end
+
+int main() {
+NSArray *array = @[ @"Hello", NSUserName(), [NSDate date], [NSNumber numberWithInt:42]];
+
+NSDictionary *dictionary = @{ @"name" : NSUserName(), @"date" : [NSDate date], @"process" : @"processInfo"};
+
+NSDictionary *dict = @{ @"name":@666, @"man":@__objc_yes, @"date":@1.3 };
+
+}
+
diff --git a/test/Rewriter/rewrite-modern-ivar-use.mm b/test/Rewriter/rewrite-modern-ivar-use.mm
new file mode 100644
index 0000000..ec8d2c7
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-ivar-use.mm
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
+
+void *sel_registerName(const char *);
+
+@interface Foo {
+ int a;
+ id b;
+}
+- (void)bar;
+- (void)baz:(id)q;
+@end
+
+@implementation Foo
+// radar 7522803
+static void foo(id bar) {
+ int i = ((Foo *)bar)->a;
+}
+
+- (void)bar {
+ a = 42;
+}
+- (void)baz:(id)q {
+}
+@end
+
diff --git a/test/Rewriter/rewrite-modern-ivars-1.mm b/test/Rewriter/rewrite-modern-ivars-1.mm
new file mode 100644
index 0000000..376d300
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-ivars-1.mm
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface NSCheapMutableString {
+@private
+ struct S s0;
+ union {
+ char *fat;
+ unsigned char *thin;
+ } contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } flags;
+
+ struct S {
+ int iS1;
+ double dS1;
+ } others;
+
+ union U {
+ int iU1;
+ double dU1;
+ } u_others;
+
+ enum {
+ One, Two
+ } E1;
+
+ enum e {
+ Yes = 1,
+ No = 0
+ } BoOl;
+
+ struct S s1;
+
+ enum e E2;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } Last_contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } Last_flags;
+}
+@end
+
+@interface III {
+@private
+ struct S s0;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } flags;
+
+ enum {
+ One1 = 1000, Two1, Three1
+ } E1;
+
+ struct S s1;
+
+ enum e E2;
+
+ union {
+ char *fat;
+ unsigned char *thin;
+ } Last_contents;
+
+ struct {
+ unsigned int isFat:1;
+ unsigned int freeWhenDone:1;
+ unsigned int refs:30;
+ } Last_flags;
+}
+@end
+
diff --git a/test/Rewriter/rewrite-modern-ivars-2.mm b/test/Rewriter/rewrite-modern-ivars-2.mm
new file mode 100644
index 0000000..0faed5c
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-ivars-2.mm
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface B @end
+
+@interface A {
+ struct s0 {
+ int f0;
+ int f1;
+ } f0;
+ id f1;
+__weak B *f2;
+ int f3 : 5;
+ struct s1 {
+ int *f0;
+ int *f1;
+ } f4[2][1];
+}
+@end
+
+@interface C : A
+@property int p3;
+@end
+
+@implementation C
+@synthesize p3 = _p3;
+@end
+
+@interface A()
+@property int p0;
+@property (assign) __strong id p1;
+@property (assign) __weak id p2;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation A
+@synthesize p0 = _p0;
+@synthesize p1 = _p1;
+@synthesize p2 = _p2;
+@end
+
+@interface D : A
+@property int p3;
+@end
+
+// FIXME: Check layout for this class, once it is clear what the right
+// answer is.
+@implementation D
+@synthesize p3 = _p3;
+@end
+
+typedef unsigned short UInt16;
+
+
+typedef signed char BOOL;
+typedef unsigned int FSCatalogInfoBitmap;
+
+@interface NSFileLocationComponent {
+ @private
+
+ id _specifierOrStandardizedPath;
+ BOOL _carbonCatalogInfoAndNameAreValid;
+ FSCatalogInfoBitmap _carbonCatalogInfoMask;
+ id _name;
+ id _containerComponent;
+ id _presentableName;
+ id _iconAsAttributedString;
+}
+@end
+
+@implementation NSFileLocationComponent @end
+
+// rdar://11229770
+
+@interface Foo {
+ int bar:26;
+}
+@end
+
+@implementation Foo
+@end
+
+@interface Foo1 {
+ int bar:26;
+ int bar2:4;
+}
+@end
+
+@implementation Foo1
+@end
+
+@interface Foo3 {
+ int foo;
+ int bar:26;
+}
+@end
+
+@implementation Foo3
+@end
+
diff --git a/test/Rewriter/rewrite-modern-ivars.mm b/test/Rewriter/rewrite-modern-ivars.mm
new file mode 100644
index 0000000..5e01a44
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-ivars.mm
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol P @end
+@protocol P1 @end
+@interface INTF
+{
+ id CLASS_IVAR;
+ id<P, P1> Q_IVAR;
+
+ void (^_block)(id<P>);
+ void (*_fptr)(void (^_block)(id<P>));
+ char CLASS_EXT_IVAR;
+ id<P, P1> (^ext_block)(id<P>, INTF<P,P1>*, INTF*);
+ id IMPL_IVAR;
+ double D_IMPL_IVAR;
+ INTF<P> *(*imp_fptr)(void (^_block)(id<P>, INTF<P,P1>*));
+ id arr[100];
+}
+@end
+
+@implementation INTF @end
+
+@interface MISC_INTF
+{
+ id CLASS_IVAR;
+ id<P, P1> Q_IVAR;
+
+ void (^_block)(id<P>);
+ void (*_fptr)(void (^_block)(id<P>));
+ unsigned int BF : 8;
+}
+@end
+
+@interface MISC_INTF()
+{
+ char CLASS_EXT_IVAR;
+ id<P, P1> (^ext_block)(id<P>, MISC_INTF<P,P1>*, MISC_INTF*);
+}
+@end
+
+@interface MISC_INTF() {
+ int II1;
+ double DD1; }
+@end
+
+@interface MISC_INTF() { int II2; double DD2; }
+@end
+
+@interface MISC_INTF() { int II3;
+ double DD3; }
+@end
+
+@interface MISC_INTF() { int II4; double DD4;
+}
+@end
+
+@implementation MISC_INTF
+{
+ id IMPL_IVAR;
+ double D_IMPL_IVAR;
+ MISC_INTF<P> *(*imp_fptr)(void (^_block)(id<P>, MISC_INTF<P,P1>*));
+}
+@end
diff --git a/test/Rewriter/rewrite-modern-nested-ivar.mm b/test/Rewriter/rewrite-modern-nested-ivar.mm
new file mode 100644
index 0000000..13e31cd
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-nested-ivar.mm
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -E %s -o %t.m
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.m -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@interface NSURLResponse {
+@public
+ NSURLResponse *InnerResponse;
+}
+@end
+
+@interface NSCachedURLResponseInternal
+{
+ @public
+ NSURLResponse *response;
+}
+@end
+
+@interface NSCachedURLResponse
+{
+ @private
+ NSCachedURLResponseInternal *_internal;
+}
+- (void) Meth;
+@end
+
+@implementation NSCachedURLResponse
+- (void) Meth {
+ _internal->response->InnerResponse = 0;
+ }
+@end
+
+// CHECK: (*(NSURLResponse **)((char *)(*(NSURLResponse **)((char *)(*(NSCachedURLResponseInternal **)((char *)self + OBJC_IVAR_$_NSCachedURLResponse$_internal)) + OBJC_IVAR_$_NSCachedURLResponseInternal$response)) + OBJC_IVAR_$_NSURLResponse$InnerResponse)) = 0;
diff --git a/test/Rewriter/rewrite-modern-protocol.mm b/test/Rewriter/rewrite-modern-protocol.mm
new file mode 100644
index 0000000..a4bd617
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-protocol.mm
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+@protocol ROOT @end
+
+@protocol P1 @end
+
+@protocol P2<ROOT> @end
+
+@class NSObject;
+
+@protocol PROTO <P1, P2>
+- (id) INST_METHOD;
++ (id) CLASS_METHOD : (id)ARG;
+@property id Prop_in_PROTO;
+@optional
+- (id) opt_instance_method;
++ (id) opt_class_method;
+@property (readonly, retain) NSObject *AnotherProperty;
+@required
+- (id) req;
+@optional
+- (id) X_opt_instance_method;
++ (id) X_opt_class_method;
+@end
+
+@interface INTF <PROTO, ROOT>
+@end
+
+@implementation INTF
+@end
diff --git a/test/Rewriter/rewrite-modern-struct-ivar.mm b/test/Rewriter/rewrite-modern-struct-ivar.mm
new file mode 100644
index 0000000..09c02df
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-struct-ivar.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp
+// RUN: FileCheck --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+struct S {
+ int i1;
+ double d1;
+ void (^block1)();
+};
+
+@interface I
+{
+ struct S struct_ivar;
+
+ struct S *pstruct_ivar;
+}
+@end
+
+@implementation I
+- (struct S) dMeth{ return struct_ivar; }
+@end
+
+// CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar));
diff --git a/test/Rewriter/rewrite-modern-synchronized.m b/test/Rewriter/rewrite-modern-synchronized.m
new file mode 100644
index 0000000..e895339
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-synchronized.m
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void *sel_registerName(const char *);
+
+id SYNCH_EXPR();
+void SYNCH_BODY();
+void SYNCH_BEFORE();
+void SYNC_AFTER();
+
+void foo(id sem)
+{
+ SYNCH_BEFORE();
+ @synchronized (SYNCH_EXPR()) {
+ SYNCH_BODY();
+ return;
+ }
+ SYNC_AFTER();
+ @synchronized ([sem self]) {
+ SYNCH_BODY();
+ return;
+ }
+}
+
+void test_sync_with_implicit_finally() {
+ id foo;
+ @synchronized (foo) {
+ return; // The rewriter knows how to generate code for implicit finally
+ }
+}
diff --git a/test/Rewriter/rewrite-modern-throw.m b/test/Rewriter/rewrite-modern-throw.m
new file mode 100644
index 0000000..1912384
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-throw.m
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void *sel_registerName(const char *);
+
+@interface Foo @end
+void TRY();
+void SPLATCH();
+void MYTRY();
+void MYCATCH();
+
+void foo() {
+ @try { TRY(); }
+ @catch (...) { SPLATCH(); @throw; }
+}
+
+int main()
+{
+
+ @try {
+ MYTRY();
+ }
+
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw localException;
+ }
+
+ // no catch clause
+ @try { }
+ @finally { }
+}
+
+
+@interface INST
+{
+ INST* throw_val;
+}
+
+- (id) ThrowThis;
+
+- (void) MainMeth;
+
+@end
+
+
+@implementation INST
+- (id) ThrowThis { return 0; }
+
+- (void) MainMeth {
+ @try {
+ MYTRY();
+ }
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw [self ThrowThis];
+ }
+ @catch (...) {
+ @throw [throw_val ThrowThis];
+ }
+}
+@end
diff --git a/test/Rewriter/rewrite-modern-try-catch-finally.m b/test/Rewriter/rewrite-modern-try-catch-finally.m
new file mode 100644
index 0000000..9beab7d
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-try-catch-finally.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+extern int printf(const char *, ...);
+
+int main() {
+ @try {
+ }
+ @finally {
+ }
+ while (1) {
+ @try {
+ printf("executing try");
+ break;
+ } @finally {
+ printf("executing finally");
+ }
+ printf("executing after finally block");
+ }
+ @try {
+ printf("executing try");
+ } @finally {
+ printf("executing finally");
+ }
+ return 0;
+}
+
+void test2_try_with_implicit_finally() {
+ @try {
+ return;
+ } @catch (id e) {
+
+ }
+}
+
+void FINALLY();
+void TRY();
+void CATCH();
+
+@interface NSException
+@end
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ TRY();
+ }
+ @catch (NSException *e) {
+ CATCH();
+ }
+ @finally {
+ FINALLY();
+ }
+}
+@end
diff --git a/test/Rewriter/rewrite-modern-try-finally.m b/test/Rewriter/rewrite-modern-try-finally.m
new file mode 100644
index 0000000..500133b
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-try-finally.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+
+typedef struct objc_class *Class;
+typedef struct objc_object {
+ Class isa;
+} *id;
+
+void FINALLY();
+void TRY();
+void INNER_FINALLY();
+void INNER_TRY();
+void CHECK();
+
+@interface Foo
+@end
+
+@implementation Foo
+- (void)bar {
+ @try {
+ TRY();
+ }
+ @finally {
+ FINALLY();
+ }
+ CHECK();
+ @try {
+ TRY();
+ }
+ @finally {
+ @try {
+ INNER_TRY();
+ }
+ @finally {
+ INNER_FINALLY();
+ }
+ FINALLY();
+ }
+}
+@end
diff --git a/test/Rewriter/rewrite-nest.m b/test/Rewriter/rewrite-nest.m
index ebbcded..a08f947 100644
--- a/test/Rewriter/rewrite-nest.m
+++ b/test/Rewriter/rewrite-nest.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface NSMapTable @end
@interface NSEnumerator @end
diff --git a/test/Rewriter/rewrite-nested-blocks-1.mm b/test/Rewriter/rewrite-nested-blocks-1.mm
index 582f5f4..672486b 100644
--- a/test/Rewriter/rewrite-nested-blocks-1.mm
+++ b/test/Rewriter/rewrite-nested-blocks-1.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7696893
diff --git a/test/Rewriter/rewrite-nested-blocks-2.mm b/test/Rewriter/rewrite-nested-blocks-2.mm
index 5a8e1cc..1555767 100644
--- a/test/Rewriter/rewrite-nested-blocks-2.mm
+++ b/test/Rewriter/rewrite-nested-blocks-2.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// grep "static void __FUNC_block_copy_" %t-rw.cpp | count 2
// rdar://8499592
diff --git a/test/Rewriter/rewrite-nested-blocks.mm b/test/Rewriter/rewrite-nested-blocks.mm
index 1a6bcdd..6c860ef 100644
--- a/test/Rewriter/rewrite-nested-blocks.mm
+++ b/test/Rewriter/rewrite-nested-blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7682149
diff --git a/test/Rewriter/rewrite-nested-ivar.mm b/test/Rewriter/rewrite-nested-ivar.mm
index 1787cc7..bab221d 100644
--- a/test/Rewriter/rewrite-nested-ivar.mm
+++ b/test/Rewriter/rewrite-nested-ivar.mm
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
// radar 7583971
diff --git a/test/Rewriter/rewrite-nested-property-in-blocks.mm b/test/Rewriter/rewrite-nested-property-in-blocks.mm
index 2dffe66..6a03d73 100755
--- a/test/Rewriter/rewrite-nested-property-in-blocks.mm
+++ b/test/Rewriter/rewrite-nested-property-in-blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 8608293
diff --git a/test/Rewriter/rewrite-no-nextline.mm b/test/Rewriter/rewrite-no-nextline.mm
index 0c3657c..4ef3715 100644
--- a/test/Rewriter/rewrite-no-nextline.mm
+++ b/test/Rewriter/rewrite-no-nextline.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7946975
diff --git a/test/Rewriter/rewrite-property-attributes.mm b/test/Rewriter/rewrite-property-attributes.mm
index 41f457c..c707603 100644
--- a/test/Rewriter/rewrite-property-attributes.mm
+++ b/test/Rewriter/rewrite-property-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7214439
diff --git a/test/Rewriter/rewrite-property-set-cfstring.mm b/test/Rewriter/rewrite-property-set-cfstring.mm
index 5e670bf..3ac9065 100644
--- a/test/Rewriter/rewrite-property-set-cfstring.mm
+++ b/test/Rewriter/rewrite-property-set-cfstring.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 8527018
diff --git a/test/Rewriter/rewrite-protocol-property.mm b/test/Rewriter/rewrite-protocol-property.mm
index b70b54f..3a53f23 100644
--- a/test/Rewriter/rewrite-protocol-property.mm
+++ b/test/Rewriter/rewrite-protocol-property.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 8558702
diff --git a/test/Rewriter/rewrite-protocol-qualified.mm b/test/Rewriter/rewrite-protocol-qualified.mm
index fae11a0..f828724 100644
--- a/test/Rewriter/rewrite-protocol-qualified.mm
+++ b/test/Rewriter/rewrite-protocol-qualified.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"id=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7589414
diff --git a/test/Rewriter/rewrite-protocol-type-1.m b/test/Rewriter/rewrite-protocol-type-1.m
index 2bdf8e4..5246df4 100644
--- a/test/Rewriter/rewrite-protocol-type-1.m
+++ b/test/Rewriter/rewrite-protocol-type-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol MyProto1
@end
diff --git a/test/Rewriter/rewrite-qualified-id.mm b/test/Rewriter/rewrite-qualified-id.mm
index fe3607d..f54bae9 100644
--- a/test/Rewriter/rewrite-qualified-id.mm
+++ b/test/Rewriter/rewrite-qualified-id.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7680953
diff --git a/test/Rewriter/rewrite-rewritten-initializer.mm b/test/Rewriter/rewrite-rewritten-initializer.mm
index 80ad7fc..14734f9 100644
--- a/test/Rewriter/rewrite-rewritten-initializer.mm
+++ b/test/Rewriter/rewrite-rewritten-initializer.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7669784
diff --git a/test/Rewriter/rewrite-static-block.mm b/test/Rewriter/rewrite-static-block.mm
index c99557f..4ee227e 100644
--- a/test/Rewriter/rewrite-static-block.mm
+++ b/test/Rewriter/rewrite-static-block.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp -emit-llvm -o %t-rw.ll
// RUN: FileCheck --input-file=%t-rw.ll %s
diff --git a/test/Rewriter/rewrite-super-message.mm b/test/Rewriter/rewrite-super-message.mm
index be0a963..d770b33 100644
--- a/test/Rewriter/rewrite-super-message.mm
+++ b/test/Rewriter/rewrite-super-message.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -DKEEP_ATTRIBUTES -D"id=struct objc_object *" -D"Class=struct objc_class *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o - %t-rw.cpp | FileCheck %t-rw.cpp
// radar 7738453
@@ -18,3 +18,34 @@ void *sel_registerName(const char *);
@end
// CHECK: call %struct.objc_class* @class_getSuperclass
+
+@class NSZone;
+
+@interface NSObject {
+}
+
++ (id)allocWithZone:(NSZone *)zone;
+@end
+
+
+@interface NSArray : NSObject
+@end
+
+@implementation NSArray
++ (id)allocWithZone:(NSZone *)zone {
+ return [super allocWithZone:zone];
+}
+@end
+
+@interface XNSArray
+{
+ Class isa;
+}
+@end
+
+@class XNSArray;
+
+@interface __NSArray0 : XNSArray
+@end
+
+@implementation __NSArray0 @end
diff --git a/test/Rewriter/rewrite-trivial-constructor.mm b/test/Rewriter/rewrite-trivial-constructor.mm
index 81c7d9b..f14f4b1 100644
--- a/test/Rewriter/rewrite-trivial-constructor.mm
+++ b/test/Rewriter/rewrite-trivial-constructor.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s
// radar 7537770
typedef struct {
diff --git a/test/Rewriter/rewrite-try-catch.m b/test/Rewriter/rewrite-try-catch.m
index d0c6d2a..b4d13b6 100644
--- a/test/Rewriter/rewrite-try-catch.m
+++ b/test/Rewriter/rewrite-try-catch.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface Foo @end
@interface GARF @end
diff --git a/test/Rewriter/rewrite-typeof.mm b/test/Rewriter/rewrite-typeof.mm
index b859ac3..24e3bcc 100644
--- a/test/Rewriter/rewrite-typeof.mm
+++ b/test/Rewriter/rewrite-typeof.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
extern "C" {
diff --git a/test/Rewriter/rewrite-unique-block-api.mm b/test/Rewriter/rewrite-unique-block-api.mm
index 130f514..2c0c4a9 100644
--- a/test/Rewriter/rewrite-unique-block-api.mm
+++ b/test/Rewriter/rewrite-unique-block-api.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// radar 7630551
diff --git a/test/Rewriter/rewrite-user-defined-accessors.mm b/test/Rewriter/rewrite-user-defined-accessors.mm
index 366e53b..3c38e17 100644
--- a/test/Rewriter/rewrite-user-defined-accessors.mm
+++ b/test/Rewriter/rewrite-user-defined-accessors.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar:// 8570020
diff --git a/test/Rewriter/rewrite-vararg.m b/test/Rewriter/rewrite-vararg.m
index d454031..bd58a6a 100644
--- a/test/Rewriter/rewrite-vararg.m
+++ b/test/Rewriter/rewrite-vararg.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
// rdar://9056351
diff --git a/test/Rewriter/rewrite-weak-attr.m b/test/Rewriter/rewrite-weak-attr.m
index 2e559ee..60c6fc8 100644
--- a/test/Rewriter/rewrite-weak-attr.m
+++ b/test/Rewriter/rewrite-weak-attr.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -o - %s
+// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -fobjc-fragile-abi -o - %s
int main() {
__weak __block id foo = nil;
__block id foo2 = nil;
diff --git a/test/Rewriter/static-type-protocol-1.m b/test/Rewriter/static-type-protocol-1.m
index a072c9f..bafe286 100644
--- a/test/Rewriter/static-type-protocol-1.m
+++ b/test/Rewriter/static-type-protocol-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@protocol Proto
- (void) ProtoDidget;
diff --git a/test/Rewriter/undecl-objc-h.m b/test/Rewriter/undecl-objc-h.m
index a60d810..5c3e693 100644
--- a/test/Rewriter/undecl-objc-h.m
+++ b/test/Rewriter/undecl-objc-h.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
typedef struct S {
int * pint;
diff --git a/test/Rewriter/undeclared-method-1.m b/test/Rewriter/undeclared-method-1.m
index 89d33ce..9b4ca19 100644
--- a/test/Rewriter/undeclared-method-1.m
+++ b/test/Rewriter/undeclared-method-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface Derived @end
diff --git a/test/Rewriter/undef-field-reference-1.m b/test/Rewriter/undef-field-reference-1.m
index 039c500..9c067a8 100644
--- a/test/Rewriter/undef-field-reference-1.m
+++ b/test/Rewriter/undef-field-reference-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
@interface MyDerived
{
diff --git a/test/Rewriter/unnamed-bf-modern-write.mm b/test/Rewriter/unnamed-bf-modern-write.mm
new file mode 100644
index 0000000..892382f
--- /dev/null
+++ b/test/Rewriter/unnamed-bf-modern-write.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+
+@interface Foo {
+@private
+ int first;
+ int :1;
+ int third :1;
+ int :1;
+ int fifth :1;
+}
+@end
+@implementation Foo
+@end
+
+// CHECK: struct Foo_IMPL {
+// CHECK-NEXT: int first;
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int third : 1;
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int fifth : 1;
+// CHECK-NEXT: char : 0;
+// CHECK-NEXT: };
diff --git a/test/Rewriter/va-method.m b/test/Rewriter/va-method.m
index 366552f..c232d23 100644
--- a/test/Rewriter/va-method.m
+++ b/test/Rewriter/va-method.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o -
#include <stdarg.h>
diff --git a/test/Rewriter/weak_byref_objects.m b/test/Rewriter/weak_byref_objects.m
index a0ebe88..1b9efbe 100644
--- a/test/Rewriter/weak_byref_objects.m
+++ b/test/Rewriter/weak_byref_objects.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc %s -o -
+// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc -fobjc-fragile-abi %s -o -
#define nil 0
int main() {
diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c
index fe83d97..89d3ee2 100644
--- a/test/Sema/128bitint.c
+++ b/test/Sema/128bitint.c
@@ -7,3 +7,7 @@ int a[(u128)-1 > 1LL ? 1 : -1];
// PR5435
__uint128_t b = (__uint128_t)-1;
+
+// PR11916: Support for libstdc++ 4.7
+__int128 i = (__int128)0;
+unsigned __int128 u = (unsigned __int128)-1;
diff --git a/test/Sema/Inputs/unused-expr-system-header.h b/test/Sema/Inputs/unused-expr-system-header.h
new file mode 100644
index 0000000..72b2d95
--- /dev/null
+++ b/test/Sema/Inputs/unused-expr-system-header.h
@@ -0,0 +1,23 @@
+// "System header" for testing that -Wunused-value is properly suppressed in
+// certain cases.
+
+#define POSSIBLY_BAD_MACRO(x) \
+ { int i = x; \
+ i; }
+
+#define STATEMENT_EXPR_MACRO(x) \
+ (__extension__ \
+ ({int i = x; \
+ i;}))
+
+#define COMMA_MACRO_1(x, y) \
+ {x, y;}
+
+#define COMMA_MACRO_2(x, y) \
+ if (x) { 1 == 2, y; }
+
+#define COMMA_MACRO_3(x, y) \
+ (x, y)
+
+#define COMMA_MACRO_4(x, y) \
+ ( 1 == 2, y )
diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c
new file mode 100644
index 0000000..f148e869
--- /dev/null
+++ b/test/Sema/MicrosoftCompatibility.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
+
+enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+enum ENUM1 var1 = 3;
+enum ENUM1* var2 = 0;
+
+
+enum ENUM2 {
+ ENUM2_a = (enum ENUM2) 4,
+ ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+ ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+};
+
+__declspec(noreturn) void f6( void ) {
+ return; // expected-warning {{function 'f6' declared 'noreturn' should not return}}
+}
diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c
index 7438f7f5..fb0c6bd 100644
--- a/test/Sema/MicrosoftExtensions.c
+++ b/test/Sema/MicrosoftExtensions.c
@@ -21,16 +21,6 @@ struct D {
};
-enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-enum ENUM1 var1 = 3;
-enum ENUM1* var2 = 0;
-
-
-enum ENUM2 {
- ENUM2_a = (enum ENUM2) 4,
- ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
- ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
-};
@@ -86,4 +76,27 @@ void pointer_to_integral_type_conv(char* ptr) {
short sh = (short)ptr;
ch = (char)ptr;
sh = (short)ptr;
-}
+}
+
+
+typedef struct {
+ UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
+} AA;
+
+typedef struct {
+ AA; // expected-warning {{anonymous structs are a Microsoft extension}}
+} BB;
+
+__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1;
+struct __declspec(deprecated) DS1 { int i; float f; };
+
+#define MY_TEXT "This is also deprecated"
+__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {}
+
+void test( void ) {
+ e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}}
+ struct DS1 s = { 0 }; // expected-warning {{'DS1' is deprecated}}
+ Dfunc1(); // expected-warning {{'Dfunc1' is deprecated: This is also deprecated}}
+
+ enum DE1 no; // no warning because E1 is not deprecated
+}
diff --git a/test/Sema/PR2963-enum-constant.c b/test/Sema/PR2963-enum-constant.c
index 1900eef..43daabf 100644
--- a/test/Sema/PR2963-enum-constant.c
+++ b/test/Sema/PR2963-enum-constant.c
@@ -13,5 +13,5 @@ enum
enum
{
- SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not integer constant expression}}
+ SOME_VALUE= FLOAT_TO_SHORT_FIXED(0.1) // expected-warning{{expression is not an integer constant expression}}
};
diff --git a/test/Sema/__try.c b/test/Sema/__try.c
index 5490aea..1641402 100644
--- a/test/Sema/__try.c
+++ b/test/Sema/__try.c
@@ -20,7 +20,7 @@ void __abnormal_termination();
#pragma sysheader end
-DWORD FilterExpression(int);
+DWORD FilterExpression(int); // expected-note{{declared here}}
DWORD FilterExceptionInformation(struct EXCEPTION_INFO*);
const char * NotFilterExpression();
@@ -47,7 +47,8 @@ void TEST() {
} // expected-error{{expected '__except' or '__finally' block}}
void TEST() {
- __except ( FilterExpression() ) { // expected-error{{}}
+ __except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+ // expected-error{{too few arguments to function call, expected 1, have 0}}
}
}
diff --git a/test/Sema/align-x86.c b/test/Sema/align-x86.c
index 61bd1d3..c6cd754 100644
--- a/test/Sema/align-x86.c
+++ b/test/Sema/align-x86.c
@@ -9,6 +9,10 @@ long long g2;
short chk1[__alignof__(g2) == 8 ? 1 : -1];
short chk2[__alignof__(long long) == 8 ? 1 : -1];
+unsigned long long g5;
+short chk1[__alignof__(g5) == 8 ? 1 : -1];
+short chk2[__alignof__(unsigned long long) == 8 ? 1 : -1];
+
_Complex double g3;
short chk1[__alignof__(g3) == 8 ? 1 : -1];
short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
diff --git a/test/Sema/anonymous-struct-union-c11.c b/test/Sema/anonymous-struct-union-c11.c
new file mode 100644
index 0000000..229ee52
--- /dev/null
+++ b/test/Sema/anonymous-struct-union-c11.c
@@ -0,0 +1,19 @@
+// Check for warnings in non-C11 mode:
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc11-extensions %s
+
+// Expect no warnings in C11 mode:
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -std=c11 %s
+
+struct s {
+ int a;
+ struct { // expected-warning{{anonymous structs are a C11 extension}}
+ int b;
+ };
+};
+
+struct t {
+ int a;
+ union { // expected-warning{{anonymous unions are a C11 extension}}
+ int b;
+ };
+};
diff --git a/test/Sema/anonymous-struct-union.c b/test/Sema/anonymous-struct-union.c
index d88abc3..e082290 100644
--- a/test/Sema/anonymous-struct-union.c
+++ b/test/Sema/anonymous-struct-union.c
@@ -102,3 +102,9 @@ typedef struct {
int x;
} a_struct;
int tmp = (a_struct) { .x = 0 }; // expected-error {{initializing 'int' with an expression of incompatible type 'a_struct'}}
+
+// This example comes out of the C11 standard; make sure we don't accidentally reject it.
+struct s {
+ struct { int i; };
+ int a[];
+};
diff --git a/test/Sema/arm-neon-types.c b/test/Sema/arm-neon-types.c
index 4be83da..1a170db 100644
--- a/test/Sema/arm-neon-types.c
+++ b/test/Sema/arm-neon-types.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding -verify %s
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversion -ffreestanding -verify %s
#include <arm_neon.h>
@@ -25,3 +25,11 @@ int32x4_t test4(int32x4_t a, vSInt32 b) {
b += a;
return b += a;
}
+
+// Warn for incompatible pointer types used with vld/vst intrinsics.
+int16x8_t test5(int *p) {
+ return vld1q_s16(p); // expected-warning {{incompatible pointer types}}
+}
+void test6(float *p, int32x2_t v) {
+ return vst1_s32(p, v); // expected-warning {{incompatible pointer types}}
+}
diff --git a/test/Sema/array-bounds-ptr-arith.c b/test/Sema/array-bounds-ptr-arith.c
index c0e0d0e..022335b 100644
--- a/test/Sema/array-bounds-ptr-arith.c
+++ b/test/Sema/array-bounds-ptr-arith.c
@@ -12,3 +12,10 @@ void* broken (struct ext2_super_block *es,int a)
{
return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}}
}
+
+// Test case reduced from PR11594
+struct S { int n; };
+void pr11594(struct S *s) {
+ int a[10];
+ int *p = a - s->n;
+}
diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c
index bc958c3..26c0b24 100644
--- a/test/Sema/array-init.c
+++ b/test/Sema/array-init.c
@@ -48,7 +48,9 @@ void func() {
extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
- static long x2[3] = { 1.0, "abc" , 5.8 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+ static long x2[3] = { 1.0,
+ "abc", // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}}
+ 5.8 }; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
}
void test() {
@@ -167,7 +169,7 @@ void charArrays() {
void variableArrayInit() {
int a = 4;
- char strlit[a] = "foo"; //expected-error{{array initializer must be an initializer list or string literal}}
+ char strlit[a] = "foo"; //expected-error{{variable-sized object may not be initialized}}
int b[a] = { 1, 2, 4 }; //expected-error{{variable-sized object may not be initialized}}
}
@@ -218,7 +220,7 @@ void varArray() {
}
// PR2151
-void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \
+void emptyInit() {struct {} x[] = {6};} //expected-warning{{empty struct is a GNU extension}} \
// expected-error{{initializer for aggregate with no elements}}
void noNamedInit() {
@@ -242,10 +244,10 @@ struct soft_segment_descriptor gdt_segs[] = {
};
static void sppp_ipv6cp_up();
-const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}} \
+const struct {} ipcp = { sppp_ipv6cp_up }; //expected-warning{{empty struct is a GNU extension}} \
// expected-warning{{excess elements in struct initializer}}
-struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a GNU extension in C}}
+struct _Matrix { union { float m[4][4]; }; }; //expected-warning{{anonymous unions are a C11 extension}}
typedef struct _Matrix Matrix;
void test_matrix() {
const Matrix mat1 = {
@@ -278,3 +280,10 @@ int a6[5] = (int[]){1, 2, 3}; // expected-error{{cannot initialize array of type
int nonconst_value();
int a7[5] = (int[5]){ 1, 2, 3, 4, nonconst_value() }; // expected-error{{initializer element is not a compile-time constant}}
+
+// <rdar://problem/10636946>
+__attribute__((weak)) const unsigned int test10_bound = 10;
+char test10_global[test10_bound]; // expected-error {{variable length array declaration not allowed at file scope}}
+void test10() {
+ char test10_local[test10_bound] = "help"; // expected-error {{variable-sized object may not be initialized}}
+}
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 359431c..44d83e9 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -21,7 +21,7 @@ void clobbers() {
asm ("nop" : : : "0", "%0", "#0");
asm ("nop" : : : "foo"); // expected-error {{unknown register name 'foo' in asm}}
asm ("nop" : : : "52");
- asm ("nop" : : : "54"); // expected-error {{unknown register name '54' in asm}}
+ asm ("nop" : : : "104"); // expected-error {{unknown register name '104' in asm}}
asm ("nop" : : : "-1"); // expected-error {{unknown register name '-1' in asm}}
asm ("nop" : : : "+1"); // expected-error {{unknown register name '+1' in asm}}
}
diff --git a/test/Sema/atomic-ops.c b/test/Sema/atomic-ops.c
index 51b46bd..f769271 100644
--- a/test/Sema/atomic-ops.c
+++ b/test/Sema/atomic-ops.c
@@ -1,37 +1,165 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple=i686-linux-gnu
-// Basic parsing/Sema tests for __atomic_*
-
-// FIXME: Need to implement __atomic_is_lock_free
+// Basic parsing/Sema tests for __c11_atomic_*
typedef enum memory_order {
memory_order_relaxed, memory_order_consume, memory_order_acquire,
memory_order_release, memory_order_acq_rel, memory_order_seq_cst
} memory_order;
-void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d) {
- __atomic_load(0); // expected-error {{too few arguments to function}}
- __atomic_load(0,0,0); // expected-error {{too many arguments to function}}
- __atomic_store(0,0,0); // expected-error {{first argument to atomic operation}}
- __atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation}}
+struct S { char c[3]; };
+
+_Static_assert(__GCC_ATOMIC_BOOL_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
+_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
+_Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
+
+_Static_assert(__c11_atomic_is_lock_free(1), "");
+_Static_assert(__c11_atomic_is_lock_free(2), "");
+_Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(4), "");
+_Static_assert(__c11_atomic_is_lock_free(8), "");
+_Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
+
+_Static_assert(__atomic_is_lock_free(1, 0), "");
+_Static_assert(__atomic_is_lock_free(2, 0), "");
+_Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, 0), "");
+_Static_assert(__atomic_is_lock_free(8, 0), "");
+_Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
+
+char i8;
+short i16;
+int i32;
+int __attribute__((vector_size(8))) i64;
+struct Incomplete *incomplete;
+
+_Static_assert(__atomic_is_lock_free(1, &i8), "");
+_Static_assert(__atomic_is_lock_free(1, &i64), "");
+_Static_assert(__atomic_is_lock_free(2, &i8), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(2, &i16), "");
+_Static_assert(__atomic_is_lock_free(2, &i64), "");
+_Static_assert(__atomic_is_lock_free(4, &i16), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(4, &i32), "");
+_Static_assert(__atomic_is_lock_free(4, &i64), "");
+_Static_assert(__atomic_is_lock_free(8, &i32), ""); // expected-error {{not an integral constant expression}}
+_Static_assert(__atomic_is_lock_free(8, &i64), "");
+
+_Static_assert(__atomic_always_lock_free(1, 0), "");
+_Static_assert(__atomic_always_lock_free(2, 0), "");
+_Static_assert(!__atomic_always_lock_free(3, 0), "");
+_Static_assert(__atomic_always_lock_free(4, 0), "");
+_Static_assert(__atomic_always_lock_free(8, 0), "");
+_Static_assert(!__atomic_always_lock_free(16, 0), "");
+_Static_assert(!__atomic_always_lock_free(17, 0), "");
+
+_Static_assert(__atomic_always_lock_free(1, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(2, incomplete), "");
+_Static_assert(!__atomic_always_lock_free(4, incomplete), "");
+
+_Static_assert(__atomic_always_lock_free(1, &i8), "");
+_Static_assert(__atomic_always_lock_free(1, &i64), "");
+_Static_assert(!__atomic_always_lock_free(2, &i8), "");
+_Static_assert(__atomic_always_lock_free(2, &i16), "");
+_Static_assert(__atomic_always_lock_free(2, &i64), "");
+_Static_assert(!__atomic_always_lock_free(4, &i16), "");
+_Static_assert(__atomic_always_lock_free(4, &i32), "");
+_Static_assert(__atomic_always_lock_free(4, &i64), "");
+_Static_assert(!__atomic_always_lock_free(8, &i32), "");
+_Static_assert(__atomic_always_lock_free(8, &i64), "");
+
+void f(_Atomic(int) *i, _Atomic(int*) *p, _Atomic(float) *d,
+ int *I, int **P, float *D, struct S *s1, struct S *s2) {
+ __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
+ __c11_atomic_load(0); // expected-error {{too few arguments to function}}
+ __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
+ __c11_atomic_store(0,0,0); // expected-error {{first argument to atomic builtin must be a pointer}}
+ __c11_atomic_store((int*)0,0,0); // expected-error {{first argument to atomic operation must be a pointer to _Atomic}}
+
+ __c11_atomic_load(i, memory_order_seq_cst);
+ __c11_atomic_load(p, memory_order_seq_cst);
+ __c11_atomic_load(d, memory_order_seq_cst);
+
+ int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
+ int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
+ float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
+
+ __atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
+ __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
+ __atomic_load(I, *P, memory_order_relaxed);
+ __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
+ (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+ __atomic_load(s1, s2, memory_order_acquire);
+
+ __c11_atomic_store(i, 1, memory_order_seq_cst);
+ __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
+ (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+ __atomic_store_n(I, 4, memory_order_release);
+ __atomic_store_n(I, 4.0, memory_order_release);
+ __atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
+ __atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
+
+ __atomic_store(I, *P, memory_order_release);
+ __atomic_store(s1, s2, memory_order_release);
+ __atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
+
+ int exchange_1 = __c11_atomic_exchange(i, 1, memory_order_seq_cst);
+ int exchange_2 = __c11_atomic_exchange(I, 1, memory_order_seq_cst); // expected-error {{must be a pointer to _Atomic}}
+ int exchange_3 = __atomic_exchange_n(i, 1, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+ int exchange_4 = __atomic_exchange_n(I, 1, memory_order_seq_cst);
+
+ __atomic_exchange(s1, s2, s2, memory_order_seq_cst);
+ __atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
+ (int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+
+ __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
+
+ __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
+ __atomic_fetch_sub(I, 3, memory_order_seq_cst);
+ __atomic_fetch_sub(P, 3, memory_order_seq_cst);
+ __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+ __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
+
+ __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
+ __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+ __c11_atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
- __atomic_load(i, memory_order_seq_cst);
- __atomic_load(p, memory_order_seq_cst);
- __atomic_load(d, memory_order_seq_cst);
+ __atomic_fetch_and(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer}}
+ __atomic_fetch_or(I, 3, memory_order_seq_cst);
+ __atomic_fetch_xor(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+ __atomic_fetch_or(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+ __atomic_fetch_and(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
- __atomic_store(i, 1, memory_order_seq_cst);
- __atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
- (int)__atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
+ _Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
- __atomic_fetch_add(i, 1, memory_order_seq_cst);
- __atomic_fetch_add(p, 1, memory_order_seq_cst);
- __atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
+ _Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
+ _Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+ _Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
- __atomic_fetch_and(i, 1, memory_order_seq_cst);
- __atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
- __atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
+ _Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
+ _Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
+ _Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
- __atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
- __atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
- __atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
+ const volatile int flag_k = 0;
+ volatile int flag = 0;
+ (void)(int)__atomic_test_and_set(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+ (void)(int)__atomic_test_and_set(&flag, memory_order_seq_cst);
+ __atomic_clear(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
+ __atomic_clear(&flag, memory_order_seq_cst);
+ (int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
}
diff --git a/test/Sema/atomic-type.c b/test/Sema/atomic-type.c
index 8e72540..a4ac552 100644
--- a/test/Sema/atomic-type.c
+++ b/test/Sema/atomic-type.c
@@ -16,7 +16,7 @@ extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest;
extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest;
_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}}
-_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}}
+_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} expected-note {{forward declaration}}
_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}}
_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}}
_Atomic(_Atomic(int)) error5; // expected-error {{_Atomic cannot be applied to atomic type}}
diff --git a/test/Sema/attr-availability-ios.c b/test/Sema/attr-availability-ios.c
index 435e312..ea05e17 100644
--- a/test/Sema/attr-availability-ios.c
+++ b/test/Sema/attr-availability-ios.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s
void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
diff --git a/test/Sema/attr-availability-macosx.c b/test/Sema/attr-availability-macosx.c
index 2b7c1e0..1de26e9 100644
--- a/test/Sema/attr-availability-macosx.c
+++ b/test/Sema/attr-availability-macosx.c
@@ -15,3 +15,17 @@ void test() {
f4(0); // expected-error{{f4' is unavailable: obsoleted in Mac OS X 10.5}}
f5(0); // expected-error{{'f5' is unavailable: not available on Mac OS X}}
}
+
+// rdar://10535640
+
+enum {
+ foo __attribute__((availability(macosx,introduced=8.0,deprecated=9.0)))
+};
+
+enum {
+ bar __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) = foo
+};
+
+enum __attribute__((availability(macosx,introduced=8.0,deprecated=9.0))) {
+ bar1 = foo
+};
diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c
index f6ed131..0e6ea96 100644
--- a/test/Sema/attr-availability.c
+++ b/test/Sema/attr-availability.c
@@ -1,7 +1,26 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in Mac OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
+
+// rdar://10095131
+extern void
+ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName")));
+
+extern void
+ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}}
+
+void test_10095131() {
+ ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in Mac OS X 9.0 - use CTFontCopyFullName}}
+ ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in Mac OS X 9.0 - use ATSFontGetFullPostScriptName}}
+}
+
+// rdar://10711037
+__attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}}
+enum {
+ NSDataWritingFileProtectionWriteOnly = 0x30000000,
+ NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
+};
diff --git a/test/Sema/attr-declspec-ignored.c b/test/Sema/attr-declspec-ignored.c
new file mode 100644
index 0000000..6fd35c0
--- /dev/null
+++ b/test/Sema/attr-declspec-ignored.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+__attribute__((visibility("hidden"))) __attribute__((aligned)) struct A; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
+__attribute__((visibility("hidden"))) __attribute__((aligned)) union B; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}}
+__attribute__((visibility("hidden"))) __attribute__((aligned)) enum C {C}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
+// expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
+
+__attribute__((visibility("hidden"))) __attribute__((aligned)) struct D {} d;
+__attribute__((visibility("hidden"))) __attribute__((aligned)) union E {} e;
+__attribute__((visibility("hidden"))) __attribute__((aligned)) enum F {F} f;
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c
index 2889f8f..4760dab 100644
--- a/test/Sema/attr-deprecated.c
+++ b/test/Sema/attr-deprecated.c
@@ -44,8 +44,8 @@ void test1(struct foo *F) {
typedef struct foo foo_dep __attribute__((deprecated));
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
-struct bar_dep __attribute__((deprecated,
- invalid_attribute)); // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
+struct __attribute__((deprecated,
+ invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
@@ -109,7 +109,7 @@ enum __attribute__((deprecated)) Test20 {
void test20() {
enum Test20 f; // expected-warning {{'Test20' is deprecated}}
f = test20_a; // expected-warning {{'test20_a' is deprecated}}
- f = test20_b; // expected-warning {{'Test20' is deprecated}}
+ f = test20_b; // expected-warning {{'test20_b' is deprecated}}
}
char test21[__has_feature(attribute_deprecated_with_message) ? 1 : -1];
diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c
index 9b0c3de..b2956d8 100644
--- a/test/Sema/attr-unavailable-message.c
+++ b/test/Sema/attr-unavailable-message.c
@@ -34,16 +34,16 @@ enum foo {
c = 3
}__attribute__((deprecated()));
-enum fee { // expected-note 2 {{declaration has been explicitly marked unavailable here}}
- r = 1,
+enum fee { // expected-note {{declaration has been explicitly marked unavailable here}}
+ r = 1, // expected-note {{declaration has been explicitly marked unavailable here}}
s = 2,
t = 3
}__attribute__((unavailable()));
-enum fee f() { // expected-error {{error: 'fee' is unavailable}}
- int i = a; // expected-warning {{'foo' is deprecated }}
+enum fee f() { // expected-error {{'fee' is unavailable}}
+ int i = a; // expected-warning {{'a' is deprecated}}
i = b; // expected-warning {{'b' is deprecated}}
- return r; // expected-error {{'fee' is unavailable}}
+ return r; // expected-error {{'r' is unavailable}}
}
diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c
new file mode 100644
index 0000000..5cf2695
--- /dev/null
+++ b/test/Sema/attr-visibility.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+
+void test0() __attribute__((visibility("default")));
+void test1() __attribute__((visibility("hidden")));
+void test2() __attribute__((visibility("internal")));
+
+// rdar://problem/10753392
+void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
+
diff --git a/test/Sema/block-explicit-noreturn-type.c b/test/Sema/block-explicit-noreturn-type.c
new file mode 100644
index 0000000..12f4f4f
--- /dev/null
+++ b/test/Sema/block-explicit-noreturn-type.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+// rdar://10466373
+
+typedef short SHORT;
+
+void f0() {
+ (void) ^{
+ if (1)
+ return (float)1.0;
+ else if (2)
+ return (double)2.0; // expected-error {{return type 'double' must match previous return type 'float' when block literal has}}
+ else
+ return (SHORT)3; // expected-error {{return type 'SHORT' (aka 'short') must match previous return type 'float' when}}
+ };
+}
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index ec74a63..2260458 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -190,7 +190,7 @@ void test18() {
// rdar://7072507
int test19() {
- goto L0; // expected-error {{illegal goto into protected scope}}
+ goto L0; // expected-error {{goto into protected scope}}
__block int x; // expected-note {{jump bypasses setup of __block variable}}
L0:
diff --git a/test/Sema/block-printf-attribute-1.c b/test/Sema/block-printf-attribute-1.c
index c19b378..dd678a5 100644
--- a/test/Sema/block-printf-attribute-1.c
+++ b/test/Sema/block-printf-attribute-1.c
@@ -1,11 +1,21 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+#include <stdarg.h>
+
int main() {
void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};
- z(1, "%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
z(1, "%s", "HELLO"); // no-warning
}
+
+void multi_attr(va_list ap, int *x, long *y) {
+ // Handle block with multiple format attributes.
+ void (^vprintf_scanf) (const char *, va_list, const char *, ...) __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) =
+ ^ __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) (const char *str, va_list args, const char *fmt, ...) {};
+
+ vprintf_scanf("%", ap, "%d"); // expected-warning {{incomplete format specifier}}, expected-warning {{more '%' conversions than data arguments}}
+}
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index c6e1e9d..6967955 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+// RUN: %clang_cc1 -pedantic -fsyntax-only %s -verify -fblocks
typedef void (^CL)(void);
@@ -9,14 +9,14 @@ CL foo() {
CL X = ^{
if (2)
return;
- return 1; // expected-error {{void block should not return a value}}
+ return 1; // expected-error {{return type 'int' must match previous return type 'void' when block literal has unspecified explicit return type}}
};
int (^Y) (void) = ^{
if (3)
return 1;
else
- return; // expected-error {{non-void block should return a value}}
+ return; // expected-error {{return type 'void' must match previous return type 'int' when block literal has unspecified explicit return type}}
};
char *(^Z)(void) = ^{
@@ -31,14 +31,14 @@ CL foo() {
return (float)1.0;
else
if (2)
- return (double)2.0;
- return 1;
+ return (double)2.0; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
+ return 1; // expected-error {{return type 'int' must match previous return type 'float' when block literal has unspecified explicit return type}}
};
char *(^B)(void) = ^{
if (3)
return "";
else
- return 2; // expected-warning {{incompatible integer to pointer conversion returning 'int' from a function with result type 'char *'}}
+ return 2; // expected-error {{return type 'int' must match previous return type 'char *' when block literal has unspecified explicit return type}}
};
return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)' from a function with result type 'CL' (aka 'void (^)(void)')}}
@@ -81,7 +81,7 @@ void foo4() {
int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
- int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring C library function 'printf' with type 'int (const char *, ...)'}} \
+ int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
@@ -130,4 +130,7 @@ void foo7()
int (^NN) (void) = ^{ return cint; };
}
-
+// rdar://11069896
+void (^blk)(void) = ^{
+ return (void)0; // expected-warning {{void block literal should not return void expression}}
+};
diff --git a/test/Sema/block-sentinel-attribute.c b/test/Sema/block-sentinel-attribute.c
index b5ce0da..daf0a95 100644
--- a/test/Sema/block-sentinel-attribute.c
+++ b/test/Sema/block-sentinel-attribute.c
@@ -3,7 +3,8 @@
void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
int main() {
- void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{sentinel' attribute only supported for variadic blocks}}
+ void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
+ bbad = ^void (int arg, const char * format) __attribute__ ((__sentinel__)) {} ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {};
void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index 64efefc..b8b0367 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -triple=i686-apple-darwin9
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wno-string-plus-int -triple=i686-apple-darwin9
// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
int test1(float a, int b) {
@@ -28,7 +28,7 @@ void test7() {
const void *X;
X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
X = CFSTR("\0"); // no-warning
- X = CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
+ X = CFSTR(242); // expected-error {{CFString literal is not a string constant}} expected-warning {{incompatible integer to pointer conversion}}
X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
}
@@ -78,7 +78,8 @@ void test12(void) {
}
void test_unknown_builtin(int a, int b) {
- __builtin_foo(a, b); // expected-error{{use of unknown builtin}}
+ __builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
+ // expected-note{{did you mean '__builtin_isless'?}}
}
int test13() {
@@ -102,3 +103,62 @@ int test16() {
__builtin_constant_p(1, 2); // expected-error {{too many arguments}}
}
+const int test17_n = 0;
+const char test17_c[] = {1, 2, 3, 0};
+const char test17_d[] = {1, 2, 3, 4};
+typedef int __attribute__((vector_size(16))) IntVector;
+struct Aggregate { int n; char c; };
+enum Enum { EnumValue1, EnumValue2 };
+
+typedef __typeof(sizeof(int)) size_t;
+size_t strlen(const char *);
+
+void test17() {
+#define ASSERT(...) { int arr[(__VA_ARGS__) ? 1 : -1]; }
+#define T(...) ASSERT(__builtin_constant_p(__VA_ARGS__))
+#define F(...) ASSERT(!__builtin_constant_p(__VA_ARGS__))
+
+ // __builtin_constant_p returns 1 if the argument folds to:
+ // - an arithmetic constant with value which is known at compile time
+ T(test17_n);
+ T(&test17_c[3] - test17_c);
+ T(3i + 5); // expected-warning {{imaginary constant}}
+ T(4.2 * 7.6);
+ T(EnumValue1);
+ T((enum Enum)(int)EnumValue2);
+
+ // - the address of the first character of a string literal, losslessly cast
+ // to any type
+ T("string literal");
+ T((double*)"string literal");
+ T("string literal" + 0);
+ T((long)"string literal");
+
+ // ... and otherwise returns 0.
+ F("string literal" + 1);
+ F(&test17_n);
+ F(test17_c);
+ F(&test17_c);
+ F(&test17_d);
+ F((struct Aggregate){0, 1});
+ F((IntVector){0, 1, 2, 3});
+
+ // Ensure that a technique used in glibc is handled correctly.
+#define OPT(...) (__builtin_constant_p(__VA_ARGS__) && strlen(__VA_ARGS__) < 4)
+ // FIXME: These are incorrectly treated as ICEs because strlen is treated as
+ // a builtin.
+ ASSERT(OPT("abc"));
+ ASSERT(!OPT("abcd"));
+ // In these cases, the strlen is non-constant, but the __builtin_constant_p
+ // is 0: the array size is not an ICE but is foldable.
+ ASSERT(!OPT(test17_c)); // expected-warning {{folded}}
+ ASSERT(!OPT(&test17_c[0])); // expected-warning {{folded}}
+ ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
+ ASSERT(!OPT(test17_d)); // expected-warning {{folded}}
+ ASSERT(!OPT(&test17_d[0])); // expected-warning {{folded}}
+ ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
+
+#undef OPT
+#undef T
+#undef F
+}
diff --git a/test/Sema/c11-typedef-redef.c b/test/Sema/c11-typedef-redef.c
new file mode 100644
index 0000000..b899f15
--- /dev/null
+++ b/test/Sema/c11-typedef-redef.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c11 %s -verify
+
+typedef int type;
+typedef type type;
+typedef int type;
+
+void f(int N) {
+ typedef int type2;
+ typedef type type2;
+ typedef int type2;
+
+ typedef int vla[N]; // expected-note{{previous definition is here}}
+ typedef int vla[N]; // expected-error{{redefinition of typedef for variably-modified type 'int [N]'}}
+
+ typedef int vla2[N];
+ typedef vla2 vla3; // expected-note{{previous definition is here}}
+ typedef vla2 vla3; // expected-error{{redefinition of typedef for variably-modified type 'vla2' (aka 'int [N]')}}
+}
diff --git a/test/Sema/c89.c b/test/Sema/c89.c
index 670dd15..110d7e1 100644
--- a/test/Sema/c89.c
+++ b/test/Sema/c89.c
@@ -1,4 +1,4 @@
-/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify
+/* RUN: %clang_cc1 %s -std=c89 -pedantic -fsyntax-only -verify -Wimplicit-function-declaration
*/
void test1() {
{
@@ -61,11 +61,11 @@ void foo(T); /* typedef for void is allowed */
void foo(void) {}
/* PR2759 */
-void test10 (int x[*]); /* expected-warning {{variable length arrays are a C99 feature, accepted as an extension}} */
-void test11 (int x[static 4]); /* expected-warning {{use of C99-specific array features}} */
+void test10 (int x[*]); /* expected-warning {{variable length arrays are a C99 feature}} */
+void test11 (int x[static 4]); /* expected-warning {{static array size is a C99 feature}} */
-void test12 (int x[const 4]) { /* expected-warning {{use of C99-specific array features}} */
- int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature, accepted as an extension}} */
+void test12 (int x[const 4]) { /* expected-warning {{qualifier in array size is a C99 feature}} */
+ int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature}} */
}
/* PR4074 */
@@ -82,3 +82,31 @@ void test13b() {
int test14() { return (&*test14)(); }
int test15[5] = { [2] = 1 }; /* expected-warning {{designated initializers are a C99 feature}} */
+
+extern int printf(__const char *__restrict __format, ...);
+
+/* Warn, but don't suggest typo correction. */
+void test16() {
+ printg("Hello, world!\n"); /* expected-warning {{implicit declaration of function 'printg'}} */
+}
+
+struct x { int x,y[]; }; /* expected-warning {{Flexible array members are a C99-specific feature}} */
+
+/* Duplicated type-qualifiers aren't allowed by C90 */
+const const int c_i; /* expected-warning {{duplicate 'const' declaration specifier}} */
+typedef volatile int vol_int;
+volatile vol_int volvol_i; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+typedef volatile vol_int volvol_int; /* expected-warning {{duplicate 'volatile' declaration specifier}} */
+const int * const c;
+
+typedef const int CI;
+
+const CI mine1[5][5]; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI array_of_CI[5];
+const array_of_CI mine2; /* expected-warning {{duplicate 'const' declaration specifier}} */
+
+typedef CI *array_of_pointer_to_CI[5];
+const array_of_pointer_to_CI mine3;
+
+void main() {} /* expected-error {{'main' must return 'int'}} */
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index cd973d4..03aebb3 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -327,3 +327,9 @@ void test10(void) {
b = (si == (ui = sl)); // expected-warning {{comparison of integers of different signs: 'int' and 'unsigned int'}}
b = (si == (ui = sl&15));
}
+
+// PR11572
+struct test11S { unsigned x : 30; };
+int test11(unsigned y, struct test11S *p) {
+ return y > (p->x >> 24); // no-warning
+}
diff --git a/test/Sema/complex-imag.c b/test/Sema/complex-imag.c
new file mode 100644
index 0000000..1c6fb15
--- /dev/null
+++ b/test/Sema/complex-imag.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify %s
+
+void f1() {
+ int a = 1;
+ int b = __imag a;
+ int *c = &__real a;
+ int *d = &__imag a; // expected-error {{must be an lvalue}}
+}
+
+void f2() {
+ _Complex int a = 1;
+ int b = __imag a;
+ int *c = &__real a;
+ int *d = &__imag a;
+}
+
+void f3() {
+ double a = 1;
+ double b = __imag a;
+ double *c = &__real a;
+ double *d = &__imag a; // expected-error {{must be an lvalue}}
+}
+
+void f4() {
+ _Complex double a = 1;
+ double b = __imag a;
+ double *c = &__real a;
+ double *d = &__imag a;
+}
diff --git a/test/Sema/complex-init-list.c b/test/Sema/complex-init-list.c
index 5b5d7ce..bfc6899 100644
--- a/test/Sema/complex-init-list.c
+++ b/test/Sema/complex-init-list.c
@@ -43,3 +43,6 @@ _Complex float sizetest1[] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning
_Complex float sizecheck1[(sizeof(sizetest1) == sizeof(*sizetest1)*2) ? 1 : -1];
_Complex float sizetest2[] = { 1.0f, 1.0f, {1.0f, 1.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
_Complex float sizecheck2[(sizeof(sizetest2) == sizeof(*sizetest2)*3) ? 1 : -1];
+
+// Constant-folding with init list.
+_Complex float x = 2 + (_Complex float) { 1, 2 }; // expected-warning {{specifying real and imaginary components is an extension}}
diff --git a/test/Sema/compound-literal.c b/test/Sema/compound-literal.c
index 4130762..beec6ca 100644
--- a/test/Sema/compound-literal.c
+++ b/test/Sema/compound-literal.c
@@ -12,7 +12,7 @@ static int x = (int){1};
static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}}
static long *p3 = (long []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
-typedef struct { } cache_t; // -expected-warning{{empty struct (accepted as an extension) has size 0 in C, size 1 in C++}}
+typedef struct { } cache_t; // -expected-warning{{empty struct is a GNU extension}}
static cache_t clo_I1_cache = ((cache_t) { } ); // -expected-warning{{use of GNU empty initializer extension}}
typedef struct Test {int a;int b;} Test;
diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c
index 436ecdb..184ac4a 100644
--- a/test/Sema/conditional-expr.c
+++ b/test/Sema/conditional-expr.c
@@ -60,6 +60,23 @@ void foo() {
test0 = test0 ? EVal : test1; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
test0 = test0 ? test1 : EVal; // expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
+ const int *const_int;
+ int *nonconst_int;
+ *(test0 ? const_int : nonconst_int) = 42; // expected-error {{read-only variable is not assignable}}
+ *(test0 ? nonconst_int : const_int) = 42; // expected-error {{read-only variable is not assignable}}
+
+ // The composite type here should be "int (*)[12]", fine for the sizeof
+ int (*incomplete)[];
+ int (*complete)[12];
+ sizeof(*(test0 ? incomplete : complete)); // expected-warning {{expression result unused}}
+ sizeof(*(test0 ? complete : incomplete)); // expected-warning {{expression result unused}}
+
+ int __attribute__((address_space(2))) *adr2;
+ int __attribute__((address_space(3))) *adr3;
+ test0 ? adr2 : adr3; // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
+
+ // Make sure address-space mask ends up in the result type
+ (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
}
int Postgresql() {
diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c
index bdb40ae..f1c0485 100644
--- a/test/Sema/const-eval.c
+++ b/test/Sema/const-eval.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s
#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
int x;
@@ -14,9 +14,9 @@ EVAL_EXPR(8, (_Bool)"asdf")
EVAL_EXPR(9, !!&x)
EVAL_EXPR(10, ((void)1, 12))
void g0(void);
-EVAL_EXPR(11, (g0(), 12)) // FIXME: This should give an error
+EVAL_EXPR(11, (g0(), 12)) // expected-error {{must have a constant size}}
EVAL_EXPR(12, 1.0&&2.0)
-EVAL_EXPR(13, x || 3.0)
+EVAL_EXPR(13, x || 3.0) // expected-error {{must have a constant size}}
unsigned int l_19 = 1;
EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{fields must have a constant size}}
@@ -24,7 +24,7 @@ EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{fields must have a constant
void f()
{
int a;
- EVAL_EXPR(15, (_Bool)&a); // expected-error {{fields must have a constant size}}
+ EVAL_EXPR(15, (_Bool)&a);
}
// FIXME: Turn into EVAL_EXPR test once we have more folding.
@@ -81,8 +81,43 @@ EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1)
EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1)
EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1)
+// From gcc testsuite
+EVAL_EXPR(41, (int)(1+(_Complex unsigned)2))
+
// rdar://8875946
void rdar8875946() {
double _Complex P;
float _Complex P2 = 3.3f + P;
}
+
+double d = (d = 0.0); // expected-error {{not a compile-time constant}}
+double d2 = ++d; // expected-error {{not a compile-time constant}}
+
+int n = 2;
+int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}}
+
+union u { int a; char b[4]; };
+char c = ((union u)(123456)).b[0]; // expected-error {{not a compile-time constant}}
+
+extern const int weak_int __attribute__((weak));
+const int weak_int = 42;
+int weak_int_test = weak_int; // expected-error {{not a compile-time constant}}
+
+int literalVsNull1 = "foo" == 0;
+int literalVsNull2 = 0 == "foo";
+
+// PR11385.
+int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}}
+
+// PR11391.
+struct PR11391 { _Complex float f; } pr11391;
+EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1))
+
+// PR12043
+float varfloat;
+const float constfloat = 0;
+EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}
+
+// <rdar://problem/11205586>
+// (Make sure we continue to reject this.)
+EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}}
diff --git a/test/Sema/constant-conversion.c b/test/Sema/constant-conversion.c
index 7c6b9b8..1376333 100644
--- a/test/Sema/constant-conversion.c
+++ b/test/Sema/constant-conversion.c
@@ -31,8 +31,8 @@ void test3() {
int bar : 2;
};
- struct A a = { 0, 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
- struct A b[] = { 0, 10, 0, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
+ struct A a = { 0, 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
+ struct A b[] = { 0, 10, 0, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
struct A e = { .foo = 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
@@ -55,3 +55,28 @@ void test5() {
// don't warn about it just because it's a bitfield.
a.b = 100;
}
+
+void test6() {
+ // Test that unreachable code doesn't trigger the truncation warning.
+ unsigned char x = 0 ? 65535 : 1; // no-warning
+ unsigned char y = 1 ? 65535 : 1; // expected-warning {{changes value}}
+}
+
+void test7() {
+ struct {
+ unsigned int twoBits1:2;
+ unsigned int twoBits2:2;
+ unsigned int reserved:28;
+ } f;
+
+ f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -2 to 2}}
+ f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}}
+ f.twoBits1 &= ~1; // no-warning
+ f.twoBits2 &= ~2; // no-warning
+}
+
+void test8() {
+ enum E { A, B, C };
+ struct { enum E x : 1; } f;
+ f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}}
+}
diff --git a/test/Sema/conversion-64-32.c b/test/Sema/conversion-64-32.c
index 112e995..3de20cb 100644
--- a/test/Sema/conversion-64-32.c
+++ b/test/Sema/conversion-64-32.c
@@ -13,3 +13,7 @@ int4 test1(long2 a) {
int4 v127 = a; // no warning.
return v127;
}
+
+int test2(long v) {
+ return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
+}
diff --git a/test/Sema/conversion.c b/test/Sema/conversion.c
index 842641b..a591ac0 100644
--- a/test/Sema/conversion.c
+++ b/test/Sema/conversion.c
@@ -61,53 +61,125 @@ void test0(char c, short s, int i, long l, long long ll) {
char test1(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_a(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_b(long long ll) {
return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_c(long long ll) {
return (short) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+char test1_d(long long ll) {
return (char) ll;
+}
+char test1_e(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'char' changes value}}
+}
+char test1_f(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
+}
+char test1_g(long long ll) {
return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'char' changes value}}
+}
+char test1_h(long long ll) {
return (short) BIG; // expected-warning {{implicit conversion from 'short' to 'char' changes value}}
+}
+char test1_i(long long ll) {
return (char) BIG;
}
short test2(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_a(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_b(long long ll) {
return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+short test2_c(long long ll) {
return (short) ll;
+}
+short test2_d(long long ll) {
return (char) ll;
+}
+short test2_e(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'short' changes value}}
+}
+short test2_f(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'short' changes value}}
+}
+short test2_g(long long ll) {
return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'short' changes value}}
+}
+short test2_h(long long ll) {
return (short) BIG;
+}
+short test2_i(long long ll) {
return (char) BIG;
}
int test3(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+int test3_b(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
+}
+int test3_c(long long ll) {
return (int) ll;
+}
+int test3_d(long long ll) {
return (short) ll;
+}
+int test3_e(long long ll) {
return (char) ll;
+}
+int test3_f(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'int' changes value}}
+}
+int test3_g(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'int' changes value}}
+}
+int test3_h(long long ll) {
return (int) BIG;
+}
+int test3_i(long long ll) {
return (short) BIG;
+}
+int test3_j(long long ll) {
return (char) BIG;
}
long test4(long long ll) {
return (long long) ll;
+}
+long test4_a(long long ll) {
return (long) ll;
+}
+long test4_b(long long ll) {
return (int) ll;
+}
+long test4_c(long long ll) {
return (short) ll;
+}
+long test4_d(long long ll) {
return (char) ll;
+}
+long test4_e(long long ll) {
return (long long) BIG;
+}
+long test4_f(long long ll) {
return (long) BIG;
+}
+long test4_g(long long ll) {
return (int) BIG;
+}
+long test4_h(long long ll) {
return (short) BIG;
+}
+long test4_i(long long ll) {
return (char) BIG;
}
diff --git a/test/Sema/decl-in-prototype.c b/test/Sema/decl-in-prototype.c
new file mode 100644
index 0000000..05b8e0a
--- /dev/null
+++ b/test/Sema/decl-in-prototype.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1_only -verify %s
+
+const int AA = 5;
+
+int f1(enum {AA,BB} E) {
+ return BB;
+}
+
+int f2(enum {AA=7,BB} E) {
+ return AA;
+}
+
+struct a {
+};
+
+int f3(struct a { } *); // expected-warning {{will not be visible outside of this function}}
+
+struct A { struct b { int j; } t; }; // expected-note {{previous definition is here}}
+
+int f4(struct A { struct b { int j; } t; } *); // expected-warning {{declaration of 'struct A' will not be visible outside of this function}} expected-warning {{redefinition of 'b' will not be visible outside of this function}}
+
+struct aA {
+ struct ab { // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
+ int j;
+ } b;
+};
+
+int f5(struct aA { struct ab { int j; } b; struct ab { char glorx; } glorx; } *); // expected-warning {{declaration of 'struct aA' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}}
+
+void f6(struct z {int b;} c) { // expected-warning {{declaration of 'struct z' will not be visible outside of this function}}
+ struct z d;
+ d.b = 4;
+}
diff --git a/test/Sema/default.c b/test/Sema/default.c
index 1318601..429e63a 100644
--- a/test/Sema/default.c
+++ b/test/Sema/default.c
@@ -3,6 +3,6 @@
void f5 (int z) {
if (z)
default: // expected-error {{not in switch statement}}
- ; // expected-warning {{if statement has empty body}}
+ ;
}
diff --git a/test/Sema/enum.c b/test/Sema/enum.c
index a95efb0..fc2b491 100644
--- a/test/Sema/enum.c
+++ b/test/Sema/enum.c
@@ -117,3 +117,5 @@ void crash(enum E* e) // expected-warning {{declaration of 'enum E' will not be
PR8694(e); // expected-warning {{incompatible pointer types passing 'enum E *' to parameter of type 'int *'}}
}
+typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
+int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
diff --git a/test/Sema/fn-ptr-as-fn-prototype.c b/test/Sema/fn-ptr-as-fn-prototype.c
new file mode 100644
index 0000000..cf95c97
--- /dev/null
+++ b/test/Sema/fn-ptr-as-fn-prototype.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1_only -ast-print %s | FileCheck %s
+
+// This testcase checks the functionality of
+// Sema::ActOn{Start,End}FunctionDeclarator, specifically checking that
+// ActOnEndFunctionDeclarator is called after the typedef so the enum
+// is in the global scope, not the scope of f().
+
+// CHECK: typedef void (*g)();
+typedef void (*g) ();
+// CHECK: enum {
+enum {
+ k = -1
+};
+// CHECK: void f() {
+void f() {}
diff --git a/test/Sema/format-strings-c90.c b/test/Sema/format-strings-c90.c
new file mode 100644
index 0000000..66ca507
--- /dev/null
+++ b/test/Sema/format-strings-c90.c
@@ -0,0 +1,30 @@
+/* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -std=c89 %s
+ */
+
+int scanf(const char * restrict, ...);
+int printf(const char *restrict, ...);
+
+void foo(char **sp, float *fp, int *ip) {
+ scanf("%as", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
+ scanf("%a[abc]", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
+
+ /* TODO: Warn that the 'a' conversion specifier is a C99 feature. */
+ scanf("%a", fp);
+ scanf("%afoobar", fp);
+ printf("%a", 1.0);
+ printf("%as", 1.0);
+ printf("%aS", 1.0);
+ printf("%a[", 1.0);
+ printf("%afoo", 1.0);
+
+ scanf("%da", ip);
+
+ /* Test argument type check for the 'a' length modifier. */
+ scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}} */
+ scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}}
+ expected-warning{{'S' conversion specifier is not supported by ISO C}} */
+ scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ expected-warning{{'a' length modifier is not supported by ISO C}} */
+}
diff --git a/test/Sema/format-strings-fixit-ssize_t.c b/test/Sema/format-strings-fixit-ssize_t.c
new file mode 100644
index 0000000..5208a29
--- /dev/null
+++ b/test/Sema/format-strings-fixit-ssize_t.c
@@ -0,0 +1,18 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -pedantic -Wall -fixit %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -Wall -Werror %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -E -o - %t | FileCheck %s
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. All of the
+ warnings will be fixed by -fixit, and the resulting file should
+ compile cleanly with -Werror -pedantic. */
+
+int printf(char const *, ...);
+
+void test() {
+ typedef signed long int ssize_t;
+ printf("%f", (ssize_t) 42);
+}
+
+// CHECK: printf("%zd", (ssize_t) 42);
diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c
index d03cccb..800691e 100644
--- a/test/Sema/format-strings-fixit.c
+++ b/test/Sema/format-strings-fixit.c
@@ -10,6 +10,11 @@
int printf(char const *, ...);
+typedef __SIZE_TYPE__ size_t;
+typedef __INTMAX_TYPE__ intmax_t;
+typedef __UINTMAX_TYPE__ uintmax_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
void test() {
// Basic types
printf("%s", (int) 123);
@@ -30,7 +35,10 @@ void test() {
printf("%0-f", 1.23); // - flag should stay
// Positional arguments
+#pragma clang diagnostic push // Don't warn about using positional arguments.
+#pragma clang diagnostic ignored "-Wformat-non-iso"
printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
+#pragma clang diagnostic pop
// Precision
printf("%10.5d", 1l); // (bug 7394)
@@ -41,21 +49,103 @@ void test() {
// Bad length modifiers
printf("%hhs", "foo");
+#pragma clang diagnostic push // Don't warn about using positional arguments.
+#pragma clang diagnostic ignored "-Wformat-non-iso"
printf("%1$zp", (void *)0);
-
- // Perserve the original formatting for unsigned integers.
+#pragma clang diagnostic pop
+
+ // Preserve the original formatting for unsigned integers.
unsigned long val = 42;
printf("%X", val);
+
+ // size_t, etc.
+ printf("%f", (size_t) 42);
+ printf("%f", (intmax_t) 42);
+ printf("%f", (uintmax_t) 42);
+ printf("%f", (ptrdiff_t) 42);
+
+ // string
+ printf("%ld", "foo");
+
+ // Preserve the original choice of conversion specifier.
+ printf("%o", (long) 42);
+ printf("%u", (long) 42);
+ printf("%x", (long) 42);
+ printf("%X", (long) 42);
+ printf("%i", (unsigned long) 42);
+ printf("%d", (unsigned long) 42);
+ printf("%F", (long double) 42);
+ printf("%e", (long double) 42);
+ printf("%E", (long double) 42);
+ printf("%g", (long double) 42);
+ printf("%G", (long double) 42);
+ printf("%a", (long double) 42);
+ printf("%A", (long double) 42);
}
-// Validate the fixes...
+int scanf(char const *, ...);
+
+void test2() {
+ char str[100];
+ short shortVar;
+ unsigned short uShortVar;
+ int intVar;
+ unsigned uIntVar;
+ float floatVar;
+ double doubleVar;
+ long double longDoubleVar;
+ long longVar;
+ unsigned long uLongVar;
+ long long longLongVar;
+ unsigned long long uLongLongVar;
+ size_t sizeVar;
+ intmax_t intmaxVar;
+ uintmax_t uIntmaxVar;
+ ptrdiff_t ptrdiffVar;
+
+ scanf("%lf", str);
+ scanf("%f", &shortVar);
+ scanf("%f", &uShortVar);
+ scanf("%p", &intVar);
+ scanf("%Lf", &uIntVar);
+ scanf("%ld", &floatVar);
+ scanf("%f", &doubleVar);
+ scanf("%d", &longDoubleVar);
+ scanf("%f", &longVar);
+ scanf("%f", &uLongVar);
+ scanf("%f", &longLongVar);
+ scanf("%f", &uLongLongVar);
+
+ // Some named ints.
+ scanf("%f", &sizeVar);
+ scanf("%f", &intmaxVar);
+ scanf("%f", &uIntmaxVar);
+ scanf("%f", &ptrdiffVar);
+
+ // Preserve the original formatting.
+ scanf("%o", &longVar);
+ scanf("%u", &longVar);
+ scanf("%x", &longVar);
+ scanf("%X", &longVar);
+ scanf("%i", &uLongVar);
+ scanf("%d", &uLongVar);
+ scanf("%F", &longDoubleVar);
+ scanf("%e", &longDoubleVar);
+ scanf("%E", &longDoubleVar);
+ scanf("%g", &longDoubleVar);
+ scanf("%G", &longDoubleVar);
+ scanf("%a", &longDoubleVar);
+ scanf("%A", &longDoubleVar);
+}
+
+// Validate the fixes.
// CHECK: printf("%d", (int) 123);
// CHECK: printf("abc%s", "testing testing 123");
-// CHECK: printf("%ld", (long) -12);
+// CHECK: printf("%lu", (long) -12);
// CHECK: printf("%d", 123);
// CHECK: printf("%s\n", "x");
// CHECK: printf("%f\n", 1.23);
-// CHECK: printf("%.2llu", (unsigned long long) 123456);
+// CHECK: printf("%+.2lld", (unsigned long long) 123456);
// CHECK: printf("%1Lf", (long double) 1.23);
// CHECK: printf("%0u", (unsigned) 31337);
// CHECK: printf("%p", (void *) 0);
@@ -68,3 +158,51 @@ void test() {
// CHECK: printf("%s", "foo");
// CHECK: printf("%1$p", (void *)0);
// CHECK: printf("%lX", val);
+// CHECK: printf("%zu", (size_t) 42);
+// CHECK: printf("%jd", (intmax_t) 42);
+// CHECK: printf("%ju", (uintmax_t) 42);
+// CHECK: printf("%td", (ptrdiff_t) 42);
+// CHECK: printf("%s", "foo");
+// CHECK: printf("%lo", (long) 42);
+// CHECK: printf("%lu", (long) 42);
+// CHECK: printf("%lx", (long) 42);
+// CHECK: printf("%lX", (long) 42);
+// CHECK: printf("%li", (unsigned long) 42);
+// CHECK: printf("%ld", (unsigned long) 42);
+// CHECK: printf("%LF", (long double) 42);
+// CHECK: printf("%Le", (long double) 42);
+// CHECK: printf("%LE", (long double) 42);
+// CHECK: printf("%Lg", (long double) 42);
+// CHECK: printf("%LG", (long double) 42);
+// CHECK: printf("%La", (long double) 42);
+// CHECK: printf("%LA", (long double) 42);
+
+// CHECK: scanf("%s", str);
+// CHECK: scanf("%hd", &shortVar);
+// CHECK: scanf("%hu", &uShortVar);
+// CHECK: scanf("%d", &intVar);
+// CHECK: scanf("%u", &uIntVar);
+// CHECK: scanf("%f", &floatVar);
+// CHECK: scanf("%lf", &doubleVar);
+// CHECK: scanf("%Lf", &longDoubleVar);
+// CHECK: scanf("%ld", &longVar);
+// CHECK: scanf("%lu", &uLongVar);
+// CHECK: scanf("%lld", &longLongVar);
+// CHECK: scanf("%llu", &uLongLongVar);
+// CHECK: scanf("%zu", &sizeVar);
+// CHECK: scanf("%jd", &intmaxVar);
+// CHECK: scanf("%ju", &uIntmaxVar);
+// CHECK: scanf("%td", &ptrdiffVar);
+// CHECK: scanf("%lo", &longVar);
+// CHECK: scanf("%lu", &longVar);
+// CHECK: scanf("%lx", &longVar);
+// CHECK: scanf("%lX", &longVar);
+// CHECK: scanf("%li", &uLongVar);
+// CHECK: scanf("%ld", &uLongVar);
+// CHECK: scanf("%LF", &longDoubleVar);
+// CHECK: scanf("%Le", &longDoubleVar);
+// CHECK: scanf("%LE", &longDoubleVar);
+// CHECK: scanf("%Lg", &longDoubleVar);
+// CHECK: scanf("%LG", &longDoubleVar);
+// CHECK: scanf("%La", &longDoubleVar);
+// CHECK: scanf("%LA", &longDoubleVar);
diff --git a/test/Sema/format-strings-int-typedefs.c b/test/Sema/format-strings-int-typedefs.c
new file mode 100644
index 0000000..341d49c
--- /dev/null
+++ b/test/Sema/format-strings-int-typedefs.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+
+int printf(char const *, ...);
+int scanf(char const *, ...);
+
+void test(void) {
+ printf("%jd", 42.0); // expected-warning {{format specifies type 'intmax_t' (aka 'long long')}}
+ printf("%ju", 42.0); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long')}}
+ printf("%zu", 42.0); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long')}}
+ printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
+ printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
+ printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ printf("%S", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ printf("%C", 42.0); // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
+
+ scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}}
+ scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}}
+ scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}}
+ scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
+ scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%S", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+ scanf("%C", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+
+
+ // typedef size_t et al. to something crazy.
+ typedef void *size_t;
+ typedef void *intmax_t;
+ typedef void *uintmax_t;
+ typedef void *ptrdiff_t;
+
+ // The warning still fires, because it checks the underlying type.
+ printf("%jd", (intmax_t)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}}
+ printf("%ju", (uintmax_t)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}}
+ printf("%zu", (size_t)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}}
+ printf("%td", (ptrdiff_t)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}}
+}
diff --git a/test/Sema/format-strings-no-fixit.c b/test/Sema/format-strings-no-fixit.c
new file mode 100644
index 0000000..701e945
--- /dev/null
+++ b/test/Sema/format-strings-no-fixit.c
@@ -0,0 +1,65 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -fixit %t
+// RUN: %clang_cc1 -E -o - %t | FileCheck %s
+
+/* This is a test of the various code modification hints that are
+ provided as part of warning or extension diagnostics. Only
+ warnings for format strings within the function call will be
+ fixed by -fixit. Other format strings will be left alone. */
+
+int printf(char const *, ...);
+int scanf(char const *, ...);
+
+void pr9751() {
+ const char kFormat1[] = "%s";
+ printf(kFormat1, 5);
+ printf("%s", 5);
+
+ const char kFormat2[] = "%.3p";
+ void *p;
+ printf(kFormat2, p);
+ printf("%.3p", p);
+
+ const char kFormat3[] = "%0s";
+ printf(kFormat3, "a");
+ printf("%0s", "a");
+
+ const char kFormat4[] = "%hhs";
+ printf(kFormat4, "a");
+ printf("%hhs", "a");
+
+ const char kFormat5[] = "%-0d";
+ printf(kFormat5, 5);
+ printf("%-0d", 5);
+
+ const char kFormat6[] = "%00d";
+ int *i;
+ scanf(kFormat6, i);
+ scanf("%00d", i);
+}
+
+// CHECK: const char kFormat1[] = "%s";
+// CHECK: printf(kFormat1, 5);
+// CHECK: printf("%d", 5);
+
+// CHECK: const char kFormat2[] = "%.3p";
+// CHECK: void *p;
+// CHECK: printf(kFormat2, p);
+// CHECK: printf("%p", p);
+
+// CHECK: const char kFormat3[] = "%0s";
+// CHECK: printf(kFormat3, "a");
+// CHECK: printf("%s", "a");
+
+// CHECK: const char kFormat4[] = "%hhs";
+// CHECK: printf(kFormat4, "a");
+// CHECK: printf("%s", "a");
+
+// CHECK: const char kFormat5[] = "%-0d";
+// CHECK: printf(kFormat5, 5);
+// CHECK: printf("%-d", 5);
+
+// CHECK: const char kFormat6[] = "%00d";
+// CHECK: int *i;
+// CHECK: scanf(kFormat6, i);
+// CHECK: scanf("%d", i);
diff --git a/test/Sema/format-strings-non-iso.c b/test/Sema/format-strings-non-iso.c
new file mode 100644
index 0000000..ed8095f
--- /dev/null
+++ b/test/Sema/format-strings-non-iso.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -pedantic %s
+
+int printf(const char *restrict, ...);
+int scanf(const char * restrict, ...);
+
+void f(void) {
+ char *cp;
+
+ // The 'q' length modifier.
+ printf("%qd", (long long)42); // expected-warning{{'q' length modifier is not supported by ISO C}}
+ scanf("%qd", (long long *)0); // expected-warning{{'q' length modifier is not supported by ISO C}}
+
+ // The 'm' length modifier.
+ scanf("%ms", &cp); // expected-warning{{'m' length modifier is not supported by ISO C}}
+
+ // The 'S' and 'C' conversion specifiers.
+ printf("%S", L"foo"); // expected-warning{{'S' conversion specifier is not supported by ISO C}}
+ printf("%C", L'x'); // expected-warning{{'C' conversion specifier is not supported by ISO C}}
+
+ // Combining 'L' with an integer conversion specifier.
+ printf("%Li", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'i' is not supported by ISO C}}
+ printf("%Lo", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'o' is not supported by ISO C}}
+ printf("%Lu", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'u' is not supported by ISO C}}
+ printf("%Lx", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'x' is not supported by ISO C}}
+ printf("%LX", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'X' is not supported by ISO C}}
+
+ // Positional arguments.
+ printf("%1$d", 42); // expected-warning{{positional arguments are not supported by ISO C}}
+}
diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c
index 42b6c03..e94af5a 100644
--- a/test/Sema/format-strings-scanf.c
+++ b/test/Sema/format-strings-scanf.c
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-nonliteral %s
+// Test that -Wformat=0 works:
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wformat=0 %s
+
+#include <stdarg.h>
typedef __typeof(sizeof(int)) size_t;
typedef struct _FILE FILE;
typedef __WCHAR_TYPE__ wchar_t;
@@ -7,6 +11,11 @@ typedef __WCHAR_TYPE__ wchar_t;
int fscanf(FILE * restrict, const char * restrict, ...) ;
int scanf(const char * restrict, ...) ;
int sscanf(const char * restrict, const char * restrict, ...) ;
+int my_scanf(const char * restrict, ...) __attribute__((__format__(__scanf__, 1, 2)));
+
+int vscanf(const char * restrict, va_list);
+int vfscanf(FILE * restrict, const char * restrict, va_list);
+int vsscanf(const char * restrict, const char * restrict, va_list);
void test(const char *s, int *i) {
scanf(s, i); // expected-warning{{ormat string is not a string literal}}
@@ -28,7 +37,87 @@ void test(const char *s, int *i) {
void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) {
scanf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
- scanf("%1$zp", p); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
+ scanf("%1$zp", &p); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
scanf("%ls", ws); // no-warning
scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}}
}
+
+// Test that the scanf call site is where the warning is attached. If the
+// format string is somewhere else, point to it in a note.
+void pr9751() {
+ int *i;
+ char str[100];
+ const char kFormat1[] = "%00d"; // expected-note{{format string is defined here}}}
+ scanf(kFormat1, i); // expected-warning{{zero field width in scanf format string is unused}}
+ scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
+ const char kFormat2[] = "%["; // expected-note{{format string is defined here}}}
+ scanf(kFormat2, str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ scanf("%[", str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ const char kFormat3[] = "%hu"; // expected-note{{format string is defined here}}}
+ scanf(kFormat3, &i); // expected-warning {{format specifies type 'unsigned short *' but the argument}}
+ const char kFormat4[] = "%lp"; // expected-note{{format string is defined here}}}
+ scanf(kFormat4, &i); // expected-warning {{length modifier 'l' results in undefined behavior or no effect with 'p' conversion specifier}}
+}
+
+void test_variants(int *i, const char *s, ...) {
+ FILE *f = 0;
+ char buf[100];
+
+ fscanf(f, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+ sscanf(buf, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+ my_scanf("%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
+
+ va_list ap;
+ va_start(ap, s);
+
+ vscanf("%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ vfscanf(f, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+ vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
+}
+
+void test_scanlist(int *ip, char *sp, wchar_t *ls) {
+ scanf("%[abc]", ip); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
+ scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}}
+ scanf("%l[xyx]", ls); // no-warning
+ scanf("%ll[xyx]", ls); // expected-warning {{length modifier 'll' results in undefined behavior or no effect with '[' conversion specifier}}
+}
+
+void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) {
+ /* Make sure "%a" gets parsed as a conversion specifier for float,
+ * even when followed by an 's', 'S' or '[', which would cause it to be
+ * parsed as a length modifier in C90. */
+ scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+ scanf("%aS", lsp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}}
+ scanf("%a[bcd]", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+
+ // Test that the 'm' length modifier is only allowed with s, S, c, C or [.
+ // TODO: Warn that 'm' is an extension.
+ scanf("%ms", sp); // No warning.
+ scanf("%mS", lsp); // No warning.
+ scanf("%mc", sp); // No warning.
+ scanf("%mC", lsp); // No warning.
+ scanf("%m[abc]", sp); // No warning.
+ scanf("%md", sp); // expected-warning{{length modifier 'm' results in undefined behavior or no effect with 'd' conversion specifier}}
+
+ // Test argument type check for the 'm' length modifier.
+ scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ scanf("%mS", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+ scanf("%mC", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
+ scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
+}
+
+void test_longlong(long long *x, unsigned long long *y) {
+ scanf("%Ld", y); // no-warning
+ scanf("%Lu", y); // no-warning
+ scanf("%Lx", y); // no-warning
+ scanf("%Ld", x); // no-warning
+ scanf("%Lu", x); // no-warning
+ scanf("%Lx", x); // no-warning
+ scanf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}
+
+void test_quad(int *x, long long *llx) {
+ scanf("%qd", x); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
+ scanf("%qd", llx); // no-warning
+}
diff --git a/test/Sema/format-strings-size_t.c b/test/Sema/format-strings-size_t.c
new file mode 100644
index 0000000..7f88ff3
--- /dev/null
+++ b/test/Sema/format-strings-size_t.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+
+int printf(char const *, ...);
+
+void test(void) {
+ // size_t
+ printf("%zu", (double)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'double'}}
+
+ // intmax_t / uintmax_t
+ printf("%jd", (double)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long') but the argument has type 'double'}}
+ printf("%ju", (double)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'double'}}
+
+ // ptrdiff_t
+ printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}}
+}
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 6b5f7e2..086c5c6 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -14,6 +14,8 @@ int vprintf(const char *restrict, va_list);
int vsnprintf(char *, size_t, const char *, va_list);
int vsprintf(char *restrict, const char *restrict, va_list); // expected-note{{passing argument to parameter here}}
+int vscanf(const char *restrict format, va_list arg);
+
char * global_fmt;
void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
@@ -23,21 +25,23 @@ void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
va_start(ap,buf);
printf(s); // expected-warning {{format string is not a string literal}}
- vprintf(s,ap); // // no-warning
+ vprintf(s,ap); // expected-warning {{format string is not a string literal}}
fprintf(fp,s); // expected-warning {{format string is not a string literal}}
- vfprintf(fp,s,ap); // no-warning
+ vfprintf(fp,s,ap); // expected-warning {{format string is not a string literal}}
asprintf(&b,s); // expected-warning {{format string is not a string lit}}
- vasprintf(&b,s,ap); // no-warning
+ vasprintf(&b,s,ap); // expected-warning {{format string is not a string literal}}
sprintf(buf,s); // expected-warning {{format string is not a string literal}}
snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
__builtin___sprintf_chk(buf,0,-1,s); // expected-warning {{format string is not a string literal}}
__builtin___snprintf_chk(buf,2,0,-1,s); // expected-warning {{format string is not a string lit}}
- vsprintf(buf,s,ap); // no-warning
- vsnprintf(buf,2,s,ap); // no-warning
+ vsprintf(buf,s,ap); // expected-warning {{format string is not a string lit}}
+ vsnprintf(buf,2,s,ap); // expected-warning {{format string is not a string lit}}
vsnprintf(buf,2,global_fmt,ap); // expected-warning {{format string is not a string literal}}
- __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // no-warning
+ __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // expected-warning {{format string is not a string lit}}
__builtin___vsnprintf_chk(buf,2,0,-1,global_fmt,ap); // expected-warning {{format string is not a string literal}}
+ vscanf(s, ap); // expected-warning {{format string is not a string literal}}
+
// rdar://6079877
printf("abc"
"%*d", 1, 1); // no-warning
@@ -51,6 +55,25 @@ def"
printf("%*d", (unsigned) 1, 1); // no-warning
}
+__attribute__((__format__ (__printf__, 2, 4)))
+void check_string_literal2( FILE* fp, const char* s, char *buf, ... ) {
+ char * b;
+ va_list ap;
+ va_start(ap,buf);
+
+ printf(s); // expected-warning {{format string is not a string literal}}
+ vprintf(s,ap); // no-warning
+ fprintf(fp,s); // expected-warning {{format string is not a string literal}}
+ vfprintf(fp,s,ap); // no-warning
+ asprintf(&b,s); // expected-warning {{format string is not a string lit}}
+ vasprintf(&b,s,ap); // no-warning
+ sprintf(buf,s); // expected-warning {{format string is not a string literal}}
+ snprintf(buf,2,s); // expected-warning {{format string is not a string lit}}
+ __builtin___vsnprintf_chk(buf,2,0,-1,s,ap); // no-warning
+
+ vscanf(s, ap); // expected-warning {{format string is not a string literal}}
+}
+
void check_conditional_literal(const char* s, int i) {
printf(i == 1 ? "yes" : "no"); // no-warning
printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
@@ -71,8 +94,8 @@ void check_invalid_specifier(FILE* fp, char *buf)
{
printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion specifier 'b'}}
fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
- sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // expected-warning{{conversion specifies type 'long' but the argument has type 'int'}}
- snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning{{conversion specifies type 'long' but the argument has type 'int'}} expected-warning {{invalid conversion specifier ';'}}
+ sprintf(buf,"%%%%%ld%d%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}}
+ snprintf(buf, 2, "%%%%%ld%;%d", 1, 2, 3); // expected-warning{{format specifies type 'long' but the argument has type 'int'}} expected-warning {{invalid conversion specifier ';'}}
}
void check_null_char_string(char* b)
@@ -166,33 +189,35 @@ void test10(int x, float f, int i, long long lli) {
printf("%"); // expected-warning{{incomplete format specifier}}
printf("%.d", x); // no-warning
printf("%.", x); // expected-warning{{incomplete format specifier}}
- printf("%f", 4); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}}
- printf("%qd", lli);
+ printf("%f", 4); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
+ printf("%qd", lli); // no-warning
+ printf("%qd", x); // expected-warning{{format specifies type 'long long' but the argument has type 'int'}}
+ printf("%qp", (void *)0); // expected-warning{{length modifier 'q' results in undefined behavior or no effect with 'p' conversion specifier}}
printf("hhX %hhX", (unsigned char)10); // no-warning
printf("llX %llX", (long long) 10); // no-warning
// This is fine, because there is an implicit conversion to an int.
printf("%d", (unsigned char) 10); // no-warning
- printf("%d", (long long) 10); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}}
+ printf("%d", (long long) 10); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
printf("%Lf\n", (long double) 1.0); // no-warning
- printf("%f\n", (long double) 1.0); // expected-warning{{conversion specifies type 'double' but the argument has type 'long double'}}
+ printf("%f\n", (long double) 1.0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
// The man page says that a zero precision is okay.
printf("%.0Lf", (long double) 1.0); // no-warning
- printf("%c\n", "x"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}}
- printf("%c\n", 1.23); // expected-warning{{conversion specifies type 'int' but the argument has type 'double'}}
+ printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+ printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}}
}
typedef unsigned char uint8_t;
void should_understand_small_integers() {
- printf("%hhu", (short) 10); // expected-warning{{conversion specifies type 'unsigned char' but the argument has type 'short'}}
- printf("%hu\n", (unsigned char) 1); // expected-warning{{conversion specifies type 'unsigned short' but the argument has type 'unsigned char'}}
- printf("%hu\n", (uint8_t)1); // expected-warning{{conversion specifies type 'unsigned short' but the argument has type 'uint8_t'}}
+ printf("%hhu", (short) 10); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'short'}}
+ printf("%hu\n", (unsigned char) 1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'unsigned char'}}
+ printf("%hu\n", (uint8_t)1); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'uint8_t'}}
}
void test11(void *p, char *s) {
printf("%p", p); // no-warning
- printf("%p", 123); // expected-warning{{conversion specifies type 'void *' but the argument has type 'int'}}
+ printf("%p", 123); // expected-warning{{format specifies type 'void *' but the argument has type 'int'}}
printf("%.4p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
printf("%+p", p); // expected-warning{{flag '+' results in undefined behavior with 'p' conversion specifier}}
printf("% p", p); // expected-warning{{flag ' ' results in undefined behavior with 'p' conversion specifier}}
@@ -206,10 +231,16 @@ void test11(void *p, char *s) {
void test12(char *b) {
unsigned char buf[4];
printf ("%.4s\n", buf); // no-warning
- printf ("%.4s\n", &buf); // expected-warning{{conversion specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
+ printf ("%.4s\n", &buf); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
// Verify that we are checking asprintf
- asprintf(&b, "%d", "asprintf"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}}
+ asprintf(&b, "%d", "asprintf"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
+}
+
+void test13(short x) {
+ char bel = 007;
+ printf("bel: '0%hhd'\n", bel); // no-warning
+ printf("x: '0%hhd'\n", x); // expected-warning {{format specifies type 'char' but the argument has type 'short'}}
}
typedef struct __aslclient *aslclient;
@@ -231,13 +262,12 @@ typedef __WCHAR_TYPE__ wchar_t;
void test_unicode_conversions(wchar_t *s) {
printf("%S", s); // no-warning
- printf("%s", s); // expected-warning{{conversion specifies type 'char *' but the argument has type 'wchar_t *'}}
+ printf("%s", s); // expected-warning{{format specifies type 'char *' but the argument has type 'wchar_t *'}}
printf("%C", s[0]); // no-warning
printf("%c", s[0]);
// FIXME: This test reports inconsistent results. On Windows, '%C' expects
// 'unsigned short'.
// printf("%C", 10);
- // FIXME: we report the expected type as 'int*' instead of 'wchar_t*'
printf("%S", "hello"); // expected-warning{{but the argument has type 'char *'}}
}
@@ -249,7 +279,7 @@ void test_positional_arguments() {
printf("%1$*0$d", (int) 2); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
printf("%1$d", (int) 2); // no-warning
printf("%1$d", (int) 2, 2); // expected-warning{{data argument not used by format string}}
- printf("%1$d%1$f", (int) 2); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}}
+ printf("%1$d%1$f", (int) 2); // expected-warning{{format specifies type 'double' but the argument has type 'int'}}
printf("%1$2.2d", (int) 2); // no-warning
printf("%2$*1$.2d", (int) 2, (int) 3); // no-warning
printf("%2$*8$d", (int) 2, (int) 3); // expected-warning{{specified field width is missing a matching 'int' argument}}
@@ -261,13 +291,13 @@ void test_positional_arguments() {
void myprintf_PR_6697(const char *format, int x, ...) __attribute__((__format__(printf,1, 3)));
void test_pr_6697() {
myprintf_PR_6697("%s\n", 1, "foo"); // no-warning
- myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ myprintf_PR_6697("%s\n", 1, (int)0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
// FIXME: Not everything should clearly support positional arguments,
// but we need a way to identify those cases.
myprintf_PR_6697("%1$s\n", 1, "foo"); // no-warning
myprintf_PR_6697("%2$s\n", 1, "foo"); // expected-warning{{data argument position '2' exceeds the number of data arguments (1)}}
myprintf_PR_6697("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (1)}}
- myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ myprintf_PR_6697("%1$s\n", 1, (int) 0); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
}
void rdar8026030(FILE *fp) {
@@ -353,7 +383,7 @@ void posix_extensions() {
#pragma GCC diagnostic ignored "-Wformat-security"
void pr8486() {
- printf("%s", 1); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ printf("%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
}
// PR9314
@@ -366,7 +396,7 @@ void pr9314() {
int printf(const char * restrict, ...) __attribute__((__format__ (__printf__, 1, 2)));
void rdar9612060(void) {
- printf("%s", 2); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int'}}
+ printf("%s", 2); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
}
void check_char(unsigned char x, signed char y) {
@@ -387,3 +417,107 @@ void test_suppress_invalid_specifier() {
#pragma clang diagnostic pop
}
+// Make sure warnings are on for next test.
+#pragma GCC diagnostic warning "-Wformat"
+#pragma GCC diagnostic warning "-Wformat-security"
+
+// Test that the printf call site is where the warning is attached. If the
+// format string is somewhere else, point to it in a note.
+void pr9751() {
+ const char kFormat1[] = "%d %d \n"; // expected-note{{format string is defined here}}}
+ printf(kFormat1, 0); // expected-warning{{more '%' conversions than data arguments}}
+ printf("%d %s\n", 0); // expected-warning{{more '%' conversions than data arguments}}
+
+ const char kFormat2[] = "%18$s\n"; // expected-note{{format string is defined here}}
+ printf(kFormat2, 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
+ printf("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}}
+
+ const char kFormat3[] = "%n"; // expected-note{{format string is defined here}}
+ printf(kFormat3, "as"); // expected-warning{{use of '%n' in format string discouraged}}
+ printf("%n", "as"); // expected-warning{{use of '%n' in format string discouraged}}
+
+ const char kFormat4[] = "%y"; // expected-note{{format string is defined here}}
+ printf(kFormat4, 5); // expected-warning{{invalid conversion specifier 'y'}}
+ printf("%y", 5); // expected-warning{{invalid conversion specifier 'y'}}
+
+ const char kFormat5[] = "%."; // expected-note{{format string is defined here}}
+ printf(kFormat5, 5); // expected-warning{{incomplete format specifier}}
+ printf("%.", 5); // expected-warning{{incomplete format specifier}}
+
+ const char kFormat6[] = "%s"; // expected-note{{format string is defined here}}
+ printf(kFormat6, 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ printf("%s", 5); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+
+ const char kFormat7[] = "%0$"; // expected-note{{format string is defined here}}
+ printf(kFormat7, 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+ printf("%0$", 5); // expected-warning{{position arguments in format strings start counting at 1 (not 0)}}
+
+ const char kFormat8[] = "%1$d %d"; // expected-note{{format string is defined here}}
+ printf(kFormat8, 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
+ printf("%1$d %d", 4, 4); // expected-warning{{cannot mix positional and non-positional arguments in format string}}
+
+ const char kFormat9[] = ""; // expected-note{{format string is defined here}}
+ printf(kFormat9, 4, 4); // expected-warning{{format string is empty}}
+ printf("", 4, 4); // expected-warning{{format string is empty}}
+
+ const char kFormat10[] = "\0%d"; // expected-note{{format string is defined here}}
+ printf(kFormat10, 4); // expected-warning{{format string contains '\0' within the string body}}
+ printf("\0%d", 4); // expected-warning{{format string contains '\0' within the string body}}
+
+ const char kFormat11[] = "%*d"; // expected-note{{format string is defined here}}
+ printf(kFormat11); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+ printf("%*d"); // expected-warning{{'*' specified field width is missing a matching 'int' argument}}
+
+ const char kFormat12[] = "%*d"; // expected-note{{format string is defined here}}
+ printf(kFormat12, 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+ printf("%*d", 4.4); // expected-warning{{field width should have type 'int', but argument has type 'double'}}
+
+ const char kFormat13[] = "%.3p"; // expected-note{{format string is defined here}}
+ void *p;
+ printf(kFormat13, p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
+ printf("%.3p", p); // expected-warning{{precision used with 'p' conversion specifier, resulting in undefined behavior}}
+
+ const char kFormat14[] = "%0s"; // expected-note{{format string is defined here}}
+ printf(kFormat14, "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
+ printf("%0s", "a"); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}}
+
+ const char kFormat15[] = "%hhs"; // expected-note{{format string is defined here}}
+ printf(kFormat15, "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+ printf("%hhs", "a"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
+
+ const char kFormat16[] = "%-0d"; // expected-note{{format string is defined here}}
+ printf(kFormat16, 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+ printf("%-0d", 5); // expected-warning{{flag '0' is ignored when flag '-' is present}}
+
+ // Make sure that the "format string is defined here" note is not emitted
+ // when the original string is within the argument expression.
+ printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
+
+ const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
+ printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
+
+ printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
+}
+
+// PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx
+void printf_longlong(long long x, unsigned long long y) {
+ printf("%Ld", y); // no-warning
+ printf("%Lu", y); // no-warning
+ printf("%Lx", y); // no-warning
+ printf("%Ld", x); // no-warning
+ printf("%Lu", x); // no-warning
+ printf("%Lx", x); // no-warning
+ printf("%Ls", "hello"); // expected-warning {{length modifier 'L' results in undefined behavior or no effect with 's' conversion specifier}}
+}
+
+void __attribute__((format(strfmon,1,2))) monformat(const char *fmt, ...);
+void __attribute__((format(strftime,1,0))) dateformat(const char *fmt);
+
+// Other formats
+void test_other_formats() {
+ char *str = "";
+ monformat("", 1); // expected-warning{{format string is empty}}
+ monformat(str); // expected-warning{{format string is not a string literal (potentially insecure)}}
+ dateformat(""); // expected-warning{{format string is empty}}
+ dateformat(str); // no-warning (using strftime non literal is not unsafe)
+}
diff --git a/test/Sema/function.c b/test/Sema/function.c
index b51c137..1b0dc2a 100644
--- a/test/Sema/function.c
+++ b/test/Sema/function.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
-// PR1892
-void f(double a[restrict][5]); // should promote to restrict ptr.
-void f(double (* restrict a)[5]);
+
+// PR1892, PR11354
+void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
int foo (__const char *__path);
int foo(__const char *__restrict __file);
@@ -89,3 +89,6 @@ unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type
// missing ',' before '...'
void t20(int i...) { } // expected-error {{requires a comma}}
+
+int n;
+void t21(int n, int (*array)[n]);
diff --git a/test/Sema/gnu89.c b/test/Sema/gnu89.c
index fc21dcd..189e6b0 100644
--- a/test/Sema/gnu89.c
+++ b/test/Sema/gnu89.c
@@ -1,3 +1,5 @@
// RUN: %clang_cc1 %s -std=gnu89 -pedantic -fsyntax-only -verify
int f(int restrict);
+
+void main() {} // expected-warning {{return type of 'main' is not 'int'}}
diff --git a/test/Sema/i-c-e.c b/test/Sema/i-c-e.c
index 9b50916..ee61ac3 100644
--- a/test/Sema/i-c-e.c
+++ b/test/Sema/i-c-e.c
@@ -11,14 +11,17 @@ char w[__builtin_constant_p(expr) ? expr : 1];
char v[sizeof(__builtin_constant_p(0)) == sizeof(int) ? 1 : -1];
+int implicitConversion = 1.0;
+char floatArith[(int)(1.0+2.0)]; // expected-warning {{must be an integer constant expression}}
+
// __builtin_constant_p as the condition of ?: allows arbitrary foldable
// constants to be transmogrified into i-c-e's.
char b[__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+2.0) : -1];
struct c {
- int a : ( // expected-error {{expression is not an integer constant expression}}
+ int a : (
__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+
- expr // expected-note {{subexpression not valid in an integer constant expression}}
+ expr // expected-error {{expression is not an integer constant expression}}
) : -1);
};
@@ -51,24 +54,21 @@ char y[__builtin_constant_p(expr) ? -1 : 1];
char z[__builtin_constant_p(4) ? 1 : -1];
// Comma tests
-int comma1[0?1,2:3]; // expected-warning {{expression result unused}}
-int comma2[1||(1,2)]; // expected-warning {{expression result unused}} \
- // expected-warning {{use of logical '||' with constant operand}} \
+int comma1[0?1,2:3];
+int comma2[1||(1,2)]; // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
-int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}} \
- // expected-warning {{expression result unused}}
+int comma3[(1,2)]; // expected-warning {{size of static array must be an integer constant expression}}
// Pointer + __builtin_constant_p
char pbcp[__builtin_constant_p(4) ? (intptr_t)&expr : 0]; // expected-error {{variable length array declaration not allowed at file scope}}
-int illegaldiv1a[1 || 1/0]; // expected-warning {{division by zero is undefined}}
-int illegaldiv1b[1 && 1/0]; // expected-warning {{division by zero is undefined}} expected-error{{variable length array declaration not allowed at file scope}}
+int illegaldiv1a[1 || 1/0];
+int illegaldiv1b[1 && 1/0]; //expected-error{{variable length array declaration not allowed at file scope}}
-int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}} \
- // expected-warning {{division by zero is undefined}}
+int illegaldiv2[1/0]; // expected-error {{variable length array declaration not allowed at file scope}}
int illegaldiv3[INT_MIN / -1]; // expected-error {{variable length array declaration not allowed at file scope}}
// PR9262
-int illegaldiv4[0 / (1 / 0)]; // expected-warning {{division by zero is undefined}} expected-error {{variable length array declaration not allowed at file scope}}
+int illegaldiv4[0 / (1 / 0)]; // expected-error {{variable length array declaration not allowed at file scope}}
int chooseexpr[__builtin_choose_expr(1, 1, expr)];
int realop[(__real__ 4) == 4 ? 1 : -1];
diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c
index d80414d..8cdd365 100644
--- a/test/Sema/implicit-builtin-decl.c
+++ b/test/Sema/implicit-builtin-decl.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f() {
- int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring C library function 'malloc' with type}} \
+ int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
// expected-note{{please include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
// expected-note{{'malloc' is a builtin with type 'void *}}
}
diff --git a/test/Sema/implicit-builtin-redecl.c b/test/Sema/implicit-builtin-redecl.c
index 1e520d2..9fb7e62 100644
--- a/test/Sema/implicit-builtin-redecl.c
+++ b/test/Sema/implicit-builtin-redecl.c
@@ -6,7 +6,7 @@ static void* malloc(int size) {
return ((void*)0); /*do not use heap in this file*/
}
-void *calloc(int, int, int); // expected-warning{{incompatible redeclaration of library function 'calloc' will be ignored}} \
+void *calloc(int, int, int); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \
// expected-note{{'calloc' is a builtin with type 'void *}}
void f1(void) {
diff --git a/test/Sema/implicit-decl.c b/test/Sema/implicit-decl.c
index f455977..ffab9a6 100644
--- a/test/Sema/implicit-decl.c
+++ b/test/Sema/implicit-decl.c
@@ -1,17 +1,32 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Werror
typedef int int32_t;
typedef unsigned char Boolean;
+extern int printf(__const char *__restrict __format, ...); // expected-note{{'printf' declared here}}
+
void func() {
int32_t *vector[16];
const char compDesc[16 + 1];
int32_t compCount = 0;
if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
- expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
+ expected-error {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
}
+
+ printg("Hello, World!\n"); // expected-error{{implicit declaration of function 'printg' is invalid in C99}} \
+ // expected-note{{did you mean 'printf'?}}
+
+ __builtin_is_les(1, 3); // expected-error{{use of unknown builtin '__builtin_is_les'}}
}
Boolean _CFCalendarDecomposeAbsoluteTimeV(const char *componentDesc, int32_t **vector, int32_t count) { // expected-error{{conflicting types for '_CFCalendarDecomposeAbsoluteTimeV'}}
return 0;
}
+
+// Test the typo-correction callback in Sema::ImplicitlyDefineFunction
+extern int sformatf(char *str, __const char *__restrict __format, ...); // expected-note{{'sformatf' declared here}}
+void test_implicit() {
+ int formats = 0;
+ formatd("Hello, World!\n"); // expected-error{{implicit declaration of function 'formatd' is invalid in C99}} \
+ // expected-note{{did you mean 'sformatf'?}}
+}
diff --git a/test/Sema/init.c b/test/Sema/init.c
index 2527e14..81a665d 100644
--- a/test/Sema/init.c
+++ b/test/Sema/init.c
@@ -18,10 +18,19 @@ extern int x;
void *g = &x;
int *h = &x;
+struct union_crash
+{
+ union
+ {
+ };
+};
+
int test() {
-int a[10];
-int b[10] = a; // expected-error {{array initializer must be an initializer list}}
-int +; // expected-error {{expected identifier or '('}}
+ int a[10];
+ int b[10] = a; // expected-error {{array initializer must be an initializer list}}
+ int +; // expected-error {{expected identifier or '('}}
+
+ struct union_crash u = { .d = 1 }; // expected-error {{field designator 'd' does not refer to any field in type 'struct union_crash'}}
}
diff --git a/test/Sema/invalid-struct-init.c b/test/Sema/invalid-struct-init.c
index a598d57..000d3ab 100644
--- a/test/Sema/invalid-struct-init.c
+++ b/test/Sema/invalid-struct-init.c
@@ -3,8 +3,6 @@
typedef struct _zend_module_entry zend_module_entry;
struct _zend_module_entry {
_efree((p)); // expected-error{{type name requires a specifier or qualifier}} \
- expected-error{{field '_efree' declared as a function}} \
- expected-warning {{type specifier missing, defaults to 'int'}} \
expected-warning {{type specifier missing, defaults to 'int'}}
};
diff --git a/test/Sema/many-logical-ops.c b/test/Sema/many-logical-ops.c
new file mode 100644
index 0000000..09a7684
--- /dev/null
+++ b/test/Sema/many-logical-ops.c
@@ -0,0 +1,2010 @@
+// RUN: %clang_cc1 -fsyntax-only -Wconstant-conversion -verify %s
+
+// rdar://10913206&10941790
+// Check that we don't get stack overflow trying to evaluate a huge number of
+// logical operators.
+
+int foo(int x) {
+ return
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x &&
+ x;
+}
diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp
index 13c90b0..ea3f899 100644
--- a/test/Sema/ms_class_layout.cpp
+++ b/test/Sema/ms_class_layout.cpp
@@ -53,11 +53,50 @@ struct DerivedStruct : public BaseStruct {
struct G
{
- virtual ~G(){}
- int a;
- double b;
+ int g_field;
};
+struct H : public G,
+ public virtual D
+{
+};
+
+struct I : public virtual D
+{
+ virtual ~I(){}
+ double q;
+};
+
+struct K
+{
+ int k;
+};
+
+struct L
+{
+ int l;
+};
+
+struct M : public virtual K
+{
+ int m;
+};
+
+struct N : public L, public M
+{
+ virtual void f(){}
+};
+
+struct O : public H, public G {
+ virtual void fo(){}
+};
+
+struct P : public M, public virtual L {
+ int p;
+};
+
+struct R {};
+
#pragma pack(pop)
// This needs only for building layouts.
@@ -67,28 +106,37 @@ int main() {
C* c;
c->foo();
DerivedStruct* v;
- G* g;
+ H* g;
BaseStruct* u;
+ I* i;
+ N* n;
+ O* o;
+ P* p;
+ R* r;
return 0;
}
// CHECK: 0 | class D
-// CHECK-NEXT: 0 | (D vtable pointer)
+// CHECK-NEXT: 0 | (D vftable pointer)
// CHECK-NEXT: 8 | double a
// CHECK-NEXT: sizeof=16, dsize=16, align=8
// CHECK-NEXT: nvsize=16, nvalign=8
+// CHECK: %class.D = type { i32 (...)**, double }
+
// CHECK: 0 | class B
-// CHECK-NEXT: 0 | (B vtable pointer)
+// CHECK-NEXT: 0 | (B vftable pointer)
// CHECK-NEXT: 4 | int b_field
// CHECK-NEXT: sizeof=8, dsize=8, align=4
// CHECK-NEXT: nvsize=8, nvalign=4
+// CHECK: %class.B = type { i32 (...)**, i32 }
+
// CHECK: 0 | class A
// CHECK-NEXT: 0 | class B (primary base)
-// CHECK-NEXT: 0 | (B vtable pointer)
+// CHECK-NEXT: 0 | (B vftable pointer)
// CHECK-NEXT: 4 | int b_field
// CHECK-NEXT: 8 | int a_field
// CHECK-NEXT: 12 | char one
@@ -98,10 +146,10 @@ int main() {
// CHECK: 0 | class C
// CHECK-NEXT: 0 | class D (primary base)
-// CHECK-NEXT: 0 | (D vtable pointer)
+// CHECK-NEXT: 0 | (D vftable pointer)
// CHECK-NEXT: 8 | double a
// CHECK-NEXT: 16 | class B (base)
-// CHECK-NEXT: 16 | (B vtable pointer)
+// CHECK-NEXT: 16 | (B vftable pointer)
// CHECK-NEXT: 20 | int b_field
// CHECK-NEXT: 24 | (C vbtable pointer)
// CHECK-NEXT: 32 | double c1_field
@@ -110,23 +158,28 @@ int main() {
// CHECK-NEXT: 56 | int c4_field
// CHECK-NEXT: 64 | class A (virtual base)
// CHECK-NEXT: 64 | class B (primary base)
-// CHECK-NEXT: 64 | (B vtable pointer)
+// CHECK-NEXT: 64 | (B vftable pointer)
// CHECK-NEXT: 68 | int b_field
// CHECK-NEXT: 72 | int a_field
// CHECK-NEXT: 76 | char one
// CHECK-NEXT: sizeof=80, dsize=80, align=8
-// CHECK-NEXT: nvsize=80, nvalign=8
-
+// CHECK-NEXT: nvsize=64, nvalign=8
+
+// CHECK: %class.A = type { %class.B, i32, i8 }
+
+// CHECK: %class.C = type { %class.D, %class.B, i32*, double, i32, double, i32, [4 x i8], %class.A }
+// CHECK: %class.C.base = type { %class.D, %class.B, i32*, double, i32, double, i32 }
+
// CHECK: 0 | struct BaseStruct
// CHECK-NEXT: 0 | double v0
// CHECK-NEXT: 8 | float v1
// CHECK-NEXT: 16 | class C fg
// CHECK-NEXT: 16 | class D (primary base)
-// CHECK-NEXT: 16 | (D vtable pointer)
+// CHECK-NEXT: 16 | (D vftable pointer)
// CHECK-NEXT: 24 | double a
// CHECK-NEXT: 32 | class B (base)
-// CHECK-NEXT: 32 | (B vtable pointer)
+// CHECK-NEXT: 32 | (B vftable pointer)
// CHECK-NEXT: 36 | int b_field
// CHECK-NEXT: 40 | (C vbtable pointer)
// CHECK-NEXT: 48 | double c1_field
@@ -135,27 +188,29 @@ int main() {
// CHECK-NEXT: 72 | int c4_field
// CHECK-NEXT: 80 | class A (virtual base)
// CHECK-NEXT: 80 | class B (primary base)
-// CHECK-NEXT: 80 | (B vtable pointer)
+// CHECK-NEXT: 80 | (B vftable pointer)
// CHECK-NEXT: 84 | int b_field
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
// CHECK-NEXT: sizeof=80, dsize=80, align=8
-// CHECK-NEXT: nvsize=80, nvalign=8
+// CHECK-NEXT: nvsize=64, nvalign=8
// CHECK: sizeof=96, dsize=96, align=8
// CHECK-NEXT: nvsize=96, nvalign=8
+// CHECK: %struct.BaseStruct = type { double, float, %class.C }
+
// CHECK: 0 | struct DerivedStruct
// CHECK-NEXT: 0 | struct BaseStruct (base)
// CHECK-NEXT: 0 | double v0
// CHECK-NEXT: 8 | float v1
// CHECK-NEXT: 16 | class C fg
// CHECK-NEXT: 16 | class D (primary base)
-// CHECK-NEXT: 16 | (D vtable pointer)
+// CHECK-NEXT: 16 | (D vftable pointer)
// CHECK-NEXT: 24 | double a
// CHECK-NEXT: 32 | class B (base)
-// CHECK-NEXT: 32 | (B vtable pointer)
+// CHECK-NEXT: 32 | (B vftable pointer)
// CHECK-NEXT: 36 | int b_field
// CHECK-NEXT: 40 | (C vbtable pointer)
// CHECK-NEXT: 48 | double c1_field
@@ -164,13 +219,117 @@ int main() {
// CHECK-NEXT: 72 | int c4_field
// CHECK-NEXT: 80 | class A (virtual base)
// CHECK-NEXT: 80 | class B (primary base)
-// CHECK-NEXT: 80 | (B vtable pointer)
+// CHECK-NEXT: 80 | (B vftable pointer)
// CHECK-NEXT: 84 | int b_field
// CHECK-NEXT: 88 | int a_field
// CHECK-NEXT: 92 | char one
// CHECK-NEXT: sizeof=80, dsize=80, align=8
-// CHECK-NEXT: nvsize=80, nvalign=8
+// CHECK-NEXT: nvsize=64, nvalign=8
// CHECK: 96 | int x
// CHECK-NEXT: sizeof=104, dsize=104, align=8
// CHECK-NEXT: nvsize=104, nvalign=8
+
+// CHECK: %struct.DerivedStruct = type { %struct.BaseStruct, i32 }
+
+// CHECK: 0 | struct G
+// CHECK-NEXT: 0 | int g_field
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct H
+// CHECK-NEXT: 0 | struct G (base)
+// CHECK-NEXT: 0 | int g_field
+// CHECK-NEXT: 4 | (H vbtable pointer)
+// CHECK-NEXT: 8 | class D (virtual base)
+// CHECK-NEXT: 8 | (D vftable pointer)
+// CHECK-NEXT: 16 | double a
+// CHECK-NEXT: sizeof=24, dsize=24, align=8
+// CHECK-NEXT: nvsize=8, nvalign=4
+
+// CHECK: %struct.H = type { %struct.G, i32*, %class.D }
+
+// CHECK: 0 | struct I
+// CHECK-NEXT: 0 | (I vftable pointer)
+// CHECK-NEXT: 8 | (I vbtable pointer)
+// CHECK-NEXT: 16 | double q
+// CHECK-NEXT: 24 | class D (virtual base)
+// CHECK-NEXT: 24 | (D vftable pointer)
+// CHECK-NEXT: 32 | double a
+// CHECK-NEXT: sizeof=40, dsize=40, align=8
+// CHECK-NEXT: nvsize=24, nvalign=8
+
+// CHECK: %struct.I = type { i32 (...)**, [4 x i8], i32*, double, %class.D }
+// CHECK: %struct.I.base = type { i32 (...)**, [4 x i8], i32*, double }
+
+// CHECK: 0 | struct L
+// CHECK-NEXT: 0 | int l
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct K
+// CHECK-NEXT: 0 | int k
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct M
+// CHECK-NEXT: 0 | (M vbtable pointer)
+// CHECK-NEXT: 4 | int m
+// CHECK-NEXT: 8 | struct K (virtual base)
+// CHECK-NEXT: 8 | int k
+// CHECK-NEXT: sizeof=12, dsize=12, align=4
+
+//CHECK: %struct.M = type { i32*, i32, %struct.K }
+//CHECK: %struct.M.base = type { i32*, i32 }
+
+// CHECK: 0 | struct N
+// CHECK-NEXT: 4 | struct L (base)
+// CHECK-NEXT: 4 | int l
+// CHECK-NEXT: 8 | struct M (base)
+// CHECK-NEXT: 8 | (M vbtable pointer)
+// CHECK-NEXT: 12 | int m
+// CHECK-NEXT: 0 | (N vftable pointer)
+// CHECK-NEXT: 16 | struct K (virtual base)
+// CHECK-NEXT: 16 | int k
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=16, nvalign=4
+
+//CHECK: %struct.N = type { i32 (...)**, %struct.L, %struct.M.base, %struct.K }
+
+// FIXME: MSVC place struct H at offset 8.
+// CHECK: 0 | struct O
+// CHECK-NEXT: 4 | struct H (base)
+// CHECK-NEXT: 4 | struct G (base)
+// CHECK-NEXT: 4 | int g_field
+// CHECK-NEXT: 8 | (H vbtable pointer)
+// CHECK-NEXT: 12 | struct G (base)
+// CHECK-NEXT: 12 | int g_field
+// CHECK-NEXT: 0 | (O vftable pointer)
+// CHECK-NEXT: 16 | class D (virtual base)
+// CHECK-NEXT: 16 | (D vftable pointer)
+// CHECK-NEXT: 24 | double a
+// CHECK-NEXT: sizeof=32, dsize=32, align=8
+// CHECK-NEXT: nvsize=16, nvalign=4
+
+//CHECK: %struct.O = type { i32 (...)**, %struct.H.base, %struct.G, %class.D }
+//CHECK: %struct.O.base = type { i32 (...)**, %struct.H.base, %struct.G }
+
+// CHECK: 0 | struct P
+// CHECK-NEXT: 0 | struct M (base)
+// CHECK-NEXT: 0 | (M vbtable pointer)
+// CHECK-NEXT: 4 | int m
+// CHECK-NEXT: 8 | int p
+// CHECK-NEXT: 12 | struct K (virtual base)
+// CHECK-NEXT: 12 | int k
+// CHECK-NEXT: 16 | struct L (virtual base)
+// CHECK-NEXT: 16 | int l
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=12, nvalign=4
+
+//CHECK: %struct.P = type { %struct.M.base, i32, %struct.K, %struct.L }
+
+// CHECK: 0 | struct R (empty)
+// CHECK-NEXT: sizeof=1, dsize=0, align=1
+// CHECK-NEXT: nvsize=0, nvalign=1
+
+//CHECK: %struct.R = type { i8 }
diff --git a/test/Sema/no-format-y2k-turnsoff-format.c b/test/Sema/no-format-y2k-turnsoff-format.c
index bd06e50..b206ecd 100644
--- a/test/Sema/no-format-y2k-turnsoff-format.c
+++ b/test/Sema/no-format-y2k-turnsoff-format.c
@@ -4,6 +4,6 @@
void foo(const char *, ...) __attribute__((__format__ (__printf__, 1, 2)));
void bar(unsigned int a) {
- foo("%s", a); // expected-warning {{conversion specifies type 'char *' but the argument has type 'unsigned int'}}
+ foo("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'unsigned int'}}
}
diff --git a/test/Sema/offsetof.c b/test/Sema/offsetof.c
index 5026193..46fb515 100644
--- a/test/Sema/offsetof.c
+++ b/test/Sema/offsetof.c
@@ -65,3 +65,7 @@ int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cann
typedef struct Array { int array[1]; } Array;
int test4 = __builtin_offsetof(Array, array);
+
+int test5() {
+ return __builtin_offsetof(Array, array[*(int*)0]); // expected-warning{{indirection of non-volatile null pointer}} expected-note{{__builtin_trap}}
+}
diff --git a/test/Sema/overloadable-complex.c b/test/Sema/overloadable-complex.c
index 770a972..efdeb8f 100644
--- a/test/Sema/overloadable-complex.c
+++ b/test/Sema/overloadable-complex.c
@@ -31,8 +31,8 @@ char *promote_or_convert(double _Complex) __attribute__((__overloadable__)); //
int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
void test_promote_or_convert(float f, float _Complex fc) {
- char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous; candidates are:}}
- int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous; candidates are:}}
+ char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous}}
+ int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
}
char *promote_or_convert2(float) __attribute__((__overloadable__));
diff --git a/test/Sema/overloadable.c b/test/Sema/overloadable.c
index 8fb41a9..5d39f15 100644
--- a/test/Sema/overloadable.c
+++ b/test/Sema/overloadable.c
@@ -22,7 +22,7 @@ float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \
void test_funcptr(int (*f1)(int, double),
int (*f2)(int, float)) {
float *fp = accept_funcptr(f1);
- accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'; candidates are:}}
+ accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'}}
}
struct X { int x; float y; };
diff --git a/test/Sema/paren-list-expr-type.cpp b/test/Sema/paren-list-expr-type.cpp
deleted file mode 100644
index ad5b7fb..0000000
--- a/test/Sema/paren-list-expr-type.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang -cc1 -ast-dump %s | not grep NULL
-// Makes sure that we don't introduce null types when handling
-// ParenListExpr.
-
-template<typename T> class X { void f() { X x(*this); } };
-
-template<typename T> class Y { Y() : t(1) {} T t; };
-
-template<typename T> class Z { Z() : b(true) {} const bool b; };
-
-template<typename T> class A : public Z<T> { A() : Z<T>() {} };
-
-class C {};
-template<typename T> class D : public C { D(): C() {} };
-
-void f() { (int)(1, 2); }
-
diff --git a/test/Sema/pragma-ms_struct.c b/test/Sema/pragma-ms_struct.c
index b2c2684..d76ee8b 100644
--- a/test/Sema/pragma-ms_struct.c
+++ b/test/Sema/pragma-ms_struct.c
@@ -32,3 +32,24 @@ struct S {
} __attribute__((ms_struct)) t2;
+// rdar://10513599
+#pragma ms_struct on
+
+typedef struct
+{
+void *pv;
+int l;
+} Foo;
+
+typedef struct
+{
+void *pv1;
+Foo foo;
+unsigned short fInited : 1;
+void *pv2;
+} PackOddity;
+
+#pragma ms_struct off
+
+static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
+
diff --git a/test/Sema/pragma-pack-2.c b/test/Sema/pragma-pack-2.c
index 3e6234c..4a4c202 100644
--- a/test/Sema/pragma-pack-2.c
+++ b/test/Sema/pragma-pack-2.c
@@ -19,52 +19,6 @@ struct s1 {
extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1];
#pragma pack(pop)
-// Test scope of definition
-
-#pragma pack(push, 2)
-struct s2_0 {
-#pragma pack(pop)
- char f0;
- int f1;
-};
-extern int a2_0[offsetof(struct s2_0, f1) == 2 ? 1 : -1];
-
-struct s2_1 {
- char f0;
-#pragma pack(push, 2)
- int f1;
-#pragma pack(pop)
-};
-extern int a2_1[offsetof(struct s2_1, f1) == 4 ? 1 : -1];
-
-struct s2_2 {
- char f0;
- int f1;
-#pragma pack(push, 2)
-};
-#pragma pack(pop)
-extern int a2_2[offsetof(struct s2_2, f1) == 4 ? 1 : -1];
-
-struct s2_3 {
- char f0;
-#pragma pack(push, 2)
- struct s2_3_0 {
-#pragma pack(pop)
- int f0;
- } f1;
-};
-extern int a2_3[offsetof(struct s2_3, f1) == 2 ? 1 : -1];
-
-struct s2_4 {
- char f0;
- struct s2_4_0 {
- int f0;
-#pragma pack(push, 2)
- } f1;
-#pragma pack(pop)
-};
-extern int a2_4[offsetof(struct s2_4, f1) == 4 ? 1 : -1];
-
#pragma pack(1)
struct s3_0 {
char f0;
@@ -91,3 +45,15 @@ struct s4_1 {
};
extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
+
+void f() {
+ #pragma pack(push, 2)
+ struct s5_0 {
+ char f0;
+ struct s2_4_0 {
+ int f0;
+ } f1;
+ };
+ #pragma pack(pop)
+ extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
+}
diff --git a/test/Sema/pragma-pack-5.c b/test/Sema/pragma-pack-5.c
new file mode 100644
index 0000000..95bbe1f
--- /dev/null
+++ b/test/Sema/pragma-pack-5.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding
+// <rdar://problem/10494810> and PR9560
+// Check #pragma pack handling with bitfields.
+
+#include <stddef.h>
+#pragma pack(2)
+
+struct s0 {
+ char f1;
+ unsigned f2 : 32;
+ char f3;
+};
+extern int check[sizeof(struct s0) == 6 ? 1 : -1];
+
+struct s1 {
+ char f1;
+ unsigned : 0;
+ char f3;
+};
+extern int check[sizeof(struct s1) == 5 ? 1 : -1];
+
+struct s2 {
+ char f1;
+ unsigned : 0;
+ unsigned f3 : 8;
+ char f4;
+};
+extern int check[sizeof(struct s2) == 6 ? 1 : -1];
+
+struct s3 {
+ char f1;
+ unsigned : 0;
+ unsigned f3 : 16;
+ char f4;
+};
+extern int check[sizeof(struct s3) == 8 ? 1 : -1];
+extern int check[offsetof(struct s3, f4) == 6 ? 1 : -1];
+
+struct s4 {
+ char f1;
+ unsigned f2 : 8;
+ char f3;
+};
+extern int check[sizeof(struct s4) == 4 ? 1 : -1];
+extern int check[offsetof(struct s4, f3) == 2 ? 1 : -1];
diff --git a/test/Sema/pragma-pack-apple.c b/test/Sema/pragma-pack-apple.c
new file mode 100644
index 0000000..5b33c03
--- /dev/null
+++ b/test/Sema/pragma-pack-apple.c
@@ -0,0 +1,10 @@
+// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -fsyntax-only -fapple-pragma-pack %s 2>&1 | FileCheck -check-prefix=CHECK-APPLE %s
+
+#pragma pack(push,1)
+#pragma pack(2)
+#pragma pack()
+#pragma pack(show)
+
+// CHECK: pack(show) == 8
+// CHECK-APPLE: pack(show) == 1
diff --git a/test/Sema/return.c b/test/Sema/return.c
index d9456b6..77bd3f6 100644
--- a/test/Sema/return.c
+++ b/test/Sema/return.c
@@ -1,4 +1,4 @@
-// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wreturn-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+// RUN: %clang %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -Xclang -verify -fblocks -Wno-unreachable-code -Wno-unused-value
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
@@ -255,3 +255,12 @@ int test_enum_cases(enum Cases C) {
case C3: return 4;
}
} // no-warning
+
+// PR12318 - Don't give a may reach end of non-void function warning.
+int test34(int x) {
+ if (x == 1) {
+ return 3;
+ } else if ( x == 2 || 1) {
+ return 5;
+ }
+}
diff --git a/test/Sema/statements.c b/test/Sema/statements.c
index 963b98f..f01ee40 100644
--- a/test/Sema/statements.c
+++ b/test/Sema/statements.c
@@ -36,7 +36,7 @@ bar:
// PR6034
void test11(int bit) {
- switch (bit)
+ switch (bit) // expected-warning {{switch statement has empty body}} expected-note {{put the semicolon on a separate line to silence this warning}}
switch (env->fpscr) // expected-error {{use of undeclared identifier 'env'}}
{
}
diff --git a/test/Sema/static-array.c b/test/Sema/static-array.c
new file mode 100644
index 0000000..2d4b968
--- /dev/null
+++ b/test/Sema/static-array.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}}
+
+void cat(int a[static 3]) {} // expected-note 2 {{callee declares array parameter as static here}}
+
+typedef int i3[static 3];
+void tcat(i3 a) {}
+
+void vat(int i, int a[static i]) {} // expected-note {{callee declares array parameter as static here}}
+
+void f(int *p) {
+ int a[2], b[3], c[4];
+
+ cat0(0);
+
+ cat(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
+ cat(b);
+ cat(c);
+ cat(p);
+
+ tcat(0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ tcat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}}
+ tcat(b);
+ tcat(c);
+ tcat(p);
+
+ vat(1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+ vat(3, b);
+}
diff --git a/test/Sema/static-init.c b/test/Sema/static-init.c
index b4de927..bbf9038 100644
--- a/test/Sema/static-init.c
+++ b/test/Sema/static-init.c
@@ -15,9 +15,10 @@ union bar {
};
struct foo {
- unsigned ptr;
+ short ptr;
};
union bar u[1];
-struct foo x = {(intptr_t) u}; // no-error
+struct foo x = {(intptr_t) u}; // expected-error {{initializer element is not a compile-time constant}}
struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
+intptr_t z = (intptr_t) u; // no-error
diff --git a/test/Sema/switch.c b/test/Sema/switch.c
index 96a6eb6..a7a7f60 100644
--- a/test/Sema/switch.c
+++ b/test/Sema/switch.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default %s
void f (int z) {
while (z) {
default: z--; // expected-error {{statement not in switch}}
@@ -24,7 +24,9 @@ void foo(int X) {
void test3(void) {
// empty switch;
- switch (0); // expected-warning {{no case matching constant switch condition '0'}}
+ switch (0); // expected-warning {{no case matching constant switch condition '0'}} \
+ // expected-warning {{switch statement has empty body}} \
+ // expected-note{{put the semicolon on a separate line to silence this warning}}
}
extern int g();
@@ -50,12 +52,15 @@ void test4()
}
switch (cond) {
- case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}}
+ case g() // expected-error {{expression is not an integer constant expression}}
+ && 0:
break;
}
switch (cond) {
- case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}}
+ case 0 ...
+ g() // expected-error {{expression is not an integer constant expression}}
+ || 1:
break;
}
}
@@ -104,14 +109,14 @@ void test7() {
switch(a) {
case A:
case B:
- case 3: // expected-warning{{case value not in enumerated type ''}}
+ case 3: // expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
switch(a) {
case A:
case B:
- case 3 ... //expected-warning{{case value not in enumerated type ''}}
- 4: //expected-warning{{case value not in enumerated type ''}}
+ case 3 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
switch(a) {
@@ -119,16 +124,16 @@ void test7() {
break;
}
switch(a) {
- case 0 ... 2: //expected-warning{{case value not in enumerated type ''}}
+ case 0 ... 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
switch(a) {
- case 1 ... 3: //expected-warning{{case value not in enumerated type ''}}
+ case 1 ... 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
switch(a) {
- case 0 ... //expected-warning{{case value not in enumerated type ''}}
- 3: //expected-warning{{case value not in enumerated type ''}}
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 3: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
@@ -162,11 +167,11 @@ void test9() {
C = 1
} a;
switch(a) {
- case 0: //expected-warning{{case value not in enumerated type ''}}
+ case 0: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
case 1:
- case 2: //expected-warning{{case value not in enumerated type ''}}
+ case 2: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
case 3:
- case 4: //expected-warning{{case value not in enumerated type ''}}
+ case 4: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
}
@@ -179,14 +184,14 @@ void test10() {
D = 12
} a;
switch(a) {
- case 0 ... //expected-warning{{case value not in enumerated type ''}}
- 1: //expected-warning{{case value not in enumerated type ''}}
+ case 0 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 1: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
case 2 ... 4:
- case 5 ... //expected-warning{{case value not in enumerated type ''}}
- 9: //expected-warning{{case value not in enumerated type ''}}
+ case 5 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 9: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
case 10 ... 12:
- case 13 ... //expected-warning{{case value not in enumerated type ''}}
- 16: //expected-warning{{case value not in enumerated type ''}}
+ case 13 ... //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
+ 16: //expected-warning{{case value not in enumerated type 'enum <anonymous enum}}
break;
}
}
@@ -203,7 +208,7 @@ void test11() {
break;
}
- switch(a) {
+ switch(a) { //expected-warning{{enumeration value 'A' not explicitly handled in switch}}
case B:
case C:
break;
@@ -288,3 +293,30 @@ void test17(int x) {
case 0: return;
}
}
+
+int test18() {
+ enum { A, B } a;
+ switch (a) {
+ case A: return 0;
+ case B: return 1;
+ case 7: return 1; // expected-warning {{case value not in enumerated type}}
+ default: return 2; // expected-warning {{default label in switch which covers all enumeration values}}
+ }
+}
+
+// rdar://110822110
+typedef enum {
+ kOne = 1,
+} Ints;
+
+void rdar110822110(Ints i)
+{
+ switch (i) {
+ case kOne:
+ break;
+ case 2: // expected-warning {{case value not in enumerated type 'Ints'}}
+ break;
+ default: // expected-warning {{default label in switch which covers all enumeration values}}
+ break;
+ }
+}
diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c
index ed27c70..9ec88c5 100644
--- a/test/Sema/thread-specifier.c
+++ b/test/Sema/thread-specifier.c
@@ -15,7 +15,7 @@ int f(__thread int t7) { // expected-error {{'__thread' is only allowed on varia
__thread register int t13; // expected-error {{'__thread' variables must have global storage}}
}
__thread typedef int t14; // expected-error {{'__thread' is only allowed on variable declarations}}
-__thread int t15; // expected-note {{[previous definition is here}}
+__thread int t15; // expected-note {{previous definition is here}}
int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}}
-int t16; // expected-note {{[previous definition is here}}
+int t16; // expected-note {{previous definition is here}}
__thread int t16; // expected-error {{thread-local declaration of 't16' follows non-thread-local declaration}}
diff --git a/test/Sema/types.c b/test/Sema/types.c
index 332b525..3bec83e 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -19,7 +19,21 @@ int b() {
int __int128_t;
int __uint128_t;
}
+// __int128 is a keyword
+int c() {
+ __int128 i;
+ unsigned __int128 j;
+ long unsigned __int128 k; // expected-error {{'long __int128' is invalid}}
+ int __int128; // expected-error {{cannot combine with previous}} expected-warning {{does not declare anything}}
+}
+// __int128_t is __int128; __uint128_t is unsigned __int128.
+typedef __int128 check_int_128; // expected-note {{here}}
+typedef __int128_t check_int_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_int_128; // expected-error {{different types ('int' vs '__int128_t' (aka '__int128'))}}
+typedef unsigned __int128 check_uint_128; // expected-note {{here}}
+typedef __uint128_t check_uint_128; // expected-note {{here}} expected-warning {{redefinition}}
+typedef int check_uint_128; // expected-error {{different types ('int' vs '__uint128_t' (aka 'unsigned __int128'))}}
// Array type merging should convert array size to whatever matches the target
// pointer size.
diff --git a/test/Sema/ucn-cstring.c b/test/Sema/ucn-cstring.c
index ac1d37f..5d3e85d 100644
--- a/test/Sema/ucn-cstring.c
+++ b/test/Sema/ucn-cstring.c
@@ -11,7 +11,6 @@ int main(void) {
printf("%s\n", "\U"); // expected-error{{\u used with no following hex digits}}
printf("%s\n", "\U00"); // expected-error{{incomplete universal character name}}
printf("%s\n", "\U0001"); // expected-error{{incomplete universal character name}}
- printf("%s\n", "\u0001"); // expected-error{{invalid universal character}}
+ printf("%s\n", "\u0001"); // expected-error{{universal character name refers to a control character}}
return 0;
}
-
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 49af4f3..d62186d 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -44,6 +44,15 @@ int test7(int y) {
return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
}
+int test7b(int y) {
+ int x = x; // expected-note{{variable 'x' is declared here}}
+ if (y)
+ x = 1;
+ // Warn with "may be uninitialized" here (not "is uninitialized"), since the
+ // self-initialization is intended to suppress a -Wuninitialized warning.
+ return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
+}
+
int test8(int y) {
int x;
if (y)
@@ -415,4 +424,3 @@ void rdar9432305(float *P) {
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
-
diff --git a/test/Sema/unused-expr-system-header.c b/test/Sema/unused-expr-system-header.c
new file mode 100644
index 0000000..dcc8918
--- /dev/null
+++ b/test/Sema/unused-expr-system-header.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify %s
+#include <unused-expr-system-header.h>
+void f(int i1, int i2) {
+ POSSIBLY_BAD_MACRO(5);
+ STATEMENT_EXPR_MACRO(5);
+ COMMA_MACRO_1(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_2(i1 == i2, f(i1, i2));
+ COMMA_MACRO_3(i1 == i2, f(i1, i2)); // expected-warning {{expression result unused}}
+ COMMA_MACRO_4(i1 == i2, f(i1, i2));
+}
diff --git a/test/Sema/variadic-incomplete-arg-type.c b/test/Sema/variadic-incomplete-arg-type.c
new file mode 100644
index 0000000..2b5dd1a
--- /dev/null
+++ b/test/Sema/variadic-incomplete-arg-type.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+// rdar://10961370
+
+typedef struct __CFError * CFErrorRef; // expected-note {{forward declaration of 'struct __CFError'}}
+
+void junk(int, ...);
+
+int main()
+{
+ CFErrorRef error;
+ junk(1, *error, (void)0); // expected-error {{argument type 'struct __CFError' is incomplete}} \
+ // expected-error {{argument type 'void' is incomplete}}
+}
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index 8b0dc92..f01eb45 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversions
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
typedef unsigned int v2u __attribute__ ((vector_size (8)));
typedef signed int v2s __attribute__ ((vector_size (8)));
typedef signed int v1s __attribute__ ((vector_size (4)));
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index a717e86..f1cf013 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversions
+// RUN: %clang_cc1 -fsyntax-only %s -verify -Wvector-conversion
typedef long long t1 __attribute__ ((vector_size (8)));
typedef char t2 __attribute__ ((vector_size (16)));
diff --git a/test/Sema/vector-ops.c b/test/Sema/vector-ops.c
index ca39737..3ab75d0 100644
--- a/test/Sema/vector-ops.c
+++ b/test/Sema/vector-ops.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversions
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
typedef unsigned int v2u __attribute__ ((vector_size (8)));
typedef int v2s __attribute__ ((vector_size (8)));
typedef float v2f __attribute__ ((vector_size(8)));
@@ -13,8 +13,9 @@ void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
(void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}}
// Comparison operators
- v2ua = (v2ua==v2sa);
-
+ v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}}
+ v2sa = (v2ua==v2sa);
+
// Arrays
int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u'}}
int array2[17];
diff --git a/test/Sema/vla-2.c b/test/Sema/vla-2.c
new file mode 100644
index 0000000..819cab9
--- /dev/null
+++ b/test/Sema/vla-2.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
+// Check that we don't crash trying to emit warnings in a potentially-evaluated
+// sizeof or typeof. (This test needs to be in a separate file because we use
+// a different codepath when we have already emitted an error.)
+
+int PotentiallyEvaluatedSizeofWarn(int n) {
+ return (int)sizeof *(0 << 32,(int(*)[n])0); // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
+}
+
+void PotentiallyEvaluatedTypeofWarn(int n) {
+ __typeof(*(0 << 32,(int(*)[n])0)) x; // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
+ (void)x;
+}
+
+void PotentiallyEvaluatedArrayBoundWarn(int n) {
+ (void)*(int(*)[(0 << 32,n)])0; // FIXME: We should warn here.
+}
diff --git a/test/Sema/vla.c b/test/Sema/vla.c
index fd7a6bf..4fd6361 100644
--- a/test/Sema/vla.c
+++ b/test/Sema/vla.c
@@ -60,3 +60,8 @@ void pr5185(int a[*]);
void pr5185(int a[*]) // expected-error {{variable length array must be bound in function definition}}
{
}
+
+// Make sure this isn't treated as an error
+int TransformBug(int a) {
+ return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
+}
diff --git a/test/Sema/warn-cast-align.c b/test/Sema/warn-cast-align.c
index 93352c2..9d64699 100644
--- a/test/Sema/warn-cast-align.c
+++ b/test/Sema/warn-cast-align.c
@@ -28,7 +28,7 @@ void test1(void *P) {
}
// Aligned struct.
-__attribute__((aligned(16))) struct A {
+struct __attribute__((aligned(16))) A {
char buffer[16];
};
void test2(char *P) {
diff --git a/test/Sema/warn-strncat-size.c b/test/Sema/warn-strncat-size.c
new file mode 100644
index 0000000..7157edf
--- /dev/null
+++ b/test/Sema/warn-strncat-size.c
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -Wstrncat-size -verify -fsyntax-only %s
+// RUN: %clang_cc1 -DUSE_BUILTINS -Wstrncat-size -verify -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -Wstrncat-size -fixit -x c %s
+// RUN: %clang_cc1 -DUSE_BUILTINS -fsyntax-only -Wstrncat-size -fixit -x c %s
+
+typedef __SIZE_TYPE__ size_t;
+size_t strlen (const char *s);
+
+#ifdef USE_BUILTINS
+# define BUILTIN(f) __builtin_ ## f
+#else
+# define BUILTIN(f) f
+#endif
+
+#define strncat BUILTIN(strncat)
+char *strncat(char *restrict s1, const char *restrict s2, size_t n);
+
+struct {
+ char f1[100];
+ char f2[100][3];
+} s4, **s5;
+
+char s1[100];
+char s2[200];
+int x;
+
+void test(char *src) {
+ char dest[10];
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest) - 1); // no-warning
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // no-warning - the code might assume that dest is empty
+
+ strncat(dest, src, sizeof(src)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, src, sizeof(src) - 1); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+
+ strncat((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+ strncat(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
+ strncat(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+}
+
+// Don't issue FIXIT for flexible arrays.
+struct S {
+ int y;
+ char x[];
+};
+
+void flexible_arrays(struct S *s) {
+ char str[] = "hi";
+ strncat(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
+}
+
+// Don't issue FIXIT for destinations of size 1.
+void size_1() {
+ char z[1];
+ char str[] = "hi";
+
+ strncat(z, str, sizeof(z)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}}
+}
+
+// Support VLAs.
+void vlas(int size) {
+ char z[size];
+ char str[] = "hi";
+
+ strncat(z, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
+}
diff --git a/test/Sema/warn-unreachable.c b/test/Sema/warn-unreachable.c
index 8db36b7..636513f 100644
--- a/test/Sema/warn-unreachable.c
+++ b/test/Sema/warn-unreachable.c
@@ -1,4 +1,4 @@
-// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
int halt() __attribute__((noreturn));
int live();
@@ -125,4 +125,10 @@ void test_assert() {
return; // no-warning
}
+// Test case for PR 9774. Tests that dead code in macros aren't warned about.
+#define MY_MAX(a,b) ((a) >= (b) ? (a) : (b))
+void PR9774(int *s) {
+ for (int i = 0; i < MY_MAX(2, 3); i++) // no-warning
+ s[i] = 0;
+}
diff --git a/test/Sema/weak-import-on-enum.c b/test/Sema/weak-import-on-enum.c
new file mode 100644
index 0000000..3a2c0e5
--- /dev/null
+++ b/test/Sema/weak-import-on-enum.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// rdar://10277579
+
+enum __attribute__((deprecated)) __attribute__((weak_import)) A {
+ a0
+};
+
diff --git a/test/Sema/x86-builtin-palignr.c b/test/Sema/x86-builtin-palignr.c
index 6e1303c..6f4b90d 100644
--- a/test/Sema/x86-builtin-palignr.c
+++ b/test/Sema/x86-builtin-palignr.c
@@ -4,7 +4,9 @@
#include <tmmintrin.h>
__m64 test1(__m64 a, __m64 b, int c) {
- return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}}
+ // FIXME: The "incompatible result type" error is due to pr10112 and should
+ // be removed when that is fixed.
+ return _mm_alignr_pi8(a, b, c); // expected-error {{argument to '__builtin_ia32_palignr' must be a constant integer}} expected-error {{incompatible result type}}
}
int test2(int N) {
diff --git a/test/SemaCXX/Inputs/array-bounds-system-header.h b/test/SemaCXX/Inputs/array-bounds-system-header.h
new file mode 100644
index 0000000..07cde80
--- /dev/null
+++ b/test/SemaCXX/Inputs/array-bounds-system-header.h
@@ -0,0 +1,11 @@
+// "System header" for testing that -Warray-bounds is properly suppressed in
+// certain cases.
+
+#define BAD_MACRO_1 \
+ int i[3]; \
+ i[3] = 5
+#define BAD_MACRO_2(_b, _i) \
+ (_b)[(_i)] = 5
+#define QUESTIONABLE_MACRO(_a) \
+ sizeof(_a) > 3 ? (_a)[3] = 5 : 5
+#define NOP(x) (x)
diff --git a/test/SemaCXX/Inputs/warn-new-overaligned-3.h b/test/SemaCXX/Inputs/warn-new-overaligned-3.h
new file mode 100644
index 0000000..d2bd4d5
--- /dev/null
+++ b/test/SemaCXX/Inputs/warn-new-overaligned-3.h
@@ -0,0 +1,19 @@
+#pragma GCC system_header
+
+// This header file pretends to be <new> from the system library, for the
+// purpose of the over-aligned warnings test.
+
+void* operator new(unsigned long) {
+ return 0;
+}
+void* operator new[](unsigned long) {
+ return 0;
+}
+
+void* operator new(unsigned long, void *) {
+ return 0;
+}
+
+void* operator new[](unsigned long, void *) {
+ return 0;
+}
diff --git a/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp b/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
new file mode 100644
index 0000000..0c7d354
--- /dev/null
+++ b/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++98 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
+
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+ENUM *var = 0;
+ENUM var2 = (ENUM)3;
+enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp
index dfc47d6..3634fa3 100644
--- a/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
@@ -23,7 +23,7 @@ namespace ms_protected_scope {
int jump_over_variable_init(bool b) {
if (b)
- goto foo; // expected-warning {{illegal goto into protected scope}}
+ goto foo; // expected-warning {{goto into protected scope}}
C c; // expected-note {{jump bypasses variable initialization}}
foo:
return 1;
@@ -35,7 +35,7 @@ struct Y {
void jump_over_var_with_dtor() {
goto end; // expected-warning{{goto into protected scope}}
- Y y; // expected-note {{jump bypasses variable initialization}}
+ Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
end:
;
}
@@ -51,7 +51,7 @@ void jump_over_var_with_dtor() {
void exception_jump() {
- goto l2; // expected-error {{illegal goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
try { // expected-note {{jump bypasses initialization of try block}}
l2: ;
} catch(int) {
@@ -68,91 +68,109 @@ int jump_over_indirect_goto() {
}
+namespace PR11826 {
+ struct pair {
+ pair(int v) { }
+ void operator=(pair&& rhs) { }
+ };
+ void f() {
+ pair p0(3);
+ pair p = p0;
+ }
+}
+
+namespace PR11826_for_symmetry {
+ struct pair {
+ pair(int v) { }
+ pair(pair&& rhs) { }
+ };
+ void f() {
+ pair p0(3);
+ pair p(4);
+ p = p0;
+ }
+}
+
+namespace ms_using_declaration_bug {
+
+class A {
+public:
+ int f();
+};
+
+class B : public A {
+private:
+ using A::f;
+};
+
+class C : public B {
+private:
+ using B::f; // expected-warning {{using declaration referring to inaccessible member 'ms_using_declaration_bug::B::f' (which refers to accessible member 'ms_using_declaration_bug::A::f') is a Microsoft compatibility extension}}
+};
+
+}
+
+
+namespace MissingTypename {
+
+template<class T> class A {
+public:
+ typedef int TYPE;
+};
+
+template<class T> class B {
+public:
+ typedef int TYPE;
+};
-namespace ms_using_declaration_bug {
-
-class A {
-public:
- int f();
-};
-
-class B : public A {
-private:
- using A::f;
-};
-
-class C : public B {
-private:
- using B::f; // expected-warning {{using declaration refers to inaccessible member 'ms_using_declaration_bug::B::f', which refers to accessible member 'ms_using_declaration_bug::A::f', accepted for Microsoft compatibility}}
-};
-
-}
-
-
-namespace MissingTypename {
-
-template<class T> class A {
-public:
- typedef int TYPE;
-};
-
-template<class T> class B {
-public:
- typedef int TYPE;
-};
-
-
-template<class T, class U>
-class C : private A<T>, public B<U> {
-public:
- typedef A<T> Base1;
- typedef B<U> Base2;
- typedef A<U> Base3;
-
- A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
- Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
-
- B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
- Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
-
- A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
- Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
- };
-
-class D {
-public:
- typedef int Type;
-};
-
-template <class T>
-void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
-{
- const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
-}
-
-template void function_missing_typename<D>(const D::Type param);
-
-}
-
-
-
-namespace lookup_dependent_bases_id_expr {
-
-template<class T> class A {
-public:
- int var;
-};
-
-
-template<class T>
-class B : public A<T> {
-public:
- void f() {
- var = 3;
- }
-};
-
-template class B<int>;
-
-} \ No newline at end of file
+template<class T, class U>
+class C : private A<T>, public B<U> {
+public:
+ typedef A<T> Base1;
+ typedef B<U> Base2;
+ typedef A<U> Base3;
+
+ A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
+ Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
+ };
+
+class D {
+public:
+ typedef int Type;
+};
+
+template <class T>
+void function_missing_typename(const T::Type param)// expected-warning {{missing 'typename' prior to dependent type name}}
+{
+ const T::Type var = 2; // expected-warning {{missing 'typename' prior to dependent type name}}
+}
+
+template void function_missing_typename<D>(const D::Type param);
+
+}
+
+enum ENUM2 {
+ ENUM2_a = (enum ENUM2) 4,
+ ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+ ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
+};
+
+
+namespace PR11791 {
+ template<class _Ty>
+ void del(_Ty *_Ptr) {
+ _Ptr->~_Ty(); // expected-warning {{pseudo-destructors on type void are a Microsoft extension}}
+ }
+
+ void f() {
+ int* a = 0;
+ del((void*)a); // expected-note {{in instantiation of function template specialization}}
+ }
+}
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index 63e058b..0b72cd3 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -92,18 +92,8 @@ void m1() {
h1(&M::subtractP);
}
-//MSVC allows forward enum declaration
-enum ENUM; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-ENUM *var = 0;
-ENUM var2 = (ENUM)3;
-enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types are a Microsoft extension}}
-enum ENUM2 {
- ENUM2_a = (enum ENUM2) 4,
- ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
- ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
-};
void f(long long);
@@ -203,3 +193,13 @@ void f()
}
+struct PR11150 {
+ class X {
+ virtual void f() = 0;
+ };
+
+ int array[__is_abstract(X)? 1 : -1];
+};
+
+void f() { int __except = 0; }
+
diff --git a/test/SemaCXX/PR10177.cpp b/test/SemaCXX/PR10177.cpp
new file mode 100644
index 0000000..8d745de
--- /dev/null
+++ b/test/SemaCXX/PR10177.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+template<typename T, typename U, U> using alias_ref = T;
+template<typename T, typename U, U> void func_ref() {}
+template<typename T, typename U, U> struct class_ref {};
+
+template<int N>
+struct U {
+ static int a;
+};
+
+template<int N> struct S; // expected-note 2{{here}}
+
+template<int N>
+int U<N>::a = S<N>::kError; // expected-error 2{{undefined}}
+
+template<typename T>
+void f() {
+ // FIXME: The standard suggests that U<0>::a is odr-used by this expression,
+ // but it's not entirely clear that's the right behaviour.
+ (void)alias_ref<int, int&, U<0>::a>();
+ (void)func_ref<int, int&, U<1>::a>(); // expected-note {{here}}
+ (void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}}
+};
+
+int main() {
+ f<int>(); // expected-note 2{{here}}
+}
+
+namespace N {
+ template<typename T> struct S { static int n; };
+ template<typename T> int S<T>::n = 5;
+ void g(int*);
+ template<typename T> int f() {
+ int k[S<T>::n];
+ g(k);
+ return k[3];
+ }
+ int j = f<int>();
+}
diff --git a/test/SemaCXX/PR10447.cpp b/test/SemaCXX/PR10447.cpp
new file mode 100644
index 0000000..08644ad
--- /dev/null
+++ b/test/SemaCXX/PR10447.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR12223
+namespace test1 {
+ namespace N {
+ extern "C" void f(struct S*);
+ void g(S*);
+ }
+ namespace N {
+ void f(struct S *s) {
+ g(s);
+ }
+ }
+}
+
+// PR10447
+namespace test2 {
+ extern "C" {
+ void f(struct Bar*) { }
+ test2::Bar *ptr;
+ }
+}
diff --git a/test/SemaCXX/PR11358.cpp b/test/SemaCXX/PR11358.cpp
new file mode 100644
index 0000000..9c49227
--- /dev/null
+++ b/test/SemaCXX/PR11358.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 %s -verify
+// PR11358
+
+namespace test1 {
+ template<typename T>
+ struct container {
+ class iterator {};
+ iterator begin() { return iterator(); }
+ };
+
+ template<typename T>
+ struct Test {
+ typedef container<T> Container;
+ void test() {
+ Container::iterator i = c.begin(); // expected-error{{missing 'typename'}}
+ }
+ Container c;
+ };
+}
+
+namespace test2 {
+ template <typename Key, typename Value>
+ class hash_map {
+ class const_iterator { void operator++(); };
+ const_iterator begin() const;
+ const_iterator end() const;
+ };
+
+ template <typename KeyType, typename ValueType>
+ void MapTest(hash_map<KeyType, ValueType> map) {
+ for (hash_map<KeyType, ValueType>::const_iterator it = map.begin(); // expected-error{{missing 'typename'}}
+ it != map.end(); it++) {
+ }
+ }
+}
+
+namespace test3 {
+ template<typename T>
+ struct container {
+ class iterator {};
+ };
+
+ template<typename T>
+ struct Test {
+ typedef container<T> Container;
+ void test() {
+ Container::iterator const i; // expected-error{{missing 'typename'}}
+ }
+ Container c;
+ };
+}
diff --git a/test/SemaCXX/PR12481.cpp b/test/SemaCXX/PR12481.cpp
new file mode 100644
index 0000000..9487e4d
--- /dev/null
+++ b/test/SemaCXX/PR12481.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -x c++ -fsyntax-only %s
+
+class C1 { };
+class C2 { };
+template<class TrieData> struct BinaryTrie {
+ ~BinaryTrie() {
+ (void)(({
+ static int x = 5;
+ }
+ ));
+ }
+};
+class FooTable {
+ BinaryTrie<C1> c1_trie_;
+ BinaryTrie<C2> c2_trie_;
+};
+FooTable* foo = new FooTable;
diff --git a/test/SemaCXX/PR8385.cpp b/test/SemaCXX/PR8385.cpp
new file mode 100644
index 0000000..77a117a
--- /dev/null
+++ b/test/SemaCXX/PR8385.cpp
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -fsyntax-only %s
+
+// don't crash on this, but don't constrain our diagnostics here as they're
+// currently rather poor (we even accept things like "template struct {}").
+// Other, explicit tests, should verify the relevant behavior of template
+// instantiation.
+struct{template struct{
diff --git a/test/SemaCXX/PR9460.cpp b/test/SemaCXX/PR9460.cpp
index 2cc435e..0dd8446 100644
--- a/test/SemaCXX/PR9460.cpp
+++ b/test/SemaCXX/PR9460.cpp
@@ -8,11 +8,11 @@ struct basic_string{
basic_string(aT*);
};
-struct runtime_error{ // expected-note {{candidate constructor}}
- runtime_error( // expected-note {{candidate constructor}}
+struct runtime_error{
+ runtime_error(
basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
a(){ // expected-error {{requires a type specifier}}
- runtime_error(0); // expected-error {{no matching conversion}}
+ runtime_error(0);
}
}
);
diff --git a/test/SemaCXX/PR9461.cpp b/test/SemaCXX/PR9461.cpp
index ce17931..beed348 100644
--- a/test/SemaCXX/PR9461.cpp
+++ b/test/SemaCXX/PR9461.cpp
@@ -26,7 +26,7 @@ basic_string<_CharT,_Traits,_Alloc>::basic_string(const _CharT*,const _Alloc&)
:us(_S_construct)
{string a;}
-struct runtime_error{runtime_error(string);}; // expected-note 2 {{candidate constructor}}
+struct runtime_error{runtime_error(string);};
-struct system_error:runtime_error{ // expected-note {{to match}} expected-note {{specified here}}
-system_error():time_error("" // expected-error 4 {{expected}} expected-error {{initializer}} expected-note {{to match}} expected-error {{no matching constructor}}
+struct system_error:runtime_error{ // expected-note {{to match}}
+system_error():time_error("" // expected-error 3 {{expected}} expected-note {{to match}}
diff --git a/test/SemaCXX/PR9572.cpp b/test/SemaCXX/PR9572.cpp
index b0bbfa6..b475b57 100644
--- a/test/SemaCXX/PR9572.cpp
+++ b/test/SemaCXX/PR9572.cpp
@@ -3,7 +3,7 @@ class Base {
virtual ~Base(); // expected-note {{implicitly declared private here}}
};
struct Foo : public Base { // expected-error {{base class 'Base' has private destructor}}
- const int kBlah = 3; // expected-warning {{accepted as a C++11 extension}}
+ const int kBlah = 3; // expected-warning {{is a C++11 extension}}
Foo();
};
struct Bar : public Foo {
diff --git a/test/SemaCXX/__null.cpp b/test/SemaCXX/__null.cpp
index 1989a45..56e59c0 100644
--- a/test/SemaCXX/__null.cpp
+++ b/test/SemaCXX/__null.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -fsyntax-only -verify
-// RUN: %clang_cc1 -triple i686-unknown-unknown %s -fsyntax-only -verify
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
+// RUN: %clang_cc1 -triple i686-unknown-unknown %s -Wno-null-conversion -fsyntax-only -verify
void f() {
int* i = __null;
diff --git a/test/SemaCXX/access.cpp b/test/SemaCXX/access.cpp
index 6115ff6..18ad301 100644
--- a/test/SemaCXX/access.cpp
+++ b/test/SemaCXX/access.cpp
@@ -28,7 +28,7 @@ namespace test1 {
private:
class X; // expected-note {{previously declared 'private' here}}
public:
- class X; // expected-error {{ 'X' redeclared with 'public' access}}
+ class X; // expected-error {{'X' redeclared with 'public' access}}
class X {};
};
}
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index a36fd58..096f748 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -13,9 +13,9 @@ int (*pfe)(...) = &f; // expected-error{{address of overloaded function 'f' d
int (&rfi)(int) = f; // selects f(int)
int (&rfd)(double) = f; // selects f(double)
-void g(int (*fp)(int)); // expected-note{{note: candidate function}}
+void g(int (*fp)(int)); // expected-note{{candidate function}}
void g(int (*fp)(float));
-void g(int (*fp)(double)); // expected-note{{note: candidate function}}
+void g(int (*fp)(double)); // expected-note{{candidate function}}
int g1(int);
int g1(char);
@@ -29,7 +29,7 @@ int g3(char);
void g_test() {
g(g1);
- g(g2); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+ g(g2); // expected-error{{call to 'g' is ambiguous}}
g(g3);
}
@@ -57,8 +57,7 @@ struct B
struct C {
C &getC() {
- // FIXME: this error message is terrible
- return makeAC; // expected-error{{cannot bind to a value of unrelated type}}
+ return makeAC; // expected-error{{reference to non-static member function must be called}}
}
C &makeAC();
@@ -99,8 +98,10 @@ namespace PR7971 {
}
namespace PR8033 {
- template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note 2{{candidate function [with T1 = const int, T2 = int]}}
- template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note 2{{candidate function [with T1 = int, T2 = const int]}}
+ template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}} \
+ // expected-note{{candidate function}}
+ template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}} \
+ // expected-note{{candidate function}}
int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
// expected-error{{address of overloaded function 'f' is ambiguous}}
@@ -146,3 +147,64 @@ namespace PR7425 {
bar2();
}
}
+
+namespace test1 {
+ void fun(int x) {}
+
+ void parameter_number() {
+ void (*ptr1)(int, int) = &fun; // expected-error {{cannot initialize a variable of type 'void (*)(int, int)' with an rvalue of type 'void (*)(int)': different number of parameters (2 vs 1)}}
+ void (*ptr2)(int, int);
+ ptr2 = &fun; // expected-error {{assigning to 'void (*)(int, int)' from incompatible type 'void (*)(int)': different number of parameters (2 vs 1)}}
+ }
+
+ void parameter_mismatch() {
+ void (*ptr1)(double) = &fun; // expected-error {{cannot initialize a variable of type 'void (*)(double)' with an rvalue of type 'void (*)(int)': type mismatch at 1st parameter ('double' vs 'int')}}
+ void (*ptr2)(double);
+ ptr2 = &fun; // expected-error {{assigning to 'void (*)(double)' from incompatible type 'void (*)(int)': type mismatch at 1st parameter ('double' vs 'int')}}
+ }
+
+ void return_type_test() {
+ int (*ptr1)(int) = &fun; // expected-error {{cannot initialize a variable of type 'int (*)(int)' with an rvalue of type 'void (*)(int)': different return type ('int' vs 'void')}}
+ int (*ptr2)(int);
+ ptr2 = &fun; // expected-error {{assigning to 'int (*)(int)' from incompatible type 'void (*)(int)': different return type ('int' vs 'void')}}
+ }
+
+ int foo(double x, double y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ int foo(int x, int y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ int foo(double x) {return 0;} // expected-note {{candidate function has type mismatch at 1st parameter (expected 'int' but has 'double')}}
+ double foo(float x, float y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ double foo(int x, float y) {return 0;} // expected-note {{candidate function has different number of parameters (expected 1 but has 2)}}
+ double foo(float x) {return 0;} // expected-note {{candidate function has type mismatch at 1st parameter (expected 'int' but has 'float')}}
+ double foo(int x) {return 0;} // expected-note {{candidate function has different return type ('int' expected but has 'double')}}
+
+ int (*ptr)(int) = &foo; // expected-error {{address of overloaded function 'foo' does not match required type 'int (int)'}}
+
+ struct Qualifiers {
+ void N() {};
+ void C() const {};
+ void V() volatile {};
+ void R() __restrict {};
+ void CV() const volatile {};
+ void CR() const __restrict {};
+ void VR() volatile __restrict {};
+ void CVR() const volatile __restrict {};
+ };
+
+
+ void QualifierTest() {
+ void (Qualifiers::*X)();
+ X = &Qualifiers::C; // expected-error {{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const': different qualifiers (none vs const)}}
+ X = &Qualifiers::V; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() volatile': different qualifiers (none vs volatile)}}
+ X = &Qualifiers::R; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() restrict': different qualifiers (none vs restrict)}}
+ X = &Qualifiers::CV; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const volatile': different qualifiers (none vs const and volatile)}}
+ X = &Qualifiers::CR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const restrict': different qualifiers (none vs const and restrict)}}
+ X = &Qualifiers::VR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() volatile restrict': different qualifiers (none vs volatile and restrict)}}
+ X = &Qualifiers::CVR; // expected-error{{assigning to 'void (test1::Qualifiers::*)()' from incompatible type 'void (test1::Qualifiers::*)() const volatile restrict': different qualifiers (none vs const, volatile, and restrict)}}
+ }
+
+ struct Dummy {
+ void N() {};
+ };
+
+ void (Qualifiers::*X)() = &Dummy::N; // expected-error{{cannot initialize a variable of type 'void (test1::Qualifiers::*)()' with an rvalue of type 'void (test1::Dummy::*)()': different classes ('test1::Qualifiers' vs 'test1::Dummy')}}
+}
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp
index 3c0e448..885bf70 100644
--- a/test/SemaCXX/aggregate-initialization.cpp
+++ b/test/SemaCXX/aggregate-initialization.cpp
@@ -1,33 +1,33 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// Verify that we can't initialize non-aggregates with an initializer
-// list.
+// Verify that using an initializer list for a non-aggregate looks for
+// constructors..
// Note that due to a (likely) standard bug, this is technically an aggregate,
// but we do not treat it as one.
-struct NonAggr1 {
- NonAggr1(int) { }
+struct NonAggr1 { // expected-note 2 {{candidate constructor}}
+ NonAggr1(int, int) { } // expected-note {{candidate constructor}}
int m;
};
struct Base { };
-struct NonAggr2 : public Base {
+struct NonAggr2 : public Base { // expected-note 3 {{candidate constructor}}
int m;
};
-class NonAggr3 {
+class NonAggr3 { // expected-note 3 {{candidate constructor}}
int m;
};
-struct NonAggr4 {
+struct NonAggr4 { // expected-note 3 {{candidate constructor}}
int m;
virtual void f();
};
-NonAggr1 na1 = { 17 }; // expected-error{{non-aggregate type 'NonAggr1' cannot be initialized with an initializer list}}
-NonAggr2 na2 = { 17 }; // expected-error{{non-aggregate type 'NonAggr2' cannot be initialized with an initializer list}}
-NonAggr3 na3 = { 17 }; // expected-error{{non-aggregate type 'NonAggr3' cannot be initialized with an initializer list}}
-NonAggr4 na4 = { 17 }; // expected-error{{non-aggregate type 'NonAggr4' cannot be initialized with an initializer list}}
+NonAggr1 na1 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr1'}}
+NonAggr2 na2 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr2'}}
+NonAggr3 na3 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr3'}}
+NonAggr4 na4 = { 17 }; // expected-error{{no matching constructor for initialization of 'NonAggr4'}}
// PR5817
typedef int type[][2];
diff --git a/test/SemaCXX/alias-template.cpp b/test/SemaCXX/alias-template.cpp
index 6cff420..484dd33 100644
--- a/test/SemaCXX/alias-template.cpp
+++ b/test/SemaCXX/alias-template.cpp
@@ -12,12 +12,12 @@ namespace IllegalTypeIds {
template<typename U> using C = virtual void(int n); // expected-error {{type name does not allow function specifier}}
template<typename U> using D = explicit void(int n); // expected-error {{type name does not allow function specifier}}
template<typename U> using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}}
- // FIXME: this is illegal; we incorrectly accept it for typedefs too.
- template<typename U> using F = void(*)(int n) &&; // expected-err
+ template<typename U> using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}}
template<typename U> using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}}
+ template<typename U> using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}}
- template<typename U> using H = void(int n); // ok
- template<typename U> using I = void(int n) &&; // ok
+ template<typename U> using Y = void(int n); // ok
+ template<typename U> using Z = void(int n) &&; // ok
}
namespace IllegalSyntax {
diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp
index 504eb1b..39421b7 100644
--- a/test/SemaCXX/altivec.cpp
+++ b/test/SemaCXX/altivec.cpp
@@ -66,3 +66,13 @@ void test2()
(++vi)[1]=1;
template_f(vi);
}
+
+namespace LValueToRValueConversions {
+ struct Struct {
+ float f();
+ int n();
+ };
+
+ vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}}
+ vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}}
+}
diff --git a/test/SemaCXX/anonymous-struct.cpp b/test/SemaCXX/anonymous-struct.cpp
index dfa284a..19a88d7 100644
--- a/test/SemaCXX/anonymous-struct.cpp
+++ b/test/SemaCXX/anonymous-struct.cpp
@@ -4,8 +4,13 @@ struct S {
S(); // expected-note {{because type 'S' has a user-declared constructor}}
};
+struct { // expected-error {{anonymous structs and classes must be class members}}
+};
+
struct E {
struct {
S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
};
+ static struct {
+ };
};
diff --git a/test/SemaCXX/array-bounds-ptr-arith.cpp b/test/SemaCXX/array-bounds-ptr-arith.cpp
index ce1ace6..16e2567 100644
--- a/test/SemaCXX/array-bounds-ptr-arith.cpp
+++ b/test/SemaCXX/array-bounds-ptr-arith.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify -Wno-string-plus-int -Warray-bounds-pointer-arithmetic %s
void swallow (const char *x) { (void)x; }
void test_pointer_arithmetic(int n) {
diff --git a/test/SemaCXX/array-bounds-system-header.cpp b/test/SemaCXX/array-bounds-system-header.cpp
new file mode 100644
index 0000000..34de5b5
--- /dev/null
+++ b/test/SemaCXX/array-bounds-system-header.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -verify %s
+#include <array-bounds-system-header.h>
+void test_system_header_macro() {
+ BAD_MACRO_1; // no-warning
+ char a[3]; // expected-note 2 {{declared here}}
+ BAD_MACRO_2(a, 3); // expected-warning {{array index 3}}
+ QUESTIONABLE_MACRO(a);
+ NOP(a[3] = 5); // expected-warning {{array index 3}}
+}
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index 555ac33..57a9e3d 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -4,16 +4,20 @@ int foo() {
int x[2]; // expected-note 4 {{array 'x' declared here}}
int y[2]; // expected-note 2 {{array 'y' declared here}}
int z[1]; // expected-note {{array 'z' declared here}}
+ int w[1][1]; // expected-note {{array 'w' declared here}}
+ int v[1][1][1]; // expected-note {{array 'v' declared here}}
int *p = &y[2]; // no-warning
(void) sizeof(x[2]); // no-warning
- y[2] = 2; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
- z[1] = 'x'; // expected-warning {{array index of '1' indexes past the end of an array (that contains 1 element)}}
- return x[2] + // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
- y[-1] + // expected-warning {{array index of '-1' indexes before the beginning of the array}}
- x[sizeof(x)] + // expected-warning {{array index of '8' indexes past the end of an array (that contains 2 elements)}}
- x[sizeof(x) / sizeof(x[0])] + // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+ y[2] = 2; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ z[1] = 'x'; // expected-warning {{array index 1 is past the end of the array (which contains 1 element)}}
+ w[0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+ v[0][0][2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+ return x[2] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ y[-1] + // expected-warning {{array index -1 is before the beginning of the array}}
+ x[sizeof(x)] + // expected-warning {{array index 8 is past the end of the array (which contains 2 elements)}}
+ x[sizeof(x) / sizeof(x[0])] + // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
x[sizeof(x) / sizeof(x[0]) - 1] + // no-warning
- x[sizeof(x[2])]; // expected-warning {{array index of '4' indexes past the end of an array (that contains 2 elements)}}
+ x[sizeof(x[2])]; // expected-warning {{array index 4 is past the end of the array (which contains 2 elements)}}
}
// This code example tests that -Warray-bounds works with arrays that
@@ -27,7 +31,7 @@ void f1(int a[1]) {
}
void f2(const int (&a)[2]) { // expected-note {{declared here}}
- int val = a[3]; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
+ int val = a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
}
void test() {
@@ -40,33 +44,33 @@ void test() {
short a[2]; // expected-note 4 {{declared here}}
char c[4];
} u;
- u.a[3] = 1; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
+ u.a[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
u.c[3] = 1; // no warning
short *p = &u.a[2]; // no warning
- p = &u.a[3]; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
- *(&u.a[2]) = 1; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
- *(&u.a[3]) = 1; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
+ p = &u.a[3]; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
+ *(&u.a[2]) = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ *(&u.a[3]) = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
*(&u.c[3]) = 1; // no warning
const int const_subscript = 3;
int array[2]; // expected-note {{declared here}}
- array[const_subscript] = 0; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
+ array[const_subscript] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
int *ptr;
ptr[3] = 0; // no warning for pointer references
int array2[] = { 0, 1, 2 }; // expected-note 2 {{declared here}}
- array2[3] = 0; // expected-warning {{array index of '3' indexes past the end of an array (that contains 3 elements)}}
- array2[2+2] = 0; // expected-warning {{array index of '4' indexes past the end of an array (that contains 3 elements)}}
+ array2[3] = 0; // expected-warning {{array index 3 is past the end of the array (which contains 3 elements)}}
+ array2[2+2] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}}
const char *str1 = "foo";
char c1 = str1[5]; // no warning for pointers
const char str2[] = "foo"; // expected-note {{declared here}}
- char c2 = str2[5]; // expected-warning {{array index of '5' indexes past the end of an array (that contains 4 elements)}}
+ char c2 = str2[5]; // expected-warning {{array index 5 is past the end of the array (which contains 4 elements)}}
int (*array_ptr)[2];
- (*array_ptr)[3] = 1; // expected-warning {{array index of '3' indexes past the end of an array (that contains 2 elements)}}
+ (*array_ptr)[3] = 1; // expected-warning {{array index 3 is past the end of the array (which contains 2 elements)}}
}
template <int I> struct S {
@@ -74,8 +78,8 @@ template <int I> struct S {
};
template <int I> void f() {
S<3> s;
- s.arr[4] = 0; // expected-warning {{array index of '4' indexes past the end of an array (that contains 3 elements)}}
- s.arr[I] = 0; // expected-warning {{array index of '5' indexes past the end of an array (that contains 3 elements)}}
+ s.arr[4] = 0; // expected-warning {{array index 4 is past the end of the array (which contains 3 elements)}}
+ s.arr[I] = 0; // expected-warning {{array index 5 is past the end of the array (which contains 3 elements)}}
}
void test_templates() {
@@ -88,13 +92,13 @@ void test_templates() {
int test_no_warn_macro_unreachable() {
int arr[SIZE]; // expected-note {{array 'arr' declared here}}
return ARR_IN_MACRO(0, arr, SIZE) + // no-warning
- ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index of '10' indexes past the end of an array (that contains 10 elements)}}
+ ARR_IN_MACRO(1, arr, SIZE); // expected-warning{{array index 10 is past the end of the array (which contains 10 elements)}}
}
// This exhibited an assertion failure for a 32-bit build of Clang.
int test_pr9240() {
short array[100]; // expected-note {{array 'array' declared here}}
- return array[(unsigned long long) 100]; // expected-warning {{array index of '100' indexes past the end of an array (that contains 100 elements)}}
+ return array[(unsigned long long) 100]; // expected-warning {{array index 100 is past the end of the array (which contains 100 elements)}}
}
// PR 9284 - a template parameter can cause an array bounds access to be
@@ -112,7 +116,7 @@ void pr9284b() {
int arr[3 + (extendArray ? 1 : 0)]; // expected-note {{array 'arr' declared here}}
if (!extendArray)
- arr[3] = 42; // expected-warning{{array index of '3' indexes past the end of an array (that contains 3 elements)}}
+ arr[3] = 42; // expected-warning{{array index 3 is past the end of the array (which contains 3 elements)}}
}
void test_pr9284() {
@@ -131,7 +135,7 @@ int test_sizeof_as_condition(int flag) {
int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
if (flag)
return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
- return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+ return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
}
void test_switch() {
@@ -143,7 +147,7 @@ void test_switch() {
}
case 4: {
int arr[2]; // expected-note {{array 'arr' declared here}}
- arr[2] = 1; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+ arr[2] = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
break;
}
default: {
@@ -186,10 +190,19 @@ namespace tailpad {
int x;
char c2[1];
};
-
- char bar(struct foo *F) {
- return F->c1[3]; // expected-warning {{array index of '3' indexes past the end of an array (that contains 1 element)}}
- return F->c2[3]; // no warning, foo could have tail padding allocated.
+
+ class baz {
+ public:
+ char c1[1]; // expected-note {{declared here}}
+ int x;
+ char c2[1];
+ };
+
+ char bar(struct foo *F, baz *B) {
+ return F->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ F->c2[3] + // no warning, foo could have tail padding allocated.
+ B->c1[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c2[3]; // no warning, baz could have tail padding allocated.
}
}
@@ -199,20 +212,20 @@ namespace metaprogramming {
template <int N> struct bar { char c[N]; }; // expected-note {{declared here}}
char test(foo *F, bar<1> *B) {
- return F->c[3] + // expected-warning {{array index of '3' indexes past the end of an array (that contains 1 element)}}
- B->c[3]; // expected-warning {{array index of '3' indexes past the end of an array (that contains 1 element)}}
+ return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+ B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
}
}
void bar(int x) {}
int test_more() {
int foo[5]; // expected-note 5 {{array 'foo' declared here}}
- bar(foo[5]); // expected-warning {{array index of '5' indexes past the end of an array (that contains 5 elements)}}
- ++foo[5]; // expected-warning {{array index of '5' indexes past the end of an array (that contains 5 elements)}}
- if (foo[6]) // expected-warning {{array index of '6' indexes past the end of an array (that contains 5 elements)}}
- return --foo[6]; // expected-warning {{array index of '6' indexes past the end of an array (that contains 5 elements)}}
+ bar(foo[5]); // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
+ ++foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
+ if (foo[6]) // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}}
+ return --foo[6]; // expected-warning {{array index 6 is past the end of the array (which contains 5 elements)}}
else
- return foo[5]; // expected-warning {{array index of '5' indexes past the end of an array (that contains 5 elements)}}
+ return foo[5]; // expected-warning {{array index 5 is past the end of the array (which contains 5 elements)}}
}
void test_pr10771() {
@@ -221,7 +234,7 @@ void test_pr10771() {
((char*)foo)[sizeof(foo) - 1] = '\0'; // no-warning
*(((char*)foo) + sizeof(foo) - 1) = '\0'; // no-warning
- ((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index of '32768' indexes past the end of an array (that contains 32768 elements)}}
+ ((char*)foo)[sizeof(foo)] = '\0'; // expected-warning {{array index 32768 is past the end of the array (which contains 32768 elements)}}
// TODO: This should probably warn, too.
*(((char*)foo) + sizeof(foo)) = '\0'; // no-warning
@@ -232,6 +245,11 @@ int test_pr11007_aux(const char * restrict, ...);
// Test checking with varargs.
void test_pr11007() {
double a[5]; // expected-note {{array 'a' declared here}}
- test_pr11007_aux("foo", a[1000]); // expected-warning {{array index of '1000' indexes past the end of an array}}
+ test_pr11007_aux("foo", a[1000]); // expected-warning {{array index 1000 is past the end of the array}}
}
+void test_rdar10916006(void)
+{
+ int a[128]; // expected-note {{array 'a' declared here}}
+ a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
+}
diff --git a/test/SemaCXX/atomic-type.cxx b/test/SemaCXX/atomic-type.cxx
new file mode 100644
index 0000000..18707eb
--- /dev/null
+++ b/test/SemaCXX/atomic-type.cxx
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -verify %s
+
+template<typename T> struct atomic {
+ _Atomic(T) value;
+};
+
+template<typename T> struct user {
+ struct inner { char n[sizeof(T)]; };
+ atomic<inner> i;
+};
+
+user<int> u;
+
+// Test overloading behavior of atomics.
+struct A { };
+
+int &ovl1(_Atomic(int));
+long &ovl1(_Atomic(long));
+float &ovl1(_Atomic(float));
+double &ovl1(_Atomic(A const *const *));
+short &ovl1(_Atomic(A **));
+
+void test_overloading(int i, float f, _Atomic(int) ai, _Atomic(float) af,
+ long l, _Atomic(long) al, A const *const *acc,
+ A const ** ac, A **a) {
+ int& ir1 = ovl1(i);
+ int& ir2 = ovl1(ai);
+ long& lr1 = ovl1(l);
+ long& lr2 = ovl1(al);
+ float &fr1 = ovl1(f);
+ float &fr2 = ovl1(af);
+ double &dr1 = ovl1(acc);
+ double &dr2 = ovl1(ac);
+ short &sr1 = ovl1(a);
+}
diff --git a/test/SemaCXX/attr-cxx0x.cpp b/test/SemaCXX/attr-cxx0x.cpp
index de9d7d1..4281895 100644
--- a/test/SemaCXX/attr-cxx0x.cpp
+++ b/test/SemaCXX/attr-cxx0x.cpp
@@ -9,6 +9,12 @@ struct align_member {
int member alignas(8);
};
+template <unsigned A> struct alignas(A) align_class_template {};
+
+// FIXME: these should not error
+template <typename... T> alignas(T...) struct align_class_temp_pack_type {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
+template <unsigned... A> alignas(A...) struct align_class_temp_pack_expr {}; // expected-error{{pack expansions in alignment specifiers are not supported yet}}
+
typedef char align_typedef alignas(8);
template<typename T> using align_alias_template = align_typedef;
@@ -18,4 +24,9 @@ static_assert(alignof(align_multiple) == 8, "l's alignment is wrong");
static_assert(alignof(align_member) == 8, "quuux's alignment is wrong");
static_assert(sizeof(align_member) == 8, "quuux's size is wrong");
static_assert(alignof(align_typedef) == 8, "typedef's alignment is wrong");
+static_assert(alignof(align_class_template<8>) == 8, "template's alignment is wrong");
+static_assert(alignof(align_class_template<16>) == 16, "template's alignment is wrong");
+// FIXME: enable these tests
+// static_assert(alignof(align_class_temp_pack_type<short, int, long>) == alignof(long), "template's alignment is wrong");
+// static_assert(alignof(align_class_temp_pack_expr<8, 16, 32>) == 32, "template's alignment is wrong");
static_assert(alignof(align_alias_template<int>) == 8, "alias template's alignment is wrong");
diff --git a/test/SemaCXX/attr-declspec-ignored.cpp b/test/SemaCXX/attr-declspec-ignored.cpp
new file mode 100644
index 0000000..0503750
--- /dev/null
+++ b/test/SemaCXX/attr-declspec-ignored.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+namespace test1 {
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) class A; // expected-warning{{attribute 'visibility' is ignored, place it after "class" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "class" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) struct B; // expected-warning{{attribute 'visibility' is ignored, place it after "struct" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "struct" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) union C; // expected-warning{{attribute 'visibility' is ignored, place it after "union" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "union" to apply attribute to type declaration}}
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D}; // expected-warning{{attribute 'visibility' is ignored, place it after "enum" to apply attribute to type declaration}} \
+ // expected-warning{{attribute 'aligned' is ignored, place it after "enum" to apply attribute to type declaration}}
+}
+
+namespace test2 {
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) class A {} a;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) struct B {} b;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) union C {} c;
+ __attribute__((visibility("hidden"))) __attribute__((aligned)) enum D {D} d;
+}
diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp
index 945aff3..46568aa 100644
--- a/test/SemaCXX/attr-deprecated.cpp
+++ b/test/SemaCXX/attr-deprecated.cpp
@@ -198,7 +198,7 @@ namespace test6 {
};
void testA() {
A x; // expected-warning {{'A' is deprecated}}
- x = a0; // expected-warning {{'A' is deprecated}}
+ x = a0; // expected-warning {{'a0' is deprecated}}
}
enum B {
@@ -218,7 +218,7 @@ namespace test6 {
};
void testC() {
C<int>::Enum x; // expected-warning {{'Enum' is deprecated}}
- x = C<int>::c0; // expected-warning {{'Enum' is deprecated}}
+ x = C<int>::c0; // expected-warning {{'c0' is deprecated}}
}
template <class T> struct D {
diff --git a/test/SemaCXX/attr-sentinel.cpp b/test/SemaCXX/attr-sentinel.cpp
index 56c8f88..92c6e21 100644
--- a/test/SemaCXX/attr-sentinel.cpp
+++ b/test/SemaCXX/attr-sentinel.cpp
@@ -1,6 +1,23 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+
void f(int, ...) __attribute__((sentinel));
void g() {
f(1, 2, __null);
}
+
+typedef __typeof__(sizeof(int)) size_t;
+
+struct S {
+ S(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void a(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void* operator new(size_t,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+ void operator()(int,...) __attribute__((sentinel)); // expected-note {{marked sentinel}}
+};
+
+void class_test() {
+ S s(1,2,3); // expected-warning {{missing sentinel in function call}}
+ S* s2 = new (1,2,3) S(1, __null); // expected-warning {{missing sentinel in function call}}
+ s2->a(1,2,3); // expected-warning {{missing sentinel in function call}}
+ s(1,2,3); // expected-warning {{missing sentinel in function call}}
+}
diff --git a/test/SemaCXX/auto-cxx98.cpp b/test/SemaCXX/auto-cxx98.cpp
index 6c401ba..1e28d06 100644
--- a/test/SemaCXX/auto-cxx98.cpp
+++ b/test/SemaCXX/auto-cxx98.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wc++11-compat
void f() {
auto int a; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
int auto b; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
diff --git a/test/SemaCXX/blocks-1.cpp b/test/SemaCXX/blocks-1.cpp
index 29de1e6..1b15094 100644
--- a/test/SemaCXX/blocks-1.cpp
+++ b/test/SemaCXX/blocks-1.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks -std=c++11
extern "C" int exit(int);
@@ -43,3 +43,16 @@ namespace rdar8134521 {
P = (int(^)(int))((void*)1);
}
}
+
+namespace rdar11055105 {
+ struct A {
+ void foo();
+ };
+
+ template <class T> void foo(T &x) noexcept(noexcept(x.foo()));
+
+ void (^block)() = ^{
+ A a;
+ foo(a);
+ };
+}
diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp
index 3f1d6a8..7773c08 100644
--- a/test/SemaCXX/c99-variable-length-array.cpp
+++ b/test/SemaCXX/c99-variable-length-array.cpp
@@ -14,8 +14,8 @@ struct POD {
// We allow VLAs of POD types, only.
void vla(int N) {
- int array1[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
- POD array2[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
+ POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}}
NonPOD array3[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}}
NonPOD2 array4[N][3]; // expected-error{{variable length array of non-POD element type 'NonPOD2'}}
}
@@ -23,7 +23,7 @@ void vla(int N) {
/// Warn about VLAs in templates.
template<typename T>
void vla_in_template(int N, T t) {
- int array1[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
}
struct HasConstantValue {
@@ -36,7 +36,7 @@ struct HasNonConstantValue {
template<typename T>
void vla_in_template(T t) {
- int array2[T::value]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array2[T::value]; // expected-warning{{variable length arrays are a C99 feature}}
}
template void vla_in_template<HasConstantValue>(HasConstantValue);
@@ -47,14 +47,14 @@ template<typename T> struct X0 { };
// Cannot use any variably-modified type with a template parameter or
// argument.
void inst_with_vla(int N) {
- int array[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array[N]; // expected-warning{{variable length arrays are a C99 feature}}
X0<__typeof__(array)> x0a; // expected-error{{variably modified type 'typeof (array)' (aka 'int [N]') cannot be used as a template argument}}
}
template<typename T>
struct X1 {
template<int (&Array)[T::value]> // expected-error{{non-type template parameter of variably modified type 'int (&)[HasNonConstantValue::value]'}} \
- // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ // expected-warning{{variable length arrays are a C99 feature}}
struct Inner {
};
@@ -68,16 +68,17 @@ template<typename T, unsigned N>
void accept_array(T (&array)[N]); // expected-note{{candidate template ignored: failed template argument deduction}}
void test_accept_array(int N) {
- int array[N]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array[N]; // expected-warning{{variable length arrays are a C99 feature}}
accept_array(array); // expected-error{{no matching function for call to 'accept_array'}}
}
// Variably-modified types cannot be used in local classes.
-void local_classes(int N) {
+void local_classes(int N) { // expected-note {{declared here}}
struct X {
int size;
int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}} \
- // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ // expected-error{{reference to local variable 'N' declared in enclosing function 'local_classes'}} \
+ // expected-warning{{variable length arrays are a C99 feature}}
};
}
@@ -87,7 +88,7 @@ namespace PR7206 {
float left;
float right;
};
- struct edge_info edgeInfo[x]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ struct edge_info edgeInfo[x]; // expected-warning{{variable length arrays are a C99 feature}}
}
}
@@ -95,7 +96,7 @@ namespace rdar8020206 {
template<typename T>
void f(int i) {
const unsigned value = i;
- int array[value * i]; // expected-warning 2{{variable length arrays are a C99 feature, accepted as an extension}}
+ int array[value * i]; // expected-warning 2{{variable length arrays are a C99 feature}}
}
template void f<int>(int); // expected-note{{instantiation of}}
@@ -109,7 +110,7 @@ namespace rdar8021385 {
typedef typename T::my_int my_int;
void f0() {
int M = 4;
- my_int a[M]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ my_int a[M]; // expected-warning{{variable length arrays are a C99 feature}}
}
};
B<A> a;
@@ -117,7 +118,7 @@ namespace rdar8021385 {
namespace PR8209 {
void f(int n) {
- typedef int vla_type[n]; // expected-warning{{variable length arrays are a C99 feature, accepted as an extension}}
+ typedef int vla_type[n]; // expected-warning{{variable length arrays are a C99 feature}}
(void)new vla_type; // expected-error{{variably}}
}
}
@@ -130,3 +131,11 @@ static const int k_cVal3 = (int)(1000*0.2f);
char rgch[k_cVal3] = {0};
}
}
+
+namespace PR11744 {
+ template<typename T> int f(int n) {
+ T arr[3][n]; // expected-warning 3 {{variable length arrays are a C99 feature}}
+ return 3;
+ }
+ int test = f<int>(0); // expected-note {{instantiation of}}
+}
diff --git a/test/SemaCXX/c99.cpp b/test/SemaCXX/c99.cpp
index cda069c..13918dc 100644
--- a/test/SemaCXX/c99.cpp
+++ b/test/SemaCXX/c99.cpp
@@ -4,6 +4,6 @@ void f1(int i[static 5]) { // expected-error{{C99}}
struct Point { int x; int y; };
-Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature, accepted in C++ as an extension}}
- y: 25 }; // expected-warning{{designated initializers are a C99 feature, accepted in C++ as an extension}} \
+Point p1 = { .x = 17, // expected-warning{{designated initializers are a C99 feature}}
+ y: 25 }; // expected-warning{{designated initializers are a C99 feature}} \
// expected-warning{{use of GNU old-style field designator extension}}
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
index ca9f045..e84e57b 100644
--- a/test/SemaCXX/class-base-member-init.cpp
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
class S {
public:
@@ -69,8 +69,24 @@ namespace test4 {
};
A(char _) : a(0), b(0) {}
- A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
- A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
- A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
+ A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of union}} expected-note {{previous initialization is here}}
+ };
+}
+
+namespace test5 {
+ struct Base {
+ Base(int);
+ };
+ struct A : Base {
+ A() : decltype(Base(1))(3) {
+ }
+ A(int) : Base(3), // expected-note {{previous initialization is here}}
+ decltype(Base(1))(2), // expected-error {{multiple initializations given for base 'decltype(test5::Base(1))' (aka 'test5::Base')}}
+ decltype(int())() { // expected-error {{constructor initializer 'decltype(int())' (aka 'int') does not name a class}}
+ }
+ A(float) : decltype(A())(3) {
+ }
};
}
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 160f365..4dffc8d 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -1,22 +1,24 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
class C {
public:
- auto int errx; // expected-error {{error: storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
- register int erry; // expected-error {{error: storage class specified for a member declaration}}
- extern int errz; // expected-error {{error: storage class specified for a member declaration}}
+ auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
+ register int erry; // expected-error {{storage class specified for a member declaration}}
+ extern int errz; // expected-error {{storage class specified for a member declaration}}
static void sm() {
sx = 0;
- this->x = 0; // expected-error {{error: invalid use of 'this' outside of a nonstatic member function}}
- x = 0; // expected-error {{error: invalid use of member 'x' in static member function}}
+ this->x = 0; // expected-error {{invalid use of 'this' outside of a non-static member function}}
+ x = 0; // expected-error {{invalid use of member 'x' in static member function}}
}
class NestedC {
public:
NestedC(int);
- void m() {
+ void f() {
sx = 0;
- x = 0; // expected-error {{invalid use of nonstatic data member 'x'}}
+ x = 0; // expected-error {{use of non-static data member 'x' of 'C' from nested type 'NestedC'}}
+ sm();
+ m(); // expected-error {{call to non-static member function 'm' of 'C' from nested type 'NestedC'}}
}
};
@@ -34,10 +36,10 @@ public:
enum E1 { en1, en2 };
- int i = 0; // expected-warning {{in-class initialization of non-static data member accepted as a C++11 extension}}
+ int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}}
static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
- static const int nci = vs; // expected-error {{in-class initializer is not a constant expression}}
+ static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
static const int vi = 0;
static const volatile int cvi = 0; // ok, illegal in C++11
static const E evi = 0;
@@ -46,7 +48,7 @@ public:
sx = 0;
this->x = 0;
y = 0;
- this = 0; // expected-error {{error: expression is not assignable}}
+ this = 0; // expected-error {{expression is not assignable}}
}
int f1(int p) {
@@ -57,7 +59,7 @@ public:
typedef int A;
virtual int viv; // expected-error {{'virtual' can only appear on non-static member functions}}
- virtual static int vsif(); // expected-error {{error: 'virtual' can only appear on non-static member functions}}
+ virtual static int vsif(); // expected-error {{'virtual' can only appear on non-static member functions}}
virtual int vif();
private:
@@ -65,9 +67,9 @@ private:
static int sx;
mutable int mi;
- mutable int &mir; // expected-error {{error: 'mutable' cannot be applied to references}}
- mutable void mfn(); // expected-error {{error: 'mutable' cannot be applied to functions}}
- mutable const int mci; // expected-error {{error: 'mutable' and 'const' cannot be mixed}}
+ mutable int &mir; // expected-error {{'mutable' cannot be applied to references}}
+ mutable void mfn(); // expected-error {{'mutable' cannot be applied to functions}}
+ mutable const int mci; // expected-error {{'mutable' and 'const' cannot be mixed}}
static const int number = 50;
static int arr[number];
@@ -98,11 +100,11 @@ void f()
}
// Play with mutable a bit more, to make sure it doesn't crash anything.
-mutable int gi; // expected-error {{error: 'mutable' can only be applied to member variables}}
+mutable int gi; // expected-error {{'mutable' can only be applied to member variables}}
mutable void gfn(); // expected-error {{illegal storage class on function}}
void ogfn()
{
- mutable int ml; // expected-error {{error: 'mutable' can only be applied to member variables}}
+ mutable int ml; // expected-error {{'mutable' can only be applied to member variables}}
// PR3020: This used to crash due to double ownership of C4.
struct C4;
@@ -129,10 +131,10 @@ namespace pr6629 {
bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
// BOGUS expected-error {{expected '{' after base class list}} \
// BOGUS expected-error {{expected ';' after struct}} \
- // BOGUS expected-error {{expected unqualified-id}} \
+ // BOGUS expected-error {{expected unqualified-id}}
{ };
- template<> struct foo<unknown,unknown> { // why isn't there an error here?
+ template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
template <typename U1, typename U2> struct bar {
typedef bar type;
static const int value = 0;
@@ -174,7 +176,7 @@ namespace rdar8367341 {
struct A {
static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}}
- static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer is not a constant expression}}
+ static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}}
};
}
@@ -186,7 +188,7 @@ struct S {
};
void f() {
- S::c; // expected-error {{invalid use of nonstatic data member}}
+ S::c; // expected-error {{invalid use of non-static data member}}
}
}
diff --git a/test/SemaCXX/complex-overload.cpp b/test/SemaCXX/complex-overload.cpp
index 2c057ac..719a850 100644
--- a/test/SemaCXX/complex-overload.cpp
+++ b/test/SemaCXX/complex-overload.cpp
@@ -32,7 +32,7 @@ int *promote_or_convert(long double _Complex); // expected-note{{candidate funct
void test_promote_or_convert(float f, float _Complex fc) {
char *cp = promote_or_convert(fc);
- int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous; candidates are:}}
+ int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
}
char *promote_or_convert2(float);
diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp
index 3441bae..993f8e1 100644
--- a/test/SemaCXX/condition.cpp
+++ b/test/SemaCXX/condition.cpp
@@ -7,7 +7,7 @@ void test() {
typedef int arr[10];
while (arr x=0) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}}
- while (int f()=0) ; // expected-error {{a function type is not allowed here}}
+ while (int f()=0) ; // expected-warning {{interpreted as a function declaration}} expected-note {{initializer}} expected-error {{a function type is not allowed here}}
struct S {} s;
if (s) ++x; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
@@ -20,7 +20,8 @@ void test() {
while (struct S {} *x=0) ; // expected-error {{types may not be defined in conditions}}
while (struct {} *x=0) ; // expected-error {{types may not be defined in conditions}}
switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize}} \
- // expected-warning{{enumeration value 'E' not handled in switch}}
+ // expected-warning{{enumeration value 'E' not handled in switch}} expected-warning {{switch statement has empty body}} \
+ // expected-note{{put the semicolon on a separate line}}
if (int x=0) { // expected-note 2 {{previous definition is here}}
int x; // expected-error {{redefinition of 'x'}}
@@ -49,6 +50,11 @@ void test3() {
if ("help")
(void) 0;
- if (test3)
+ if (test3) // expected-warning {{address of function 'test3' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
(void) 0;
}
+
+void test4(bool (&x)(void)) {
+ while (x);
+}
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index 5648d02..4aee913 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -96,8 +96,8 @@ void test()
(void)(i1 ? BadDerived() : BadBase());
// b2.1 (hierarchy stuff)
- const Base constret();
- const Derived constder();
+ extern const Base constret();
+ extern const Derived constder();
// should use const overload
A a1((i1 ? constret() : Base()).trick());
A a2((i1 ? Base() : constret()).trick());
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
new file mode 100644
index 0000000..41d214a
--- /dev/null
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -0,0 +1,1246 @@
+// RUN: %clang_cc1 -triple i686-linux -Wno-string-plus-int -fsyntax-only -verify -std=c++11 -pedantic %s -Wno-comment
+
+namespace StaticAssertFoldTest {
+
+int x;
+static_assert(++x, "test"); // expected-error {{not an integral constant expression}}
+static_assert(false, "test"); // expected-error {{test}}
+
+}
+
+typedef decltype(sizeof(char)) size_t;
+
+template<typename T> constexpr T id(const T &t) { return t; }
+template<typename T> constexpr T min(const T &a, const T &b) {
+ return a < b ? a : b;
+}
+template<typename T> constexpr T max(const T &a, const T &b) {
+ return a < b ? b : a;
+}
+template<typename T, size_t N> constexpr T *begin(T (&xs)[N]) { return xs; }
+template<typename T, size_t N> constexpr T *end(T (&xs)[N]) { return xs + N; }
+
+struct MemberZero {
+ constexpr int zero() { return 0; }
+};
+
+namespace DerivedToVBaseCast {
+
+ struct U { int n; };
+ struct V : U { int n; };
+ struct A : virtual V { int n; };
+ struct Aa { int n; };
+ struct B : virtual A, Aa {};
+ struct C : virtual A, Aa {};
+ struct D : B, C {};
+
+ D d;
+ constexpr B *p = &d;
+ constexpr C *q = &d;
+
+ static_assert((void*)p != (void*)q, "");
+ static_assert((A*)p == (A*)q, "");
+ static_assert((Aa*)p != (Aa*)q, "");
+
+ constexpr B &pp = d;
+ constexpr C &qq = d;
+ static_assert((void*)&pp != (void*)&qq, "");
+ static_assert(&(A&)pp == &(A&)qq, "");
+ static_assert(&(Aa&)pp != &(Aa&)qq, "");
+
+ constexpr V *v = p;
+ constexpr V *w = q;
+ constexpr V *x = (A*)p;
+ static_assert(v == w, "");
+ static_assert(v == x, "");
+
+ static_assert((U*)&d == p, "");
+ static_assert((U*)&d == q, "");
+ static_assert((U*)&d == v, "");
+ static_assert((U*)&d == w, "");
+ static_assert((U*)&d == x, "");
+
+ struct X {};
+ struct Y1 : virtual X {};
+ struct Y2 : X {};
+ struct Z : Y1, Y2 {};
+ Z z;
+ static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
+}
+
+namespace ConstCast {
+
+constexpr int n1 = 0;
+constexpr int n2 = const_cast<int&>(n1);
+constexpr int *n3 = const_cast<int*>(&n1);
+constexpr int n4 = *const_cast<int*>(&n1);
+constexpr const int * const *n5 = const_cast<const int* const*>(&n3);
+constexpr int **n6 = const_cast<int**>(&n3);
+constexpr int n7 = **n5;
+constexpr int n8 = **n6;
+
+}
+
+namespace TemplateArgumentConversion {
+ template<int n> struct IntParam {};
+
+ using IntParam0 = IntParam<0>;
+ using IntParam0 = IntParam<id(0)>;
+ using IntParam0 = IntParam<MemberZero().zero>; // expected-error {{did you mean to call it with no arguments?}}
+}
+
+namespace CaseStatements {
+ void f(int n) {
+ switch (n) {
+ case MemberZero().zero: // expected-error {{did you mean to call it with no arguments?}} expected-note {{previous}}
+ case id(0): // expected-error {{duplicate case value '0'}}
+ return;
+ }
+ }
+}
+
+extern int &Recurse1;
+int &Recurse2 = Recurse1; // expected-note {{declared here}}
+int &Recurse1 = Recurse2;
+constexpr int &Recurse3 = Recurse2; // expected-error {{must be initialized by a constant expression}} expected-note {{initializer of 'Recurse2' is not a constant expression}}
+
+extern const int RecurseA;
+const int RecurseB = RecurseA; // expected-note {{declared here}}
+const int RecurseA = 10;
+constexpr int RecurseC = RecurseB; // expected-error {{must be initialized by a constant expression}} expected-note {{initializer of 'RecurseB' is not a constant expression}}
+
+namespace MemberEnum {
+ struct WithMemberEnum {
+ enum E { A = 42 };
+ } wme;
+
+ static_assert(wme.A == 42, "");
+}
+
+namespace DefaultArguments {
+
+const int z = int();
+constexpr int Sum(int a = 0, const int &b = 0, const int *c = &z, char d = 0) {
+ return a + b + *c + d;
+}
+const int four = 4;
+constexpr int eight = 8;
+constexpr const int twentyseven = 27;
+static_assert(Sum() == 0, "");
+static_assert(Sum(1) == 1, "");
+static_assert(Sum(1, four) == 5, "");
+static_assert(Sum(1, eight, &twentyseven) == 36, "");
+static_assert(Sum(1, 2, &four, eight) == 15, "");
+
+}
+
+namespace Ellipsis {
+
+// Note, values passed through an ellipsis can't actually be used.
+constexpr int F(int a, ...) { return a; }
+static_assert(F(0) == 0, "");
+static_assert(F(1, 0) == 1, "");
+static_assert(F(2, "test") == 2, "");
+static_assert(F(3, &F) == 3, "");
+int k = 0; // expected-note {{here}}
+static_assert(F(4, k) == 3, ""); // expected-error {{constant expression}} expected-note {{read of non-const variable 'k'}}
+
+}
+
+namespace Recursion {
+ constexpr int fib(int n) { return n > 1 ? fib(n-1) + fib(n-2) : n; }
+ static_assert(fib(11) == 89, "");
+
+ constexpr int gcd_inner(int a, int b) {
+ return b == 0 ? a : gcd_inner(b, a % b);
+ }
+ constexpr int gcd(int a, int b) {
+ return gcd_inner(max(a, b), min(a, b));
+ }
+
+ static_assert(gcd(1749237, 5628959) == 7, "");
+}
+
+namespace FunctionCast {
+ // When folding, we allow functions to be cast to different types. Such
+ // cast functions cannot be called, even if they're constexpr.
+ constexpr int f() { return 1; }
+ typedef double (*DoubleFn)();
+ typedef int (*IntFn)();
+ int a[(int)DoubleFn(f)()]; // expected-error {{variable length array}} expected-warning{{C99 feature}}
+ int b[(int)IntFn(f)()]; // ok
+}
+
+namespace StaticMemberFunction {
+ struct S {
+ static constexpr int k = 42;
+ static constexpr int f(int n) { return n * k + 2; }
+ } s;
+
+ constexpr int n = s.f(19);
+ static_assert(S::f(19) == 800, "");
+ static_assert(s.f(19) == 800, "");
+ static_assert(n == 800, "");
+
+ constexpr int (*sf1)(int) = &S::f;
+ constexpr int (*sf2)(int) = &s.f;
+ constexpr const int *sk = &s.k;
+}
+
+namespace ParameterScopes {
+
+ const int k = 42;
+ constexpr const int &ObscureTheTruth(const int &a) { return a; }
+ constexpr const int &MaybeReturnJunk(bool b, const int a) { // expected-note 2{{declared here}}
+ return ObscureTheTruth(b ? a : k);
+ }
+ static_assert(MaybeReturnJunk(false, 0) == 42, ""); // ok
+ constexpr int a = MaybeReturnJunk(true, 0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}}
+
+ constexpr const int MaybeReturnNonstaticRef(bool b, const int a) {
+ return ObscureTheTruth(b ? a : k);
+ }
+ static_assert(MaybeReturnNonstaticRef(false, 0) == 42, ""); // ok
+ constexpr int b = MaybeReturnNonstaticRef(true, 0); // ok
+
+ constexpr int InternalReturnJunk(int n) {
+ return MaybeReturnJunk(true, n); // expected-note {{read of variable whose lifetime has ended}}
+ }
+ constexpr int n3 = InternalReturnJunk(0); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'InternalReturnJunk(0)'}}
+
+ constexpr int LToR(int &n) { return n; }
+ constexpr int GrabCallersArgument(bool which, int a, int b) {
+ return LToR(which ? b : a);
+ }
+ static_assert(GrabCallersArgument(false, 1, 2) == 1, "");
+ static_assert(GrabCallersArgument(true, 4, 8) == 8, "");
+
+}
+
+namespace Pointers {
+
+ constexpr int f(int n, const int *a, const int *b, const int *c) {
+ return n == 0 ? 0 : *a + f(n-1, b, c, a);
+ }
+
+ const int x = 1, y = 10, z = 100;
+ static_assert(f(23, &x, &y, &z) == 788, "");
+
+ constexpr int g(int n, int a, int b, int c) {
+ return f(n, &a, &b, &c);
+ }
+ static_assert(g(23, x, y, z) == 788, "");
+
+}
+
+namespace FunctionPointers {
+
+ constexpr int Double(int n) { return 2 * n; }
+ constexpr int Triple(int n) { return 3 * n; }
+ constexpr int Twice(int (*F)(int), int n) { return F(F(n)); }
+ constexpr int Quadruple(int n) { return Twice(Double, n); }
+ constexpr auto Select(int n) -> int (*)(int) {
+ return n == 2 ? &Double : n == 3 ? &Triple : n == 4 ? &Quadruple : 0;
+ }
+ constexpr int Apply(int (*F)(int), int n) { return F(n); } // expected-note {{subexpression}}
+
+ static_assert(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
+
+ constexpr int Invalid = Apply(Select(0), 0); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'Apply(0, 0)'}}
+
+}
+
+namespace PointerComparison {
+
+int x, y;
+static_assert(&x == &y, "false"); // expected-error {{false}}
+static_assert(&x != &y, "");
+constexpr bool g1 = &x == &y;
+constexpr bool g2 = &x != &y;
+constexpr bool g3 = &x <= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g4 = &x >= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g5 = &x < &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool g6 = &x > &y; // expected-error {{must be initialized by a constant expression}}
+
+struct S { int x, y; } s;
+static_assert(&s.x == &s.y, "false"); // expected-error {{false}}
+static_assert(&s.x != &s.y, "");
+static_assert(&s.x <= &s.y, "");
+static_assert(&s.x >= &s.y, "false"); // expected-error {{false}}
+static_assert(&s.x < &s.y, "");
+static_assert(&s.x > &s.y, "false"); // expected-error {{false}}
+
+static_assert(0 == &y, "false"); // expected-error {{false}}
+static_assert(0 != &y, "");
+constexpr bool n3 = 0 <= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n4 = 0 >= &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n5 = 0 < &y; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n6 = 0 > &y; // expected-error {{must be initialized by a constant expression}}
+
+static_assert(&x == 0, "false"); // expected-error {{false}}
+static_assert(&x != 0, "");
+constexpr bool n9 = &x <= 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n10 = &x >= 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n11 = &x < 0; // expected-error {{must be initialized by a constant expression}}
+constexpr bool n12 = &x > 0; // expected-error {{must be initialized by a constant expression}}
+
+static_assert(&x == &x, "");
+static_assert(&x != &x, "false"); // expected-error {{false}}
+static_assert(&x <= &x, "");
+static_assert(&x >= &x, "");
+static_assert(&x < &x, "false"); // expected-error {{false}}
+static_assert(&x > &x, "false"); // expected-error {{false}}
+
+constexpr S* sptr = &s;
+constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); // expected-error {{constant expression}} expected-note {{dynamic_cast}}
+
+struct U {};
+struct Str {
+ int a : dynamic_cast<S*>(sptr) == dynamic_cast<S*>(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{dynamic_cast is not allowed in a constant expression}}
+ int b : reinterpret_cast<S*>(sptr) == reinterpret_cast<S*>(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{reinterpret_cast is not allowed in a constant expression}}
+ int c : (S*)(long)(sptr) == (S*)(long)(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int d : (S*)(42) == (S*)(42); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int e : (Str*)(sptr) == (Str*)(sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int f : &(U&)(*sptr) == &(U&)(*sptr); // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+ int g : (S*)(void*)(sptr) == sptr; // \
+ expected-warning {{not an integral constant expression}} \
+ expected-note {{cast from 'void *' is not allowed in a constant expression}}
+};
+
+extern char externalvar[];
+constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}}
+constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant expression}} expected-warning {{unspecified}}
+static_assert(0 != "foo", "");
+
+}
+
+namespace MaterializeTemporary {
+
+constexpr int f(const int &r) { return r; }
+constexpr int n = f(1);
+
+constexpr bool same(const int &a, const int &b) { return &a == &b; }
+constexpr bool sameTemporary(const int &n) { return same(n, n); }
+
+static_assert(n, "");
+static_assert(!same(4, 4), "");
+static_assert(same(n, n), "");
+static_assert(sameTemporary(9), "");
+
+}
+
+constexpr int strcmp_ce(const char *p, const char *q) {
+ return (!*p || *p != *q) ? *p - *q : strcmp_ce(p+1, q+1);
+}
+
+namespace StringLiteral {
+
+template<typename Char>
+constexpr int MangleChars(const Char *p) {
+ return *p + 3 * (*p ? MangleChars(p+1) : 0);
+}
+
+static_assert(MangleChars("constexpr!") == 1768383, "");
+static_assert(MangleChars(u8"constexpr!") == 1768383, "");
+static_assert(MangleChars(L"constexpr!") == 1768383, "");
+static_assert(MangleChars(u"constexpr!") == 1768383, "");
+static_assert(MangleChars(U"constexpr!") == 1768383, "");
+
+constexpr char c0 = "nought index"[0];
+constexpr char c1 = "nice index"[10];
+constexpr char c2 = "nasty index"[12]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is past the end}} expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr char c3 = "negative index"[-1]; // expected-error {{must be initialized by a constant expression}} expected-warning {{is before the beginning}} expected-note {{cannot refer to element -1 of array of 15 elements}}
+constexpr char c4 = ((char*)(int*)"no reinterpret_casts allowed")[14]; // expected-error {{must be initialized by a constant expression}} expected-note {{cast which performs the conversions of a reinterpret_cast}}
+
+constexpr const char *p = "test" + 2;
+static_assert(*p == 's', "");
+
+constexpr const char *max_iter(const char *a, const char *b) {
+ return *a < *b ? b : a;
+}
+constexpr const char *max_element(const char *a, const char *b) {
+ return (a+1 >= b) ? a : max_iter(a, max_element(a+1, b));
+}
+
+constexpr char str[] = "the quick brown fox jumped over the lazy dog";
+constexpr const char *max = max_element(begin(str), end(str));
+static_assert(*max == 'z', "");
+static_assert(max == str + 38, "");
+
+static_assert(strcmp_ce("hello world", "hello world") == 0, "");
+static_assert(strcmp_ce("hello world", "hello clang") > 0, "");
+static_assert(strcmp_ce("constexpr", "test") < 0, "");
+static_assert(strcmp_ce("", " ") < 0, "");
+
+struct S {
+ int n : "foo"[4]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
+};
+
+struct T {
+ char c[6];
+ constexpr T() : c{"foo"} {}
+};
+constexpr T t;
+
+static_assert(t.c[0] == 'f', "");
+static_assert(t.c[1] == 'o', "");
+static_assert(t.c[2] == 'o', "");
+static_assert(t.c[3] == 0, "");
+static_assert(t.c[4] == 0, "");
+static_assert(t.c[5] == 0, "");
+static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
+
+struct U {
+ wchar_t chars[6];
+ int n;
+} constexpr u = { { L"test" }, 0 };
+static_assert(u.chars[2] == L's', "");
+
+struct V {
+ char c[4];
+ constexpr V() : c("hi!") {}
+};
+static_assert(V().c[1] == "i"[0], "");
+
+}
+
+namespace Array {
+
+template<typename Iter>
+constexpr auto Sum(Iter begin, Iter end) -> decltype(+*begin) {
+ return begin == end ? 0 : *begin + Sum(begin+1, end);
+}
+
+constexpr int xs[] = { 1, 2, 3, 4, 5 };
+constexpr int ys[] = { 5, 4, 3, 2, 1 };
+constexpr int sum_xs = Sum(begin(xs), end(xs));
+static_assert(sum_xs == 15, "");
+
+constexpr int ZipFoldR(int (*F)(int x, int y, int c), int n,
+ const int *xs, const int *ys, int c) {
+ return n ? F(
+ *xs, // expected-note {{read of dereferenced one-past-the-end pointer}}
+ *ys,
+ ZipFoldR(F, n-1, xs+1, ys+1, c)) // \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 2, &xs[4], &ys[4], 1)'}} \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 1, &xs[5], &ys[5], 1)'}}
+ : c;
+}
+constexpr int MulAdd(int x, int y, int c) { return x * y + c; }
+constexpr int InnerProduct = ZipFoldR(MulAdd, 5, xs, ys, 0);
+static_assert(InnerProduct == 35, "");
+
+constexpr int SubMul(int x, int y, int c) { return (x - y) * c; }
+constexpr int DiffProd = ZipFoldR(SubMul, 2, xs+3, ys+3, 1);
+static_assert(DiffProd == 8, "");
+static_assert(ZipFoldR(SubMul, 3, xs+3, ys+3, 1), ""); // \
+ expected-error {{constant expression}} \
+ expected-note {{in call to 'ZipFoldR(&SubMul, 3, &xs[3], &ys[3], 1)'}}
+
+constexpr const int *p = xs + 3;
+constexpr int xs4 = p[1]; // ok
+constexpr int xs5 = p[2]; // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr int xs6 = p[3]; // expected-error {{constant expression}} expected-note {{cannot refer to element 6}}
+constexpr int xs0 = p[-3]; // ok
+constexpr int xs_1 = p[-4]; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
+
+constexpr int zs[2][2][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+static_assert(zs[0][0][0][0] == 1, "");
+static_assert(zs[1][1][1][1] == 16, "");
+static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+static_assert((&zs[0][0][0][2])[-1] == 2, "");
+static_assert(**(**(zs + 1) + 1) == 11, "");
+static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}}
+static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
+constexpr int err_zs_1_2_0_0 = zs[1][2][0][0]; // expected-error {{constant expression}} expected-note {{cannot access array element of pointer past the end}}
+
+constexpr int fail(const int &p) {
+ return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}}
+}
+static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
+expected-error {{static_assert expression is not an integral constant expression}} \
+expected-note {{in call to 'fail(zs[1][0][1][0])'}}
+
+constexpr int arr[40] = { 1, 2, 3, [8] = 4 }; // expected-warning {{C99 feature}}
+constexpr int SumNonzero(const int *p) {
+ return *p + (*p ? SumNonzero(p+1) : 0);
+}
+constexpr int CountZero(const int *p, const int *q) {
+ return p == q ? 0 : (*p == 0) + CountZero(p+1, q);
+}
+static_assert(SumNonzero(arr) == 6, "");
+static_assert(CountZero(arr, arr + 40) == 36, "");
+
+struct ArrayElem {
+ constexpr ArrayElem() : n(0) {}
+ int n;
+ constexpr int f() { return n; }
+};
+struct ArrayRVal {
+ constexpr ArrayRVal() {}
+ ArrayElem elems[10];
+};
+static_assert(ArrayRVal().elems[3].f() == 0, "");
+
+}
+
+namespace DependentValues {
+
+struct I { int n; typedef I V[10]; };
+I::V x, y;
+template<bool B> struct S {
+ int k;
+ void f() {
+ I::V &cells = B ? x : y;
+ I &i = cells[k];
+ switch (i.n) {}
+ }
+};
+
+}
+
+namespace Class {
+
+struct A { constexpr A(int a, int b) : k(a + b) {} int k; };
+constexpr int fn(const A &a) { return a.k; }
+static_assert(fn(A(4,5)) == 9, "");
+
+struct B { int n; int m; } constexpr b = { 0, b.n }; // expected-warning {{uninitialized}}
+struct C {
+ constexpr C(C *this_) : m(42), n(this_->m) {} // ok
+ int m, n;
+};
+struct D {
+ C c;
+ constexpr D() : c(&c) {}
+};
+static_assert(D().c.n == 42, "");
+
+struct E {
+ constexpr E() : p(&p) {}
+ void *p;
+};
+constexpr const E &e1 = E(); // expected-error {{constant expression}} expected-note {{reference to temporary is not a constant expression}} expected-note {{temporary created here}}
+// This is a constant expression if we elide the copy constructor call, and
+// is not a constant expression if we don't! But we do, so it is.
+constexpr E e2 = E();
+static_assert(e2.p == &e2.p, "");
+constexpr E e3;
+static_assert(e3.p == &e3.p, "");
+
+extern const class F f;
+struct F {
+ constexpr F() : p(&f.p) {}
+ const void *p;
+};
+constexpr F f;
+
+struct G {
+ struct T {
+ constexpr T(T *p) : u1(), u2(p) {}
+ union U1 {
+ constexpr U1() {}
+ int a, b = 42;
+ } u1;
+ union U2 {
+ constexpr U2(T *p) : c(p->u1.b) {}
+ int c, d;
+ } u2;
+ } t;
+ constexpr G() : t(&t) {}
+} constexpr g;
+
+static_assert(g.t.u1.a == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
+static_assert(g.t.u1.b == 42, "");
+static_assert(g.t.u2.c == 42, "");
+static_assert(g.t.u2.d == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'd' of union with active member 'c'}}
+
+struct S {
+ int a, b;
+ const S *p;
+ double d;
+ const char *q;
+
+ constexpr S(int n, const S *p) : a(5), b(n), p(p), d(n), q("hello") {}
+};
+
+S global(43, &global);
+
+static_assert(S(15, &global).b == 15, "");
+
+constexpr bool CheckS(const S &s) {
+ return s.a == 5 && s.b == 27 && s.p == &global && s.d == 27. && s.q[3] == 'l';
+}
+static_assert(CheckS(S(27, &global)), "");
+
+struct Arr {
+ char arr[3];
+ constexpr Arr() : arr{'x', 'y', 'z'} {}
+};
+constexpr int hash(Arr &&a) {
+ return a.arr[0] + a.arr[1] * 0x100 + a.arr[2] * 0x10000;
+}
+constexpr int k = hash(Arr());
+static_assert(k == 0x007a7978, "");
+
+
+struct AggregateInit {
+ const char &c;
+ int n;
+ double d;
+ int arr[5];
+ void *p;
+};
+
+constexpr AggregateInit agg1 = { "hello"[0] };
+
+static_assert(strcmp_ce(&agg1.c, "hello") == 0, "");
+static_assert(agg1.n == 0, "");
+static_assert(agg1.d == 0.0, "");
+static_assert(agg1.arr[-1] == 0, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
+static_assert(agg1.arr[0] == 0, "");
+static_assert(agg1.arr[4] == 0, "");
+static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end}}
+static_assert(agg1.p == nullptr, "");
+
+namespace SimpleDerivedClass {
+
+struct B {
+ constexpr B(int n) : a(n) {}
+ int a;
+};
+struct D : B {
+ constexpr D(int n) : B(n) {}
+};
+constexpr D d(3);
+static_assert(d.a == 3, "");
+
+}
+
+struct Bottom { constexpr Bottom() {} };
+struct Base : Bottom {
+ constexpr Base(int a = 42, const char *b = "test") : a(a), b(b) {}
+ int a;
+ const char *b;
+};
+struct Base2 : Bottom {
+ constexpr Base2(const int &r) : r(r) {}
+ int q = 123;
+ const int &r;
+};
+struct Derived : Base, Base2 {
+ constexpr Derived() : Base(76), Base2(a) {}
+ int c = r + b[1];
+};
+
+constexpr bool operator==(const Base &a, const Base &b) {
+ return a.a == b.a && strcmp_ce(a.b, b.b) == 0;
+}
+
+constexpr Base base;
+constexpr Base base2(76);
+constexpr Derived derived;
+static_assert(derived.a == 76, "");
+static_assert(derived.b[2] == 's', "");
+static_assert(derived.c == 76 + 'e', "");
+static_assert(derived.q == 123, "");
+static_assert(derived.r == 76, "");
+static_assert(&derived.r == &derived.a, "");
+
+static_assert(!(derived == base), "");
+static_assert(derived == base2, "");
+
+constexpr Bottom &bot1 = (Base&)derived;
+constexpr Bottom &bot2 = (Base2&)derived;
+static_assert(&bot1 != &bot2, "");
+
+constexpr Bottom *pb1 = (Base*)&derived;
+constexpr Bottom *pb2 = (Base2*)&derived;
+static_assert(&pb1 != &pb2, "");
+static_assert(pb1 == &bot1, "");
+static_assert(pb2 == &bot2, "");
+
+constexpr Base2 &fail = (Base2&)bot1; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base2'}}
+constexpr Base &fail2 = (Base&)*pb2; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base'}}
+constexpr Base2 &ok2 = (Base2&)bot2;
+static_assert(&ok2 == &derived, "");
+
+constexpr Base2 *pfail = (Base2*)pb1; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base2'}}
+constexpr Base *pfail2 = (Base*)&bot2; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'const Class::Derived' to type 'Class::Base'}}
+constexpr Base2 *pok2 = (Base2*)pb2;
+static_assert(pok2 == &derived, "");
+static_assert(&ok2 == pok2, "");
+static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, "");
+static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, "");
+
+constexpr Base *nullB = 42 - 6 * 7;
+static_assert((Bottom*)nullB == 0, "");
+static_assert((Derived*)nullB == 0, "");
+static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
+
+namespace ConversionOperators {
+
+struct T {
+ constexpr T(int n) : k(5*n - 3) {}
+ constexpr operator int() { return k; }
+ int k;
+};
+
+struct S {
+ constexpr S(int n) : k(2*n + 1) {}
+ constexpr operator int() { return k; }
+ constexpr operator T() { return T(k); }
+ int k;
+};
+
+constexpr bool check(T a, T b) { return a == b.k; }
+
+static_assert(S(5) == 11, "");
+static_assert(check(S(5), 11), "");
+
+}
+
+}
+
+namespace Temporaries {
+
+struct S {
+ constexpr S() {}
+ constexpr int f();
+};
+struct T : S {
+ constexpr T(int n) : S(), n(n) {}
+ int n;
+};
+constexpr int S::f() {
+ // 'this' must be the postfix-expression in a class member access expression,
+ // so we can't just use
+ // return static_cast<T*>(this)->n;
+ return this->*(int(S::*))&T::n;
+}
+// The T temporary is implicitly cast to an S subobject, but we can recover the
+// T full-object via a base-to-derived cast, or a derived-to-base-casted member
+// pointer.
+static_assert(T(3).f() == 3, "");
+
+constexpr int f(const S &s) {
+ return static_cast<const T&>(s).n;
+}
+constexpr int n = f(T(5));
+static_assert(f(T(5)) == 5, "");
+
+constexpr bool b(int n) { return &n; }
+static_assert(b(0), "");
+
+}
+
+namespace Union {
+
+union U {
+ int a;
+ int b;
+};
+
+constexpr U u[4] = { { .a = 0 }, { .b = 1 }, { .a = 2 }, { .b = 3 } }; // expected-warning 4{{C99 feature}}
+static_assert(u[0].a == 0, "");
+static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
+static_assert(u[1].b == 1, "");
+static_assert((&u[1].b)[1] == 2, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
+static_assert(*(&(u[1].b) + 1 + 1) == 3, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element 2 of non-array object}}
+static_assert((&(u[1]) + 1 + 1)->b == 3, "");
+
+constexpr U v = {};
+static_assert(v.a == 0, "");
+
+union Empty {};
+constexpr Empty e = {};
+
+// Make sure we handle trivial copy constructors for unions.
+constexpr U x = {42};
+constexpr U y = x;
+static_assert(y.a == 42, "");
+static_assert(y.b == 42, ""); // expected-error {{constant expression}} expected-note {{'b' of union with active member 'a'}}
+
+}
+
+namespace MemberPointer {
+ struct A {
+ constexpr A(int n) : n(n) {}
+ int n;
+ constexpr int f() { return n + 3; }
+ };
+ constexpr A a(7);
+ static_assert(A(5).*&A::n == 5, "");
+ static_assert((&a)->*&A::n == 7, "");
+ static_assert((A(8).*&A::f)() == 11, "");
+ static_assert(((&a)->*&A::f)() == 10, "");
+
+ struct B : A {
+ constexpr B(int n, int m) : A(n), m(m) {}
+ int m;
+ constexpr int g() { return n + m + 1; }
+ };
+ constexpr B b(9, 13);
+ static_assert(B(4, 11).*&A::n == 4, "");
+ static_assert(B(4, 11).*&B::m == 11, "");
+ static_assert(B(4, 11).*(int(A::*))&B::m == 11, "");
+ static_assert((&b)->*&A::n == 9, "");
+ static_assert((&b)->*&B::m == 13, "");
+ static_assert((&b)->*(int(A::*))&B::m == 13, "");
+ static_assert((B(4, 11).*&A::f)() == 7, "");
+ static_assert((B(4, 11).*&B::g)() == 16, "");
+ static_assert((B(4, 11).*(int(A::*)()const)&B::g)() == 16, "");
+ static_assert(((&b)->*&A::f)() == 12, "");
+ static_assert(((&b)->*&B::g)() == 23, "");
+ static_assert(((&b)->*(int(A::*)()const)&B::g)() == 23, "");
+
+ struct S {
+ constexpr S(int m, int n, int (S::*pf)() const, int S::*pn) :
+ m(m), n(n), pf(pf), pn(pn) {}
+ constexpr S() : m(), n(), pf(&S::f), pn(&S::n) {}
+
+ constexpr int f() { return this->*pn; }
+ virtual int g() const;
+
+ int m, n;
+ int (S::*pf)() const;
+ int S::*pn;
+ };
+
+ constexpr int S::*pm = &S::m;
+ constexpr int S::*pn = &S::n;
+ constexpr int (S::*pf)() const = &S::f;
+ constexpr int (S::*pg)() const = &S::g;
+
+ constexpr S s(2, 5, &S::f, &S::m);
+
+ static_assert((s.*&S::f)() == 2, "");
+ static_assert((s.*s.pf)() == 2, "");
+
+ static_assert(pf == &S::f, "");
+ static_assert(pf == s.*&S::pf, "");
+ static_assert(pm == &S::m, "");
+ static_assert(pm != pn, "");
+ static_assert(s.pn != pn, "");
+ static_assert(s.pn == pm, "");
+ static_assert(pg != nullptr, "");
+ static_assert(pf != nullptr, "");
+ static_assert((int S::*)nullptr == nullptr, "");
+ static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+ static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
+
+ template<int n> struct T : T<n-1> {};
+ template<> struct T<0> { int n; };
+ template<> struct T<30> : T<29> { int m; };
+
+ T<17> t17;
+ T<30> t30;
+
+ constexpr int (T<10>::*deepn) = &T<0>::n;
+ static_assert(&(t17.*deepn) == &t17.n, "");
+ static_assert(deepn == &T<2>::n, "");
+
+ constexpr int (T<15>::*deepm) = (int(T<10>::*))&T<30>::m;
+ constexpr int *pbad = &(t17.*deepm); // expected-error {{constant expression}}
+ static_assert(&(t30.*deepm) == &t30.m, "");
+ static_assert(deepm == &T<50>::m, "");
+ static_assert(deepm != deepn, "");
+
+ constexpr T<5> *p17_5 = &t17;
+ constexpr T<13> *p17_13 = (T<13>*)p17_5;
+ constexpr T<23> *p17_23 = (T<23>*)p17_13; // expected-error {{constant expression}} expected-note {{cannot cast object of dynamic type 'T<17>' to type 'T<23>'}}
+ static_assert(&(p17_5->*(int(T<3>::*))deepn) == &t17.n, "");
+ static_assert(&(p17_13->*deepn) == &t17.n, "");
+ constexpr int *pbad2 = &(p17_13->*(int(T<9>::*))deepm); // expected-error {{constant expression}}
+
+ constexpr T<5> *p30_5 = &t30;
+ constexpr T<23> *p30_23 = (T<23>*)p30_5;
+ constexpr T<13> *p30_13 = p30_23;
+ static_assert(&(p30_5->*(int(T<3>::*))deepn) == &t30.n, "");
+ static_assert(&(p30_13->*deepn) == &t30.n, "");
+ static_assert(&(p30_23->*deepn) == &t30.n, "");
+ static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
+ static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
+ static_assert(&(p30_23->*deepm) == &t30.m, "");
+
+ struct Base { int n; };
+ template<int N> struct Mid : Base {};
+ struct Derived : Mid<0>, Mid<1> {};
+ static_assert(&Mid<0>::n == &Mid<1>::n, "");
+ static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
+ (int Derived::*)(int Mid<1>::*)&Mid<1>::n, "");
+ static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
+}
+
+namespace ArrayBaseDerived {
+
+ struct Base {
+ constexpr Base() {}
+ int n = 0;
+ };
+ struct Derived : Base {
+ constexpr Derived() {}
+ constexpr const int *f() { return &n; }
+ };
+
+ constexpr Derived a[10];
+ constexpr Derived *pd3 = const_cast<Derived*>(&a[3]);
+ constexpr Base *pb3 = const_cast<Derived*>(&a[3]);
+ static_assert(pb3 == pd3, "");
+
+ // pb3 does not point to an array element.
+ constexpr Base *pb4 = pb3 + 1; // ok, one-past-the-end pointer.
+ constexpr int pb4n = pb4->n; // expected-error {{constant expression}} expected-note {{cannot access field of pointer past the end}}
+ constexpr Base *err_pb5 = pb3 + 2; // expected-error {{constant expression}} expected-note {{cannot refer to element 2}} expected-note {{here}}
+ constexpr int err_pb5n = err_pb5->n; // expected-error {{constant expression}} expected-note {{initializer of 'err_pb5' is not a constant expression}}
+ constexpr Base *err_pb2 = pb3 - 1; // expected-error {{constant expression}} expected-note {{cannot refer to element -1}} expected-note {{here}}
+ constexpr int err_pb2n = err_pb2->n; // expected-error {{constant expression}} expected-note {{initializer of 'err_pb2'}}
+ constexpr Base *pb3a = pb4 - 1;
+
+ // pb4 does not point to a Derived.
+ constexpr Derived *err_pd4 = (Derived*)pb4; // expected-error {{constant expression}} expected-note {{cannot access derived class of pointer past the end}}
+ constexpr Derived *pd3a = (Derived*)pb3a;
+ constexpr int pd3n = pd3a->n;
+
+ // pd3a still points to the Derived array.
+ constexpr Derived *pd6 = pd3a + 3;
+ static_assert(pd6 == &a[6], "");
+ constexpr Derived *pd9 = pd6 + 3;
+ constexpr Derived *pd10 = pd6 + 4;
+ constexpr int pd9n = pd9->n; // ok
+ constexpr int err_pd10n = pd10->n; // expected-error {{constant expression}} expected-note {{cannot access base class of pointer past the end}}
+ constexpr int pd0n = pd10[-10].n;
+ constexpr int err_pdminus1n = pd10[-11].n; // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of}}
+
+ constexpr Base *pb9 = pd9;
+ constexpr const int *(Base::*pfb)() const =
+ static_cast<const int *(Base::*)() const>(&Derived::f);
+ static_assert((pb9->*pfb)() == &a[9].n, "");
+}
+
+namespace Complex {
+
+class complex {
+ int re, im;
+public:
+ constexpr complex(int re = 0, int im = 0) : re(re), im(im) {}
+ constexpr complex(const complex &o) : re(o.re), im(o.im) {}
+ constexpr complex operator-() const { return complex(-re, -im); }
+ friend constexpr complex operator+(const complex &l, const complex &r) {
+ return complex(l.re + r.re, l.im + r.im);
+ }
+ friend constexpr complex operator-(const complex &l, const complex &r) {
+ return l + -r;
+ }
+ friend constexpr complex operator*(const complex &l, const complex &r) {
+ return complex(l.re * r.re - l.im * r.im, l.re * r.im + l.im * r.re);
+ }
+ friend constexpr bool operator==(const complex &l, const complex &r) {
+ return l.re == r.re && l.im == r.im;
+ }
+ constexpr bool operator!=(const complex &r) const {
+ return re != r.re || im != r.im;
+ }
+ constexpr int real() const { return re; }
+ constexpr int imag() const { return im; }
+};
+
+constexpr complex i = complex(0, 1);
+constexpr complex k = (3 + 4*i) * (6 - 4*i);
+static_assert(complex(1,0).real() == 1, "");
+static_assert(complex(1,0).imag() == 0, "");
+static_assert(((complex)1).imag() == 0, "");
+static_assert(k.real() == 34, "");
+static_assert(k.imag() == 12, "");
+static_assert(k - 34 == 12*i, "");
+static_assert((complex)1 == complex(1), "");
+static_assert((complex)1 != complex(0, 1), "");
+static_assert(complex(1) == complex(1), "");
+static_assert(complex(1) != complex(0, 1), "");
+constexpr complex makeComplex(int re, int im) { return complex(re, im); }
+static_assert(makeComplex(1,0) == complex(1), "");
+static_assert(makeComplex(1,0) != complex(0, 1), "");
+
+class complex_wrap : public complex {
+public:
+ constexpr complex_wrap(int re, int im = 0) : complex(re, im) {}
+ constexpr complex_wrap(const complex_wrap &o) : complex(o) {}
+};
+
+static_assert((complex_wrap)1 == complex(1), "");
+static_assert((complex)1 != complex_wrap(0, 1), "");
+static_assert(complex(1) == complex_wrap(1), "");
+static_assert(complex_wrap(1) != complex(0, 1), "");
+constexpr complex_wrap makeComplexWrap(int re, int im) {
+ return complex_wrap(re, im);
+}
+static_assert(makeComplexWrap(1,0) == complex(1), "");
+static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
+
+}
+
+namespace PR11595 {
+ struct A { constexpr bool operator==(int x) { return true; } };
+ struct B { B(); A& x; };
+ static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
+
+ constexpr bool f(int k) { // expected-error {{constexpr function never produces a constant expression}}
+ return B().x == k; // expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
+ }
+}
+
+namespace ExprWithCleanups {
+ struct A { A(); ~A(); int get(); };
+ constexpr int get(bool FromA) { return FromA ? A().get() : 1; }
+ constexpr int n = get(false);
+}
+
+namespace Volatile {
+
+volatile constexpr int n1 = 0; // expected-note {{here}}
+volatile const int n2 = 0; // expected-note {{here}}
+int n3 = 37; // expected-note {{declared here}}
+
+constexpr int m1 = n1; // expected-error {{constant expression}} expected-note {{read of volatile-qualified type 'const volatile int'}}
+constexpr int m2 = n2; // expected-error {{constant expression}} expected-note {{read of volatile-qualified type 'const volatile int'}}
+constexpr int m1b = const_cast<const int&>(n1); // expected-error {{constant expression}} expected-note {{read of volatile object 'n1'}}
+constexpr int m2b = const_cast<const int&>(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
+
+struct T { int n; };
+const T t = { 42 }; // expected-note {{declared here}}
+
+constexpr int f(volatile int &&r) {
+ return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
+}
+constexpr int g(volatile int &&r) {
+ return const_cast<int&>(r); // expected-note {{read of volatile temporary is not allowed in a constant expression}}
+}
+struct S {
+ int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}}
+ int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}}
+ int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}}
+ int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}}
+};
+
+}
+
+namespace ExternConstexpr {
+ extern constexpr int n = 0;
+ extern constexpr int m; // expected-error {{constexpr variable declaration must be a definition}}
+ void f() {
+ extern constexpr int i; // expected-error {{constexpr variable declaration must be a definition}}
+ constexpr int j = 0;
+ constexpr int k; // expected-error {{default initialization of an object of const type}}
+ }
+}
+
+namespace ComplexConstexpr {
+ constexpr _Complex float test1 = {};
+ constexpr _Complex float test2 = {1};
+ constexpr _Complex double test3 = {1,2};
+ constexpr _Complex int test4 = {4};
+ constexpr _Complex int test5 = 4;
+ constexpr _Complex int test6 = {5,6};
+ typedef _Complex float fcomplex;
+ constexpr fcomplex test7 = fcomplex();
+
+ constexpr const double &t2r = __real test3;
+ constexpr const double &t2i = __imag test3;
+ static_assert(&t2r + 1 == &t2i, "");
+ static_assert(t2r == 1.0, "");
+ static_assert(t2i == 2.0, "");
+ constexpr const double *t2p = &t2r;
+ static_assert(t2p[-1] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element -1 of array of 2 elements}}
+ static_assert(t2p[0] == 1.0, "");
+ static_assert(t2p[1] == 2.0, "");
+ static_assert(t2p[2] == 0.0, ""); // expected-error {{constant expr}} expected-note {{one-past-the-end pointer}}
+ static_assert(t2p[3] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element 3 of array of 2 elements}}
+ constexpr _Complex float *p = 0;
+ constexpr float pr = __real *p; // expected-error {{constant expr}} expected-note {{cannot access real component of null}}
+ constexpr float pi = __imag *p; // expected-error {{constant expr}} expected-note {{cannot access imaginary component of null}}
+ constexpr const _Complex double *q = &test3 + 1;
+ constexpr double qr = __real *q; // expected-error {{constant expr}} expected-note {{cannot access real component of pointer past the end}}
+ constexpr double qi = __imag *q; // expected-error {{constant expr}} expected-note {{cannot access imaginary component of pointer past the end}}
+
+ static_assert(__real test6 == 5, "");
+ static_assert(__imag test6 == 6, "");
+ static_assert(&__imag test6 == &__real test6 + 1, "");
+}
+
+namespace InstantiateCaseStmt {
+ template<int x> constexpr int f() { return x; }
+ template<int x> int g(int c) { switch(c) { case f<x>(): return 1; } return 0; }
+ int gg(int c) { return g<4>(c); }
+}
+
+namespace ConvertedConstantExpr {
+ extern int &m;
+ extern int &n;
+
+ constexpr int k = 4;
+ int &m = const_cast<int&>(k);
+
+ // If we have nothing more interesting to say, ensure we don't produce a
+ // useless note and instead just point to the non-constant subexpression.
+ enum class E {
+ em = m,
+ en = n, // expected-error {{not a constant expression}}
+ eo = (m +
+ n // expected-error {{not a constant expression}}
+ ),
+ eq = reinterpret_cast<int>((int*)0) // expected-error {{not a constant expression}} expected-note {{reinterpret_cast}}
+ };
+}
+
+namespace IndirectField {
+ struct S {
+ struct { // expected-warning {{GNU extension}}
+ union {
+ struct { // expected-warning {{GNU extension}}
+ int a;
+ int b;
+ };
+ int c;
+ };
+ int d;
+ };
+ union {
+ int e;
+ int f;
+ };
+ constexpr S(int a, int b, int d, int e) : a(a), b(b), d(d), e(e) {}
+ constexpr S(int c, int d, int f) : c(c), d(d), f(f) {}
+ };
+
+ constexpr S s1(1, 2, 3, 4);
+ constexpr S s2(5, 6, 7);
+
+ // FIXME: The diagnostics here do a very poor job of explaining which unnamed
+ // member is active and which is requested.
+ static_assert(s1.a == 1, "");
+ static_assert(s1.b == 2, "");
+ static_assert(s1.c == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s1.d == 3, "");
+ static_assert(s1.e == 4, "");
+ static_assert(s1.f == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+
+ static_assert(s2.a == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.b == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.c == 5, "");
+ static_assert(s2.d == 6, "");
+ static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
+ static_assert(s2.f == 7, "");
+}
+
+// DR1405: don't allow reading mutable members in constant expressions.
+namespace MutableMembers {
+ struct MM {
+ mutable int n; // expected-note 3{{declared here}}
+ } constexpr mm = { 4 };
+ constexpr int mmn = mm.n; // expected-error {{constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+ int x = (mm.n = 1, 3);
+ constexpr int mmn2 = mm.n; // expected-error {{constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+
+ // Here's one reason why allowing this would be a disaster...
+ template<int n> struct Id { int k = n; };
+ int f() {
+ constexpr MM m = { 0 };
+ ++m.n;
+ return Id<m.n>().k; // expected-error {{not a constant expression}} expected-note {{read of mutable member 'n' is not allowed in a constant expression}}
+ }
+
+ struct A { int n; };
+ struct B { mutable A a; }; // expected-note {{here}}
+ struct C { B b; };
+ constexpr C c[3] = {};
+ constexpr int k = c[1].b.a.n; // expected-error {{constant expression}} expected-note {{mutable}}
+}
+
+namespace Fold {
+
+ // This macro forces its argument to be constant-folded, even if it's not
+ // otherwise a constant expression.
+ #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+
+ constexpr int n = (int)(char*)123; // expected-error {{constant expression}} expected-note {{reinterpret_cast}}
+ constexpr int m = fold((int)(char*)123); // ok
+ static_assert(m == 123, "");
+
+ #undef fold
+
+}
+
+namespace DR1454 {
+
+constexpr const int &f(const int &n) { return n; }
+constexpr int k1 = f(0); // ok
+
+struct Wrap {
+ const int &value;
+};
+constexpr const Wrap &g(const Wrap &w) { return w; }
+constexpr int k2 = g({0}).value; // ok
+
+constexpr const int &i = 0; // expected-error {{constant expression}} expected-note {{temporary}} expected-note 2{{here}}
+constexpr const int j = i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
+
+}
+
+namespace RecursiveOpaqueExpr {
+ template<typename Iter>
+ constexpr auto LastNonzero(Iter p, Iter q) -> decltype(+*p) {
+ return p != q ? (LastNonzero(p+1, q) ?: *p) : 0; // expected-warning {{GNU}}
+ }
+
+ constexpr int arr1[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 0 };
+ static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
+
+ constexpr int arr2[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 5 };
+ static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
+}
+
+namespace VLASizeof {
+
+ void f(int k) {
+ int arr[k]; // expected-warning {{C99}}
+ constexpr int n = 1 +
+ sizeof(arr) // expected-error {{constant expression}}
+ * 3;
+ }
+}
+
+namespace CompoundLiteral {
+ // FIXME:
+ // We don't model the semantics of this correctly: the compound literal is
+ // represented as a prvalue in the AST, but actually behaves like an lvalue.
+ // We treat the compound literal as a temporary and refuse to produce a
+ // pointer to it. This is OK: we're not required to treat this as a constant
+ // in C++, and in C we model compound literals as lvalues.
+ constexpr int *p = (int*)(int[1]){0}; // expected-warning {{C99}} expected-error {{constant expression}} expected-note 2{{temporary}}
+}
+
+namespace Vector {
+ typedef int __attribute__((vector_size(16))) VI4;
+ constexpr VI4 f(int n) {
+ return VI4 { n * 3, n + 4, n - 5, n / 6 };
+ }
+ constexpr auto v1 = f(10);
+
+ typedef double __attribute__((vector_size(32))) VD4;
+ constexpr VD4 g(int n) {
+ return (VD4) { n / 2.0, n + 1.5, n - 5.4, n * 0.9 }; // expected-warning {{C99}}
+ }
+ constexpr auto v2 = g(4);
+}
diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp
index 1341036..23a4dda 100644
--- a/test/SemaCXX/constant-expression.cpp
+++ b/test/SemaCXX/constant-expression.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s
// C++ [expr.const]p1:
// In several places, C++ requires expressions that evaluate to an integral
// or enumeration constant: as array bounds, as case expressions, as
@@ -85,3 +85,35 @@ enum {
a = sizeof(int) == 8,
b = a? 8 : 4
};
+
+void diags(int n) {
+ switch (n) {
+ case (1/0, 1): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)(1/0, 2.0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case __imag(1/0): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ case (int)__imag((double)(1/0)): // expected-error {{not an integral constant expression}} expected-note {{division by zero}}
+ ;
+ }
+}
+
+namespace IntOrEnum {
+ const int k = 0;
+ const int &p = k;
+ template<int n> struct S {};
+ S<p> s; // expected-error {{not an integral constant expression}}
+}
+
+extern const int recurse1;
+// recurse2 cannot be used in a constant expression because it is not
+// initialized by a constant expression. The same expression appearing later in
+// the TU would be a constant expression, but here it is not.
+const int recurse2 = recurse1;
+const int recurse1 = 1;
+int array1[recurse1]; // ok
+int array2[recurse2]; // expected-warning {{variable length array}} expected-warning {{integer constant expression}}
+
+namespace FloatConvert {
+ typedef int a[(int)42.3];
+ typedef int a[(int)42.997];
+ typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-error {{variable length}}
+}
diff --git a/test/SemaCXX/constexpr-ackermann.cpp b/test/SemaCXX/constexpr-ackermann.cpp
new file mode 100644
index 0000000..c4ea313
--- /dev/null
+++ b/test/SemaCXX/constexpr-ackermann.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+constexpr unsigned long long A(unsigned long long m, unsigned long long n) {
+ return m == 0 ? n + 1 : n == 0 ? A(m-1, 1) : A(m - 1, A(m, n - 1));
+}
+
+using X = int[A(3,4)];
+using X = int[125];
diff --git a/test/SemaCXX/constexpr-backtrace-limit.cpp b/test/SemaCXX/constexpr-backtrace-limit.cpp
new file mode 100644
index 0000000..9c40eed
--- /dev/null
+++ b/test/SemaCXX/constexpr-backtrace-limit.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 0 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST1
+// TEST1: constant expression
+// TEST1-NEXT: exceeded maximum depth of 4
+// TEST1-NEXT: in call to 'recurse(2)'
+// TEST1-NEXT: in call to 'recurse(3)'
+// TEST1-NEXT: in call to 'recurse(4)'
+// TEST1-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 4 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST2
+// TEST2: constant expression
+// TEST2-NEXT: exceeded maximum depth of 4
+// TEST2-NEXT: in call to 'recurse(2)'
+// TEST2-NEXT: skipping 2 calls
+// TEST2-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 2 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST3
+// TEST3: constant expression
+// TEST3-NEXT: reinterpret_cast
+// TEST3-NEXT: in call to 'recurse(0)'
+// TEST3-NEXT: skipping 4 calls
+// TEST3-NEXT: in call to 'recurse(5)'
+
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -fconstexpr-backtrace-limit 8 -fconstexpr-depth 8 -fno-caret-diagnostics 2>&1 | FileCheck %s -check-prefix=TEST4
+// TEST4: constant expression
+// TEST4-NEXT: reinterpret_cast
+// TEST4-NEXT: in call to 'recurse(0)'
+// TEST4-NEXT: in call to 'recurse(1)'
+// TEST4-NEXT: in call to 'recurse(2)'
+// TEST4-NEXT: in call to 'recurse(3)'
+// TEST4-NEXT: in call to 'recurse(4)'
+// TEST4-NEXT: in call to 'recurse(5)'
+
+constexpr int recurse(int n) { return n ? recurse(n-1) : *(int*)n; }
+static_assert(recurse(5), "");
diff --git a/test/SemaCXX/constexpr-depth.cpp b/test/SemaCXX/constexpr-depth.cpp
new file mode 100644
index 0000000..feba6fd
--- /dev/null
+++ b/test/SemaCXX/constexpr-depth.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=128 -fconstexpr-depth 128
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DMAX=2 -fconstexpr-depth 2
+// RUN: %clang -std=c++11 -fsyntax-only -Xclang -verify %s -DMAX=10 -fconstexpr-depth=10
+
+constexpr int depth(int n) { return n > 1 ? depth(n-1) : 0; } // expected-note {{exceeded maximum depth}} expected-note +{{}}
+
+constexpr int kBad = depth(MAX + 1); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'depth(}}
+constexpr int kGood = depth(MAX);
diff --git a/test/SemaCXX/constexpr-factorial.cpp b/test/SemaCXX/constexpr-factorial.cpp
new file mode 100644
index 0000000..b6cdde5
--- /dev/null
+++ b/test/SemaCXX/constexpr-factorial.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+constexpr unsigned oddfac(unsigned n) {
+ return n == 1 ? 1 : n * oddfac(n-2);
+}
+constexpr unsigned k = oddfac(123);
+
+using A = int[k % 256];
+using A = int[43];
diff --git a/test/SemaCXX/constexpr-nqueens.cpp b/test/SemaCXX/constexpr-nqueens.cpp
new file mode 100644
index 0000000..b158d6e
--- /dev/null
+++ b/test/SemaCXX/constexpr-nqueens.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+
+typedef unsigned long uint64_t;
+
+struct Board {
+ uint64_t State;
+ bool Failed;
+
+ constexpr Board() : State(0), Failed(false) {}
+ constexpr Board(const Board &O) : State(O.State), Failed(O.Failed) {}
+ constexpr Board(uint64_t State, bool Failed = false) :
+ State(State), Failed(Failed) {}
+ constexpr Board addQueen(int Row, int Col) {
+ return Board(State | ((uint64_t)Row << (Col * 4)));
+ }
+ constexpr int getQueenRow(int Col) {
+ return (State >> (Col * 4)) & 0xf;
+ }
+ constexpr bool ok(int Row, int Col) {
+ return okRecurse(Row, Col, 0);
+ }
+ constexpr bool okRecurse(int Row, int Col, int CheckCol) {
+ return Col == CheckCol ? true :
+ getQueenRow(CheckCol) == Row ? false :
+ getQueenRow(CheckCol) == Row + (Col - CheckCol) ? false :
+ getQueenRow(CheckCol) == Row + (CheckCol - Col) ? false :
+ okRecurse(Row, Col, CheckCol + 1);
+ }
+ constexpr bool at(int Row, int Col) {
+ return getQueenRow(Col) == Row;
+ }
+ constexpr bool check(const char *, int=0, int=0);
+};
+
+constexpr Board buildBoardRecurse(int N, int Col, const Board &B);
+constexpr Board buildBoardScan(int N, int Col, int Row, const Board &B);
+constexpr Board tryBoard(const Board &Try,
+ int N, int Col, int Row, const Board &B) {
+ return Try.Failed ? buildBoardScan(N, Col, Row, B) : Try;
+}
+constexpr Board buildBoardScan(int N, int Col, int Row, const Board &B) {
+ return Row == N ? Board(0, true) :
+ B.ok(Row, Col) ?
+ tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)),
+ N, Col, Row+1, B) :
+ buildBoardScan(N, Col, Row + 1, B);
+}
+constexpr Board buildBoardRecurse(int N, int Col, const Board &B) {
+ return Col == N ? B : buildBoardScan(N, Col, 0, B);
+}
+constexpr Board buildBoard(int N) {
+ return buildBoardRecurse(N, 0, Board());
+}
+
+constexpr Board q8 = buildBoard(8);
+
+constexpr bool Board::check(const char *p, int Row, int Col) {
+ return
+ *p == '\n' ? check(p+1, Row+1, 0) :
+ *p == 'o' ? at(Row, Col) && check(p+1, Row, Col+1) :
+ *p == '-' ? !at(Row, Col) && check(p+1, Row, Col+1) :
+ *p == 0 ? true :
+ false;
+}
+static_assert(q8.check(
+ "o-------\n"
+ "------o-\n"
+ "----o---\n"
+ "-------o\n"
+ "-o------\n"
+ "---o----\n"
+ "-----o--\n"
+ "--o-----\n"), "");
diff --git a/test/SemaCXX/constexpr-printing.cpp b/test/SemaCXX/constexpr-printing.cpp
new file mode 100644
index 0000000..9170fa1
--- /dev/null
+++ b/test/SemaCXX/constexpr-printing.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+
+struct S;
+constexpr int extract(const S &s);
+
+struct S {
+ constexpr S() : n(extract(*this)), m(0) {} // expected-note {{in call to 'extract(s1)'}}
+ constexpr S(int k) : n(k), m(extract(*this)) {}
+ int n, m;
+};
+
+constexpr int extract(const S &s) { return s.n; } // expected-note {{read of uninitialized object is not allowed in a constant expression}}
+
+constexpr S s1; // ok
+void f() {
+ constexpr S s1; // expected-error {{constant expression}} expected-note {{in call to 'S()'}}
+ constexpr S s2(10);
+}
+
+typedef __attribute__((vector_size(16))) int vector_int;
+
+struct T {
+ constexpr T() : arr() {}
+ int arr[4];
+};
+struct U : T {
+ constexpr U(const int *p) : T(), another(), p(p) {}
+ constexpr U(const U &u) : T(), another(), p(u.p) {}
+ T another;
+ const int *p;
+};
+constexpr U u1(&u1.arr[2]);
+
+constexpr int test_printing(int a, float b, _Complex int c, _Complex float d,
+ int *e, int &f, vector_int g, U h) {
+ return *e; // expected-note {{read of non-constexpr variable 'u2'}}
+}
+U u2(0); // expected-note {{here}}
+static_assert(test_printing(12, 39.762, 3 + 4i, 12.9 + 3.6i, &u2.arr[4], u2.another.arr[2], (vector_int){5, 1, 2, 3}, u1) == 0, ""); // \
+expected-error {{constant expression}} \
+expected-note {{in call to 'test_printing(12, 3.976200e+01, 3+4i, 1.290000e+01+3.600000e+00i, &u2.T::arr[4], u2.another.arr[2], {5, 1, 2, 3}, {{{}}, {{}}, &u1.T::arr[2]})'}}
+
+struct V {
+ // FIXME: when we can generate these as constexpr constructors, remove the
+ // explicit definitions.
+ constexpr V() : arr{[255] = 42} {}
+ constexpr V(const V &v) : arr{[255] = 42} {}
+ int arr[256];
+};
+constexpr V v;
+constexpr int get(const int *p) { return *p; } // expected-note {{read of dereferenced one-past-the-end pointer}}
+constexpr int passLargeArray(V v) { return get(v.arr+256); } // expected-note {{in call to 'get(&v.arr[256])'}}
+static_assert(passLargeArray(v) == 0, ""); // expected-error {{constant expression}} expected-note {{in call to 'passLargeArray({{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...}})'}}
+
+union Union {
+ constexpr Union(int n) : b(n) {}
+ constexpr Union(const Union &u) : b(u.b) {}
+ int a, b;
+};
+constexpr Union myUnion = 76;
+
+constexpr int badness(Union u) { return u.a + u.b; } // expected-note {{read of member 'a' of union with active member 'b'}}
+static_assert(badness(myUnion), ""); // expected-error {{constant expression}} \
+ expected-note {{in call to 'badness({.b = 76})'}}
+
+struct MemPtrTest {
+ int n;
+ void f();
+};
+MemPtrTest mpt; // expected-note {{here}}
+constexpr int MemPtr(int (MemPtrTest::*a), void (MemPtrTest::*b)(), int &c) {
+ return c; // expected-note {{read of non-constexpr variable 'mpt'}}
+}
+static_assert(MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.*&MemPtrTest::n), ""); // expected-error {{constant expression}} \
+expected-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.n)'}}
+
+template<typename CharT>
+constexpr CharT get(const CharT *p) { return p[-1]; } // expected-note 5{{}}
+
+constexpr char c = get("test\0\\\"\t\a\b\234"); // \
+ expected-error {{}} expected-note {{"test\000\\\"\t\a\b\234"}}
+constexpr char c8 = get(u8"test\0\\\"\t\a\b\234"); // \
+ expected-error {{}} expected-note {{u8"test\000\\\"\t\a\b\234"}}
+constexpr char16_t c16 = get(u"test\0\\\"\t\a\b\234\u1234"); // \
+ expected-error {{}} expected-note {{u"test\000\\\"\t\a\b\234\u1234"}}
+constexpr char32_t c32 = get(U"test\0\\\"\t\a\b\234\u1234\U0010ffff"); // \
+ expected-error {{}} expected-note {{U"test\000\\\"\t\a\b\234\u1234\U0010FFFF"}}
+constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \
+ expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF"}}
+
+constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}}
+
+typedef decltype(sizeof(int)) LabelDiffTy;
+constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}}
+void LabelDiffTest() {
+ static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}}
+ a:b:return;
+}
+
+constexpr bool test_bool_printing(bool b) { return 1 / !(2*b | !(2*b)); } // expected-note 2{{division by zero}}
+constexpr bool test_bool_0 = test_bool_printing(false); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(false)'}}
+constexpr bool test_bool_1 = test_bool_printing(true); // expected-error {{constant expr}} expected-note {{in call to 'test_bool_printing(true)'}}
diff --git a/test/SemaCXX/constexpr-strlen.cpp b/test/SemaCXX/constexpr-strlen.cpp
new file mode 100644
index 0000000..5e28e7f
--- /dev/null
+++ b/test/SemaCXX/constexpr-strlen.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -pedantic
+
+# 1 "/usr/include/string.h" 1 3 4
+extern "C" {
+ typedef decltype(sizeof(int)) size_t;
+ extern size_t strlen(const char *p);
+}
+
+# 10 "SemaCXX/constexpr-strlen.cpp" 2
+constexpr int n = __builtin_strlen("hello"); // ok
+constexpr int m = strlen("hello"); // expected-error {{constant expression}} expected-note {{non-constexpr function 'strlen' cannot be used in a constant expression}}
+
+// Make sure we can evaluate a call to strlen.
+int arr[3]; // expected-note {{here}}
+int k = arr[strlen("hello")]; // expected-warning {{array index 5}}
diff --git a/test/SemaCXX/constexpr-turing.cpp b/test/SemaCXX/constexpr-turing.cpp
new file mode 100644
index 0000000..c515378
--- /dev/null
+++ b/test/SemaCXX/constexpr-turing.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s
+
+// A direct proof that constexpr is Turing-complete, once DR1454 is implemented.
+
+const unsigned halt = (unsigned)-1;
+
+enum Dir { L, R };
+struct Action {
+ bool tape;
+ Dir dir;
+ unsigned next;
+};
+using State = Action[2];
+
+// An infinite tape!
+struct Tape {
+ constexpr Tape() : l(0), val(false), r(0) {}
+ constexpr Tape(const Tape &old, bool write) :
+ l(old.l), val(write), r(old.r) {}
+ constexpr Tape(const Tape &old, Dir dir) :
+ l(dir == L ? old.l ? old.l->l : 0 : &old),
+ val(dir == L ? old.l ? old.l->val : false
+ : old.r ? old.r->val : false),
+ r(dir == R ? old.r ? old.r->r : 0 : &old) {}
+ const Tape *l;
+ bool val;
+ const Tape *r;
+};
+constexpr Tape update(const Tape &old, bool write) { return Tape(old, write); }
+constexpr Tape move(const Tape &old, Dir dir) { return Tape(old, dir); }
+
+// Run turing machine 'tm' on tape 'tape' from state 'state'. Return number of
+// steps taken until halt.
+constexpr unsigned run(const State *tm, const Tape &tape, unsigned state) {
+ return state == halt ? 1 :
+ run(tm, move(update(tape, tm[state][tape.val].tape),
+ tm[state][tape.val].dir),
+ tm[state][tape.val].next) + 1;
+}
+
+// 3-state busy beaver. 14 steps.
+constexpr State bb3[] = {
+ { { true, R, 1 }, { true, L, 2 } },
+ { { true, L, 0 }, { true, R, 1 } },
+ { { true, L, 1 }, { true, R, halt } }
+};
+static_assert(run(bb3, Tape(), 0) == 14, "");
+
+// 4-state busy beaver. 108 steps.
+constexpr State bb4[] = {
+ { { true, R, 1 }, { true, L, 1 } },
+ { { true, L, 0 }, { false, L, 2 } },
+ { { true, R, halt }, { true, L, 3 } },
+ { { true, R, 3 }, { false, R, 0 } } };
+static_assert(run(bb4, Tape(), 0) == 108, "");
diff --git a/test/SemaCXX/constexpr-value-init.cpp b/test/SemaCXX/constexpr-value-init.cpp
new file mode 100644
index 0000000..e459f09
--- /dev/null
+++ b/test/SemaCXX/constexpr-value-init.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify
+
+struct A {
+ constexpr A() : a(b + 1), b(a + 1) {} // expected-note {{uninitialized}}
+ int a;
+ int b;
+};
+struct B {
+ A a;
+};
+
+constexpr A a; // ok, zero initialization preceeds static initialization
+void f() {
+ constexpr A a; // expected-error {{constant expression}} expected-note {{in call to 'A()'}}
+}
+
+constexpr B b1; // expected-error {{requires a user-provided default constructor}}
+constexpr B b2 = B(); // ok
+static_assert(b2.a.a == 1, "");
+static_assert(b2.a.b == 2, "");
+
+struct C {
+ int c;
+};
+struct D : C { int d; };
+constexpr C c1; // expected-error {{requires a user-provided default constructor}}
+constexpr C c2 = C(); // ok
+constexpr D d1; // expected-error {{requires a user-provided default constructor}}
+constexpr D d2 = D(); // ok with DR1452
+static_assert(D().c == 0, "");
+static_assert(D().d == 0, "");
+
+struct V : virtual C {};
+template<typename T> struct Z : T {
+ constexpr Z() : V() {}
+};
+constexpr int n = Z<V>().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index e439a76..e8b7f0b 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -74,7 +74,7 @@ class U {
union { int b; double d; };
U() : a(1), // expected-note {{previous initialization is here}}
- p(0), // expected-error {{initializing multiple members of anonymous union}}
+ p(0), // expected-error {{initializing multiple members of union}}
d(1.0) {}
};
@@ -268,3 +268,15 @@ struct S4 {
};
}
+
+namespace PR12049 {
+ int function();
+
+ class Class
+ {
+ public:
+ Class() : member(function() {} // expected-note {{to match this '('}}
+
+ int member; // expected-error {{expected ')'}}
+ };
+}
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
index b069abc..a64b187 100644
--- a/test/SemaCXX/conversion.cpp
+++ b/test/SemaCXX/conversion.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion %s 2>&1 | FileCheck %s
#include <stddef.h>
@@ -53,11 +54,30 @@ namespace test2 {
};
}
+// This file tests -Wnull-conversion, a subcategory of -Wconversion
+// which is on by default.
+
void test3() {
- int a = NULL; // expected-warning {{implicit conversion of NULL constant to integer}}
+ int a = NULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
int b;
- b = NULL; // expected-warning {{implicit conversion of NULL constant to integer}}
- int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to integer}}
+ b = NULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ long l = NULL; // FIXME: this should also warn, but currently does not if sizeof(NULL)==sizeof(inttype)
+ int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}}
int d;
- d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to integer}}
+ d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ bool bl = NULL; // FIXME: this should warn but we currently suppress a bunch of conversion-to-bool warnings including this one
+ char ch = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}}
+ unsigned char uch = NULL; // expected-warning {{implicit conversion of NULL constant to 'unsigned char'}}
+ short sh = NULL; // expected-warning {{implicit conversion of NULL constant to 'short'}}
+
+ // Use FileCheck to ensure we don't get any unnecessary macro-expansion notes
+ // (that don't appear as 'real' notes & can't be seen/tested by -verify)
+ // CHECK-NOT: note:
+ // CHECK: note: expanded from macro 'FNULL'
+#define FNULL NULL
+ int a2 = FNULL; // expected-warning {{implicit conversion of NULL constant to 'int'}}
+ // CHECK-NOT: note:
+ // CHECK: note: expanded from macro 'FINIT'
+#define FINIT int a3 = NULL;
+ FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}}
}
diff --git a/test/SemaCXX/copy-assignment.cpp b/test/SemaCXX/copy-assignment.cpp
index 7aca9d6..798582c 100644
--- a/test/SemaCXX/copy-assignment.cpp
+++ b/test/SemaCXX/copy-assignment.cpp
@@ -98,18 +98,13 @@ void test() {
}
// <rdar://problem/8315440>: Don't crash
-// FIXME: the recovery here is really bad.
namespace test1 {
template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}}
- A(UndeclaredType n) : X(n) {} // expected-error{{expected ')'}} expected-note{{to match this '('}} \
- // expected-error{{use of undeclared identifier 'n'}} \
- // expected-error{{expected ';' at end of declaration list}} \
- // expected-error{{field has incomplete type 'test1::A<char>'}}
+ A(UndeclaredType n) : X(n) {} // expected-error {{unknown type name 'UndeclaredType'}}
};
template<typename T> class B : public A<T> {
virtual void foo() {}
};
- extern template class A<char>; // expected-note {{in instantiation of template class 'test1::A<char>' requested here}} \
- // expected-note {{definition of 'test1::A<char>' is not complete until the closing '}'}}
+ extern template class A<char>;
extern template class B<char>;
}
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp
index fb83dcf..ea2db0c 100644
--- a/test/SemaCXX/copy-initialization.cpp
+++ b/test/SemaCXX/copy-initialization.cpp
@@ -42,3 +42,26 @@ namespace PR6757 {
f(foo);
}
}
+
+namespace DR5 {
+ // Core issue 5: if a temporary is created in copy-initialization, it is of
+ // the cv-unqualified version of the destination type.
+ namespace Ex1 {
+ struct C { };
+ C c;
+ struct A {
+ A(const A&);
+ A(const C&);
+ };
+ const volatile A a = c; // ok
+ }
+
+ namespace Ex2 {
+ struct S {
+ S(S&&); // expected-warning {{C++11}}
+ S(int);
+ };
+ const S a(0);
+ const S b = 0;
+ }
+}
diff --git a/test/SemaCXX/cxx0x-class.cpp b/test/SemaCXX/cxx0x-class.cpp
index 3527ccb..41b0a5c 100644
--- a/test/SemaCXX/cxx0x-class.cpp
+++ b/test/SemaCXX/cxx0x-class.cpp
@@ -11,18 +11,29 @@ public:
int i = 0;
static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
- static const int nci = vs; // expected-error {{in-class initializer is not a constant expression}}
+ static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
static const int vi = 0;
static const volatile int cvi = 0; // expected-error {{static const volatile data member must be initialized out of line}}
};
namespace rdar8367341 {
- float foo();
+ float foo(); // expected-note {{here}}
struct A {
static const float x = 5.0f; // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}}
- static const float y = foo(); // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} expected-error {{in-class initializer is not a constant expression}}
+ static const float y = foo(); // expected-warning {{GNU extension}} expected-note {{use 'constexpr' specifier to silence this warning}} expected-error {{in-class initializer for static data member is not a constant expression}}
static constexpr float x2 = 5.0f;
- static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}}
+ static constexpr float y2 = foo(); // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo'}}
+ };
+}
+
+
+namespace Foo {
+ // Regression test -- forward declaration of Foo should not cause error about
+ // nonstatic data member.
+ class Foo;
+ class Foo {
+ int x;
+ int y = x;
};
}
diff --git a/test/SemaCXX/cxx0x-compat.cpp b/test/SemaCXX/cxx0x-compat.cpp
index a01b26c..123008a 100644
--- a/test/SemaCXX/cxx0x-compat.cpp
+++ b/test/SemaCXX/cxx0x-compat.cpp
@@ -1,18 +1,23 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++0x-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -verify %s
namespace N {
- template<typename T> void f(T) {} // expected-note {{here}}
+ template<typename T> void f(T) {} // expected-note 2{{here}}
namespace M {
- template void f<int>(int); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}}
+ template void ::N::f<int>(int); // expected-warning {{explicit instantiation of 'f' not in a namespace enclosing 'N'}}
}
}
+using namespace N;
+template void f<char>(char); // expected-warning {{explicit instantiation of 'N::f' must occur in namespace 'N'}}
-template<typename T> void f(T) {} // expected-note {{here}}
+template<typename T> void g(T) {} // expected-note 2{{here}}
namespace M {
- template void f<int>(int); // expected-warning {{explicit instantiation of 'f' must occur in the global namespace}}
+ template void g<int>(int); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
+ template void ::g<char>(char); // expected-warning {{explicit instantiation of 'g' must occur at global scope}}
}
-void f() {
+template inline void g<double>(double); // expected-warning {{explicit instantiation cannot be 'inline'}}
+
+void g() {
auto int n = 0; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++11}}
}
@@ -22,3 +27,13 @@ struct S {
}
s = { n }, // expected-warning {{non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list in C++11}} expected-note {{explicit cast}}
t = { 1234 }; // expected-warning {{constant expression evaluates to 1234 which cannot be narrowed to type 'char' in C++11}} expected-warning {{changes value}} expected-note {{explicit cast}}
+
+#define PRIuS "uS"
+int printf(const char *, ...);
+typedef __typeof(sizeof(int)) size_t;
+void h(size_t foo, size_t bar) {
+ printf("foo is %"PRIuS", bar is %"PRIuS, foo, bar); // expected-warning 2{{identifier after literal will be treated as a reserved user-defined literal suffix in C++11}}
+}
+
+#define _x + 1
+char c = 'x'_x; // expected-warning {{will be treated as a user-defined literal suffix}}
diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
index 17933c2..3290595 100644
--- a/test/SemaCXX/cxx0x-cursory-default-delete.cpp
+++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -67,3 +67,9 @@ struct except_spec_d_mismatch : except_spec_a, except_spec_b {
struct except_spec_d_match : except_spec_a, except_spec_b {
except_spec_d_match() throw(A, B) = default;
};
+
+// gcc-compatibility: allow attributes on default definitions
+// (but not normal definitions)
+struct S { S(); };
+S::S() __attribute((pure)) = default;
+
diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp
index d01f63b..2e4107c 100644
--- a/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -28,7 +28,7 @@ bar& bar::operator = (const bar&) = default;
bar& bar::operator = (bar&) = default;
bar::~bar() = default;
-// FIXME: static_assert(__is_trivial(foo), "foo should be trivial");
+static_assert(__is_trivial(foo), "foo should be trivial");
static_assert(!__has_trivial_destructor(bar), "bar's destructor isn't trivial");
static_assert(!__has_trivial_constructor(bar),
@@ -43,3 +43,11 @@ void tester() {
b = c;
}
+template<typename T> struct S : T {
+ constexpr S() = default;
+ constexpr S(const S&) = default;
+ constexpr S(S&&) = default;
+};
+struct lit { constexpr lit() {} };
+S<lit> s_lit; // ok
+S<bar> s_bar; // ok
diff --git a/test/SemaCXX/cxx0x-deleted-default-ctor.cpp b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
index 16c5664..0cebc10 100644
--- a/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
+++ b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
@@ -7,27 +7,27 @@ struct non_trivial {
~non_trivial();
};
-union bad_union { // expected-note {{marked deleted here}}
- non_trivial nt;
+union bad_union {
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
};
-bad_union u; // expected-error {{call to deleted constructor}}
-union bad_union2 { // expected-note {{marked deleted here}}
+bad_union u; // expected-error {{call to implicitly-deleted default constructor}}
+union bad_union2 { // expected-note {{all data members are const-qualified}}
const int i;
};
-bad_union2 u2; // expected-error {{call to deleted constructor}}
+bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_anon { // expected-note {{marked deleted here}}
+struct bad_anon {
union {
- non_trivial nt;
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
};
};
-bad_anon a; // expected-error {{call to deleted constructor}}
-struct bad_anon2 { // expected-note {{marked deleted here}}
- union {
+bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_anon2 {
+ union { // expected-note {{all data members of an anonymous union member are const-qualified}}
const int i;
};
};
-bad_anon2 a2; // expected-error {{call to deleted constructor}}
+bad_anon2 a2; // expected-error {{call to implicitly-deleted default constructor}}
// This would be great except that we implement
union good_union {
@@ -48,10 +48,10 @@ struct good : non_trivial {
};
good g;
-struct bad_const { // expected-note {{marked deleted here}}
- const good g;
+struct bad_const {
+ const good g; // expected-note {{field 'g' of const-qualified type 'const good' would not be initialized}}
};
-bad_const bc; // expected-error {{call to deleted constructor}}
+bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}
struct good_const {
const non_trivial nt;
@@ -59,44 +59,44 @@ struct good_const {
good_const gc;
struct no_default {
- no_default() = delete;
+ no_default() = delete; // expected-note 3{{deleted here}}
};
struct no_dtor {
- ~no_dtor() = delete;
+ ~no_dtor() = delete; // expected-note 2{{deleted here}}
};
-struct bad_field_default { // expected-note {{marked deleted here}}
- no_default nd;
+struct bad_field_default {
+ no_default nd; // expected-note {{field 'nd' has a deleted default constructor}}
};
-bad_field_default bfd; // expected-error {{call to deleted constructor}}
-struct bad_base_default : no_default { // expected-note {{marked deleted here}}
+bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_base_default : no_default { // expected-note {{base class 'no_default' has a deleted default constructor}}
};
-bad_base_default bbd; // expected-error {{call to deleted constructor}}
+bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_field_dtor { // expected-note {{marked deleted here}}
- no_dtor nd;
+struct bad_field_dtor {
+ no_dtor nd; // expected-note {{field 'nd' has a deleted destructor}}
};
-bad_field_dtor bfx; // expected-error {{call to deleted constructor}}
-struct bad_base_dtor : no_dtor { // expected-note {{marked deleted here}}
+bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}
+struct bad_base_dtor : no_dtor { // expected-note {{base class 'no_dtor' has a deleted destructor}}
};
-bad_base_dtor bbx; // expected-error {{call to deleted constructor}}
+bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}
struct ambiguous_default {
ambiguous_default();
ambiguous_default(int = 2);
};
-struct has_amb_field { // expected-note {{marked deleted here}}
- ambiguous_default ad;
+struct has_amb_field {
+ ambiguous_default ad; // expected-note {{field 'ad' has multiple default constructors}}
};
-has_amb_field haf; // expected-error {{call to deleted constructor}}
+has_amb_field haf; // expected-error {{call to implicitly-deleted default constructor}}
class inaccessible_default {
inaccessible_default();
};
-struct has_inacc_field { // expected-note {{marked deleted here}}
- inaccessible_default id;
+struct has_inacc_field {
+ inaccessible_default id; // expected-note {{field 'id' has an inaccessible default constructor}}
};
-has_inacc_field hif; // expected-error {{call to deleted constructor}}
+has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}
class friend_default {
friend struct has_friend;
@@ -108,10 +108,10 @@ struct has_friend {
has_friend hf;
struct defaulted_delete {
- no_default nd;
- defaulted_delete() = default; // expected-note {{marked deleted here}}
+ no_default nd; // expected-note {{because field 'nd' has a deleted default constructor}}
+ defaulted_delete() = default; // expected-note{{implicitly deleted here}}
};
-defaulted_delete dd; // expected-error {{call to deleted constructor}}
+defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}
struct late_delete {
no_default nd;
@@ -121,12 +121,11 @@ late_delete::late_delete() = default; // expected-error {{would delete it}}
// See also rdar://problem/8125400.
namespace empty {
- static union {}; // expected-error {{deleted constructor}} expected-note {{here}}
+ static union {};
static union { union {}; };
static union { struct {}; };
static union { union { union {}; }; };
static union { union { struct {}; }; };
- static union { struct { union {}; }; }; // expected-error {{deleted constructor}} expected-note {{here}}
+ static union { struct { union {}; }; };
static union { struct { struct {}; }; };
}
-
diff --git a/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/test/SemaCXX/cxx0x-initializer-aggregates.cpp
new file mode 100644
index 0000000..801a82f
--- /dev/null
+++ b/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace aggregate {
+ // Direct list initialization does NOT allow braces to be elided!
+ struct S {
+ int ar[2];
+ struct T {
+ int i1;
+ int i2;
+ } t;
+ struct U {
+ int i1;
+ } u[2];
+ struct V {
+ int var[2];
+ } v;
+ };
+
+ void bracing() {
+ S s1 = { 1, 2, 3 ,4, 5, 6, 7, 8 }; // no-error
+ S s2{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ S s3{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ S s4{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ S s5{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ void bracing_new() {
+ new S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ new S{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ new S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ new S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ void bracing_construct() {
+ (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
+ (void) S{ 1, 2, 3, 4, 5, 6 }; // expected-error 5 {{cannot omit braces}}
+ (void) S{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // expected-error 2 {{cannot omit braces}}
+ (void) S{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // expected-error {{cannot omit braces}}
+ }
+
+ struct String {
+ String(const char*);
+ };
+
+ struct A {
+ int m1;
+ int m2;
+ };
+
+ void function_call() {
+ void takes_A(A);
+ takes_A({1, 2});
+ }
+
+ struct B {
+ int m1;
+ String m2;
+ };
+
+ void overloaded_call() {
+ one overloaded(A);
+ two overloaded(B);
+
+ static_assert(sizeof(overloaded({1, 2})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({1, "two"})) == sizeof(two),
+ "bad overload");
+ // String is not default-constructible
+ static_assert(sizeof(overloaded({1})) == sizeof(one), "bad overload");
+ }
+
+ struct C { int a[2]; C():a({1, 2}) { } }; // expected-error {{parenthesized initialization of a member array is a GNU extension}}
+}
+
+namespace array_explicit_conversion {
+ typedef int test1[2];
+ typedef int test2[];
+ template<int x> struct A { int a[x]; }; // expected-error {{'a' declared as an array with a negative size}}
+ typedef A<1> test3[];
+ typedef A<-1> test4[];
+ void f() {
+ (void)test1{1};
+ (void)test2{1};
+ (void)test3{{{1}}};
+ (void)test4{{{1}}}; // expected-note {{in instantiation of template class 'array_explicit_conversion::A<-1>' requested here}}
+ }
+}
diff --git a/test/SemaCXX/cxx0x-initializer-constructor.cpp b/test/SemaCXX/cxx0x-initializer-constructor.cpp
new file mode 100644
index 0000000..09aca24
--- /dev/null
+++ b/test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -0,0 +1,283 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+namespace objects {
+
+ struct X1 { X1(int); };
+ struct X2 { explicit X2(int); }; // expected-note {{constructor declared here}}
+
+ template <int N>
+ struct A {
+ A() { static_assert(N == 0, ""); }
+ A(int, double) { static_assert(N == 1, ""); }
+ };
+
+ template <int N>
+ struct F {
+ F() { static_assert(N == 0, ""); }
+ F(int, double) { static_assert(N == 1, ""); }
+ F(std::initializer_list<int>) { static_assert(N == 3, ""); }
+ };
+
+ template <int N>
+ struct D {
+ D(std::initializer_list<int>) { static_assert(N == 0, ""); } // expected-note 1 {{candidate}}
+ D(std::initializer_list<double>) { static_assert(N == 1, ""); } // expected-note 1 {{candidate}}
+ };
+
+ template <int N>
+ struct E {
+ E(int, int) { static_assert(N == 0, ""); }
+ E(X1, int) { static_assert(N == 1, ""); }
+ };
+
+ void overload_resolution() {
+ { A<0> a{}; }
+ { A<0> a = {}; }
+ { A<1> a{1, 1.0}; }
+ { A<1> a = {1, 1.0}; }
+
+ { F<0> f{}; }
+ { F<0> f = {}; }
+ // Narrowing conversions don't affect viability. The next two choose
+ // the initializer_list constructor.
+ // FIXME: Emit narrowing conversion errors.
+ { F<3> f{1, 1.0}; } // xpected-error {{narrowing conversion}}
+ { F<3> f = {1, 1.0}; } // xpected-error {{narrowing conversion}}
+ { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f = {1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f{1, 2, 3, 4, 5, 6, 7, 8}; }
+ { F<3> f{1, 2}; }
+
+ { D<0> d{1, 2, 3}; }
+ { D<1> d{1.0, 2.0, 3.0}; }
+ { D<-1> d{1, 2.0}; } // expected-error {{ambiguous}}
+
+ { E<0> e{1, 2}; }
+ }
+
+ void explicit_implicit() {
+ { X1 x{0}; }
+ { X1 x = {0}; }
+ { X2 x{0}; }
+ { X2 x = {0}; } // expected-error {{constructor is explicit}}
+ }
+
+ struct C {
+ C();
+ C(int, double);
+ C(int, int);
+
+ int operator[](C);
+ };
+
+ C function_call() {
+ void takes_C(C);
+ takes_C({1, 1.0});
+
+ C c;
+ c[{1, 1.0}];
+
+ return {1, 1.0};
+ }
+
+ void inline_init() {
+ (void) C{1, 1.0};
+ (void) new C{1, 1.0};
+ (void) A<1>{1, 1.0};
+ (void) new A<1>{1, 1.0};
+ }
+
+ struct B { // expected-note 2 {{candidate constructor}}
+ B(C, int, C); // expected-note {{candidate constructor not viable: cannot convert initializer list argument to 'objects::C'}}
+ };
+
+ void nested_init() {
+ B b1{{1, 1.0}, 2, {3, 4}};
+ B b2{{1, 1.0, 4}, 2, {3, 4}}; // expected-error {{no matching constructor for initialization of 'objects::B'}}
+ }
+
+ void overloaded_call() {
+ one ov1(B); // expected-note {{not viable: cannot convert initializer list}}
+ two ov1(C); // expected-note {{not viable: cannot convert initializer list}}
+
+ static_assert(sizeof(ov1({})) == sizeof(two), "bad overload");
+ static_assert(sizeof(ov1({1, 2})) == sizeof(two), "bad overload");
+ static_assert(sizeof(ov1({{1, 1.0}, 2, {3, 4}})) == sizeof(one), "bad overload");
+
+ ov1({1}); // expected-error {{no matching function}}
+
+ one ov2(int);
+ two ov2(F<3>);
+ static_assert(sizeof(ov2({1})) == sizeof(one), "bad overload"); // list -> int ranks as identity
+ static_assert(sizeof(ov2({1, 2, 3})) == sizeof(two), "bad overload"); // list -> F only viable
+ }
+
+ struct G { // expected-note 6 {{not viable}}
+ // This is not an initializer-list constructor.
+ template<typename ...T>
+ G(std::initializer_list<int>, T ...); // expected-note 3 {{not viable}}
+ };
+
+ struct H { // expected-note 6 {{not viable}}
+ explicit H(int, int); // expected-note 3 {{not viable}} expected-note {{declared here}}
+ H(int, void*); // expected-note 3 {{not viable}}
+ };
+
+ void edge_cases() {
+ // invalid (the first phase only considers init-list ctors)
+ // (for the second phase, no constructor is viable)
+ G g1{1, 2, 3}; // expected-error {{no matching constructor}}
+ (void) new G{1, 2, 3}; // expected-error {{no matching constructor}}
+ (void) G{1, 2, 3} // expected-error {{no matching constructor}}
+
+ // valid (T deduced to <>).
+ G g2({1, 2, 3});
+ (void) new G({1, 2, 3});
+ (void) G({1, 2, 3});
+
+ // invalid
+ H h1({1, 2}); // expected-error {{no matching constructor}}
+ (void) new H({1, 2}); // expected-error {{no matching constructor}}
+ // FIXME: Bad diagnostic, mentions void type instead of init list.
+ (void) H({1, 2}); // expected-error {{no matching conversion}}
+
+ // valid (by copy constructor).
+ H h2({1, nullptr});
+ (void) new H({1, nullptr});
+ (void) H({1, nullptr});
+
+ // valid
+ H h3{1, 2};
+ (void) new H{1, 2};
+ (void) H{1, 2};
+ }
+
+ struct memberinit {
+ H h1{1, nullptr};
+ H h2 = {1, nullptr};
+ H h3{1, 1};
+ H h4 = {1, 1}; // expected-error {{constructor is explicit}}
+ };
+}
+
+namespace PR12092 {
+
+ struct S {
+ S(const char*);
+ };
+ struct V {
+ template<typename T> V(T, T);
+ void f(std::initializer_list<S>);
+ void f(const V &);
+ };
+
+ void g() {
+ extern V s;
+ s.f({"foo", "bar"});
+ }
+
+}
+
+namespace PR12117 {
+ struct A { A(int); };
+ struct B { B(A); } b{{0}};
+ struct C { C(int); } c{0};
+}
+
+namespace PR12167 {
+ template<int N> struct string {};
+
+ struct X {
+ X(const char v);
+ template<typename T> bool operator()(T) const;
+ };
+
+ template<int N, class Comparator> bool g(const string<N>& s, Comparator cmp) {
+ return cmp(s);
+ }
+ template<int N> bool f(const string<N> &s) {
+ return g(s, X{'x'});
+ }
+
+ bool s = f(string<1>());
+}
+
+namespace PR12257_PR12241 {
+ struct command_pair
+ {
+ command_pair(int, int);
+ };
+
+ struct command_map
+ {
+ command_map(std::initializer_list<command_pair>);
+ };
+
+ struct generator_pair
+ {
+ generator_pair(const command_map);
+ };
+
+ // 5 levels: init list, gen_pair, command_map, init list, command_pair
+ const std::initializer_list<generator_pair> x = {{{{{3, 4}}}}};
+
+ // 4 levels: init list, gen_pair, command_map via init list, command_pair
+ const std::initializer_list<generator_pair> y = {{{{1, 2}}}};
+}
+
+namespace PR12120 {
+ struct A { explicit A(int); A(float); }; // expected-note {{declared here}}
+ A a = { 0 }; // expected-error {{constructor is explicit}}
+
+ struct B { explicit B(short); B(long); }; // expected-note 2 {{candidate}}
+ B b = { 0 }; // expected-error {{ambiguous}}
+}
+
+namespace PR12498 {
+ class ArrayRef; // expected-note{{forward declaration}}
+
+ struct C {
+ void foo(const ArrayRef&); // expected-note{{passing argument to parameter here}}
+ };
+
+ static void bar(C* c)
+ {
+ c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}}
+ }
+
+}
diff --git a/test/SemaCXX/cxx0x-initializer-references.cpp b/test/SemaCXX/cxx0x-initializer-references.cpp
new file mode 100644
index 0000000..d8fdd5a
--- /dev/null
+++ b/test/SemaCXX/cxx0x-initializer-references.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct one { char c; };
+struct two { char c[2]; };
+
+namespace reference {
+ struct A {
+ int i1, i2;
+ };
+
+ void single_init() {
+ const int &cri1a = {1};
+ const int &cri1b{1};
+
+ int i = 1;
+ int &ri1a = {i};
+ int &ri1b{i};
+
+ int &ri2 = {1}; // expected-error {{cannot bind to an initializer list temporary}}
+
+ A a{1, 2};
+ A &ra1a = {a};
+ A &ra1b{a};
+ }
+
+ void reference_to_aggregate() {
+ const A &ra1{1, 2};
+ A &ra2{1, 2}; // expected-error {{cannot bind to an initializer list temporary}}
+
+ const int (&arrayRef)[] = {1, 2, 3};
+ static_assert(sizeof(arrayRef) == 3 * sizeof(int), "bad array size");
+ }
+
+ struct B {
+ int i1;
+ };
+
+ void call() {
+ void f(const int&);
+ f({1});
+
+ void g(int&); // expected-note {{passing argument}}
+ g({1}); // expected-error {{cannot bind to an initializer list temporary}}
+ int i = 0;
+ g({i});
+
+ void h(const B&);
+ h({1});
+
+ void a(B&); // expected-note {{passing argument}}
+ a({1}); // expected-error {{cannot bind to an initializer list temporary}}
+ B b{1};
+ a({b});
+ }
+
+ void overloading() {
+ one f(const int&);
+ two f(const B&);
+
+ // First is identity conversion, second is user-defined conversion.
+ static_assert(sizeof(f({1})) == sizeof(one), "bad overload resolution");
+
+ one g(int&);
+ two g(const B&);
+
+ static_assert(sizeof(g({1})) == sizeof(two), "bad overload resolution");
+
+ one h(const int&);
+ two h(const A&);
+
+ static_assert(sizeof(h({1, 2})) == sizeof(two), "bad overload resolution");
+ }
+
+ void edge_cases() {
+ // FIXME: very poor error message
+ int const &b({0}); // expected-error {{could not bind}}
+ }
+
+}
+
+namespace PR12182 {
+ void f(int const(&)[3]);
+
+ void g() {
+ f({1, 2});
+ }
+}
diff --git a/test/SemaCXX/cxx0x-initializer-scalars.cpp b/test/SemaCXX/cxx0x-initializer-scalars.cpp
index 41fc219..627855e 100644
--- a/test/SemaCXX/cxx0x-initializer-scalars.cpp
+++ b/test/SemaCXX/cxx0x-initializer-scalars.cpp
@@ -1,5 +1,40 @@
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
namespace integral {
void initialization() {
@@ -12,6 +47,8 @@ namespace integral {
// FIXME: Redundant warnings.
{ const short a{100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
{ const short a = {100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
+ { if (const int a{1}) static_assert(a == 1, ""); }
+ { if (const int a = {1}) static_assert(a == 1, ""); }
}
int direct_usage() {
@@ -22,7 +59,7 @@ namespace integral {
}
void inline_init() {
- (void) int{1};
+ auto v = int{1};
(void) new int{1};
}
@@ -31,4 +68,49 @@ namespace integral {
A() : i{1} {}
};
+ void function_call() {
+ void takes_int(int);
+ takes_int({1});
+ }
+
+ void overloaded_call() {
+ one overloaded(int);
+ two overloaded(double);
+
+ static_assert(sizeof(overloaded({0})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({0.0})) == sizeof(two), "bad overload");
+
+ void ambiguous(int, double); // expected-note {{candidate}}
+ void ambiguous(double, int); // expected-note {{candidate}}
+ ambiguous({0}, {0}); // expected-error {{ambiguous}}
+
+ void emptylist(int);
+ void emptylist(int, int, int);
+ emptylist({});
+ emptylist({}, {}, {});
+ }
+
+ void edge_cases() {
+ // FIXME: very poor error message
+ int a({0}); // expected-error {{cannot initialize}}
+ (void) int({0}); // expected-error {{functional-style cast}}
+ new int({0}); // expected-error {{cannot initialize}}
+ }
+
+ void default_argument(int i = {}) {
+ }
+ struct DefaultArgument {
+ void default_argument(int i = {}) {
+ }
+ };
+}
+
+namespace PR12118 {
+ void test() {
+ one f(std::initializer_list<int>);
+ two f(int);
+
+ // to initializer_list is preferred
+ static_assert(sizeof(f({0})) == sizeof(one), "bad overload");
+ }
}
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
new file mode 100644
index 0000000..7384309
--- /dev/null
+++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// This must obviously come before the definition of std::initializer_list.
+void missing_initializerlist() {
+ auto l = {1, 2, 3, 4}; // expected-error {{std::initializer_list was not found}}
+}
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+template <typename T, typename U>
+struct same_type { static const bool value = false; };
+template <typename T>
+struct same_type<T, T> { static const bool value = true; };
+
+struct one { char c[1]; };
+struct two { char c[2]; };
+
+struct A {
+ int a, b;
+};
+
+struct B {
+ B();
+ B(int, int);
+};
+
+void simple_list() {
+ std::initializer_list<int> il = { 1, 2, 3 };
+ std::initializer_list<double> dl = { 1.0, 2.0, 3 };
+ std::initializer_list<A> al = { {1, 2}, {2, 3}, {3, 4} };
+ std::initializer_list<B> bl = { {1, 2}, {2, 3}, {} };
+}
+
+void function_call() {
+ void f(std::initializer_list<int>);
+ f({1, 2, 3});
+
+ void g(std::initializer_list<B>);
+ g({ {1, 2}, {2, 3}, {} });
+}
+
+struct C {
+ C(int);
+};
+
+struct D {
+ D();
+ operator int();
+ operator C();
+};
+
+void overloaded_call() {
+ one overloaded(std::initializer_list<int>);
+ two overloaded(std::initializer_list<B>);
+
+ static_assert(sizeof(overloaded({1, 2, 3})) == sizeof(one), "bad overload");
+ static_assert(sizeof(overloaded({ {1, 2}, {2, 3}, {} })) == sizeof(two), "bad overload");
+
+ void ambiguous(std::initializer_list<A>); // expected-note {{candidate}}
+ void ambiguous(std::initializer_list<B>); // expected-note {{candidate}}
+ ambiguous({ {1, 2}, {2, 3}, {3, 4} }); // expected-error {{ambiguous}}
+
+ one ov2(std::initializer_list<int>); // expected-note {{candidate}}
+ two ov2(std::initializer_list<C>); // expected-note {{candidate}}
+ // Worst sequence to int is identity, whereas to C it's user-defined.
+ static_assert(sizeof(ov2({1, 2, 3})) == sizeof(one), "bad overload");
+ // But here, user-defined is worst in both cases.
+ ov2({1, 2, D()}); // expected-error {{ambiguous}}
+}
+
+template <typename T>
+T deduce(std::initializer_list<T>); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}}
+template <typename T>
+T deduce_ref(const std::initializer_list<T>&); // expected-note {{conflicting types for parameter 'T' ('int' vs. 'double')}}
+
+void argument_deduction() {
+ static_assert(same_type<decltype(deduce({1, 2, 3})), int>::value, "bad deduction");
+ static_assert(same_type<decltype(deduce({1.0, 2.0, 3.0})), double>::value, "bad deduction");
+
+ deduce({1, 2.0}); // expected-error {{no matching function}}
+
+ static_assert(same_type<decltype(deduce_ref({1, 2, 3})), int>::value, "bad deduction");
+ static_assert(same_type<decltype(deduce_ref({1.0, 2.0, 3.0})), double>::value, "bad deduction");
+
+ deduce_ref({1, 2.0}); // expected-error {{no matching function}}
+}
+
+void auto_deduction() {
+ auto l = {1, 2, 3, 4};
+ static_assert(same_type<decltype(l), std::initializer_list<int>>::value, "");
+ auto bl = {1, 2.0}; // expected-error {{cannot deduce}}
+
+ for (int i : {1, 2, 3, 4}) {}
+}
+
+void dangle() {
+ new auto{1, 2, 3}; // expected-error {{cannot use list-initialization}}
+ new std::initializer_list<int>{1, 2, 3}; // expected-warning {{at the end of the full-expression}}
+}
+
+struct haslist1 {
+ std::initializer_list<int> il = {1, 2, 3}; // expected-warning{{at the end of the constructor}}
+ std::initializer_list<int> jl{1, 2, 3}; // expected-warning{{at the end of the constructor}}
+ haslist1();
+};
+
+haslist1::haslist1()
+: il{1, 2, 3} // expected-warning{{at the end of the constructor}}
+{}
+
+namespace PR12119 {
+ // Deduction with nested initializer lists.
+ template<typename T> void f(std::initializer_list<T>);
+ template<typename T> void g(std::initializer_list<std::initializer_list<T>>);
+
+ void foo() {
+ f({0, {1}});
+ g({{0, 1}, {2, 3}});
+ std::initializer_list<int> il = {1, 2};
+ g({il, {2, 3}});
+ }
+}
+
+namespace Decay {
+ template<typename T>
+ void f(std::initializer_list<T>) {
+ T x = 1; // expected-error{{cannot initialize a variable of type 'const char *' with an rvalue of type 'int'}}
+ }
+
+ void g() {
+ f({"A", "BB", "CCC"}); // expected-note{{in instantiation of function template specialization 'Decay::f<const char *>' requested here}}
+
+ auto x = { "A", "BB", "CCC" };
+ std::initializer_list<const char *> *il = &x;
+
+ for( auto s : {"A", "BB", "CCC", "DDD"}) { }
+ }
+}
+
+namespace PR12436 {
+ struct X {
+ template<typename T>
+ X(std::initializer_list<int>, T);
+ };
+
+ X x({}, 17);
+}
diff --git a/test/SemaCXX/cxx0x-nontrivial-union.cpp b/test/SemaCXX/cxx0x-nontrivial-union.cpp
index 6275af6..0e4add8 100644
--- a/test/SemaCXX/cxx0x-nontrivial-union.cpp
+++ b/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -10,9 +10,20 @@ struct non_trivial {
union u {
non_trivial nt;
};
+union u2 {
+ non_trivial nt;
+ int k;
+ u2(int k) : k(k) {}
+ u2() : nt() {}
+};
+
+union static_data_member {
+ static int i;
+};
+int static_data_member::i;
union bad {
- static int i; // expected-error {{static data member}}
+ int &i; // expected-error {{union member 'i' has reference type 'int &'}}
};
struct s {
@@ -20,3 +31,94 @@ struct s {
non_trivial nt;
};
};
+
+// Don't crash on this.
+struct TemplateCtor { template<typename T> TemplateCtor(T); };
+union TemplateCtorMember { TemplateCtor s; };
+
+template<typename T> struct remove_ref { typedef T type; };
+template<typename T> struct remove_ref<T&> { typedef T type; };
+template<typename T> struct remove_ref<T&&> { typedef T type; };
+template<typename T> T &&forward(typename remove_ref<T>::type &&t);
+template<typename T> T &&forward(typename remove_ref<T>::type &t);
+template<typename T> typename remove_ref<T>::type &&move(T &&t);
+
+using size_t = decltype(sizeof(int));
+void *operator new(size_t, void *p) noexcept { return p; }
+
+namespace disabled_dtor {
+ template<typename T>
+ union disable_dtor {
+ T val;
+ template<typename...U>
+ disable_dtor(U &&...u) : val(forward<U>(u)...) {}
+ ~disable_dtor() {}
+ };
+
+ struct deleted_dtor {
+ deleted_dtor(int n, char c) : n(n), c(c) {}
+ int n;
+ char c;
+ ~deleted_dtor() = delete;
+ };
+
+ disable_dtor<deleted_dtor> dd(4, 'x');
+}
+
+namespace optional {
+ template<typename T> struct optional {
+ bool has;
+ union { T value; };
+
+ optional() : has(false) {}
+ template<typename...U>
+ optional(U &&...u) : has(true), value(forward<U>(u)...) {}
+
+ optional(const optional &o) : has(o.has) {
+ if (has) new (&value) T(o.value);
+ }
+ optional(optional &&o) : has(o.has) {
+ if (has) new (&value) T(move(o.value));
+ }
+
+ optional &operator=(const optional &o) {
+ if (has) {
+ if (o.has)
+ value = o.value;
+ else
+ value.~T();
+ } else if (o.has) {
+ new (&value) T(o.value);
+ }
+ has = o.has;
+ }
+ optional &operator=(optional &&o) {
+ if (has) {
+ if (o.has)
+ value = move(o.value);
+ else
+ value.~T();
+ } else if (o.has) {
+ new (&value) T(move(o.value));
+ }
+ has = o.has;
+ }
+
+ ~optional() {
+ if (has)
+ value.~T();
+ }
+
+ explicit operator bool() const { return has; }
+ T &operator*() const { return value; }
+ };
+
+ optional<non_trivial> o1;
+ optional<non_trivial> o2{non_trivial()};
+ optional<non_trivial> o3{*o2};
+ void f() {
+ if (o2)
+ o1 = o2;
+ o2 = optional<non_trivial>();
+ }
+}
diff --git a/test/SemaCXX/cxx0x-return-init-list.cpp b/test/SemaCXX/cxx0x-return-init-list.cpp
index b786922..da83271 100644
--- a/test/SemaCXX/cxx0x-return-init-list.cpp
+++ b/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -1,17 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-// This test checks for a teeny tiny subset of the functionality in
-// the C++11 generalized initializer lists feature, which happens to
-// be used in libstdc++ 4.5. We accept only this syntax so that Clang
-// can handle the libstdc++ 4.5 headers.
+// Test that a very basic variation of generalized initializer returns (that
+// required for libstdc++ 4.5) is supported in C++98.
int test0(int i) {
- return { i }; // expected-warning{{generalized initializer lists are a C++11 extension unsupported in Clang}}
+ return { i }; // expected-warning{{generalized initializer lists are a C++11 extension}}
}
template<typename T, typename U>
T test1(U u) {
- return { u }; // expected-warning{{generalized initializer lists are a C++11 extension unsupported in Clang}}
+ return { u }; // expected-warning{{generalized initializer lists are a C++11 extension}}
}
template int test1(char);
diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp
new file mode 100644
index 0000000..afabf88
--- /dev/null
+++ b/test/SemaCXX/cxx11-ast-print.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s
+
+// FIXME: Print the trailing-return-type properly.
+// CHECK: decltype(nullptr) operator "" _foo(const char *p, decltype(sizeof(int)));
+auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
+
+// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+decltype(""_foo) operator"" _bar(unsigned long long);
+
+// CHECK: decltype(42_bar) operator "" _baz(long double);
+decltype(42_bar) operator"" _baz(long double);
+
+// CHECK: decltype(4.5_baz) operator "" _baz(char);
+decltype(4.5_baz) operator"" _baz(char);
+
+// CHECK: const char *operator "" _quux(const char *);
+const char *operator"" _quux(const char *);
+
+// CHECK: template <char...> const char *operator "" _fritz();
+template<char...> const char *operator"" _fritz();
+
+// CHECK: const char *p1 = "bar1"_foo;
+const char *p1 = "bar1"_foo;
+// CHECK: const char *p2 = "bar2"_foo;
+const char *p2 = R"x(bar2)x"_foo;
+// CHECK: const char *p3 = u8"bar3"_foo;
+const char *p3 = u8"bar3"_foo;
+// CHECK: const char *p4 = 297_bar;
+const char *p4 = 0x129_bar;
+// CHECK: const char *p5 = 1.0E+12_baz;
+const char *p5 = 1e12_baz;
+// CHECK: const char *p6 = 'x'_baz;
+const char *p6 = 'x'_baz;
+// CHECK: const char *p7 = 123_quux;
+const char *p7 = 123_quux;
+// CHECK: const char *p8 = 4.9_quux;
+const char *p8 = 4.9_quux;
+// CHECK: const char *p9 = 0x42e3F_fritz;
+const char *p9 = 0x42e3F_fritz;
+// CHECK: const char *p10 = 3.300e+15_fritz;
+const char *p10 = 3.300e+15_fritz;
diff --git a/test/SemaCXX/cxx11-user-defined-literals.cpp b/test/SemaCXX/cxx11-user-defined-literals.cpp
new file mode 100644
index 0000000..4bbecdb
--- /dev/null
+++ b/test/SemaCXX/cxx11-user-defined-literals.cpp
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -fms-extensions -triple x86_64-apple-darwin9.0.0
+
+using size_t = decltype(sizeof(int));
+enum class LitKind {
+ Char, WideChar, Char16, Char32,
+ CharStr, WideStr, Char16Str, Char32Str,
+ Integer, Floating, Raw, Template
+};
+constexpr LitKind operator"" _kind(char p) { return LitKind::Char; }
+constexpr LitKind operator"" _kind(wchar_t p) { return LitKind::WideChar; }
+constexpr LitKind operator"" _kind(char16_t p) { return LitKind::Char16; }
+constexpr LitKind operator"" _kind(char32_t p) { return LitKind::Char32; }
+constexpr LitKind operator"" _kind(const char *p, size_t n) { return LitKind::CharStr; }
+constexpr LitKind operator"" _kind(const wchar_t *p, size_t n) { return LitKind::WideStr; }
+constexpr LitKind operator"" _kind(const char16_t *p, size_t n) { return LitKind::Char16Str; }
+constexpr LitKind operator"" _kind(const char32_t *p, size_t n) { return LitKind::Char32Str; }
+constexpr LitKind operator"" _kind(unsigned long long n) { return LitKind::Integer; }
+constexpr LitKind operator"" _kind(long double n) { return LitKind::Floating; }
+constexpr LitKind operator"" _kind2(const char *p) { return LitKind::Raw; }
+template<char ...Cs> constexpr LitKind operator"" _kind3() { return LitKind::Template; }
+
+static_assert('x'_kind == LitKind::Char, "");
+static_assert(L'x'_kind == LitKind::WideChar, "");
+static_assert(u'x'_kind == LitKind::Char16, "");
+static_assert(U'x'_kind == LitKind::Char32, "");
+static_assert("foo"_kind == LitKind::CharStr, "");
+static_assert(u8"foo"_kind == LitKind::CharStr, "");
+static_assert(L"foo"_kind == LitKind::WideStr, "");
+static_assert(u"foo"_kind == LitKind::Char16Str, "");
+static_assert(U"foo"_kind == LitKind::Char32Str, "");
+static_assert(194_kind == LitKind::Integer, "");
+static_assert(0377_kind == LitKind::Integer, "");
+static_assert(0x5ffc_kind == LitKind::Integer, "");
+static_assert(.5954_kind == LitKind::Floating, "");
+static_assert(1._kind == LitKind::Floating, "");
+static_assert(1.e-2_kind == LitKind::Floating, "");
+static_assert(4e6_kind == LitKind::Floating, "");
+static_assert(4e6_kind2 == LitKind::Raw, "");
+static_assert(4e6_kind3 == LitKind::Template, "");
+
+constexpr const char *fractional_digits_impl(const char *p) {
+ return *p == '.' ? p + 1 : *p ? fractional_digits_impl(p + 1) : 0;
+}
+constexpr const char *operator"" _fractional_digits(const char *p) {
+ return fractional_digits_impl(p) ?: p;
+}
+constexpr bool streq(const char *p, const char *q) {
+ return *p == *q && (!*p || streq(p+1, q+1));
+}
+
+static_assert(streq(143.97_fractional_digits, "97"), "");
+static_assert(streq(0x786_fractional_digits, "0x786"), "");
+static_assert(streq(.4_fractional_digits, "4"), "");
+static_assert(streq(4._fractional_digits, ""), "");
+static_assert(streq(1e+97_fractional_digits, "1e+97"), "");
+static_assert(streq(0377_fractional_digits, "0377"), "");
+static_assert(streq(0377.5_fractional_digits, "5"), "");
+
+int operator"" _ambiguous(char); // expected-note {{candidate}}
+namespace N {
+ void *operator"" _ambiguous(char); // expected-note {{candidate}}
+}
+using namespace N;
+int k = 'x'_ambiguous; // expected-error {{ambiguous}}
+
+int operator"" _deleted(unsigned long long) = delete; // expected-note {{here}}
+int m = 42_deleted; // expected-error {{attempt to use a deleted}}
+
+namespace Using {
+ namespace M {
+ int operator"" _using(char);
+ }
+ int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator "" _using'}}
+
+ using M::operator "" _using;
+ int k2 = 'x'_using;
+}
+
+namespace AmbiguousRawTemplate {
+ int operator"" _ambig1(const char *); // expected-note {{candidate}}
+ template<char...> int operator"" _ambig1(); // expected-note {{candidate}}
+
+ int k1 = 123_ambig1; // expected-error {{call to 'operator "" _ambig1' is ambiguous}}
+
+ namespace Inner {
+ template<char...> int operator"" _ambig2(); // expected-note 3{{candidate}}
+ }
+ int operator"" _ambig2(const char *); // expected-note 3{{candidate}}
+ using Inner::operator"" _ambig2;
+
+ int k2 = 123_ambig2; // expected-error {{call to 'operator "" _ambig2' is ambiguous}}
+
+ namespace N {
+ using Inner::operator"" _ambig2;
+
+ int k3 = 123_ambig2; // ok
+
+ using AmbiguousRawTemplate::operator"" _ambig2;
+
+ int k4 = 123_ambig2; // expected-error {{ambiguous}}
+
+ namespace M {
+
+ template<char...> int operator"" _ambig2();
+
+ int k5 = 123_ambig2; // ok
+ }
+
+ int operator"" _ambig2(unsigned long long);
+
+ int k6 = 123_ambig2; // ok
+ int k7 = 123._ambig2; // expected-error {{ambiguous}}
+ }
+}
+
+constexpr unsigned mash(unsigned a) {
+ return 0x93ae27b5 * ((a >> 13) | a << 19);
+}
+template<typename=void> constexpr unsigned hash(unsigned a) { return a; }
+template<char C, char...Cs> constexpr unsigned hash(unsigned a) {
+ return hash<Cs...>(mash(a ^ mash(C)));
+}
+template<typename T, T v> struct constant { constexpr static T value = v; };
+template<char...Cs> constexpr unsigned operator"" _hash() {
+ return constant<unsigned, hash<Cs...>(0)>::value;
+}
+static_assert(0x1234_hash == 0x103eff5e, "");
+static_assert(hash<'0', 'x', '1', '2', '3', '4'>(0) == 0x103eff5e, "");
+
+// Functions and literal suffixes go in separate namespaces.
+namespace Namespace {
+ template<char...> int operator"" _x();
+ int k = _x(); // expected-error {{undeclared identifier '_x'}}
+
+ int _y(unsigned long long);
+ int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}}
+}
diff --git a/test/SemaCXX/cxx98-compat-flags.cpp b/test/SemaCXX/cxx98-compat-flags.cpp
new file mode 100644
index 0000000..6dc24be
--- /dev/null
+++ b/test/SemaCXX/cxx98-compat-flags.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Wno-bind-to-temporary-copy -Wno-unnamed-type-template-args -Wno-local-type-template-args -Werror %s
+
+template<typename T> int TemplateFn(T) { return 0; }
+void LocalTemplateArg() {
+ struct S {};
+ TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
+}
+struct {} obj_of_unnamed_type; // expected-note {{here}}
+int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // expected-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable();
+ NoViable(NoViable&); // expected-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+ };
+ struct Deleted {
+ Private p; // expected-note {{copy constructor of 'Deleted' is implicitly deleted because field 'p' has an inaccessible copy constructor}}
+ };
+
+ const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+ const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}
diff --git a/test/SemaCXX/cxx98-compat-pedantic.cpp b/test/SemaCXX/cxx98-compat-pedantic.cpp
index 2ca0ae4..00532d5 100644
--- a/test/SemaCXX/cxx98-compat-pedantic.cpp
+++ b/test/SemaCXX/cxx98-compat-pedantic.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s
// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s
// -Wc++98-compat-pedantic warns on C++11 features which we accept without a
@@ -9,3 +10,25 @@
#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}}
VA_MACRO(,x) // expected-warning {{empty macro argument list is incompatible with C++98}}
+
+; // expected-warning {{extra ';' outside of a function is incompatible with C++98}}
+
+enum Enum {
+ Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}}
+};
+
+template<typename T> struct InstantiationAfterSpecialization {};
+template<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}}
+template struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}}
+
+void *dlsym();
+void (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+void *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}}
+
+struct ConvertToInt {
+ operator int();
+};
+int *ArraySizeConversion = new int[ConvertToInt()]; // expected-warning {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}}
+
+template<typename T> class ExternTemplate {};
+extern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}}
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp
index 6a3881c..4758913 100644
--- a/test/SemaCXX/cxx98-compat.cpp
+++ b/test/SemaCXX/cxx98-compat.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+namespace std { struct type_info; }
template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
class Variadic1 {};
@@ -27,4 +30,272 @@ void Literals() {
}
template<typename T> struct S {};
-S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
+namespace TemplateParsing {
+ S<::S<void> > s; // expected-warning {{'<::' is treated as digraph '<:' (aka '[') followed by ':' in C++98}}
+ S< ::S<void>> t; // expected-warning {{consecutive right angle brackets are incompatible with C++98 (use '> >')}}
+}
+
+void Lambda() {
+ []{}(); // expected-warning {{lambda expressions are incompatible with C++98}}
+}
+
+int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ (void)int{}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \
+ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+ int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ S<int> s = {}; // ok, aggregate
+ s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}}
+}
+struct DelayedDefaultArgumentParseInitList {
+ void f(int i = {1}) { // expected-warning {{generalized initializer lists are incompatible with C++98}}
+ }
+};
+
+int operator"" _hello(const char *); // expected-warning {{literal operators are incompatible with C++98}}
+
+enum EnumFixed : int { // expected-warning {{enumeration types with a fixed underlying type are incompatible with C++98}}
+};
+
+enum class EnumScoped { // expected-warning {{scoped enumerations are incompatible with C++98}}
+};
+
+void Deleted() = delete; // expected-warning {{deleted function definitions are incompatible with C++98}}
+struct Defaulted {
+ Defaulted() = default; // expected-warning {{defaulted function definitions are incompatible with C++98}}
+};
+
+int &&RvalueReference = 0; // expected-warning {{rvalue references are incompatible with C++98}}
+struct RefQualifier {
+ void f() &; // expected-warning {{reference qualifiers on functions are incompatible with C++98}}
+};
+
+auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
+
+void RangeFor() {
+ int xs[] = {1, 2, 3};
+ for (int &a : xs) { // expected-warning {{range-based for loop is incompatible with C++98}}
+ }
+}
+
+struct InClassInit {
+ int n = 0; // expected-warning {{in-class initialization of non-static data members is incompatible with C++98}}
+};
+
+struct OverrideControlBase {
+ virtual void f();
+ virtual void g();
+};
+struct OverrideControl final : OverrideControlBase { // expected-warning {{'final' keyword is incompatible with C++98}}
+ virtual void f() override; // expected-warning {{'override' keyword is incompatible with C++98}}
+ virtual void g() final; // expected-warning {{'final' keyword is incompatible with C++98}}
+};
+
+using AliasDecl = int; // expected-warning {{alias declarations are incompatible with C++98}}
+template<typename T> using AliasTemplate = T; // expected-warning {{alias declarations are incompatible with C++98}}
+
+inline namespace InlineNS { // expected-warning {{inline namespaces are incompatible with C++98}}
+}
+
+auto auto_deduction = 0; // expected-warning {{'auto' type specifier is incompatible with C++98}}
+int *p = new auto(0); // expected-warning {{'auto' type specifier is incompatible with C++98}}
+
+const int align_of = alignof(int); // expected-warning {{alignof expressions are incompatible with C++98}}
+char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatible with C++98}}
+char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}}
+constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}}
+decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}}
+__decltype(const_expr) decl_type2 = 0; // ok
+void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
+bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}}
+void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
+static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
+
+struct InhCtorBase {
+ InhCtorBase(int);
+};
+struct InhCtorDerived : InhCtorBase {
+ using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}}
+};
+
+struct FriendMember {
+ static void MemberFn();
+ friend void FriendMember::MemberFn(); // expected-warning {{friend declaration naming a member of the declaring class is incompatible with C++98}}
+};
+
+struct DelegCtor {
+ DelegCtor(int) : DelegCtor() {} // expected-warning {{delegating constructors are incompatible with C++98}}
+ DelegCtor();
+};
+
+template<int n = 0> void DefaultFuncTemplateArg(); // expected-warning {{default template arguments for a function template are incompatible with C++98}}
+
+template<typename T> int TemplateFn(T) { return 0; }
+void LocalTemplateArg() {
+ struct S {};
+ TemplateFn(S()); // expected-warning {{local type 'S' as template argument is incompatible with C++98}}
+}
+struct {} obj_of_unnamed_type; // expected-note {{here}}
+int UnnamedTemplateArg = TemplateFn(obj_of_unnamed_type); // expected-warning {{unnamed type as template argument is incompatible with C++98}}
+
+namespace RedundantParensInAddressTemplateParam {
+ int n;
+ template<int*p> struct S {};
+ S<(&n)> s; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
+ S<(((&n)))> t; // expected-warning {{redundant parentheses surrounding address non-type template argument are incompatible with C++98}}
+}
+
+namespace TemplateSpecOutOfScopeNs {
+ template<typename T> struct S {}; // expected-note {{here}}
+}
+template<> struct TemplateSpecOutOfScopeNs::S<char> {}; // expected-warning {{class template specialization of 'S' outside namespace 'TemplateSpecOutOfScopeNs' is incompatible with C++98}}
+
+struct Typename {
+ template<typename T> struct Inner {};
+};
+typename ::Typename TypenameOutsideTemplate(); // expected-warning {{use of 'typename' outside of a template is incompatible with C++98}}
+Typename::template Inner<int> TemplateOutsideTemplate(); // expected-warning {{use of 'template' keyword outside of a template is incompatible with C++98}}
+
+struct TrivialButNonPOD {
+ int f(int);
+private:
+ int k;
+};
+void Ellipsis(int n, ...);
+void TrivialButNonPODThroughEllipsis() {
+ Ellipsis(1, TrivialButNonPOD()); // expected-warning {{passing object of trivial but non-POD type 'TrivialButNonPOD' through variadic function is incompatible with C++98}}
+}
+
+struct HasExplicitConversion {
+ explicit operator bool(); // expected-warning {{explicit conversion functions are incompatible with C++98}}
+};
+
+struct Struct {};
+enum Enum { enum_val = 0 };
+struct BadFriends {
+ friend enum ::Enum; // expected-warning {{befriending enumeration type 'enum ::Enum' is incompatible with C++98}}
+ friend int; // expected-warning {{non-class friend type 'int' is incompatible with C++98}}
+ friend Struct; // expected-warning {{befriending 'Struct' without 'struct' keyword is incompatible with C++98}}
+};
+
+int n = {}; // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}}
+
+class PrivateMember {
+ struct ImPrivate {};
+};
+template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}} expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
+ return typename T::ImPrivate();
+}
+int SFINAEAccessControl(...) { return 0; }
+int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember());
+
+template<typename T>
+struct FriendRedefinition {
+ friend void Friend() {} // expected-warning {{friend function 'Friend' would be implicitly redefined in C++98}} expected-note {{previous}}
+};
+FriendRedefinition<int> FriendRedef1;
+FriendRedefinition<char> FriendRedef2; // expected-note {{requested here}}
+
+namespace CopyCtorIssues {
+ struct Private {
+ Private();
+ private:
+ Private(const Private&); // expected-note {{declared private here}}
+ };
+ struct NoViable {
+ NoViable();
+ NoViable(NoViable&); // expected-note {{not viable}}
+ };
+ struct Ambiguous {
+ Ambiguous();
+ Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
+ Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
+ };
+ struct Deleted {
+ Private p; // expected-note {{implicitly deleted}}
+ };
+
+ const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+ const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}}
+ const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}}
+ const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}}
+}
+
+namespace UnionOrAnonStructMembers {
+ struct NonTrivCtor {
+ NonTrivCtor(); // expected-note 2{{user-declared constructor}}
+ };
+ struct NonTrivCopy {
+ NonTrivCopy(const NonTrivCopy&); // expected-note 2{{user-declared copy constructor}}
+ };
+ struct NonTrivDtor {
+ ~NonTrivDtor(); // expected-note 2{{user-declared destructor}}
+ };
+ union BadUnion {
+ NonTrivCtor ntc; // expected-warning {{union member 'ntc' with a non-trivial constructor is incompatible with C++98}}
+ NonTrivCopy ntcp; // expected-warning {{union member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
+ NonTrivDtor ntd; // expected-warning {{union member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ };
+ struct Wrap {
+ struct {
+ NonTrivCtor ntc; // expected-warning {{anonymous struct member 'ntc' with a non-trivial constructor is incompatible with C++98}}
+ NonTrivCopy ntcp; // expected-warning {{anonymous struct member 'ntcp' with a non-trivial copy constructor is incompatible with C++98}}
+ NonTrivDtor ntd; // expected-warning {{anonymous struct member 'ntd' with a non-trivial destructor is incompatible with C++98}}
+ };
+ };
+ union WithStaticDataMember {
+ static constexpr double d = 0.0; // expected-warning {{static data member 'd' in union is incompatible with C++98}} expected-warning {{'constexpr' specifier is incompatible with C++98}}
+ static const int n = 0; // expected-warning {{static data member 'n' in union is incompatible with C++98}}
+ static int k; // expected-warning {{static data member 'k' in union is incompatible with C++98}}
+ };
+}
+
+int EnumNNS = Enum::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+template<typename T> void EnumNNSFn() {
+ int k = T::enum_val; // expected-warning {{enumeration type in nested name specifier is incompatible with C++98}}
+};
+template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
+
+void JumpDiagnostics(int n) {
+ goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}}
+ TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
+
+DirectJump:
+ void *Table[] = {&&DirectJump, &&Later};
+ goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}}
+
+ TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
+Later: // expected-note {{possible target of indirect goto}}
+ switch (n) {
+ TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
+ default: // expected-warning {{switch case would be in a protected scope in C++98}}
+ return;
+ }
+}
+
+namespace UnevaluatedMemberAccess {
+ struct S {
+ int n;
+ int f() { return sizeof(S::n); } // ok
+ };
+ int k = sizeof(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+ const std::type_info &ti = typeid(S::n); // expected-warning {{use of non-static data member 'n' in an unevaluated context is incompatible with C++98}}
+}
+
+namespace LiteralUCNs {
+ char c1 = '\u001e'; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
+ wchar_t c2 = L'\u0041'; // expected-warning {{specifying character 'A' with a universal character name is incompatible with C++98}}
+ const char *s1 = "foo\u0031"; // expected-warning {{specifying character '1' with a universal character name is incompatible with C++98}}
+ const wchar_t *s2 = L"bar\u0085"; // expected-warning {{universal character name referring to a control character is incompatible with C++98}}
+}
+
+namespace NonTypeTemplateArgs {
+ template<typename T, T v> struct S {};
+ const int k = 5; // expected-note {{here}}
+ static void f() {} // expected-note {{here}}
+ S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}}
+ S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
+}
diff --git a/test/SemaCXX/dcl_init_aggr.cpp b/test/SemaCXX/dcl_init_aggr.cpp
index 2dbd381..bd3de9e 100644
--- a/test/SemaCXX/dcl_init_aggr.cpp
+++ b/test/SemaCXX/dcl_init_aggr.cpp
@@ -80,7 +80,7 @@ struct HasReference {
};
int global_int;
HasReference r1 = { 1, global_int };
-HasReference r2 = { 1 } ; // expected-error{{initialization leaves reference member of type 'int &' uninitialized}}
+HasReference r2 = { 1 } ; // expected-error{{reference member of type 'int &' uninitialized}}
// C++ [dcl.init.aggr]p10
// Note: the behavior here is identical to C
diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp
index 1ddff80..6f4d08c 100644
--- a/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic-errors %s
void f() {
int a;
@@ -24,14 +24,43 @@ void f() {
// Declarations.
int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}}
T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}}
+ typedef T(*td)(int(p));
+ extern T(*tp)(int(p));
+ T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+ T d3v(void);
+ typedef T d3t();
+ extern T f3();
+ __typeof(*T()) f4(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
+ typedef void *V;
+ __typeof(*V()) f5();
+ T multi1,
+ multi2(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}}
T(d)[5]; // expected-error {{redefinition of 'd'}}
typeof(int[])(f) = { 1, 2 }; // expected-error {{extension used}}
void(b)(int);
- int(d2) __attribute__(());
+ int(d2) __attribute__(());
if (int(a)=1) {}
int(d3(int()));
}
+struct RAII {
+ RAII();
+ ~RAII();
+};
+
+void func();
+namespace N {
+ struct S;
+
+ void emptyParens() {
+ RAII raii(); // expected-warning {{function declaration}} expected-note {{remove parentheses to declare a variable}}
+ int a, b, c, d, e, // expected-note {{change this ',' to a ';' to call 'func'}}
+ func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
+
+ S s(); // expected-warning {{function declaration}}
+ }
+}
+
class C { };
void fn(int(C)) { } // void fn(int(*fp)(C c)) { } expected-note{{candidate function}}
// not: void fn(int C);
diff --git a/test/SemaCXX/decltype-crash.cpp b/test/SemaCXX/decltype-crash.cpp
index 50b3e49..002bd4c 100644
--- a/test/SemaCXX/decltype-crash.cpp
+++ b/test/SemaCXX/decltype-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
int& a();
diff --git a/test/SemaCXX/decltype.cpp b/test/SemaCXX/decltype.cpp
index 78fb8ef..a1200e0 100644
--- a/test/SemaCXX/decltype.cpp
+++ b/test/SemaCXX/decltype.cpp
@@ -20,4 +20,11 @@ namespace pr10154 {
class A{
A(decltype(nullptr) param);
};
-} \ No newline at end of file
+}
+
+template<typename T> struct S {};
+template<typename T> auto f(T t) -> decltype(S<int>(t)) {
+ using U = decltype(S<int>(t));
+ using U = S<int>;
+ return S<int>(t);
+}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index e9d8a2f..ae6ef97 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -32,3 +32,21 @@ void k(Y y = 17); // expected-error{{no viable conversion}} \
void kk(Y = 17); // expected-error{{no viable conversion}} \
// expected-note{{passing argument to parameter here}}
+
+int l () {
+ int m(int i, int j, int k = 3);
+ if (1)
+ {
+ int m(int i, int j = 2, int k = 4);
+ m(8);
+ }
+ return 0;
+}
+
+int i () {
+ void j (int f = 4);
+ {
+ void j (int f); // expected-note{{'j' declared here}}
+ j(); // expected-error{{too few arguments to function call, expected 1, have 0}}
+ }
+}
diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp
index 2076322..1626044 100644
--- a/test/SemaCXX/default2.cpp
+++ b/test/SemaCXX/default2.cpp
@@ -28,7 +28,7 @@ void g(int x, int y = x); // expected-error {{default argument references parame
void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
class X {
- void f(X* x = this); // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+ void f(X* x = this); // expected-error{{invalid use of 'this' outside of a non-static member function}}
void g() {
int f(X* x = this); // expected-error{{default argument references 'this'}}
@@ -55,7 +55,7 @@ void C::h() {
// C++ [dcl.fct.default]p9
struct Y {
int a;
- int mem1(int i = a); // expected-error{{invalid use of nonstatic data member 'a'}}
+ int mem1(int i = a); // expected-error{{invalid use of non-static data member 'a'}}
int mem2(int i = b); // OK; use Y::b
int mem3(int i);
int mem4(int i);
@@ -64,8 +64,8 @@ struct Y {
int mem5(int i = b, // OK; use Y::b
int j = c, // OK; use Y::Nested::c
int k = j, // expected-error{{default argument references parameter 'j'}}
- int l = a, // expected-error{{invalid use of nonstatic data member 'a'}}
- Nested* self = this, // expected-error{{invalid use of 'this' outside of a nonstatic member function}}
+ int l = a, // expected-error{{invalid use of non-static data member 'a'}}
+ Nested* self = this, // expected-error{{invalid use of 'this' outside of a non-static member function}}
int m); // expected-error{{missing default argument on parameter 'm'}}
static int c;
Nested(int i = 42);
@@ -78,7 +78,7 @@ struct Y {
int Y::mem3(int i = b) { return i; } // OK; use X::b
-int Y::mem4(int i = a) // expected-error{{invalid use of nonstatic data member 'a'}}
+int Y::mem4(int i = a) // expected-error{{invalid use of non-static data member 'a'}}
{ return i; }
diff --git a/test/SemaCXX/defaulted-private-dtor.cpp b/test/SemaCXX/defaulted-private-dtor.cpp
new file mode 100644
index 0000000..e6f9555
--- /dev/null
+++ b/test/SemaCXX/defaulted-private-dtor.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions
+
+class BadDtor {
+ // A private, but nonetheless trivial, destructor.
+ ~BadDtor() = default; // expected-note 9{{here}}
+ friend class K;
+};
+void f() {
+ BadDtor *p = new BadDtor[3]; // expected-error {{private destructor}}
+ delete [] p; // expected-error {{private destructor}}
+ const BadDtor &dd2 = BadDtor(); // expected-error {{private destructor}}
+ BadDtor dd; // expected-error {{private destructor}}
+ throw dd; // expected-error {{private destructor}}
+}
+struct V {
+ V();
+ BadDtor bd; // expected-note {{inaccessible destructor}}
+};
+V v; // expected-error {{deleted function}}
+struct W : BadDtor { // expected-note {{inaccessible destructor}}
+ W();
+};
+W w; // expected-error {{deleted function}}
+struct X : BadDtor { // expected-error {{private destructor}}
+ ~X() {}
+};
+struct Y {
+ BadDtor dd; // expected-error {{private destructor}}
+ ~Y() {}
+};
+struct Z : virtual BadDtor { // expected-error {{private destructor}}
+ ~Z() {}
+};
+BadDtor dd; // expected-error {{private destructor}}
+
+class K : BadDtor {
+ void f() {
+ BadDtor *p = new BadDtor[3];
+ delete [] p;
+ const BadDtor &dd2 = BadDtor();
+ BadDtor dd;
+ throw dd;
+
+ {
+ BadDtor x;
+ goto dont_call_dtor;
+ }
+dont_call_dtor:
+ ;
+ }
+ struct Z : virtual BadDtor {
+ ~Z() {}
+ };
+ BadDtor dd;
+ ~K();
+};
diff --git a/test/SemaCXX/deleted-function.cpp b/test/SemaCXX/deleted-function.cpp
index 4620a19..d13fd0e 100644
--- a/test/SemaCXX/deleted-function.cpp
+++ b/test/SemaCXX/deleted-function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
int i = delete; // expected-error {{only functions can have deleted definitions}}
@@ -33,3 +33,25 @@ void test() {
d->fn(); // expected-error {{attempt to use a deleted function}}
int i = *d; // expected-error {{invokes a deleted function}}
}
+
+struct DelDtor {
+ ~DelDtor() = delete; // expected-note 9{{here}}
+};
+void f() {
+ DelDtor *p = new DelDtor[3]; // expected-error {{attempt to use a deleted function}}
+ delete [] p; // expected-error {{attempt to use a deleted function}}
+ const DelDtor &dd2 = DelDtor(); // expected-error {{attempt to use a deleted function}}
+ DelDtor dd; // expected-error {{attempt to use a deleted function}}
+ throw dd; // expected-error {{attempt to use a deleted function}}
+}
+struct X : DelDtor {
+ ~X() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Y {
+ DelDtor dd;
+ ~Y() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Z : virtual DelDtor {
+ ~Z() {} // expected-error {{attempt to use a deleted function}}
+};
+DelDtor dd; // expected-error {{attempt to use a deleted function}}
diff --git a/test/SemaCXX/deleted-operator.cpp b/test/SemaCXX/deleted-operator.cpp
index e357401..0e0282a 100644
--- a/test/SemaCXX/deleted-operator.cpp
+++ b/test/SemaCXX/deleted-operator.cpp
@@ -11,3 +11,8 @@ int PR10757f() {
if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}}
if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}}
}
+
+struct DelOpDel {
+ virtual ~DelOpDel() {} // expected-error {{deleted function}}
+ void operator delete(void*) = delete; // expected-note {{deleted here}}
+};
diff --git a/test/SemaCXX/dependent-auto.cpp b/test/SemaCXX/dependent-auto.cpp
index 1be1566..6d37f7a 100644
--- a/test/SemaCXX/dependent-auto.cpp
+++ b/test/SemaCXX/dependent-auto.cpp
@@ -8,7 +8,7 @@ struct only {
template<typename ...T>
void f(T ...t) {
- auto x(t...); // expected-error {{requires an initializer}} expected-error {{contains multiple expressions}}
+ auto x(t...); // expected-error {{is empty}} expected-error {{contains multiple expressions}}
only<int> check = x;
}
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 14a0cda..f3c6ab0 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -16,7 +16,7 @@ public:
struct D {
static void ~D(int, ...) const { } // \
- // expected-error{{type qualifier is not allowed on this function}} \
+ // expected-error{{static member function cannot have 'const' qualifier}} \
// expected-error{{destructor cannot be declared 'static'}} \
// expected-error{{destructor cannot have any parameters}} \
// expected-error{{destructor cannot be variadic}} \
diff --git a/test/SemaCXX/discrim-union.cpp b/test/SemaCXX/discrim-union.cpp
new file mode 100644
index 0000000..15c9a22
--- /dev/null
+++ b/test/SemaCXX/discrim-union.cpp
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -fcxx-exceptions
+
+template<typename T> struct remove_reference { typedef T type; };
+template<typename T> struct remove_reference<T&> { typedef T type; };
+template<typename T> struct remove_reference<T&&> { typedef T type; };
+
+template<typename T> constexpr T &&forward(typename remove_reference<T>::type &t) noexcept { return static_cast<T&&>(t); }
+template<typename T> constexpr T &&forward(typename remove_reference<T>::type &&t) noexcept { return static_cast<T&&>(t); }
+template<typename T> constexpr typename remove_reference<T>::type &&move(T &&t) noexcept { return static_cast<typename remove_reference<T>::type&&>(t); }
+
+template<typename T> T declval() noexcept;
+
+namespace detail {
+ template<unsigned N> struct select {}; // : integral_constant<unsigned, N> {};
+ template<typename T> struct type {};
+
+ template<typename...T> union either_impl;
+
+ template<> union either_impl<> {
+ void get(...);
+ void destroy(...) { throw "logic_error"; }
+ };
+
+ template<typename T, typename...Ts> union either_impl<T, Ts...> {
+ private:
+ T val;
+ either_impl<Ts...> rest;
+ typedef either_impl<Ts...> rest_t;
+
+ public:
+ constexpr either_impl(select<0>, T &&t) : val(move(t)) {}
+
+ template<unsigned N, typename U>
+ constexpr either_impl(select<N>, U &&u) : rest(select<N-1>(), move(u)) {}
+
+ constexpr static unsigned index(type<T>) { return 0; }
+ template<typename U>
+ constexpr static unsigned index(type<U> t) {
+ return decltype(rest)::index(t) + 1;
+ }
+
+ void destroy(unsigned elem) {
+ if (elem)
+ rest.destroy(elem - 1);
+ else
+ val.~T();
+ }
+
+ constexpr const T &get(select<0>) { return val; }
+ template<unsigned N> constexpr const decltype(static_cast<const rest_t&>(rest).get(select<N-1>{})) get(select<N>) {
+ return rest.get(select<N-1>{});
+ }
+ };
+}
+
+template<typename T>
+struct a {
+ T value;
+ template<typename...U>
+ constexpr a(U &&...u) : value{forward<U>(u)...} {}
+};
+template<typename T> using an = a<T>;
+
+template<typename T, typename U> T throw_(const U &u) { throw u; }
+
+template<typename...T>
+class either {
+ unsigned elem;
+ detail::either_impl<T...> impl;
+ typedef decltype(impl) impl_t;
+
+public:
+ template<typename U>
+ constexpr either(a<U> &&t) :
+ elem(impl_t::index(detail::type<U>())),
+ impl(detail::select<impl_t::index(detail::type<U>())>(), move(t.value)) {}
+
+ // Destruction disabled to allow use in a constant expression.
+ // FIXME: declare a destructor iff any element has a nontrivial destructor
+ //~either() { impl.destroy(elem); }
+
+ constexpr unsigned index() noexcept { return elem; }
+
+ template<unsigned N> using const_get_result =
+ decltype(static_cast<const impl_t&>(impl).get(detail::select<N>{}));
+
+ template<unsigned N>
+ constexpr const_get_result<N> get() {
+ // Can't just use throw here, since that makes the conditional a prvalue,
+ // which means we return a reference to a temporary.
+ return (elem != N ? throw_<const_get_result<N>>("bad_either_get")
+ : impl.get(detail::select<N>{}));
+ }
+
+ template<typename U>
+ constexpr const U &get() {
+ return get<impl_t::index(detail::type<U>())>();
+ }
+};
+
+typedef either<int, char, double> icd;
+constexpr icd icd1 = an<int>(4);
+constexpr icd icd2 = a<char>('x');
+constexpr icd icd3 = a<double>(6.5);
+
+static_assert(icd1.get<int>() == 4, "");
+static_assert(icd2.get<char>() == 'x', "");
+static_assert(icd3.get<double>() == 6.5, "");
+
+struct non_triv {
+ constexpr non_triv() : n(5) {}
+ int n;
+};
+constexpr either<const icd*, non_triv> icd4 = a<const icd*>(&icd2);
+constexpr either<const icd*, non_triv> icd5 = a<non_triv>();
+
+static_assert(icd4.get<const icd*>()->get<char>() == 'x', "");
+static_assert(icd5.get<non_triv>().n == 5, "");
diff --git a/test/SemaCXX/dr1301.cpp b/test/SemaCXX/dr1301.cpp
new file mode 100644
index 0000000..ec0db74
--- /dev/null
+++ b/test/SemaCXX/dr1301.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+struct A { // expected-note 2{{candidate}}
+ A(int); // expected-note {{candidate}}
+ int n;
+};
+int a = A().n; // expected-error {{no matching constructor}}
+
+struct B {
+ B() = delete; // expected-note 3{{here}}
+ int n;
+};
+int b = B().n; // expected-error {{call to deleted}}
+
+struct C {
+ B b; // expected-note {{deleted default constructor}}
+};
+int c = C().b.n; // expected-error {{call to implicitly-deleted default}}
+
+struct D {
+ D() = default; // expected-note {{here}}
+ B b; // expected-note {{'b' has a deleted default constructor}}
+};
+int d = D().b.n; // expected-error {{call to implicitly-deleted default}}
+
+struct E {
+ E() = default;
+ int n;
+};
+int e = E().n; // ok
+
+struct F {
+ F();
+ int n;
+};
+int f = F().n; // ok
+
+union G {
+ F f; // expected-note {{non-trivial default constructor}}
+};
+int g = G().f.n; // expected-error {{call to implicitly-deleted default}}
+
+struct H {
+ int n;
+private:
+ H(); // expected-note {{here}}
+};
+int h = H().n; // expected-error {{private constructor}}
+
+struct I {
+ H h; // expected-note {{inaccessible default constructor}}
+};
+int i = I().h.n; // expected-error {{call to implicitly-deleted default}}
+
+struct J {
+ J();
+ virtual int f();
+ int n;
+};
+int j1 = J().n; // ok
+int j2 = J().f(); // ok
+
+union K {
+ J j; // expected-note 2{{non-trivial default constructor}}
+ int m;
+};
+int k1 = K().j.n; // expected-error {{call to implicitly-deleted default}}
+int k2 = K().j.f(); // expected-error {{call to implicitly-deleted default}}
diff --git a/test/SemaCXX/empty-class-layout.cpp b/test/SemaCXX/empty-class-layout.cpp
index 0b46bf0..c68f2bb 100644
--- a/test/SemaCXX/empty-class-layout.cpp
+++ b/test/SemaCXX/empty-class-layout.cpp
@@ -144,3 +144,14 @@ struct B : Empty, A { };
SA(0, sizeof(B) == 16);
}
+
+namespace Test7 {
+ // Make sure we reserve enough space for both bases; PR11745.
+ struct Empty { };
+ struct Base1 : Empty { };
+ struct Base2 : Empty { };
+ struct Test : Base1, Base2 {
+ char c;
+ };
+ SA(0, sizeof(Test) == 2);
+}
diff --git a/test/SemaCXX/enum-bitfield.cpp b/test/SemaCXX/enum-bitfield.cpp
index 1a65740..63445ca 100644
--- a/test/SemaCXX/enum-bitfield.cpp
+++ b/test/SemaCXX/enum-bitfield.cpp
@@ -14,5 +14,5 @@ struct X {
struct Y {
enum E : int(2);
- enum E : Z(); // expected-error{{not an integer constant}}
+ enum E : Z(); // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'Z'}}
};
diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp
index 35ba1b4..ebe9245 100644
--- a/test/SemaCXX/enum-scoped.cpp
+++ b/test/SemaCXX/enum-scoped.cpp
@@ -34,12 +34,12 @@ int a1[Val2];
int a2[E1::Val1]; // expected-error{{size of array has non-integer type}}
int* p1 = new int[Val2];
-int* p2 = new int[E1::Val1]; // FIXME Expected-error{{must have integral}}
+int* p2 = new int[E1::Val1]; // expected-error{{array size expression must have integral or unscoped enumeration type, not 'E1'}}
enum class E4 {
e1 = -2147483648, // ok
e2 = 2147483647, // ok
- e3 = 2147483648 // expected-error{{value is not representable}}
+ e3 = 2147483648 // expected-error{{enumerator value evaluates to 2147483648, which cannot be narrowed to type 'int'}}
};
enum class E5 {
@@ -142,3 +142,106 @@ namespace test6 {
(void) A::e; // expected-error {{incomplete type 'test6::A' named in nested name specifier}}
}
}
+
+namespace PR11484 {
+ const int val = 104;
+ enum class test1 { owner_dead = val, };
+}
+
+namespace N2764 {
+ enum class E { a, b };
+ enum E x1 = E::a; // ok
+ enum class E x2 = E::a; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}}
+
+ enum F { a, b };
+ enum F y1 = a; // ok
+ enum class F y2 = a; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
+
+ struct S {
+ friend enum class E; // expected-error {{reference to scoped enumeration must use 'enum' not 'enum class'}}
+ friend enum class F; // expected-error {{reference to enumeration must use 'enum' not 'enum class'}}
+
+ friend enum G {}; // expected-error {{forward reference}} expected-error {{cannot define a type in a friend declaration}}
+ friend enum class H {}; // expected-error {{cannot define a type in a friend declaration}}
+
+ enum A : int;
+ A a;
+ } s;
+
+ enum S::A : int {};
+
+ enum class B;
+}
+
+enum class N2764::B {};
+
+namespace PR12106 {
+ template<typename E> struct Enum {
+ Enum() : m_e(E::Last) {}
+ E m_e;
+ };
+
+ enum eCOLORS { Last };
+ Enum<eCOLORS> e;
+}
+
+namespace test7 {
+ enum class E { e = (struct S*)0 == (struct S*)0 };
+ S *p;
+}
+
+namespace test8 {
+ template<typename T> struct S {
+ enum A : int; // expected-note {{here}}
+ enum class B; // expected-note {{here}}
+ enum class C : int; // expected-note {{here}}
+ enum class D : int; // expected-note {{here}}
+ };
+ template<typename T> enum S<T>::A { a }; // expected-error {{previously declared with fixed underlying type}}
+ template<typename T> enum class S<T>::B : char { b }; // expected-error {{redeclared with different underlying}}
+ template<typename T> enum S<T>::C : int { c }; // expected-error {{previously declared as scoped}}
+ template<typename T> enum class S<T>::D : char { d }; // expected-error {{redeclared with different underlying}}
+}
+
+namespace test9 {
+ template<typename T> struct S {
+ enum class ET : T; // expected-note 2{{here}}
+ enum class Eint : int; // expected-note 2{{here}}
+ };
+ template<> enum class S<int>::ET : int {};
+ template<> enum class S<char>::ET : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<int>::Eint : short {}; // expected-error {{different underlying type}}
+ template<> enum class S<char>::Eint : int {};
+
+ template<typename T> enum class S<T>::ET : int {}; // expected-error {{different underlying type 'int' (was 'short')}}
+ template<typename T> enum class S<T>::Eint : T {}; // expected-error {{different underlying type 'short' (was 'int')}}
+
+ // The implicit instantiation of S<short> causes the implicit instantiation of
+ // all declarations of member enumerations, so is ill-formed, even though we
+ // never instantiate the definitions of S<short>::ET nor S<short>::Eint.
+ S<short> s; // expected-note {{in instantiation of}}
+}
+
+namespace test10 {
+ template<typename T> int f() {
+ enum E : int;
+ enum E : T; // expected-note {{here}}
+ E x;
+ enum E : int { e }; // expected-error {{different underlying}}
+ x = e;
+ return x;
+ }
+ int k = f<int>();
+ int l = f<short>(); // expected-note {{here}}
+
+ template<typename T> int g() {
+ enum class E : int;
+ enum class E : T; // expected-note {{here}}
+ E x;
+ enum class E : int { e }; // expected-error {{different underlying}}
+ x = E::e;
+ return (int)x;
+ }
+ int m = g<int>();
+ int n = g<short>(); // expected-note {{here}}
+}
diff --git a/test/SemaCXX/enum-unscoped-nonexistent.cpp b/test/SemaCXX/enum-unscoped-nonexistent.cpp
new file mode 100644
index 0000000..d49800c
--- /dev/null
+++ b/test/SemaCXX/enum-unscoped-nonexistent.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+struct Base {
+ static const int a = 1;
+};
+template<typename T> struct S : Base {
+ enum E : int;
+ constexpr int f();
+ constexpr int g(); // expected-note {{declared here}}
+ void h();
+};
+template<> enum S<char>::E : int {}; // expected-note {{enum 'S<char>::E' was explicitly specialized here}}
+template<> enum S<short>::E : int { b = 2 };
+template<> enum S<int>::E : int { a = 4 };
+template<typename T> enum S<T>::E : int { b = 8 };
+
+// The unqualified-id here names a member of the non-dependent base class Base
+// and not the injected enumerator name 'a' from the specialization.
+template<typename T> constexpr int S<T>::f() { return a; }
+static_assert(S<char>().f() == 1, "");
+static_assert(S<int>().f() == 1, "");
+
+// The unqualified-id here names a member of the current instantiation, which
+// bizarrely might not exist in some instantiations.
+template<typename T> constexpr int S<T>::g() { return b; } // expected-error {{enumerator 'b' does not exist in instantiation of 'S<char>'}}
+static_assert(S<char>().g() == 1, ""); // expected-note {{here}} expected-error {{not an integral constant expression}} expected-note {{undefined}}
+static_assert(S<short>().g() == 2, "");
+static_assert(S<long>().g() == 8, "");
+
+// 'b' is type-dependent, so these assertions should not fire before 'h' is
+// instantiated.
+template<typename T> void S<T>::h() {
+ char c[S<T>::b];
+ static_assert(b != 8, "");
+ static_assert(sizeof(c) != 8, "");
+}
+void f() {
+ S<short>().h(); // ok, b == 2
+}
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index b4a050c..370e1c3 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -88,7 +88,7 @@ typedef enum { }; // expected-warning{{typedef requires a name}}
// PR7921
enum PR7921E {
- PR7921V = (PR7921E)(123) // expected-error {{expression is not an integer constant expression}}
+ PR7921V = (PR7921E)(123) // expected-error {{expression is not an integral constant expression}}
};
void PR8089() {
diff --git a/test/SemaCXX/exceptions.cpp b/test/SemaCXX/exceptions.cpp
index e2bfe18..486d88e 100644
--- a/test/SemaCXX/exceptions.cpp
+++ b/test/SemaCXX/exceptions.cpp
@@ -12,8 +12,8 @@ void trys() {
} catch(float i) {
} catch(void v) { // expected-error {{cannot catch incomplete type 'void'}}
} catch(A a) { // expected-error {{cannot catch incomplete type 'A'}}
- } catch(A *a) { // expected-warning {{ISO C++ forbids catching a pointer to incomplete type 'A'}}
- } catch(A &a) { // expected-warning {{ISO C++ forbids catching a reference to incomplete type 'A'}}
+ } catch(A *a) { // expected-error {{cannot catch pointer to incomplete type 'A'}}
+ } catch(A &a) { // expected-error {{cannot catch reference to incomplete type 'A'}}
} catch(Abstract) { // expected-error {{variable type 'Abstract' is an abstract class}}
} catch(...) {
int j = i; // expected-error {{use of undeclared identifier 'i'}}
@@ -35,37 +35,37 @@ void throws() {
void jumps() {
l1:
goto l5;
- goto l4; // expected-error {{illegal goto into protected scope}}
- goto l3; // expected-error {{illegal goto into protected scope}}
- goto l2; // expected-error {{illegal goto into protected scope}}
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
goto l1;
try { // expected-note 4 {{jump bypasses initialization of try block}}
l2:
goto l5;
- goto l4; // expected-error {{illegal goto into protected scope}}
- goto l3; // expected-error {{illegal goto into protected scope}}
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
goto l2;
goto l1;
} catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
l3:
goto l5;
- goto l4; // expected-error {{illegal goto into protected scope}}
+ goto l4; // expected-error {{goto into protected scope}}
goto l3;
- goto l2; // expected-error {{illegal goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
goto l1;
} catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
l4:
goto l5;
goto l4;
- goto l3; // expected-error {{illegal goto into protected scope}}
- goto l2; // expected-error {{illegal goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
goto l1;
}
l5:
goto l5;
- goto l4; // expected-error {{illegal goto into protected scope}}
- goto l3; // expected-error {{illegal goto into protected scope}}
- goto l2; // expected-error {{illegal goto into protected scope}}
+ goto l4; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{goto into protected scope}}
goto l1;
}
diff --git a/test/SemaCXX/explicit.cpp b/test/SemaCXX/explicit.cpp
index 11b9672..4774637 100644
--- a/test/SemaCXX/explicit.cpp
+++ b/test/SemaCXX/explicit.cpp
@@ -43,16 +43,8 @@ namespace Conversion {
class Y { }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}} \
expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y &' for 1st argument}} \
- expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} \
- expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} \
- expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'Conversion::Z' to 'const Conversion::Y' for 1st argument}} \
- expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}} \
- expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
+ expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'Conversion::Z' to 'Conversion::Y &&' for 1st argument}}
+
struct Z {
explicit operator Y() const;
explicit operator int() const;
@@ -61,10 +53,9 @@ namespace Conversion {
Z z;
// 13.3.1.4p1 & 8.5p16:
Y y2 = z; // expected-error {{no viable conversion from 'Conversion::Z' to 'Conversion::Y'}}
- // FIXME: These are well-formed per C++0x 13.3.1.4p1 (see DR899).
- Y y3 = (Y)z; // expected-error {{no matching conversion for C-style cast from 'Conversion::Z' to 'Conversion::Y''}}
- Y y4 = Y(z); // expected-error {{no matching conversion for functional-style cast from 'Conversion::Z' to 'Conversion::Y'}}
- Y y5 = static_cast<Y>(z); // expected-error {{no matching conversion for static_cast from 'Conversion::Z' to 'Conversion::Y'}}
+ Y y3 = (Y)z;
+ Y y4 = Y(z);
+ Y y5 = static_cast<Y>(z);
// 13.3.1.5p1 & 8.5p16:
int i1 = (int)z;
int i2 = int(z);
diff --git a/test/SemaCXX/expression-traits.cpp b/test/SemaCXX/expression-traits.cpp
index 32b3ff9..2767d4a 100644
--- a/test/SemaCXX/expression-traits.cpp
+++ b/test/SemaCXX/expression-traits.cpp
@@ -185,8 +185,8 @@ struct Class : BaseClass
template <class T>
struct NestedClassTemplate {};
- template <class T> // expected-note{{possible target for call}}
- static int& NestedFuncTemplate() { return variable; }
+ template <class T>
+ static int& NestedFuncTemplate() { return variable; } // expected-note{{possible target for call}}
template <class T>
int& NestedMemfunTemplate() { return variable; }
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp
index b994e8c..8bda510 100644
--- a/test/SemaCXX/for-range-examples.cpp
+++ b/test/SemaCXX/for-range-examples.cpp
@@ -148,3 +148,35 @@ int main() {
}
assert(total == 500);
}
+
+// PR11793
+namespace test2 {
+ class A {
+ int xs[10]; // expected-note {{implicitly declared private here}}
+ };
+ void test(A &a) {
+ for (int x : a.xs) { } // expected-error {{'xs' is a private member of 'test2::A'}}
+ }
+}
+
+namespace test3 {
+ // Make sure this doesn't crash
+ struct A {};
+ struct B { ~B(); operator bool(); };
+ struct C { B operator!=(const C&); C& operator++(); int operator*(); };
+ C begin(const A&);
+ C end(const A&);
+ template<typename T> void f() { for (auto a : A()) {} }
+ void g() { f<int>(); }
+}
+
+namespace test4 {
+ void f() {
+ int y;
+
+ // Make sure these don't crash. Better diagnostics would be nice.
+ for (: {1, 2, 3}) {} // expected-error {{expected expression}} expected-error {{expected ';'}}
+ for (x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} expected-error {{expected ';'}}
+ for (y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}}
+ }
+}
diff --git a/test/SemaCXX/for-range-no-std.cpp b/test/SemaCXX/for-range-no-std.cpp
index dae41f1..fa42ca4 100644
--- a/test/SemaCXX/for-range-no-std.cpp
+++ b/test/SemaCXX/for-range-no-std.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions
struct S {
int *begin();
@@ -36,3 +36,8 @@ void f() {
for (int b : NS::ADL()) {} // ok
for (int b : NS::NoADL()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
}
+
+void PR11601() {
+ void (*vv[])() = {PR11601, PR11601, PR11601};
+ for (void (*i)() : vv) i();
+}
diff --git a/test/SemaCXX/format-strings-0x.cpp b/test/SemaCXX/format-strings-0x.cpp
new file mode 100644
index 0000000..e7c5904
--- /dev/null
+++ b/test/SemaCXX/format-strings-0x.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
+
+extern "C" {
+extern int scanf(const char *restrict, ...);
+extern int printf(const char *restrict, ...);
+}
+
+void f(char **sp, float *fp) {
+ scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
+
+ printf("%a", 1.0);
+ scanf("%afoobar", fp);
+ printf(nullptr);
+ printf(*sp); // expected-warning {{not a string literal}}
+}
diff --git a/test/SemaCXX/format-strings.cpp b/test/SemaCXX/format-strings.cpp
new file mode 100644
index 0000000..6b0df29
--- /dev/null
+++ b/test/SemaCXX/format-strings.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -pedantic %s
+
+#include <stdarg.h>
+
+extern "C" {
+extern int scanf(const char *restrict, ...);
+extern int printf(const char *restrict, ...);
+extern int vprintf(const char *restrict, va_list);
+}
+
+void f(char **sp, float *fp) {
+ scanf("%as", sp); // expected-warning{{'a' length modifier is not supported by ISO C}}
+
+ // TODO: Warn that the 'a' conversion specifier is a C++11 feature.
+ printf("%a", 1.0);
+ scanf("%afoobar", fp);
+}
+
+void g() {
+ printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+}
+
+// Test that we properly handle format_idx on C++ members.
+class Foo {
+public:
+ const char *gettext(const char *fmt) __attribute__((format_arg(2)));
+
+ int scanf(const char *, ...) __attribute__((format(scanf, 2, 3)));
+ int printf(const char *, ...) __attribute__((format(printf, 2, 3)));
+ int printf2(const char *, ...);
+
+ static const char *gettext_static(const char *fmt) __attribute__((format_arg(1)));
+ static int printf_static(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
+};
+
+void h(int *i) {
+ Foo foo;
+ foo.scanf("%d"); // expected-warning{{more '%' conversions than data arguments}}
+ foo.printf("%d", i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+ Foo::printf_static("%d", i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+
+ printf(foo.gettext("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+ printf(Foo::gettext_static("%d"), i); // expected-warning{{format specifies type 'int' but the argument has type 'int *'}}
+}
+
+// Test handling __null for format string literal checking.
+extern "C" {
+ int test_null_format(const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
+}
+
+void rdar8269537(const char *f)
+{
+ test_null_format(false); // expected-warning {{null from a constant boolean}}
+ test_null_format(0); // no-warning
+ test_null_format(__null); // no-warning
+ test_null_format(f); // expected-warning {{not a string literal}}
+}
+
+int Foo::printf(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap,fmt);
+ const char * const format = fmt;
+ vprintf(format, ap); // no-warning
+
+ const char *format2 = fmt;
+ vprintf(format2, ap); // expected-warning{{format string is not a string literal}}
+
+ return 0;
+}
+
+int Foo::printf2(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap,fmt);
+ vprintf(fmt, ap); // expected-warning{{format string is not a string literal}}
+
+ return 0;
+}
diff --git a/test/SemaCXX/friend-out-of-line.cpp b/test/SemaCXX/friend-out-of-line.cpp
new file mode 100644
index 0000000..56b2daa
--- /dev/null
+++ b/test/SemaCXX/friend-out-of-line.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/10204947>
+namespace N {
+ class X;
+};
+
+class N::X {
+ template<typename T> friend const T& f(const X&);
+ friend const int& g(const X&);
+ friend class Y;
+};
diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp
index b1ef220..c5b11eb 100644
--- a/test/SemaCXX/friend.cpp
+++ b/test/SemaCXX/friend.cpp
@@ -130,3 +130,11 @@ namespace test6_3 {
v.f();
}
}
+
+namespace test7 {
+ extern "C" {
+ class X {
+ friend int f() { return 42; }
+ };
+ }
+}
diff --git a/test/SemaCXX/function-extern-c.cpp b/test/SemaCXX/function-extern-c.cpp
new file mode 100644
index 0000000..f20cd38
--- /dev/null
+++ b/test/SemaCXX/function-extern-c.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -Wreturn-type -fsyntax-only -std=c++11 -verify %s
+
+class A {
+public:
+ A(const A&);
+};
+
+struct S {
+ int i;
+ double d;
+
+ virtual void B() {}
+};
+
+union U {
+ struct {
+ int i;
+ virtual void B() {} // Can only do this in C++11
+ } t;
+};
+
+struct S2 {
+ int i;
+ double d;
+};
+
+extern "C" U f3( void ); // expected-warning {{'f3' has C-linkage specified, but returns user-defined type 'U' which is incompatible with C}}
+extern "C" S f0(void); // expected-warning {{'f0' has C-linkage specified, but returns user-defined type 'S' which is incompatible with C}}
+extern "C" A f4( void ); // expected-warning {{'f4' has C-linkage specified, but returns user-defined type 'A' which is incompatible with C}}
+
+// These should all be fine
+extern "C" S2 f5( void );
+extern "C" void f2( A x );
+extern "C" void f6( S s );
+extern "C" void f7( U u );
+extern "C" double f8(void);
+extern "C" long long f11( void );
+extern "C" A *f10( void );
diff --git a/test/SemaCXX/function-redecl.cpp b/test/SemaCXX/function-redecl.cpp
index 0d9ecf3..0eb109d 100644
--- a/test/SemaCXX/function-redecl.cpp
+++ b/test/SemaCXX/function-redecl.cpp
@@ -76,9 +76,12 @@ class Crash {
void GetCart(int count) const;
};
// This out-of-line definition was fine...
-void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}}
+void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \
+ // expected-note {{'cart' declared here}} \
+ // expected-note {{previous definition is here}}
// ...while this one crashed clang
-void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}}
+void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \
+ // expected-error {{redefinition of 'cart'}}
class TestConst {
public:
diff --git a/test/SemaCXX/function-type-qual.cpp b/test/SemaCXX/function-type-qual.cpp
index 8ebb506..73613ae 100644
--- a/test/SemaCXX/function-type-qual.cpp
+++ b/test/SemaCXX/function-type-qual.cpp
@@ -1,17 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-void f() const; // expected-error {{type qualifier is not allowed on this function}}
-void (*pf)() const; // expected-error {{type qualifier is not allowed on this function pointer}}
-void (&rf)() const = f; // expected-error {{type qualifier is not allowed on this function reference}}
+void f() const; // expected-error {{non-member function cannot have 'const' qualifier}}
+void (*pf)() const; // expected-error {{pointer to function type cannot have 'const' qualifier}}
+extern void (&rf)() const; // expected-error {{reference to function type cannot have 'const' qualifier}}
-typedef void cfn() const;
-cfn f2; // expected-error {{a qualified function type cannot be used to declare a nonmember function}}
+typedef void cfn() const;
+cfn f2; // expected-error {{non-member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
class C {
void f() const;
cfn f2;
- static void f3() const; // expected-error {{type qualifier is not allowed on this function}}
- static cfn f4; // expected-error {{a qualified function type cannot be used to declare a static member function}}
+ static void f3() const; // expected-error {{static member function cannot have 'const' qualifier}}
+ static cfn f4; // expected-error {{static member function of type 'cfn' (aka 'void () const') cannot have 'const' qualifier}}
void m1() {
x = 0;
diff --git a/test/SemaCXX/generalized-initializers.cpp b/test/SemaCXX/generalized-initializers.cpp
deleted file mode 100644
index a1891c9..0000000
--- a/test/SemaCXX/generalized-initializers.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// XFAIL: *
-
-template <typename T, typename U>
-struct same_type { static const bool value = false; };
-template <typename T>
-struct same_type<T, T> { static const bool value = true; };
-
-namespace std {
- typedef decltype(sizeof(int)) size_t;
-
- // libc++'s implementation
- template <class _E>
- class initializer_list
- {
- const _E* __begin_;
- size_t __size_;
-
- initializer_list(const _E* __b, size_t __s)
- : __begin_(__b),
- __size_(__s)
- {}
-
- public:
- typedef _E value_type;
- typedef const _E& reference;
- typedef const _E& const_reference;
- typedef size_t size_type;
-
- typedef const _E* iterator;
- typedef const _E* const_iterator;
-
- initializer_list() : __begin_(nullptr), __size_(0) {}
-
- size_t size() const {return __size_;}
- const _E* begin() const {return __begin_;}
- const _E* end() const {return __begin_ + __size_;}
- };
-}
-
-namespace integral {
-
- int function_call() {
- void takes_int(int);
- takes_int({1});
- }
-
- void inline_init() {
- (void) int{1};
- (void) new int{1};
- }
-
- void initializer_list() {
- std::initializer_list<int> il = { 1, 2, 3 };
- std::initializer_list<double> dl = { 1.0, 2.0, 3 };
- auto l = {1, 2, 3, 4};
- static_assert(same_type<decltype(l), std::initializer_list<int>>::value, "");
- auto bl = {1, 2.0}; // expected-error {{cannot deduce}}
-
- for (int i : {1, 2, 3, 4}) {}
- }
-
-}
-
-namespace objects {
-
- struct X1 { X1(int); };
- struct X2 { explicit X2(int); };
-
- template <int N>
- struct A {
- A() { static_assert(N == 0, ""); }
- A(int, double) { static_assert(N == 1, ""); }
- A(std::initializer_list<int>) { static_assert(N == 3, ""); }
- };
-
- template <int N>
- struct D {
- D(std::initializer_list<int>) { static_assert(N == 0, ""); } // expected-note 1 {{candidate}}
- D(std::initializer_list<double>) { static_assert(N == 1, ""); } // expected-note 1 {{candidate}}
- };
-
- template <int N>
- struct E {
- E(int, int) { static_assert(N == 0, ""); }
- E(X1, int) { static_assert(N == 1, ""); }
- };
-
- void overload_resolution() {
- { A<0> a{}; }
- { A<0> a = {}; }
- // Narrowing conversions don't affect viability. The next two choose
- // the initializer_list constructor.
- { A<3> a{1, 1.0}; } // expected-error {{narrowing conversion}}
- { A<3> a = {1, 1.0}; } // expected-error {{narrowing conversion}}
- { A<3> a{1, 2, 3, 4, 5, 6, 7, 8}; }
- { A<3> a = {1, 2, 3, 4, 5, 6, 7, 8}; }
- { A<3> a{1, 2, 3, 4, 5, 6, 7, 8}; }
- { A<3> a{1, 2}; }
-
- { D<0> d{1, 2, 3}; }
- { D<1> d{1.0, 2.0, 3.0}; }
- { D<-1> d{1, 2.0}; } // expected-error {{ambiguous}}
-
- { E<0> e{1, 2}; }
- }
-
- void explicit_implicit() {
- { X1 x{0}; }
- { X1 x = {0}; }
- { X2 x{0}; }
- { X2 x = {0}; } // expected-error {{explicit}}
- }
-
- struct C {
- C();
- C(int, double);
- C(int, int);
- C(std::initializer_list<int>);
-
- int operator[](C);
- };
-
- C function_call() {
- void takes_C(C);
- takes_C({1, 1.0});
-
- C c;
- c[{1, 1.0}];
-
- return {1, 1.0};
- }
-
- void inline_init() {
- (void) A<1>{1, 1.0};
- (void) new A<1>{1, 1.0};
- }
-
- struct B {
- B(C, int, C);
- };
-
- void nested_init() {
- B b{{1, 1.0}, 2, {3, 4, 5, 6, 7}};
- }
-}
-
-namespace litb {
-
- // invalid
- struct A { int a[2]; A():a({1, 2}) { } }; // expected-error {{}}
-
- // invalid
- int a({0}); // expected-error {{}}
-
- // invalid
- int const &b({0}); // expected-error {{}}
-
- struct C { explicit C(int, int); C(int, long); };
-
- // invalid
- C c({1, 2}); // expected-error {{}}
-
- // valid (by copy constructor).
- C d({1, 2L}); // expected-error {{}}
-
- // valid
- C e{1, 2};
-
- struct B {
- template<typename ...T>
- B(std::initializer_list<int>, T ...);
- };
-
- // invalid (the first phase only considers init-list ctors)
- // (for the second phase, no constructor is viable)
- B f{1, 2, 3};
-
- // valid (T deduced to <>).
- B g({1, 2, 3});
-
-}
-
-namespace aggregate {
- // Direct list initialization does NOT allow braces to be elided!
- struct S {
- int ar[2];
- struct T {
- int i1;
- int i2;
- } t;
- struct U {
- int i1;
- } u[2];
- struct V {
- int var[2];
- } v;
- };
-
- void test() {
- S s1 = { 1, 2, 3 ,4, 5, 6, 7, 8 }; // no-error
- S s2{ {1, 2}, {3, 4}, { {5}, {6} }, { {7, 8} } }; // completely braced
- S s3{ 1, 2, 3, 4, 5, 6 }; // xpected-error
- S s4{ {1, 2}, {3, 4}, {5, 6}, { {7, 8} } }; // xpected-error
- S s5{ {1, 2}, {3, 4}, { {5}, {6} }, {7, 8} }; // xpected-error
- }
-}
diff --git a/test/SemaCXX/gnu-case-ranges.cpp b/test/SemaCXX/gnu-case-ranges.cpp
index c1c18a8..b082e3a 100644
--- a/test/SemaCXX/gnu-case-ranges.cpp
+++ b/test/SemaCXX/gnu-case-ranges.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-covered-switch-default %s
enum E {
one,
diff --git a/test/SemaCXX/goto.cpp b/test/SemaCXX/goto.cpp
index d8d5ec5..24bcb7c 100644
--- a/test/SemaCXX/goto.cpp
+++ b/test/SemaCXX/goto.cpp
@@ -103,3 +103,25 @@ void f() {
exit:
return;
}
+
+namespace PR10620 {
+ struct S {
+ ~S() {}
+ };
+ void g(const S& s) {
+ goto done; // expected-error {{goto into protected scope}}
+ const S s2(s); // expected-note {{jump bypasses variable initialization}}
+ done:
+ ;
+ }
+}
+
+namespace test12 {
+ struct A { A(); A(const A&); ~A(); };
+ void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+ goto lbl; // expected-error {{goto into protected scope}}
+ (void) ^{ (void) a; };
+ lbl:
+ return;
+ }
+}
diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp
index 4d02ca8..5631577 100644
--- a/test/SemaCXX/i-c-e-cxx.cpp
+++ b/test/SemaCXX/i-c-e-cxx.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// C++-specific tests for integral constant expressions.
@@ -16,9 +16,9 @@ void f() {
}
int a() {
- const int t=t;
+ const int t=t; // expected-note {{declared here}}
switch(1) { // expected-warning {{no case matching constant switch condition '1'}}
- case t:; // expected-error {{not an integer constant expression}}
+ case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}}
}
}
@@ -48,7 +48,7 @@ void pr6373(const unsigned x = 0) {
namespace rdar9204520 {
struct A {
- static const int B = int(0.75 * 1000 * 1000);
+ static const int B = int(0.75 * 1000 * 1000); // expected-warning {{not a constant expression; folding it to a constant is a GNU extension}}
};
int foo() { return A::B; }
@@ -59,5 +59,10 @@ const int x = 10;
int* y = reinterpret_cast<const char&>(x); // expected-error {{cannot initialize}}
// This isn't an integral constant expression, but make sure it folds anyway.
-struct PR8836 { char _; long long a; };
-int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))];
+struct PR8836 { char _; long long a; }; // expected-warning {{long long}}
+int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))]; // expected-warning {{folded to constant array as an extension}} expected-note {{cast which performs the conversions of a reinterpret_cast is not allowed in a constant expression}}
+
+const int nonconst = 1.0; // expected-note {{declared here}}
+int arr[nonconst]; // expected-warning {{folded to constant array as an extension}} expected-note {{initializer of 'nonconst' is not a constant expression}}
+const int castfloat = static_cast<int>(1.0);
+int arr2[castfloat]; // ok
diff --git a/test/SemaCXX/if-empty-body.cpp b/test/SemaCXX/if-empty-body.cpp
deleted file mode 100644
index ec7f89d..0000000
--- a/test/SemaCXX/if-empty-body.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void f1(int a) {
- if (a); // expected-warning {{if statement has empty body}}
-}
-
-void f2(int a) {
- if (a) {}
-}
-
-void f3() {
- if (1)
- xx; // expected-error {{use of undeclared identifier}}
- return; // no empty body warning.
-}
-
-// Don't warn about an empty body if is expanded from a macro.
-void f4(int i) {
- #define BODY(x)
- if (i == i) // expected-warning{{self-comparison always evaluates to true}}
- BODY(0);
- #undef BODY
-}
-
-template <typename T>
-void tf() {
- #define BODY(x)
- if (0)
- BODY(0);
- #undef BODY
-}
-
-void f5() {
- tf<int>();
-}
diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp
index 559c301..786e8f4 100644
--- a/test/SemaCXX/implicit-exception-spec.cpp
+++ b/test/SemaCXX/implicit-exception-spec.cpp
@@ -54,10 +54,9 @@ namespace ExceptionSpecification {
// The same problem arises in delayed parsing of default arguments,
// which clang does not yet support.
namespace DefaultArgument {
- // FIXME: this diagnostic is completely wrong.
- struct Default { // expected-note {{explicitly marked deleted here}}
+ struct Default {
struct T {
- T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to deleted constructor}}
- } t;
+ T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to implicitly-deleted default constructor}}
+ } t; // expected-note {{has no default constructor}}
};
}
diff --git a/test/SemaCXX/incomplete-call.cpp b/test/SemaCXX/incomplete-call.cpp
index d627c33..69eb03a 100644
--- a/test/SemaCXX/incomplete-call.cpp
+++ b/test/SemaCXX/incomplete-call.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A; // expected-note 14 {{forward declaration of 'A'}}
-A f(); // expected-note {{note: 'f' declared here}}
+A f(); // expected-note {{'f' declared here}}
struct B {
A f(); // expected-note {{'f' declared here}}
diff --git a/test/SemaCXX/indirect-goto.cpp b/test/SemaCXX/indirect-goto.cpp
new file mode 100644
index 0000000..5b3fac4
--- /dev/null
+++ b/test/SemaCXX/indirect-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test1 {
+ // Make sure this doesn't crash.
+ struct A { ~A(); };
+ void a() { goto *(A(), &&L); L: return; }
+}
diff --git a/test/SemaCXX/instantiate-blocks.cpp b/test/SemaCXX/instantiate-blocks.cpp
index a4001a7..bb0f8d8 100644
--- a/test/SemaCXX/instantiate-blocks.cpp
+++ b/test/SemaCXX/instantiate-blocks.cpp
@@ -12,8 +12,21 @@ template <typename T, typename T1> void foo(T t, T1 r)
return block_arg+arg; };
}
+// rdar://10466373
+template <typename T, typename T1> void noret(T t, T1 r)
+{
+ (void) ^{
+ if (1)
+ return t;
+ else if (2)
+ return r; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
+ };
+}
+
int main(void)
{
foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
+
+ noret((float)0.0, double(0.0)); // expected-note {{in instantiation of function template specialization 'noret<float, double>' requested here}}
}
diff --git a/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp
index 37025d9..287d9af 100644
--- a/test/SemaCXX/invalid-member-expr.cpp
+++ b/test/SemaCXX/invalid-member-expr.cpp
@@ -8,7 +8,7 @@ void test() {
x.int; // expected-error{{expected unqualified-id}}
x.~int(); // expected-error{{expected a class name}}
x.operator; // expected-error{{expected a type}}
- x.operator typedef; // expected-error{{expected a type}}
+ x.operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
}
void test2() {
@@ -17,7 +17,7 @@ void test2() {
x->int; // expected-error{{expected unqualified-id}}
x->~int(); // expected-error{{expected a class name}}
x->operator; // expected-error{{expected a type}}
- x->operator typedef; // expected-error{{expected a type}}
+ x->operator typedef; // expected-error{{expected a type}} expected-error{{type name does not allow storage class}}
}
// PR6327
diff --git a/test/SemaCXX/issue547.cpp b/test/SemaCXX/issue547.cpp
index 5b82dc6..ab03a15 100644
--- a/test/SemaCXX/issue547.cpp
+++ b/test/SemaCXX/issue547.cpp
@@ -11,17 +11,17 @@ struct classify_function<R(Args...)> {
};
template<typename R, typename ...Args>
-struct classify_function<R(Args...) const> { // expected-warning{{template argument of 'const' qualified function type is a GNU extension}}
+struct classify_function<R(Args...) const> {
static const unsigned value = 2;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args...) volatile> { // expected-warning{{template argument of 'volatile' qualified function type is a GNU extension}}
+struct classify_function<R(Args...) volatile> {
static const unsigned value = 3;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args...) const volatile> { // expected-warning{{template argument of 'const volatile' qualified function type is a GNU extension}}
+struct classify_function<R(Args...) const volatile> {
static const unsigned value = 4;
};
@@ -31,27 +31,27 @@ struct classify_function<R(Args......)> {
};
template<typename R, typename ...Args>
-struct classify_function<R(Args......) const> { // expected-warning{{template argument of 'const' qualified function type is a GNU extension}}
+struct classify_function<R(Args......) const> {
static const unsigned value = 6;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args......) volatile> { // expected-warning{{template argument of 'volatile' qualified function type is a GNU extension}}
+struct classify_function<R(Args......) volatile> {
static const unsigned value = 7;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args......) const volatile> { // expected-warning{{template argument of 'const volatile' qualified function type is a GNU extension}}
+struct classify_function<R(Args......) const volatile> {
static const unsigned value = 8;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args......) &&> { // expected-warning{{template argument of '&&' qualified function type is a GNU extension}}
+struct classify_function<R(Args......) &&> {
static const unsigned value = 9;
};
template<typename R, typename ...Args>
-struct classify_function<R(Args......) const &> { // expected-warning{{template argument of 'const &' qualified function type is a GNU extension}}
+struct classify_function<R(Args......) const &> {
static const unsigned value = 10;
};
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
new file mode 100644
index 0000000..e91dee9
--- /dev/null
+++ b/test/SemaCXX/lambda-expressions.cpp
@@ -0,0 +1,150 @@
+// RUN: %clang_cc1 -std=c++0x -Wno-unused-value -fsyntax-only -verify -fblocks %s
+
+namespace std { class type_info; };
+
+namespace ExplicitCapture {
+ class C {
+ int Member;
+
+ static void Overload(int);
+ void Overload();
+ virtual C& Overload(float);
+
+ void ImplicitThisCapture() {
+ [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ [&](){(void)Member;};
+
+ [this](){(void)Member;};
+ [this]{[this]{};};
+ []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
+ []{Overload(3);};
+ []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+ []{(void)typeid(Overload());};
+ []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+ }
+ };
+
+ void f() {
+ [this] () {}; // expected-error {{'this' cannot be captured in this context}}
+ }
+}
+
+namespace ReturnDeduction {
+ void test() {
+ [](){ return 1; };
+ [](){ return 1; };
+ [](){ return ({return 1; 1;}); };
+ [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} \
+ // expected-warning{{omitted result type}}
+ []()->int{ return 'c'; return 1; };
+ [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}}
+ []() { return; return (void)0; };
+ [](){ return 1; return 1; }; // expected-warning{{omitted result type}}
+ }
+}
+
+namespace ImplicitCapture {
+ void test() {
+ int a = 0; // expected-note 5 {{declared}}
+ []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+ [&]() { return a; };
+ [=]() { return a; };
+ [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
+ [=]() { return [&]() { return a; }; };
+ []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}}
+ [=]() { return [&a] { return a; }; }; //
+
+ const int b = 2;
+ []() { return b; };
+
+ union { // expected-note {{declared}}
+ int c;
+ float d;
+ };
+ d = 3;
+ [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}}
+
+ __block int e; // expected-note 3 {{declared}}
+ [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}}
+ [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}}
+
+ int f[10]; // expected-note {{declared}}
+ [&]() { return f[2]; };
+ (void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \
+ // expected-note{{lambda expression begins here}}
+
+ struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}}
+ G g;
+ [=]() { const G* gg = &g; return gg->a; }; // expected-warning{{omitted result type}}
+ [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} \
+ // expected-warning{{omitted result type}}
+ (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \
+ // expected-warning{{omitted result type}}
+
+ const int h = a; // expected-note {{declared}}
+ []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+
+ // The exemption for variables which can appear in constant expressions
+ // applies only to objects (and not to references).
+ // FIXME: This might be a bug in the standard.
+ static int i;
+ constexpr int &ref_i = i; // expected-note {{declared}}
+ [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
+ }
+}
+
+namespace PR12031 {
+ struct X {
+ template<typename T>
+ X(const T&);
+ ~X();
+ };
+
+ void f(int i, X x);
+ void g() {
+ const int v = 10;
+ f(v, [](){});
+ }
+}
+
+namespace NullPtr {
+ int &f(int *p);
+ char &f(...);
+ void g() {
+ int n = 0;
+ [=] {
+ char &k = f(n); // not a null pointer constant
+ } ();
+
+ const int m = 0;
+ [=] {
+ int &k = f(m); // a null pointer constant
+ } ();
+
+ [=] () -> bool {
+ int &k = f(m); // a null pointer constant
+ return &m == 0;
+ } ();
+
+ [m] {
+ int &k = f(m); // a null pointer constant
+ } ();
+ }
+}
+
+void PR12248()
+{
+ unsigned int result = 0;
+ auto l = [&]() { ++result; };
+}
+
+namespace ModifyingCapture {
+ void test() {
+ int n = 0;
+ [=] {
+ n = 1; // expected-error {{cannot assign to a variable captured by copy in a non-mutable lambda}}
+ };
+ }
+}
diff --git a/test/SemaCXX/literal-operators.cpp b/test/SemaCXX/literal-operators.cpp
index 06ef49f..7f68cd3 100644
--- a/test/SemaCXX/literal-operators.cpp
+++ b/test/SemaCXX/literal-operators.cpp
@@ -13,7 +13,7 @@ namespace ns { void operator "" _ns_good (const char *); }
extern "C++" void operator "" _extern_good (const char *);
extern "C++" { void operator "" _extern_good (const char *); }
-void fn () { void operator "" _fn_bad (const char *); } // expected-error {{literal operator 'operator "" _fn_bad' must be in a namespace or global scope}}
+void fn () { void operator "" _fn_good (const char *); }
// One-param declarations (const char * was already checked)
void operator "" _good (char);
@@ -35,9 +35,9 @@ typedef const char c;
void operator "" _good (c*);
// Check extra cv-qualifiers
-void operator "" _cv_good (volatile const char *, const size_t);
+void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator "" _cv_good' is not valid}}
-// Template delcaration (not implemented yet)
-// template <char...> void operator "" good ();
+// Template declaration
+template <char...> void operator "" _good ();
// FIXME: Test some invalid decls that might crop up.
diff --git a/test/SemaCXX/literal-type.cpp b/test/SemaCXX/literal-type.cpp
index 60bfcf0..14a4094 100644
--- a/test/SemaCXX/literal-type.cpp
+++ b/test/SemaCXX/literal-type.cpp
@@ -23,6 +23,8 @@ static_assert(__is_literal(VectorExt), "fail");
// a constant expression,
// -- it is an aggregate type or has at least one constexpr constructor
// or constructor template that is not a copy or move constructor, and
+// [DR1452 adds class types with trivial default constructors to
+// this list]
// -- it has all non-static data members and base classes of literal
// types
struct Empty {};
@@ -36,25 +38,26 @@ struct LiteralType {
struct HasDtor { ~HasDtor(); };
class NonAggregate { int x; };
-struct HasNonLiteralBase : NonAggregate {};
+struct NonLiteral { NonLiteral(); };
+struct HasNonLiteralBase : NonLiteral {};
struct HasNonLiteralMember { HasDtor x; };
static_assert(__is_literal(Empty), "fail");
static_assert(__is_literal(LiteralType), "fail");
+static_assert(__is_literal(NonAggregate), "fail");
+static_assert(!__is_literal(NonLiteral), "fail");
static_assert(!__is_literal(HasDtor), "fail");
-static_assert(!__is_literal(NonAggregate), "fail");
static_assert(!__is_literal(HasNonLiteralBase), "fail");
static_assert(!__is_literal(HasNonLiteralMember), "fail");
-// FIXME: Test constexpr constructors and non-static members with initializers
-// when Clang supports them:
-#if 0
-extern int f();
+// DR1361 removes the brace-or-equal-initializer bullet so that we can allow:
+extern int f(); // expected-note {{here}}
struct HasNonConstExprMemInit {
- int x = f();
- constexpr HasNonConstExprMemInit(int y) {}
+ int x = f(); // expected-note {{non-constexpr function}}
+ constexpr HasNonConstExprMemInit() {} // expected-error {{never produces a constant expression}}
+ constexpr HasNonConstExprMemInit(int y) : x(y) {} // ok
};
-static_assert(!__is_literal(HasNonConstExprMemInit), "fail");
+static_assert(__is_literal(HasNonConstExprMemInit), "fail");
class HasConstExprCtor {
int x;
@@ -66,6 +69,9 @@ template <typename T> class HasConstExprCtorTemplate {
public:
template <typename U> constexpr HasConstExprCtorTemplate(U y) : x(y) {}
};
+template <typename T> class HasConstExprCtorT {
+ constexpr HasConstExprCtorT(T) {}
+};
static_assert(__is_literal(HasConstExprCtor), "fail");
-static_assert(__is_literal(HasConstExprCtorTemplate), "fail");
-#endif
+static_assert(__is_literal(HasConstExprCtorTemplate<int>), "fail");
+static_assert(__is_literal(HasConstExprCtorT<NonLiteral>), "fail");
diff --git a/test/SemaCXX/member-class-11.cpp b/test/SemaCXX/member-class-11.cpp
new file mode 100644
index 0000000..c230c53
--- /dev/null
+++ b/test/SemaCXX/member-class-11.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct rdar9677163 {
+ struct Y { ~Y(); };
+ struct Z { ~Z(); };
+ Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a qualified name}}
+ ~Z(); // expected-error{{expected the class name after '~' to name the enclosing class}}
+};
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 2e3fd73..dbddd1c 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -94,11 +94,11 @@ namespace test5 {
namespace PR7508 {
struct A {
struct CleanupScope {};
- void PopCleanupBlock();
+ void PopCleanupBlock(); // expected-note{{'PopCleanupBlock' declared here}}
};
void foo(A &a) {
- a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}}
+ a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'; did you mean 'PopCleanupBlock'?}}
}
}
@@ -147,3 +147,13 @@ namespace PR9025 {
return fun5.x; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}}
}
}
+
+namespace FuncInMemberExpr {
+ struct Vec { int size(); };
+ Vec fun1();
+ int test1() { return fun1.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec *fun2();
+ int test2() { return fun2->size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+ Vec fun3(int x = 0);
+ int test3() { return fun3.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}}
+}
diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp
index 819c8d1..c93c85b 100644
--- a/test/SemaCXX/member-init.cpp
+++ b/test/SemaCXX/member-init.cpp
@@ -29,6 +29,9 @@ const int C = 0, D = 0;
struct S {
int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
T<sizeof(as) / sizeof(int)> x; // expected-error {{requires a type specifier}}
+ // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid
+ operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \
+ // expected-error {{array bound cannot be deduced from an in-class initializer}}
};
struct ThrowCtor { ThrowCtor(int) noexcept(false); };
diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp
index cf64810..4e8b4a8 100644
--- a/test/SemaCXX/member-pointer.cpp
+++ b/test/SemaCXX/member-pointer.cpp
@@ -278,7 +278,7 @@ namespace PR9973 {
typedef R T::*F;
F f_;
template<class U> int & call(U u)
- { return u->*f_; } // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type '<bound member function type>'}}
+ { return u->*f_; } // expected-error{{reference to non-static member function must be called; did you mean to call it with no arguments?}} expected-error {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}}
template<class U> int operator()(U u)
{ call(u); } // expected-note{{in instantiation of}}
diff --git a/test/SemaCXX/microsoft-cxx0x.cpp b/test/SemaCXX/microsoft-cxx0x.cpp
index 3f78eda..3b9bbef 100644
--- a/test/SemaCXX/microsoft-cxx0x.cpp
+++ b/test/SemaCXX/microsoft-cxx0x.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++0x-narrowing -Wmicrosoft -verify -fms-extensions -std=c++11
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++11-narrowing -Wmicrosoft -verify -fms-extensions -std=c++11
struct A {
@@ -6,5 +6,3 @@ struct A {
};
int b = 3;
A var = { b }; // expected-warning {{ cannot be narrowed }} expected-note {{override}}
-
-
diff --git a/test/SemaCXX/missing-header.cpp b/test/SemaCXX/missing-header.cpp
index f436579..5b3915b 100644
--- a/test/SemaCXX/missing-header.cpp
+++ b/test/SemaCXX/missing-header.cpp
@@ -2,8 +2,8 @@
#include "not exist" // expected-error{{'not exist' file not found}}
-class AnalysisContext {};
-static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
+class AnalysisDeclContext {};
+static ControlFlowKind CheckFallThrough(AnalysisDeclContext &AC) {
if (const AsmStmt *AS = dyn_cast<AsmStmt>(S)) {}
bool NoReturnEdge = false;
}
diff --git a/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp b/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
index 76ceea1..83f8395 100644
--- a/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
+++ b/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
namespace fizbin { class Foobar {}; } // expected-note 2 {{'fizbin::Foobar' declared here}} \
// expected-note {{'Foobar' declared here}}
Foobar *my_bar // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
= new Foobar; // expected-error{{unknown type name 'Foobar'; did you mean 'fizbin::Foobar'?}}
-fizbin::Foobar *my_foo = new fizbin::FooBar; // expected-error{{unknown type name 'FooBar'; did you mean 'Foobar'?}}
+fizbin::Foobar *my_foo = new fizbin::FooBar; // expected-error{{no type named 'FooBar' in namespace 'fizbin'; did you mean 'Foobar'?}}
namespace barstool { int toFoobar() { return 1; } } // expected-note 3 {{'barstool::toFoobar' declared here}}
int Double(int x) { return x + x; }
void empty() {
- Double(toFoobar()); // expected-error{{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
+ Double(toFoobar()); // expected-error{{use of undeclared identifier 'toFoobar'; did you mean 'barstool::toFoobar'?}}
}
namespace fizbin {
@@ -36,7 +36,7 @@ void Check() { // expected-note{{'Check' declared here}}
}
void Alt() {
- Cleck(); // expected-error{{{use of undeclared identifier 'Cleck'; did you mean 'Check'?}}
+ Cleck(); // expected-error{{use of undeclared identifier 'Cleck'; did you mean 'Check'?}}
}
namespace N {
@@ -64,13 +64,58 @@ void f() {
// Test case from http://llvm.org/bugs/show_bug.cgi?id=10318
namespace llvm {
- template <typename T> class GraphWriter {}; // expected-note {{'llvm::GraphWriter' declared here}} \
- // expected-note {{'GraphWriter' declared here}}
+ template <typename T> class GraphWriter {}; // expected-note 3{{declared here}}
}
struct S {};
void bar() {
GraphWriter<S> x; //expected-error{{no template named 'GraphWriter'; did you mean 'llvm::GraphWriter'?}}
- (void)new llvm::GraphWriter; // expected-error {{expected a type}}
+ (void)new llvm::GraphWriter; // expected-error {{use of class template llvm::GraphWriter requires template arguments}}
(void)new llvm::Graphwriter<S>; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}}
}
+
+// If namespace prefixes and character edits have the same weight, correcting
+// "fimish" to "N::famish" would have the same edit distance as correcting
+// "fimish" to "Finish". The result would be no correction being suggested
+// unless one of the corrections is given precedence (e.g. by filtering out
+// suggestions with added namespace qualifiers).
+namespace N { void famish(int); }
+void Finish(int); // expected-note {{'Finish' declared here}}
+void Start() {
+ fimish(7); // expected-error {{use of undeclared identifier 'fimish'; did you mean 'Finish'?}}
+}
+
+// But just eliminating the corrections containing added namespace qualifiers
+// won't work if both of the tied corrections have namespace qualifiers added.
+namespace N {
+void someCheck(int); // expected-note {{'N::someCheck' declared here}}
+namespace O { void somechock(int); }
+}
+void confusing() {
+ somechick(7); // expected-error {{use of undeclared identifier 'somechick'; did you mean 'N::someCheck'?}}
+}
+
+
+class Message {};
+namespace extra {
+ namespace util {
+ namespace MessageUtils {
+ bool Equivalent(const Message&, const Message&); // expected-note {{'extra::util::MessageUtils::Equivalent' declared here}} \
+ // expected-note {{'::extra::util::MessageUtils::Equivalent' declared here}}
+ }
+ }
+}
+namespace util { namespace MessageUtils {} }
+bool nstest () {
+ Message a, b;
+ return util::MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean 'extra::util::MessageUtils::Equivalent'?}}
+}
+
+namespace util {
+ namespace extra {
+ bool nstest () {
+ Message a, b;
+ return MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean '::extra::util::MessageUtils::Equivalent'?}}
+ }
+ }
+}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 52cae2e..e18b58b 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -11,9 +11,13 @@ namespace C { } // expected-note {{previous definition is here}}
namespace C = N; // expected-error {{redefinition of 'C'}}
int i;
-namespace D = i; // expected-error {{expected namespace name}}
+namespace D =
+i; // expected-error {{expected namespace name}}
-namespace E = N::Foo; // expected-error {{expected namespace name}}
+namespace E1 = N::
+Foo; // expected-error {{expected namespace name}}
+namespace E2 = N::
+X; // expected-error {{expected namespace name}}
namespace F {
namespace A { namespace B { } } // expected-note {{candidate found by name lookup is 'F::A::B'}}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index e13030c..b317634 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -45,7 +45,7 @@ void C2::m() {
}
namespace B {
- void ::A::Af() {} // expected-error {{definition or redeclaration of 'Af' not in a namespace enclosing 'A'}}
+ void ::A::Af() {} // expected-error {{cannot define or redeclare 'Af' here because namespace 'B' does not enclose namespace 'A'}}
}
void f1() {
@@ -160,7 +160,7 @@ namespace N {
void f();
// FIXME: if we move this to a separate definition of N, things break!
}
-void ::global_func2(int) { } // expected-error{{definition or redeclaration of 'global_func2' cannot name the global scope}}
+void ::global_func2(int) { } // expected-warning{{extra qualification on member 'global_func2'}}
void N::f() { } // okay
@@ -274,7 +274,8 @@ struct A {
protected:
struct B;
struct B::C; // expected-error {{requires a template parameter list}} \
- // expected-error {{no struct named 'C'}}
+ // expected-error {{no struct named 'C'}} \
+ // expected-error{{non-friend class member 'C' cannot have a qualified name}}
};
template<typename T>
diff --git a/test/SemaCXX/new-delete-0x.cpp b/test/SemaCXX/new-delete-0x.cpp
new file mode 100644
index 0000000..dcc2e9b
--- /dev/null
+++ b/test/SemaCXX/new-delete-0x.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -std=c++11
+
+using size_t = decltype(sizeof(0));
+struct noreturn_t {} constexpr noreturn = {};
+
+void *operator new [[noreturn]] (size_t, noreturn_t);
+void operator delete [[noreturn]] (void*, noreturn_t);
+
+void good_news()
+{
+ auto p = new int[2][[]];
+ auto q = new int[[]][2];
+ auto r = new int*[[]][2][[]];
+ auto s = new (int(*[[]])[2][[]]);
+}
+
+void bad_news(int *ip)
+{
+ // attribute-specifiers can go almost anywhere in a new-type-id...
+ auto r = new int[[]{return 1;}()][2]; // expected-error {{expected ']'}}
+ auto s = new int*[[]{return 1;}()][2]; // expected-error {{expected ']'}}
+ // ... but not here:
+ auto t = new (int(*)[[]]); // expected-error {{an attribute list cannot appear here}}
+ auto u = new (int(*)[[]{return 1;}()][2]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} expected-error {{variably modified type}}
+}
+
+void good_deletes()
+{
+ delete [&]{ return (int*)0; }();
+ // FIXME: This appears to be legal.
+ delete []{ return (int*)0; }(); // unexpected-error {{expected expression}}
+}
diff --git a/test/SemaCXX/new-delete-cxx0x.cpp b/test/SemaCXX/new-delete-cxx0x.cpp
new file mode 100644
index 0000000..c404fab
--- /dev/null
+++ b/test/SemaCXX/new-delete-cxx0x.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu
+
+void ugly_news(int *ip) {
+ // These are ill-formed according to one reading of C++98, and at the least
+ // have undefined behavior. But they're well-formed, and defined to throw
+ // std::bad_array_new_length, in C++11.
+ (void)new int[-1]; // expected-warning {{array size is negative}}
+ (void)new int[2000000000]; // expected-warning {{array is too large}}
+}
+
+
+struct S {
+ S(int);
+ S();
+ ~S();
+};
+
+struct T { // expected-note 2 {{not viable}}
+ T(int); // expected-note {{not viable}}
+};
+
+void fn() {
+ (void) new int[2] {1, 2};
+ (void) new S[2] {1, 2};
+ (void) new T[2] {1, 2}; // expected-error {{no matching constructor}}
+}
diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp
index 748ce77..e77e3d6 100644
--- a/test/SemaCXX/new-delete.cpp
+++ b/test/SemaCXX/new-delete.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu
#include <stddef.h>
@@ -61,13 +61,13 @@ struct abstract {
void bad_news(int *ip)
{
- int i = 1;
+ int i = 1; // expected-note 2{{here}}
(void)new; // expected-error {{expected a type}}
(void)new 4; // expected-error {{expected a type}}
(void)new () int; // expected-error {{expected expression}}
- (void)new int[1.1]; // expected-error {{array size expression must have integral or enumerated type, not 'double'}}
- (void)new int[1][i]; // expected-error {{only the first dimension}}
- (void)new (int[1][i]); // expected-error {{only the first dimension}}
+ (void)new int[1.1]; // expected-error {{array size expression must have integral or enumeration type, not 'double'}}
+ (void)new int[1][i]; // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
+ (void)new (int[1][i]); // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
(void)new (int[i]); // expected-warning {{when type is in parentheses}}
(void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}}
(void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
@@ -77,7 +77,8 @@ void bad_news(int *ip)
(void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
// Undefined, but clang should reject it directly.
(void)new int[-1]; // expected-error {{array size is negative}}
- (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'S'}}
+ (void)new int[2000000000]; // expected-error {{array is too large}}
+ (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumeration type, not 'S'}}
(void)::S::new int; // expected-error {{expected unqualified-id}}
(void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
(void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}}
@@ -101,8 +102,7 @@ void good_deletes()
void bad_deletes()
{
delete 0; // expected-error {{cannot delete expression of type 'int'}}
- delete [0] (int*)0; // expected-error {{expected ']'}} \
- // expected-note {{to match this '['}}
+ delete [0] (int*)0; // expected-error {{expected expression}}
delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}}
delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
::S::delete (int*)0; // expected-error {{expected unqualified-id}}
@@ -386,7 +386,7 @@ namespace PairedDelete {
namespace PR7702 {
void test1() {
- new DoesNotExist; // expected-error {{expected a type}}
+ new DoesNotExist; // expected-error {{unknown type name 'DoesNotExist'}}
}
}
@@ -416,3 +416,86 @@ namespace PR10504 {
};
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
}
+
+struct PlacementArg {};
+inline void *operator new[](size_t, const PlacementArg &) throw () {
+ return 0;
+}
+inline void operator delete[](void *, const PlacementArg &) throw () {
+}
+
+namespace r150682 {
+
+ template <typename X>
+ struct S {
+ struct Inner {};
+ S() { new Inner[1]; }
+ };
+
+ struct T {
+ };
+
+ template<typename X>
+ void tfn() {
+ new (*(PlacementArg*)0) T[1];
+ }
+
+ void fn() {
+ tfn<int>();
+ }
+
+}
+
+namespace P12023 {
+ struct CopyCounter
+ {
+ CopyCounter();
+ CopyCounter(const CopyCounter&);
+ };
+
+ int main()
+ {
+ CopyCounter* f = new CopyCounter[10](CopyCounter()); // expected-error {{cannot have initialization arguments}}
+ return 0;
+ }
+}
+
+namespace PR12061 {
+ template <class C> struct scoped_array {
+ scoped_array(C* p = __null);
+ };
+ template <class Payload> struct Foo {
+ Foo() : a_(new scoped_array<int>[5]) { }
+ scoped_array< scoped_array<int> > a_;
+ };
+ class Bar {};
+ Foo<Bar> x;
+
+ template <class C> struct scoped_array2 {
+ scoped_array2(C* p = __null, C* q = __null);
+ };
+ template <class Payload> struct Foo2 {
+ Foo2() : a_(new scoped_array2<int>[5]) { }
+ scoped_array2< scoped_array2<int> > a_;
+ };
+ class Bar2 {};
+ Foo2<Bar2> x2;
+
+ class MessageLoop {
+ public:
+ explicit MessageLoop(int type = 0);
+ };
+ template <class CookieStoreTestTraits>
+ class CookieStoreTest {
+ protected:
+ CookieStoreTest() {
+ new MessageLoop;
+ }
+ };
+ struct CookieMonsterTestTraits {
+ };
+ class DeferredCookieTaskTest : public CookieStoreTest<CookieMonsterTestTraits>
+ {
+ DeferredCookieTaskTest() {}
+ };
+}
diff --git a/test/SemaCXX/null_in_arithmetic_ops.cpp b/test/SemaCXX/null_in_arithmetic_ops.cpp
index 24590ce..a6c0dbf 100644
--- a/test/SemaCXX/null_in_arithmetic_ops.cpp
+++ b/test/SemaCXX/null_in_arithmetic_ops.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -fblocks -Wnull-arithmetic -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -fblocks -Wnull-arithmetic -verify -Wno-string-plus-int %s
#include <stddef.h>
void f() {
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp
index 6f66036..e313603 100644
--- a/test/SemaCXX/nullptr.cpp
+++ b/test/SemaCXX/nullptr.cpp
@@ -109,19 +109,30 @@ namespace test3 {
}
}
-int array0[__is_scalar(nullptr_t)? 1 : -1];
-int array1[__is_pod(nullptr_t)? 1 : -1];
-int array2[sizeof(nullptr_t) == sizeof(void*)? 1 : -1];
-
-// FIXME: when we implement constexpr, this will be testable.
-#if 0
-int relational0[nullptr < nullptr? -1 : 1];
-int relational1[nullptr > nullptr? -1 : 1];
-int relational2[nullptr <= nullptr? 1 : -1];
-int relational3[nullptr >= nullptr? 1 : -1];
-int equality[nullptr == nullptr? 1 : -1];
-int inequality[nullptr != nullptr? -1 : 1];
-#endif
+static_assert(__is_scalar(nullptr_t), "");
+static_assert(__is_pod(nullptr_t), "");
+static_assert(sizeof(nullptr_t) == sizeof(void*), "");
+
+static_assert(!(nullptr < nullptr), "");
+static_assert(!(nullptr > nullptr), "");
+static_assert( nullptr <= nullptr, "");
+static_assert( nullptr >= nullptr, "");
+static_assert( nullptr == nullptr, "");
+static_assert(!(nullptr != nullptr), "");
+
+static_assert(!(0 < nullptr), "");
+static_assert(!(0 > nullptr), "");
+static_assert( 0 <= nullptr, "");
+static_assert( 0 >= nullptr, "");
+static_assert( 0 == nullptr, "");
+static_assert(!(0 != nullptr), "");
+
+static_assert(!(nullptr < 0), "");
+static_assert(!(nullptr > 0), "");
+static_assert( nullptr <= 0, "");
+static_assert( nullptr >= 0, "");
+static_assert( nullptr == 0, "");
+static_assert(!(nullptr != 0), "");
namespace overloading {
int &f1(int*);
@@ -161,3 +172,14 @@ namespace templates {
X2<nullptr, nullptr, nullptr, nullptr> x2;
}
+
+namespace null_pointer_constant {
+
+// Pending implementation of core issue 903, ensure we don't allow any of the
+// C++11 constant evaluation semantics in null pointer constants.
+struct S { int n; };
+constexpr int null() { return 0; }
+void *p = S().n; // expected-error {{cannot initialize}}
+void *q = null(); // expected-error {{cannot initialize}}
+
+}
diff --git a/test/SemaCXX/offsetof.cpp b/test/SemaCXX/offsetof.cpp
index 17cee62..a5f5d34 100644
--- a/test/SemaCXX/offsetof.cpp
+++ b/test/SemaCXX/offsetof.cpp
@@ -66,3 +66,10 @@ struct bar : public foo {
};
int anonstruct[__builtin_offsetof(bar, x) == 0 ? 1 : -1];
+
+struct LtoRCheck {
+ int a[10];
+ int f();
+};
+int ltor = __builtin_offsetof(struct LtoRCheck, a[LtoRCheck().f]); // \
+ expected-error {{reference to non-static member function must be called}}
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 00f6a94..b5e1214 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -8,10 +8,10 @@ void test_f(int iv, float fv) {
int* ip = f(iv);
}
-int* g(int, float, int); // expected-note {{ candidate function }}
-float* g(int, int, int); // expected-note {{ candidate function }}
-double* g(int, float, float); // expected-note {{ candidate function }}
-char* g(int, float, ...); // expected-note {{ candidate function }}
+int* g(int, float, int); // expected-note {{candidate function}}
+float* g(int, int, int); // expected-note {{candidate function}}
+double* g(int, float, float); // expected-note {{candidate function}}
+char* g(int, float, ...); // expected-note {{candidate function}}
void g();
void test_g(int iv, float fv) {
@@ -21,7 +21,7 @@ void test_g(int iv, float fv) {
char* cp1 = g(0, 0);
char* cp2 = g(0, 0, 0, iv, fv);
- double* dp2 = g(0, fv, 1.5); // expected-error {{ call to 'g' is ambiguous; candidates are: }}
+ double* dp2 = g(0, fv, 1.5); // expected-error {{call to 'g' is ambiguous}}
}
double* h(double f);
@@ -126,9 +126,9 @@ void test_bitfield(Bits bits, int x) {
float* fp = bitfields(bits.uint_bitfield, 0u);
}
-int* multiparm(long, int, long); // expected-note {{ candidate function }}
-float* multiparm(int, int, int); // expected-note {{ candidate function }}
-double* multiparm(int, int, short); // expected-note {{ candidate function }}
+int* multiparm(long, int, long); // expected-note {{candidate function}}
+float* multiparm(int, int, int); // expected-note {{candidate function}}
+double* multiparm(int, int, short); // expected-note {{candidate function}}
void test_multiparm(long lv, short sv, int iv) {
int* ip1 = multiparm(lv, iv, lv);
@@ -137,7 +137,7 @@ void test_multiparm(long lv, short sv, int iv) {
float* fp2 = multiparm(sv, iv, iv);
double* dp1 = multiparm(sv, sv, sv);
double* dp2 = multiparm(iv, sv, sv);
- multiparm(sv, sv, lv); // expected-error {{ call to 'multiparm' is ambiguous; candidates are: }}
+ multiparm(sv, sv, lv); // expected-error {{call to 'multiparm' is ambiguous}}
}
// Test overloading based on qualification vs. no qualification
@@ -183,9 +183,9 @@ void test_quals_ranking(int * p, int volatile *pq, int * * pp, int * * * ppp) {
float* q6 = quals_rank2(pp);
- quals_rank3(ppp); // expected-error {{call to 'quals_rank3' is ambiguous; candidates are:}}
+ quals_rank3(ppp); // expected-error {{call to 'quals_rank3' is ambiguous}}
- quals_rank3(p); // expected-error {{call to 'quals_rank3' is ambiguous; candidates are:}}
+ quals_rank3(p); // expected-error {{call to 'quals_rank3' is ambiguous}}
quals_rank3(pq);
}
@@ -233,7 +233,7 @@ float* intref(const int&);
void intref_test() {
float* ir1 = intref(5);
- float* ir2 = intref(5.5);
+ float* ir2 = intref(5.5); // expected-warning{{implicit conversion turns literal floating-point number into integer}}
}
void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}}
@@ -266,8 +266,8 @@ float& cvqual_subsume2(const volatile Y&); // expected-note{{candidate function}
Z get_Z();
void cvqual_subsume_test(Z z) {
- cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous; candidates are:}}
- int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous; candidates are:}}
+ cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous}}
+ int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous}}
}
// Test overloading with cv-qualification differences in reference
@@ -534,3 +534,37 @@ namespace rdar9803316 {
int &ir = (&foo)(0);
}
}
+
+namespace IncompleteArg {
+ // Ensure that overload resolution attempts to complete argument types when
+ // performing ADL.
+ template<typename T> struct S {
+ friend int f(const S&);
+ };
+ extern S<int> s;
+ int k = f(s);
+
+ template<typename T> struct Op {
+ friend bool operator==(const Op &, const Op &);
+ };
+ extern Op<char> op;
+ bool b = op == op;
+
+ // ... and not in other cases! Nothing here requires U<int()> to be complete.
+ // (Note that instantiating U<int()> will fail.)
+ template<typename T> struct U {
+ T t;
+ };
+ struct Consumer {
+ template<typename T>
+ int operator()(const U<T> &);
+ };
+ template<typename T> U<T> &make();
+ Consumer c;
+ int n = sizeof(c(make<int()>()));
+}
+
+namespace PR12142 {
+ void fun(int (*x)[10]); // expected-note{{candidate function not viable: 1st argument ('const int (*)[10]') would lose const qualifier}}
+ void g() { fun((const int(*)[10])0); } // expected-error{{no matching function for call to 'fun'}}
+}
diff --git a/test/SemaCXX/overload-member-call.cpp b/test/SemaCXX/overload-member-call.cpp
index 37815b9..37c9552 100644
--- a/test/SemaCXX/overload-member-call.cpp
+++ b/test/SemaCXX/overload-member-call.cpp
@@ -32,7 +32,7 @@ struct X {
static void test_member_static() {
double& d1 = g(0.0);
- g(0); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+ g(0); // expected-error{{call to 'g' is ambiguous}}
}
};
@@ -41,8 +41,8 @@ void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp)
int& i2 = xcp->f(0);
float& f1 = x.f(0);
float& f2 = xp->f(0);
- xv.f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}}
- xvp->f(0); // expected-error{{no matching member function for call to 'f'; candidates are:}}
+ xv.f(0); // expected-error{{no matching member function for call to 'f'}}
+ xvp->f(0); // expected-error{{no matching member function for call to 'f'}}
int& i3 = xc.g(0);
int& i4 = xcp->g(0);
@@ -50,7 +50,7 @@ void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp)
float& f4 = xp->g(0);
double& d1 = xp->g(0.0);
double& d2 = X::g(0.0);
- X::g(0); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+ X::g(0); // expected-error{{call to 'g' is ambiguous}}
X::h(0); // expected-error{{call to non-static member function without an object argument}}
}
diff --git a/test/SemaCXX/overloaded-name.cpp b/test/SemaCXX/overloaded-name.cpp
index a5ec51c..6da0354 100644
--- a/test/SemaCXX/overloaded-name.cpp
+++ b/test/SemaCXX/overloaded-name.cpp
@@ -21,11 +21,10 @@ namespace rdar9623945 {
public:
const char* text(void);
void g(void) {
- // FIXME: why 2x?
f(text());
- f(text); // expected-error 2{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ f(text); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
f(text());
- f(text); // expected-error 2{{reference to non-static member function must be called; did you mean to call it with no arguments?}}
+ f(text); // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
}
};
}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 1e4a3b7..8ecb54d 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -232,7 +232,7 @@ struct Arrow2 {
void test_arrow(Arrow1 a1, Arrow2 a2, const Arrow2 a3) {
int &i1 = a1->m;
int &i2 = a2->m;
- a3->m; // expected-error{{no viable overloaded 'operator->'; candidate is}}
+ a3->m; // expected-error{{no viable overloaded 'operator->'}}
}
struct CopyConBase {
@@ -392,7 +392,7 @@ namespace rdar9136502 {
};
struct Y {
- Y &operator<<(int); // expected-note{{candidate function not viable: no known conversion from '<bound member function type>' to 'int'}}
+ Y &operator<<(int);
};
void f(X x, Y y) {
@@ -408,3 +408,10 @@ class StringRef {
};
}
+
+namespace PR11784 {
+ struct A { A& operator=(void (*x)()); };
+ void f();
+ void f(int);
+ void g() { A x; x = f; }
+}
diff --git a/test/SemaCXX/pragma-visibility.cpp b/test/SemaCXX/pragma-visibility.cpp
new file mode 100644
index 0000000..e3ef97a
--- /dev/null
+++ b/test/SemaCXX/pragma-visibility.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace test1 __attribute__((visibility("hidden"))) { // expected-note{{surrounding namespace with visibility attribute starts here}}
+#pragma GCC visibility pop // expected-error{{#pragma visibility pop with no matching #pragma visibility push}}
+}
+
+// GCC 4.6 accepts this, but the "hidden" leaks past the namespace end.
+namespace test2 __attribute__((visibility("hidden"))) {
+#pragma GCC visibility push(protected) // expected-error{{#pragma visibility push with no matching #pragma visibility pop}}
+} // expected-note{{surrounding namespace with visibility attribute ends here}}
+
+#pragma GCC visibility pop // expected-error{{#pragma visibility pop with no matching #pragma visibility push}}
+
+// <rdar://problem/10871094>
+struct A {
+ #pragma GCC visibility push(protected)
+ #pragma GCC visibility pop
+};
+
+void f() {
+ #pragma GCC visibility push(protected)
+ #pragma GCC visibility pop
+}
diff --git a/test/SemaCXX/pseudo-destructors.cpp b/test/SemaCXX/pseudo-destructors.cpp
index d71304e..a8f6683 100644
--- a/test/SemaCXX/pseudo-destructors.cpp
+++ b/test/SemaCXX/pseudo-destructors.cpp
@@ -19,7 +19,7 @@ void cv_test(const volatile T* cvt) {
cvt->T::~T(); // no-warning
}
-void f(A* a, Foo *f, int *i, double *d) {
+void f(A* a, Foo *f, int *i, double *d, int ii) {
a->~A();
a->A::~A();
@@ -46,6 +46,9 @@ void f(A* a, Foo *f, int *i, double *d) {
i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}}
+ ii->~Integer(); // expected-error{{member reference type 'int' is not a pointer; maybe you meant to use '.'?}}
+ ii.~Integer();
+
cv_test(a);
cv_test(f);
cv_test(i);
@@ -68,3 +71,12 @@ void test_X0(N1::X0 &x0) {
x0.~X0();
}
+namespace PR11339 {
+ template<class T>
+ void destroy(T* p) {
+ p->~T(); // ok
+ p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}}
+ }
+
+ template void destroy(int*); // expected-note{{in instantiation of function template specialization}}
+}
diff --git a/test/SemaCXX/qual-id-test.cpp b/test/SemaCXX/qual-id-test.cpp
index e5c7306..9994d75 100644
--- a/test/SemaCXX/qual-id-test.cpp
+++ b/test/SemaCXX/qual-id-test.cpp
@@ -137,13 +137,13 @@ struct a {
a a;
-int a::sa = a.a; // expected-error {{invalid use of nonstatic data member 'a'}}
+int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}}
namespace PR6645 {
typedef int foo;
namespace Inner {
typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
- // expected-error{{definition or redeclaration of 'foo' not in a namespace enclosing 'PR6645'}}
+ // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}}
}
}
diff --git a/test/SemaCXX/qualified-id-lookup.cpp b/test/SemaCXX/qualified-id-lookup.cpp
index 3cd6e18..d65a468 100644
--- a/test/SemaCXX/qualified-id-lookup.cpp
+++ b/test/SemaCXX/qualified-id-lookup.cpp
@@ -146,3 +146,8 @@ namespace PR6830 {
Z(foo::X()).Work();
}
}
+
+namespace pr12339 {
+ extern "C" void i;
+ pr12339::FOO // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
+} // expected-error{{expected unqualified-id}}
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index 68005a5..7f41b93 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -9,13 +9,27 @@ typedef void (*fnptr)();
// Test the conversion to self.
void self_conversion()
{
- // T*->T* is allowed, T->T in general not.
+ // T->T is allowed per [expr.reinterpret.cast]p2 so long as it doesn't
+ // cast away constness, and is integral, enumeration, pointer or
+ // pointer-to-member.
int i = 0;
- (void)reinterpret_cast<int>(i); // expected-error {{reinterpret_cast from 'int' to 'int' is not allowed}}
- structure s;
- (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}}
+ (void)reinterpret_cast<int>(i);
+
+ test e = testval;
+ (void)reinterpret_cast<test>(e);
+
+ // T*->T* is allowed
int *pi = 0;
(void)reinterpret_cast<int*>(pi);
+
+ const int structure::*psi = 0;
+ (void)reinterpret_cast<const int structure::*>(psi);
+
+ structure s;
+ (void)reinterpret_cast<structure>(s); // expected-error {{reinterpret_cast from 'structure' to 'structure' is not allowed}}
+
+ float f = 0.0f;
+ (void)reinterpret_cast<float>(f); // expected-error {{reinterpret_cast from 'float' to 'float' is not allowed}}
}
// Test conversion between pointer and integral types, as in /3 and /4.
diff --git a/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp b/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp
index 09d08f9..9cdf5a1 100644
--- a/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp
+++ b/test/SemaCXX/reinterpret-fn-obj-pedantic.cpp
@@ -4,6 +4,6 @@ void fnptrs()
{
typedef void (*fnptr)();
fnptr fp = 0;
- void *vp = reinterpret_cast<void*>(fp); // expected-warning {{reinterpret_cast between pointer-to-function and pointer-to-object is an extension}}
- (void)reinterpret_cast<fnptr>(vp); // expected-warning {{reinterpret_cast between pointer-to-function and pointer-to-object is an extension}}
+ void *vp = reinterpret_cast<void*>(fp); // expected-warning {{cast between pointer-to-function and pointer-to-object is an extension}}
+ (void)reinterpret_cast<fnptr>(vp); // expected-warning {{cast between pointer-to-function and pointer-to-object is an extension}}
}
diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp
index e06ba40..617de00 100644
--- a/test/SemaCXX/return-noreturn.cpp
+++ b/test/SemaCXX/return-noreturn.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code
-// RUN: %clang_cc1 %s -fsyntax-only -std=c++11 -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++11 -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code -Wno-covered-switch-default
// A destructor may be marked noreturn and should still influence the CFG.
void pr6884_abort() __attribute__((noreturn));
diff --git a/test/SemaCXX/runtimediag-ppe.cpp b/test/SemaCXX/runtimediag-ppe.cpp
new file mode 100644
index 0000000..0e8451b
--- /dev/null
+++ b/test/SemaCXX/runtimediag-ppe.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Make sure diagnostics that we don't print based on runtime control
+// flow are delayed correctly in cases where we can't immediately tell whether
+// the context is unevaluated.
+
+namespace std {
+ class type_info;
+}
+
+int& NP(int);
+void test1() { (void)typeid(NP(1 << 32)); }
+
+class Poly { virtual ~Poly(); };
+Poly& P(int);
+void test2() { (void)typeid(P(1 << 32)); } // expected-warning {{shift count >= width of type}}
+
+void test3() { 1 ? (void)0 : (void)typeid(P(1 << 32)); }
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index ad109f4..b659de0 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -20,7 +20,7 @@ namespace test1 {
int f(bool b) {
if (b)
- goto foo; // expected-error {{illegal goto into protected scope}}
+ goto foo; // expected-error {{goto into protected scope}}
C c; // expected-note {{jump bypasses variable initialization}}
foo:
return 1;
diff --git a/test/SemaCXX/statements.cpp b/test/SemaCXX/statements.cpp
index 0e27f46..6d04c84 100644
--- a/test/SemaCXX/statements.cpp
+++ b/test/SemaCXX/statements.cpp
@@ -10,7 +10,7 @@ struct X {
};
void test2() {
- goto later; // expected-error {{illegal goto into protected scope}}
+ goto later; // expected-error {{goto into protected scope}}
X x; // expected-note {{jump bypasses variable initialization}}
later:
;
diff --git a/test/SemaCXX/static-assert.cpp b/test/SemaCXX/static-assert.cpp
index 0991a5f..364e4e4 100644
--- a/test/SemaCXX/static-assert.cpp
+++ b/test/SemaCXX/static-assert.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=x86_64-linux-gnu
-int f();
+int f(); // expected-note {{declared here}}
-static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}}
+static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
static_assert(true, "true is not false");
static_assert(false, "false is false"); // expected-error {{static_assert failed "false is false"}}
@@ -28,3 +28,9 @@ template<typename T> struct S {
S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}}
S<int> s2;
+static_assert(false, L"\xFFFFFFFF"); // expected-error {{static_assert failed L"\xFFFFFFFF"}}
+static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u"\U000317FF"}}
+// FIXME: render this as u8"\u03A9"
+static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}}
+static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}}
+static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFFFFFgoop"}}
diff --git a/test/SemaCXX/string-plus-int.cpp b/test/SemaCXX/string-plus-int.cpp
new file mode 100644
index 0000000..5752f8f
--- /dev/null
+++ b/test/SemaCXX/string-plus-int.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-array-bounds %s -fpascal-strings
+// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 -Wno-array-bounds -fpascal-strings | FileCheck %s
+
+void consume(const char* c) {}
+void consume(const unsigned char* c) {}
+void consume(const wchar_t* c) {}
+void consumeChar(char c) {}
+
+enum MyEnum {
+ kMySmallEnum = 1,
+ kMyEnum = 5
+};
+
+enum OperatorOverloadEnum {
+ kMyOperatorOverloadedEnum = 5
+};
+
+const char* operator+(const char* c, OperatorOverloadEnum e) {
+ return "yo";
+}
+
+const char* operator+(OperatorOverloadEnum e, const char* c) {
+ return "yo";
+}
+
+void f(int index) {
+ // Should warn.
+ // CHECK: fix-it:"{{.*}}":{31:11-31:11}:"&"
+ // CHECK: fix-it:"{{.*}}":{31:17-31:18}:"["
+ // CHECK: fix-it:"{{.*}}":{31:20-31:20}:"]"
+ consume("foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume("foo" + index); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume("foo" + kMyEnum); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ consume(5 + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume(index + "foo"); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consume(kMyEnum + "foo"); // expected-warning {{adding 'MyEnum' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ // FIXME: suggest replacing with "foo"[5]
+ consumeChar(*("foo" + 5)); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+ consumeChar(*(5 + "foo")); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ consume(L"foo" + 5); // expected-warning {{adding 'int' to a string does not append to the string}} expected-note {{use array indexing to silence this warning}}
+
+ // Should not warn.
+ consume(&("foo"[3]));
+ consume(&("foo"[index]));
+ consume(&("foo"[kMyEnum]));
+ consume("foo" + kMySmallEnum);
+ consume(kMySmallEnum + "foo");
+
+ consume(L"foo" + 2);
+
+ consume("foo" + 3); // Points at the \0
+ consume("foo" + 4); // Points 1 past the \0, which is legal too.
+ consume("\pfoo" + 4); // Pascal strings don't have a trailing \0, but they
+ // have a leading length byte, so this is fine too.
+
+ consume("foo" + kMyOperatorOverloadedEnum);
+ consume(kMyOperatorOverloadedEnum + "foo");
+
+ #define A "foo"
+ #define B "bar"
+ consume(A B + sizeof(A) - 1);
+}
+
diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp
index 8a8cf33..517faa9 100644
--- a/test/SemaCXX/switch.cpp
+++ b/test/SemaCXX/switch.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
void test() {
bool x = true;
@@ -64,3 +64,24 @@ void click_check_header_sizes() {
case 0: ;
}
}
+
+void local_class(int n) {
+ for (;;) switch (n) {
+ case 0:
+ struct S {
+ void f() {
+ case 1: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ };
+ S().f();
+ []{
+ case 2: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }();
+ }
+}
diff --git a/test/SemaCXX/this.cpp b/test/SemaCXX/this.cpp
index 167755f..27ee1e8 100644
--- a/test/SemaCXX/this.cpp
+++ b/test/SemaCXX/this.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int x = this; // expected-error {{error: invalid use of 'this' outside of a nonstatic member function}}
+int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
void f() {
- int x = this; // expected-error {{error: invalid use of 'this' outside of a nonstatic member function}}
+ int x = this; // expected-error {{invalid use of 'this' outside of a non-static member function}}
}
diff --git a/test/SemaCXX/trailing-return-0x.cpp b/test/SemaCXX/trailing-return-0x.cpp
index e25939f..c219b77 100644
--- a/test/SemaCXX/trailing-return-0x.cpp
+++ b/test/SemaCXX/trailing-return-0x.cpp
@@ -21,6 +21,16 @@ auto g(); // expected-error{{return without trailing return type}}
int h() -> int; // expected-error{{trailing return type must specify return type 'auto', not 'int'}}
+int i();
+auto i() -> int;
+int i() {}
+
+using T = auto (int) -> auto (*)(char) -> void; // expected-note {{previous}}
+using T = void; // expected-error {{type alias redefinition with different types ('void' vs 'auto (int) -> auto (*)(char) -> void')}}
+
+using U = auto (int) -> auto (*)(char) -> void;
+using U = void (*(int))(char); // ok
+
int x;
template <class T>
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 0914c7c..f53939a 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -39,6 +39,18 @@ struct DerivesEmpty : Empty {};
struct HasCons { HasCons(int); };
struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
+struct HasDefaultTrivialCopyAssign {
+ HasDefaultTrivialCopyAssign &operator =(const HasDefaultTrivialCopyAssign&)
+ = default;
+};
+struct TrivialMoveButNotCopy {
+ TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
+ TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
+};
+struct NonTrivialDefault {
+ NonTrivialDefault();
+};
+
struct HasDest { ~HasDest(); };
class HasPriv { int priv; };
class HasProt { protected: int prot; };
@@ -96,6 +108,10 @@ class AllPrivate {
~AllPrivate() throw();
};
+struct ThreeArgCtor {
+ ThreeArgCtor(int*, char*, int);
+};
+
void is_pod()
{
{ int arr[T(__is_pod(int))]; }
@@ -235,6 +251,37 @@ void is_enum()
{ int arr[F(__is_enum(HasAnonymousUnion))]; }
}
+struct FinalClass final {
+};
+
+template<typename T>
+struct PotentiallyFinal { };
+
+template<typename T>
+struct PotentiallyFinal<T*> final { };
+
+template<>
+struct PotentiallyFinal<int> final { };
+
+void is_final()
+{
+ { int arr[T(__is_final(FinalClass))]; }
+ { int arr[T(__is_final(PotentiallyFinal<float*>))]; }
+ { int arr[T(__is_final(PotentiallyFinal<int>))]; }
+
+ { int arr[F(__is_final(int))]; }
+ { int arr[F(__is_final(Union))]; }
+ { int arr[F(__is_final(Int))]; }
+ { int arr[F(__is_final(IntAr))]; }
+ { int arr[F(__is_final(UnionAr))]; }
+ { int arr[F(__is_final(Derives))]; }
+ { int arr[F(__is_final(ClassType))]; }
+ { int arr[F(__is_final(cvoid))]; }
+ { int arr[F(__is_final(IntArNB))]; }
+ { int arr[F(__is_final(HasAnonymousUnion))]; }
+ { int arr[F(__is_final(PotentiallyFinal<float>))]; }
+}
+
typedef HasVirt Polymorph;
struct InheritPolymorph : Polymorph {};
@@ -885,6 +932,41 @@ struct NonTCStruct {
NonTCStruct(const NonTCStruct&) {}
};
+struct AllDefaulted {
+ AllDefaulted() = default;
+ AllDefaulted(const AllDefaulted &) = default;
+ AllDefaulted(AllDefaulted &&) = default;
+ AllDefaulted &operator=(const AllDefaulted &) = default;
+ AllDefaulted &operator=(AllDefaulted &&) = default;
+ ~AllDefaulted() = default;
+};
+
+struct AllDeleted {
+ AllDeleted() = delete;
+ AllDeleted(const AllDeleted &) = delete;
+ AllDeleted(AllDeleted &&) = delete;
+ AllDeleted &operator=(const AllDeleted &) = delete;
+ AllDeleted &operator=(AllDeleted &&) = delete;
+ ~AllDeleted() = delete;
+};
+
+struct ExtDefaulted {
+ ExtDefaulted();
+ ExtDefaulted(const ExtDefaulted &);
+ ExtDefaulted(ExtDefaulted &&);
+ ExtDefaulted &operator=(const ExtDefaulted &);
+ ExtDefaulted &operator=(ExtDefaulted &&);
+ ~ExtDefaulted();
+};
+
+// Despite being defaulted, these functions are not trivial.
+ExtDefaulted::ExtDefaulted() = default;
+ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default;
+ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default;
+ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default;
+ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default;
+ExtDefaulted::~ExtDefaulted() = default;
+
void is_trivial2()
{
int t01[T(__is_trivial(char))];
@@ -909,11 +991,14 @@ void is_trivial2()
int t20[T(__is_trivial(Union))];
int t21[T(__is_trivial(UnionAr))];
int t22[T(__is_trivial(TrivialStruct))];
+ int t23[T(__is_trivial(AllDefaulted))];
+ int t24[T(__is_trivial(AllDeleted))];
int t30[F(__is_trivial(void))];
int t31[F(__is_trivial(NonTrivialStruct))];
int t32[F(__is_trivial(SuperNonTrivialStruct))];
int t33[F(__is_trivial(NonTCStruct))];
+ int t34[F(__is_trivial(ExtDefaulted))];
}
void is_trivially_copyable2()
@@ -941,10 +1026,13 @@ void is_trivially_copyable2()
int t21[T(__is_trivially_copyable(UnionAr))];
int t22[T(__is_trivially_copyable(TrivialStruct))];
int t23[T(__is_trivially_copyable(NonTrivialStruct))];
+ int t24[T(__is_trivially_copyable(AllDefaulted))];
+ int t25[T(__is_trivially_copyable(AllDeleted))];
int t30[F(__is_trivially_copyable(void))];
- int t32[F(__is_trivially_copyable(SuperNonTrivialStruct))];
- int t31[F(__is_trivially_copyable(NonTCStruct))];
+ int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
+ int t32[F(__is_trivially_copyable(NonTCStruct))];
+ int t33[F(__is_trivially_copyable(ExtDefaulted))];
}
struct CStruct {
@@ -1100,6 +1188,8 @@ void has_trivial_default_constructor() {
{ int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
{ int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
{ int arr[T(__has_trivial_constructor(const Int))]; }
+ { int arr[T(__has_trivial_constructor(AllDefaulted))]; }
+ { int arr[T(__has_trivial_constructor(AllDeleted))]; }
{ int arr[F(__has_trivial_constructor(HasCons))]; }
{ int arr[F(__has_trivial_constructor(HasRef))]; }
@@ -1110,6 +1200,7 @@ void has_trivial_default_constructor() {
{ int arr[F(__has_trivial_constructor(cvoid))]; }
{ int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
{ int arr[F(__has_trivial_constructor(AllPrivate))]; }
+ { int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
}
void has_trivial_copy_constructor() {
@@ -1130,6 +1221,8 @@ void has_trivial_copy_constructor() {
{ int arr[T(__has_trivial_copy(HasCopyAssign))]; }
{ int arr[T(__has_trivial_copy(HasMoveAssign))]; }
{ int arr[T(__has_trivial_copy(const Int))]; }
+ { int arr[T(__has_trivial_copy(AllDefaulted))]; }
+ { int arr[T(__has_trivial_copy(AllDeleted))]; }
{ int arr[F(__has_trivial_copy(HasCopy))]; }
{ int arr[F(__has_trivial_copy(HasTemplateCons))]; }
@@ -1138,6 +1231,7 @@ void has_trivial_copy_constructor() {
{ int arr[F(__has_trivial_copy(void))]; }
{ int arr[F(__has_trivial_copy(cvoid))]; }
{ int arr[F(__has_trivial_copy(AllPrivate))]; }
+ { int arr[F(__has_trivial_copy(ExtDefaulted))]; }
}
void has_trivial_copy_assignment() {
@@ -1154,6 +1248,8 @@ void has_trivial_copy_assignment() {
{ int arr[T(__has_trivial_assign(HasCopy))]; }
{ int arr[T(__has_trivial_assign(HasMove))]; }
{ int arr[T(__has_trivial_assign(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_assign(AllDefaulted))]; }
+ { int arr[T(__has_trivial_assign(AllDeleted))]; }
{ int arr[F(__has_trivial_assign(IntRef))]; }
{ int arr[F(__has_trivial_assign(HasCopyAssign))]; }
@@ -1165,6 +1261,7 @@ void has_trivial_copy_assignment() {
{ int arr[F(__has_trivial_assign(void))]; }
{ int arr[F(__has_trivial_assign(cvoid))]; }
{ int arr[F(__has_trivial_assign(AllPrivate))]; }
+ { int arr[F(__has_trivial_assign(ExtDefaulted))]; }
}
void has_trivial_destructor() {
@@ -1187,11 +1284,14 @@ void has_trivial_destructor() {
{ int arr[T(__has_trivial_destructor(const Int))]; }
{ int arr[T(__has_trivial_destructor(DerivesAr))]; }
{ int arr[T(__has_trivial_destructor(VirtAr))]; }
+ { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
+ { int arr[T(__has_trivial_destructor(AllDeleted))]; }
{ int arr[F(__has_trivial_destructor(HasDest))]; }
{ int arr[F(__has_trivial_destructor(void))]; }
{ int arr[F(__has_trivial_destructor(cvoid))]; }
{ int arr[F(__has_trivial_destructor(AllPrivate))]; }
+ { int arr[F(__has_trivial_destructor(ExtDefaulted))]; }
}
struct A { ~A() {} };
@@ -1413,13 +1513,11 @@ void is_base_of() {
isBaseOfF<DerivedB<int>, BaseA<int> >();
}
-#if 0
template<class T, class U>
class TemplateClass {};
template<class T>
using TemplateAlias = TemplateClass<T, int>;
-#endif
typedef class Base BaseTypedef;
@@ -1427,9 +1525,7 @@ void is_same()
{
int t01[T(__is_same(Base, Base))];
int t02[T(__is_same(Base, BaseTypedef))];
-#if 0
int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
-#endif
int t10[F(__is_same(Base, const Base))];
int t11[F(__is_same(Base, Base&))];
@@ -1512,6 +1608,12 @@ void is_convertible_to() {
{ int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
}
+namespace is_convertible_to_instantiate {
+ // Make sure we don't try to instantiate the constructor.
+ template<int x> class A { A(int) { int a[x]; } };
+ int x = __is_convertible_to(int, A<-1>);
+}
+
void is_trivial()
{
{ int arr[T(__is_trivial(int))]; }
@@ -1557,7 +1659,7 @@ void is_trivial()
{ int arr[F(__is_trivial(cvoid))]; }
}
-void is_trivially_copyable()
+void trivial_checks()
{
{ int arr[T(__is_trivially_copyable(int))]; }
{ int arr[T(__is_trivially_copyable(Enum))]; }
@@ -1600,6 +1702,108 @@ void is_trivially_copyable()
{ int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
{ int arr[F(__is_trivially_copyable(void))]; }
{ int arr[F(__is_trivially_copyable(cvoid))]; }
+
+ { int arr[T((__is_trivially_constructible(int)))]; }
+ { int arr[T((__is_trivially_constructible(int, int)))]; }
+ { int arr[T((__is_trivially_constructible(int, float)))]; }
+ { int arr[T((__is_trivially_constructible(int, int&)))]; }
+ { int arr[T((__is_trivially_constructible(int, const int&)))]; }
+ { int arr[T((__is_trivially_constructible(int, int)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; }
+ { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; }
+ { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+ const NonTrivialDefault&)))]; }
+ { int arr[T((__is_trivially_constructible(NonTrivialDefault,
+ NonTrivialDefault&&)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted,
+ const AllDefaulted &)))]; }
+ { int arr[T((__is_trivially_constructible(AllDefaulted,
+ AllDefaulted &&)))]; }
+
+ { int arr[F((__is_trivially_constructible(int, int*)))]; }
+ { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; }
+ { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted,
+ const AllDeleted &)))]; }
+ { int arr[F((__is_trivially_constructible(AllDeleted,
+ AllDeleted &&)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted,
+ const ExtDefaulted &)))]; }
+ { int arr[F((__is_trivially_constructible(ExtDefaulted,
+ ExtDefaulted &&)))]; }
+
+ { int arr[T((__is_trivially_assignable(int&, int)))]; }
+ { int arr[T((__is_trivially_assignable(int&, int&)))]; }
+ { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
+ { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
+ { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
+ { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
+ { int arr[T((__is_trivially_assignable(AllDefaulted,
+ const AllDefaulted &)))]; }
+ { int arr[T((__is_trivially_assignable(AllDefaulted,
+ AllDefaulted &&)))]; }
+
+ { int arr[F((__is_trivially_assignable(int*&, float*)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; }
+ { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; }
+ { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy&)))]; }
+ { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ const TrivialMoveButNotCopy&)))]; }
+ { int arr[F((__is_trivially_assignable(AllDeleted,
+ const AllDeleted &)))]; }
+ { int arr[F((__is_trivially_assignable(AllDeleted,
+ AllDeleted &&)))]; }
+ { int arr[F((__is_trivially_assignable(ExtDefaulted,
+ const ExtDefaulted &)))]; }
+ { int arr[F((__is_trivially_assignable(ExtDefaulted,
+ ExtDefaulted &&)))]; }
+
+ { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+ HasDefaultTrivialCopyAssign&)))]; }
+ { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
+ const HasDefaultTrivialCopyAssign&)))]; }
+ { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy)))]; }
+ { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
+ TrivialMoveButNotCopy&&)))]; }
+}
+
+// Instantiation of __is_trivially_constructible
+template<typename T, typename ...Args>
+struct is_trivially_constructible {
+ static const bool value = __is_trivially_constructible(T, Args...);
+};
+
+void is_trivially_constructible_test() {
+ { int arr[T((is_trivially_constructible<int>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int>::value))]; }
+ { int arr[T((is_trivially_constructible<int, float>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int&>::value))]; }
+ { int arr[T((is_trivially_constructible<int, const int&>::value))]; }
+ { int arr[T((is_trivially_constructible<int, int>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; }
+ { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; }
+ { int arr[T((is_trivially_constructible<NonTrivialDefault,
+ const NonTrivialDefault&>::value))]; }
+ { int arr[T((is_trivially_constructible<NonTrivialDefault,
+ NonTrivialDefault&&>::value))]; }
+
+ { int arr[F((is_trivially_constructible<int, int*>::value))]; }
+ { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; }
+ { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; }
}
void array_rank() {
diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp
index 7db1970..b53bcd2 100644
--- a/test/SemaCXX/typedef-redecl.cpp
+++ b/test/SemaCXX/typedef-redecl.cpp
@@ -54,3 +54,42 @@ namespace PR7462 {
typedef int operator! (A); // expected-error{{typedef name must be an identifier}}
int i = !A(); // expected-error{{invalid argument type}}
}
+
+template<typename T>
+typedef T f(T t) { return t; } // expected-error {{function definition declared 'typedef'}}
+int k = f(0);
+int k2 = k;
+
+namespace PR11630 {
+ template <class T>
+ struct S
+ {
+ static const unsigned C = 1;
+ static void f()
+ {
+ typedef int q[C == 1 ? 1 : -1]; // expected-note{{previous definition is here}}
+ typedef int q[C >= 1 ? 2 : -2]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
+ typedef int n[C == 1 ? 1 : -1];
+ typedef int n[C >= 1 ? 1 : -1];
+ }
+ };
+
+ template <int T>
+ struct S2
+ {
+ static void f()
+ {
+ typedef int q[1]; // expected-note{{previous definition is here}}
+ typedef int q[T]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
+ }
+ };
+
+ void f() {
+ S<int> a;
+ a.f(); // expected-note{{in instantiation of member function 'PR11630::S<int>::f' requested here}}
+ S2<1> b;
+ b.f();
+ S2<2> b2;
+ b2.f(); // expected-note{{in instantiation of member function 'PR11630::S2<2>::f' requested here}}
+ }
+}
diff --git a/test/SemaCXX/typeid.cpp b/test/SemaCXX/typeid.cpp
index 8db7db5..d3a2a28 100644
--- a/test/SemaCXX/typeid.cpp
+++ b/test/SemaCXX/typeid.cpp
@@ -2,7 +2,7 @@
void f()
{
- (void)typeid(int); // expected-error {{error: you need to include <typeinfo> before using the 'typeid' operator}}
+ (void)typeid(int); // expected-error {{you need to include <typeinfo> before using the 'typeid' operator}}
}
namespace std {
diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp
index fa32c57..b1e8d91 100644
--- a/test/SemaCXX/typo-correction.cpp
+++ b/test/SemaCXX/typo-correction.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++0x-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
struct errc {
int v_;
@@ -29,3 +29,164 @@ public:
inline error_condition make_error_condition(errc _e) {
return error_condition(static_cast<int>(_e));
}
+
+
+// Prior to the introduction of a callback object to further filter possible
+// typo corrections, this example would not trigger a suggestion as "base_type"
+// is a closer match to "basetype" than is "BaseType" but "base_type" does not
+// refer to a base class or non-static data member.
+struct BaseType { };
+struct Derived : public BaseType { // expected-note {{base class 'BaseType' specified here}}
+ static int base_type; // expected-note {{'base_type' declared here}}
+ Derived() : basetype() {} // expected-error{{initializer 'basetype' does not name a non-static data member or base class; did you mean the base class 'BaseType'?}}
+};
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// the helper function LookupMemberExprInRecord.
+int get_type(struct Derived *st) {
+ return st->Base_Type; // expected-error{{no member named 'Base_Type' in 'Derived'; did you mean 'base_type'?}}
+}
+
+// In this example, somename should not be corrected to the cached correction
+// "some_name" since "some_name" is a class and a namespace name is needed.
+class some_name {}; // expected-note {{'some_name' declared here}}
+somename Foo; // expected-error {{unknown type name 'somename'; did you mean 'some_name'?}}
+namespace SomeName {} // expected-note {{namespace 'SomeName' defined here}}
+using namespace somename; // expected-error {{no namespace named 'somename'; did you mean 'SomeName'?}}
+
+
+// Without the callback object, CorrectTypo would choose "field1" as the
+// correction for "fielda" as it is closer than "FieldA", but that correction
+// would be later discarded by the caller and no suggestion would be given.
+struct st {
+ struct {
+ int field1;
+ };
+ double FieldA; // expected-note{{'FieldA' declared here}}
+};
+st var = { .fielda = 0.0 }; // expected-error{{field designator 'fielda' does not refer to any field in type 'st'; did you mean 'FieldA'?}}
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// Sema::BuildCXXNestedNameSpecifier. And also for the improvement by doing
+// so in Sema::getTypeName.
+typedef char* another_str; // expected-note{{'another_str' declared here}}
+namespace AnotherStd { // expected-note{{'AnotherStd' declared here}}
+ class string {};
+}
+another_std::string str; // expected-error{{use of undeclared identifier 'another_std'; did you mean 'AnotherStd'?}}
+another_str *cstr = new AnotherStr; // expected-error{{unknown type name 'AnotherStr'; did you mean 'another_str'?}}
+
+// Test the improvement from passing a callback object to CorrectTypo in
+// Sema::ActOnSizeofParameterPackExpr.
+char* TireNames;
+template<typename ...TypeNames> struct count { // expected-note{{parameter pack 'TypeNames' declared here}}
+ static const unsigned value = sizeof...(TyreNames); // expected-error{{'TyreNames' does not refer to the name of a parameter pack; did you mean 'TypeNames'?}}
+};
+
+// Test the typo-correction callback in Sema::DiagnoseUnknownTypeName.
+namespace unknown_type_test {
+ class StreamOut {}; // expected-note 2 {{'StreamOut' declared here}}
+ long stream_count; // expected-note 2 {{'stream_count' declared here}}
+};
+unknown_type_test::stream_out out; // expected-error{{no type named 'stream_out' in namespace 'unknown_type_test'; did you mean 'StreamOut'?}}
+
+// Demonstrate a case where using only the cached value returns the wrong thing
+// when the cached value was the result of a previous callback object that only
+// accepts a subset of the current callback object.
+namespace {
+using namespace unknown_type_test;
+void bar(long i);
+void before_caching_classname() {
+ bar((stream_out)); // expected-error{{use of undeclared identifier 'stream_out'; did you mean 'stream_count'?}}
+}
+stream_out out; // expected-error{{unknown type name 'stream_out'; did you mean 'StreamOut'?}}
+void after_caching_classname() {
+ bar((stream_out)); // expected-error{{use of undeclared identifier 'stream_out'; did you mean 'stream_count'?}}
+}
+}
+
+// Test the typo-correction callback in Sema::DiagnoseInvalidRedeclaration.
+struct BaseDecl {
+ void add_in(int i);
+};
+struct TestRedecl : public BaseDecl {
+ void add_it(int i); // expected-note{{'add_it' declared here}}
+};
+void TestRedecl::add_in(int i) {} // expected-error{{out-of-line definition of 'add_in' does not match any declaration in 'TestRedecl'; did you mean 'add_it'?}}
+
+// Test the improved typo correction for the Parser::ParseCastExpr =>
+// Sema::ActOnIdExpression => Sema::DiagnoseEmptyLookup call path.
+class SomeNetMessage;
+class Message {};
+void foo(Message&);
+void foo(SomeNetMessage&);
+void doit(void *data) {
+ Message somenetmsg; // expected-note{{'somenetmsg' declared here}}
+ foo(somenetmessage); // expected-error{{use of undeclared identifier 'somenetmessage'; did you mean 'somenetmsg'?}}
+ foo((somenetmessage)data); // expected-error{{use of undeclared identifier 'somenetmessage'; did you mean 'SomeNetMessage'?}}
+}
+
+// Test the typo-correction callback in BuildRecoveryCallExpr.
+// Solves the main issue in PR 9320 of suggesting corrections that take the
+// wrong number of arguments.
+void revoke(const char*); // expected-note 2{{'revoke' declared here}}
+void Test() {
+ Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}}
+ Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}}
+ Invoke("foo", "bar"); // expected-error{{use of undeclared identifier 'Invoke'}}
+}
+void Test2(void (*invoke)(const char *, int)) { // expected-note{{'invoke' declared here}}
+ Invoke(); // expected-error{{use of undeclared identifier 'Invoke'}}
+ Invoke("foo"); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'revoke'?}}
+ Invoke("foo", 7); // expected-error{{use of undeclared identifier 'Invoke'; did you mean 'invoke'?}}
+ Invoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Invoke'}}
+}
+
+void provoke(const char *x, bool y=false) {} // expected-note 2{{'provoke' declared here}}
+void Test3() {
+ Provoke(); // expected-error{{use of undeclared identifier 'Provoke'}}
+ Provoke("foo"); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}}
+ Provoke("foo", true); // expected-error{{use of undeclared identifier 'Provoke'; did you mean 'provoke'?}}
+ Provoke("foo", 7, 22); // expected-error{{use of undeclared identifier 'Provoke'}}
+}
+
+// PR 11737 - Don't try to typo-correct the implicit 'begin' and 'end' in a
+// C++11 for-range statement.
+struct R {};
+bool begun(R);
+void RangeTest() {
+ for (auto b : R()) {} // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type}}
+}
+
+// PR 12019 - Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration
+// by not trying to typo-correct a method redeclaration to declarations not
+// in the current record.
+class Parent {
+ void set_types(int index, int value);
+ void add_types(int value);
+};
+class Child: public Parent {};
+void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}}
+
+// Fix the callback based filtering of typo corrections within
+// Sema::ActOnIdExpression by Parser::ParseCastExpression to allow type names as
+// potential corrections for template arguments.
+namespace clash {
+class ConstructExpr {}; // expected-note{{'clash::ConstructExpr' declared here}}
+}
+class ClashTool {
+ bool HaveConstructExpr();
+ template <class T> T* getExprAs();
+
+ void test() {
+ ConstructExpr *expr = // expected-error{{unknown type name 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+ getExprAs<ConstructExpr>(); // expected-error{{use of undeclared identifier 'ConstructExpr'; did you mean 'clash::ConstructExpr'?}}
+ }
+};
+
+namespace test1 {
+ struct S {
+ struct Foobar *f; // expected-note{{'Foobar' declared here}}
+ };
+ test1::FooBar *b; // expected-error{{no type named 'FooBar' in namespace 'test1'; did you mean 'Foobar'?}}
+}
diff --git a/test/SemaCXX/undefined-internal.cpp b/test/SemaCXX/undefined-internal.cpp
index e926f18..1541720 100644
--- a/test/SemaCXX/undefined-internal.cpp
+++ b/test/SemaCXX/undefined-internal.cpp
@@ -122,3 +122,62 @@ namespace PR9323 {
f(Uncopyable()); // expected-warning {{C++98 requires an accessible copy constructor}}
};
}
+
+
+namespace std { class type_info; };
+namespace cxx11_odr_rules {
+ // Note: the way this test is written isn't really ideal, but there really
+ // isn't any other way to check that the odr-used logic for constants
+ // is working without working implicit capture in lambda-expressions.
+ // (The more accurate used-but-not-defined warning is the only other visible
+ // effect of accurate odr-used computation.)
+ //
+ // Note that the warning in question can trigger in cases some people would
+ // consider false positives; hopefully that happens rarely in practice.
+ //
+ // FIXME: Suppressing this test while I figure out how to fix a bug in the
+ // odr-use marking code.
+
+ namespace {
+ struct A {
+ static const int unused = 10;
+ static const int used1 = 20; // xpected-warning {{internal linkage}}
+ static const int used2 = 20; // xpected-warning {{internal linkage}}
+ virtual ~A() {}
+ };
+ }
+
+ void a(int,int);
+ A& p(const int&) { static A a; return a; }
+
+ // Check handling of default arguments
+ void b(int = A::unused);
+
+ void tests() {
+ // Basic test
+ a(A::unused, A::unused);
+
+ // Check that nesting an unevaluated or constant-evaluated context does
+ // the right thing.
+ a(A::unused, sizeof(int[10]));
+
+ // Check that the checks work with unevaluated contexts
+ (void)sizeof(p(A::used1));
+ (void)typeid(p(A::used1)); // xpected-note {{used here}}
+
+ // Misc other testing
+ a(A::unused, 1 ? A::used2 : A::used2); // xpected-note {{used here}}
+ b();
+ }
+}
+
+
+namespace OverloadUse {
+ namespace {
+ void f();
+ void f(int); // expected-warning {{function 'OverloadUse::<anonymous namespace>::f' has internal linkage but is not defined}}
+ }
+ template<void x()> void t(int*) { x(); }
+ template<void x(int)> void t(long*) { x(10); } // expected-note {{used here}}
+ void g() { long a; t<f>(&a); }
+}
diff --git a/test/SemaCXX/underlying_type.cpp b/test/SemaCXX/underlying_type.cpp
index dcfaab3..7bca06b 100644
--- a/test/SemaCXX/underlying_type.cpp
+++ b/test/SemaCXX/underlying_type.cpp
@@ -35,3 +35,9 @@ static_assert(is_same_type<underlying_type<f>::type, char>::value,
"f has the wrong underlying type in the template");
underlying_type<int>::type e; // expected-note {{requested here}}
+
+using uint = unsigned;
+enum class foo : uint { bar };
+
+static_assert(is_same_type<underlying_type<foo>::type, unsigned>::value,
+ "foo has the wrong underlying type");
diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp
index 358a572..eb6428d 100644
--- a/test/SemaCXX/uninit-variables.cpp
+++ b/test/SemaCXX/uninit-variables.cpp
@@ -27,7 +27,7 @@ void unevaluated_tests() {
struct A { virtual ~A() {} };
void polymorphic_test() {
A *a; // expected-note{{initialize the variable 'a' to silence this warning}}
- (void)typeid(*a); // expected-warning{{variable 'a' is uninitialized when used here }}
+ (void)typeid(*a); // expected-warning{{variable 'a' is uninitialized when used here}}
}
// Handle cases where the CFG may constant fold some branches, thus
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index c25bd20..7879e7c 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s
int foo(int x);
int bar(int* x);
@@ -33,6 +33,7 @@ class A {
int num;
static int count;
int get() const { return num; }
+ int get2() { return num; }
void set(int x) { num = x; }
static int zero() { return 0; }
@@ -41,6 +42,7 @@ class A {
A(int x) {}
A(int *x) {}
A(A *a) {}
+ ~A();
};
A getA() { return A(); }
@@ -66,6 +68,7 @@ void setupA() {
A a14 = A(a14); // expected-warning {{variable 'a14' is uninitialized when used within its own initialization}}
A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}}
A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}}
+ A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}}
}
struct B {
@@ -117,3 +120,50 @@ struct S {
};
struct C { char a[100], *e; } car = { .e = car.a };
+
+// <rdar://problem/10398199>
+namespace rdar10398199 {
+ class FooBase { protected: ~FooBase() {} };
+ class Foo : public FooBase {
+ public:
+ operator int&() const;
+ };
+ void stuff();
+ template <typename T> class FooImpl : public Foo {
+ T val;
+ public:
+ FooImpl(const T &x) : val(x) {}
+ ~FooImpl() { stuff(); }
+ };
+
+ template <typename T> FooImpl<T> makeFoo(const T& x) {
+ return FooImpl<T>(x);
+ }
+
+ void test() {
+ const Foo &x = makeFoo(42);
+ const int&y = makeFoo(42u);
+ (void)x;
+ (void)y;
+ };
+}
+
+// PR 12325 - this was a false uninitialized value warning due to
+// a broken CFG.
+int pr12325(int params) {
+ int x = ({
+ while (false)
+ ;
+ int _v = params;
+ if (false)
+ ;
+ _v; // no-warning
+ });
+ return x;
+}
+
+// Test lambda expressions with -Wuninitialized
+int test_lambda() {
+ auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning {{C++11 requires lambda with omitted result type to consist of a single return statement}} expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}}
+ return f1(1, 2);
+}
diff --git a/test/SemaCXX/unknown-anytype-blocks.cpp b/test/SemaCXX/unknown-anytype-blocks.cpp
new file mode 100644
index 0000000..86ce7e1
--- /dev/null
+++ b/test/SemaCXX/unknown-anytype-blocks.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -funknown-anytype -fblocks -fsyntax-only -verify -std=c++11 %s
+
+namespace test1 {
+ __unknown_anytype (^foo)();
+ __unknown_anytype (^bar)();
+ int test() {
+ auto ret1 = (int)foo();
+ auto ret2 = bar(); // expected-error {{'bar' has unknown return type; cast the call to its declared return type}}
+ return ret1;
+ }
+}
diff --git a/test/SemaCXX/unknown-anytype.cpp b/test/SemaCXX/unknown-anytype.cpp
index ba52122..a07ec83 100644
--- a/test/SemaCXX/unknown-anytype.cpp
+++ b/test/SemaCXX/unknown-anytype.cpp
@@ -14,9 +14,9 @@ namespace test1 {
// making sure that these locations check for placeholder types
// properly.
- int x = foo; // expected-error {{cannot initialize}}
+ int x = foo; // expected-error {{'foo' has unknown type}}
int y = 0 + foo; // expected-error {{'foo' has unknown type}}
- return foo; // expected-error {{cannot initialize}}
+ return foo; // expected-error {{'foo' has unknown type}}
}
}
diff --git a/test/SemaCXX/value-initialization.cpp b/test/SemaCXX/value-initialization.cpp
index 19be03a..4e3acbb 100644
--- a/test/SemaCXX/value-initialization.cpp
+++ b/test/SemaCXX/value-initialization.cpp
@@ -1,11 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-struct A { //expected-note {{marked deleted here}} \
- // expected-warning {{does not declare any constructor to initialize}}
- const int i; // expected-note{{const member 'i' will never be initialized}}
+struct A { // expected-warning {{does not declare any constructor to initialize}}
+ const int i; // expected-note{{const member 'i' will never be initialized}} expected-note {{implicitly deleted}}
virtual void f() { }
};
int main () {
- (void)A(); // expected-error {{call to deleted constructor}}
+ (void)A(); // expected-error {{call to implicitly-deleted default constructor}}
}
diff --git a/test/SemaCXX/vararg-non-pod.cpp b/test/SemaCXX/vararg-non-pod.cpp
index 42c27fb..86b560e 100644
--- a/test/SemaCXX/vararg-non-pod.cpp
+++ b/test/SemaCXX/vararg-non-pod.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wnon-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-error=non-pod-varargs
extern char version[];
@@ -118,3 +118,8 @@ void t8(int n, ...) {
(void)__builtin_va_arg(list, Abstract); // expected-error{{second argument to 'va_arg' is of abstract type 'Abstract'}}
__builtin_va_end(list);
}
+
+int t9(int n) {
+ // Make sure the error works in potentially-evaluated sizeof
+ return (int)sizeof(*(Helper(Foo()), (int (*)[n])0)); // expected-warning{{cannot pass object of non-POD type}}
+}
diff --git a/test/SemaCXX/vector.cpp b/test/SemaCXX/vector.cpp
index 4d3d939..82245ac 100644
--- a/test/SemaCXX/vector.cpp
+++ b/test/SemaCXX/vector.cpp
@@ -218,3 +218,52 @@ void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
// Scalar-to-vector conversions.
accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}}
}
+
+typedef int intx4 __attribute__((__vector_size__(16)));
+typedef int inte4 __attribute__((__ext_vector_type__(4)));
+typedef int flte4 __attribute__((__ext_vector_type__(4)));
+
+void test_mixed_vector_types(fltx4 f, intx4 n, flte4 g, flte4 m) {
+ (void)(f == g);
+ (void)(g != f);
+ (void)(f <= g);
+ (void)(g >= f);
+ (void)(f < g);
+ (void)(g > f);
+
+ (void)(+g);
+ (void)(-g);
+
+ (void)(f + g);
+ (void)(f - g);
+ (void)(f * g);
+ (void)(f / g);
+ (void)(f = g);
+ (void)(f += g);
+ (void)(f -= g);
+ (void)(f *= g);
+ (void)(f /= g);
+
+
+ (void)(n == m);
+ (void)(m != n);
+ (void)(n <= m);
+ (void)(m >= n);
+ (void)(n < m);
+ (void)(m > n);
+
+ (void)(+m);
+ (void)(-m);
+ (void)(~m);
+
+ (void)(n + m);
+ (void)(n - m);
+ (void)(n * m);
+ (void)(n / m);
+ (void)(n % m);
+ (void)(n = m);
+ (void)(n += m);
+ (void)(n -= m);
+ (void)(n *= m);
+ (void)(n /= m);
+}
diff --git a/test/SemaCXX/vla.cpp b/test/SemaCXX/vla.cpp
new file mode 100644
index 0000000..d63b633
--- /dev/null
+++ b/test/SemaCXX/vla.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -verify %s
+
+// PR11925
+int n;
+int (&f())[n]; // expected-error {{function declaration cannot have variably modified type}}
diff --git a/test/SemaCXX/warn-bool-conversion.cpp b/test/SemaCXX/warn-bool-conversion.cpp
index 595c749..b3d136e 100644
--- a/test/SemaCXX/warn-bool-conversion.cpp
+++ b/test/SemaCXX/warn-bool-conversion.cpp
@@ -1,18 +1,18 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int* j = false; // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
+int* j = false; // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
-void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
+void foo(int* i, int *j=(false)) // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
{
- foo(false); // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo(false); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
foo((int*)false); // no-warning: explicit cast
foo(0); // no-warning: not a bool, even though its convertible to bool
- foo(false == true); // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
- foo((42 + 24) < 32); // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo(false == true); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo((42 + 24) < 32); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
const bool kFlag = false;
- foo(kFlag); // expected-warning{{ initialization of pointer of type 'int *' to null from a constant boolean expression}}
+ foo(kFlag); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}}
}
char f(struct Undefined*);
diff --git a/test/SemaCXX/warn-empty-body.cpp b/test/SemaCXX/warn-empty-body.cpp
new file mode 100644
index 0000000..d643ced
--- /dev/null
+++ b/test/SemaCXX/warn-empty-body.cpp
@@ -0,0 +1,271 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+void a(int i);
+int b();
+int c();
+
+void test1(int x, int y) {
+ while(true) {
+ if (x); // expected-warning {{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ int i;
+ // PR11329
+ for (i = 0; i < x; i++); { // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+ b();
+ }
+
+ for (i = 0; i < x; i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ for (i = 0;
+ i < x;
+ i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (int j :
+ arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); { // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+ }
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ while (b() == 0 ||
+ c() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ a(i);
+ }
+
+ do; // expected-note{{to match this 'do'}}
+ b(); // expected-error{{expected 'while' in do/while loop}}
+ while (b()); // no-warning
+ c();
+
+ do; // expected-note{{to match this 'do'}}
+ b(); // expected-error{{expected 'while' in do/while loop}}
+ while (b()); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ c();
+
+ switch(x) // no-warning
+ {
+ switch(y); // expected-warning{{switch statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ {
+ case 0:
+ a(10);
+ break;
+ default:
+ a(20);
+ break;
+ }
+ }
+ }
+}
+
+/// There should be no warning when null statement is placed on its own line.
+void test2(int x, int y) {
+ if (x) // no-warning
+ ; // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) // no-warning
+ ; // no-warning
+
+ for (i = 0;
+ i < x;
+ i++) // no-warning
+ ; // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) // no-warning
+ ; // no-warning
+
+ while (b() == 0) // no-warning
+ ; // no-warning
+
+ while (b() == 0 ||
+ c() == 0) // no-warning
+ ; // no-warning
+
+ switch(x)
+ {
+ switch(y) // no-warning
+ ; // no-warning
+ }
+
+ // Last `for' or `while' statement in compound statement shouldn't warn.
+ while(b() == 0); // no-warning
+}
+
+/// There should be no warning for a null statement resulting from an empty macro.
+#define EMPTY(a)
+void test3(int x, int y) {
+ if (x) EMPTY(x); // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) EMPTY(i); // no-warning
+
+ for (i = 0;
+ i < x;
+ i++) EMPTY(i); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) EMPTY(j); // no-warning
+
+ for (int j :
+ arr) EMPTY(j); // no-warning
+
+ while (b() == 0) EMPTY(i); // no-warning
+
+ while (b() == 0 ||
+ c() == 0) EMPTY(i); // no-warning
+
+ switch (x) {
+ switch (y)
+ EMPTY(i); // no-warning
+ }
+}
+
+void test4(int x)
+{
+ // Idiom used in some metaprogramming constructs.
+ switch (x) default:; // no-warning
+
+ // Frequent idiom used in macros.
+ do {} while (false); // no-warning
+}
+
+/// There should be no warning for a common for/while idiom when it is obvious
+/// from indentation that next statement wasn't meant to be a body.
+void test5(int x, int y) {
+ int i;
+ for (i = 0; i < x; i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (i = 0; i < x; i++); // no-warning
+ a(i);
+
+ for (i = 0;
+ i < x;
+ i++); // expected-warning{{for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ for (i = 0;
+ i < x;
+ i++); // no-warning
+ a(i);
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0); // no-warning
+ a(i);
+
+ while (b() == 0 ||
+ c() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(i);
+
+ while (b() == 0 ||
+ c() == 0); // no-warning
+ a(i);
+}
+
+/// There should be no warning for a statement with a non-null body.
+void test6(int x, int y) {
+ if (x) {} // no-warning
+
+ if (x)
+ a(x); // no-warning
+
+ int i;
+ for (i = 0; i < x; i++) // no-warning
+ a(i); // no-warning
+
+ for (i = 0; i < x; i++) { // no-warning
+ a(i); // no-warning
+ }
+
+ for (i = 0;
+ i < x;
+ i++) // no-warning
+ a(i); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr) // no-warning
+ a(j);
+
+ for (int j : arr) {} // no-warning
+
+ while (b() == 0) // no-warning
+ a(i); // no-warning
+
+ while (b() == 0) {} // no-warning
+
+ switch(x) // no-warning
+ {
+ switch(y) // no-warning
+ {
+ case 0:
+ a(10);
+ break;
+ default:
+ a(20);
+ break;
+ }
+ }
+}
+
+void test_errors(int x) {
+ if (1)
+ aa; // expected-error{{use of undeclared identifier}}
+ // no empty body warning.
+
+ int i;
+ for (i = 0; i < x; i++)
+ bb; // expected-error{{use of undeclared identifier}}
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr)
+ cc; // expected-error{{use of undeclared identifier}}
+
+ while (b() == 0)
+ dd; // expected-error{{use of undeclared identifier}}
+}
+
+// Warnings for statements in templates shouldn't be duplicated for all
+// instantiations.
+template <typename T>
+void test_template(int x) {
+ if (x); // expected-warning{{if statement has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ if (x)
+ EMPTY(x); // no-warning
+
+ int arr[3] = { 1, 2, 3 };
+ for (int j : arr); // expected-warning{{range-based for loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+
+ while (b() == 0); // expected-warning{{while loop has empty body}} expected-note{{put the semicolon on a separate line to silence this warning}}
+ a(x);
+}
+
+void test_template_inst(int x) {
+ test_template<int>(x);
+ test_template<double>(x);
+}
+
diff --git a/test/SemaCXX/warn-everthing.cpp b/test/SemaCXX/warn-everthing.cpp
new file mode 100644
index 0000000..144a8f9
--- /dev/null
+++ b/test/SemaCXX/warn-everthing.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang -Weverything -fsyntax-only %s -verify
+
+// This previously crashed due to a bug in the CFG. Exercising all
+// warnings helps check CFG construction.
+class PR12271 {
+public:
+ PR12271();
+ ~PR12271();
+};
+
+void testPR12271() {
+ PR12271 a[1][1];
+} \ No newline at end of file
diff --git a/test/SemaCXX/warn-func-as-bool.cpp b/test/SemaCXX/warn-func-as-bool.cpp
new file mode 100644
index 0000000..b5df744
--- /dev/null
+++ b/test/SemaCXX/warn-func-as-bool.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -x c++ -verify -fsyntax-only %s
+
+void f1();
+
+struct S {
+ static void f2();
+};
+
+extern void f3() __attribute__((weak_import));
+
+struct S2 {
+ static void f4() __attribute__((weak_import));
+};
+
+bool f5();
+bool f6(int);
+
+void bar() {
+ bool b;
+
+ b = f1; // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ if (f1) {} // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ b = S::f2; // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ if (S::f2) {} // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+ b = f5; // expected-warning {{address of function 'f5' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}} \
+ expected-note {{suffix with parentheses to turn this into a function call}}
+ b = f6; // expected-warning {{address of function 'f6' will always evaluate to 'true'}} \
+ expected-note {{prefix with the address-of operator to silence this warning}}
+
+ // implicit casts of weakly imported symbols are ok:
+ b = f3;
+ if (f3) {}
+ b = S2::f4;
+ if (S2::f4) {}
+}
diff --git a/test/SemaCXX/warn-large-by-value-copy.cpp b/test/SemaCXX/warn-large-by-value-copy.cpp
index 39dbd76..3e419ec 100644
--- a/test/SemaCXX/warn-large-by-value-copy.cpp
+++ b/test/SemaCXX/warn-large-by-value-copy.cpp
@@ -40,3 +40,8 @@ void g() {
}
}
+
+template<typename T> class DependentPOD {
+ enum b { x };
+ b foo() { return x; }
+};
diff --git a/test/SemaCXX/warn-memset-bad-sizeof.cpp b/test/SemaCXX/warn-memset-bad-sizeof.cpp
index a018223..e0d28da 100644
--- a/test/SemaCXX/warn-memset-bad-sizeof.cpp
+++ b/test/SemaCXX/warn-memset-bad-sizeof.cpp
@@ -104,6 +104,14 @@ void f(Mat m, const Foo& const_foo, char *buffer) {
// Copy to raw buffer shouldn't warn either
memcpy(&foo, &arr, sizeof(Foo));
memcpy(&arr, &foo, sizeof(Foo));
+
+ // Shouldn't warn, and shouldn't crash either.
+ memset(({
+ if (0) {}
+ while (0) {}
+ for (;;) {}
+ &s;
+ }), 0, sizeof(s));
}
namespace ns {
@@ -132,8 +140,6 @@ void strcpy_and_friends() {
strncpy(buff, BAR, sizeof(BAR)); // \
// expected-warning {{argument to 'sizeof' in 'strncpy' call is the same expression as the source}}
- strncat(buff, BAR, sizeof(BAR)); // \
- // expected-warning {{argument to 'sizeof' in 'strncat' call is the same expression as the source}}
strndup(FOO, sizeof(FOO)); // \
// expected-warning {{argument to 'sizeof' in 'strndup' call is the same expression as the source}}
}
diff --git a/test/SemaCXX/warn-new-overaligned-2.cpp b/test/SemaCXX/warn-new-overaligned-2.cpp
new file mode 100644
index 0000000..5505009
--- /dev/null
+++ b/test/SemaCXX/warn-new-overaligned-2.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
+
+// This test verifies that we don't warn when the global operator new is
+// overridden. That's why we can't merge this with the other test file.
+
+void* operator new(unsigned long);
+void* operator new[](unsigned long);
+
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test;
+ new Test[10];
+}
diff --git a/test/SemaCXX/warn-new-overaligned-3.cpp b/test/SemaCXX/warn-new-overaligned-3.cpp
new file mode 100644
index 0000000..c9a57fb
--- /dev/null
+++ b/test/SemaCXX/warn-new-overaligned-3.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned %s -isystem %S/Inputs -verify
+
+// This test ensures that we still get the warning even if we #include <new>
+// where the header here simulates <new>.
+#include <warn-new-overaligned-3.h>
+
+namespace test1 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test2 {
+struct helper { int i __attribute__((aligned(256))); };
+
+struct Placement {
+ Placement() {
+ new (d) helper();
+ }
+ helper *d;
+};
+}
diff --git a/test/SemaCXX/warn-new-overaligned.cpp b/test/SemaCXX/warn-new-overaligned.cpp
new file mode 100644
index 0000000..42a4e35
--- /dev/null
+++ b/test/SemaCXX/warn-new-overaligned.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
+
+namespace test1 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test2 {
+class Test {
+ typedef int __attribute__((aligned(256))) aligned_int;
+ aligned_int high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10]; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test3 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ void* operator new(unsigned long) {
+ return 0;
+ }
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test;
+ new Test[10]; // expected-warning {{type 'test3::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+}
+}
+
+namespace test4 {
+struct Test {
+ template <typename T>
+ struct SeparateCacheLines {
+ T data;
+ } __attribute__((aligned(256)));
+
+ void* operator new[](unsigned long) {
+ return 0;
+ }
+
+ SeparateCacheLines<int> high_contention_data[10];
+};
+
+void helper() {
+ Test t;
+ new Test; // expected-warning {{type 'test4::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
+ new Test[10];
+}
+}
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp
index 90a8933..566e5c1 100644
--- a/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -36,6 +36,18 @@ class __attribute__((lockable)) Mutex {
void LockWhen(const int &cond) __attribute__((exclusive_lock_function));
};
+class __attribute__((scoped_lockable)) MutexLock {
+ public:
+ MutexLock(Mutex *mu) __attribute__((exclusive_lock_function(mu)));
+ ~MutexLock() __attribute__((unlock_function));
+};
+
+class __attribute__((scoped_lockable)) ReaderMutexLock {
+ public:
+ ReaderMutexLock(Mutex *mu) __attribute__((exclusive_lock_function(mu)));
+ ~ReaderMutexLock() __attribute__((unlock_function));
+};
+
Mutex sls_mu;
@@ -160,30 +172,29 @@ void sls_fun_bad_2() {
}
void sls_fun_bad_3() {
- sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of function 'sls_fun_bad_3'}}
-}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+} // expected-warning{{mutex 'sls_mu' is still locked at the end of function}}
void sls_fun_bad_4() {
if (getBool())
sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of its scope}}
+ expected-warning{{mutex 'sls_mu2' is not locked on every path through here}} \
+ expected-note{{mutex acquired here}}
+
else
sls_mu2.Lock(); // \
- // expected-warning{{mutex 'sls_mu2' is still locked at the end of its scope}}
-}
+ expected-note{{mutex acquired here}}
+} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
void sls_fun_bad_5() {
- sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of its scope}}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
if (getBool())
sls_mu.Unlock();
-}
+} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
void sls_fun_bad_6() {
if (getBool()) {
- sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of its scope}}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
} else {
if (getBool()) {
getBool(); // EMPTY
@@ -192,29 +203,30 @@ void sls_fun_bad_6() {
}
}
sls_mu.Unlock(); // \
- // expected-warning{{unlocking 'sls_mu' that was not locked}}
+ expected-warning{{mutex 'sls_mu' is not locked on every path through here}}\
+ expected-warning{{unlocking 'sls_mu' that was not locked}}
}
void sls_fun_bad_7() {
- sls_mu.Lock(); // \
- // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ sls_mu.Lock();
while (getBool()) {
sls_mu.Unlock();
if (getBool()) {
if (getBool()) {
- continue;
+ continue; // \
+ expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
}
}
- sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of its scope}}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
}
sls_mu.Unlock();
}
void sls_fun_bad_8() {
- sls_mu.Lock(); // \
- // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
- do {
+ sls_mu.Lock(); // expected-note{{mutex acquired here}}
+
+ // FIXME: TERRIBLE SOURCE LOCATION!
+ do { // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
sls_mu.Unlock();
} while (getBool());
}
@@ -222,29 +234,42 @@ void sls_fun_bad_8() {
void sls_fun_bad_9() {
do {
sls_mu.Lock(); // \
- // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} \
+ // expected-note{{mutex acquired here}}
} while (getBool());
sls_mu.Unlock();
}
void sls_fun_bad_10() {
- sls_mu.Lock(); // \
- // expected-warning{{mutex 'sls_mu' is still locked at the end of function 'sls_fun_bad_10'}} \
- // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ sls_mu.Lock(); // expected-note 2{{mutex acquired here}}
while(getBool()) {
- sls_mu.Unlock();
+ sls_mu.Unlock(); // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
}
-}
+} // expected-warning{{mutex 'sls_mu' is still locked at the end of function}}
void sls_fun_bad_11() {
- while (getBool()) {
- sls_mu.Lock(); // \
- // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ while (getBool()) { // \
+ expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}}
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
}
sls_mu.Unlock(); // \
// expected-warning{{unlocking 'sls_mu' that was not locked}}
}
+void sls_fun_bad_12() {
+ sls_mu.Lock(); // expected-note {{mutex acquired here}}
+ while (getBool()) {
+ sls_mu.Unlock();
+ if (getBool()) {
+ if (getBool()) {
+ break; // expected-warning{{mutex 'sls_mu' is not locked on every path through here}}
+ }
+ }
+ sls_mu.Lock();
+ }
+ sls_mu.Unlock();
+}
+
//-----------------------------------------//
// Handling lock expressions in attribute args
// -------------------------------------------//
@@ -277,9 +302,8 @@ void aa_fun_bad_2() {
}
void aa_fun_bad_3() {
- glock.globalLock(); // \
- // expected-warning{{mutex 'aa_mu' is still locked at the end of function 'aa_fun_bad_3'}}
-}
+ glock.globalLock(); // expected-note{{mutex acquired here}}
+} // expected-warning{{mutex 'aa_mu' is still locked at the end of function}}
//--------------------------------------------------//
// Regression tests for unusual method names
@@ -289,23 +313,20 @@ Mutex wmu;
// Test diagnostics for other method names.
class WeirdMethods {
+ // FIXME: can't currently check inside constructors and destructors.
WeirdMethods() {
- wmu.Lock(); // \
- // expected-warning {{mutex 'wmu' is still locked at the end of function 'WeirdMethods'}}
- }
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
~WeirdMethods() {
- wmu.Lock(); // \
- // expected-warning {{mutex 'wmu' is still locked at the end of function '~WeirdMethods'}}
- }
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
void operator++() {
- wmu.Lock(); // \
- // expected-warning {{mutex 'wmu' is still locked at the end of function 'operator++'}}
- }
+ wmu.Lock(); // expected-note {{mutex acquired here}}
+ } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
operator int*() {
- wmu.Lock(); // \
- // expected-warning {{mutex 'wmu' is still locked at the end of function 'operator int *'}}
+ wmu.Lock(); // expected-note {{mutex acquired here}}
return 0;
- }
+ } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
};
//-----------------------------------------------//
@@ -740,32 +761,12 @@ void es_bad_7() {
sls_mu.Unlock();
}
+
//-----------------------------------------------//
// Unparseable lock expressions
// ----------------------------------------------//
-Mutex UPmu;
-// FIXME: add support for lock expressions involving arrays.
-Mutex mua[5];
-
-int x __attribute__((guarded_by(UPmu = sls_mu))); // \
- // expected-warning{{cannot resolve lock expression to a specific lockable object}}
-int y __attribute__((guarded_by(mua[0]))); // \
- // expected-warning{{cannot resolve lock expression to a specific lockable object}}
-
-
-void testUnparse() {
- // no errors, since the lock expressions are not resolved
- x = 5;
- y = 5;
-}
-
-void testUnparse2() {
- mua[0].Lock(); // \
- // expected-warning{{cannot resolve lock expression to a specific lockable object}}
- (&(mua[0]) + 4)->Lock(); // \
- // expected-warning{{cannot resolve lock expression to a specific lockable object}}
-}
+// FIXME -- derive new tests for unhandled expressions
//----------------------------------------------------------------------------//
@@ -1152,7 +1153,7 @@ class Foo {
int Foo::foo()
{
int res;
- w = 5.2;
+ w = 5;
res = a_ + 5;
return res;
}
@@ -1166,7 +1167,7 @@ void Foo::bar()
mu_.Unlock();
if (x > 5) {
mu1.Lock();
- g = 2.3;
+ g = 2;
mu1.Unlock();
}
}
@@ -1184,7 +1185,7 @@ void main()
f2->bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}}
f2->mu_.Unlock();
mu2.Lock();
- w = 2.5;
+ w = 2;
mu2.Unlock();
}
} // end namespace thread_annot_lock_13
@@ -1420,3 +1421,823 @@ void main()
} // end namespace thread_annot_lock_67_modified
+namespace substitution_test {
+ class MyData {
+ public:
+ Mutex mu;
+
+ void lockData() __attribute__((exclusive_lock_function(mu))) { }
+ void unlockData() __attribute__((unlock_function(mu))) { }
+
+ void doSomething() __attribute__((exclusive_locks_required(mu))) { }
+ };
+
+
+ class DataLocker {
+ public:
+ void lockData (MyData *d) __attribute__((exclusive_lock_function(d->mu))) { }
+ void unlockData(MyData *d) __attribute__((unlock_function(d->mu))) { }
+ };
+
+
+ class Foo {
+ public:
+ void foo(MyData* d) __attribute__((exclusive_locks_required(d->mu))) { }
+
+ void bar1(MyData* d) {
+ d->lockData();
+ foo(d);
+ d->unlockData();
+ }
+
+ void bar2(MyData* d) {
+ DataLocker dlr;
+ dlr.lockData(d);
+ foo(d);
+ dlr.unlockData(d);
+ }
+
+ void bar3(MyData* d1, MyData* d2) {
+ DataLocker dlr;
+ dlr.lockData(d1); // expected-note {{mutex acquired here}}
+ dlr.unlockData(d2); // \
+ // expected-warning {{unlocking 'mu' that was not locked}}
+ } // expected-warning {{mutex 'mu' is still locked at the end of function}}
+
+ void bar4(MyData* d1, MyData* d2) {
+ DataLocker dlr;
+ dlr.lockData(d1);
+ foo(d2); // \
+ // expected-warning {{calling function 'foo' requires exclusive lock on 'mu'}}
+ dlr.unlockData(d1);
+ }
+ };
+} // end namespace substituation_test
+
+
+
+namespace constructor_destructor_tests {
+ Mutex fooMu;
+ int myVar GUARDED_BY(fooMu);
+
+ class Foo {
+ public:
+ Foo() __attribute__((exclusive_lock_function(fooMu))) { }
+ ~Foo() __attribute__((unlock_function(fooMu))) { }
+ };
+
+ void fooTest() {
+ Foo foo;
+ myVar = 0;
+ }
+}
+
+
+namespace invalid_lock_expression_test {
+
+class LOCKABLE MyLockable {
+public:
+ MyLockable() __attribute__((exclusive_lock_function)) { }
+ ~MyLockable() { }
+};
+
+// create an empty lock expression
+void foo() {
+ MyLockable lock; // \
+ // expected-warning {{cannot resolve lock expression}}
+}
+
+} // end namespace invalid_lock_expression_test
+
+namespace template_member_test {
+
+ struct S { int n; };
+ struct T {
+ Mutex m;
+ S *s GUARDED_BY(this->m);
+ };
+ Mutex m;
+ struct U {
+ union {
+ int n;
+ };
+ } *u GUARDED_BY(m);
+
+ template<typename U>
+ struct IndirectLock {
+ int DoNaughtyThings(T *t) {
+ u->n = 0; // expected-warning {{reading variable 'u' requires locking 'm'}}
+ return t->s->n; // expected-warning {{reading variable 's' requires locking 'm'}}
+ }
+ };
+
+ template struct IndirectLock<int>; // expected-note {{here}}
+
+ struct V {
+ void f(int);
+ void f(double);
+
+ Mutex m;
+ V *p GUARDED_BY(this->m);
+ };
+ template<typename U> struct W {
+ V v;
+ void f(U u) {
+ v.p->f(u); // expected-warning {{reading variable 'p' requires locking 'm'}}
+ }
+ };
+ template struct W<int>; // expected-note {{here}}
+
+}
+
+namespace test_scoped_lockable {
+
+struct TestScopedLockable {
+ Mutex mu1;
+ Mutex mu2;
+ int a __attribute__((guarded_by(mu1)));
+ int b __attribute__((guarded_by(mu2)));
+
+ bool getBool();
+
+ void foo1() {
+ MutexLock mulock(&mu1);
+ a = 5;
+ }
+
+ void foo2() {
+ ReaderMutexLock mulock1(&mu1);
+ if (getBool()) {
+ MutexLock mulock2a(&mu2);
+ b = a + 1;
+ }
+ else {
+ MutexLock mulock2b(&mu2);
+ b = a + 2;
+ }
+ }
+
+ void foo3() {
+ MutexLock mulock_a(&mu1);
+ MutexLock mulock_b(&mu1); // \
+ // expected-warning {{locking 'mu1' that is already locked}}
+ } // expected-warning {{unlocking 'mu1' that was not locked}}
+
+ void foo4() {
+ MutexLock mulock1(&mu1), mulock2(&mu2);
+ a = b+1;
+ b = a+1;
+ }
+};
+
+} // end namespace test_scoped_lockable
+
+
+namespace FunctionAttrTest {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+Foo fooObj;
+
+void foo() EXCLUSIVE_LOCKS_REQUIRED(fooObj.mu_);
+
+void bar() {
+ foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+ fooObj.mu_.Lock();
+ foo();
+ fooObj.mu_.Unlock();
+}
+
+}; // end namespace FunctionAttrTest
+
+
+struct TestTryLock {
+ Mutex mu;
+ int a GUARDED_BY(mu);
+ bool cond;
+
+ void foo1() {
+ if (mu.TryLock()) {
+ a = 1;
+ mu.Unlock();
+ }
+ }
+
+ void foo2() {
+ if (!mu.TryLock()) return;
+ a = 2;
+ mu.Unlock();
+ }
+
+ void foo3() {
+ bool b = mu.TryLock();
+ if (b) {
+ a = 3;
+ mu.Unlock();
+ }
+ }
+
+ void foo4() {
+ bool b = mu.TryLock();
+ if (!b) return;
+ a = 4;
+ mu.Unlock();
+ }
+
+ void foo5() {
+ while (mu.TryLock()) {
+ a = a + 1;
+ mu.Unlock();
+ }
+ }
+
+ void foo6() {
+ bool b = mu.TryLock();
+ b = !b;
+ if (b) return;
+ a = 6;
+ mu.Unlock();
+ }
+
+ void foo7() {
+ bool b1 = mu.TryLock();
+ bool b2 = !b1;
+ bool b3 = !b2;
+ if (b3) {
+ a = 7;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def chains: join points
+ void foo8() {
+ bool b = mu.TryLock();
+ bool b2 = b;
+ if (cond)
+ b = true;
+ if (b) { // b should be unknown at this point, becuase of the join point
+ a = 8; // expected-warning {{writing variable 'a' requires locking 'mu' exclusively}}
+ }
+ if (b2) { // b2 should be known at this point.
+ a = 8;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def-chains: back edges
+ void foo9() {
+ bool b = mu.TryLock();
+
+ for (int i = 0; i < 10; ++i);
+
+ if (b) { // b is still known, because the loop doesn't alter it
+ a = 9;
+ mu.Unlock();
+ }
+ }
+
+ // Test use-def chains: back edges
+ void foo10() {
+ bool b = mu.TryLock();
+
+ while (cond) {
+ if (b) { // b should be uknown at this point b/c of the loop
+ a = 10; // expected-warning {{writing variable 'a' requires locking 'mu' exclusively}}
+ }
+ b = !b;
+ }
+ }
+}; // end TestTrylock
+
+
+namespace TestTemplateAttributeInstantiation {
+
+class Foo1 {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+class Foo2 {
+public:
+ int a GUARDED_BY(mu_);
+ Mutex mu_;
+};
+
+
+class Bar {
+public:
+ // Test non-dependent expressions in attributes on template functions
+ template <class T>
+ void barND(Foo1 *foo, T *fooT) EXCLUSIVE_LOCKS_REQUIRED(foo->mu_) {
+ foo->a = 0;
+ }
+
+ // Test dependent expressions in attributes on template functions
+ template <class T>
+ void barD(Foo1 *foo, T *fooT) EXCLUSIVE_LOCKS_REQUIRED(fooT->mu_) {
+ fooT->a = 0;
+ }
+};
+
+
+template <class T>
+class BarT {
+public:
+ Foo1 fooBase;
+ T fooBaseT;
+
+ // Test non-dependent expression in ordinary method on template class
+ void barND() EXCLUSIVE_LOCKS_REQUIRED(fooBase.mu_) {
+ fooBase.a = 0;
+ }
+
+ // Test dependent expressions in ordinary methods on template class
+ void barD() EXCLUSIVE_LOCKS_REQUIRED(fooBaseT.mu_) {
+ fooBaseT.a = 0;
+ }
+
+ // Test dependent expressions in template method in template class
+ template <class T2>
+ void barTD(T2 *fooT) EXCLUSIVE_LOCKS_REQUIRED(fooBaseT.mu_, fooT->mu_) {
+ fooBaseT.a = 0;
+ fooT->a = 0;
+ }
+};
+
+template <class T>
+class Cell {
+public:
+ Mutex mu_;
+ // Test dependent guarded_by
+ T data GUARDED_BY(mu_);
+
+ void fooEx() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ data = 0;
+ }
+
+ void foo() {
+ mu_.Lock();
+ data = 0;
+ mu_.Unlock();
+ }
+};
+
+void test() {
+ Bar b;
+ BarT<Foo2> bt;
+ Foo1 f1;
+ Foo2 f2;
+
+ f1.mu_.Lock();
+ f2.mu_.Lock();
+ bt.fooBase.mu_.Lock();
+ bt.fooBaseT.mu_.Lock();
+
+ b.barND(&f1, &f2);
+ b.barD(&f1, &f2);
+ bt.barND();
+ bt.barD();
+ bt.barTD(&f2);
+
+ f1.mu_.Unlock();
+ bt.barTD(&f1); // \
+ // expected-warning {{calling function 'barTD' requires exclusive lock on 'mu_'}}
+
+ bt.fooBase.mu_.Unlock();
+ bt.fooBaseT.mu_.Unlock();
+ f2.mu_.Unlock();
+
+ Cell<int> cell;
+ cell.data = 0; // \
+ // expected-warning {{writing variable 'data' requires locking 'mu_' exclusively}}
+ cell.foo();
+ cell.mu_.Lock();
+ cell.fooEx();
+ cell.mu_.Unlock();
+}
+
+
+template <class T>
+class CellDelayed {
+public:
+ // Test dependent guarded_by
+ T data GUARDED_BY(mu_);
+ static T static_data GUARDED_BY(static_mu_);
+
+ void fooEx(CellDelayed<T> *other) EXCLUSIVE_LOCKS_REQUIRED(mu_, other->mu_) {
+ this->data = other->data;
+ }
+
+ template <class T2>
+ void fooExT(CellDelayed<T2> *otherT) EXCLUSIVE_LOCKS_REQUIRED(mu_, otherT->mu_) {
+ this->data = otherT->data;
+ }
+
+ void foo() {
+ mu_.Lock();
+ data = 0;
+ mu_.Unlock();
+ }
+
+ Mutex mu_;
+ static Mutex static_mu_;
+};
+
+void testDelayed() {
+ CellDelayed<int> celld;
+ CellDelayed<int> celld2;
+ celld.foo();
+ celld.mu_.Lock();
+ celld2.mu_.Lock();
+
+ celld.fooEx(&celld2);
+ celld.fooExT(&celld2);
+
+ celld2.mu_.Unlock();
+ celld.mu_.Unlock();
+}
+
+}; // end namespace TestTemplateAttributeInstantiation
+
+
+namespace FunctionDeclDefTest {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+
+ virtual void foo1(Foo *f_declared) EXCLUSIVE_LOCKS_REQUIRED(f_declared->mu_);
+};
+
+// EXCLUSIVE_LOCKS_REQUIRED should be applied, and rewritten to f_defined->mu_
+void Foo::foo1(Foo *f_defined) {
+ f_defined->a = 0;
+};
+
+void test() {
+ Foo myfoo;
+ myfoo.foo1(&myfoo); // \
+ // expected-warning {{calling function 'foo1' requires exclusive lock on 'mu_'}}
+ myfoo.mu_.Lock();
+ myfoo.foo1(&myfoo);
+ myfoo.mu_.Unlock();
+}
+
+};
+
+namespace GoingNative {
+
+ struct __attribute__((lockable)) mutex {
+ void lock() __attribute__((exclusive_lock_function));
+ void unlock() __attribute__((unlock_function));
+ // ...
+ };
+ bool foo();
+ bool bar();
+ mutex m;
+ void test() {
+ m.lock();
+ while (foo()) {
+ m.unlock();
+ // ...
+ if (bar()) {
+ // ...
+ if (foo())
+ continue; // expected-warning {{expecting mutex 'm' to be locked at start of each loop}}
+ //...
+ }
+ // ...
+ m.lock(); // expected-note {{mutex acquired here}}
+ }
+ m.unlock();
+ }
+
+}
+
+
+
+namespace FunctionDefinitionTest {
+
+class Foo {
+public:
+ void foo1();
+ void foo2();
+ void foo3(Foo *other);
+
+ template<class T>
+ void fooT1(const T& dummy1);
+
+ template<class T>
+ void fooT2(const T& dummy2) EXCLUSIVE_LOCKS_REQUIRED(mu_);
+
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+template<class T>
+class FooT {
+public:
+ void foo();
+
+ Mutex mu_;
+ T a GUARDED_BY(mu_);
+};
+
+
+void Foo::foo1() NO_THREAD_SAFETY_ANALYSIS {
+ a = 1;
+}
+
+void Foo::foo2() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 2;
+}
+
+void Foo::foo3(Foo *other) EXCLUSIVE_LOCKS_REQUIRED(other->mu_) {
+ other->a = 3;
+}
+
+template<class T>
+void Foo::fooT1(const T& dummy1) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = dummy1;
+}
+
+/* TODO -- uncomment with template instantiation of attributes.
+template<class T>
+void Foo::fooT2(const T& dummy2) {
+ a = dummy2;
+}
+*/
+
+void fooF1(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 1;
+}
+
+void fooF2(Foo *f);
+void fooF2(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 2;
+}
+
+void fooF3(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_);
+void fooF3(Foo *f) {
+ f->a = 3;
+}
+
+template<class T>
+void FooT<T>::foo() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 0;
+}
+
+void test() {
+ int dummy = 0;
+ Foo myFoo;
+
+ myFoo.foo2(); // \
+ // expected-warning {{calling function 'foo2' requires exclusive lock on 'mu_'}}
+ myFoo.foo3(&myFoo); // \
+ // expected-warning {{calling function 'foo3' requires exclusive lock on 'mu_'}}
+ myFoo.fooT1(dummy); // \
+ // expected-warning {{calling function 'fooT1' requires exclusive lock on 'mu_'}}
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy); // expected warning
+
+ fooF1(&myFoo); // \
+ // expected-warning {{calling function 'fooF1' requires exclusive lock on 'mu_'}}
+ fooF2(&myFoo); // \
+ // expected-warning {{calling function 'fooF2' requires exclusive lock on 'mu_'}}
+ fooF3(&myFoo); // \
+ // expected-warning {{calling function 'fooF3' requires exclusive lock on 'mu_'}}
+
+ myFoo.mu_.Lock();
+ myFoo.foo2();
+ myFoo.foo3(&myFoo);
+ myFoo.fooT1(dummy);
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy);
+
+ fooF1(&myFoo);
+ fooF2(&myFoo);
+ fooF3(&myFoo);
+ myFoo.mu_.Unlock();
+
+ FooT<int> myFooT;
+ myFooT.foo(); // \
+ // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+}
+
+} // end namespace FunctionDefinitionTest
+
+
+namespace SelfLockingTest {
+
+class LOCKABLE MyLock {
+public:
+ int foo GUARDED_BY(this);
+
+ void lock() EXCLUSIVE_LOCK_FUNCTION();
+ void unlock() UNLOCK_FUNCTION();
+
+ void doSomething() {
+ this->lock(); // allow 'this' as a lock expression
+ foo = 0;
+ doSomethingElse();
+ this->unlock();
+ }
+
+ void doSomethingElse() EXCLUSIVE_LOCKS_REQUIRED(this) {
+ foo = 1;
+ };
+
+ void test() {
+ foo = 2; // \
+ // expected-warning {{writing variable 'foo' requires locking 'this' exclusively}}
+ }
+};
+
+
+class LOCKABLE MyLock2 {
+public:
+ Mutex mu_;
+ int foo GUARDED_BY(this);
+
+ // don't check inside lock and unlock functions
+ void lock() EXCLUSIVE_LOCK_FUNCTION() { mu_.Lock(); }
+ void unlock() UNLOCK_FUNCTION() { mu_.Unlock(); }
+
+ // don't check inside constructors and destructors
+ MyLock2() { foo = 1; }
+ ~MyLock2() { foo = 0; }
+};
+
+
+} // end namespace SelfLockingTest
+
+
+namespace InvalidNonstatic {
+
+// Forward decl here causes bogus "invalid use of non-static data member"
+// on reference to mutex_ in guarded_by attribute.
+class Foo;
+
+class Foo {
+ Mutex* mutex_;
+
+ int foo __attribute__((guarded_by(mutex_)));
+};
+
+} // end namespace InvalidNonStatic
+
+
+namespace NoReturnTest {
+
+bool condition();
+void fatal() __attribute__((noreturn));
+
+Mutex mu_;
+
+void test1() {
+ MutexLock lock(&mu_);
+ if (condition()) {
+ fatal();
+ return;
+ }
+}
+
+} // end namespace NoReturnTest
+
+
+namespace TestMultiDecl {
+
+class Foo {
+public:
+ int GUARDED_BY(mu_) a;
+ int GUARDED_BY(mu_) b, c;
+
+ void foo() {
+ a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ b = 0; // \
+ // expected-warning {{writing variable 'b' requires locking 'mu_' exclusively}}
+ c = 0; // \
+ // expected-warning {{writing variable 'c' requires locking 'mu_' exclusively}}
+ }
+
+private:
+ Mutex mu_;
+};
+
+} // end namespace TestMultiDecl
+
+
+namespace WarnNoDecl {
+
+class Foo {
+ void foo(int a); __attribute__(( // \
+ // expected-warning {{declaration does not declare anything}}
+ exclusive_locks_required(a))); // \
+ // expected-warning {{attribute exclusive_locks_required ignored}}
+};
+
+} // end namespace WarnNoDecl
+
+
+
+namespace MoreLockExpressions {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+class Bar {
+public:
+ int b;
+ Foo* f;
+
+ Foo& getFoo() { return *f; }
+ Foo& getFoo2(int c) { return *f; }
+ Foo& getFoo3(int c, int d) { return *f; }
+
+ Foo& getFooey() { return *f; }
+};
+
+Foo& getBarFoo(Bar &bar, int c) { return bar.getFoo2(c); }
+
+void test() {
+ Foo foo;
+ Foo *fooArray;
+ Bar bar;
+ int a;
+ int b;
+ int c;
+
+ bar.getFoo().mu_.Lock();
+ bar.getFoo().a = 0;
+ bar.getFoo().mu_.Unlock();
+
+ (bar.getFoo().mu_).Lock(); // test parenthesis
+ bar.getFoo().a = 0;
+ (bar.getFoo().mu_).Unlock();
+
+ bar.getFoo2(a).mu_.Lock();
+ bar.getFoo2(a).a = 0;
+ bar.getFoo2(a).mu_.Unlock();
+
+ bar.getFoo3(a, b).mu_.Lock();
+ bar.getFoo3(a, b).a = 0;
+ bar.getFoo3(a, b).mu_.Unlock();
+
+ getBarFoo(bar, a).mu_.Lock();
+ getBarFoo(bar, a).a = 0;
+ getBarFoo(bar, a).mu_.Unlock();
+
+ bar.getFoo2(10).mu_.Lock();
+ bar.getFoo2(10).a = 0;
+ bar.getFoo2(10).mu_.Unlock();
+
+ bar.getFoo2(a + 1).mu_.Lock();
+ bar.getFoo2(a + 1).a = 0;
+ bar.getFoo2(a + 1).mu_.Unlock();
+
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
+ (a > 0 ? fooArray[1] : fooArray[b]).a = 0;
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
+
+ bar.getFoo().mu_.Lock();
+ bar.getFooey().a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo().mu_.Unlock();
+
+ bar.getFoo2(a).mu_.Lock();
+ bar.getFoo2(b).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo2(a).mu_.Unlock();
+
+ bar.getFoo3(a, b).mu_.Lock();
+ bar.getFoo3(a, c).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ bar.getFoo3(a, b).mu_.Unlock();
+
+ getBarFoo(bar, a).mu_.Lock();
+ getBarFoo(bar, b).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ getBarFoo(bar, a).mu_.Unlock();
+
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock();
+ (a > 0 ? fooArray[b] : fooArray[c]).a = 0; // \
+ // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}}
+ (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock();
+}
+
+
+} // end namespace
+
+
diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp
index 67882d0..587cb8a 100644
--- a/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ b/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,9 +1,26 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+#define LOCKABLE __attribute__ ((lockable))
+#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
+#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
+#define GUARDED_VAR __attribute__ ((guarded_var))
+#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
+#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
+#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
+#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
+#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
+#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
+#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
+#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
+#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
+#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
+#define EXCLUSIVE_LOCKS_REQUIRED(...) \
+ __attribute__ ((exclusive_locks_required(__VA_ARGS__)))
+#define SHARED_LOCKS_REQUIRED(...) \
+ __attribute__ ((shared_locks_required(__VA_ARGS__)))
+#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
-//-----------------------------------------//
-// Helper fields
-//-----------------------------------------//
class __attribute__((lockable)) Mu {
public:
@@ -324,13 +341,13 @@ int gb_var_arg_8 __attribute__((guarded_by(muPointer)));
// illegal attribute arguments
int gb_var_arg_bad_1 __attribute__((guarded_by(1))); // \
- // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'int'}}
int gb_var_arg_bad_2 __attribute__((guarded_by("mu"))); // \
- // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'const char [3]'}}
int gb_var_arg_bad_3 __attribute__((guarded_by(muDoublePointer))); // \
- // expected-error {{'guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mu **'}}
int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \
- // expected-error {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class UnlockableMu'}}
//3.
// Thread Safety analysis tests
@@ -395,13 +412,13 @@ int * pgb_var_arg_8 __attribute__((pt_guarded_by(muPointer)));
// illegal attribute arguments
int * pgb_var_arg_bad_1 __attribute__((pt_guarded_by(1))); // \
- // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
int * pgb_var_arg_bad_2 __attribute__((pt_guarded_by("mu"))); // \
- // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
int * pgb_var_arg_bad_3 __attribute__((pt_guarded_by(muDoublePointer))); // \
- // expected-error {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}}
int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \
- // expected-error {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}}
//-----------------------------------------//
@@ -456,15 +473,15 @@ Mu aa_var_arg_8 __attribute__((acquired_after(muPointer)));
// illegal attribute arguments
Mu aa_var_arg_bad_1 __attribute__((acquired_after(1))); // \
- // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
Mu aa_var_arg_bad_2 __attribute__((acquired_after("mu"))); // \
- // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
Mu aa_var_arg_bad_3 __attribute__((acquired_after(muDoublePointer))); // \
- // expected-error {{'acquired_after' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}}
Mu aa_var_arg_bad_4 __attribute__((acquired_after(umu))); // \
- // expected-error {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}}
UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \
- // expected-error {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}}
+ // expected-warning {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}}
//-----------------------------------------//
// Acquired Before (ab)
@@ -519,15 +536,15 @@ Mu ab_var_arg_8 __attribute__((acquired_before(muPointer)));
// illegal attribute arguments
Mu ab_var_arg_bad_1 __attribute__((acquired_before(1))); // \
- // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
Mu ab_var_arg_bad_2 __attribute__((acquired_before("mu"))); // \
- // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
Mu ab_var_arg_bad_3 __attribute__((acquired_before(muDoublePointer))); // \
- // expected-error {{'acquired_before' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}}
Mu ab_var_arg_bad_4 __attribute__((acquired_before(umu))); // \
- // expected-error {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}}
UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \
- // expected-error {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}}
+ // expected-warning {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}}
//-----------------------------------------//
@@ -586,11 +603,11 @@ int elf_function_9(Mu x, Mu y) __attribute__((exclusive_lock_function(1,2)));
// illegal attribute arguments
int elf_function_bad_2() __attribute__((exclusive_lock_function("mu"))); // \
- // expected-error {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
int elf_function_bad_3() __attribute__((exclusive_lock_function(muDoublePointer))); // \
- // expected-error {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}}
int elf_function_bad_4() __attribute__((exclusive_lock_function(umu))); // \
- // expected-error {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
int elf_function_bad_1() __attribute__((exclusive_lock_function(1))); // \
// expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -658,11 +675,11 @@ int slf_function_9(Mu x, Mu y) __attribute__((shared_lock_function(1,2)));
// illegal attribute arguments
int slf_function_bad_2() __attribute__((shared_lock_function("mu"))); // \
- // expected-error {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
int slf_function_bad_3() __attribute__((shared_lock_function(muDoublePointer))); // \
- // expected-error {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}}
int slf_function_bad_4() __attribute__((shared_lock_function(umu))); // \
- // expected-error {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
int slf_function_bad_1() __attribute__((shared_lock_function(1))); // \
// expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -686,7 +703,7 @@ int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \
// plus an optional list of locks (vars/fields)
void etf_function() __attribute__((exclusive_trylock_function)); // \
- // expected-error {{attribute takes attribute takes at least 1 argument arguments}}
+ // expected-error {{attribute takes at least 1 argument}}
void etf_function_args() __attribute__((exclusive_trylock_function(1, mu2)));
@@ -740,11 +757,11 @@ int etf_function_bad_3() __attribute__((exclusive_trylock_function(muDoublePoint
// expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}}
int etf_function_bad_4() __attribute__((exclusive_trylock_function(1, "mu"))); // \
- // expected-error {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
int etf_function_bad_5() __attribute__((exclusive_trylock_function(1, muDoublePointer))); // \
- // expected-error {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}}
int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // \
- // expected-error {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
//-----------------------------------------//
@@ -814,11 +831,11 @@ int stf_function_bad_3() __attribute__((shared_trylock_function(muDoublePointer)
// expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}}
int stf_function_bad_4() __attribute__((shared_trylock_function(1, "mu"))); // \
- // expected-error {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
int stf_function_bad_5() __attribute__((shared_trylock_function(1, muDoublePointer))); // \
- // expected-error {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}}
int stf_function_bad_6() __attribute__((shared_trylock_function(1, umu))); // \
- // expected-error {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
//-----------------------------------------//
@@ -877,11 +894,11 @@ int uf_function_9(Mu x, Mu y) __attribute__((unlock_function(1,2)));
// illegal attribute arguments
int uf_function_bad_2() __attribute__((unlock_function("mu"))); // \
- // expected-error {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
int uf_function_bad_3() __attribute__((unlock_function(muDoublePointer))); // \
- // expected-error {{'unlock_function' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}}
int uf_function_bad_4() __attribute__((unlock_function(umu))); // \
- // expected-error {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}}
int uf_function_bad_1() __attribute__((unlock_function(1))); // \
// expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
@@ -951,13 +968,13 @@ int lr_function_8() __attribute__((lock_returned(muPointer)));
// illegal attribute arguments
int lr_function_bad_1() __attribute__((lock_returned(1))); // \
- // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_2() __attribute__((lock_returned("mu"))); // \
- // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_3() __attribute__((lock_returned(muDoublePointer))); // \
- // expected-error {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_4() __attribute__((lock_returned(umu))); // \
- // expected-error {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}}
@@ -1018,13 +1035,13 @@ int le_function_8() __attribute__((locks_excluded(muPointer)));
// illegal attribute arguments
int le_function_bad_1() __attribute__((locks_excluded(1))); // \
- // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
int le_function_bad_2() __attribute__((locks_excluded("mu"))); // \
- // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
int le_function_bad_3() __attribute__((locks_excluded(muDoublePointer))); // \
- // expected-error {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}}
int le_function_bad_4() __attribute__((locks_excluded(umu))); // \
- // expected-error {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}}
@@ -1085,13 +1102,13 @@ int elr_function_8() __attribute__((exclusive_locks_required(muPointer)));
// illegal attribute arguments
int elr_function_bad_1() __attribute__((exclusive_locks_required(1))); // \
- // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
int elr_function_bad_2() __attribute__((exclusive_locks_required("mu"))); // \
- // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
int elr_function_bad_3() __attribute__((exclusive_locks_required(muDoublePointer))); // \
- // expected-error {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}}
int elr_function_bad_4() __attribute__((exclusive_locks_required(umu))); // \
- // expected-error {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
@@ -1153,13 +1170,13 @@ int slr_function_8() __attribute__((shared_locks_required(muPointer)));
// illegal attribute arguments
int slr_function_bad_1() __attribute__((shared_locks_required(1))); // \
- // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
int slr_function_bad_2() __attribute__((shared_locks_required("mu"))); // \
- // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
int slr_function_bad_3() __attribute__((shared_locks_required(muDoublePointer))); // \
- // expected-error {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}}
int slr_function_bad_4() __attribute__((shared_locks_required(umu))); // \
- // expected-error {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
+ // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}}
//-----------------------------------------//
@@ -1253,3 +1270,76 @@ public:
Mu mu;
};
+//-------------------------
+// Empty argument lists
+//-------------------------
+
+class __attribute__((lockable)) EmptyArgListsTest {
+ void lock() __attribute__((exclusive_lock_function())) { }
+ void unlock() __attribute__((unlock_function())) { }
+};
+
+
+namespace FunctionDefinitionParseTest {
+// Test parsing of attributes on function definitions.
+
+class Foo {
+public:
+ Mu mu_;
+ void foo1();
+ void foo2(Foo *f);
+};
+
+template <class T>
+class Bar {
+public:
+ Mu mu_;
+ void bar();
+};
+
+void Foo::foo1() __attribute__((exclusive_locks_required(mu_))) { }
+void Foo::foo2(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+
+template <class T>
+void Bar<T>::bar() __attribute__((exclusive_locks_required(mu_))) { }
+
+void baz(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+
+} // end namespace
+
+
+namespace TestMultiDecl {
+
+class Foo {
+public:
+ int __attribute__((guarded_by(mu_))) a;
+ int __attribute__((guarded_by(mu_))) b, c;
+
+private:
+ Mu mu_;
+};
+
+
+namespace NestedClassLateDecl {
+
+class Foo {
+ class Bar {
+ int a GUARDED_BY(mu);
+ int b GUARDED_BY(fooMuStatic);
+
+ void bar() EXCLUSIVE_LOCKS_REQUIRED(mu) { a = 0; }
+ void bar2(Bar* b) EXCLUSIVE_LOCKS_REQUIRED(b->mu) { b->a = 0; }
+ void bar3(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(f->fooMu) { f->a = 0; }
+
+ Mu mu;
+ };
+
+ int a GUARDED_BY(fooMu);
+ Mu fooMu;
+ static Mu fooMuStatic;
+};
+
+}
+
+} // end namespace TestMultiDecl
+
diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp
index 604a3c0..f36300a 100644
--- a/test/SemaCXX/warn-unreachable.cpp
+++ b/test/SemaCXX/warn-unreachable.cpp
@@ -76,3 +76,34 @@ void test6() {
S
(halt()); // expected-warning {{will never be executed}}
}
+
+// Don't warn about unreachable code in template instantiations, as
+// they may only be unreachable in that specific instantiation.
+void isUnreachable();
+
+template <typename T> void test_unreachable_templates() {
+ T::foo();
+ isUnreachable(); // no-warning
+}
+
+struct TestUnreachableA {
+ static void foo() __attribute__((noreturn));
+};
+struct TestUnreachableB {
+ static void foo();
+};
+
+void test_unreachable_templates_harness() {
+ test_unreachable_templates<TestUnreachableA>();
+ test_unreachable_templates<TestUnreachableB>();
+}
+
+// Do warn about explict template specializations, as they represent
+// actual concrete functions that somebody wrote.
+
+template <typename T> void funcToSpecialize() {}
+template <> void funcToSpecialize<int>() {
+ halt();
+ dead(); // expected-warning {{will never be executed}}
+}
+
diff --git a/test/SemaCXX/warn-unused-parameters.cpp b/test/SemaCXX/warn-unused-parameters.cpp
index 75d8dcc..00ce1a9 100644
--- a/test/SemaCXX/warn-unused-parameters.cpp
+++ b/test/SemaCXX/warn-unused-parameters.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -std=c++11 %s
template<typename T>
struct X {
T f0(T x);
@@ -24,3 +24,11 @@ void test_X(X<int> &x, int i) {
x.f4(i);
x.f5(i);
}
+
+// Make sure both parameters aren't considered unused.
+template <typename... T>
+static int test_pack(T... t, T... s)
+{
+ auto l = [&t...]() { return sizeof...(s); };
+ return l();
+}
diff --git a/test/SemaCXX/warn-unused-value.cpp b/test/SemaCXX/warn-unused-value.cpp
index 80298ec..1c0263c 100644
--- a/test/SemaCXX/warn-unused-value.cpp
+++ b/test/SemaCXX/warn-unused-value.cpp
@@ -30,3 +30,22 @@ void b(Foo f1, Foo f2) {
}
#undef NOP
}
+
+namespace test2 {
+ extern "C" {
+ namespace std {
+ template<typename T> struct basic_string {
+ struct X {};
+ void method() const {
+ X* x;
+ &x[0]; // expected-warning {{expression result unused}}
+ }
+ };
+ typedef basic_string<char> string;
+ void func(const std::string& str) {
+ str.method(); // expected-note {{in instantiation of member function}}
+ }
+ }
+ }
+}
+
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp
index 5ba1f2a..5827019 100644
--- a/test/SemaCXX/warn-unused-variables.cpp
+++ b/test/SemaCXX/warn-unused-variables.cpp
@@ -80,3 +80,45 @@ namespace PR10168 {
f<char>(); // expected-note {{here}}
}
}
+
+namespace PR11550 {
+ struct S1 {
+ S1();
+ };
+ S1 makeS1();
+ void testS1(S1 a) {
+ // This constructor call can be elided.
+ S1 x = makeS1(); // expected-warning {{unused variable 'x'}}
+
+ // This one cannot, so no warning.
+ S1 y;
+
+ // This call cannot, but the constructor is trivial.
+ S1 z = a; // expected-warning {{unused variable 'z'}}
+ }
+
+ // The same is true even when we know thet constructor has side effects.
+ void foo();
+ struct S2 {
+ S2() {
+ foo();
+ }
+ };
+ S2 makeS2();
+ void testS2(S2 a) {
+ S2 x = makeS2(); // expected-warning {{unused variable 'x'}}
+ S2 y;
+ S2 z = a; // expected-warning {{unused variable 'z'}}
+ }
+
+ // Or when the constructor is not declared by the user.
+ struct S3 {
+ S1 m;
+ };
+ S3 makeS3();
+ void testS3(S3 a) {
+ S3 x = makeS3(); // expected-warning {{unused variable 'x'}}
+ S3 y;
+ S3 z = a; // expected-warning {{unused variable 'z'}}
+ }
+}
diff --git a/test/SemaCXX/warn-weak-vtables.cpp b/test/SemaCXX/warn-weak-vtables.cpp
index 912622f..135e034 100644
--- a/test/SemaCXX/warn-weak-vtables.cpp
+++ b/test/SemaCXX/warn-weak-vtables.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wweak-vtables
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wweak-vtables -Wweak-template-vtables
struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
virtual void f() { }
@@ -56,3 +56,23 @@ void uses(Parent &p, Derived &d, VeryDerived &vd) {
d.getFoo();
vd.getFoo();
}
+
+template<typename T> struct TemplVirt {
+ virtual void f();
+};
+
+template class TemplVirt<float>; // expected-warning{{explicit template instantiation 'TemplVirt<float>' will emit a vtable in every translation unit}}
+
+template<> struct TemplVirt<bool> {
+ virtual void f();
+};
+
+template<> struct TemplVirt<long> { // expected-warning{{'TemplVirt<long>' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
+ virtual void f() {}
+};
+
+void uses(TemplVirt<float>& f, TemplVirt<bool>& b, TemplVirt<long>& l) {
+ f.f();
+ b.f();
+ l.f();
+}
diff --git a/test/SemaCXX/zero-length-arrays.cpp b/test/SemaCXX/zero-length-arrays.cpp
new file mode 100644
index 0000000..05ded4a
--- /dev/null
+++ b/test/SemaCXX/zero-length-arrays.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/10228639>
+class Foo {
+ ~Foo();
+ Foo(const Foo&);
+public:
+ Foo(int);
+};
+
+class Bar {
+ int foo_count;
+ Foo foos[0];
+ Foo foos2[0][2];
+ Foo foos3[2][0];
+
+public:
+ Bar(): foo_count(0) { }
+ ~Bar() { }
+};
+
+void testBar() {
+ Bar b;
+ Bar b2(b);
+ b = b2;
+}
diff --git a/test/SemaObjC/ClassPropertyNotObject.m b/test/SemaObjC/ClassPropertyNotObject.m
new file mode 100644
index 0000000..02ed40a
--- /dev/null
+++ b/test/SemaObjC/ClassPropertyNotObject.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10565506
+
+@protocol P @end
+
+@interface I
+@property Class<P> MyClass;
+@property Class MyClass1;
+@property void * VOIDSTAR;
+@end
+
+@implementation I
+@synthesize MyClass, MyClass1, VOIDSTAR;
+@end
diff --git a/test/SemaObjC/ContClassPropertyLookup.m b/test/SemaObjC/ContClassPropertyLookup.m
index b3459c1..06a0ffa 100644
--- a/test/SemaObjC/ContClassPropertyLookup.m
+++ b/test/SemaObjC/ContClassPropertyLookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MyObject {
int _foo;
@@ -16,3 +16,23 @@
@implementation MyObject
@synthesize foo = _foo;
@end
+
+// rdar://10666594
+@interface MPMediaItem
+@end
+
+@class MPMediaItem;
+
+@interface MPMediaItem ()
+@property (nonatomic, readonly) id title;
+@end
+
+@interface PodcastEpisodesViewController
+@end
+
+@implementation PodcastEpisodesViewController
+- (id) Meth {
+ MPMediaItem *episode;
+ return episode.title;
+}
+@end
diff --git a/test/SemaObjC/DoubleMethod.m b/test/SemaObjC/DoubleMethod.m
index 98aa699..4eca4c7 100644
--- a/test/SemaObjC/DoubleMethod.m
+++ b/test/SemaObjC/DoubleMethod.m
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify -Wno-objc-root-class %s
@interface Subclass
{
int ivar;
}
-- (void) method;
-- (void) method;
+- (void) method; // expected-note {{previous declaration is here}}
+- (void) method; // expected-warning {{multiple declarations of method 'method' found and ignored}}
@end
@implementation Subclass
diff --git a/test/SemaObjC/NSString-type.m b/test/SemaObjC/NSString-type.m
new file mode 100644
index 0000000..3b4857a
--- /dev/null
+++ b/test/SemaObjC/NSString-type.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+}
+
diff --git a/test/SemaObjC/alias-test-2.m b/test/SemaObjC/alias-test-2.m
index 1f12b76..6688db6 100644
--- a/test/SemaObjC/alias-test-2.m
+++ b/test/SemaObjC/alias-test-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// Note: GCC doesn't produce any of the following errors.
@interface Super @end // expected-note {{previous definition is here}}
@@ -9,9 +9,9 @@
@compatibility_alias AliasForSuper Super;
-@interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}}
+@implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}}
@end
-@implementation MyAlias : AliasForSuper // expected-error {{conflicting super class name 'Super'}}
+@interface MyAlias : AliasForSuper // expected-error {{duplicate interface definition for class 'MyWpModule'}}
@end
diff --git a/test/SemaObjC/arc-bridged-cast.m b/test/SemaObjC/arc-bridged-cast.m
index 47476c8..56efe81 100644
--- a/test/SemaObjC/arc-bridged-cast.m
+++ b/test/SemaObjC/arc-bridged-cast.m
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks %s
typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
typedef const struct __CFString *CFStringRef;
@interface NSString
@@ -36,8 +37,8 @@ void to_cf(id obj) {
void fixits() {
id obj1 = (id)CFCreateSomething(); // expected-error{{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
CFTypeRef cf1 = (CFTypeRef)CreateSomething(); // expected-error{{cast of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
+ // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}}
}
diff --git a/test/SemaObjC/arc-cf.m b/test/SemaObjC/arc-cf.m
index c1df3e0..69662ea 100644
--- a/test/SemaObjC/arc-cf.m
+++ b/test/SemaObjC/arc-cf.m
@@ -1,14 +1,20 @@
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
+#if __has_feature(arc_cf_code_audited)
+char _global[-1]; // expected-error {{declared as an array with a negative size}}
+#endif
+
typedef const void *CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
typedef const struct __CFString *CFStringRef;
extern CFStringRef CFMakeString0(void);
extern CFStringRef CFCreateString0(void);
void test0() {
id x;
- x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
- x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
}
extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
@@ -16,5 +22,24 @@ extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained));
void test1() {
id x;
x = (id) CFMakeString1();
- x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
+ x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+}
+
+#define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin")
+#define CF_AUDIT_END _Pragma("clang arc_cf_code_audited end")
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
+
+CF_AUDIT_BEGIN
+extern CFStringRef CFMakeString2(void);
+extern CFStringRef CFCreateString2(void) CF_RETURNS_NOT_RETAINED;
+extern CFStringRef CFMakeString3(void) CF_RETURNS_RETAINED;
+extern CFStringRef CFCreateString3(void);
+CF_AUDIT_END
+void test2() {
+ id x;
+ x = (id) CFMakeString2();
+ x = (id) CFCreateString2();
+ x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
+ x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}}
}
diff --git a/test/SemaObjC/arc-decls.m b/test/SemaObjC/arc-decls.m
index 1084db8..8d5cca2 100644
--- a/test/SemaObjC/arc-decls.m
+++ b/test/SemaObjC/arc-decls.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://8843524
@@ -21,6 +21,11 @@ union u {
};
@end
+// rdar://10260525
+struct r10260525 {
+ id (^block) (); // expected-error {{ARC forbids blocks in structs or unions}}
+};
+
struct S {
id __attribute__((objc_ownership(none))) i;
void * vp;
@@ -81,3 +86,14 @@ void func()
- (id)not_ret:(id) b __attribute((ns_returns_retained)); // expected-error {{overriding method has mismatched ns_returns_retained attributes}}
- (id)both__returns_not_retained:(id) b __attribute((ns_returns_not_retained));
@end
+
+// Test that we give a good diagnostic here that mentions the missing
+// ownership qualifier. We don't want this to get suppressed because
+// of an invalid conversion.
+void test7(void) {
+ id x;
+ id *px = &x; // expected-error {{pointer to non-const type 'id' with no explicit ownership}}
+
+ I *y;
+ J **py = &y; // expected-error {{pointer to non-const type 'J *' with no explicit ownership}} expected-warning {{incompatible pointer types initializing}}
+}
diff --git a/test/SemaObjC/arc-invalid.m b/test/SemaObjC/arc-invalid.m
new file mode 100644
index 0000000..c736ed4
--- /dev/null
+++ b/test/SemaObjC/arc-invalid.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fblocks -verify %s
+
+// rdar://problem/10982793
+// [p foo] in ARC creates a cleanup.
+// The plus is invalid and causes the cleanup to go unbound.
+// Don't crash.
+@interface A
+- (id) foo;
+@end
+void takeBlock(void (^)(void));
+void test0(id p) {
+ takeBlock(^{ [p foo] + p; }); // expected-error {{invalid operands to binary expression}}
+}
+
+void test1(void) {
+ __autoreleasing id p; // expected-note {{'p' declared here}}
+ takeBlock(^{ (void) p; }); // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
diff --git a/test/SemaObjC/arc-jump-block.m b/test/SemaObjC/arc-jump-block.m
index 9b44606..26a1fc8 100644
--- a/test/SemaObjC/arc-jump-block.m
+++ b/test/SemaObjC/arc-jump-block.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
// rdar://9535237
typedef struct dispatch_queue_s *dispatch_queue_t;
@@ -82,3 +82,16 @@ extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_
- (void)pageLeft {}
- (void)pageRight {}
@end
+
+// Test 2. rdar://problem/11150919
+int test2(id obj, int state) { // expected-note {{jump enters lifetime of block}} FIXME: wierd location
+ switch (state) {
+ case 0:
+ (void) ^{ (void) obj; };
+ return 0;
+
+ default: // expected-error {{switch case is in protected scope}}
+ return 1;
+ }
+}
+
diff --git a/test/SemaObjC/arc-no-runtime.m b/test/SemaObjC/arc-no-runtime.m
index 49c439b..b75064f 100644
--- a/test/SemaObjC/arc-no-runtime.m
+++ b/test/SemaObjC/arc-no-runtime.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://problem/9150784
void test(void) {
__weak id x; // expected-error {{the current deployment target does not support automated __weak references}}
+ __weak void *v; // expected-warning {{'__weak' only applies to objective-c object or block pointer types}}
}
@interface A
diff --git a/test/SemaObjC/arc-objc-lifetime.m b/test/SemaObjC/arc-objc-lifetime.m
new file mode 100644
index 0000000..03260e8
--- /dev/null
+++ b/test/SemaObjC/arc-objc-lifetime.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
+// rdar://10244607
+
+typedef const struct __CFString * CFStringRef;
+@class NSString;
+
+NSString *CFBridgingRelease();
+
+typedef NSString * PNSString;
+
+typedef __autoreleasing NSString * AUTORELEASEPNSString;
+
+@interface I @end
+
+@implementation I
+- (CFStringRef)myString
+{
+ CFStringRef myString =
+ (__bridge CFStringRef) (__strong NSString *)CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+
+ myString =
+ (__bridge CFStringRef) (__autoreleasing PNSString) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+ myString =
+ (__bridge CFStringRef) (AUTORELEASEPNSString) CFBridgingRelease(); // OK
+ myString =
+ (__bridge CFStringRef) (typeof(__strong NSString *)) CFBridgingRelease(); // expected-error {{explicit ownership qualifier on cast result has no effect}}
+ return myString;
+}
+
+- (void)decodeValueOfObjCType:(const char *)type at:(void *)addr {
+ __autoreleasing id *stuff = (__autoreleasing id *)addr;
+}
+@end
+
+// rdar://problem/10711456
+__strong I *__strong test1; // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__strong I *(__strong test2); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__strong I *(__strong (test3)); // expected-error {{the type 'I *__strong' is already explicitly ownership-qualified}}
+__unsafe_unretained __typeof__(test3) test4;
+typedef __strong I *strong_I;
+__unsafe_unretained strong_I test5;
diff --git a/test/SemaObjC/arc-peformselector.m b/test/SemaObjC/arc-peformselector.m
index c015eb8..dec09e3 100644
--- a/test/SemaObjC/arc-peformselector.m
+++ b/test/SemaObjC/arc-peformselector.m
@@ -2,12 +2,12 @@
// rdar://9659270
@interface NSObject
-- (id)copy; // expected-note {{method declared here}}
-- (id) test __attribute__((ns_returns_retained)); // expected-note {{method declared here}}
-+ (id) new ; // expected-note {{method declared here}}
+- (id)copy; // expected-note {{method 'copy' declared here}}
+- (id) test __attribute__((ns_returns_retained)); // expected-note {{method 'test' declared here}}
++ (id) new ; // expected-note {{method 'new' declared here}}
- (id) init __attribute__((ns_returns_not_retained));
- (id)PlusZero;
-- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method declared here}}
+- (id)PlusOne __attribute__((ns_returns_retained)); // expected-note {{method 'PlusOne' declared here}}
@end
@interface I : NSObject
diff --git a/test/SemaObjC/arc-property-lifetime.m b/test/SemaObjC/arc-property-lifetime.m
index 9cc3ada..fad37cc 100644
--- a/test/SemaObjC/arc-property-lifetime.m
+++ b/test/SemaObjC/arc-property-lifetime.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://9340606
@interface Foo {
@@ -125,3 +125,46 @@
@synthesize controllerClass = _controllerClass;
@synthesize controllerId = _controllerId;
@end
+
+// rdar://10630891
+@interface UIView @end
+@class UIColor;
+
+@interface UIView(UIViewRendering)
+@property(nonatomic,copy) UIColor *backgroundColor;
+@end
+
+@interface UILabel : UIView
+@end
+
+@interface MyView
+@property (strong) UILabel *label;
+@end
+
+@interface MyView2 : MyView @end
+
+@implementation MyView2
+- (void)foo {
+ super.label.backgroundColor = 0;
+}
+@end
+
+// rdar://10694932
+@interface Baz
+@property id prop;
+@property __strong id strong_prop;
+@property (strong) id strong_attr_prop;
+@property (strong) __strong id realy_strong_attr_prop;
++ (id) alloc;
+- (id) init;
+- (id) implicit;
+- (void) setImplicit : (id) arg;
+@end
+
+void foo(Baz *f) {
+ f.prop = [[Baz alloc] init];
+ f.strong_prop = [[Baz alloc] init];
+ f.strong_attr_prop = [[Baz alloc] init];
+ f.realy_strong_attr_prop = [[Baz alloc] init];
+ f.implicit = [[Baz alloc] init];
+}
diff --git a/test/SemaObjC/arc-property.m b/test/SemaObjC/arc-property.m
index 2993118..2599fb9 100644
--- a/test/SemaObjC/arc-property.m
+++ b/test/SemaObjC/arc-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
// rdar://9309489
@interface MyClass {
@@ -46,3 +46,12 @@
@synthesize z; // suppressed
@end
+// rdar://problem/10904479
+// Don't crash.
+@interface Test2
+// Minor FIXME: kill the redundant error
+@property (strong) UndeclaredClass *test2; // expected-error {{unknown type name 'UndeclaredClass'}} expected-error {{must be of object type}}
+@end
+@implementation Test2
+@synthesize test2;
+@end
diff --git a/test/SemaObjC/arc-readonly-property-ivar-1.m b/test/SemaObjC/arc-readonly-property-ivar-1.m
new file mode 100644
index 0000000..c773f26
--- /dev/null
+++ b/test/SemaObjC/arc-readonly-property-ivar-1.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fobjc-default-synthesize-properties -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fobjc-default-synthesize-properties -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar:// 10558871
+
+@interface PP
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyX;
+@end
+
+@implementation PP {
+__weak id _ReadOnlyProperty;
+}
+@synthesize ReadOnlyPropertyNoBackingIvar;
+@synthesize ReadOnlyProperty = _ReadOnlyProperty;
+@synthesize ReadOnlyPropertyX = _ReadOnlyPropertyX;
+@end
+
+@interface DD
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyStrong;
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@end
+
+@implementation DD {
+__weak id _ReadOnlyProperty;
+__strong id _ReadOnlyPropertyStrong;
+}
+@end
diff --git a/test/SemaObjC/arc-readonly-property-ivar.m b/test/SemaObjC/arc-readonly-property-ivar.m
new file mode 100644
index 0000000..635b9fe
--- /dev/null
+++ b/test/SemaObjC/arc-readonly-property-ivar.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar:// 10558871
+
+@interface PP
+@property (readonly) id ReadOnlyPropertyNoBackingIvar;
+@property (readonly) id ReadOnlyProperty;
+@property (readonly) id ReadOnlyPropertyX;
+@end
+
+@implementation PP {
+__weak id _ReadOnlyProperty;
+}
+@synthesize ReadOnlyPropertyNoBackingIvar;
+@synthesize ReadOnlyProperty = _ReadOnlyProperty;
+@synthesize ReadOnlyPropertyX = _ReadOnlyPropertyX;
+@end
diff --git a/test/SemaObjC/arc-retain-block-property.m b/test/SemaObjC/arc-retain-block-property.m
index c7d04300..3b66d14 100644
--- a/test/SemaObjC/arc-retain-block-property.m
+++ b/test/SemaObjC/arc-retain-block-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://9829425
extern void doSomething();
diff --git a/test/SemaObjC/arc-setter-property-match.m b/test/SemaObjC/arc-setter-property-match.m
index 0de0a11..9158b09 100644
--- a/test/SemaObjC/arc-setter-property-match.m
+++ b/test/SemaObjC/arc-setter-property-match.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
// rdar://10156674
@class NSArray;
diff --git a/test/SemaObjC/arc-type-conversion.m b/test/SemaObjC/arc-type-conversion.m
index 01f61bd..5cf2cf4 100644
--- a/test/SemaObjC/arc-type-conversion.m
+++ b/test/SemaObjC/arc-type-conversion.m
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
void * cvt(id arg)
{
void* voidp_val;
@@ -12,12 +16,15 @@ void * cvt(id arg)
(void)(void*)voidp_val;
(void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed with ARC}}
cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
- // expected-error {{implicit conversion of a non-Objective-C pointer type 'void *' to 'id' is disallowed with ARC}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+ // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} \
+ // expected-note 2 {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}} \
+ // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'void *' into ARC}}
cvt(0);
(void)(__strong id**)(0);
- return arg; // expected-error {{implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC}}
+ return arg; // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
+ // expected-note {{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note {{use CFBridgingRetain call to make an ARC object available as a +1 'void *'}}
}
void to_void(__strong id *sip, __weak id *wip,
@@ -74,4 +81,18 @@ void ownership_transfer_in_cast(void *vp, Block *pblk) {
Block_strong blk_strong1;
Block_strong blk_strong2 = (Block)blk_strong1;
Block_autoreleasing *blk_auto = (Block*)pblk;
+
+ id lv;
+ (void)(id)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'id'}}
+ (void)(id*)lv; // expected-error {{cast of an Objective-C pointer to '__strong id *'}}
+ (void)(NSString*)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'NSString *'}}
+ (void)(NSString**)lv; // expected-error {{cast of an Objective-C pointer to 'NSString *__strong *'}}
+ (void)(Block)&lv; // expected-error {{cast of an indirect pointer to an Objective-C pointer to 'Block'}}
+ (void)(Block*)lv; // expected-error {{cast of an Objective-C pointer to '__strong Block *'}}
+}
+
+// <rdar://problem/10486347>
+void conversion_in_conditional(id a, void* b) {
+ id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' and 'void *' are incompatible in ARC mode}}
+ id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void *' and 'id' are incompatible in ARC mode}}
}
diff --git a/test/SemaObjC/arc-unavailable-for-weakref.m b/test/SemaObjC/arc-unavailable-for-weakref.m
index 6db2155..8498de6 100644
--- a/test/SemaObjC/arc-unavailable-for-weakref.m
+++ b/test/SemaObjC/arc-unavailable-for-weakref.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://9693477
__attribute__((objc_arc_weak_reference_unavailable))
@@ -15,7 +15,8 @@ int main() {
id obj;
ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \
- // expected-error {{class is incompatible with __weak references}}
+ // expected-error {{class is incompatible with __weak references}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
// rdar://9732636
@@ -30,7 +31,8 @@ NOWEAK * Test1() {
weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
__weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
- return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}}
+ return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
@protocol P @end
@@ -42,6 +44,21 @@ NOWEAK<P, P1> * Test2() {
weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
__weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
- return (__weak id<P>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P>'}}
+ return (__weak id<P>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P>'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
+// rdar://10535245
+__attribute__((objc_arc_weak_reference_unavailable))
+@interface NSFont
+@end
+
+@interface I
+{
+}
+@property (weak) NSFont *font; // expected-note {{property declared here}}
+@end
+
+@implementation I
+@synthesize font = _font; // expected-error {{synthesis of a weak-unavailable property is disallowed because it requires synthesis of an ivar of the __weak object}}
+@end
diff --git a/test/SemaObjC/arc-unbridged-cast.m b/test/SemaObjC/arc-unbridged-cast.m
index 8b835a1..7d5a6b0 100644
--- a/test/SemaObjC/arc-unbridged-cast.m
+++ b/test/SemaObjC/arc-unbridged-cast.m
@@ -1,6 +1,10 @@
// // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
+
@interface Object
@property CFStringRef property;
@@ -35,15 +39,15 @@ void test1(int cond) {
x = (id) (cond ? (void*) 0 : auditedString());
x = (id) (cond ? (CFStringRef) @"help" : auditedString());
- x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
- x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
- x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use __bridge_transfer to}}
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
x = (id) [object property];
x = (id) (cond ? [object property] : (void*) 0);
@@ -70,3 +74,50 @@ void test1(int cond) {
x = (id) (cond ? (void*) 0 : [object newString]);
x = (id) (cond ? (CFStringRef) @"help" : [object newString]); // a bit questionable
}
+
+// rdar://problem/10246264
+@interface CFTaker
+- (void) takeOrdinary: (CFStringRef) arg;
+- (void) takeVariadic: (int) n, ...;
+- (void) takeConsumed: (CFStringRef __attribute__((cf_consumed))) arg;
+@end
+void testCFTaker(CFTaker *taker, id string) {
+ [taker takeOrdinary: (CFStringRef) string];
+ [taker takeVariadic: 1, (CFStringRef) string];
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void takeCFOrdinaryUnaudited(CFStringRef arg);
+void takeCFVariadicUnaudited(int n, ...);
+void takeCFConsumedUnaudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited begin
+void takeCFOrdinaryAudited(CFStringRef arg);
+void takeCFVariadicAudited(int n, ...);
+void takeCFConsumedAudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited end
+
+void testTakerFunctions(id string) {
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited((CFStringRef) string);
+ takeCFVariadicAudited(1, (CFStringRef) string);
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void testTakerFunctions_parens(id string) {
+ takeCFOrdinaryUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, ((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited(((CFStringRef) string));
+ takeCFVariadicAudited(1, ((CFStringRef) string));
+ takeCFConsumedAudited(((CFStringRef) string)); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
diff --git a/test/SemaObjC/arc-unsafe-assigns.m b/test/SemaObjC/arc-unsafe-assigns.m
index 6dba18b..1805b85 100644
--- a/test/SemaObjC/arc-unsafe-assigns.m
+++ b/test/SemaObjC/arc-unsafe-assigns.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://9495837
@interface Foo {
diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m
index ed6e60d..9c3b298 100644
--- a/test/SemaObjC/arc.m
+++ b/test/SemaObjC/arc.m
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
typedef unsigned long NSUInteger;
+typedef const void * CFTypeRef;
+CFTypeRef CFBridgingRetain(id X);
+id CFBridgingRelease(CFTypeRef);
void test0(void (*fn)(int), int val) {
fn(val);
@@ -36,15 +39,13 @@ void test1(A *a) {
}
@end
-__weak __strong id x; // expected-error {{the type '__strong id' already has retainment attributes}}
-
// rdar://8843638
@interface I
-- (id)retain; // expected-note {{method declared here}}
-- (id)autorelease; // expected-note {{method declared here}}
-- (oneway void)release; // expected-note {{method declared here}}
-- (NSUInteger)retainCount; // expected-note {{method declared here}}
+- (id)retain; // expected-note {{method 'retain' declared here}}
+- (id)autorelease; // expected-note {{method 'autorelease' declared here}}
+- (oneway void)release; // expected-note {{method 'release' declared here}}
+- (NSUInteger)retainCount; // expected-note {{method 'retainCount' declared here}}
@end
@implementation I
@@ -189,13 +190,13 @@ void test7_unsafe(void) {
- (id) init50 { return 0; }
- (void) init01 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \
- // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
- (void) init11 {}
- (void) init21 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}}
- (void) init31 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \
- // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
- (void) init41 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \
- // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
+ // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
- (void) init51 {}
- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
@@ -263,8 +264,8 @@ void test11(id op, void *vp) {
b = (vp == nil);
b = (nil == vp);
- b = (vp == op); // expected-error {{implicit conversion of an Objective-C pointer to 'void *'}}
- b = (op == vp); // expected-error {{implicit conversion of a non-Objective-C pointer type 'void *' to 'id'}}
+ b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}}
+ b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}}
}
void test12(id collection) {
@@ -294,6 +295,16 @@ void test12(id collection) {
}
@end
+// <rdar://problem/10274056>
+@interface Test13_B
+- (id) consumesSelf __attribute__((ns_consumes_self));
+@end
+@implementation Test13_B
+- (id) consumesSelf {
+ self = 0; // no-warning
+}
+@end
+
// rdar://problem/9172151
@class Test14A, Test14B;
void test14() {
@@ -368,7 +379,7 @@ void test16(void) {
[v test16_6: 0];
}
-@class Test17;
+@class Test17; // expected-note 2{{forward declaration of class here}}
@protocol Test17p
- (void) test17;
+ (void) test17;
@@ -393,11 +404,11 @@ struct Test19 *const test19b = 0;
void test19(void) {
id x;
x = (id) test19a; // expected-error {{bridged cast}} \
- // expected-note{{use __bridge to convert directly (no change in ownership))}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
+ // expected-note{{use __bridge to convert directly (no change in ownership)}} \
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
x = (id) test19b; // expected-error {{bridged cast}} \
// expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
+ // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}}
}
// rdar://problem/8951453
@@ -492,18 +503,18 @@ void test26(id y) {
id myProp2;
}
@property id x;
-@property (readonly) id ro; // expected-note {{declared here}}
+@property (readonly) id ro;
@property (readonly) id custom_ro;
@property int y;
-@property (readonly) id myProp1;
+@property (readonly) __weak id myProp1;
@property (readonly) id myProp2;
@property (readonly) __strong id myProp3;
@end
@implementation Test27
@synthesize x;
-@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
+@synthesize ro;
@synthesize y;
@synthesize myProp1 = _myProp1;
@@ -641,7 +652,7 @@ void test36(int first, ...) {
__builtin_va_end(arglist);
}
-@class Test37;
+@class Test37; // expected-note{{forward declaration of class here}}
void test37(Test37 *c) {
for (id y in c) { // expected-error {{collection expression type 'Test37' is a forward declaration}}
(void) y;
diff --git a/test/SemaObjC/assign-rvalue-message.m b/test/SemaObjC/assign-rvalue-message.m
index 8cbce8e..1105d5e 100644
--- a/test/SemaObjC/assign-rvalue-message.m
+++ b/test/SemaObjC/assign-rvalue-message.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9005189
@interface Foo
diff --git a/test/SemaObjC/atomoic-property-synnthesis-rules.m b/test/SemaObjC/atomoic-property-synnthesis-rules.m
index 2061a77..b681558 100644
--- a/test/SemaObjC/atomoic-property-synnthesis-rules.m
+++ b/test/SemaObjC/atomoic-property-synnthesis-rules.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
/*
Conditions for warning:
@@ -107,8 +107,10 @@
// read-write - might warn
@property int GetSet;
-@property int Get; // expected-note {{property declared here}}
-@property int Set; // expected-note {{property declared here}}
+@property int Get; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int Set; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
@property int None;
@property(nonatomic) int GetSet_Nonatomic;
@property(nonatomic) int Get_Nonatomic;
@@ -127,8 +129,10 @@
// read-only in class, read-write in class extension - might warn
@property(readonly) int GetSet_ReadWriteInExt;
-@property(readonly) int Get_ReadWriteInExt; // expected-note {{property declared here}}
-@property(readonly) int Set_ReadWriteInExt; // expected-note {{property declared here}}
+@property(readonly) int Get_ReadWriteInExt; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int Set_ReadWriteInExt; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
@property(readonly) int None_ReadWriteInExt;
@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt;
@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt;
@@ -138,8 +142,10 @@
// same as above, but @synthesize follows the hand-written methods - might warn
@property int GetSet_LateSynthesize;
-@property int Get_LateSynthesize; // expected-note {{property declared here}}
-@property int Set_LateSynthesize; // expected-note {{property declared here}}
+@property int Get_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property int Set_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
@property int None_LateSynthesize;
@property(nonatomic) int GetSet_Nonatomic_LateSynthesize;
@property(nonatomic) int Get_Nonatomic_LateSynthesize;
@@ -156,8 +162,10 @@
@property(nonatomic,readonly) int None_Nonatomic_ReadOnly_LateSynthesize;
@property(readonly) int GetSet_ReadWriteInExt_LateSynthesize;
-@property(readonly) int Get_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}}
-@property(readonly) int Set_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}}
+@property(readonly) int Get_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
+@property(readonly) int Set_ReadWriteInExt_LateSynthesize; // expected-note {{property declared here}} \
+ // expected-note {{setter and getter must both be synthesized}}
@property(readonly) int None_ReadWriteInExt_LateSynthesize;
@property(nonatomic,readonly) int GetSet_Nonatomic_ReadWriteInExt_LateSynthesize;
@property(nonatomic,readonly) int Get_Nonatomic_ReadWriteInExt_LateSynthesize;
@@ -240,10 +248,8 @@
GET(GetSet)
SET(GetSet)
-GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}} \
- // expected-note {{setter and getter must both be synthesized}}
-SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}} \
- // expected-note {{setter and getter must both be synthesized}}
+GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}}
+SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}}
GET(GetSet_Nonatomic)
SET(GetSet_Nonatomic)
GET(Get_Nonatomic)
@@ -260,10 +266,8 @@ SET(Set_Nonatomic_ReadOnly)
GET(GetSet_ReadWriteInExt)
SET(GetSet_ReadWriteInExt)
-GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}} \
- // expected-note {{setter and getter must both be synthesized}}
-SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}} \
- // expected-note {{setter and getter must both be synthesized}}
+GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}}
GET(GetSet_Nonatomic_ReadWriteInExt)
SET(GetSet_Nonatomic_ReadWriteInExt)
GET(Get_Nonatomic_ReadWriteInExt)
@@ -272,10 +276,8 @@ SET(Set_Nonatomic_ReadWriteInExt)
GET(GetSet_LateSynthesize)
SET(GetSet_LateSynthesize)
-GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \
- // expected-note {{setter and getter must both be synthesized}}
-SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \
- // expected-note {{setter and getter must both be synthesized}}
+GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
GET(GetSet_Nonatomic_LateSynthesize)
SET(GetSet_Nonatomic_LateSynthesize)
GET(Get_Nonatomic_LateSynthesize)
@@ -292,10 +294,8 @@ SET(Set_Nonatomic_ReadOnly_LateSynthesize)
GET(GetSet_ReadWriteInExt_LateSynthesize)
SET(GetSet_ReadWriteInExt_LateSynthesize)
-GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \
- // expected-note {{setter and getter must both be synthesized}}
-SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \
- // expected-note {{setter and getter must both be synthesized}}
+GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}}
+SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}}
GET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
SET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize)
GET(Get_Nonatomic_ReadWriteInExt_LateSynthesize)
diff --git a/test/SemaObjC/attr-deprecated.m b/test/SemaObjC/attr-deprecated.m
index ca26759..db0b958 100644
--- a/test/SemaObjC/attr-deprecated.m
+++ b/test/SemaObjC/attr-deprecated.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface A {
int X __attribute__((deprecated));
@@ -9,7 +9,7 @@
@implementation A
+ (void)F __attribute__((deprecated))
-{ // expected-warning {{method attribute can only be specified on method declarations}}
+{
[self F]; // no warning, since the caller is also deprecated.
}
@@ -77,8 +77,8 @@ void t4(Class c)
int t5() {
Bar *f;
- f.FooBar = 1; // expected-warning {{warning: 'FooBar' is deprecated}}
- return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
+ f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
+ return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
}
@@ -99,10 +99,10 @@ __attribute ((deprecated))
@interface DEPRECATED (Category2) // no warning.
@end
-@implementation DEPRECATED (Category2) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
+@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
@end
-@interface NS : DEPRECATED // expected-warning {{warning: 'DEPRECATED' is deprecated}}
+@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
@end
diff --git a/test/SemaObjC/attr-root-class.m b/test/SemaObjC/attr-root-class.m
new file mode 100644
index 0000000..195cd66
--- /dev/null
+++ b/test/SemaObjC/attr-root-class.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes -Wobjc-root-class %s
+@interface RootClass {} // expected-warning {{class 'RootClass' defined without specifying a base class}} \
+ // expected-note {{add a super class to fix this problem}}
+@end
+@implementation RootClass
+@end
+
+__attribute__((objc_root_class))
+@interface NonRootClass : RootClass // expected-error {{objc_root_class attribute may only be specified on a root class declaration}}
+@end
+@implementation NonRootClass
+@end
+
+__attribute__((objc_root_class)) static void nonClassDeclaration() // expected-error {{attribute may only be applied to an Objective-C interface}}
+{
+}
diff --git a/test/SemaObjC/autoreleasepool.m b/test/SemaObjC/autoreleasepool.m
index 41e1768..45c749e 100644
--- a/test/SemaObjC/autoreleasepool.m
+++ b/test/SemaObjC/autoreleasepool.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
void *objc_autoreleasepool_push();
void autoreleasepool_pop(void*);
diff --git a/test/SemaObjC/bad-property-synthesis-crash.m b/test/SemaObjC/bad-property-synthesis-crash.m
index 577faea..ea4e004 100644
--- a/test/SemaObjC/bad-property-synthesis-crash.m
+++ b/test/SemaObjC/bad-property-synthesis-crash.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://10177744
@interface Foo
diff --git a/test/SemaObjC/block-id-as-block-argtype.m b/test/SemaObjC/block-id-as-block-argtype.m
new file mode 100644
index 0000000..20bb6ad
--- /dev/null
+++ b/test/SemaObjC/block-id-as-block-argtype.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
+// rdar://10734265
+
+@class NSObject;
+typedef void (^block1_t)(int arg);
+typedef void (^block2_t)(block1_t arg);
+typedef void (^block3_t)(NSObject *arg);
+typedef void (^block4_t)(id arg);
+
+void fn(block4_t arg); // expected-note {{passing argument to parameter 'arg' here}}
+
+void another_fn(block2_t arg);
+
+int main() {
+ block1_t b1;
+ block2_t b2;
+ block3_t b3;
+ block3_t b4;
+ block4_t b5;
+
+ fn(b1); // expected-error {{incompatible block pointer types passing 'block1_t' (aka 'void (^)(int)') to parameter of type 'block4_t' (aka 'void (^)(id)')}}
+ fn(b2); // must succeed: block1_t *is* compatible with id
+ fn(b3); // succeeds: NSObject* compatible with id
+ fn(b4); // succeeds: id compatible with id
+
+ another_fn(b5);
+}
diff --git a/test/SemaObjC/block-on-method-param.m b/test/SemaObjC/block-on-method-param.m
new file mode 100644
index 0000000..d5cbc8a
--- /dev/null
+++ b/test/SemaObjC/block-on-method-param.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+
+// rdar://10681443
+@interface I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp; // expected-error {{__block attribute not allowed, only allowed on local variables}}
+@end
+
+@implementation I
+- (void) compileSandboxProfileAndReturnError:(__attribute__((__blocks__(byref))) id)errorp {} // expected-error {{__block attribute not allowed, only allowed on local variables}}
+@end
+
diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m
index ebc6777..56342ba 100644
--- a/test/SemaObjC/block-type-safety.m
+++ b/test/SemaObjC/block-type-safety.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
// test for block type safety.
@interface Super @end
@@ -138,3 +138,20 @@ int test5() {
return 0;
}
+// rdar://10798770
+typedef int NSInteger;
+
+typedef enum : NSInteger {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending} NSComparisonResult;
+
+typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
+
+@interface radar10798770
+- (void)sortUsingComparator:(NSComparator)c;
+@end
+
+void f() {
+ radar10798770 *f;
+ [f sortUsingComparator:^(id a, id b) {
+ return NSOrderedSame;
+ }];
+}
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 2d77a20..7beec19 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -45,10 +45,10 @@ void foo7(id (^x)(int)) {
@end
void foo8() {
- void *P = ^(itf x) {}; // expected-error {{Objective-C interface type 'itf' cannot be passed by value; did you forget * in 'itf'}}
- P = ^itf(int x) {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
- P = ^itf() {}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
- P = ^itf{}; // expected-error {{Objective-C interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+ void *P = ^(itf x) {}; // expected-error {{interface type 'itf' cannot be passed by value; did you forget * in 'itf'}}
+ P = ^itf(int x) {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+ P = ^itf() {}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
+ P = ^itf{}; // expected-error {{interface type 'itf' cannot be returned by value; did you forget * in 'itf'}}
}
diff --git a/test/SemaObjC/builtin_objc_lib_functions.m b/test/SemaObjC/builtin_objc_lib_functions.m
index 02b05b9..956ee12 100644
--- a/test/SemaObjC/builtin_objc_lib_functions.m
+++ b/test/SemaObjC/builtin_objc_lib_functions.m
@@ -1,29 +1,29 @@
// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
// rdar://8592641
-Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring C library function 'objc_getClass' with type 'id (const char *)'}} \
+Class f0() { return objc_getClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getClass' with type 'id (const char *)'}} \
// expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getClass'}}
// rdar://8735023
-Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring C library function 'objc_getMetaClass' with type 'id (const char *)'}} \
+Class f1() { return objc_getMetaClass("a"); } // expected-warning {{implicitly declaring library function 'objc_getMetaClass' with type 'id (const char *)'}} \
// expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_getMetaClass'}}
-void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring C library function 'objc_enumerationMutation' with type 'void (id)'}} \
+void f2(id val) { objc_enumerationMutation(val); } // expected-warning {{implicitly declaring library function 'objc_enumerationMutation' with type 'void (id)'}} \
// expected-note {{please include the header <objc/runtime.h> or explicitly provide a declaration for 'objc_enumerationMutation'}}
-long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{implicitly declaring C library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
+long double f3(id self, SEL op) { return objc_msgSend_fpret(self, op); } // expected-warning {{implicitly declaring library function 'objc_msgSend_fpret' with type 'long double (id, SEL, ...)'}} \
// expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSend_fpret'}}
id f4(struct objc_super *super, SEL op) { // expected-warning {{declaration of 'struct objc_super' will not be visible outside of this function}}
- return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring C library function 'objc_msgSendSuper' with type 'id (void *, SEL, ...)'}} \
+ return objc_msgSendSuper(super, op); // expected-warning {{implicitly declaring library function 'objc_msgSendSuper' with type 'id (void *, SEL, ...)'}} \
// expected-note {{please include the header <objc/message.h> or explicitly provide a declaration for 'objc_msgSendSuper'}}
}
id f5(id val, id *dest) {
- return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring C library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
- // expected-note {{please include the header </objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
+ return objc_assign_strongCast(val, dest); // expected-warning {{implicitly declaring library function 'objc_assign_strongCast' with type 'id (id, id *)'}} \
+ // expected-note {{please include the header <objc/objc-auto.h> or explicitly provide a declaration for 'objc_assign_strongCast'}}
}
int f6(Class exceptionClass, id exception) {
- return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring C library function 'objc_exception_match' with type 'int (id, id)'}} \
- // expected-note {{please include the header </objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
+ return objc_exception_match(exceptionClass, exception); // expected-warning {{implicitly declaring library function 'objc_exception_match' with type 'int (id, id)'}} \
+ // expected-note {{please include the header <objc/objc-exception.h> or explicitly provide a declaration for 'objc_exception_match'}}
}
diff --git a/test/SemaObjC/builtin_objc_nslog.m b/test/SemaObjC/builtin_objc_nslog.m
new file mode 100644
index 0000000..c940b16
--- /dev/null
+++ b/test/SemaObjC/builtin_objc_nslog.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c %s -fsyntax-only -verify
+
+#include <stdarg.h>
+
+void f1(id arg) {
+ NSLog(@"%@", arg); // expected-warning {{implicitly declaring library function 'NSLog' with type 'void (id, ...)'}} \
+ // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLog'}}
+}
+
+void f2(id str, va_list args) {
+ NSLogv(@"%@", args); // expected-warning {{implicitly declaring library function 'NSLogv' with type }} \
+ // expected-note {{please include the header <Foundation/NSObjCRuntime.h> or explicitly provide a declaration for 'NSLogv'}}
+}
diff --git a/test/SemaObjC/call-super-2.m b/test/SemaObjC/call-super-2.m
index d77b759..3c45a2c 100644
--- a/test/SemaObjC/call-super-2.m
+++ b/test/SemaObjC/call-super-2.m
@@ -68,8 +68,8 @@ id objc_getClass(const char *s);
}
- (int) instance_func1
{
- int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id'))}}
- return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0')}}
+ int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id')}}
+ return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0'}}
}
- (int) instance_func2
{
diff --git a/test/SemaObjC/category-1.m b/test/SemaObjC/category-1.m
index 4cc5daf..f842278 100644
--- a/test/SemaObjC/category-1.m
+++ b/test/SemaObjC/category-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MyClass1 @end
@@ -31,9 +31,9 @@
@interface UnknownClass (Category) @end // expected-error {{cannot find interface declaration for 'UnknownClass'}}
-@class MyClass2;
+@class MyClass2; // expected-note{{forward declaration of class here}}
-@interface MyClass2 (Category) @end // expected-error {{cannot find interface declaration for 'MyClass2'}}
+@interface MyClass2 (Category) @end // expected-error {{cannot define category for undefined class 'MyClass2'}}
@interface XCRemoteComputerManager
@end
@@ -62,7 +62,7 @@
// <rdar://problem/7249233>
@protocol MultipleCat_P
--(void) im0; // expected-note {{method declared here}}
+-(void) im0; // expected-note {{method 'im0' declared here}}
@end
@interface MultipleCat_I @end // expected-note {{required for direct or indirect protocol 'MultipleCat_P'}}
@@ -72,7 +72,7 @@
@interface MultipleCat_I() <MultipleCat_P> @end
@implementation MultipleCat_I // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ // expected-warning {{method 'im0' in protocol not implemented}}
@end
// <rdar://problem/7680391> - Handle nameless categories with no name that refer
@@ -95,3 +95,7 @@
@synthesize name = _name;
@end
+// rdar://10968158
+@class I; // expected-note {{forward declaration}}
+@implementation I(cat) // expected-error{{cannot find interface declaration}}
+@end
diff --git a/test/SemaObjC/category-method-lookup.m b/test/SemaObjC/category-method-lookup.m
index 27a10e5..4223a74 100644
--- a/test/SemaObjC/category-method-lookup.m
+++ b/test/SemaObjC/category-method-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo
@end
diff --git a/test/SemaObjC/check-dup-decl-methods-1.m b/test/SemaObjC/check-dup-decl-methods-1.m
index 1dd6446..3895667 100644
--- a/test/SemaObjC/check-dup-decl-methods-1.m
+++ b/test/SemaObjC/check-dup-decl-methods-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify %s
@interface SUPER
- (int) meth;
@@ -10,8 +10,8 @@
@interface class1 : SUPER
- (int) meth; // expected-note {{previous declaration is here}}
- (int*) meth; // expected-error {{duplicate declaration of method 'meth'}}
-- (T*) meth1;
-- (T*) meth1;
+- (T*) meth1; // expected-note {{previous declaration is here}}
+- (T*) meth1; // expected-warning {{multiple declarations of method 'meth1' found and ignored}}
+ (T*) meth1;
@end
diff --git a/test/SemaObjC/check-dup-objc-decls-1.m b/test/SemaObjC/check-dup-objc-decls-1.m
index 8dde777..d6fa53a 100644
--- a/test/SemaObjC/check-dup-objc-decls-1.m
+++ b/test/SemaObjC/check-dup-objc-decls-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo // expected-note {{previous definition is here}}
@end
diff --git a/test/SemaObjC/class-conforming-protocol-1.m b/test/SemaObjC/class-conforming-protocol-1.m
index 43ea6d3..115ddd2 100644
--- a/test/SemaObjC/class-conforming-protocol-1.m
+++ b/test/SemaObjC/class-conforming-protocol-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wduplicate-method-match -fsyntax-only -verify %s
@protocol P1 @end
@protocol P2 @end
@@ -8,12 +8,11 @@
- (INTF*) METH1; // expected-note {{previous declaration is here}}
- (INTF<P1>*) METH1; // expected-error {{duplicate declaration of method 'METH1'}}
-- (INTF<P1,P2>*) METH2;
- (INTF<P2,P1>*) METH2; // expected-note {{previous declaration is here}}
- (INTF<P2,P1,P3>*) METH2; // expected-error {{duplicate declaration of method 'METH2'}}
-- (INTF<P2,P1,P3>*) METH3;
-- (INTF<P3,P1,P2, P3>*) METH3;
+- (INTF<P2,P1,P3>*) METH3; // expected-note {{previous declaration is here}}
+- (INTF<P3,P1,P2, P3>*) METH3; // expected-warning {{multiple declarations of method 'METH3' found and ignored}}
@end
diff --git a/test/SemaObjC/class-def-test-1.m b/test/SemaObjC/class-def-test-1.m
index 95a259b..0d114b9 100644
--- a/test/SemaObjC/class-def-test-1.m
+++ b/test/SemaObjC/class-def-test-1.m
@@ -30,4 +30,6 @@ typedef NSObject TD_NSObject;
@interface XCElementUnit : TD_NSObject {}
@end
-
+// Make sure we don't typo-correct to ourselves.
+@interface SomeClassSub : SomeClassSup // expected-error{{cannot find interface declaration for 'SomeClassSup', superclass of 'SomeClassSub'}}
+@end
diff --git a/test/SemaObjC/class-extension-after-implementation.m b/test/SemaObjC/class-extension-after-implementation.m
index 2d8a5b1..ccfd3ef 100644
--- a/test/SemaObjC/class-extension-after-implementation.m
+++ b/test/SemaObjC/class-extension-after-implementation.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://7822210
@interface A @end
diff --git a/test/SemaObjC/class-extension-dup-methods.m b/test/SemaObjC/class-extension-dup-methods.m
index 452d242..692ff8c 100644
--- a/test/SemaObjC/class-extension-dup-methods.m
+++ b/test/SemaObjC/class-extension-dup-methods.m
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
@interface Foo
-- (int) garf; // expected-note {{ previous declaration is here}}
+- (int) garf; // expected-note {{previous declaration is here}}
- (int) OK;
-+ (int) cgarf; // expected-note {{ previous declaration is here}}
++ (int) cgarf; // expected-note {{previous declaration is here}}
- (int) InstMeth;
@end
diff --git a/test/SemaObjC/class-getter-using-dotsyntax.m b/test/SemaObjC/class-getter-using-dotsyntax.m
index 6454bc0..4ff9428 100644
--- a/test/SemaObjC/class-getter-using-dotsyntax.m
+++ b/test/SemaObjC/class-getter-using-dotsyntax.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef struct objc_class *Class;
diff --git a/test/SemaObjC/class-impl-1.m b/test/SemaObjC/class-impl-1.m
index 90a4112..68becaf 100644
--- a/test/SemaObjC/class-impl-1.m
+++ b/test/SemaObjC/class-impl-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef int INTF3; // expected-note {{previous definition is here}}
@@ -31,7 +31,7 @@ typedef int INTF3; // expected-note {{previous definition is here}}
@implementation INTF4 @end // expected-warning {{cannot find interface declaration for 'INTF4'}}
-@class INTF5;
+@class INTF5; // expected-note{{forward declaration of class here}}
@implementation INTF5 { // expected-warning {{cannot find interface declaration for 'INTF5'}}
int x;
diff --git a/test/SemaObjC/class-message-protocol-lookup.m b/test/SemaObjC/class-message-protocol-lookup.m
index ae64ea8..37df7a6 100644
--- a/test/SemaObjC/class-message-protocol-lookup.m
+++ b/test/SemaObjC/class-message-protocol-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9224670
@interface RandomObject {
@@ -13,7 +13,7 @@
@protocol Test2Protocol
+ (id)alloc;
-- (id)alloc2; // expected-note 2 {{method declared here}}
+- (id)alloc2; // expected-note 2 {{method 'alloc2' declared here}}
@end
@implementation RandomObject
diff --git a/test/SemaObjC/class-method-self.m b/test/SemaObjC/class-method-self.m
index ba70644..b1e37bf 100644
--- a/test/SemaObjC/class-method-self.m
+++ b/test/SemaObjC/class-method-self.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
typedef struct objc_class *Class;
@interface XX
diff --git a/test/SemaObjC/class-proto-1.m b/test/SemaObjC/class-proto-1.m
index 8030976..02c40aa 100644
--- a/test/SemaObjC/class-proto-1.m
+++ b/test/SemaObjC/class-proto-1.m
@@ -23,7 +23,7 @@
@interface E2 <p1,p2,p3> @end // expected-warning {{cannot find protocol definition for 'p3'}}
-@class U1, U2; // expected-note {{forward class is declared here}}
+@class U1, U2; // expected-note {{forward declaration of class here}}
@interface E3 : U1 @end // expected-error {{attempting to use the forward class 'U1' as superclass of 'E3'}}
diff --git a/test/SemaObjC/class-protocol-method-match.m b/test/SemaObjC/class-protocol-method-match.m
index 04243e9..7c936e6 100644
--- a/test/SemaObjC/class-protocol-method-match.m
+++ b/test/SemaObjC/class-protocol-method-match.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9352731
@protocol Bar
diff --git a/test/SemaObjC/cocoa-api-usage.m b/test/SemaObjC/cocoa-api-usage.m
new file mode 100644
index 0000000..85e2115
--- /dev/null
+++ b/test/SemaObjC/cocoa-api-usage.m
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)array;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
++ (id)arrayWithObjects:(id)firstObj, ...;
++ (id)arrayWithArray:(NSArray *)array;
+
+- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
+- (id)initWithObjects:(id)firstObj, ...;
+- (id)initWithArray:(NSArray *)array;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@interface NSDictionary (NSDictionaryCreation)
++ (id)dictionary;
++ (id)dictionaryWithObject:(id)object forKey:(id)key;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ (id)dictionaryWithDictionary:(NSDictionary *)dict;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+- (id)initWithObjectsAndKeys:(id)firstObject, ...;
+- (id)initWithDictionary:(NSDictionary *)otherDictionary;
+- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+void foo() {
+ NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}}
+ str = [[NSString alloc] initWithString:@"foo"];
+ NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}}
+ NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}}
+}
diff --git a/test/SemaObjC/cocoa-api-usage.m.fixed b/test/SemaObjC/cocoa-api-usage.m.fixed
new file mode 100644
index 0000000..55e060a
--- /dev/null
+++ b/test/SemaObjC/cocoa-api-usage.m.fixed
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+// RUN: cp %s %t.m
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api
+// RUN: diff %s.fixed %t.m
+
+typedef signed char BOOL;
+#define nil ((void*) 0)
+
+@interface NSObject
++ (id)alloc;
+@end
+
+@interface NSString : NSObject
++ (id)stringWithString:(NSString *)string;
+- (id)initWithString:(NSString *)aString;
+@end
+
+@interface NSArray : NSObject
+- (id)objectAtIndex:(unsigned long)index;
+- (id)objectAtIndexedSubscript:(int)index;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)array;
++ (id)arrayWithObject:(id)anObject;
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
++ (id)arrayWithObjects:(id)firstObj, ...;
++ (id)arrayWithArray:(NSArray *)array;
+
+- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt;
+- (id)initWithObjects:(id)firstObj, ...;
+- (id)initWithArray:(NSArray *)array;
+
+- (id)objectAtIndex:(unsigned long)index;
+@end
+
+@interface NSMutableArray : NSArray
+- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+@interface NSDictionary : NSObject
+- (id)objectForKeyedSubscript:(id)key;
+@end
+
+@interface NSDictionary (NSDictionaryCreation)
++ (id)dictionary;
++ (id)dictionaryWithObject:(id)object forKey:(id)key;
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...;
++ (id)dictionaryWithDictionary:(NSDictionary *)dict;
++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+- (id)initWithObjectsAndKeys:(id)firstObject, ...;
+- (id)initWithDictionary:(NSDictionary *)otherDictionary;
+- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
+
+- (id)objectForKey:(id)aKey;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+- (void)setObject:(id)anObject forKey:(id)aKey;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSNumber : NSObject
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+#define M(x) (x)
+#define PAIR(x) @#x, [NSNumber numberWithInt:(x)]
+#define TWO(x) ((x), (x))
+
+void foo() {
+ NSString *str = M(@"foo"); // expected-warning {{redundant}}
+ str = [[NSString alloc] initWithString:@"foo"];
+ NSArray *arr = @[str]; // expected-warning {{redundant}}
+ NSDictionary *dict = @{str: arr}; // expected-warning {{redundant}}
+}
diff --git a/test/SemaObjC/compare-qualified-id.m b/test/SemaObjC/compare-qualified-id.m
index ce0db19..d31dfae 100644
--- a/test/SemaObjC/compare-qualified-id.m
+++ b/test/SemaObjC/compare-qualified-id.m
@@ -5,7 +5,7 @@ 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 // expected-note {{method declared here}}
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end // expected-note {{method 'copyWithZone:' declared here}}
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
@interface NSObject <NSObject> {} @end
@@ -24,7 +24,7 @@ extern NSString * const NSTaskDidTerminateNotification;
@end
@implementation XCPropertyExpansionContext // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ // expected-warning {{method 'copyWithZone:' in protocol not implemented}}
- (NSString *)expandedValueForProperty:(NSString *)property {
id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
if (cachedValueNode == ((void *)0)) { }
diff --git a/test/SemaObjC/compatible-protocol-qualified-types.m b/test/SemaObjC/compatible-protocol-qualified-types.m
index 0342622..c0b929d 100644
--- a/test/SemaObjC/compatible-protocol-qualified-types.m
+++ b/test/SemaObjC/compatible-protocol-qualified-types.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -pedantic -fsyntax-only -verify %s
+// RUN: %clang_cc1 -pedantic -fsyntax-only -verify -Wno-objc-root-class %s
typedef signed char BOOL;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
diff --git a/test/SemaObjC/comptypes-1.m b/test/SemaObjC/comptypes-1.m
index 98107ee..997ef19 100644
--- a/test/SemaObjC/comptypes-1.m
+++ b/test/SemaObjC/comptypes-1.m
@@ -42,7 +42,7 @@ int main()
MyProtocol), but not from an 'id' or from a 'MyOtherClass *'
(which implements MyProtocol). */
obj_p = obj; /* Ok */
- obj_p = obj_c; // expected-warning {{ assigning to 'id<MyProtocol>' from incompatible type 'MyClass *'}}
+ obj_p = obj_c; // expected-warning {{assigning to 'id<MyProtocol>' from incompatible type 'MyClass *'}}
obj_p = obj_cp; /* Ok */
obj_p = obj_C; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'Class'}}
diff --git a/test/SemaObjC/comptypes-10.m b/test/SemaObjC/comptypes-10.m
index 1a6533a..5f16a6e 100644
--- a/test/SemaObjC/comptypes-10.m
+++ b/test/SemaObjC/comptypes-10.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
//rdar: //8591619
// pr8453
diff --git a/test/SemaObjC/comptypes-7.m b/test/SemaObjC/comptypes-7.m
index ef0f158..dde504b 100644
--- a/test/SemaObjC/comptypes-7.m
+++ b/test/SemaObjC/comptypes-7.m
@@ -28,7 +28,7 @@ int main()
obj = j; // expected-warning {{incompatible pointer types assigning to 'id' from 'int *'}}
obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
- obj_p = j; // expected-warning {{ incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
+ obj_p = j; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
@@ -42,7 +42,7 @@ int main()
i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
j = obj; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id'}}
- j = obj_p; // expected-warning {{ incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
+ j = obj_p; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
j = obj_c; // expected-warning {{incompatible pointer types assigning to 'int *' from 'MyClass *'}}
j = obj_C; // expected-warning {{incompatible pointer types assigning to 'int *' from 'Class'}}
diff --git a/test/SemaObjC/comptypes-a.m b/test/SemaObjC/comptypes-a.m
index 8480f52..18d546b 100644
--- a/test/SemaObjC/comptypes-a.m
+++ b/test/SemaObjC/comptypes-a.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -Wmethod-signatures -verify -pedantic -Wno-objc-root-class %s
typedef signed char BOOL;
typedef int NSInteger;
diff --git a/test/SemaObjC/conditional-expr-3.m b/test/SemaObjC/conditional-expr-3.m
index 3b5f609..166e02b 100644
--- a/test/SemaObjC/conditional-expr-3.m
+++ b/test/SemaObjC/conditional-expr-3.m
@@ -31,7 +31,7 @@ void f2(id<P1> x) {
}
void f3(A *a) {
- id<P1> l = a; // expected-warning {{ initializing 'id<P1>' with an expression of incompatible type 'A *'}}
+ id<P1> l = a; // expected-warning {{initializing 'id<P1>' with an expression of incompatible type 'A *'}}
}
void f4(int cond, id x, A *a) {
diff --git a/test/SemaObjC/conditional-expr-5.m b/test/SemaObjC/conditional-expr-5.m
index 63afca1..47aed3e 100644
--- a/test/SemaObjC/conditional-expr-5.m
+++ b/test/SemaObjC/conditional-expr-5.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface PBXBuildSettingsDictionary
{
diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m
index 74ab59b..e0a3210 100644
--- a/test/SemaObjC/conditional-expr.m
+++ b/test/SemaObjC/conditional-expr.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s
@protocol NSObject
@end
@@ -21,7 +21,7 @@
@end
@interface DTFilterOutputStream2
-- nextOutputStream; // expected-note {{{{method definition for 'nextOutputStream' not found}}
+- nextOutputStream; // expected-note {{method definition for 'nextOutputStream' not found}}
@end
@implementation DTFilterOutputStream2 // expected-warning {{incomplete implementation}}
@@ -100,7 +100,7 @@ void f8(int a, A<P0> *x, A *y) {
}
void f9(int a, A<P0> *x, A<P1> *y) {
- id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')'}}
+ id l0 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
A<P0> *l1 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
A<P1> *l2 = (a ? x : y ); // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
[ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('A<P0> *' and 'A<P1> *')}}
diff --git a/test/SemaObjC/conflict-nonfragile-abi2.m b/test/SemaObjC/conflict-nonfragile-abi2.m
index 7c95d5d..8197327 100644
--- a/test/SemaObjC/conflict-nonfragile-abi2.m
+++ b/test/SemaObjC/conflict-nonfragile-abi2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
// rdar://8225011
int glob;
diff --git a/test/SemaObjC/conflicting-ivar-test-1.m b/test/SemaObjC/conflicting-ivar-test-1.m
index 01b3531..a7c1d35 100644
--- a/test/SemaObjC/conflicting-ivar-test-1.m
+++ b/test/SemaObjC/conflicting-ivar-test-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s
@interface INTF
{
diff --git a/test/SemaObjC/continuation-class-err.m b/test/SemaObjC/continuation-class-err.m
index 700cf61..d691f12 100644
--- a/test/SemaObjC/continuation-class-err.m
+++ b/test/SemaObjC/continuation-class-err.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface ReadOnly
{
@@ -40,3 +40,12 @@
@synthesize fee = _fee;
@end
+// rdar://10752081
+@interface MyOtherClass() // expected-error {{cannot find interface declaration for 'MyOtherClass'}}
+{
+ id array;
+}
+@end
+
+@implementation MyOtherClass // expected-warning {{cannot find interface declaration for 'MyOtherClass'}}
+@end
diff --git a/test/SemaObjC/continuation-class-property.m b/test/SemaObjC/continuation-class-property.m
index a579184..7d95424 100644
--- a/test/SemaObjC/continuation-class-property.m
+++ b/test/SemaObjC/continuation-class-property.m
@@ -38,6 +38,26 @@ typedef struct {
@end
@interface MyClass ()
-@property (readwrite) NSString *foo; // expected-warning {{type of property 'NSString *' in continuation class does not match property type in primary class}}
-@property (readwrite, strong) NSRect bar; // expected-warning {{type of property 'NSRect' in continuation class does not match property type in primary class}}
+@property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not match property type in primary class}}
+@property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not match property type in primary class}}
+@end
+
+// rdar://10655530
+struct S;
+struct S1;
+@interface STAdKitContext
+@property (nonatomic, readonly, assign) struct evhttp_request *httpRequest;
+@property (nonatomic, readonly, assign) struct S *httpRequest2;
+@property (nonatomic, readonly, assign) struct S1 *httpRequest3;
+@property (nonatomic, readonly, assign) struct S2 *httpRequest4;
+@end
+
+struct evhttp_request;
+struct S1;
+
+@interface STAdKitContext()
+@property (nonatomic, readwrite, assign) struct evhttp_request *httpRequest;
+@property (nonatomic, readwrite, assign) struct S *httpRequest2;
+@property (nonatomic, readwrite, assign) struct S1 *httpRequest3;
+@property (nonatomic, readwrite, assign) struct S2 *httpRequest4;
@end
diff --git a/test/SemaObjC/custom-atomic-property.m b/test/SemaObjC/custom-atomic-property.m
index f80119e..53eaeb0 100644
--- a/test/SemaObjC/custom-atomic-property.m
+++ b/test/SemaObjC/custom-atomic-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wcustom-atomic-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wcustom-atomic-properties -verify -Wno-objc-root-class %s
@interface Foo
@property (assign) Foo *myProp; // expected-note {{property declared here}} expected-note {{property declared here}}
diff --git a/test/SemaObjC/debugger-cast-result-to-id.m b/test/SemaObjC/debugger-cast-result-to-id.m
new file mode 100644
index 0000000..00a02be
--- /dev/null
+++ b/test/SemaObjC/debugger-cast-result-to-id.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -fdebugger-cast-result-to-id -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+void test_unknown_anytype_receiver() {
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+}
+
+// rdar://10988847
+@class NSString; // expected-note {{forward declaration of class here}}
+
+void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+}
diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m
index 1e763af..c201e74 100644
--- a/test/SemaObjC/default-synthesize-1.m
+++ b/test/SemaObjC/default-synthesize-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
@interface NSObject
- (void) release;
diff --git a/test/SemaObjC/default-synthesize-2.m b/test/SemaObjC/default-synthesize-2.m
index 1ea492e..b95f263 100644
--- a/test/SemaObjC/default-synthesize-2.m
+++ b/test/SemaObjC/default-synthesize-2.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
// rdar://8843851
@interface StopAccessingIvarsDirectlyExample
diff --git a/test/SemaObjC/default-synthesize-3.m b/test/SemaObjC/default-synthesize-3.m
new file mode 100644
index 0000000..606ece3
--- /dev/null
+++ b/test/SemaObjC/default-synthesize-3.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+
+#if __has_attribute(objc_requires_property_definitions)
+__attribute ((objc_requires_property_definitions))
+#endif
+@interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
+@property int NoAutoProp; // expected-note 2 {{property declared here}}
+@end
+
+@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
+ // expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
+@end
+
+__attribute ((objc_requires_property_definitions)) // redundant, just for testing
+@interface Sub : NoAuto // expected-note 3 {{class with specified objc_requires_property_definitions attribute is declared here}}
+@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
+@end
+
+@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
+ // expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
+@end
+
+@interface Deep : Sub
+@property (copy) id DeepProperty;
+@property (copy) id DeepSynthProperty;
+@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
+@end
+
+@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
+@dynamic DeepProperty;
+@synthesize DeepSynthProperty;
+- (id) DeepMustSynthProperty { return 0; }
+@end
+
+__attribute ((objc_requires_property_definitions))
+@interface Deep(CAT) // expected-error {{attributes may not be specified on a category}}
+@end
+
+__attribute ((objc_requires_property_definitions)) // expected-error {{objc_requires_property_definitions attribute may only be specified on a class}}
+@protocol P @end
diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m
index 0d2f473..e6ea0a5 100644
--- a/test/SemaObjC/default-synthesize.m
+++ b/test/SemaObjC/default-synthesize.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
@interface NSString @end
@@ -10,7 +10,9 @@
@end
@implementation SynthItAll
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
@end
@@ -20,7 +22,9 @@
@end
@implementation SynthSetter
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
- (int) howMany {
return self.howMany;
@@ -40,7 +44,9 @@
@end
@implementation SynthGetter
-//@synthesize howMany, what;
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what;
+#endif
// - (int) howMany
- (void) setHowMany: (int) value {
@@ -61,7 +67,9 @@
@end
@implementation SynthNone
-//@synthesize howMany, what; // REM: Redundant anyway
+#if !__has_feature(objc_default_synthesize_properties)
+@synthesize howMany, what; // REM: Redundant anyway
+#endif
- (int) howMany {
return self.howMany;
@@ -112,6 +120,21 @@
@implementation D
- (int) Meth { return self.PROP; }
+#if __has_feature(objc_default_synthesize_properties)
@synthesize PROP=IVAR;
+#endif
@end
+// rdar://10567333
+@protocol MyProtocol
+@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}
+
+@optional
+@property (nonatomic, strong) NSString *optionalString;
+@end
+
+@interface MyClass <MyProtocol>
+@end
+
+@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}}
+@end
diff --git a/test/SemaObjC/deref-interface.m b/test/SemaObjC/deref-interface.m
index 490e3a5..3201412 100644
--- a/test/SemaObjC/deref-interface.m
+++ b/test/SemaObjC/deref-interface.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
@interface NSView
- (id)initWithView:(id)realView;
@@ -6,7 +6,7 @@
@implementation NSView
- (id)initWithView:(id)realView {
- *(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object in non-fragile ABI}}
+ *(NSView *)self = *(NSView *)realView; // expected-error {{cannot assign to class object}}
}
@end
diff --git a/test/SemaObjC/direct-synthesized-ivar-access.m b/test/SemaObjC/direct-synthesized-ivar-access.m
index 7e57a29..54b7110 100644
--- a/test/SemaObjC/direct-synthesized-ivar-access.m
+++ b/test/SemaObjC/direct-synthesized-ivar-access.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
// rdar://8673791
// rdar://9943851
diff --git a/test/SemaObjC/dist-object-modifiers.m b/test/SemaObjC/dist-object-modifiers.m
index 98a9ce6..aa7e340 100644
--- a/test/SemaObjC/dist-object-modifiers.m
+++ b/test/SemaObjC/dist-object-modifiers.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://7076235
@protocol P
diff --git a/test/SemaObjC/enhanced-proto-2.m b/test/SemaObjC/enhanced-proto-2.m
index da7875cf..28b03d9 100644
--- a/test/SemaObjC/enhanced-proto-2.m
+++ b/test/SemaObjC/enhanced-proto-2.m
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
@protocol MyProto1
@optional
- (void) FOO;
@optional
-- (void) FOO;
+- (void) FOO1;
@optional
- (void) REQ;
@optional
diff --git a/test/SemaObjC/enum-fixed-type.m b/test/SemaObjC/enum-fixed-type.m
index 530ee0f..95153be 100644
--- a/test/SemaObjC/enum-fixed-type.m
+++ b/test/SemaObjC/enum-fixed-type.m
@@ -25,3 +25,13 @@ void test() {
long value = 2;
Enumeration e = value;
}
+
+// <rdar://10381507>
+typedef enum : long { Foo } IntegerEnum;
+int arr[(sizeof(typeof(Foo)) == sizeof(typeof(IntegerEnum))) - 1];
+int arr1[(sizeof(typeof(Foo)) == sizeof(typeof(long))) - 1];
+int arr2[(sizeof(typeof(IntegerEnum)) == sizeof(typeof(long))) - 1];
+
+// <rdar://problem/10760113>
+typedef enum : long long { Bar = -1 } LongLongEnum;
+int arr3[(long long)Bar == (long long)-1 ? 1 : -1];
diff --git a/test/SemaObjC/err-ivar-access-in-class-method.m b/test/SemaObjC/err-ivar-access-in-class-method.m
new file mode 100644
index 0000000..2a5e0dc
--- /dev/null
+++ b/test/SemaObjC/err-ivar-access-in-class-method.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10593227
+
+@class UIWindow;
+
+@interface CNAppDelegate
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
+
+
+@interface CNAppDelegate ()
+@property (nonatomic,retain) id foo;
+@end
+
+@implementation CNAppDelegate
+@synthesize foo;
+@synthesize window = _window;
+
++(void)myClassMethod;
+{
+ foo = 0; // expected-error {{instance variable 'foo' accessed in class method}}
+}
+@end
diff --git a/test/SemaObjC/error-property-gc-attr.m b/test/SemaObjC/error-property-gc-attr.m
index 25fee05..5680296 100644
--- a/test/SemaObjC/error-property-gc-attr.m
+++ b/test/SemaObjC/error-property-gc-attr.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -fsyntax-only -verify -Wno-objc-root-class %s
@interface INTF
{
diff --git a/test/SemaObjC/exprs.m b/test/SemaObjC/exprs.m
index 2b505e0..b198cba 100644
--- a/test/SemaObjC/exprs.m
+++ b/test/SemaObjC/exprs.m
@@ -33,7 +33,7 @@ void test3(Object *o) {
__sync_bool_compare_and_swap(&g, 0, o);
}
-@class Incomplete_ObjC_class;
+@class Incomplete_ObjC_class; // expected-note{{forward declaration of class here}}
struct Incomplete_struct; // expected-note {{forward declaration}}
void test_encode() {
diff --git a/test/SemaObjC/foreach.m b/test/SemaObjC/foreach.m
index c865374..d0e0f7b 100644
--- a/test/SemaObjC/foreach.m
+++ b/test/SemaObjC/foreach.m
@@ -46,3 +46,12 @@ int main ()
return 0;
}
+/* rdar://problem/11068137 */
+@interface Test2
+@property (assign) id prop;
+@end
+void test2(NSObject<NSFastEnumeration> *collection) {
+ Test2 *obj;
+ for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */
+ }
+}
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
index d89f50a..987889b 100644
--- a/test/SemaObjC/format-strings-objc.m
+++ b/test/SemaObjC/format-strings-objc.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -Wformat-nonliteral -fsyntax-only -fblocks -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
@@ -9,10 +9,13 @@
// portable to non-Mac platforms.
//===----------------------------------------------------------------------===//
+#include <stdarg.h>
+
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@class NSString, Protocol;
-extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void NSLog(NSString *format, ...);
+extern void NSLogv(NSString *format, va_list args);
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
@@ -47,8 +50,8 @@ extern void CFStringCreateWithFormat2(int *format, ...) __attribute__((format(CF
// <rdar://problem/7068334> - Catch use of long long with int arguments.
void rdar_7068334() {
long long test = 500;
- printf("%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}}
- NSLog(@"%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}}
+ printf("%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
+ NSLog(@"%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}}
}
// <rdar://problem/7697748>
@@ -63,3 +66,123 @@ void test_p_conversion_with_objc_pointer(id x, id<Foo> y) {
printf("%p", y); // no-warning
}
+// <rdar://problem/10696348>, PR 10274 - CFString and NSString formats are ignored
+extern void MyNSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(__CFString__, 1, 2)));
+
+void check_mylog() {
+ MyNSLog(@"%@"); // expected-warning {{more '%' conversions than data arguments}}
+ // FIXME: find a way to test CFString too, but I don't know how to create constant CFString.
+}
+
+// PR 10275 - format function attribute isn't checked in Objective-C methods
+@interface Foo
++ (id)fooWithFormat:(NSString *)fmt, ... __attribute__((format(__NSString__, 1, 2)));
++ (id)fooWithCStringFormat:(const char *)format, ... __attribute__((format(__printf__, 1, 2)));
+@end
+
+void check_method() {
+ [Foo fooWithFormat:@"%@"]; // expected-warning {{more '%' conversions than data arguments}}
+ [Foo fooWithCStringFormat:"%@"]; // expected-warning {{invalid conversion specifier '@'}}
+}
+
+// Warn about using BOOL with %@
+void rdar10743758(id x) {
+ NSLog(@"%@ %@", x, (BOOL) 1); // expected-warning {{format specifies type 'id' but the argument has type 'BOOL' (aka 'signed char')}}
+}
+
+NSString *test_literal_propagation(void) {
+ const char * const s1 = "constant string %s"; // expected-note {{format string is defined here}}
+ printf(s1); // expected-warning {{more '%' conversions than data arguments}}
+ const char * const s5 = "constant string %s"; // expected-note {{format string is defined here}}
+ const char * const s2 = s5;
+ printf(s2); // expected-warning {{more '%' conversions than data arguments}}
+
+ const char * const s3 = (const char *)0;
+ printf(s3); // no-warning (NULL is a valid format string)
+
+ NSString * const ns1 = @"constant string %s"; // expected-note {{format string is defined here}}
+ NSLog(ns1); // expected-warning {{more '%' conversions than data arguments}}
+ NSString * const ns5 = @"constant string %s"; // expected-note {{format string is defined here}}
+ NSString * const ns2 = ns5;
+ NSLog(ns2); // expected-warning {{more '%' conversions than data arguments}}
+ NSString * ns3 = ns1;
+ NSLog(ns3); // expected-warning {{format string is not a string literal}}}
+}
+
+// Do not emit warnings when using NSLocalizedString
+extern NSString *GetLocalizedString(NSString *str);
+#define NSLocalizedString(key) GetLocalizedString(key)
+
+void check_NSLocalizedString() {
+ [Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning
+}
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+// Test that %S, %C, %ls check for 16 bit types in ObjC strings, as described at
+// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265
+
+void test_percent_S() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%S", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%S", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_ls() {
+ const unsigned short data[] = { 'a', 'b', 0 };
+ const unsigned short* ptr = data;
+ NSLog(@"%ls", ptr); // no-warning
+
+ const wchar_t* wchar_ptr = L"ab";
+ NSLog(@"%ls", wchar_ptr); // expected-warning{{format specifies type 'const unsigned short *' but the argument has type 'const wchar_t *'}}
+}
+
+void test_percent_C() {
+ const unsigned short data = 'a';
+ NSLog(@"%C", data); // no-warning
+
+ const wchar_t wchar_data = L'a';
+ NSLog(@"%C", wchar_data); // expected-warning{{format specifies type 'unsigned short' but the argument has type 'wchar_t'}}
+}
+
+// Test that %@ works with toll-free bridging (<rdar://problem/10814120>).
+void test_toll_free_bridging(CFStringRef x) {
+ NSLog(@"%@", x); // no-warning
+}
+
+@interface Bar
++ (void)log:(NSString *)fmt, ...;
++ (void)log2:(NSString *)fmt, ... __attribute__((format(NSString, 1, 2)));
+@end
+
+@implementation Bar
+
++ (void)log:(NSString *)fmt, ... {
+ va_list ap;
+ va_start(ap,fmt);
+ NSLogv(fmt, ap); // expected-warning{{format string is not a string literal}}
+ va_end(ap);
+}
+
++ (void)log2:(NSString *)fmt, ... {
+ va_list ap;
+ va_start(ap,fmt);
+ NSLogv(fmt, ap); // no-warning
+ va_end(ap);
+}
+
+@end
+
+
+// Test that it is okay to use %p with the address of a block.
+void rdar11049844_aux();
+int rdar11049844() {
+ typedef void (^MyBlock)(void);
+ MyBlock x = ^void() { rdar11049844_aux(); };
+ printf("%p", x); // no-warning
+}
+
diff --git a/test/SemaObjC/forward-class-1.m b/test/SemaObjC/forward-class-1.m
index de94e88..85c6c87 100644
--- a/test/SemaObjC/forward-class-1.m
+++ b/test/SemaObjC/forward-class-1.m
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
-@class FOO, BAR; // expected-note {{forward class is declared here}}
-@class FOO, BAR;
+@class FOO, BAR; // expected-note {{forward declaration of class here}}
+@class FOO, BAR;
@interface INTF : FOO // expected-error {{attempting to use the forward class 'FOO' as superclass of 'INTF'}}
@end
@@ -31,14 +31,14 @@
@protocol XCElementP @end
-typedef NSObject <XCElementP> XCElement;
+typedef NSObject <XCElementP> XCElement; // expected-note {{previous definition is here}}
@interface XCElementMainImp {
XCElement * _editingElement;
}
@end
-@class XCElement;
+@class XCElement; // expected-warning {{redefinition of forward class 'XCElement' of a typedef name of an object type is ignored}}
@implementation XCElementMainImp
- (XCElement *)editingElement { return _editingElement; }
@@ -46,7 +46,7 @@ typedef NSObject <XCElementP> XCElement;
// rdar://9653341
-@class B; // expected-note {{forward class is declared here}}
+@class B; // expected-note {{forward declaration of class here}}
@interface A : B {} // expected-error {{attempting to use the forward class 'B' as superclass of 'A'}}
@end
diff --git a/test/SemaObjC/forward-class-receiver.m b/test/SemaObjC/forward-class-receiver.m
index 55b29c1..9bcb039 100644
--- a/test/SemaObjC/forward-class-receiver.m
+++ b/test/SemaObjC/forward-class-receiver.m
@@ -5,7 +5,7 @@
@end
Class isa;
-@class NotKnown;
+@class NotKnown; // expected-note{{forward declaration of class here}}
void foo(NotKnown *n) {
[isa new];
diff --git a/test/SemaObjC/forward-class-redeclare.m b/test/SemaObjC/forward-class-redeclare.m
new file mode 100644
index 0000000..80dc335
--- /dev/null
+++ b/test/SemaObjC/forward-class-redeclare.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10733000
+
+@interface NSObject @end
+
+@protocol PLAssetContainer
+@property (readonly, nonatomic, retain) id assets;
+@end
+
+
+typedef NSObject <PLAssetContainer> PLAlbum; // expected-note {{previous definition is here}}
+
+@class PLAlbum; // expected-warning {{redefinition of forward class 'PLAlbum' of a typedef name of an object type is ignore}}
+
+@interface PLPhotoBrowserController
+{
+ PLAlbum *_album;
+}
+@end
+
+@interface WPhotoViewController:PLPhotoBrowserController
+@end
+
+@implementation WPhotoViewController
+- (void)_prepareForContracting
+{
+ (void)_album.assets;
+}
+@end
diff --git a/test/SemaObjC/gcc-cast-ext.m b/test/SemaObjC/gcc-cast-ext.m
index 599e37d..30e0dce 100644
--- a/test/SemaObjC/gcc-cast-ext.m
+++ b/test/SemaObjC/gcc-cast-ext.m
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 %s -verify -fms-extensions
+// RUN: %clang_cc1 -verify -fms-extensions -Wno-objc-root-class %s
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
typedef struct _NSRange { } NSRange;
@class PBXFileReference;
@interface PBXDocBookmark
-+ alloc; // expected-note {{{{method definition for 'alloc' not found}}
-- autorelease; // expected-note {{{{method definition for 'autorelease' not found}}
++ alloc; // expected-note {{method definition for 'alloc' not found}}
+- autorelease; // expected-note {{method definition for 'autorelease' not found}}
@end
// GCC allows pointer expressions in integer constant expressions.
diff --git a/test/SemaObjC/ibaction.m b/test/SemaObjC/ibaction.m
index bcedf83..9c59d7a 100644
--- a/test/SemaObjC/ibaction.m
+++ b/test/SemaObjC/ibaction.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
@interface Foo
{
diff --git a/test/SemaObjC/iboutletcollection-attr.m b/test/SemaObjC/iboutletcollection-attr.m
index 6bfe313..22c21a7 100644
--- a/test/SemaObjC/iboutletcollection-attr.m
+++ b/test/SemaObjC/iboutletcollection-attr.m
@@ -2,6 +2,8 @@
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
// rdar://8308053
+@class NSObject;
+
@interface I {
__attribute__((iboutletcollection(I))) id ivar1;
__attribute__((iboutletcollection(id))) id ivar2;
@@ -19,13 +21,23 @@ typedef void *PV;
__attribute__((iboutletcollection(I, 1))) id ivar1; // expected-error {{attribute takes one argument}}
__attribute__((iboutletcollection(B))) id ivar2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
__attribute__((iboutletcollection(PV))) id ivar3; // expected-error {{invalid type 'PV' as argument of iboutletcollection attribute}}
- __attribute__((iboutletcollection(PV))) void *ivar4; // expected-error {{ivar with 'iboutletcollection' attribute must be an object type (invalid 'void *')}}
+ __attribute__((iboutletcollection(PV))) void *ivar4; // expected-warning {{ivar with 'iboutletcollection' attribute must be an object type (invalid 'void *')}}
__attribute__((iboutletcollection(int))) id ivar5; // expected-error {{type argument of iboutletcollection attribute cannot be a builtin type}}
- __attribute__((iboutlet)) int ivar6; // expected-error {{ivar with 'iboutlet' attribute must be an object type}}
+ __attribute__((iboutlet)) int ivar6; // expected-warning {{ivar with 'iboutlet' attribute must be an object type}}
}
@property (nonatomic, retain) __attribute__((iboutletcollection(I,2,3))) id prop1; // expected-error {{attribute takes one argument}}
@property (nonatomic, retain) __attribute__((iboutletcollection(B))) id prop2; // expected-error {{invalid type 'B' as argument of iboutletcollection attribute}}
-@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-error {{property with 'iboutletcollection' attribute must be an object type (invalid 'int')}}
+@property __attribute__((iboutletcollection(BAD))) int prop3; // expected-warning {{property with 'iboutletcollection' attribute must be an object type (invalid 'int')}}
@end
+// rdar://10296078
+@interface ParentRDar10296078 @end
+@class NSArray;
+@protocol RDar10296078_Protocol;
+@class RDar10296078_OtherClass;
+
+@interface RDar10296078 : ParentRDar10296078
+@property (nonatomic, strong)
+ __attribute__((iboutletcollection(RDar10296078_OtherClass<RDar10296078_Protocol>))) NSArray *stuff;
+@end
diff --git a/test/SemaObjC/id-isa-ref.m b/test/SemaObjC/id-isa-ref.m
index dfc0a5b..c2debb0 100644
--- a/test/SemaObjC/id-isa-ref.m
+++ b/test/SemaObjC/id-isa-ref.m
@@ -16,8 +16,9 @@ static void func() {
id x;
- [(*x).isa self];
- [x->isa self];
+ // rdar://8290002
+ [(*x).isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
+ [x->isa self]; // expected-warning {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
Whatever *y;
diff --git a/test/SemaObjC/idiomatic-parentheses.m b/test/SemaObjC/idiomatic-parentheses.m
index 39e97e2..417b948 100644
--- a/test/SemaObjC/idiomatic-parentheses.m
+++ b/test/SemaObjC/idiomatic-parentheses.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wparentheses -Wno-objc-root-class %s
// Don't warn about some common ObjC idioms unless we have -Widiomatic-parentheses on.
// <rdar://problem/7382435>
diff --git a/test/SemaObjC/ignore-qualifier-on-qualified-id.m b/test/SemaObjC/ignore-qualifier-on-qualified-id.m
new file mode 100644
index 0000000..36a2c1a
--- /dev/null
+++ b/test/SemaObjC/ignore-qualifier-on-qualified-id.m
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10667659
+
+@protocol NSCopying @end
+
+@interface NSString <NSCopying>
+@end
+
+void takeId(id test) {}
+
+void takeCopyableId(id<NSCopying> test) {}
+
+id<NSCopying> Test () {
+ NSString const *constantString = @"Test";
+ takeId(constantString);
+ takeCopyableId(constantString);
+ id ID = constantString;
+ id<NSCopying> IDQNSCopying = constantString;
+ return constantString;
+}
diff --git a/test/SemaObjC/illegal-nonarc-bridged-cast.m b/test/SemaObjC/illegal-nonarc-bridged-cast.m
new file mode 100644
index 0000000..a5bb01f
--- /dev/null
+++ b/test/SemaObjC/illegal-nonarc-bridged-cast.m
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks -verify %s
+// rdar://10597832
+
+typedef const void *CFTypeRef;
+typedef const struct __CFString *CFStringRef;
+
+@interface NSString
+@end
+
+CFTypeRef CFCreateSomething();
+CFStringRef CFCreateString();
+CFTypeRef CFGetSomething();
+CFStringRef CFGetString();
+
+id CreateSomething();
+NSString *CreateNSString();
+
+void from_cf() {
+ id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ (__bridge int*)CFCreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}} \
+ // expected-warning {{expression result unused}}
+ id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+}
+
+void to_cf(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+}
+
+void fixits() {
+ id obj1 = (id)CFCreateSomething();
+ CFTypeRef cf1 = (CFTypeRef)CreateSomething();
+}
+
+#pragma clang diagnostic ignored "-Warc-bridge-casts-disallowed-in-nonarc"
+
+void to_cf_ignored(id obj) {
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // no-warning
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning
+}
diff --git a/test/SemaObjC/incomplete-implementation.m b/test/SemaObjC/incomplete-implementation.m
index f5c5a7c..54f66ef 100644
--- a/test/SemaObjC/incomplete-implementation.m
+++ b/test/SemaObjC/incomplete-implementation.m
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface I
- Meth; // expected-note{{method definition for 'Meth' not found}} \
- // expected-note{{method declared here}}
+ // expected-note{{method 'Meth' declared here}}
@end
@implementation I // expected-warning{{incomplete implementation}}
@@ -14,7 +14,7 @@
#pragma GCC diagnostic ignored "-Wincomplete-implementation"
@interface I2
-- Meth; // expected-note{{method declared here}}
+- Meth; // expected-note{{method 'Meth' declared here}}
@end
@implementation I2
@@ -24,4 +24,17 @@
- Meth {return 0;} // expected-warning {{category is implementing a method which will also be implemented by its primary class}}
@end
+@interface Q
+@end
+
+// rdar://10336158
+@implementation Q
+
+__attribute__((visibility("default")))
+@interface QN // expected-error {{Objective-C declarations may only appear in global scope}}
+{
+}
+@end
+
+@end
diff --git a/test/SemaObjC/instancetype.m b/test/SemaObjC/instancetype.m
index 13d6e03..40f35d9 100644
--- a/test/SemaObjC/instancetype.m
+++ b/test/SemaObjC/instancetype.m
@@ -143,7 +143,7 @@ void test_instancetype_narrow_method_search() {
@implementation Subclass4
+ (id)alloc {
- return self; // expected-warning{{incompatible pointer types returning 'Class' from a function with result type 'Subclass4 *'}}
+ return self; // expected-warning{{incompatible pointer types casting 'Class' to type 'Subclass4 *'}}
}
- (Subclass3 *)init { return 0; } // don't complain: we lost the related return type
@@ -166,12 +166,12 @@ void test_instancetype_inherited() {
@implementation Subclass2
- (instancetype)initSubclass2 {
Subclass1 *sc1 = [[Subclass1 alloc] init];
- return sc1; // expected-warning{{incompatible pointer types returning 'Subclass1 *' from a function with result type 'Subclass2 *'}}
+ return sc1; // expected-warning{{incompatible pointer types casting 'Subclass1 *' to type 'Subclass2 *'}}
}
- (void)methodOnSubclass2 {}
- (id)self {
Subclass1 *sc1 = [[Subclass1 alloc] init];
- return sc1; // expected-warning{{incompatible pointer types returning 'Subclass1 *' from a function with result type 'Subclass2 *'}}
+ return sc1; // expected-warning{{incompatible pointer types casting 'Subclass1 *' to type 'Subclass2 *'}}
}
@end
diff --git a/test/SemaObjC/interface-scope-2.m b/test/SemaObjC/interface-scope-2.m
index d8046c9..60fd900 100644
--- a/test/SemaObjC/interface-scope-2.m
+++ b/test/SemaObjC/interface-scope-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9 -Wno-objc-root-class %s
// FIXME: must also compile as Objective-C++
// <rdar://problem/6487662>
diff --git a/test/SemaObjC/invalid-code.m b/test/SemaObjC/invalid-code.m
index 9b7f2c8..290f9d5 100644
--- a/test/SemaObjC/invalid-code.m
+++ b/test/SemaObjC/invalid-code.m
@@ -1,8 +1,9 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fobjc-exceptions
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
// rdar://6124613
void test1() {
- void *p = @1; // expected-error {{unexpected '@' in program}}
+ void *xyzzy = 0;
+ void *p = @xyzzy; // expected-error {{unexpected '@' in program}}
}
// <rdar://problem/7495713>
@@ -19,3 +20,35 @@ void foo() {
@throw (id)0 // expected-error{{expected ';' after @throw}}
}
+// <rdar://problem/10415026>
+@class NSView;
+@implementation IBFillView(IBFillViewIntegration) // expected-error {{cannot find interface declaration for 'IBFillView'}}
+- (NSView *)ibDesignableContentView {
+ [Cake lie]; // expected-error {{undeclared}}
+ return self;
+}
+@end
+
+@interface I
+@end
+@interface I2
+@end
+
+@implementation I // expected-note {{started here}}
+-(void) foo {}
+
+@implementation I2 // expected-error {{missing '@end'}}
+-(void) foo2 {}
+@end
+
+@end // expected-error {{'@end' must appear in an Objective-C context}}
+
+@class ForwardBase;
+@implementation SomeI : ForwardBase // expected-error {{cannot find interface declaration for 'ForwardBase', superclass of 'SomeI'}} \
+ // expected-warning {{cannot find interface declaration for 'SomeI'}}
+-(void)meth {}
+@end
+
+@interface I3
+__attribute__((unavailable)) @interface I4 @end // expected-error {{Objective-C declarations may only appear in global scope}}
+@end
diff --git a/test/SemaObjC/invalid-objc-decls-1.m b/test/SemaObjC/invalid-objc-decls-1.m
index 91bd8a8..46338bb 100644
--- a/test/SemaObjC/invalid-objc-decls-1.m
+++ b/test/SemaObjC/invalid-objc-decls-1.m
@@ -27,8 +27,8 @@ struct whatever {
}
@end
-Super foo( // expected-error{{interface interface type 'Super' cannot be returned by value; did you forget * in 'Super'}}
- Super parm1) { // expected-error{{interface interface type 'Super' cannot be passed by value; did you forget * in 'Super'}}
+Super foo( // expected-error{{interface type 'Super' cannot be returned by value; did you forget * in 'Super'}}
+ Super parm1) { // expected-error{{interface type 'Super' cannot be passed by value; did you forget * in 'Super'}}
Super p1; // expected-error{{interface type cannot be statically allocated}}
return p1;
}
diff --git a/test/SemaObjC/ivar-access-tests.m b/test/SemaObjC/ivar-access-tests.m
index 8561220..cd7e09d 100644
--- a/test/SemaObjC/ivar-access-tests.m
+++ b/test/SemaObjC/ivar-access-tests.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MySuperClass
{
diff --git a/test/SemaObjC/ivar-in-class-extension.m b/test/SemaObjC/ivar-in-class-extension.m
index c9f138f..cf02d26 100644
--- a/test/SemaObjC/ivar-in-class-extension.m
+++ b/test/SemaObjC/ivar-in-class-extension.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface SomeClass @end
diff --git a/test/SemaObjC/ivar-in-implementations.m b/test/SemaObjC/ivar-in-implementations.m
index c4cfc10..7281f55 100644
--- a/test/SemaObjC/ivar-in-implementations.m
+++ b/test/SemaObjC/ivar-in-implementations.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Super @end
diff --git a/test/SemaObjC/ivar-lookup-resolution-builtin.m b/test/SemaObjC/ivar-lookup-resolution-builtin.m
index 2e90e8e..dd11b51 100644
--- a/test/SemaObjC/ivar-lookup-resolution-builtin.m
+++ b/test/SemaObjC/ivar-lookup-resolution-builtin.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// pr5986
@interface Test {
@@ -28,7 +28,7 @@
@implementation Test1
- (int) InstMethod
{
- return index; // expected-warning {{implicitly declaring C library function 'index'}} \
+ return index; // expected-warning {{implicitly declaring library function 'index'}} \
// expected-note {{please include the header <strings.h> or explicitly provide a declaration for 'index'}} \
// expected-warning {{incompatible pointer to integer conversion returning}}
}
diff --git a/test/SemaObjC/ivar-lookup.m b/test/SemaObjC/ivar-lookup.m
index 2b14bff..df9d8ba 100644
--- a/test/SemaObjC/ivar-lookup.m
+++ b/test/SemaObjC/ivar-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Test {
int x;
@@ -29,7 +29,7 @@ extern struct foo x;
@implementation A
- (int*)method {
- int *ip = [Ivar method]; // expected-warning{{warning: incompatible pointer types initializing 'int *' with an expression of type 'float *'}}
+ int *ip = [Ivar method]; // expected-warning{{incompatible pointer types initializing 'int *' with an expression of type 'float *'}}
// Note that there is no warning in Objective-C++
return 0;
}
@@ -47,3 +47,36 @@ extern struct foo x;
// expected-error{{instance variable 'b' accessed in class method}}
}
@end
+
+// rdar://10309454
+@interface Radar10309454
+{
+ int IVAR; // expected-note 4 {{previous definition is here}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+ int PIVAR; // expected-note {{previous definition is here}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+}
+@end
+
+@interface Radar10309454()
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+ int PIVAR; // expected-error {{instance variable is already declared}}
+}
+@end
+
+@implementation Radar10309454
+{
+ int IVAR; // expected-error {{instance variable is already declared}}
+}
+@end
diff --git a/test/SemaObjC/ivar-ref-misuse.m b/test/SemaObjC/ivar-ref-misuse.m
index f6d9c94..3115f5b 100644
--- a/test/SemaObjC/ivar-ref-misuse.m
+++ b/test/SemaObjC/ivar-ref-misuse.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Sprite { // expected-note{{'Sprite' declared here}}
int sprite, spree;
diff --git a/test/SemaObjC/legacy-implementation-1.m b/test/SemaObjC/legacy-implementation-1.m
index e9abb87..2e4c5ae 100644
--- a/test/SemaObjC/legacy-implementation-1.m
+++ b/test/SemaObjC/legacy-implementation-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@implementation INTF // expected-warning {{cannot find interface declaration for 'INTF'}}
@end
diff --git a/test/SemaObjC/message.m b/test/SemaObjC/message.m
index fed3961..621a18f 100644
--- a/test/SemaObjC/message.m
+++ b/test/SemaObjC/message.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef struct objc_object {
Class isa;
diff --git a/test/SemaObjC/method-attributes.m b/test/SemaObjC/method-attributes.m
index 9157fcf..f7252af 100644
--- a/test/SemaObjC/method-attributes.m
+++ b/test/SemaObjC/method-attributes.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
@class NSString;
@@ -13,20 +13,45 @@
@interface INTF
- (int) foo1: (int)arg1 __attribute__((deprecated));
-- (int) foo: (int)arg1;
+- (int) foo: (int)arg1; // expected-note {{method 'foo:' declared here}}
-- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable));
+- (int) foo2: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{method 'foo2:' declared here}}
+- (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self));
@end
@implementation INTF
-- (int) foo: (int)arg1 __attribute__((deprecated)){ // expected-warning {{method attribute can only be specified}}
+- (int) foo: (int)arg1 __attribute__((deprecated)){ // expected-warning {{attributes on method implementation and its declaration must match}}
return 10;
}
- (int) foo1: (int)arg1 {
return 10;
}
-- (int) foo2: (int)arg1 __attribute__((deprecated)) { // expected-warning {{method attribute can only be specified}}
+- (int) foo2: (int)arg1 __attribute__((deprecated)) { // expected-warning {{attributes on method implementation and its declaration must match}}
return 10;
}
+- (int) foo3: (int)arg1 __attribute__((deprecated)) __attribute__((unavailable)) __attribute__((ns_consumes_self)) {return 0; }
+- (void) dep __attribute__((deprecated)) { } // OK private methodn
@end
+
+// rdar://10529259
+#define IBAction void)__attribute__((ibaction)
+
+@interface Foo
+- (void)doSomething1:(id)sender;
+- (void)doSomething2:(id)sender; // expected-note {{method 'doSomething2:' declared here}}
+@end
+
+@implementation Foo
+- (void)doSomething1:(id)sender{}
+- (void)doSomething2:(id)sender{}
+@end
+
+@interface Bar : Foo
+- (IBAction)doSomething1:(id)sender;
+@end
+@implementation Bar
+- (IBAction)doSomething1:(id)sender {}
+- (IBAction)doSomething2:(id)sender {} // expected-warning {{attributes on method implementation and its declaration must match}}
+- (IBAction)doSomething3:(id)sender {}
+@end
diff --git a/test/SemaObjC/method-bad-param.m b/test/SemaObjC/method-bad-param.m
index 0a1b1cd..9505cb4 100644
--- a/test/SemaObjC/method-bad-param.m
+++ b/test/SemaObjC/method-bad-param.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface foo
@end
@@ -7,21 +7,21 @@
@end
@interface bar
--(void) my_method:(foo) my_param; // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
-- (foo)cccccc:(long)ddddd; // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+-(void) my_method:(foo) my_param; // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+- (foo)cccccc:(long)ddddd; // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
@end
@implementation bar
--(void) my_method:(foo) my_param // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+-(void) my_method:(foo) my_param // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
{
}
-- (foo)cccccc:(long)ddddd // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+- (foo)cccccc:(long)ddddd // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
{
}
@end
-void somefunc(foo x) {} // expected-error {{Objective-C interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
-foo somefunc2() {} // expected-error {{Objective-C interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
+void somefunc(foo x) {} // expected-error {{interface type 'foo' cannot be passed by value; did you forget * in 'foo'}}
+foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned by value; did you forget * in 'foo'}}
// rdar://6780761
void f0(foo *a0) {
diff --git a/test/SemaObjC/method-conflict-1.m b/test/SemaObjC/method-conflict-1.m
index 3cf2c6b..ca91ebd 100644
--- a/test/SemaObjC/method-conflict-1.m
+++ b/test/SemaObjC/method-conflict-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// This test case tests the default behavior.
diff --git a/test/SemaObjC/method-conflict-2.m b/test/SemaObjC/method-conflict-2.m
index 7b5a08a..df59f24 100644
--- a/test/SemaObjC/method-conflict-2.m
+++ b/test/SemaObjC/method-conflict-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
@interface A @end
@interface B : A @end
diff --git a/test/SemaObjC/method-conflict.m b/test/SemaObjC/method-conflict.m
index 4eb7290..2da629e 100644
--- a/test/SemaObjC/method-conflict.m
+++ b/test/SemaObjC/method-conflict.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef unsigned int NSUInteger;
diff --git a/test/SemaObjC/method-def-1.m b/test/SemaObjC/method-def-1.m
index bc7ea7b..7b292fb 100644
--- a/test/SemaObjC/method-def-1.m
+++ b/test/SemaObjC/method-def-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
@interface foo
- (int)meth;
diff --git a/test/SemaObjC/method-lookup.m b/test/SemaObjC/method-lookup.m
index 3091124..13e2d7f 100644
--- a/test/SemaObjC/method-lookup.m
+++ b/test/SemaObjC/method-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef int NSInteger;
diff --git a/test/SemaObjC/method-not-defined.m b/test/SemaObjC/method-not-defined.m
index ed68b22..22466f7 100644
--- a/test/SemaObjC/method-not-defined.m
+++ b/test/SemaObjC/method-not-defined.m
@@ -9,5 +9,5 @@ void test() {
[[Foo alloc] init]; // expected-warning {{class method '+alloc' not found (return type defaults to 'id')}} expected-warning {{instance method '-init' not found (return type defaults to 'id')}}
[fooObj notdefined]; // expected-warning {{instance method '-notdefined' not found (return type defaults to 'id')}}
- [obj whatever:1 :2 :3]; // expected-warning {{instance method '-whatever:::' not found (return type defaults to 'id'))}}
+ [obj whatever:1 :2 :3]; // expected-warning {{instance method '-whatever:::' not found (return type defaults to 'id')}}
}
diff --git a/test/SemaObjC/method-prototype-scope.m b/test/SemaObjC/method-prototype-scope.m
index b08faa6..0bebd9b 100644
--- a/test/SemaObjC/method-prototype-scope.m
+++ b/test/SemaObjC/method-prototype-scope.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wduplicate-method-arg -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wduplicate-method-arg -verify -Wno-objc-root-class %s
// rdar://8877730
diff --git a/test/SemaObjC/method-typecheck-1.m b/test/SemaObjC/method-typecheck-1.m
index 6c382d8..ee068d0 100644
--- a/test/SemaObjC/method-typecheck-1.m
+++ b/test/SemaObjC/method-typecheck-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface A
- (void) setMoo: (int) x; // expected-note {{previous definition is here}}
diff --git a/test/SemaObjC/method-undef-category-warn-1.m b/test/SemaObjC/method-undef-category-warn-1.m
index 532ecfc..2548cbd 100644
--- a/test/SemaObjC/method-undef-category-warn-1.m
+++ b/test/SemaObjC/method-undef-category-warn-1.m
@@ -4,8 +4,8 @@
@end
@protocol P
-- (void) Pmeth; // expected-note {{method declared here }}
-- (void) Pmeth1; // expected-note {{method declared here }}
+- (void) Pmeth; // expected-note {{method 'Pmeth' declared here}}
+- (void) Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
@end
@interface MyClass1(CAT) <P> // expected-note {{required for direct or indirect protocol 'P'}}
@@ -13,7 +13,7 @@
@end
@implementation MyClass1(CAT) // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ // expected-warning {{method 'Pmeth' in protocol not implemented}}
- (void) Pmeth1{}
@end
@@ -22,9 +22,53 @@
@end
@implementation MyClass1(DOG) // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ // expected-warning {{method 'Pmeth1' in protocol not implemented}}
- (void) Pmeth {}
@end
@implementation MyClass1(CAT1)
@end
+
+// rdar://10823023
+@class NSString;
+
+@protocol NSObject
+- (NSString *)meth_inprotocol;
+@end
+
+@interface NSObject <NSObject>
+- (NSString *)description;
++ (NSString *) cls_description;
+@end
+
+@protocol Foo
+- (NSString *)description;
++ (NSString *) cls_description;
+@end
+
+@interface NSObject (FooConformance) <Foo>
+@end
+
+@implementation NSObject (FooConformance)
+@end
+
+// rdar://11186449
+// Don't warn when a category does not implemented a method imported
+// by its protocol because another category has its declaration and
+// that category will implement it.
+@interface NSOrderedSet @end
+
+@interface NSOrderedSet(CoolectionImplements)
+- (unsigned char)containsObject:(id)object;
+@end
+
+@protocol Collection
+- (unsigned char)containsObject:(id)object;
+@end
+
+@interface NSOrderedSet (CollectionConformance) <Collection>
+@end
+
+@implementation NSOrderedSet (CollectionConformance)
+@end
+
diff --git a/test/SemaObjC/method-undef-extension-warn-1.m b/test/SemaObjC/method-undef-extension-warn-1.m
index ade861e..c092f24 100644
--- a/test/SemaObjC/method-undef-extension-warn-1.m
+++ b/test/SemaObjC/method-undef-extension-warn-1.m
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface MyClass // expected-note {{required for direct or indirect protocol 'P'}}
@end
@protocol P
- (void)Pmeth;
-- (void)Pmeth1; // expected-note {{method declared here}}
+- (void)Pmeth1; // expected-note {{method 'Pmeth1' declared here}}
@end
// Class extension
@@ -19,6 +19,6 @@
@end
@implementation MyClass // expected-warning {{incomplete implementation}} \
- // expected-warning {{method in protocol not implemented [-Wprotocol]}}
+ // expected-warning {{method 'Pmeth1' in protocol not implemented}}
- (void)Pmeth {}
@end
diff --git a/test/SemaObjC/method-undefined-warn-1.m b/test/SemaObjC/method-undefined-warn-1.m
index 922a034..27d645e 100644
--- a/test/SemaObjC/method-undefined-warn-1.m
+++ b/test/SemaObjC/method-undefined-warn-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface INTF
- (void) meth;
diff --git a/test/SemaObjC/method-unused-attribute.m b/test/SemaObjC/method-unused-attribute.m
index a4e5321..d604c39 100644
--- a/test/SemaObjC/method-unused-attribute.m
+++ b/test/SemaObjC/method-unused-attribute.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify -Wno-objc-root-class %s
@interface INTF
- (void) correct_use_of_unused: (void *) notice : (id)another_arg;
diff --git a/test/SemaObjC/missing-atend-metadata.m b/test/SemaObjC/missing-atend-metadata.m
index 9b79c52..f072981 100644
--- a/test/SemaObjC/missing-atend-metadata.m
+++ b/test/SemaObjC/missing-atend-metadata.m
@@ -1,22 +1,22 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
@interface I0
@end
-@implementation I0 // expected-error {{'@end' is missing in implementation context}}
+@implementation I0 // expected-note {{implementation started here}}
- meth { return 0; }
-@interface I1 : I0
+@interface I1 : I0 // expected-error {{missing '@end'}}
@end
-@implementation I1 // expected-error {{'@end' is missing in implementation context}}
--(void) im0 { self = [super init]; }
+@implementation I1 // expected-note {{implementation started here}}
+-(void) im0 { self = [super init]; } // expected-warning {{not found}}
-@interface I2 : I0
+@interface I2 : I0 // expected-error {{missing '@end'}}
- I2meth;
@end
-@implementation I2 // expected-error {{'@end' is missing in implementation context}}
+@implementation I2 // expected-note {{implementation started here}}
- I2meth { return 0; }
-@implementation I2(CAT) // expected-error {{'@end' is missing in implementation context}}
+@implementation I2(CAT) // expected-error 2 {{missing '@end'}} expected-note {{implementation started here}}
diff --git a/test/SemaObjC/missing-method-return-type.m b/test/SemaObjC/missing-method-return-type.m
index b62a046..fc6ff7b 100644
--- a/test/SemaObjC/missing-method-return-type.m
+++ b/test/SemaObjC/missing-method-return-type.m
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -Wmissing-method-return-type -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wmissing-method-return-type -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9615045
@interface I
-- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+- initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id'}}
@end
@implementation I
-- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id'}}
@end
diff --git a/test/SemaObjC/narrow-property-type-in-cont-class.m b/test/SemaObjC/narrow-property-type-in-cont-class.m
new file mode 100644
index 0000000..3ba848f
--- /dev/null
+++ b/test/SemaObjC/narrow-property-type-in-cont-class.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// rdar://10790488
+
+@interface NSArray @end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface GKTurnBasedMatchMakerKVO
+@property(nonatomic,readonly,retain) NSArray* outline;
+@property(nonatomic,readonly,retain) NSMutableArray* err_outline; // expected-note {{property declared here}}
+@end
+
+@interface GKTurnBasedMatchMakerKVO ()
+@property(nonatomic,readwrite,retain) NSMutableArray* outline;
+@property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}}
+@end
+
diff --git a/test/SemaObjC/nested-typedef-decl.m b/test/SemaObjC/nested-typedef-decl.m
index 70ca3a1..bb01ead 100644
--- a/test/SemaObjC/nested-typedef-decl.m
+++ b/test/SemaObjC/nested-typedef-decl.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://10041908
@interface Bar {
diff --git a/test/SemaObjC/newproperty-class-method-1.m b/test/SemaObjC/newproperty-class-method-1.m
index d4ea5e5..0f32998 100644
--- a/test/SemaObjC/newproperty-class-method-1.m
+++ b/test/SemaObjC/newproperty-class-method-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
void abort(void);
diff --git a/test/SemaObjC/no-gc-weak-test.m b/test/SemaObjC/no-gc-weak-test.m
index ca8318d..dd9b73c 100644
--- a/test/SemaObjC/no-gc-weak-test.m
+++ b/test/SemaObjC/no-gc-weak-test.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Subtask
{
diff --git a/test/SemaObjC/no-ivar-access-control.m b/test/SemaObjC/no-ivar-access-control.m
new file mode 100644
index 0000000..6f00b1a
--- /dev/null
+++ b/test/SemaObjC/no-ivar-access-control.m
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -fdebugger-support -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fdebugger-support -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10997647
+
+@interface I
+{
+@private
+int ivar;
+}
+@end
+
+@implementation I
+- (int) meth {
+ return self->ivar;
+}
+int foo1(I* p) {
+ return p->ivar;
+}
+@end
+
+int foo(I* p) {
+ return p->ivar;
+}
+
+@interface B
+@end
+
+@implementation B
+- (int) meth : (I*) arg {
+ return arg->ivar;
+}
+@end
+
+
+@interface I1 {
+ int protected_ivar;
+}
+@property int PROP_INMAIN;
+@end
+
+@interface I1() {
+ int private_ivar;
+}
+@property int PROP_INCLASSEXT;
+@end
+
+@implementation I1
+@synthesize PROP_INMAIN, PROP_INCLASSEXT;
+
+- (int) Meth {
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ protected_ivar = 1; // OK
+ return private_ivar; // OK
+}
+@end
+
+
+@interface DER : I1
+@end
+
+@implementation DER
+- (int) Meth {
+ protected_ivar = 1; // OK
+ PROP_INMAIN = 1;
+ PROP_INCLASSEXT = 2;
+ return private_ivar;
+}
+@end
+
diff --git a/test/SemaObjC/no-protocol-option-tests.m b/test/SemaObjC/no-protocol-option-tests.m
index 5d2da0a..dbd2a14 100644
--- a/test/SemaObjC/no-protocol-option-tests.m
+++ b/test/SemaObjC/no-protocol-option-tests.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wno-protocol -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-protocol -verify -Wno-objc-root-class %s
// rdar: // 7056600
@protocol P
@@ -17,7 +17,7 @@
// Test2
@interface super - PMeth; @end
@interface J : super <P>
-- PMeth; // expected-note {{ method definition for 'PMeth' not found}}
+- PMeth; // expected-note {{method definition for 'PMeth' not found}}
@end
@implementation J @end // expected-warning {{incomplete implementation}}
diff --git a/test/SemaObjC/no-warn-qual-mismatch.m b/test/SemaObjC/no-warn-qual-mismatch.m
index 1b5f184..1e3c186 100644
--- a/test/SemaObjC/no-warn-qual-mismatch.m
+++ b/test/SemaObjC/no-warn-qual-mismatch.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// radar 7211563
@interface X
diff --git a/test/SemaObjC/no-warn-synth-protocol-meth.m b/test/SemaObjC/no-warn-synth-protocol-meth.m
index fed6b27..103f6bb 100644
--- a/test/SemaObjC/no-warn-synth-protocol-meth.m
+++ b/test/SemaObjC/no-warn-synth-protocol-meth.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@protocol CYCdef
- (int)name;
diff --git a/test/SemaObjC/no-warning-unavail-unimp.m b/test/SemaObjC/no-warning-unavail-unimp.m
index 9409322..88d519d 100644
--- a/test/SemaObjC/no-warning-unavail-unimp.m
+++ b/test/SemaObjC/no-warning-unavail-unimp.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9651605
@interface Foo
diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m
index 76c6ffa..a38c0ac 100644
--- a/test/SemaObjC/nonnull.m
+++ b/test/SemaObjC/nonnull.m
@@ -1,6 +1,6 @@
#include "nonnull.h"
-// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
@class NSObject;
diff --git a/test/SemaObjC/nsobject-attribute-1.m b/test/SemaObjC/nsobject-attribute-1.m
index 991246c..72d8fa6 100644
--- a/test/SemaObjC/nsobject-attribute-1.m
+++ b/test/SemaObjC/nsobject-attribute-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wno-objc-root-class %s
@interface NSObject
- (id)self;
diff --git a/test/SemaObjC/nsobject-attribute.m b/test/SemaObjC/nsobject-attribute.m
index 13a4929..f41df89 100644
--- a/test/SemaObjC/nsobject-attribute.m
+++ b/test/SemaObjC/nsobject-attribute.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef struct CGColor * __attribute__ ((NSObject)) CGColorRef;
static int count;
@@ -15,8 +15,8 @@ typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__at
@property(copy) CGColorRef x;
// rdar: // 7809460
-typedef struct CGColor *CGColorRefNoNSObject;
-@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color;
+typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject;
+@property (nonatomic, retain) CGColorRefNoNSObject color;
@end
void setProperty(id self, id value) {
@@ -40,3 +40,15 @@ int main(int argc, char *argv[]) {
return 0;
}
+// rdar://10453342
+@interface I
+{
+ __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+}
+ // <rdar://problem/10930507>
+@property (nonatomic, retain) __attribute__((NSObject)) void * color; // // no-warning
+@end
+void test_10453342() {
+ char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+}
+
diff --git a/test/SemaObjC/objc-array-literal.m b/test/SemaObjC/objc-array-literal.m
new file mode 100644
index 0000000..9f59316
--- /dev/null
+++ b/test/SemaObjC/objc-array-literal.m
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10111397
+
+#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
+typedef unsigned long NSUInteger;
+#else
+typedef unsigned int NSUInteger;
+#endif
+
+@class NSString;
+
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+
+@class NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
+
+@end
+
+@interface NSNumber
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@interface NSArray <NSFastEnumeration>
++ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
+@end
+
+
+int main() {
+ NSArray *array = @[@"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42]];
+
+ for (id string in array)
+ NSLog(@"%@\n", string);
+
+ NSArray *array1 = @["Forgot"]; // expected-error {{string literal must be prefixed by '@' in a collection}}
+
+ const char *blah;
+ NSArray *array2 = @[blah]; // expected-error{{collection element of type 'const char *' is not an Objective-C object}}
+}
diff --git a/test/SemaObjC/objc-buffered-methods.m b/test/SemaObjC/objc-buffered-methods.m
index 78912ae..a4b83be 100644
--- a/test/SemaObjC/objc-buffered-methods.m
+++ b/test/SemaObjC/objc-buffered-methods.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://8843851
int* global;
diff --git a/test/SemaObjC/objc-container-subscripting-1.m b/test/SemaObjC/objc-container-subscripting-1.m
new file mode 100644
index 0000000..a58a7c3
--- /dev/null
+++ b/test/SemaObjC/objc-container-subscripting-1.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+@end
+
+@interface XNSMutableArray
+@end
+
+int main() {
+id array;
+id oldObject = array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}}
+
+array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}}
+
+id<P> p_array;
+oldObject = p_array[10]; // expected-warning {{instance method '-objectAtIndexedSubscript:' not found (return type defaults to 'id')}}
+
+p_array[10] = 0; // expected-warning {{instance method '-setObject:atIndexedSubscript:' not found (return type defaults to 'id')}}
+}
+
diff --git a/test/SemaObjC/objc-container-subscripting-2.m b/test/SemaObjC/objc-container-subscripting-2.m
new file mode 100644
index 0000000..3c0081b
--- /dev/null
+++ b/test/SemaObjC/objc-container-subscripting-2.m
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(size_t)index;
+- (void)setObject:(id)object atIndexedSubscript:(size_t)index;
+@end
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(size_t)key;
+@end
+
+id func() {
+ NSMutableArray *array;
+ float f;
+ array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an integral or objective-C pointer type}}
+ return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+}
+
+void test_unused() {
+ NSMutableArray *array;
+ array[10]; // expected-warning {{container access result unused - container access should not be used for side effects}}
+
+ NSMutableDictionary *dict;
+ dict[array]; // expected-warning {{container access result unused - container access should not be used for side effects}}
+}
+
diff --git a/test/SemaObjC/objc-container-subscripting-3.m b/test/SemaObjC/objc-container-subscripting-3.m
new file mode 100644
index 0000000..5fd1a10
--- /dev/null
+++ b/test/SemaObjC/objc-container-subscripting-3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://10904488
+
+@interface Test
+- (int)objectAtIndexedSubscript:(int)index; // expected-note {{method 'objectAtIndexedSubscript:' declared here}}
+- (void)setObject:(int)object atIndexedSubscript:(int)index; // expected-note {{parameter of type 'int' is declared here}}
+@end
+
+@interface NSMutableDictionary
+- (int)objectForKeyedSubscript:(id)key; // expected-note {{method 'objectForKeyedSubscript:' declared here}}
+- (void)setObject:(int)object forKeyedSubscript:(id)key; // expected-note {{parameter of type 'int' is declared here}}
+@end
+
+int main() {
+ Test *array;
+ int i = array[10]; // expected-error {{method for accessing array element must have Objective-C object return type instead of 'int'}}
+ array[2] = i; // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an objective-C pointer type}}
+
+ NSMutableDictionary *dict;
+ id key, val;
+ val = dict[key]; // expected-error {{method for accessing dictionary element must have Objective-C object return type instead of 'int'}} \
+ // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
+ dict[key] = val; // expected-error {{method object parameter type 'int' is not object type}}
+}
+
diff --git a/test/SemaObjC/objc-container-subscripting.m b/test/SemaObjC/objc-container-subscripting.m
new file mode 100644
index 0000000..4125bc6
--- /dev/null
+++ b/test/SemaObjC/objc-container-subscripting.m
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef unsigned int size_t;
+@protocol P @end
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(double)index; // expected-note {{parameter of type 'double' is declared here}}
+- (void)setObject:(id *)object atIndexedSubscript:(void *)index; // expected-note {{parameter of type 'void *' is declared here}} \
+ // expected-note {{parameter of type 'id *' is declared here}}
+@end
+@interface I @end
+
+int main() {
+ NSMutableArray<P> * array;
+ id oldObject = array[10]; // expected-error {{method index parameter type 'double' is not integral type}}
+ array[3] = 0; // expected-error {{method index parameter type 'void *' is not integral type}} \
+ // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'id *' is not an objective-C pointer type}}
+
+ I* iarray;
+ iarray[3] = 0; // expected-error {{expected method to write array element not found on object of type 'I *'}}
+ I* p = iarray[4]; // expected-error {{expected method to read array element not found on object of type 'I *'}}
+
+ oldObject = array[10]++; // expected-error {{illegal operation on objective-c container subscripting}}
+ oldObject = array[10]--; // expected-error {{illegal operation on objective-c container subscripting}}
+ oldObject = --array[10]; // expected-error {{illegal operation on objective-c container subscripting}}
+}
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id*)key; // expected-note {{parameter of type 'id *' is declared here}}
+- (void)setObject:(void*)object forKeyedSubscript:(id*)key; // expected-note {{parameter of type 'void *' is declared here}} \
+ // expected-note {{parameter of type 'id *' is declared here}}
+@end
+@class NSString;
+
+void testDict() {
+ NSMutableDictionary *dictionary;
+ NSString *key;
+ id newObject, oldObject;
+ oldObject = dictionary[key]; // expected-error {{method key parameter type 'id *' is not object type}}
+ dictionary[key] = newObject; // expected-error {{method object parameter type 'void *' is not object type}} \
+ // expected-error {{method key parameter type 'id *' is not object type}}
+}
diff --git a/test/SemaObjC/objc-cstyle-args-in-methods.m b/test/SemaObjC/objc-cstyle-args-in-methods.m
index 9f75295..d37b589 100644
--- a/test/SemaObjC/objc-cstyle-args-in-methods.m
+++ b/test/SemaObjC/objc-cstyle-args-in-methods.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo
- (id)test:(id)one, id two;
diff --git a/test/SemaObjC/objc-dictionary-literal.m b/test/SemaObjC/objc-dictionary-literal.m
new file mode 100644
index 0000000..2acbc39
--- /dev/null
+++ b/test/SemaObjC/objc-dictionary-literal.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://11062080
+
+@interface NSNumber
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
+@end
+
+@protocol NSCopying @end
+typedef unsigned long NSUInteger;
+typedef long NSInteger;
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
+- (void)setObject:(id)object forKeyedSubscript:(id)key;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+@interface NSArray
+- (id)objectAtIndexedSubscript:(NSInteger)index;
+- (void)setObject:(id)object atIndexedSubscript:(NSInteger)index;
+@end
+
+int main() {
+ NSDictionary *dict = @{ @"name":@666 };
+ dict[@"name"] = @666;
+
+ dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an objective-C pointer}}
+
+ return 0;
+}
+
diff --git a/test/SemaObjC/objc-literal-nsnumber.m b/test/SemaObjC/objc-literal-nsnumber.m
new file mode 100644
index 0000000..449bfff
--- /dev/null
+++ b/test/SemaObjC/objc-literal-nsnumber.m
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+// rdar://10111397
+
+#if __LP64__
+typedef unsigned long NSUInteger;
+#else
+typedef unsigned int NSUInteger;
+#endif
+
+@interface NSObject
++ (NSObject*)nsobject;
+@end
+
+@interface NSNumber : NSObject
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithFloat:(float)value;
+@end
+
+int main() {
+ NSNumber * N = @3.1415926535; // expected-error {{declaration of 'numberWithDouble:' is missing in NSNumber class}}
+ NSNumber *noNumber = @__objc_yes; // expected-error {{declaration of 'numberWithBool:' is missing in NSNumber class}}
+ NSNumber * NInt = @1000;
+ NSNumber * NLongDouble = @1000.0l; // expected-error{{'long double' is not a valid literal type for NSNumber}}
+ id character = @ 'a';
+
+ NSNumber *NNegativeInt = @-1000;
+ NSNumber *NPositiveInt = @+1000;
+ NSNumber *NNegativeFloat = @-1000.1f;
+ NSNumber *NPositiveFloat = @+1000.1f;
+
+ int five = 5;
+ @-five; // expected-error{{@- must be followed by a number to form an NSNumber object}}
+ @+five; // expected-error{{@+ must be followed by a number to form an NSNumber object}}
+}
+
+// Dictionary test
+@class NSDictionary;
+
+NSDictionary *err() {
+ return @{@"name" : @"value"}; // expected-error {{declaration of 'dictionaryWithObjects:forKeys:count:' is missing in NSDictionary class}}
+}
+
+@interface NSDate : NSObject
++ (NSDate *) date;
+@end
+
+@protocol NSCopying
+- copy;
+@end
+
+@interface NSDictionary : NSObject
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(NSUInteger)cnt;
+@end
+
+@interface NSString<NSCopying>
+@end
+
+id NSUserName();
+
+int Int();
+
+NSDictionary * blocks() {
+ return @{ @"task" : ^ { return 17; } };
+}
+
+NSDictionary * warn() {
+ NSDictionary *dictionary = @{@"name" : NSUserName(),
+ @"date" : [NSDate date],
+ @"name2" : @"other",
+ NSObject.nsobject : @"nsobject" }; // expected-warning{{passing 'NSObject *' to parameter of incompatible type 'const id<NSCopying>'}}
+ NSDictionary *dictionary2 = @{@"name" : Int()}; // expected-error {{collection element of type 'int' is not an Objective-C object}}
+
+ NSObject *o;
+ NSDictionary *dictionary3 = @{o : o, // expected-warning{{passing 'NSObject *' to parameter of incompatible type 'const id<NSCopying>'}}
+ @"date" : [NSDate date] };
+ return dictionary3;
+}
+
+// rdar:// 11231426
+typedef float BOOL; // expected-note {{previous declaration is here}}
+
+BOOL radar11231426() {
+ return __objc_yes; // expected-warning {{BOOL of type 'float' is non-intergal and unsuitable for a boolean literal - ignored}}
+}
diff --git a/test/SemaObjC/objc-literal-sig.m b/test/SemaObjC/objc-literal-sig.m
new file mode 100644
index 0000000..fb5c79f
--- /dev/null
+++ b/test/SemaObjC/objc-literal-sig.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+typedef _Bool BOOL;
+
+@interface NSNumber @end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (int)numberWithBool:(BOOL)value; // expected-note{{method returns unexpected type 'int' (should be an object type)}}
+@end
+
+@interface NSArray
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const int [])objects // expected-note{{first parameter has unexpected type 'const int *' (should be 'const id *')}}
+ count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects
+ forKeys:(const int [])keys // expected-note{{second parameter has unexpected type 'const int *' (should be 'const id *')}}
+ count:(unsigned long)cnt;
+@end
+
+void test_sig() {
+ (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}}
+ id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}}
+ id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}}
+}
diff --git a/test/SemaObjC/objc-qualified-property-lookup.m b/test/SemaObjC/objc-qualified-property-lookup.m
index daf583d..48b28cb 100644
--- a/test/SemaObjC/objc-qualified-property-lookup.m
+++ b/test/SemaObjC/objc-qualified-property-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9078584
@interface NSObject @end
diff --git a/test/SemaObjC/pedantic-dynamic-test.m b/test/SemaObjC/pedantic-dynamic-test.m
index 9b14c1d..61f36b3 100644
--- a/test/SemaObjC/pedantic-dynamic-test.m
+++ b/test/SemaObjC/pedantic-dynamic-test.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s
// rdar: // 7860960
@interface I
diff --git a/test/SemaObjC/pragma-pack.m b/test/SemaObjC/pragma-pack.m
new file mode 100644
index 0000000..ba39257
--- /dev/null
+++ b/test/SemaObjC/pragma-pack.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -verify -Wno-objc-root-class %s
+
+// Make sure pragma pack works inside ObjC methods. <rdar://problem/10893316>
+@interface X
+@end
+@implementation X
+- (void)Y {
+#pragma pack(push, 1)
+ struct x {
+ char a;
+ int b;
+ };
+#pragma pack(pop)
+ typedef char check_[sizeof (struct x) == 5 ? 1 : -1];
+}
+@end
diff --git a/test/SemaObjC/property-10.m b/test/SemaObjC/property-10.m
index e89d68e..51eb39c 100644
--- a/test/SemaObjC/property-10.m
+++ b/test/SemaObjC/property-10.m
@@ -37,3 +37,12 @@
@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}}
@property(nonatomic,weak) int (*PROP2)(); // expected-error {{property with 'weak' attribute must be of object type}}
@end
+
+// rdar://10357768
+@interface rdar10357768
+{
+ int n1;
+}
+@property (readonly, setter=crushN1:) int n1; // expected-warning {{setter cannot be specified for a readonly property}}
+@end
+
diff --git a/test/SemaObjC/property-2.m b/test/SemaObjC/property-2.m
index 069b0cb..f95af59 100644
--- a/test/SemaObjC/property-2.m
+++ b/test/SemaObjC/property-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Tester
@property char PropertyAtomic_char;
diff --git a/test/SemaObjC/property-9.m b/test/SemaObjC/property-9.m
index 2b6564d..4bed875 100644
--- a/test/SemaObjC/property-9.m
+++ b/test/SemaObjC/property-9.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef signed char BOOL;
@protocol NSObject - (BOOL)isEqual:(id)object; @end
@@ -44,21 +44,20 @@ typedef signed char BOOL;
}
@property (readonly) int; // expected-warning {{declaration does not declare anything}}
-@property (readonly) ; // expected-error {{type name requires a specifier or qualifier}} \
- expected-warning {{declaration does not declare anything}}
+@property (readonly) ; // expected-error {{type name requires a specifier or qualifier}}
@property (readonly) int : 4; // expected-error {{property requires fields to be named}}
// test parser recovery: rdar://6254579
@property ( // expected-note {{to match this '('}}
- readonly getter=isAwesome) // expected-error {{error: expected ')'}}
+ readonly getter=isAwesome) // expected-error {{expected ')'}}
int _awesome;
@property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}}
int _awesome2;
@property ( // expected-note {{to match this '('}}
- +) // expected-error {{error: expected ')'}}
+ +) // expected-error {{expected ')'}}
int _awesome3;
@@ -97,13 +96,13 @@ typedef signed char BOOL;
@end
// rdar://8774513
-@class MDAInstance; // expected-note {{forward class is declared here}}
+@class MDAInstance; // expected-note {{forward declaration of class here}}
@interface MDATestDocument
@property(retain) MDAInstance *instance;
@end
id f0(MDATestDocument *d) {
- return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance *'}}
+ return d.instance.path; // expected-error {{property 'path' cannot be found in forward class object 'MDAInstance'}}
}
diff --git a/test/SemaObjC/property-and-ivar-use.m b/test/SemaObjC/property-and-ivar-use.m
index 12874e7..5b40d85 100644
--- a/test/SemaObjC/property-and-ivar-use.m
+++ b/test/SemaObjC/property-and-ivar-use.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// Do not issue error if 'ivar' used previously belongs to the inherited class
// and has same name as @dynalic property in current class.
diff --git a/test/SemaObjC/property-category-1.m b/test/SemaObjC/property-category-1.m
index 6382826..3788bc9 100644
--- a/test/SemaObjC/property-category-1.m
+++ b/test/SemaObjC/property-category-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Object
+ (id)new;
@@ -48,6 +48,6 @@ int main(int argc, char **argv) {
@implementation I0 // expected-warning {{property 'p0' requires method 'p0' to be define}}
- (void) foo {
- self.p0 = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+ self.p0 = 0; // expected-error {{assignment to readonly property}}
}
@end
diff --git a/test/SemaObjC/property-category-3.m b/test/SemaObjC/property-category-3.m
index 2a61d92..47e93a3 100644
--- a/test/SemaObjC/property-category-3.m
+++ b/test/SemaObjC/property-category-3.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@protocol P
@property(readonly) int X; // expected-note {{property declared here}}
diff --git a/test/SemaObjC/property-category-4.m b/test/SemaObjC/property-category-4.m
index aa49a3f..e7939b3 100644
--- a/test/SemaObjC/property-category-4.m
+++ b/test/SemaObjC/property-category-4.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface IDELogNavigator
{
diff --git a/test/SemaObjC/property-category-impl.m b/test/SemaObjC/property-category-impl.m
index 21fdf1b..9524c22 100644
--- a/test/SemaObjC/property-category-impl.m
+++ b/test/SemaObjC/property-category-impl.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
/* This test is for categories which don't implement the accessors but some accessors are
implemented in their base class implementation. In this case,no warning must be issued.
diff --git a/test/SemaObjC/property-dot-receiver.m b/test/SemaObjC/property-dot-receiver.m
index 733ad42..c5a928b 100644
--- a/test/SemaObjC/property-dot-receiver.m
+++ b/test/SemaObjC/property-dot-receiver.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://8962253
@interface Singleton {
diff --git a/test/SemaObjC/property-error-readonly-assign.m b/test/SemaObjC/property-error-readonly-assign.m
index fc8c48c..3484172 100644
--- a/test/SemaObjC/property-error-readonly-assign.m
+++ b/test/SemaObjC/property-error-readonly-assign.m
@@ -13,9 +13,9 @@
@end
void f0(A *a, B* b) {
- a.x = 10; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+ a.x = 10; // expected-error {{assignment to readonly property}}
a.ok = 20;
- b.x = 10; // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+ b.x = 10; // expected-error {{no setter method 'setX:' for assignment to property}}
b.ok = 20;
}
@@ -39,6 +39,6 @@ NSRect NSMakeRect();
@implementation NSWindow (Category)
-(void)methodToMakeClangCrash
{
- self.frame = NSMakeRect(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+ self.frame = NSMakeRect(); // expected-error {{no setter method 'setFrame:' for assignment to property}}
}
@end
diff --git a/test/SemaObjC/property-expression-error.m b/test/SemaObjC/property-expression-error.m
index 6b5cf04..e306722 100644
--- a/test/SemaObjC/property-expression-error.m
+++ b/test/SemaObjC/property-expression-error.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface AddressMyProperties
{
diff --git a/test/SemaObjC/property-impl-misuse.m b/test/SemaObjC/property-impl-misuse.m
index 122afc1d..c3cedb0 100644
--- a/test/SemaObjC/property-impl-misuse.m
+++ b/test/SemaObjC/property-impl-misuse.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface I {
int Y;
diff --git a/test/SemaObjC/property-in-class-extension.m b/test/SemaObjC/property-in-class-extension.m
index 6ae0b81..a7b5130 100644
--- a/test/SemaObjC/property-in-class-extension.m
+++ b/test/SemaObjC/property-in-class-extension.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://7766184
@interface Foo @end
@@ -9,7 +9,7 @@
void FUNC () {
Foo *foo;
- foo.bar = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+ foo.bar = 0; // expected-error {{assignment to readonly property}}
}
// rdar://8747333
diff --git a/test/SemaObjC/property-ivar-mismatch.m b/test/SemaObjC/property-ivar-mismatch.m
index 16ff338..6abd6e6 100644
--- a/test/SemaObjC/property-ivar-mismatch.m
+++ b/test/SemaObjC/property-ivar-mismatch.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// Test that arithmatic types on property and its ivar have exact match.
@interface Test4
diff --git a/test/SemaObjC/property-lookup-in-id.m b/test/SemaObjC/property-lookup-in-id.m
index 86da48e..38aa32c 100644
--- a/test/SemaObjC/property-lookup-in-id.m
+++ b/test/SemaObjC/property-lookup-in-id.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9106929
typedef struct objc_class *Class;
@@ -25,7 +25,7 @@ extern id NSApp;
- (void)startFSEventGathering:(id)sender
{
- fsEventStream = [NSApp delegate].fsEventStream; // expected-warning {{warning: instance method '-delegate' not found (return type defaults to 'id')}} \
+ fsEventStream = [NSApp delegate].fsEventStream; // expected-warning {{instance method '-delegate' not found (return type defaults to 'id')}} \
// expected-error {{property 'fsEventStream' not found on object of type 'id'}}
}
diff --git a/test/SemaObjC/property-method-lookup-impl.m b/test/SemaObjC/property-method-lookup-impl.m
index 0a018b0..19d4e68 100644
--- a/test/SemaObjC/property-method-lookup-impl.m
+++ b/test/SemaObjC/property-method-lookup-impl.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface SSyncCEList
{
diff --git a/test/SemaObjC/property-missing.m b/test/SemaObjC/property-missing.m
index bf75601..3ebf0a8 100644
--- a/test/SemaObjC/property-missing.m
+++ b/test/SemaObjC/property-missing.m
@@ -21,7 +21,7 @@ void f3(id o)
}
// rdar://8851803
-@class SomeOtherClass; // expected-note {{forward class is declared here}}
+@class SomeOtherClass; // expected-note {{forward declaration of class here}}
@interface MyClass {
SomeOtherClass *someOtherObject;
diff --git a/test/SemaObjC/property-not-lvalue.m b/test/SemaObjC/property-not-lvalue.m
index 3d95d26..12d2cc6 100644
--- a/test/SemaObjC/property-not-lvalue.m
+++ b/test/SemaObjC/property-not-lvalue.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef struct NSSize {
int width;
diff --git a/test/SemaObjC/property-ns-returns-not-retained-attr.m b/test/SemaObjC/property-ns-returns-not-retained-attr.m
index a209da8..96ef3ed 100644
--- a/test/SemaObjC/property-ns-returns-not-retained-attr.m
+++ b/test/SemaObjC/property-ns-returns-not-retained-attr.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9636091
@interface I
diff --git a/test/SemaObjC/property-redundant-decl-accessor.m b/test/SemaObjC/property-redundant-decl-accessor.m
index 2a24e7e..3b0e825 100644
--- a/test/SemaObjC/property-redundant-decl-accessor.m
+++ b/test/SemaObjC/property-redundant-decl-accessor.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Werror -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Werror -verify -Wno-objc-root-class %s
@interface MyClass {
const char *_myName;
diff --git a/test/SemaObjC/property-typecheck-1.m b/test/SemaObjC/property-typecheck-1.m
index f86e047..f71e4a0 100644
--- a/test/SemaObjC/property-typecheck-1.m
+++ b/test/SemaObjC/property-typecheck-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface A
-(float) x; // expected-note {{declared here}}
diff --git a/test/SemaObjC/property-user-setter.m b/test/SemaObjC/property-user-setter.m
index 2f1e197..7d4e544 100644
--- a/test/SemaObjC/property-user-setter.m
+++ b/test/SemaObjC/property-user-setter.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface I0
@property(readonly) int x;
@@ -20,7 +20,7 @@
-(void) im0 {
self.x = 0;
self.y = 2;
- self.z = 2; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
+ self.z = 2; // expected-error {{assignment to readonly property}}
}
@end
@@ -85,7 +85,7 @@ static int g_val;
- (void)setFoo:(int)value;
@end
-void g(int);
+void g(int); // expected-note {{passing argument to parameter here}}
void f(C *c) {
c.Foo = 17; // OK
diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m
index 7d1cb7a..a948741 100644
--- a/test/SemaObjC/property.m
+++ b/test/SemaObjC/property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s
@interface I
{
@@ -65,3 +65,19 @@ typedef id BYObjectIdentifier;
// rdar://10127639
@synthesize window; // expected-error {{missing context for property implementation declaration}}
+
+// rdar://10408414
+Class test6_getClass();
+@interface Test6
+@end
+@implementation Test6
++ (float) globalValue { return 5.0f; }
++ (float) gv { return test6_getClass().globalValue; }
+@end
+
+@interface Test7
+@property unsigned length;
+@end
+void test7(Test7 *t) {
+ char data[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
+}
diff --git a/test/SemaObjC/protocol-archane.m b/test/SemaObjC/protocol-archane.m
index 992d3e4..49c9851 100644
--- a/test/SemaObjC/protocol-archane.m
+++ b/test/SemaObjC/protocol-archane.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://5986251
@protocol SomeProtocol
diff --git a/test/SemaObjC/protocol-id-test-1.m b/test/SemaObjC/protocol-id-test-1.m
index 6b2b682..19a4432 100644
--- a/test/SemaObjC/protocol-id-test-1.m
+++ b/test/SemaObjC/protocol-id-test-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
@interface FF
- (void) Meth;
diff --git a/test/SemaObjC/protocol-id-test-2.m b/test/SemaObjC/protocol-id-test-2.m
index a9365e9..6bd2fee 100644
--- a/test/SemaObjC/protocol-id-test-2.m
+++ b/test/SemaObjC/protocol-id-test-2.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
@protocol P
@end
diff --git a/test/SemaObjC/protocol-implementing-class-methods.m b/test/SemaObjC/protocol-implementing-class-methods.m
index f08a5a9..503eef1 100644
--- a/test/SemaObjC/protocol-implementing-class-methods.m
+++ b/test/SemaObjC/protocol-implementing-class-methods.m
@@ -5,11 +5,11 @@
@optional
- (int) PMeth;
@required
-- (void) : (double) arg; // expected-note {{method declared here}}
+- (void) : (double) arg; // expected-note {{method ':' declared here}}
@end
@interface NSImage <P1>
-- (void) initialize; // expected-note {{method declared here}}
+- (void) initialize; // expected-note {{method 'initialize' declared here}}
@end
@interface NSImage (AirPortUI)
@@ -17,7 +17,7 @@
@end
@interface NSImage()
-- (void) CEMeth; // expected-note {{method declared here}}
+- (void) CEMeth; // expected-note {{method 'CEMeth' declared here}}
@end
@implementation NSImage (AirPortUI)
diff --git a/test/SemaObjC/provisional-ivar-lookup.m b/test/SemaObjC/provisional-ivar-lookup.m
index 007c21b..2ec23a5 100644
--- a/test/SemaObjC/provisional-ivar-lookup.m
+++ b/test/SemaObjC/provisional-ivar-lookup.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
// rdar:// 8565343
@interface Foo {
diff --git a/test/SemaObjC/qualified-protocol-method-conflicts.m b/test/SemaObjC/qualified-protocol-method-conflicts.m
index 0cff3ff..d1d5612 100644
--- a/test/SemaObjC/qualified-protocol-method-conflicts.m
+++ b/test/SemaObjC/qualified-protocol-method-conflicts.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Woverriding-method-mismatch -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://6191214
@protocol Xint
diff --git a/test/SemaObjC/receiver-forward-class.m b/test/SemaObjC/receiver-forward-class.m
new file mode 100644
index 0000000..cefb5d7
--- /dev/null
+++ b/test/SemaObjC/receiver-forward-class.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wreceiver-forward-class -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Wreceiver-forward-class -verify %s
+// rdar://10686120
+
+@class A; // expected-note {{forward declaration of class here}}
+
+@interface B
+-(int) width; // expected-note {{using}}
+@end
+@interface C
+-(float) width; // expected-note {{also found}}
+@end
+
+int f0(A *x) {
+ return [x width]; // expected-warning {{receiver type 'A' for instance message is a forward declaration}} \
+ // expected-warning {{multiple methods named 'width' found}} \
+ // expected-note {{receiver is treated with 'id' type for purpose of method lookup}}
+}
+
diff --git a/test/SemaObjC/related-result-type-inference.m b/test/SemaObjC/related-result-type-inference.m
index 11b4b96..124767c 100644
--- a/test/SemaObjC/related-result-type-inference.m
+++ b/test/SemaObjC/related-result-type-inference.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
@interface Unrelated
@end
@@ -150,7 +150,7 @@ void test_inference() {
// <rdar://problem/9340699>
@interface G
-- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method declared here}}
+- (id)_ABC_init __attribute__((objc_method_family(init))); // expected-note {{method '_ABC_init' declared here}}
@end
@interface G (Additions)
@@ -169,3 +169,12 @@ void test_inference() {
}
@end
+// PR12384
+@interface Fail @end
+@protocol X @end
+@implementation Fail
+- (id<X>) initWithX
+{
+ return (id)self; // expected-warning {{returning 'Fail *' from a function with incompatible result type 'id<X>'}}
+}
+@end
diff --git a/test/SemaObjC/return.m b/test/SemaObjC/return.m
index 4e70bde..f69d41e 100644
--- a/test/SemaObjC/return.m
+++ b/test/SemaObjC/return.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions -Wno-objc-root-class %s
int test1() {
id a;
diff --git a/test/SemaObjC/scope-check.m b/test/SemaObjC/scope-check.m
index 3f474be..e19ba47 100644
--- a/test/SemaObjC/scope-check.m
+++ b/test/SemaObjC/scope-check.m
@@ -1,11 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
@class A, B, C;
void test1() {
- goto L; // expected-error{{illegal goto into protected scope}}
- goto L2; // expected-error{{illegal goto into protected scope}}
- goto L3; // expected-error{{illegal goto into protected scope}}
+ goto L; // expected-error{{goto into protected scope}}
+ goto L2; // expected-error{{goto into protected scope}}
+ goto L3; // expected-error{{goto into protected scope}}
@try { // expected-note {{jump bypasses initialization of @try block}}
L: ;
} @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
@@ -17,11 +17,11 @@ L3: ;
}
@try {
- goto L4; // expected-error{{illegal goto into protected scope}}
- goto L5; // expected-error{{illegal goto into protected scope}}
+ goto L4; // expected-error{{goto into protected scope}}
+ goto L5; // expected-error{{goto into protected scope}}
} @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
L5: ;
- goto L6; // expected-error{{illegal goto into protected scope}}
+ goto L6; // expected-error{{goto into protected scope}}
} @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
L6: ;
} @finally { // expected-note {{jump bypasses initialization of @finally block}}
@@ -32,12 +32,12 @@ L3: ;
@try { // expected-note 2 {{jump bypasses initialization of @try block}}
L7: ;
} @catch (C *c) {
- goto L7; // expected-error{{illegal goto into protected scope}}
+ goto L7; // expected-error{{goto into protected scope}}
} @finally {
- goto L7; // expected-error{{illegal goto into protected scope}}
+ goto L7; // expected-error{{goto into protected scope}}
}
- goto L8; // expected-error{{illegal goto into protected scope}}
+ goto L8; // expected-error{{goto into protected scope}}
@try {
} @catch (A *c) {
} @catch (B *c) {
@@ -47,7 +47,7 @@ L3: ;
// rdar://6810106
id X;
- goto L9; // expected-error{{illegal goto into protected scope}}
+ goto L9; // expected-error{{goto into protected scope}}
goto L10; // ok
@synchronized // expected-note {{jump bypasses initialization of @synchronized block}}
( ({ L10: ; X; })) {
@@ -79,7 +79,7 @@ void test3() {
+ (void) hello {
@try {
- goto blargh; // expected-error {{illegal goto into protected scope}}
+ goto blargh; // expected-error {{goto into protected scope}}
} @catch (...) { // expected-note {{jump bypasses initialization of @catch block}}
blargh: ;
}
@@ -87,14 +87,14 @@ void test3() {
+ (void)meth2 {
int n; void *P;
- goto L0; // expected-error {{illegal goto into protected scope}}
+ goto L0; // expected-error {{goto into protected scope}}
typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
L0:
- goto L1; // expected-error {{illegal goto into protected scope}}
+ goto L1; // expected-error {{goto into protected scope}}
A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
L1:
- goto L2; // expected-error {{illegal goto into protected scope}}
+ goto L2; // expected-error {{goto into protected scope}}
A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
L2:
return;
diff --git a/test/SemaObjC/selector-3.m b/test/SemaObjC/selector-3.m
index b248a5d..4c12a93 100644
--- a/test/SemaObjC/selector-3.m
+++ b/test/SemaObjC/selector-3.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wselector -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wselector -verify -Wno-objc-root-class %s
// rdar://8851684
@interface Foo
diff --git a/test/SemaObjC/selector-error.m b/test/SemaObjC/selector-error.m
index dfd6bd0..f59dec8 100644
--- a/test/SemaObjC/selector-error.m
+++ b/test/SemaObjC/selector-error.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo
- (char*) foo;
diff --git a/test/SemaObjC/self-assign.m b/test/SemaObjC/self-assign.m
index f05b028..e0f5f43 100644
--- a/test/SemaObjC/self-assign.m
+++ b/test/SemaObjC/self-assign.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface A
@end
diff --git a/test/SemaObjC/self-declared-in-block.m b/test/SemaObjC/self-declared-in-block.m
index 25ce8ba..40a0331 100644
--- a/test/SemaObjC/self-declared-in-block.m
+++ b/test/SemaObjC/self-declared-in-block.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify %s
-// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10 -fblocks -verify -Wno-objc-root-class %s
// rdar://9154582
@interface Blocky @end
diff --git a/test/SemaObjC/severe-syntax-error.m b/test/SemaObjC/severe-syntax-error.m
new file mode 100644
index 0000000..8c59151
--- /dev/null
+++ b/test/SemaObjC/severe-syntax-error.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10633434
+
+@interface testClass
+@end
+
+@class NSArray;
+
+@implementation testClass
+
+static NSArray* prefixArray[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static NSString* prefixArray1[] = @"BEGIN:", @"END:", @"VERSION:", @"N:", @"FN:", @"TEL;", @"TEL:", nil; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+static char* cArray[] = "BEGIN:", "END"; // expected-error {{array initializer must be an initializer list}} \
+ // expected-error {{expected identifier or '('}} \
+ // expected-error {{expected ';' after top level declarator}}
+
+@end
diff --git a/test/SemaObjC/sizeof-interface.m b/test/SemaObjC/sizeof-interface.m
index 43870a1..7304b6c 100644
--- a/test/SemaObjC/sizeof-interface.m
+++ b/test/SemaObjC/sizeof-interface.m
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s
-@class I0;
+@class I0; // expected-note 2{{forward declaration of class here}}
// rdar://6811884
int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an incomplete type 'I0'}}
@@ -9,7 +9,7 @@ int g0 = sizeof(I0); // expected-error{{invalid application of 'sizeof' to an in
void *g3(I0 *P) {
P = P+5; // expected-error {{arithmetic on a pointer to an incomplete type 'I0'}}
- return &P[4]; // expected-error{{subscript of pointer to incomplete type 'I0'}}
+ return &P[4]; // expected-error{{expected method to read array element not found on object of type 'I0 *'}}
}
@@ -55,7 +55,7 @@ int bar(I0 *P) {
P = 5+P; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}}
P = P-5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}}
- return P[4].x[2]; // expected-error {{subscript requires size of interface 'I0', which is not constant in non-fragile ABI}}
+ return P[4].x[2]; // expected-error {{expected method to read array element not found on object of type 'I0 *'}}
}
diff --git a/test/SemaObjC/special-dep-unavail-warning.m b/test/SemaObjC/special-dep-unavail-warning.m
index 57a2fa3..754bf5f 100644
--- a/test/SemaObjC/special-dep-unavail-warning.m
+++ b/test/SemaObjC/special-dep-unavail-warning.m
@@ -27,7 +27,7 @@
@end
-@class C; // expected-note 5 {{forward class is declared here}}
+@class C; // expected-note 5 {{forward declaration of class here}}
void test(C *c) {
[c depInA]; // expected-warning {{'depInA' maybe deprecated because receiver type is unknown}}
@@ -43,3 +43,13 @@ void test(C *c) {
}
+// rdar://10268422
+__attribute ((deprecated))
+@interface DEPRECATED
++(id)new;
+@end
+
+void foo() {
+ [DEPRECATED new]; // expected-warning {{'DEPRECATED' is deprecated}}
+}
+
diff --git a/test/SemaObjC/stand-alone-implementation.m b/test/SemaObjC/stand-alone-implementation.m
index c33b66a..6fa9b4b 100644
--- a/test/SemaObjC/stand-alone-implementation.m
+++ b/test/SemaObjC/stand-alone-implementation.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// radar 7547942
// Allow injection of ivars into implementation's implicit class.
diff --git a/test/SemaObjC/super.m b/test/SemaObjC/super.m
index 0c42e99..cf48c19 100644
--- a/test/SemaObjC/super.m
+++ b/test/SemaObjC/super.m
@@ -21,7 +21,7 @@ void takevoidptr(void*);
@implementation B
- (void)instanceMethod {
- [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod')}}
+ [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod'}}
// Use of super in a block is ok and does codegen to the right thing.
// rdar://7852959
diff --git a/test/SemaObjC/synchronized.m b/test/SemaObjC/synchronized.m
index dac620a..c158815 100644
--- a/test/SemaObjC/synchronized.m
+++ b/test/SemaObjC/synchronized.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface PBXTrackableTaskManager @end
diff --git a/test/SemaObjC/synth-provisional-ivars-1.m b/test/SemaObjC/synth-provisional-ivars-1.m
index 8bf6878..0e155f4 100644
--- a/test/SemaObjC/synth-provisional-ivars-1.m
+++ b/test/SemaObjC/synth-provisional-ivars-1.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
// rdar://8913053
typedef unsigned char BOOL;
diff --git a/test/SemaObjC/synth-provisional-ivars.m b/test/SemaObjC/synth-provisional-ivars.m
index 696eb9b..9d7abd5 100644
--- a/test/SemaObjC/synth-provisional-ivars.m
+++ b/test/SemaObjC/synth-provisional-ivars.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
int bar;
diff --git a/test/SemaObjC/synthesize-setter-contclass.m b/test/SemaObjC/synthesize-setter-contclass.m
index 36967d4..d754415 100644
--- a/test/SemaObjC/synthesize-setter-contclass.m
+++ b/test/SemaObjC/synthesize-setter-contclass.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface TestClass
{
diff --git a/test/SemaObjC/synthesized-ivar.m b/test/SemaObjC/synthesized-ivar.m
index 745fe77..8c9d905 100644
--- a/test/SemaObjC/synthesized-ivar.m
+++ b/test/SemaObjC/synthesized-ivar.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
@interface I
{
}
diff --git a/test/SemaObjC/transparent-union.m b/test/SemaObjC/transparent-union.m
index cb03dfe..6f2dbf9 100644
--- a/test/SemaObjC/transparent-union.m
+++ b/test/SemaObjC/transparent-union.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef union {
struct xx_object_s *_do;
diff --git a/test/SemaObjC/try-catch.m b/test/SemaObjC/try-catch.m
index da06eca..5afbbb6 100644
--- a/test/SemaObjC/try-catch.m
+++ b/test/SemaObjC/try-catch.m
@@ -40,7 +40,7 @@ typedef struct _NSZone NSZone;
int foo() {
struct s { int a, b; } agg, *pagg;
- @throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid))}}
+ @throw 42; // expected-error {{@throw requires an Objective-C object type ('int' invalid)}}
@throw agg; // expected-error {{@throw requires an Objective-C object type ('struct s' invalid)}}
@throw pagg; // expected-error {{@throw requires an Objective-C object type ('struct s *' invalid)}}
@throw; // expected-error {{@throw (rethrow) used outside of a @catch block}}
diff --git a/test/SemaObjC/typedef-class.m b/test/SemaObjC/typedef-class.m
index c983195..bd68397 100644
--- a/test/SemaObjC/typedef-class.m
+++ b/test/SemaObjC/typedef-class.m
@@ -48,13 +48,13 @@ typedef NSObject < XCElementSpacerP > XCElementSpacer;
@protocol XCElementTogglerP < XCElementP > -(void) setDisplayed:(BOOL) displayed;
@end
-typedef NSObject < XCElementTogglerP > XCElementToggler;
+typedef NSObject < XCElementTogglerP > XCElementToggler; // expected-note {{previous definition is here}}
@interface XCElementRootFace:NSObject {} @end
@interface XCElementFace:XCElementRootFace {} @end
-@class XCElementToggler;
+@class XCElementToggler; // expected-warning {{redefinition of forward class 'XCElementToggler' of a typedef name of an object type is ignored}}
@interface XCRASlice:XCElementFace {} @end
diff --git a/test/SemaObjC/undeclared-selector.m b/test/SemaObjC/undeclared-selector.m
index af52fde..0914510 100644
--- a/test/SemaObjC/undeclared-selector.m
+++ b/test/SemaObjC/undeclared-selector.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wundeclared-selector -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wundeclared-selector -verify -Wno-objc-root-class %s
typedef struct objc_selector *SEL;
diff --git a/test/SemaObjC/undef-protocol-methods-1.m b/test/SemaObjC/undef-protocol-methods-1.m
index 44d384c6..15ba1a1 100644
--- a/test/SemaObjC/undef-protocol-methods-1.m
+++ b/test/SemaObjC/undef-protocol-methods-1.m
@@ -1,25 +1,25 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@protocol P1
-- (void) P1proto; // expected-note {{method declared here}}
-+ (void) ClsP1Proto; // expected-note {{method declared here}}
+- (void) P1proto; // expected-note {{method 'P1proto' declared here}}
++ (void) ClsP1Proto; // expected-note {{method 'ClsP1Proto' declared here}}
- (void) DefP1proto;
@end
@protocol P2
-- (void) P2proto; // expected-note {{method declared here}}
-+ (void) ClsP2Proto; // expected-note {{method declared here}}
+- (void) P2proto; // expected-note {{method 'P2proto' declared here}}
++ (void) ClsP2Proto; // expected-note {{method 'ClsP2Proto' declared here}}
@end
@protocol P3<P2>
-- (void) P3proto; // expected-note {{method declared here}}
-+ (void) ClsP3Proto; // expected-note {{method declared here}}
+- (void) P3proto; // expected-note {{method 'P3proto' declared here}}
++ (void) ClsP3Proto; // expected-note {{method 'ClsP3Proto' declared here}}
+ (void) DefClsP3Proto;
@end
@protocol PROTO<P1, P3>
-- (void) meth; // expected-note {{method declared here}}
-- (void) meth : (int) arg1; // expected-note {{method declared here}}
-+ (void) cls_meth : (int) arg1; // expected-note {{method declared here}}
+- (void) meth; // expected-note {{method 'meth' declared here}}
+- (void) meth : (int) arg1; // expected-note {{method 'meth:' declared here}}
++ (void) cls_meth : (int) arg1; // expected-note {{method 'cls_meth:' declared here}}
@end
@interface INTF <PROTO> // expected-note 3 {{required for direct or indirect protocol 'PROTO'}} \
@@ -29,7 +29,7 @@
@end
@implementation INTF // expected-warning {{incomplete implementation}} \
- // expected-warning 9 {{method in protocol not implemented [-Wprotocol}}
+ // expected-warning 9 {{in protocol not implemented}}
- (void) DefP1proto{}
+ (void) DefClsP3Proto{}
diff --git a/test/SemaObjC/undef-superclass-1.m b/test/SemaObjC/undef-superclass-1.m
index 41cf143..e8e03c5 100644
--- a/test/SemaObjC/undef-superclass-1.m
+++ b/test/SemaObjC/undef-superclass-1.m
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
-@class SUPER, Y; // expected-note 2 {{forward class is declared here}}
+@class SUPER, Y; // expected-note 2 {{forward declaration of class here}}
@interface INTF :SUPER // expected-error {{attempting to use the forward class 'SUPER' as superclass of 'INTF'}}
@end
diff --git a/test/SemaObjC/undefined-protocol-type-1.m b/test/SemaObjC/undefined-protocol-type-1.m
index 3be4425..f1a0802 100644
--- a/test/SemaObjC/undefined-protocol-type-1.m
+++ b/test/SemaObjC/undefined-protocol-type-1.m
@@ -5,5 +5,5 @@
@interface T
- (T<p2, p3, p1, p4>*) meth; // expected-error {{cannot find protocol declaration for 'p3'}}
-- (T<p2, p3, p1, p4>*) meth; // expected-error {{cannot find protocol declaration for 'p3'}}
+- (T<p2, p3, p1, p4>*) meth1; // expected-error {{cannot find protocol declaration for 'p3'}}
@end
diff --git a/test/SemaObjC/unimplemented-protocol-prop.m b/test/SemaObjC/unimplemented-protocol-prop.m
index fa3ed8e..1438cf5 100644
--- a/test/SemaObjC/unimplemented-protocol-prop.m
+++ b/test/SemaObjC/unimplemented-protocol-prop.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@protocol PROTOCOL0
@required
diff --git a/test/SemaObjC/unknown-anytype.m b/test/SemaObjC/unknown-anytype.m
new file mode 100644
index 0000000..38e058c
--- /dev/null
+++ b/test/SemaObjC/unknown-anytype.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -fdebugger-support -verify %s
+
+extern __unknown_anytype test0;
+extern __unknown_anytype test1();
+
+@interface A
+- (int*)getIntPtr;
+- (double*)getSomePtr;
+@end
+
+@interface B
+- (float*)getFloatPtr;
+- (short*)getSomePtr;
+@end
+
+void test_unknown_anytype_receiver() {
+ int *ip = [test0 getIntPtr];
+ float *fp = [test1() getFloatPtr];
+ double *dp = [test1() getSomePtr]; // okay: picks first method found
+ [[test0 unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ (void)(int)[[test0 unknownMethod] otherUnknownMethod];;
+ [[test1() unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ (void)(id)[[test1() unknownMethod] otherUnknownMethod];
+
+ if ([[test0 unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ }
+ if ([[test1() unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
+ }
+}
diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m
index 1ecf322..975b9a9 100644
--- a/test/SemaObjC/unused.m
+++ b/test/SemaObjC/unused.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -Wunused -Wunused-parameter -fsyntax-only
+// RUN: %clang_cc1 -verify -Wunused -Wunused-parameter -fsyntax-only -Wno-objc-root-class %s
int printf(const char *, ...);
diff --git a/test/SemaObjC/warn-deprecated-implementations.m b/test/SemaObjC/warn-deprecated-implementations.m
index 60da7b0..919b221 100644
--- a/test/SemaObjC/warn-deprecated-implementations.m
+++ b/test/SemaObjC/warn-deprecated-implementations.m
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wdeprecated-implementations -verify -Wno-objc-root-class %s
// rdar://8973810
@protocol P
-- (void) D __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) D __attribute__((deprecated)); // expected-note {{method 'D' declared here}}
@end
@interface A <P>
-+ (void)F __attribute__((deprecated)); // expected-note {{method declared here}}
++ (void)F __attribute__((deprecated)); // expected-note {{method 'F' declared here}}
@end
@interface A()
-- (void) E __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) E __attribute__((deprecated)); // expected-note {{method 'E' declared here}}
@end
@implementation A
@@ -34,7 +34,7 @@ __attribute__((deprecated))
@end
@interface BASE
-- (void) B __attribute__((deprecated)); // expected-note {{method declared here}}
+- (void) B __attribute__((deprecated)); // expected-note {{method 'B' declared here}}
@end
@interface SUB : BASE
diff --git a/test/SemaObjC/warn-forward-class-attr-deprecated.m b/test/SemaObjC/warn-forward-class-attr-deprecated.m
new file mode 100644
index 0000000..854ff69
--- /dev/null
+++ b/test/SemaObjC/warn-forward-class-attr-deprecated.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// rdar://10290322
+
+@class ABGroupImportFilesScope; // expected-note {{forward declaration of class here}}
+
+@interface I1
+- (id) filenames __attribute__((deprecated));
+@end
+
+@interface I2
+- (id) Meth : (ABGroupImportFilesScope*) scope;
+- (id) filenames __attribute__((deprecated));
+- (id)initWithAccount: (id)account filenames:(id)filenames;
+@end
+
+@implementation I2
+- (id) Meth : (ABGroupImportFilesScope*) scope
+{
+ id p = [self initWithAccount : 0 filenames :[scope filenames]]; // expected-warning {{'filenames' maybe deprecated because receiver type is unknown}}
+ return 0;
+}
+- (id) filenames { return 0; }
+- (id)initWithAccount: (id)account filenames:(id)filenames { return 0; }
+@end
diff --git a/test/SemaObjC/warn-implicit-atomic-property.m b/test/SemaObjC/warn-implicit-atomic-property.m
index ec8e84e..887a286 100644
--- a/test/SemaObjC/warn-implicit-atomic-property.m
+++ b/test/SemaObjC/warn-implicit-atomic-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wimplicit-atomic-properties -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wimplicit-atomic-properties -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
// rdar://8774580
@interface Super
@@ -8,6 +8,6 @@
@property int P3; // expected-note {{property declared here}}
@end
-@implementation Super // expected-warning {{property is assumed atomic when auto-synthesizing the property [-Wimplicit-atomic-properties]}}
-@synthesize P,P1,P2; // expected-warning {{property is assumed atomic by default [-Wimplicit-atomic-properties]}}
+@implementation Super // expected-warning {{property is assumed atomic when auto-synthesizing the property}}
+@synthesize P,P1,P2; // expected-warning {{property is assumed atomic by default}}
@end
diff --git a/test/SemaObjC/warn-missing-super.m b/test/SemaObjC/warn-missing-super.m
index 0169a61..02b8165 100644
--- a/test/SemaObjC/warn-missing-super.m
+++ b/test/SemaObjC/warn-missing-super.m
@@ -1,5 +1,6 @@
@protocol NSCopying @end
+__attribute__((objc_root_class))
@interface NSObject <NSCopying>
- (void)dealloc;
@end
@@ -40,18 +41,18 @@
@end
// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
-// CHECK: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
+// CHECK: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
// CHECK: 1 warning generated.
// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
-// CHECK-GC: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
-// CHECK-GC: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
+// CHECK-GC: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
// CHECK-GC: 2 warnings generated.
// RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
-// CHECK-GC-ONLY: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
+// CHECK-GC-ONLY: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
// CHECK-GC-ONLY: 1 warning generated.
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
-// CHECK-ARC: warn-missing-super.m:35:4: error: ARC forbids explicit message send of 'dealloc'
+// CHECK-ARC: warn-missing-super.m:36:4: error: ARC forbids explicit message send of 'dealloc'
// CHECK-ARC: 1 error generated.
diff --git a/test/SemaObjC/warn-retain-cycle.m b/test/SemaObjC/warn-retain-cycle.m
index 596858f..00fd234 100644
--- a/test/SemaObjC/warn-retain-cycle.m
+++ b/test/SemaObjC/warn-retain-cycle.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
@interface Test0
- (void) setBlock: (void(^)(void)) block;
@@ -89,3 +89,37 @@ void test2_helper(id);
};
}
@end
+
+
+@interface NSOperationQueue {}
+- (void)addOperationWithBlock:(void (^)(void))block;
+- (void)addSomethingElse:(void (^)(void))block;
+
+@end
+
+@interface Test3 {
+ NSOperationQueue *myOperationQueue;
+ unsigned count;
+}
+@end
+void doSomething(unsigned v);
+@implementation Test3
+- (void) test {
+ // 'addOperationWithBlock:' is specifically whitelisted.
+ [myOperationQueue addOperationWithBlock:^() { // no-warning
+ if (count > 20) {
+ doSomething(count);
+ }
+ }];
+}
+- (void) test_positive {
+ // Sanity check that we are really whitelisting 'addOperationWithBlock:' and not doing
+ // something funny.
+ [myOperationQueue addSomethingElse:^() { // expected-note {{block will be retained by an object strongly retained by the captured object}}
+ if (count > 20) { // expected-warning {{capturing 'self' strongly in this block is likely to lead to a retain cycle}}
+ doSomething(count);
+ }
+ }];
+}
+@end
+
diff --git a/test/SemaObjC/warn-strict-selector-match.m b/test/SemaObjC/warn-strict-selector-match.m
index 8ac0ca4..34f1712 100644
--- a/test/SemaObjC/warn-strict-selector-match.m
+++ b/test/SemaObjC/warn-strict-selector-match.m
@@ -8,7 +8,7 @@
-(float) method; // expected-note {{also found}}
@end
-int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found [-Wstrict-selector-match]}}
+int main() { [(id)0 method]; } // expected-warning {{multiple methods named 'method' found}}
@interface Object @end
@@ -24,7 +24,7 @@ id foo(void) {
Object *obj = 0;
id obj2 = obj;
[obj setWindow:0]; // expected-warning {{Object' may not respond to 'setWindow:'}}
- [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found [-Wstrict-selector-match]}}
+ [obj2 setWindow:0]; // expected-warning {{multiple methods named 'setWindow:' found}}
return obj;
}
@@ -54,7 +54,7 @@ id foo(void) {
}
+ (NTGridDataObject*)dataObject:(id<MyObject, MyCoding>)data
{
- NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found [-Wstrict-selector-match]}} \
+ NTGridDataObject *result = [(id)0 initWithData:data]; // expected-warning {{multiple methods named 'initWithData:' found}} \
expected-warning {{sending 'id<MyObject,MyCoding>' to parameter of incompatible type 'Object *'}}
return result;
}
diff --git a/test/SemaObjC/warn-unreachable.m b/test/SemaObjC/warn-unreachable.m
new file mode 100644
index 0000000..832cbd2
--- /dev/null
+++ b/test/SemaObjC/warn-unreachable.m
@@ -0,0 +1,17 @@
+// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value -Wno-covered-switch-default
+
+// This previously triggered a warning from -Wunreachable-code because of
+// a busted CFG.
+typedef signed char BOOL;
+BOOL radar10989084() {
+ @autoreleasepool { // no-warning
+ return __objc_yes;
+ }
+}
+
+// Test the warning works.
+void test_unreachable() {
+ return;
+ return; // expected-warning {{will never be executed}}
+}
+
diff --git a/test/SemaObjC/warn-weak-field.m b/test/SemaObjC/warn-weak-field.m
index ead454a..e7b0fe2 100644
--- a/test/SemaObjC/warn-weak-field.m
+++ b/test/SemaObjC/warn-weak-field.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify %s
-// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fsyntax-only -fobjc-gc -verify -Wno-objc-root-class %s
struct S {
__weak id w; // expected-warning {{__weak attribute cannot be specified on a field declaration}}
diff --git a/test/SemaObjC/weak-property.m b/test/SemaObjC/weak-property.m
index bea6628..8a2adf9 100644
--- a/test/SemaObjC/weak-property.m
+++ b/test/SemaObjC/weak-property.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://8899430
@interface WeakPropertyTest {
diff --git a/test/SemaObjC/weak-receiver-warn.m b/test/SemaObjC/weak-receiver-warn.m
new file mode 100644
index 0000000..f3955da
--- /dev/null
+++ b/test/SemaObjC/weak-receiver-warn.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wreceiver-is-weak -verify %s
+// rdar://10225276
+
+@interface Test0
+- (void) setBlock: (void(^)(void)) block;
+- (void) addBlock: (void(^)(void)) block;
+- (void) actNow;
+@end
+
+void test0(Test0 *x) {
+ __weak Test0 *weakx = x;
+ [x addBlock: ^{ [weakx actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ [x setBlock: ^{ [weakx actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ x.block = ^{ [weakx actNow]; }; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+
+ [weakx addBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ [weakx setBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}}
+ weakx.block = ^{ [x actNow]; };
+}
diff --git a/test/SemaObjCXX/NSString-type.mm b/test/SemaObjCXX/NSString-type.mm
new file mode 100644
index 0000000..1033866
--- /dev/null
+++ b/test/SemaObjCXX/NSString-type.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+}
+
diff --git a/test/SemaObjCXX/arc-0x.mm b/test/SemaObjCXX/arc-0x.mm
index be9f1dc..28eec51 100644
--- a/test/SemaObjCXX/arc-0x.mm
+++ b/test/SemaObjCXX/arc-0x.mm
@@ -30,3 +30,24 @@ void deduction(id obj) {
} @catch (auto e) { // expected-error {{'auto' not allowed in exception declaration}}
}
}
+
+// rdar://problem/11068137
+void test1a() {
+ __autoreleasing id p; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1b() {
+ __autoreleasing id v;
+ __autoreleasing id &p = v; // expected-note 2 {{'p' declared here}}
+ (void) [&p] {};
+ (void) [p] {}; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+ (void) [=] { (void) p; }; // expected-error {{cannot capture __autoreleasing variable in a lambda by copy}}
+}
+void test1c() {
+ __autoreleasing id v; // expected-note {{'v' declared here}}
+ __autoreleasing id &p = v;
+ (void) ^{ (void) p; };
+ (void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}}
+}
diff --git a/test/SemaObjCXX/arc-overloading.mm b/test/SemaObjCXX/arc-overloading.mm
index dad5d0f..a749417 100644
--- a/test/SemaObjCXX/arc-overloading.mm
+++ b/test/SemaObjCXX/arc-overloading.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks %s
+// RUN: %clang_cc1 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -verify -fblocks -Wno-objc-root-class %s
// Simple ownership conversions + diagnostics.
int &f0(id __strong const *); // expected-note{{candidate function not viable: 1st argument ('__weak id *') has __weak ownership, but parameter has __strong ownership}}
diff --git a/test/SemaObjCXX/arc-ppe.mm b/test/SemaObjCXX/arc-ppe.mm
new file mode 100644
index 0000000..c9ff811
--- /dev/null
+++ b/test/SemaObjCXX/arc-ppe.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-arc %s
+
+// Make sure the ARC auto-deduction of id* in unevaluated contexts
+// works correctly in cases where we can't immediately tell whether the
+// context is unevaluated.
+
+namespace std {
+ class type_info;
+}
+
+int& NP(void*);
+void test1() { (void)typeid(NP((void*)(id*)0)); }
+
+class Poly { virtual ~Poly(); };
+Poly& P(void*);
+void test2() { (void)typeid(P((void*)(id*)0)); } // expected-error {{pointer to non-const type 'id'}}
diff --git a/test/SemaObjCXX/arc-templates.mm b/test/SemaObjCXX/arc-templates.mm
index 931b21f..9eca846 100644
--- a/test/SemaObjCXX/arc-templates.mm
+++ b/test/SemaObjCXX/arc-templates.mm
@@ -97,8 +97,8 @@ int check_make_weak2[is_same<make_weak<__autoreleasing id>::type, __weak id>::va
template<typename T>
struct make_weak_fail {
typedef T T_type;
- typedef __weak T_type type; // expected-error{{the type 'T_type' (aka '__weak id') already has retainment attributes set on it}} \
- // expected-error{{the type 'T_type' (aka '__strong id') already has retainment attributes set on it}}
+ typedef __weak T_type type; // expected-error{{the type 'T_type' (aka '__weak id') is already explicitly ownership-qualified}} \
+ // expected-error{{the type 'T_type' (aka '__strong id') is already explicitly ownership-qualified}}
};
int check_make_weak_fail0[is_same<make_weak_fail<__weak id>::type, __weak id>::value? 1 : -1]; // expected-note{{in instantiation of template class 'make_weak_fail<__weak id>' requested here}}
diff --git a/test/SemaObjCXX/arc-type-conversion.mm b/test/SemaObjCXX/arc-type-conversion.mm
index 48d1e48..fd42513 100644
--- a/test/SemaObjCXX/arc-type-conversion.mm
+++ b/test/SemaObjCXX/arc-type-conversion.mm
@@ -12,10 +12,7 @@ void * cvt(id arg) // expected-note{{candidate function not viable: cannot conve
(void)(__autoreleasing id**)voidp_val;
(void)(void*)voidp_val;
(void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed}}
- cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
- // expected-error {{no matching function for call to 'cvt'}} \
- // expected-note{{use __bridge to convert directly (no change in ownership)}} \
- // expected-note{{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+ cvt((void*)arg); // expected-error {{no matching function for call to 'cvt'}}
cvt(0);
(void)(__strong id**)(0);
diff --git a/test/SemaObjCXX/arc-type-traits.mm b/test/SemaObjCXX/arc-type-traits.mm
index b876018..9877870 100644
--- a/test/SemaObjCXX/arc-type-traits.mm
+++ b/test/SemaObjCXX/arc-type-traits.mm
@@ -53,16 +53,16 @@ TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
// __is_literal
-TRAIT_IS_FALSE(__is_literal, __strong id);
-TRAIT_IS_FALSE(__is_literal, __weak id);
-TRAIT_IS_FALSE(__is_literal, __autoreleasing id);
-TRAIT_IS_FALSE(__is_literal, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_literal, __strong id);
+TRAIT_IS_TRUE(__is_literal, __weak id);
+TRAIT_IS_TRUE(__is_literal, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal, __unsafe_unretained id);
// __is_literal_type
-TRAIT_IS_FALSE(__is_literal_type, __strong id);
-TRAIT_IS_FALSE(__is_literal_type, __weak id);
-TRAIT_IS_FALSE(__is_literal_type, __autoreleasing id);
-TRAIT_IS_FALSE(__is_literal_type, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_literal_type, __strong id);
+TRAIT_IS_TRUE(__is_literal_type, __weak id);
+TRAIT_IS_TRUE(__is_literal_type, __autoreleasing id);
+TRAIT_IS_TRUE(__is_literal_type, __unsafe_unretained id);
// __is_pod
TRAIT_IS_FALSE(__is_pod, __strong id);
diff --git a/test/SemaObjCXX/arc-unavailable-for-weakref.mm b/test/SemaObjCXX/arc-unavailable-for-weakref.mm
index 24593ce..2a80aeb 100644
--- a/test/SemaObjCXX/arc-unavailable-for-weakref.mm
+++ b/test/SemaObjCXX/arc-unavailable-for-weakref.mm
@@ -15,7 +15,8 @@ int main() {
id obj;
ns1 = (__weak sub *)obj; // expected-error {{assignment of a weak-unavailable object to a __weak object}} \
- // expected-error {{class is incompatible with __weak references}}
+ // expected-error {{class is incompatible with __weak references}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
// rdar://9732636
@@ -30,7 +31,8 @@ NOWEAK * Test1() {
weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
__weak id weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
- return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}}
+ return (__weak id)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK *' to a __weak object of type '__weak id'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
@protocol P @end
@@ -42,6 +44,7 @@ NOWEAK<P, P1> * Test2() {
weak1 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
__weak id<P> weak2 = strong1; // expected-error {{assignment of a weak-unavailable object to a __weak object}}
- return (__weak id<P, P1>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P,P1>'}}
+ return (__weak id<P, P1>)strong1; // expected-error {{cast of weak-unavailable object of type 'NOWEAK<P,P1> *' to a __weak object of type '__weak id<P,P1>'}} \
+ // expected-error {{explicit ownership qualifier on cast result has no effect}}
}
diff --git a/test/SemaObjCXX/arc-unbridged-cast.mm b/test/SemaObjCXX/arc-unbridged-cast.mm
new file mode 100644
index 0000000..0b3ba07
--- /dev/null
+++ b/test/SemaObjCXX/arc-unbridged-cast.mm
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+
+typedef const struct __CFString * CFStringRef;
+typedef const void * CFTypeRef;
+extern "C" CFTypeRef CFBridgingRetain(id X);
+extern "C" id CFBridgingRelease(CFTypeRef);
+
+
+@interface Object
+@property CFStringRef property;
+- (CFStringRef) implicitProperty;
+- (CFStringRef) newString;
+- (CFStringRef) makeString;
+@end
+
+extern Object *object;
+
+// rdar://9744349
+id test0(void) {
+ id p1 = (id)[object property];
+ id p2 = (__bridge_transfer id)[object property];
+ id p3 = (__bridge id)[object property];
+ return (id) object.property;
+}
+
+// rdar://10140692
+CFStringRef unauditedString(void);
+CFStringRef plusOneString(void) __attribute__((cf_returns_retained));
+
+#pragma clang arc_cf_code_audited begin
+CFStringRef auditedString(void);
+CFStringRef auditedCreateString(void);
+#pragma clang arc_cf_code_audited end
+
+void test1(int cond) {
+ id x;
+ x = (id) auditedString();
+ x = (id) (cond ? auditedString() : (void*) 0);
+ x = (id) (cond ? (void*) 0 : auditedString());
+ x = (id) (cond ? (CFStringRef) @"help" : auditedString());
+
+ x = (id) unauditedString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? unauditedString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+
+ x = (id) [object property];
+ x = (id) (cond ? [object property] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object property]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object property]);
+
+ x = (id) object.property;
+ x = (id) (cond ? object.property : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.property);
+ x = (id) (cond ? (CFStringRef) @"help" : object.property);
+
+ x = (id) object.implicitProperty;
+ x = (id) (cond ? object.implicitProperty : (void*) 0);
+ x = (id) (cond ? (void*) 0 : object.implicitProperty);
+ x = (id) (cond ? (CFStringRef) @"help" : object.implicitProperty);
+
+ x = (id) [object makeString];
+ x = (id) (cond ? [object makeString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object makeString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object makeString]);
+
+ x = (id) [object newString];
+ x = (id) (cond ? [object newString] : (void*) 0);
+ x = (id) (cond ? (void*) 0 : [object newString]);
+ x = (id) (cond ? (CFStringRef) @"help" : [object newString]); // a bit questionable
+}
+
+// rdar://problem/10246264
+@interface CFTaker
+- (void) takeOrdinary: (CFStringRef) arg;
+- (void) takeVariadic: (int) n, ...;
+- (void) takeConsumed: (CFStringRef __attribute__((cf_consumed))) arg;
+@end
+void testCFTaker(CFTaker *taker, id string) {
+ [taker takeOrdinary: (CFStringRef) string];
+ [taker takeVariadic: 1, (CFStringRef) string];
+ [taker takeConsumed: (CFStringRef) string]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
+
+void takeCFOrdinaryUnaudited(CFStringRef arg);
+void takeCFVariadicUnaudited(int n, ...);
+void takeCFConsumedUnaudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited begin
+void takeCFOrdinaryAudited(CFStringRef arg);
+void takeCFVariadicAudited(int n, ...);
+void takeCFConsumedAudited(CFStringRef __attribute__((cf_consumed)) arg);
+#pragma clang arc_cf_code_audited end
+
+void testTakerFunctions(id string) {
+ takeCFOrdinaryUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFVariadicUnaudited(1, (CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+ takeCFConsumedUnaudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ void (*taker)(CFStringRef) = 0;
+ taker((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+
+ takeCFOrdinaryAudited((CFStringRef) string);
+ takeCFVariadicAudited(1, (CFStringRef) string);
+ takeCFConsumedAudited((CFStringRef) string); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef'}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRetain call to}}
+}
diff --git a/test/SemaObjCXX/blocks.mm b/test/SemaObjCXX/blocks.mm
index c91fd10..09d614d 100644
--- a/test/SemaObjCXX/blocks.mm
+++ b/test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
@protocol NSObject;
void bar(id(^)(void));
diff --git a/test/SemaObjCXX/composite-objc-pointertype.mm b/test/SemaObjCXX/composite-objc-pointertype.mm
index 0d9a938..684f633 100644
--- a/test/SemaObjCXX/composite-objc-pointertype.mm
+++ b/test/SemaObjCXX/composite-objc-pointertype.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo
@end
diff --git a/test/SemaObjCXX/cstyle-block-pointer-cast.mm b/test/SemaObjCXX/cstyle-block-pointer-cast.mm
index 72f5283..0f982ba 100644
--- a/test/SemaObjCXX/cstyle-block-pointer-cast.mm
+++ b/test/SemaObjCXX/cstyle-block-pointer-cast.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
// radar 7562285
typedef int (^blocktype)(int a, int b);
diff --git a/test/SemaObjCXX/cxxoperator-selector.mm b/test/SemaObjCXX/cxxoperator-selector.mm
index 6dd36a8..f1aecab 100644
--- a/test/SemaObjCXX/cxxoperator-selector.mm
+++ b/test/SemaObjCXX/cxxoperator-selector.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar:// 8328250
@class NSDate;
diff --git a/test/SemaObjCXX/debugger-cast-result-to-id.mm b/test/SemaObjCXX/debugger-cast-result-to-id.mm
new file mode 100644
index 0000000..cd7aa7b
--- /dev/null
+++ b/test/SemaObjCXX/debugger-cast-result-to-id.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fdebugger-support -fdebugger-cast-result-to-id -funknown-anytype -fsyntax-only -verify %s
+
+// rdar://problem/9416370
+namespace test0 {
+ void test(id x) {
+ if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
+ [x foo];
+ }
+}
+
+// rdar://10988847
+@class NSString; // expected-note {{forward declaration of class here}}
+namespace test1 {
+ void rdar10988847() {
+ id s = [NSString stringWithUTF8String:"foo"]; // expected-warning {{receiver 'NSString' is a forward class and corresponding @interface may not exist}}
+ }
+}
diff --git a/test/SemaObjCXX/fragile-abi-object-assign.m b/test/SemaObjCXX/fragile-abi-object-assign.m
new file mode 100644
index 0000000..5bb3ac6
--- /dev/null
+++ b/test/SemaObjCXX/fragile-abi-object-assign.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
+// rdar://10731065
+
+@interface MyView {}
+@end
+
+@implementation MyViewTemplate // expected-warning {{cannot find interface declaration for 'MyViewTemplate'}}
+- (id) createRealObject {
+ id realObj;
+ *(MyView *) realObj = *(MyView *) self; // expected-error {{cannot assign to class object}}
+}
+@end
+
diff --git a/test/SemaObjCXX/goto.mm b/test/SemaObjCXX/goto.mm
index 67df1f4..55bde99 100644
--- a/test/SemaObjCXX/goto.mm
+++ b/test/SemaObjCXX/goto.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// PR9495
struct NonPOD { NonPOD(); ~NonPOD(); };
diff --git a/test/SemaObjCXX/instantiate-expr.mm b/test/SemaObjCXX/instantiate-expr.mm
index 08be5f7..75a5b7e 100644
--- a/test/SemaObjCXX/instantiate-expr.mm
+++ b/test/SemaObjCXX/instantiate-expr.mm
@@ -20,10 +20,11 @@ template<unsigned N, typename T, typename U, typename V>
void f(U value, V value2) {
get_an_A(N)->ivar = value; // expected-error{{assigning to 'int' from incompatible type 'int *'}}
get_an_A(N).prop = value2; // expected-error{{assigning to 'int' from incompatible type 'double *'}}
- T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}}
+ T c = get_an_id(N)->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \
+ // expected-warning 5 {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
}
-template void f<6, Class>(int, int);
+template void f<6, Class>(int, int); // expected-note{{in instantiation of}}
template void f<7, Class>(int*, int); // expected-note{{in instantiation of}}
template void f<8, Class>(int, double*); // expected-note{{in instantiation of}}
template void f<9, int>(int, int); // expected-note{{in instantiation of}}
@@ -44,10 +45,11 @@ template void f2(A*, int, double*); // expected-note{{instantiation of}}
// an isa.
template<typename T, typename U>
void f3(U ptr) {
- T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}}
+ T c = ptr->isa; // expected-error{{cannot initialize a variable of type 'int' with an lvalue of type 'Class'}} \
+ // expected-warning 2 {{direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()}}
}
-template void f3<Class>(id);
+template void f3<Class>(id); // expected-note{{in instantiation of}}
template void f3<int>(id); // expected-note{{instantiation of}}
// Implicit setter/getter
diff --git a/test/SemaObjCXX/instantiate-method-return.mm b/test/SemaObjCXX/instantiate-method-return.mm
index b8ba4af..2a3ae32 100644
--- a/test/SemaObjCXX/instantiate-method-return.mm
+++ b/test/SemaObjCXX/instantiate-method-return.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// PR7386
@class NSObject;
diff --git a/test/SemaObjCXX/ivar-construct.mm b/test/SemaObjCXX/ivar-construct.mm
index da066e9..535d2a0 100644
--- a/test/SemaObjCXX/ivar-construct.mm
+++ b/test/SemaObjCXX/ivar-construct.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
struct Y {
Y();
diff --git a/test/SemaObjCXX/ivar-lookup.mm b/test/SemaObjCXX/ivar-lookup.mm
index bb26f48..fc99c15 100644
--- a/test/SemaObjCXX/ivar-lookup.mm
+++ b/test/SemaObjCXX/ivar-lookup.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Ivar
- (float*)method;
@end
diff --git a/test/SemaObjCXX/literals.mm b/test/SemaObjCXX/literals.mm
new file mode 100644
index 0000000..eed6765
--- /dev/null
+++ b/test/SemaObjCXX/literals.mm
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fblocks %s
+
+// rdar://11231426
+typedef bool BOOL;
+
+void y(BOOL (^foo)());
+
+void x() {
+ y(^{
+ return __objc_yes;
+ });
+}
+
+@protocol NSCopying
+- copy;
+@end
+
+@interface NSObject
+@end
+
+@interface NSNumber : NSObject <NSCopying>
+-copy;
+@end
+
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
+@end
+
+@interface NSArray : NSObject <NSCopying>
+-copy;
+@end
+
+@interface NSArray (NSArrayCreation)
++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
+@end
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id<NSCopying> [])keys count:(unsigned long)cnt;
+@end
+
+template<typename T>
+struct ConvertibleTo {
+ operator T();
+};
+
+template<typename T>
+struct ExplicitlyConvertibleTo {
+ explicit operator T();
+};
+
+template<typename T>
+class PrivateConvertibleTo {
+private:
+ operator T(); // expected-note{{declared private here}}
+};
+
+template<typename T> ConvertibleTo<T> makeConvertible();
+
+struct X {
+ ConvertibleTo<id> x;
+ ConvertibleTo<id> get();
+};
+
+template<typename T> T test_numeric_instantiation() {
+ return @-17.42;
+}
+
+template id test_numeric_instantiation();
+
+void test_convertibility(ConvertibleTo<NSArray*> toArray,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSArray *> toArrayExplicit) {
+ id array = @[
+ toArray,
+ toId,
+ toBlock,
+ toInt // expected-error{{collection element of type 'ConvertibleTo<int>' is not an Objective-C object}}
+ ];
+ id array2 = @[ toArrayExplicit ]; // expected-error{{collection element of type 'ExplicitlyConvertibleTo<NSArray *>' is not an Objective-C object}}
+
+ id array3 = @[
+ makeConvertible<id>(),
+ makeConvertible<id>, // expected-error{{collection element of type 'ConvertibleTo<id> ()' is not an Objective-C object}}
+ ];
+
+ X x;
+ id array4 = @[ x.x ];
+ id array5 = @[ x.get ]; // expected-error{{reference to non-static member function must be called}}
+ id array6 = @[ PrivateConvertibleTo<NSArray*>() ]; // expected-error{{operator NSArray *' is a private member of 'PrivateConvertibleTo<NSArray *>'}}
+}
+
+template<typename T>
+void test_array_literals(T t) {
+ id arr = @[ @17, t ]; // expected-error{{collection element of type 'int' is not an Objective-C object}}
+}
+
+template void test_array_literals(id);
+template void test_array_literals(NSArray*);
+template void test_array_literals(int); // expected-note{{in instantiation of function template specialization 'test_array_literals<int>' requested here}}
+
+template<typename T, typename U>
+void test_dictionary_literals(T t, U u) {
+ NSObject *object;
+ id dict = @{
+ @17 : t, // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ u : @42 // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ };
+
+ id dict2 = @{
+ object : @"object" // expected-error{{cannot initialize a parameter of type 'const id<NSCopying>' with an rvalue of type 'NSObject *'}}
+ };
+}
+
+template void test_dictionary_literals(id, NSArray*);
+template void test_dictionary_literals(NSArray*, id);
+template void test_dictionary_literals(int, id); // expected-note{{in instantiation of function template specialization 'test_dictionary_literals<int, id>' requested here}}
+template void test_dictionary_literals(id, int); // expected-note{{in instantiation of function template specialization 'test_dictionary_literals<id, int>' requested here}}
+
+template<typename ...Args>
+void test_bad_variadic_array_literal(Args ...args) {
+ id arr1 = @[ args ]; // expected-error{{initializer contains unexpanded parameter pack 'args'}}
+}
+
+template<typename ...Args>
+void test_variadic_array_literal(Args ...args) {
+ id arr1 = @[ args... ]; // expected-error{{collection element of type 'int' is not an Objective-C object}}
+}
+template void test_variadic_array_literal(id);
+template void test_variadic_array_literal(id, NSArray*);
+template void test_variadic_array_literal(id, int, NSArray*); // expected-note{{in instantiation of function template specialization 'test_variadic_array_literal<id, int, NSArray *>' requested here}}
+
+template<typename ...Args>
+void test_bad_variadic_dictionary_literal(Args ...args) {
+ id dict = @{ args : @17 }; // expected-error{{initializer contains unexpanded parameter pack 'args'}}
+}
+
+// Test array literal pack expansions.
+template<typename T, typename U>
+struct pair {
+ T first;
+ U second;
+};
+
+template<typename T, typename ...Ts, typename ... Us>
+void test_variadic_dictionary_expansion(T t, pair<Ts, Us>... key_values) {
+ id dict = @{
+ t : key_values.second ..., // expected-error{{collection element of type 'int' is not an Objective-C object}}
+ key_values.first : key_values.second ..., // expected-error{{collection element of type 'float' is not an Objective-C object}}
+ key_values.second : t ...
+ };
+}
+
+template void test_variadic_dictionary_expansion(id,
+ pair<NSNumber*, id>,
+ pair<id, ConvertibleTo<id>>);
+template void test_variadic_dictionary_expansion(NSNumber *, // expected-note{{in instantiation of function template specialization}}
+ pair<NSNumber*, int>,
+ pair<id, ConvertibleTo<id>>);
+template void test_variadic_dictionary_expansion(NSNumber *, // expected-note{{in instantiation of function template specialization}}
+ pair<NSNumber*, id>,
+ pair<float, ConvertibleTo<id>>);
+
+// Test parsing
+struct key {
+ static id value;
+};
+
+id key;
+id value;
+
+void test_dictionary_colon() {
+ id dict = @{ key : value };
+}
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 51a15d5..5ac2f40 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
@interface I1
- (int*)method;
@end
diff --git a/test/SemaObjCXX/objc-container-subscripting.mm b/test/SemaObjCXX/objc-container-subscripting.mm
new file mode 100644
index 0000000..c835cbe
--- /dev/null
+++ b/test/SemaObjCXX/objc-container-subscripting.mm
@@ -0,0 +1,138 @@
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fsyntax-only -std=c++11 -verify %s
+
+@class NSArray;
+
+@interface NSMutableDictionary
+- (id)objectForKeyedSubscript:(id)key;
+- (void)setObject:(id)object forKeyedSubscript:(id)key; // expected-note {{passing argument to parameter 'object' here}}
+@end
+
+template<typename T, typename U, typename O>
+void test_dictionary_subscripts(T base, U key, O obj) {
+ base[key] = obj; // expected-error {{expected method to write array element not found on object of type 'NSMutableDictionary *'}} \
+ // expected-error {{cannot initialize a parameter of type 'id' with an lvalue of type 'int'}}
+ obj = base[key]; // expected-error {{expected method to read array element not found on object of type 'NSMutableDictionary *'}} \
+ // expected-error {{assigning to 'int' from incompatible type 'id'}}
+
+}
+
+template void test_dictionary_subscripts(NSMutableDictionary*, id, NSArray *ns);
+
+template void test_dictionary_subscripts(NSMutableDictionary*, NSArray *ns, id);
+
+template void test_dictionary_subscripts(NSMutableDictionary*, int, id); // expected-note {{in instantiation of function template specialization 'test_dictionary_subscripts<NSMutableDictionary *, int, id>' requested here}}
+
+template void test_dictionary_subscripts(NSMutableDictionary*, id, int); // expected-note {{in instantiation of function template specialization 'test_dictionary_subscripts<NSMutableDictionary *, id, int>' requested here}}
+
+
+@interface NSMutableArray
+- (id)objectAtIndexedSubscript:(int)index;
+- (void)setObject:(id)object atIndexedSubscript:(int)index;
+@end
+
+template<typename T, typename U, typename O>
+void test_array_subscripts(T base, U index, O obj) {
+ base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+ obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+}
+
+template void test_array_subscripts(NSMutableArray *, int, id);
+template void test_array_subscripts(NSMutableArray *, short, id);
+enum E { e };
+
+template void test_array_subscripts(NSMutableArray *, E, id);
+
+template void test_array_subscripts(NSMutableArray *, double, id); // expected-note {{in instantiation of function template specialization 'test_array_subscripts<NSMutableArray *, double, id>' requested here}}
+
+template<typename T>
+struct ConvertibleTo {
+ operator T();
+};
+
+template<typename T>
+struct ExplicitlyConvertibleTo {
+ explicit operator T();
+};
+
+template<typename T> ConvertibleTo<T> makeConvertible();
+
+struct X {
+ ConvertibleTo<id> x;
+ ConvertibleTo<id> get();
+};
+
+NSMutableArray *test_array_convertibility(ConvertibleTo<NSMutableArray*> toArray,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSMutableArray *> toArrayExplicit) {
+ id array;
+
+ array[1] = toArray;
+
+ array[4] = array[1];
+
+ toArrayExplicit[2] = toId; // expected-error {{type 'ExplicitlyConvertibleTo<NSMutableArray *>' does not provide a subscript operator}}
+
+ return array[toInt];
+
+}
+
+id test_dict_convertibility(ConvertibleTo<NSMutableDictionary*> toDict,
+ ConvertibleTo<id> toId,
+ ConvertibleTo<int (^)(int)> toBlock,
+ ConvertibleTo<int> toInt,
+ ExplicitlyConvertibleTo<NSMutableDictionary *> toDictExplicit) {
+
+
+ NSMutableDictionary *Dict;
+ id Id;
+ Dict[toId] = toBlock;
+
+ Dict[toBlock] = toBlock;
+
+ Dict[toBlock] = Dict[toId] = Dict[toBlock];
+
+ Id = toDictExplicit[toId] = Id; // expected-error {{no viable overloaded operator[] for type 'ExplicitlyConvertibleTo<NSMutableDictionary *>'}}
+
+ return Dict[toBlock];
+}
+
+
+template<typename ...Args>
+void test_bad_variadic_array_subscripting(Args ...args) {
+ id arr1;
+ arr1[3] = args; // expected-error {{expression contains unexpanded parameter pack 'args'}}
+}
+
+template<typename ...Args>
+void test_variadic_array_subscripting(Args ...args) {
+ id arr[] = {args[3]...}; // which means: {a[3], b[3], c[3]};
+}
+
+template void test_variadic_array_subscripting(id arg1, NSMutableArray* arg2, id arg3);
+
+@class Key;
+
+template<typename Index, typename ...Args>
+void test_variadic_dictionary_subscripting(Index I, Args ...args) {
+ id arr[] = {args[I]...}; // which means: {a[3], b[3], c[3]};
+}
+
+template void test_variadic_dictionary_subscripting(Key *key, id arg1, NSMutableDictionary* arg2, id arg3);
+
+template<int N>
+id get(NSMutableArray *array) {
+ return array[N]; // array[N] should be a value- and instantiation-dependent ObjCSubscriptRefExpr
+}
+
+struct WeirdIndex {
+ operator int(); // expected-note {{type conversion function declared here}}
+ operator id(); // expected-note {{type conversion function declared here}}
+};
+
+id FUNC(WeirdIndex w) {
+ NSMutableArray *array;
+ return array[w]; // expected-error {{indexing expression is invalid because subscript type 'WeirdIndex' has multiple type conversion functions}}
+}
+
diff --git a/test/SemaObjCXX/objc-decls-inside-namespace.mm b/test/SemaObjCXX/objc-decls-inside-namespace.mm
index f68078b..0702071 100644
--- a/test/SemaObjCXX/objc-decls-inside-namespace.mm
+++ b/test/SemaObjCXX/objc-decls-inside-namespace.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
namespace C {
diff --git a/test/SemaObjCXX/objc-extern-c.mm b/test/SemaObjCXX/objc-extern-c.mm
new file mode 100644
index 0000000..6bd3761
--- /dev/null
+++ b/test/SemaObjCXX/objc-extern-c.mm
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@protocol P // expected-note {{previous}}
+-(void)meth1;
+@end
+
+@interface I // expected-note {{previous}}
+@end
+
+@interface I2
+@end
+@interface I2(C) // expected-note {{previous}}
+@end
+
+extern "C" {
+@protocol P // expected-warning {{duplicate protocol definition of 'P' is ignored}}
+-(void)meth2;
+@end
+
+@interface I // expected-error {{duplicate}}
+@end
+
+@interface I2(C) // expected-warning {{duplicate}}
+@end
+}
+
+void test(id<P> p) {
+ [p meth1];
+ [p meth2]; // expected-warning {{not found}}
+}
diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm
index 6f59de1..611b7bc 100644
--- a/test/SemaObjCXX/objc-pointer-conv.mm
+++ b/test/SemaObjCXX/objc-pointer-conv.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
typedef const void * VoidStar;
diff --git a/test/SemaObjCXX/overload.mm b/test/SemaObjCXX/overload.mm
index ea5f0e5..6f24c59 100644
--- a/test/SemaObjCXX/overload.mm
+++ b/test/SemaObjCXX/overload.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
@interface Foo
@end
@@ -171,3 +171,9 @@ namespace rdar9327203 {
int &fr = (f)(x, 0);
}
}
+
+namespace class_id {
+ // it's okay to overload Class with id.
+ void f(Class) { }
+ void f(id) { }
+}
diff --git a/test/SemaObjCXX/propert-dot-error.mm b/test/SemaObjCXX/propert-dot-error.mm
index 747efeb..2237411 100644
--- a/test/SemaObjCXX/propert-dot-error.mm
+++ b/test/SemaObjCXX/propert-dot-error.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar: // 8379892
struct X {
@@ -20,7 +20,7 @@ struct X {
@end
void f(A* a) {
- a.x = X(); // expected-error {{setter method is needed to assign to object using property assignment syntax}}
+ a.x = X(); // expected-error {{no setter method 'setX:' for assignment to property}}
}
struct Y : X { };
diff --git a/test/SemaObjCXX/properties.mm b/test/SemaObjCXX/properties.mm
index f148b33..3c6b138 100644
--- a/test/SemaObjCXX/properties.mm
+++ b/test/SemaObjCXX/properties.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Wno-objc-root-class %s
struct X {
void f() const;
@@ -19,6 +19,90 @@ struct X {
- (void)setx:(const X&)other { x_ = other; }
- (void)method {
self.x.f();
-}
+}
+@end
+
+// rdar://problem/10444030
+@interface Test2
+- (void) setY: (int) y;
+- (int) z;
+@end
+void test2(Test2 *a) {
+ auto y = a.y; // expected-error {{expected getter method not found on object of type 'Test2 *'}}
+ auto z = a.z;
+}
+
+// rdar://problem/10672108
+@interface Test3
+- (int) length;
@end
+void test3(Test3 *t) {
+ char vla[t.length] = {}; // expected-error {{variable-sized object may not be initialized}}
+ char *heaparray = new char[t.length];
+}
+// <rdar://problem/10672501>
+namespace std {
+ template<typename T> void count();
+}
+
+@interface Test4
+- (X&) prop;
+@end
+
+void test4(Test4 *t) {
+ (void)const_cast<const X&>(t.prop);
+ (void)dynamic_cast<X&>(t.prop);
+ (void)reinterpret_cast<int&>(t.prop);
+}
+
+@interface Test5 {
+@public
+ int count;
+}
+@property int count;
+@end
+
+void test5(Test5* t5) {
+ if (t5.count < 2) { }
+ if (t5->count < 2) { }
+}
+
+
+@interface Test6
++ (Class)class;
+- (Class)class;
+@end
+
+void test6(Test6 *t6) {
+ Class x = t6.class;
+ Class x2 = Test6.class;
+}
+
+template<typename T>
+void test6_template(T *t6) {
+ Class x = t6.class;
+}
+
+template void test6_template(Test6*);
+
+// rdar://problem/10965735
+struct Test7PointerMaker {
+ operator char *() const;
+};
+@interface Test7
+- (char*) implicit_property;
+- (char) bad_implicit_property;
+- (Test7PointerMaker) implicit_struct_property;
+@property int *explicit_property;
+@property int bad_explicit_property;
+@property Test7PointerMaker explicit_struct_property;
+@end
+void test7(Test7 *ptr) {
+ delete ptr.implicit_property;
+ delete ptr.bad_implicit_property; // expected-error {{cannot delete expression of type 'char'}}
+ delete ptr.explicit_property;
+ delete ptr.bad_explicit_property; // expected-error {{cannot delete expression of type 'int'}}
+ delete ptr.implicit_struct_property;
+ delete ptr.explicit_struct_property;
+}
diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm
index 236dba6..18f0604 100644
--- a/test/SemaObjCXX/property-reference.mm
+++ b/test/SemaObjCXX/property-reference.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar://9070460
class TCPPObject
@@ -8,7 +8,7 @@ public:
TCPPObject();
~TCPPObject();
- TCPPObject& operator=(const TCPPObject& inObj)const ;
+ TCPPObject& operator=(const TCPPObject& inObj)const ; // expected-note {{'operator=' declared here}}
void* Data();
@@ -29,7 +29,7 @@ typedef const TCPPObject& CREF_TCPPObject;
@implementation TNSObject
@synthesize cppObjectNonAtomic;
-@synthesize cppObjectAtomic; // expected-warning{{atomic property of type 'CREF_TCPPObject' (aka 'const TCPPObject &') synthesizing setter using non-trivial assignment operator}}
+@synthesize cppObjectAtomic; // expected-error{{atomic property of reference type 'CREF_TCPPObject' (aka 'const TCPPObject &') cannot have non-trivial assignment operator}}
@dynamic cppObjectDynamic;
- (const TCPPObject&) cppObjectNonAtomic
diff --git a/test/SemaObjCXX/property-synthesis-error.mm b/test/SemaObjCXX/property-synthesis-error.mm
index 5ba4b70..4b726d8 100644
--- a/test/SemaObjCXX/property-synthesis-error.mm
+++ b/test/SemaObjCXX/property-synthesis-error.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// rdar: //8550657
@interface NSArray @end
@@ -38,7 +38,7 @@ public:
TCPPObject(const TCPPObject& inObj);
TCPPObject();
~TCPPObject();
- TCPPObject& operator=(const TCPPObject& inObj);
+ TCPPObject& operator=(const TCPPObject& inObj); // expected-note {{'operator=' declared here}}
private:
void* fData;
};
@@ -67,7 +67,7 @@ private:
@implementation MyDocument
-@synthesize cppObject = _cppObject; // expected-warning {{atomic property of type 'const TCPPObject &' synthesizing setter using non-trivial assignment operator}}
+@synthesize cppObject = _cppObject; // expected-error {{atomic property of reference type 'const TCPPObject &' cannot have non-trivial assignment operator}}
@synthesize ncppObject = _ncppObject;
@synthesize tcppObject = _tcppObject;
diff --git a/test/SemaObjCXX/unknown-anytype.mm b/test/SemaObjCXX/unknown-anytype.mm
index 163ddde..b28b135 100644
--- a/test/SemaObjCXX/unknown-anytype.mm
+++ b/test/SemaObjCXX/unknown-anytype.mm
@@ -3,6 +3,7 @@
// rdar://problem/9416370
namespace test0 {
void test(id x) {
+ if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
[x foo]; // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
}
}
diff --git a/test/SemaObjCXX/vararg-non-pod.mm b/test/SemaObjCXX/vararg-non-pod.mm
index 7e5c4c6..5a6281d 100644
--- a/test/SemaObjCXX/vararg-non-pod.mm
+++ b/test/SemaObjCXX/vararg-non-pod.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs
extern char version[];
diff --git a/test/SemaObjCXX/void_to_obj.mm b/test/SemaObjCXX/void_to_obj.mm
index 7dca9fa..97151fd 100644
--- a/test/SemaObjCXX/void_to_obj.mm
+++ b/test/SemaObjCXX/void_to_obj.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
// <rdar://problem/6463729>
@class XX;
diff --git a/test/SemaObjCXX/warn-strict-selector-match.mm b/test/SemaObjCXX/warn-strict-selector-match.mm
index 6d315db..330b10b 100644
--- a/test/SemaObjCXX/warn-strict-selector-match.mm
+++ b/test/SemaObjCXX/warn-strict-selector-match.mm
@@ -13,6 +13,6 @@
void foo(void) {
id r;
- [r meth1:r]; // expected-warning {{multiple methods named 'meth1:' found [-Wstrict-selector-match]}}
- [r window]; // expected-warning {{multiple methods named 'window' found [-Wstrict-selector-match]}}
+ [r meth1:r]; // expected-warning {{multiple methods named 'meth1:' found}}
+ [r window]; // expected-warning {{multiple methods named 'window' found}}
}
diff --git a/test/SemaOpenCL/address-spaces.cl b/test/SemaOpenCL/address-spaces.cl
new file mode 100644
index 0000000..6ab10b3
--- /dev/null
+++ b/test/SemaOpenCL/address-spaces.cl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+__constant int ci = 1;
+
+__kernel void foo(__global int *gip) {
+ __local int li;
+ __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}}
+
+ int *ip;
+ ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}}
+ ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}}
+ ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}}
+}
diff --git a/test/SemaOpenCL/local.cl b/test/SemaOpenCL/local.cl
deleted file mode 100644
index 8637cff..0000000
--- a/test/SemaOpenCL/local.cl
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
-
-__kernel void foo(void) {
- __local int i;
- __local int j = 2; // expected-error {{'__local' variable cannot have an initializer}}
-}
diff --git a/test/SemaOpenCL/vec_compare.cl b/test/SemaOpenCL/vec_compare.cl
new file mode 100644
index 0000000..dd91aa5
--- /dev/null
+++ b/test/SemaOpenCL/vec_compare.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef __attribute__((ext_vector_type(2))) unsigned int uint2;
+typedef __attribute__((ext_vector_type(2))) int int2;
+
+void unsignedCompareOps()
+{
+ uint2 A, B;
+ int2 result = A != B;
+}
+
diff --git a/test/SemaOpenCL/vector_literals_const.cl b/test/SemaOpenCL/vector_literals_const.cl
new file mode 100644
index 0000000..e761816
--- /dev/null
+++ b/test/SemaOpenCL/vector_literals_const.cl
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+typedef int int2 __attribute((ext_vector_type(2)));
+typedef int int3 __attribute((ext_vector_type(3)));
+typedef int int4 __attribute((ext_vector_type(4)));
+
+__constant int4 i_1_1_1_1 = (int4)(1,2,3,4);
+__constant int4 i_2_1_1 = (int4)((int2)(1,2),3,4);
+__constant int4 i_1_2_1 = (int4)(1,(int2)(2,3),4);
+__constant int4 i_1_1_2 = (int4)(1,2,(int2)(3,4));
+__constant int4 i_2_2 = (int4)((int2)(1,2),(int2)(3,4));
+__constant int4 i_3_1 = (int4)((int3)(1,2,3),4);
+__constant int4 i_1_3 = (int4)(1,(int3)(2,3,4));
+
+typedef float float2 __attribute((ext_vector_type(2)));
+typedef float float3 __attribute((ext_vector_type(3)));
+typedef float float4 __attribute((ext_vector_type(4)));
+
+__constant float4 f_1_1_1_1 = (float4)(1,2,3,4);
+__constant float4 f_2_1_1 = (float4)((float2)(1,2),3,4);
+__constant float4 f_1_2_1 = (float4)(1,(float2)(2,3),4);
+__constant float4 f_1_1_2 = (float4)(1,2,(float2)(3,4));
+__constant float4 f_2_2 = (float4)((float2)(1,2),(float2)(3,4));
+__constant float4 f_3_1 = (float4)((float3)(1,2,3),4);
+__constant float4 f_1_3 = (float4)(1,(float3)(2,3,4));
+
diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp
index 79d6849..75615ee 100644
--- a/test/SemaTemplate/alias-templates.cpp
+++ b/test/SemaTemplate/alias-templates.cpp
@@ -68,3 +68,35 @@ itt::thing ith(itr);
itt::rebind<bool> btr;
itt::rebind_thing<bool> btt(btr);
+
+namespace PR11848 {
+ template<typename T> using U = int;
+
+ template<typename T, typename ...Ts>
+ void f(U<T> i, U<Ts> ...is) { // expected-error {{type 'U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+ return i + f<Ts...>(is...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}}
+ }
+
+ template<typename ...Ts>
+ struct S {
+ S(U<Ts>...ts); // expected-error {{does not contain any unexpanded parameter packs}}
+ };
+
+ template<typename T>
+ struct Hidden1 {
+ template<typename ...Ts>
+ Hidden1(typename T::template U<Ts> ...ts); // expected-error{{type 'typename Hide::U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}}
+ };
+
+ template<typename T, typename ...Ts>
+ struct Hidden2 {
+ Hidden2(typename T::template U<Ts> ...ts);
+ };
+
+ struct Hide {
+ template<typename T> using U = int;
+ };
+
+ Hidden1<Hide> h1; // expected-note{{in instantiation of template class 'PR11848::Hidden1<PR11848::Hide>' requested here}}
+ Hidden2<Hide, double, char> h2(1, 2);
+}
diff --git a/test/SemaTemplate/atomics.cpp b/test/SemaTemplate/atomics.cpp
index 7165bbe..e9fdc9d 100644
--- a/test/SemaTemplate/atomics.cpp
+++ b/test/SemaTemplate/atomics.cpp
@@ -6,3 +6,11 @@ template<typename T> T f(T* value) {
}
int g(long long* x) { return f(x); }
int g(int* x) { return f(x); }
+
+namespace PR11320 {
+ template<typename T>
+ void g(unsigned *x) {
+ __sync_bool_compare_and_swap(x, 1, 4);
+ }
+ void h() { g<int>(0); }
+}
diff --git a/test/SemaTemplate/canonical-expr-type-0x.cpp b/test/SemaTemplate/canonical-expr-type-0x.cpp
index 94ae360..d7379ea 100644
--- a/test/SemaTemplate/canonical-expr-type-0x.cpp
+++ b/test/SemaTemplate/canonical-expr-type-0x.cpp
@@ -2,15 +2,24 @@
void f();
-// FIXME: would like to refer to the first function parameter in these test,
-// but that won't work (yet).
-
// Test typeof(expr) canonicalization
template<typename T, T N>
-void f0(T x, decltype(f(N)) y) { } // expected-note{{previous}}
+void f0(T x, decltype(f(N, x)) y) { } // expected-note{{previous}}
template<typename T, T N>
-void f0(T x, decltype((f)(N)) y) { }
+void f0(T x, decltype((f)(N, x)) y) { }
template<typename U, U M>
-void f0(U u, decltype(f(M))) { } // expected-error{{redefinition}}
+void f0(U u, decltype(f(M, u))) { } // expected-error{{redefinition}}
+
+// PR12438: Test sizeof...() canonicalization
+template<int> struct N {};
+
+template<typename...T>
+N<sizeof...(T)> f1() {} // expected-note{{previous}}
+
+template<typename, typename...T>
+N<sizeof...(T)> f1() {}
+
+template<class...U>
+N<sizeof...(U)> f1() {} // expected-error{{redefinition}}
diff --git a/test/SemaTemplate/class-template-ctor-initializer.cpp b/test/SemaTemplate/class-template-ctor-initializer.cpp
index 81a5e2b..44bb4bd 100644
--- a/test/SemaTemplate/class-template-ctor-initializer.cpp
+++ b/test/SemaTemplate/class-template-ctor-initializer.cpp
@@ -49,7 +49,7 @@ namespace PR7259 {
int
main (void)
{
- Final final();
+ Final final;
return 0;
}
}
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp
index 2e84e93..ec4e016 100644
--- a/test/SemaTemplate/class-template-decl.cpp
+++ b/test/SemaTemplate/class-template-decl.cpp
@@ -74,3 +74,24 @@ namespace PR8001 {
Foo<int>::Bar<int> y(x);
}
}
+
+namespace rdar9676205 {
+ template <unsigned, class _Tp> class tuple_element;
+
+ template <class _T1, class _T2> class pair;
+
+ template <class _T1, class _T2>
+ class tuple_element<0, pair<_T1, _T2> >
+ {
+ template <class _Tp>
+ struct X
+ {
+ template <class _Up, bool = X<_Up>::value>
+ struct Y
+ : public X<_Up>,
+ public Y<_Up>
+ { };
+ };
+ };
+}
+
diff --git a/test/SemaTemplate/class-template-spec.cpp b/test/SemaTemplate/class-template-spec.cpp
index 07a5e29..f9015b3 100644
--- a/test/SemaTemplate/class-template-spec.cpp
+++ b/test/SemaTemplate/class-template-spec.cpp
@@ -86,7 +86,7 @@ namespace N {
template<> struct N::B<int> { }; // okay
-template<> struct N::B<float> { }; // expected-warning{{originally}}
+template<> struct N::B<float> { }; // expected-warning{{C++11 extension}}
namespace M {
template<> struct ::N::B<short> { }; // expected-error{{class template specialization of 'B' not in a namespace enclosing 'N'}}
@@ -109,3 +109,13 @@ Foo<int> x;
// Template template parameters
template<template<class T> class Wibble>
class Wibble<int> { }; // expected-error{{cannot specialize a template template parameter}}
+
+namespace rdar9676205 {
+ template<typename T>
+ struct X {
+ template<typename U>
+ struct X<U*> { // expected-error{{explicit specialization of 'X' in class scope}}
+ };
+ };
+
+}
diff --git a/test/SemaTemplate/constexpr-instantiate.cpp b/test/SemaTemplate/constexpr-instantiate.cpp
new file mode 100644
index 0000000..2f9fe0e
--- /dev/null
+++ b/test/SemaTemplate/constexpr-instantiate.cpp
@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+namespace UseBeforeDefinition {
+ struct A {
+ template<typename T> static constexpr T get() { return T(); }
+ // ok, not a constant expression.
+ int n = get<int>();
+ };
+
+ // ok, constant expression.
+ constexpr int j = A::get<int>();
+
+ template<typename T> constexpr int consume(T);
+ // ok, not a constant expression.
+ const int k = consume(0); // expected-note {{here}}
+
+ template<typename T> constexpr int consume(T) { return 0; }
+ // ok, constant expression.
+ constexpr int l = consume(0);
+
+ constexpr int m = k; // expected-error {{constant expression}} expected-note {{initializer of 'k'}}
+}
+
+namespace IntegralConst {
+ template<typename T> constexpr T f(T n) { return n; }
+ enum E {
+ v = f(0), w = f(1) // ok
+ };
+ static_assert(w == 1, "");
+
+ char arr[f('x')]; // ok
+ static_assert(sizeof(arr) == 'x', "");
+}
+
+namespace ConvertedConst {
+ template<typename T> constexpr T f(T n) { return n; }
+ int f() {
+ switch (f()) {
+ case f(4): return 0;
+ }
+ return 1;
+ }
+}
+
+namespace OverloadResolution {
+ template<typename T> constexpr T f(T t) { return t; }
+
+ template<int n> struct S { };
+
+ template<typename T> auto g(T t) -> S<f(sizeof(T))> &;
+ char &f(...);
+
+ template<typename T> auto h(T t[f(sizeof(T))]) -> decltype(&*t) {
+ return t;
+ }
+
+ S<4> &k = g(0);
+ int *p, *q = h(p);
+}
+
+namespace DataMember {
+ template<typename T> struct S { static const int k; };
+ const int n = S<int>::k; // expected-note {{here}}
+ template<typename T> const int S<T>::k = 0;
+ constexpr int m = S<int>::k; // ok
+ constexpr int o = n; // expected-error {{constant expression}} expected-note {{initializer of 'n'}}
+}
+
+namespace Reference {
+ const int k = 5;
+ template<typename T> struct S {
+ static volatile int &r;
+ };
+ template<typename T> volatile int &S<T>::r = const_cast<volatile int&>(k);
+ constexpr int n = const_cast<int&>(S<int>::r);
+ static_assert(n == 5, "");
+}
diff --git a/test/SemaTemplate/crash-10438657.cpp b/test/SemaTemplate/crash-10438657.cpp
new file mode 100644
index 0000000..2ee64bd
--- /dev/null
+++ b/test/SemaTemplate/crash-10438657.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -fsyntax-only %s 2> %t
+// RUN: FileCheck %s < %t
+// CHECK: 10 errors
+template<typename _CharT>
+class collate : public locale::facet {
+
+protected:
+virtual ~collate() {}
+ class wxObject;
+ class __attribute__ ((visibility("default"))) wxGDIRefData
+ : public wxObjectRefData {};
+ class __attribute__ ((visibility("default"))) wxGDIObject : public wxObject { \
+ public:
+ virtual bool IsOk() const {
+ return m_refData && static_cast<wxGDIRefData *>(m_refData)->IsOk();
diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp
index fb23eda..cf3899f 100644
--- a/test/SemaTemplate/deduction-crash.cpp
+++ b/test/SemaTemplate/deduction-crash.cpp
@@ -2,7 +2,7 @@
// Note that the error count below doesn't matter. We just want to
// make sure that the parser doesn't crash.
-// CHECK: 14 errors
+// CHECK: 13 errors
// PR7511
template<a>
diff --git a/test/SemaTemplate/delegating-constructors.cpp b/test/SemaTemplate/delegating-constructors.cpp
index d823434..e177b50 100644
--- a/test/SemaTemplate/delegating-constructors.cpp
+++ b/test/SemaTemplate/delegating-constructors.cpp
@@ -15,4 +15,17 @@ namespace PR10457 {
void f() {
string s("hello");
}
+
+ struct Foo {
+ Foo(int) { }
+
+
+ template <typename T>
+ Foo(T, int i) : Foo(i) { }
+};
+
+ void test_Foo()
+ {
+ Foo f(1, 1);
+ }
}
diff --git a/test/SemaTemplate/enum-forward.cpp b/test/SemaTemplate/enum-forward.cpp
index 3a4f05c..b25c21f 100644
--- a/test/SemaTemplate/enum-forward.cpp
+++ b/test/SemaTemplate/enum-forward.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s
template<typename T>
struct X {
diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp
index 63016fd..13d76be 100644
--- a/test/SemaTemplate/explicit-instantiation.cpp
+++ b/test/SemaTemplate/explicit-instantiation.cpp
@@ -94,6 +94,14 @@ namespace PR7622 {
template<typename,typename>
struct basic_streambuf{friend bob<>()}; // expected-error{{unknown type name 'bob'}} \
- // expected-error{{ expected member name or ';' after declaration specifiers}}
+ // expected-error{{expected member name or ';' after declaration specifiers}}
template struct basic_streambuf<int>;
}
+
+// Test that we do not crash.
+class TC1 {
+ class TC2 {
+ template // FIXME: error here.
+ void foo() { }
+ };
+};
diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp
index d1284de..9c95fa0 100644
--- a/test/SemaTemplate/friend-template.cpp
+++ b/test/SemaTemplate/friend-template.cpp
@@ -224,3 +224,22 @@ namespace friend_type_template_no_tag {
};
template struct S<int>;
}
+
+namespace PR10660 {
+ struct A {
+ template <> friend class B; // expected-error{{extraneous 'template<>' in declaration of class 'B'}}
+ };
+}
+
+namespace rdar11147355 {
+ template <class T>
+ struct A {
+ template <class U> class B;
+ template <class S> template <class U> friend class A<S>::B;
+ };
+
+ template <class S> template <class U> class A<S>::B {
+ };
+
+ A<double>::B<double> ab;
+}
diff --git a/test/SemaTemplate/friend.cpp b/test/SemaTemplate/friend.cpp
index 99685f2..e78a067 100644
--- a/test/SemaTemplate/friend.cpp
+++ b/test/SemaTemplate/friend.cpp
@@ -28,6 +28,6 @@ namespace PR6770 {
template <class T>
void f() {
friend class f; // expected-error{{'friend' used outside of class}}
- friend class f1; // expected-error{{ 'friend' used outside of class}}
+ friend class f1; // expected-error{{'friend' used outside of class}}
}
}
diff --git a/test/SemaTemplate/instantiate-complete.cpp b/test/SemaTemplate/instantiate-complete.cpp
index 4b27da7..68d5ae3 100644
--- a/test/SemaTemplate/instantiate-complete.cpp
+++ b/test/SemaTemplate/instantiate-complete.cpp
@@ -28,7 +28,6 @@ void test_subscript(X<double> *ptr1, X<int(int)> *ptr2, int i) {
void test_arith(X<signed char> *ptr1, X<unsigned char> *ptr2,
X<char(char)> *ptr3, X<short(short)> *ptr4) {
(void)(ptr1 + 5);
- // FIXME: if I drop the ')' after void, below, it still parses (!)
(void)(5 + ptr2);
(void)(ptr3 + 5); // expected-note{{in instantiation of template class 'X<char (char)>' requested here}}
(void)(5 + ptr4); // expected-note{{in instantiation of template class 'X<short (short)>' requested here}}
@@ -145,4 +144,3 @@ namespace PR8425 {
BaseT<int> bt(ft);
}
}
-
diff --git a/test/SemaTemplate/instantiate-declref-ice.cpp b/test/SemaTemplate/instantiate-declref-ice.cpp
index 0f3c08b..49b1b63 100644
--- a/test/SemaTemplate/instantiate-declref-ice.cpp
+++ b/test/SemaTemplate/instantiate-declref-ice.cpp
@@ -31,4 +31,4 @@ struct X1 {
template<typename T>
const unsigned X1<T>::value = sizeof(T);
-int array3[X1<int>::value == sizeof(int)? 1 : -1]; // expected-error{{variable length array declaration not allowed at file scope}}
+int array3[X1<int>::value == sizeof(int)? 1 : -1];
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 8964374..9395117 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -34,7 +34,7 @@ void test_BitfieldMinus() {
template<int I, int J>
struct BitfieldDivide {
- int bitfield : I / J; // expected-error{{expression is not an integer constant expression}} \
+ int bitfield : I / J; // expected-error{{expression is not an integral constant expression}} \
// expected-note{{division by zero}}
};
@@ -167,8 +167,15 @@ namespace PR6424 {
new X(); // expected-note{{instantiation of}}
}
};
-
+
template void Y2<3>::f();
+
+ template<typename T>
+ void rdar10283928(int count) {
+ (void)new char[count]();
+ }
+
+ template void rdar10283928<int>(int);
}
namespace PR10864 {
diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp
index 9483f9b..d95ccfe 100644
--- a/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/test/SemaTemplate/instantiate-expr-4.cpp
@@ -282,6 +282,16 @@ template struct ArrowMemRef0<ArrowWrapper<MemIntFunc*>, int (*)(int)>;
template struct ArrowMemRef0<ArrowWrapper<MemInt*>, float&>; // expected-note{{instantiation}}
template struct ArrowMemRef0<ArrowWrapper<ArrowWrapper<MemInt*> >, int&>;
+struct UnresolvedMemRefArray {
+ int f(int);
+ int f(char);
+};
+UnresolvedMemRefArray Arr[10];
+template<typename U> int UnresolvedMemRefArrayT(U u) {
+ return Arr->f(u);
+}
+template int UnresolvedMemRefArrayT<int>(int);
+
// FIXME: we should be able to return a MemInt without the reference!
MemInt &createMemInt(int);
diff --git a/test/SemaTemplate/instantiate-expr-5.cpp b/test/SemaTemplate/instantiate-expr-5.cpp
index 6cdedda..13b7eae 100644
--- a/test/SemaTemplate/instantiate-expr-5.cpp
+++ b/test/SemaTemplate/instantiate-expr-5.cpp
@@ -6,7 +6,7 @@ int y() { return x<int>(1); }
namespace PR5880 {
template<typename T>
struct A {
- static const int a = __builtin_offsetof(T, a.array[5].m); // expected-error{{error: no member named 'a' in 'HasM'}}
+ static const int a = __builtin_offsetof(T, a.array[5].m); // expected-error{{no member named 'a' in 'HasM'}}
};
struct HasM {
float m;
diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp
index 5406fbc..ceef274 100644
--- a/test/SemaTemplate/instantiate-function-1.cpp
+++ b/test/SemaTemplate/instantiate-function-1.cpp
@@ -194,7 +194,7 @@ template struct IndirectGoto0<int>; // expected-note{{instantiation}}
template<typename T> struct TryCatch0 {
void f() {
try {
- } catch (T t) { // expected-warning{{incomplete type}} \
+ } catch (T t) { // expected-error{{incomplete type}} \
// expected-error{{abstract class}}
} catch (...) {
}
diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp
index c67eb40..bb64276 100644
--- a/test/SemaTemplate/instantiate-member-class.cpp
+++ b/test/SemaTemplate/instantiate-member-class.cpp
@@ -118,3 +118,25 @@ namespace AliasTagDef {
int m = F<int>::S().g();
int n = F<int>::U().g();
}
+
+namespace rdar10397846 {
+ template<int I> struct A
+ {
+ struct B
+ {
+ struct C { C() { int *ptr = I; } }; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+ };
+ };
+
+ template<int N> void foo()
+ {
+ class A<N>::B::C X; // expected-note{{in instantiation of member function}}
+ int A<N+1>::B::C::*member = 0;
+ }
+
+ void bar()
+ {
+ foo<0>();
+ foo<1>(); // expected-note{{in instantiation of function template}}
+ }
+}
diff --git a/test/SemaTemplate/instantiate-self.cpp b/test/SemaTemplate/instantiate-self.cpp
new file mode 100644
index 0000000..cfe9025
--- /dev/null
+++ b/test/SemaTemplate/instantiate-self.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// Check that we deal with cases where the instantiation of a class template
+// recursively requires the instantiation of the same template.
+namespace test1 {
+ template<typename T> struct A {
+ struct B { // expected-note {{not complete until the closing '}'}}
+ B b; // expected-error {{has incomplete type 'test1::A<int>::B'}}
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+namespace test2 {
+ template<typename T> struct A {
+ struct B {
+ struct C {};
+ char c[1 + C()]; // expected-error {{invalid operands to binary expression}}
+ friend constexpr int operator+(int, C) { return 4; }
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+namespace test3 {
+ // PR12317
+ template<typename T> struct A {
+ struct B {
+ enum { Val = 1 };
+ char c[1 + Val]; // ok
+ };
+ B b;
+ };
+ A<int> a;
+}
+
+namespace test4 {
+ template<typename T> struct M { typedef int type; };
+ template<typename T> struct A {
+ struct B { // expected-note {{not complete until the closing '}'}}
+ int k[typename A<typename M<T>::type>::B().k[0] + 1]; // expected-error {{incomplete type}}
+ };
+ B b; // expected-note {{in instantiation of}}
+ };
+ A<int> a; // expected-note {{in instantiation of}}
+}
+
+// FIXME: PR12298: Recursive constexpr function template instantiation leads to
+// stack overflow.
+#if 0
+namespace test5 {
+ template<typename T> struct A {
+ constexpr T f(T k) { return g(k); }
+ constexpr T g(T k) {
+ return k ? f(k-1)+1 : 0;
+ }
+ };
+ // This should be accepted.
+ constexpr int x = A<int>().f(5);
+}
+
+namespace test6 {
+ template<typename T> constexpr T f(T);
+ template<typename T> constexpr T g(T t) {
+ typedef int arr[f(T())];
+ return t;
+ }
+ template<typename T> constexpr T f(T t) {
+ typedef int arr[g(T())];
+ return t;
+ }
+ // This should be ill-formed.
+ int n = f(0);
+}
+
+namespace test7 {
+ template<typename T> constexpr T g(T t) {
+ return t;
+ }
+ template<typename T> constexpr T f(T t) {
+ typedef int arr[g(T())];
+ return t;
+ }
+ // This should be accepted.
+ int n = f(0);
+}
+#endif
diff --git a/test/SemaTemplate/instantiate-sizeof.cpp b/test/SemaTemplate/instantiate-sizeof.cpp
new file mode 100644
index 0000000..00d63d0
--- /dev/null
+++ b/test/SemaTemplate/instantiate-sizeof.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Make sure we handle contexts correctly with sizeof
+template<typename T> void f(T n) {
+ int buffer[n];
+ [] { int x = sizeof(sizeof(buffer)); }();
+}
+int main() {
+ f<int>(1);
+}
diff --git a/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp
index d2b0459..f309f29 100644
--- a/test/SemaTemplate/instantiate-static-var.cpp
+++ b/test/SemaTemplate/instantiate-static-var.cpp
@@ -2,7 +2,7 @@
template<typename T, T Divisor>
class X {
public:
- static const T value = 10 / Divisor; // expected-error{{in-class initializer is not a constant expression}}
+ static const T value = 10 / Divisor; // expected-error{{in-class initializer for static data member is not a constant expression}}
};
int array1[X<int, 2>::value == 5? 1 : -1];
@@ -114,4 +114,3 @@ namespace PR6449 {
template class X1<char>;
}
-
diff --git a/test/SemaTemplate/instantiate-typeof.cpp b/test/SemaTemplate/instantiate-typeof.cpp
new file mode 100644
index 0000000..92873cb
--- /dev/null
+++ b/test/SemaTemplate/instantiate-typeof.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+// Make sure we correctly treat __typeof as potentially-evaluated when appropriate
+template<typename T> void f(T n) {
+ int buffer[n]; // expected-note {{declared here}}
+ [] { __typeof(buffer) x; }(); // expected-error {{variable 'buffer' with variably modified type cannot be captured in a lambda expression}}
+}
+int main() {
+ f<int>(1); // expected-note {{in instantiation}}
+}
diff --git a/test/SemaTemplate/instantiation-depth.cpp b/test/SemaTemplate/instantiation-depth.cpp
index a2b9d2e..8e1b803 100644
--- a/test/SemaTemplate/instantiation-depth.cpp
+++ b/test/SemaTemplate/instantiation-depth.cpp
@@ -1,10 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 5 -ftemplate-backtrace-limit 4 %s
+// RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth-5 -ftemplate-backtrace-limit=4 %s
+// RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s
template<typename T> struct X : X<T*> { }; \
// expected-error{{recursive template instantiation exceeded maximum depth of 5}} \
// expected-note 3 {{instantiation of template class}} \
// expected-note {{skipping 2 contexts in backtrace}} \
-// expected-note {{use -ftemplate-depth-N to increase recursive template instantiation depth}}
+// expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}}
void test() {
(void)sizeof(X<int>); // expected-note {{instantiation of template class}}
diff --git a/test/SemaTemplate/instantiation-order.cpp b/test/SemaTemplate/instantiation-order.cpp
new file mode 100644
index 0000000..e058a5b
--- /dev/null
+++ b/test/SemaTemplate/instantiation-order.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+// From core issue 1227.
+
+template <class T> struct A { using X = typename T::X; }; // expected-error {{no members}}
+template <class T> typename T::X f(typename A<T>::X);
+template <class T> void f(...) {}
+template <class T> auto g(typename A<T>::X) -> typename T::X; // expected-note {{here}} expected-note {{substituting}}
+template <class T> void g(...) {}
+
+void h()
+{
+ f<int>(0); // ok, SFINAE in return type
+ g<int>(0); // not ok, substitution inside A<int> is a hard error
+}
diff --git a/test/SemaTemplate/member-access-ambig.cpp b/test/SemaTemplate/member-access-ambig.cpp
index bf19043..f8a01d5 100644
--- a/test/SemaTemplate/member-access-ambig.cpp
+++ b/test/SemaTemplate/member-access-ambig.cpp
@@ -33,3 +33,13 @@ void X::g()
// expected-error{{expected '(' for function-style cast}} \
// expected-error{{expected expression}}
}
+
+namespace PR11134 {
+ template<typename Derived> class A;
+ template<typename Derived> class B : A<Derived> {
+ typedef A<Derived> Base;
+ using Base::member;
+ int member;
+ };
+}
+
diff --git a/test/SemaTemplate/member-template-access-expr.cpp b/test/SemaTemplate/member-template-access-expr.cpp
index dbd27c4..c95b57d 100644
--- a/test/SemaTemplate/member-template-access-expr.cpp
+++ b/test/SemaTemplate/member-template-access-expr.cpp
@@ -60,7 +60,7 @@ struct X1 {
void test_X1(X1 x1) {
float *fp1 = x1.f1<>(17);
- float *fp2 = x1.f1<int>(3.14);
+ float *fp2 = x1.f1<int>(3.14); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
int *ip1 = x1.f1(17);
float *ip2 = x1.f1(3.14);
diff --git a/test/SemaTemplate/ms-if-exists.cpp b/test/SemaTemplate/ms-if-exists.cpp
new file mode 100644
index 0000000..04f4a63
--- /dev/null
+++ b/test/SemaTemplate/ms-if-exists.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fms-extensions -std=c++11 %s -verify
+
+struct Nontemplate {
+ typedef int type;
+};
+
+template<typename T>
+struct X {
+ __if_exists(Nontemplate::type) {
+ typedef Nontemplate::type type;
+ }
+
+ __if_exists(Nontemplate::value) {
+ typedef Nontemplate::value type2;
+ }
+
+ __if_not_exists(Nontemplate::value) {
+ typedef int type3;
+ }
+
+ __if_exists(T::X) { // expected-warning{{dependent __if_exists declarations are ignored}}
+ typedef T::X type4;
+ }
+};
+
+X<int>::type i1;
+X<int>::type2 i2; // expected-error{{no type named 'type2' in 'X<int>'}}
+X<int>::type3 i3;
+X<int>::type4 i4; // expected-error{{no type named 'type4' in 'X<int>'}}
+
+struct HasFoo {
+ void foo();
+};
+struct HasBar {
+ void bar(int);
+ void bar(float);
+};
+
+template<typename T>
+void f(T t) {
+ __if_exists(T::foo) {
+ { }
+ t.foo();
+ }
+
+ __if_not_exists(T::bar) {
+ int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+ { }
+ }
+
+ int array2[] = {
+ 0,
+ __if_exists(T::bar) {2, }// expected-warning{{dependent __if_exists declarations are ignored}}
+ 3
+ };
+}
+
+template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}}
+template void f(HasBar);
+
+template<typename T, typename ...Ts>
+void g(T, Ts...) {
+ __if_exists(T::operator Ts) { // expected-error{{__if_exists name contains unexpanded parameter pack 'Ts'}}
+ }
+
+ __if_not_exists(Ts::operator T) { // expected-error{{__if_not_exists name contains unexpanded parameter pack 'Ts'}}
+ }
+}
diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp
index 910fa37..2c422dc 100644
--- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s
template <class T>
@@ -28,4 +28,118 @@ void test()
b.z(3);
}
+namespace lookup_dependent_bases_id_expr {
+template<class T> class A {
+public:
+ int var;
+};
+
+
+template<class T>
+class B : public A<T> {
+public:
+ void f() {
+ var = 3;
+ }
+};
+
+template class B<int>;
+
+}
+
+
+
+namespace lookup_dependent_base_class_static_function {
+
+template <class T>
+class A {
+public:
+ static void static_func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ void func();// expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+
+template <class T>
+class B : public A<T> {
+public:
+ static void z2(){
+ static_func(); // expected-warning {{use of identifier 'static_func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ func(); // expected-warning {{use of identifier 'func' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
+ }
+};
+template class B<int>; // expected-note {{requested here}}
+
+}
+
+
+
+namespace lookup_dependent_base_class_default_argument {
+
+template<class T>
+class A {
+public:
+ static int f1(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+ int f2(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+template<class T>
+class B : public A<T> {
+public:
+ void g1(int p = f1());// expected-warning {{use of identifier 'f1' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ void g2(int p = f2());// expected-warning {{use of identifier 'f2' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} expected-error {{call to non-static member function without an object argument}}
+};
+
+void foo()
+{
+ B<int> b;
+ b.g1(); // expected-note {{required here}}
+ b.g2(); // expected-note {{required here}}
+}
+
+}
+
+
+namespace lookup_dependent_base_class_friend {
+
+template <class T>
+class B {
+public:
+ static void g(); // expected-note {{must qualify identifier to find this declaration in dependent base class}}
+};
+
+template <class T>
+class A : public B<T> {
+public:
+ friend void foo(A<T> p){
+ g(); // expected-warning {{use of identifier 'g' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}}
+ }
+};
+
+int main2()
+{
+ A<int> a;
+ foo(a); // expected-note {{requested here}}
+}
+
+}
+
+
+namespace lookup_dependent_base_no_typo_correction {
+
+class C {
+public:
+ int m_hWnd;
+};
+
+template <class T>
+class A : public T {
+public:
+ void f(int hWnd) {
+ m_hWnd = 1;
+ }
+};
+
+template class A<C>;
+
+}
diff --git a/test/SemaTemplate/nested-incomplete-class.cpp b/test/SemaTemplate/nested-incomplete-class.cpp
new file mode 100644
index 0000000..a4bfccb
--- /dev/null
+++ b/test/SemaTemplate/nested-incomplete-class.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+template <typename T>
+struct foo {
+ struct bar;
+
+ bar fn() {
+ // Should not get errors about bar being incomplete here.
+ bar b = bar(1, 2);
+ return b;
+ }
+};
+
+template <typename T>
+struct foo<T>::bar {
+ bar(int, int);
+};
+
+void fn() {
+ foo<int>().fn();
+}
diff --git a/test/SemaTemplate/nested-template.cpp b/test/SemaTemplate/nested-template.cpp
index ab647aa..7849bae 100644
--- a/test/SemaTemplate/nested-template.cpp
+++ b/test/SemaTemplate/nested-template.cpp
@@ -142,3 +142,16 @@ namespace PR10896 {
f.foo();
}
}
+
+namespace PR10924 {
+ template< class Topology, class ctype >
+ struct ReferenceElement
+ {
+ };
+
+ template< class Topology, class ctype >
+ template< int codim >
+ class ReferenceElement< Topology, ctype > :: BaryCenterArray // expected-error{{out-of-line definition of 'BaryCenterArray' does not match any declaration in 'ReferenceElement<Topology, ctype>'}}
+ {
+ };
+}
diff --git a/test/SemaTemplate/pragma-ms_struct.cpp b/test/SemaTemplate/pragma-ms_struct.cpp
new file mode 100644
index 0000000..f04dc5c
--- /dev/null
+++ b/test/SemaTemplate/pragma-ms_struct.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-osx10.7.0 %s
+
+#pragma ms_struct on
+
+// <rdar://problem/10791194>
+template<int x> struct foo {
+ long long a;
+ int b;
+};
+extern int arr[sizeof(foo<0>) == 16 ? 1 : -1];
diff --git a/test/SemaTemplate/qualified-id.cpp b/test/SemaTemplate/qualified-id.cpp
index 29eab89..64dff1c 100644
--- a/test/SemaTemplate/qualified-id.cpp
+++ b/test/SemaTemplate/qualified-id.cpp
@@ -45,3 +45,12 @@ namespace PR6063 {
detail::f(a, b);
}
}
+
+namespace PR12291 {
+ template <typename T>
+ class Outer2 {
+ template <typename V>
+ template <typename W>
+ class Outer2<V>::Inner; // expected-error{{nested name specifier 'Outer2<V>::' for declaration does not refer into a class, class template or class template partial specialization}}
+ };
+}
diff --git a/test/SemaTemplate/resolve-single-template-id.cpp b/test/SemaTemplate/resolve-single-template-id.cpp
index b9833d8..0c9bacc 100644
--- a/test/SemaTemplate/resolve-single-template-id.cpp
+++ b/test/SemaTemplate/resolve-single-template-id.cpp
@@ -41,7 +41,7 @@ int main()
*oneT<int>; // expected-warning {{expression result unused}}
*two; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} expected-error {{indirection requires pointer operand}}
*twoT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
- !oneT<int>; // expected-warning {{expression result unused}}
+ !oneT<int>; // expected-warning {{expression result unused}} expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}}
+oneT<int>; // expected-warning {{expression result unused}}
-oneT<int>; //expected-error {{invalid argument type}}
oneT<int> == 0; // expected-warning {{equality comparison result unused}} \
@@ -53,7 +53,7 @@ int main()
int i = (int) (false ? (void (*)(int))twoT<int> : oneT<int>); //expected-error {{incompatible operand}}
(twoT<int>) == oneT<int>; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} {{cannot resolve overloaded function 'twoT' from context}}
- bool b = oneT<int>;
+ bool b = oneT<int>; // expected-warning {{address of function 'oneT<int>' will always evaluate to 'true'}} expected-note {{prefix with the address-of operator to silence this warning}}
void (*p)() = oneT<int>;
test<oneT<int> > ti;
void (*u)(int) = oneT<int>;
diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp
index 9c34089..c9ce1b6 100644
--- a/test/SemaTemplate/temp_arg_template.cpp
+++ b/test/SemaTemplate/temp_arg_template.cpp
@@ -54,3 +54,9 @@ namespace N {
void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}}
}
+
+// PR12179
+template <typename Primitive, template <Primitive...> class F> // expected-warning {{variadic templates are a C++11 extension}}
+struct unbox_args {
+ typedef typename Primitive::template call<F> x;
+};
diff --git a/test/SemaTemplate/temp_class_spec_neg.cpp b/test/SemaTemplate/temp_class_spec_neg.cpp
index 6b129a5..be5fbb1 100644
--- a/test/SemaTemplate/temp_class_spec_neg.cpp
+++ b/test/SemaTemplate/temp_class_spec_neg.cpp
@@ -9,7 +9,7 @@ namespace N {
}
template<typename T>
-struct N::M::A<T*> { }; // expected-warning{{originally}}
+struct N::M::A<T*> { }; // expected-warning{{C++11 extension}}
// C++ [temp.class.spec]p9
// bullet 1
diff --git a/test/SemaTemplate/temp_explicit.cpp b/test/SemaTemplate/temp_explicit.cpp
index 76244c2..80c90d0 100644
--- a/test/SemaTemplate/temp_explicit.cpp
+++ b/test/SemaTemplate/temp_explicit.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++0x-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s
//
// Tests explicit instantiation of templates.
template<typename T, typename U = T> class X0 { };
@@ -80,7 +80,7 @@ struct X5 {
void f(T&);
};
- struct Inner2 {
+ struct Inner2 { // expected-note {{here}}
struct VeryInner {
void g(T*); // expected-error 2{{pointer to a reference}}
};
@@ -98,7 +98,7 @@ void f4(X5<float&>::Inner2);
template struct X5<float&>::Inner2; // expected-note{{instantiation}}
namespace N3 {
- template struct N2::X5<int>::Inner2;
+ template struct N2::X5<int>::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}}
}
struct X6 {
@@ -147,5 +147,5 @@ namespace N2 {
template struct X7<double>; // expected-warning{{must occur in namespace}}
- template struct X9<float>; // expected-warning{{must occur in the global}}
+ template struct X9<float>; // expected-warning{{must occur at global scope}}
}
diff --git a/test/SemaTemplate/temp_explicit_cxx0x.cpp b/test/SemaTemplate/temp_explicit_cxx0x.cpp
index 9d6dc80..e37fcd7 100644
--- a/test/SemaTemplate/temp_explicit_cxx0x.cpp
+++ b/test/SemaTemplate/temp_explicit_cxx0x.cpp
@@ -18,7 +18,7 @@ template struct ::N1::Inner::X1<float>;
namespace N2 {
using namespace N1;
- template struct X0<double>; // expected-error{{not in a namespace enclosing}}
+ template struct X0<double>; // expected-error{{must occur in namespace 'N1'}}
template struct X2<float>; // expected-error{{at global scope}}
}
diff --git a/test/SemaTemplate/template-id-expr.cpp b/test/SemaTemplate/template-id-expr.cpp
index de8d7f6..4416f92 100644
--- a/test/SemaTemplate/template-id-expr.cpp
+++ b/test/SemaTemplate/template-id-expr.cpp
@@ -82,3 +82,17 @@ struct Y0 {
x = this->template f4(0); // expected-error {{assigning to 'int' from incompatible type 'void'}}
}
};
+
+struct A {
+ template<int I>
+ struct B {
+ static void b1();
+ };
+};
+
+template<int I>
+void f5() {
+ A::template B<I>::template b1(); // expected-error {{'b1' following the 'template' keyword does not refer to a template}}
+}
+
+template void f5<0>(); // expected-note {{in instantiation of function template specialization 'f5<0>' requested here}}
diff --git a/test/SemaTemplate/template-id-printing.cpp b/test/SemaTemplate/template-id-printing.cpp
index fcd4974..047589b 100644
--- a/test/SemaTemplate/template-id-printing.cpp
+++ b/test/SemaTemplate/template-id-printing.cpp
@@ -11,3 +11,131 @@ void g() {
// CHECK: N::f<double>
void (*fp)(int) = N::f<double>;
}
+
+
+// (NNS qualified) DeclRefExpr.
+namespace DRE {
+
+template <typename T>
+void foo();
+
+void test() {
+ // CHECK: DRE::foo<int>;
+ DRE::foo<int>;
+ // CHECK: DRE::template foo<int>;
+ DRE::template foo<int>;
+ // CHECK: DRE::foo<int>();
+ DRE::foo<int>();
+ // CHECK: DRE::template foo<int>();
+ DRE::template foo<int>();
+}
+
+} // namespace DRE
+
+
+// MemberExpr.
+namespace ME {
+
+struct S {
+ template <typename T>
+ void mem();
+};
+
+void test() {
+ S s;
+ // CHECK: s.mem<int>();
+ s.mem<int>();
+ // CHECK: s.template mem<int>();
+ s.template mem<int>();
+}
+
+} // namespace ME
+
+
+// UnresolvedLookupExpr.
+namespace ULE {
+
+template <typename T>
+int foo();
+
+template <typename T>
+void test() {
+ // CHECK: ULE::foo<T>;
+ ULE::foo<T>;
+ // CHECK: ULE::template foo<T>;
+ ULE::template foo<T>;
+}
+
+} // namespace ULE
+
+
+// UnresolvedMemberExpr.
+namespace UME {
+
+struct S {
+ template <typename T>
+ void mem();
+};
+
+template <typename U>
+void test() {
+ S s;
+ // CHECK: s.mem<U>();
+ s.mem<U>();
+ // CHECK: s.template mem<U>();
+ s.template mem<U>();
+}
+
+} // namespace UME
+
+
+// DependentScopeDeclRefExpr.
+namespace DSDRE {
+
+template <typename T>
+struct S;
+
+template <typename T>
+void test() {
+ // CHECK: S<T>::foo;
+ S<T>::foo;
+ // CHECK: S<T>::template foo;
+ S<T>::template foo;
+ // CHECK: S<T>::template foo<>;
+ S<T>::template foo<>;
+ // CHECK: S<T>::template foo<T>;
+ S<T>::template foo<T>;
+}
+
+} // namespace DSDRE
+
+
+// DependentScopeMemberExpr.
+namespace DSME {
+
+template <typename T>
+struct S;
+
+template <typename T>
+void test() {
+ S<T> s;
+ // CHECK: s.foo;
+ s.foo;
+ // CHECK: s.template foo;
+ s.template foo;
+ // CHECK: s.template foo<>;
+ s.template foo<>;
+ // CHECK: s.template foo<T>;
+ s.template foo<T>;
+}
+
+} // namespace DSME
+
+namespace DSDRE_withImplicitTemplateArgs {
+
+template <typename T> void foo() {
+ // CHECK: T::template bar();
+ T::template bar();
+}
+
+} // namespace DSDRE_withImplicitTemplateArgs
diff --git a/test/Tooling/clang-check-pwd.cpp b/test/Tooling/clang-check-pwd.cpp
new file mode 100644
index 0000000..cb94344
--- /dev/null
+++ b/test/Tooling/clang-check-pwd.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: PWD="%t" clang-check "%t" "test.cpp" 2>&1|FileCheck %s
+// FIXME: Make the above easier.
+
+// CHECK: C++ requires
+invalid;
+
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// FIXME: clang-check doesn't like gcc driver on cygming.
+// XFAIL: cygwin,mingw32,win32
diff --git a/test/Tooling/clang-check.cpp b/test/Tooling/clang-check.cpp
new file mode 100644
index 0000000..de10e4a
--- /dev/null
+++ b/test/Tooling/clang-check.cpp
@@ -0,0 +1,13 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s
+// FIXME: Make the above easier.
+
+// CHECK: C++ requires
+invalid;
+
+// FIXME: JSON doesn't like path separator '\', on Win32 hosts.
+// FIXME: clang-check doesn't like gcc driver on cygming.
+// XFAIL: cygwin,mingw32,win32
diff --git a/test/lit.cfg b/test/lit.cfg
index 1f4a845..738dc38 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -32,7 +32,7 @@ execute_external = (platform.system() != 'Windows'
config.test_format = lit.formats.ShTest(execute_external)
# suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl']
+config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
@@ -46,6 +46,35 @@ if clang_obj_root is not None:
config.llvm_src_root = getattr(config, 'llvm_src_root', None)
config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
+# Clear some environment variables that might affect Clang.
+#
+# This first set of vars are read by Clang, but shouldn't affect tests
+# that aren't specifically looking for these features, or are required
+# simply to run the tests at all.
+#
+# FIXME: Should we have a tool that enforces this?
+
+# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
+# 'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
+# 'IOS_SIMULATOR_DEPLOYMENT_TARGET',
+# 'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
+# 'VC80COMNTOOLS')
+possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+ 'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+ 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+ 'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+ 'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+ 'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+ 'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+ 'LIBCLANG_RESOURCE_USAGE',
+ 'LIBCLANG_CODE_COMPLETION_LOGGING']
+# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
+if platform.system() != 'Windows':
+ possibly_dangerous_env_vars.append('INCLUDE')
+for name in possibly_dangerous_env_vars:
+ if name in config.environment:
+ del config.environment[name]
+
# Tweak the PATH to include the tools dir and the scripts dir.
if clang_obj_root is not None:
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
@@ -194,8 +223,9 @@ if platform.system() not in ['Windows'] or lit.getBashPath() != '':
config.available_features.add('shell')
# Registered Targets
-def getRegisteredTargets(tool):
+def get_llc_props(tool):
set_of_targets = set()
+ enable_assertions = False
cmd = subprocess.Popen([tool, '-version'], stdout=subprocess.PIPE)
@@ -211,10 +241,17 @@ def getRegisteredTargets(tool):
elif "Registered Targets:" in line:
parse_targets = True
- return set_of_targets
+ if re.search(r'with assertions', line):
+ enable_assertions = True
-registered_targets = getRegisteredTargets(os.path.join(llvm_tools_dir, 'llc'))
-if len(registered_targets) > 0:
- config.available_features.update(registered_targets)
+ return {"set_of_targets": set_of_targets,
+ "enable_assertions": enable_assertions}
+
+llc_props = get_llc_props(os.path.join(llvm_tools_dir, 'llc'))
+if len(llc_props['set_of_targets']) > 0:
+ config.available_features.update(llc_props['set_of_targets'])
else:
lit.fatal('No Targets Registered with the LLVM Tools!')
+
+if llc_props['enable_assertions']:
+ config.available_features.add('asserts')
OpenPOWER on IntegriCloud