summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/CFNumber.c7
-rw-r--r--test/Analysis/bstring.c37
-rw-r--r--test/Analysis/misc-ps-cxx0x.cpp11
-rw-r--r--test/Analysis/misc-ps-region-store.cpp19
-rw-r--r--test/Analysis/misc-ps-region-store.m24
-rw-r--r--test/Analysis/misc-ps.c83
-rw-r--r--test/Analysis/misc-ps.m25
-rw-r--r--test/Analysis/plist-output-alternate.m9
-rw-r--r--test/Analysis/retain-release.m10
-rw-r--r--test/Analysis/retain-release.mm306
-rw-r--r--test/Analysis/string.c174
-rw-r--r--test/CMakeLists.txt24
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp3
-rw-r--r--test/CXX/class.access/class.friend/p2-cxx03.cpp2
-rw-r--r--test/CXX/class.access/p4.cpp6
-rw-r--r--test/CXX/class/class.friend/p2.cpp4
-rw-r--r--test/CXX/class/class.mem/p1b.cpp2
-rw-r--r--test/CXX/class/class.mem/p5-0x.cpp9
-rw-r--r--test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp32
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp25
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp8
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp19
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp9
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp63
-rw-r--r--test/CXX/dcl.decl/dcl.init/p14-0x.cpp44
-rw-r--r--test/CXX/dcl.decl/dcl.init/p6.cpp12
-rw-r--r--test/CXX/except/except.spec/p1.cpp13
-rw-r--r--test/CXX/except/except.spec/p14.cpp14
-rw-r--r--test/CXX/except/except.spec/p9-dynamic.cpp2
-rw-r--r--test/CXX/expr/expr.const/p2-0x.cpp25
-rw-r--r--test/CXX/expr/expr.post/expr.call/p7-0x.cpp17
-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.unary.noexcept/sema.cpp13
-rw-r--r--test/CXX/special/class.ctor/p5-0x.cpp173
-rw-r--r--test/CXX/special/class.dtor/p3-0x.cpp177
-rw-r--r--test/CXX/special/class.init/class.base.init/p8-0x.cpp23
-rw-r--r--test/CXX/special/class.init/class.base.init/p9-0x.cpp36
-rw-r--r--test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp55
-rw-r--r--test/CXX/stmt.stmt/stmt.dcl/p3.cpp47
-rw-r--r--test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp6
-rw-r--r--test/CXX/temp/temp.decls/p3.cpp7
-rw-r--r--test/CXX/temp/temp.decls/temp.alias/p1.cpp8
-rw-r--r--test/CXX/temp/temp.decls/temp.alias/p2.cpp45
-rw-r--r--test/CXX/temp/temp.decls/temp.alias/p3.cpp13
-rw-r--r--test/CXX/temp/temp.decls/temp.friend/p3.cpp2
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp7
-rw-r--r--test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp41
-rw-r--r--test/CXX/temp/temp.param/p10-0x.cpp13
-rw-r--r--test/CXX/temp/temp.param/p11-0x.cpp31
-rw-r--r--test/CXX/temp/temp.param/p9-0x.cpp9
-rw-r--r--test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp30
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp209
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp11
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp14
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp5
-rw-r--r--test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp34
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p2.cpp4
-rw-r--r--test/CXX/temp/temp.type/p1-0x.cpp23
-rw-r--r--test/CodeGen/2009-10-20-GlobalDebug.c1
-rw-r--r--test/CodeGen/altivec.c2
-rw-r--r--test/CodeGen/arm-asm.c7
-rw-r--r--test/CodeGen/asm-errors.c1
-rw-r--r--test/CodeGen/asm-label.c12
-rw-r--r--test/CodeGen/available-externally-suppress.c10
-rw-r--r--test/CodeGen/avx-cmp-builtins.c46
-rw-r--r--test/CodeGen/builtins-ppc-altivec.c86
-rw-r--r--test/CodeGen/builtins-x86.c1
-rw-r--r--test/CodeGen/builtinshufflevector.c3
-rw-r--r--test/CodeGen/byval-memcpy-elim.c20
-rw-r--r--test/CodeGen/debug-info-crash.c1
-rw-r--r--test/CodeGen/debug-info.c9
-rw-r--r--test/CodeGen/decl.c4
-rw-r--r--test/CodeGen/ext-vector.c26
-rw-r--r--test/CodeGen/extern-inline.c1
-rw-r--r--test/CodeGen/frame-pointer-elim.c2
-rw-r--r--test/CodeGen/inline.c2
-rw-r--r--test/CodeGen/mmx-builtins.c1
-rw-r--r--test/CodeGen/ms_struct-bitfield-1.c91
-rw-r--r--test/CodeGen/ms_struct-bitfield-2.c135
-rw-r--r--test/CodeGen/ms_struct-bitfield-3.c49
-rw-r--r--test/CodeGen/ms_struct-pack.c125
-rw-r--r--test/CodeGen/ms_struct.c23
-rw-r--r--test/CodeGen/packed-arrays.c14
-rw-r--r--test/CodeGen/packed-structure.c9
-rw-r--r--test/CodeGen/palignr.c1
-rw-r--r--test/CodeGen/string-literal-short-wstring.c2
-rw-r--r--test/CodeGen/string-literal.c8
-rw-r--r--test/CodeGen/struct-passing.c4
-rw-r--r--test/CodeGen/transparent-union.c2
-rw-r--r--test/CodeGen/x86_32-arguments-darwin.c6
-rw-r--r--test/CodeGen/x86_32-arguments-linux.c4
-rw-r--r--test/CodeGen/x86_64-arguments.c2
-rw-r--r--test/CodeGenCXX/PR5050-constructor-conversion.cpp1
-rw-r--r--test/CodeGenCXX/abstract-class-ctors-dtors.cpp16
-rw-r--r--test/CodeGenCXX/arm.cpp8
-rw-r--r--test/CodeGenCXX/array-construction.cpp1
-rw-r--r--test/CodeGenCXX/array-operator-delete-call.cpp1
-rw-r--r--test/CodeGenCXX/call-arg-zero-temp.cpp1
-rw-r--r--test/CodeGenCXX/cast-conversion.cpp1
-rw-r--r--test/CodeGenCXX/constructor-conversion.cpp1
-rw-r--r--test/CodeGenCXX/constructor-default-arg.cpp1
-rw-r--r--test/CodeGenCXX/constructor-for-array-members.cpp1
-rw-r--r--test/CodeGenCXX/constructor-template.cpp1
-rw-r--r--test/CodeGenCXX/convert-to-fptr.cpp1
-rw-r--r--test/CodeGenCXX/copy-assign-synthesis-1.cpp1
-rw-r--r--test/CodeGenCXX/cxx0x-defaulted-templates.cpp19
-rw-r--r--test/CodeGenCXX/cxx0x-delegating-ctors.cpp42
-rw-r--r--test/CodeGenCXX/debug-info-pubtypes.cpp15
-rw-r--r--test/CodeGenCXX/decl-ref-init.cpp1
-rw-r--r--test/CodeGenCXX/default-constructor-for-members.cpp1
-rw-r--r--test/CodeGenCXX/derived-to-base-conv.cpp1
-rw-r--r--test/CodeGenCXX/destructors.cpp4
-rw-r--r--test/CodeGenCXX/eh.cpp22
-rw-r--r--test/CodeGenCXX/exceptions.cpp2
-rw-r--r--test/CodeGenCXX/global-array-destruction.cpp1
-rw-r--r--test/CodeGenCXX/global-llvm-constant.cpp22
-rw-r--r--test/CodeGenCXX/goto.cpp1
-rw-r--r--test/CodeGenCXX/instrument-functions.cpp30
-rw-r--r--test/CodeGenCXX/internal-linkage.cpp8
-rw-r--r--test/CodeGenCXX/mangle-alias-template.cpp41
-rw-r--r--test/CodeGenCXX/mangle-exprs.cpp16
-rw-r--r--test/CodeGenCXX/mangle-subst-std.cpp1
-rw-r--r--test/CodeGenCXX/mangle-unnameable-conversions.cpp14
-rw-r--r--test/CodeGenCXX/mangle.cpp43
-rw-r--r--test/CodeGenCXX/member-init-ctor.cpp14
-rw-r--r--test/CodeGenCXX/new.cpp52
-rw-r--r--test/CodeGenCXX/nrvo.cpp2
-rw-r--r--test/CodeGenCXX/pr9965.cpp12
-rw-r--r--test/CodeGenCXX/ptr-to-member-function.cpp1
-rw-r--r--test/CodeGenCXX/scoped-enums.cpp9
-rw-r--r--test/CodeGenCXX/skip-vtable-pointer-initialization.cpp200
-rw-r--r--test/CodeGenCXX/static-init-2.cpp2
-rw-r--r--test/CodeGenCXX/template-instantiation.cpp30
-rw-r--r--test/CodeGenCXX/threadsafe-statics-exceptions.cpp2
-rw-r--r--test/CodeGenCXX/thunks.cpp30
-rw-r--r--test/CodeGenCXX/vararg-non-pod.cpp16
-rw-r--r--test/CodeGenCXX/virtual-base-destructor-call.cpp10
-rw-r--r--test/CodeGenCXX/x86_32-arguments.cpp4
-rw-r--r--test/CodeGenObjC/bitfield-ivar-offsets.m14
-rw-r--r--test/CodeGenObjC/blocks-2.m2
-rw-r--r--test/CodeGenObjC/constant-string-class-1.m23
-rw-r--r--test/CodeGenObjC/constant-string-class.m2
-rw-r--r--test/CodeGenObjC/debug-info-block-helper.m30
-rw-r--r--test/CodeGenObjC/debug-info-blocks.m55
-rw-r--r--test/CodeGenObjC/debug-info-class-extension.m15
-rw-r--r--test/CodeGenObjC/debug-info-class-extension2.m14
-rw-r--r--test/CodeGenObjC/debug-info-class-extension3.m12
-rw-r--r--test/CodeGenObjC/debug-info-crash.m1
-rw-r--r--test/CodeGenObjC/debug-info-getter-name.m3
-rw-r--r--test/CodeGenObjC/debug-info-pubtypes.m19
-rw-r--r--test/CodeGenObjC/debug-info-static-var.m1
-rw-r--r--test/CodeGenObjC/debug-property-synth.m19
-rw-r--r--test/CodeGenObjC/encode-test.m17
-rw-r--r--test/CodeGenObjC/forward-decl-param.m19
-rw-r--r--test/CodeGenObjC/instance-method-metadata.m1
-rw-r--r--test/CodeGenObjC/interface-layout-64.m22
-rw-r--r--test/CodeGenObjC/ivar-layout-array0-struct.m1
-rw-r--r--test/CodeGenObjC/ivar-layout-no-optimize.m1
-rw-r--r--test/CodeGenObjC/messages-2.m28
-rw-r--r--test/CodeGenObjC/metadata-symbols-64.m2
-rw-r--r--test/CodeGenObjC/no-vararg-messaging.m1
-rw-r--r--test/CodeGenObjC/objc-read-weak-byref.m1
-rw-r--r--test/CodeGenObjC/protocol-in-extended-class.m1
-rw-r--r--test/CodeGenObjC/try.m1
-rw-r--r--test/CodeGenObjC/unwind-fn.m14
-rw-r--r--test/CodeGenObjCXX/block-in-template-inst.mm71
-rw-r--r--test/CodeGenObjCXX/blocks.mm18
-rw-r--r--test/CodeGenObjCXX/encode.mm70
-rw-r--r--test/CodeGenObjCXX/mangle.mm12
-rw-r--r--test/CodeGenObjCXX/property-object-conditional-exp.mm7
-rw-r--r--test/Driver/cc-log-diagnostics.c12
-rw-r--r--test/Driver/cfi.c8
-rw-r--r--test/Driver/darwin-debug-flags.c2
-rw-r--r--test/Driver/darwin-ld.c7
-rw-r--r--test/Driver/nostdlib.c4
-rw-r--r--test/Driver/rewrite-objc.m2
-rw-r--r--test/Driver/sysroot.c18
-rw-r--r--test/FixIt/fixit-cxx0x.cpp2
-rw-r--r--test/Frontend/diagnostic-name.c4
-rw-r--r--test/Frontend/ir-support-codegen.ll1
-rw-r--r--test/Frontend/undef.c4
-rw-r--r--test/Index/Inputs/guarded.h6
-rw-r--r--test/Index/Inputs/pragma-once.h3
-rw-r--r--test/Index/annotate-context-sensitive.cpp12
-rw-r--r--test/Index/annotate-tokens-pp.c8
-rw-r--r--test/Index/annotate-tokens.m8
-rw-r--r--test/Index/complete-kvc.m20
-rw-r--r--test/Index/complete-member-access.m17
-rw-r--r--test/Index/complete-property-flags.m1
-rw-r--r--test/Index/nested-macro-instantiations.cpp20
-rw-r--r--test/Index/overrides.cpp4
-rw-r--r--test/Index/properties-class-extensions.m2
-rw-r--r--test/Index/recursive-cxx-member-calls.cpp34
-rw-r--r--test/Index/usrs.cpp22
-rw-r--r--test/Index/usrs.m2
-rw-r--r--test/Lexer/block_cmt_end.c8
-rw-r--r--test/Lexer/has_extension.c30
-rw-r--r--test/Lexer/has_extension_cxx.cpp36
-rw-r--r--test/Lexer/has_feature_c1x.c20
-rw-r--r--test/Lexer/has_feature_cxx0x.cpp11
-rw-r--r--test/Lexer/has_feature_type_traits.cpp10
-rw-r--r--test/Misc/Inputs/include.h2
-rw-r--r--test/Misc/diag-format.c34
-rw-r--r--test/Misc/include-stack-for-note-flag.cpp10
-rw-r--r--test/PCH/cxx-alias-decl.cpp20
-rw-r--r--test/PCH/cxx-alias-decl.h11
-rw-r--r--test/PCH/cxx-for-range.cpp6
-rw-r--r--test/PCH/cxx-member-init.cpp22
-rw-r--r--test/PCH/cxx-reference.cpp6
-rw-r--r--test/PCH/cxx-static_assert.cpp15
-rw-r--r--test/PCH/cxx-static_assert.h9
-rw-r--r--test/PCH/cxx0x-default-delete.cpp23
-rw-r--r--test/PCH/cxx0x-delegating-ctors.cpp20
-rw-r--r--test/PCH/modified-header-error.c11
-rw-r--r--test/PCH/objc_methods.h2
-rw-r--r--test/PCH/objc_methods.m2
-rw-r--r--test/PCH/objcxx-ivar-class.mm2
-rw-r--r--test/Parser/MicrosoftExtensions.cpp100
-rw-r--r--test/Parser/cxx-default-delete.cpp15
-rw-r--r--test/Parser/cxx-ext-delete-default.cpp11
-rw-r--r--test/Parser/cxx-friend.cpp6
-rw-r--r--test/Parser/cxx0x-member-initializers.cpp15
-rw-r--r--test/Parser/nested-namespaces-recovery.cpp24
-rw-r--r--test/Parser/opencl-astype.cl20
-rw-r--r--test/Preprocessor/if_warning.c4
-rw-r--r--test/Preprocessor/pragma_sysheader.c9
-rw-r--r--test/Sema/MicrosoftExtensions.c8
-rw-r--r--test/Sema/arm-neon-types.c9
-rw-r--r--test/Sema/asm.c8
-rw-r--r--test/Sema/attr-unknown.c2
-rw-r--r--test/Sema/builtins-arm.c5
-rw-r--r--test/Sema/carbon.c2
-rw-r--r--test/Sema/exprs.c18
-rw-r--r--test/Sema/illegal-types.c2
-rw-r--r--test/Sema/parentheses.c24
-rw-r--r--test/Sema/parentheses.cpp31
-rw-r--r--test/Sema/stdcall-fastcall.c3
-rw-r--r--test/Sema/uninit-variables.c13
-rw-r--r--test/Sema/x86-builtin-palignr.c3
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp74
-rw-r--r--test/SemaCXX/PR9572.cpp8
-rw-r--r--test/SemaCXX/PR9884.cpp17
-rw-r--r--test/SemaCXX/PR9902.cpp28
-rw-r--r--test/SemaCXX/PR9908.cpp32
-rw-r--r--test/SemaCXX/aggregate-initialization.cpp4
-rw-r--r--test/SemaCXX/alias-template.cpp147
-rw-r--r--test/SemaCXX/anonymous-union.cpp30
-rw-r--r--test/SemaCXX/attr-cxx0x.cpp5
-rw-r--r--test/SemaCXX/attr-noreturn.cpp17
-rw-r--r--test/SemaCXX/attr-regparm.cpp3
-rw-r--r--test/SemaCXX/class.cpp2
-rw-r--r--test/SemaCXX/conversion.cpp11
-rw-r--r--test/SemaCXX/copy-constructor-error.cpp4
-rw-r--r--test/SemaCXX/cxx0x-cursory-default-delete.cpp69
-rw-r--r--test/SemaCXX/cxx0x-defaulted-functions.cpp45
-rw-r--r--test/SemaCXX/cxx0x-delegating-ctors.cpp24
-rw-r--r--test/SemaCXX/cxx0x-deleted-default-ctor.cpp120
-rw-r--r--test/SemaCXX/cxx0x-nontrivial-union.cpp22
-rw-r--r--test/SemaCXX/default-arg-special-member.cpp12
-rw-r--r--test/SemaCXX/default-constructor-initializers.cpp7
-rw-r--r--test/SemaCXX/defaulted-ctor-loop.cpp14
-rw-r--r--test/SemaCXX/deleted-function-extension.cpp8
-rw-r--r--test/SemaCXX/deleted-function.cpp5
-rw-r--r--test/SemaCXX/dependent-noexcept-unevaluated.cpp41
-rw-r--r--test/SemaCXX/dependent-types.cpp5
-rw-r--r--test/SemaCXX/destructor.cpp175
-rw-r--r--test/SemaCXX/enum-scoped.cpp10
-rw-r--r--test/SemaCXX/expressions.cpp31
-rw-r--r--test/SemaCXX/generalized-initializers.cpp174
-rw-r--r--test/SemaCXX/implicit-exception-spec.cpp63
-rw-r--r--test/SemaCXX/implicit-member-functions.cpp2
-rw-r--r--test/SemaCXX/member-expr.cpp12
-rw-r--r--test/SemaCXX/member-init.cpp50
-rw-r--r--test/SemaCXX/member-pointer.cpp25
-rw-r--r--test/SemaCXX/nullptr.cpp57
-rw-r--r--test/SemaCXX/overload-call.cpp22
-rw-r--r--test/SemaCXX/overloaded-operator.cpp17
-rw-r--r--test/SemaCXX/redeclared-alias-template.cpp23
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp162
-rw-r--r--test/SemaCXX/return.cpp16
-rw-r--r--test/SemaCXX/struct-class-redecl.cpp160
-rw-r--r--test/SemaCXX/switch.cpp2
-rw-r--r--test/SemaCXX/tag-ambig.cpp28
-rw-r--r--test/SemaCXX/type-traits.cpp102
-rw-r--r--test/SemaCXX/underlying_type.cpp37
-rw-r--r--test/SemaCXX/value-initialization.cpp9
-rw-r--r--test/SemaCXX/vararg-non-pod.cpp9
-rw-r--r--test/SemaCXX/vtable-instantiation.cc50
-rw-r--r--test/SemaCXX/warn-bad-memaccess.cpp70
-rw-r--r--test/SemaCXX/warn-non-pod-memset.cpp63
-rw-r--r--test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp7
-rw-r--r--test/SemaObjC/exprs.m10
-rw-r--r--test/SemaObjC/gc-attributes.m22
-rw-r--r--test/SemaObjC/objc2-warn-weak-decl.m2
-rw-r--r--test/SemaObjC/related-result-type-inference.m171
-rw-r--r--test/SemaObjCXX/blocks.mm26
-rw-r--r--test/SemaObjCXX/gc-attributes.mm22
-rw-r--r--test/SemaObjCXX/namespace-lookup.mm14
-rw-r--r--test/SemaObjCXX/nullptr.mm13
-rw-r--r--test/SemaObjCXX/overload-gc.mm4
-rw-r--r--test/SemaObjCXX/overload.mm4
-rw-r--r--test/SemaObjCXX/related-result-type-inference.mm71
-rw-r--r--test/SemaTemplate/alias-church-numerals.cpp34
-rw-r--r--test/SemaTemplate/alias-nested-nontag.cpp6
-rw-r--r--test/SemaTemplate/alias-template-template-param.cpp7
-rw-r--r--test/SemaTemplate/alias-templates.cpp70
-rw-r--r--test/SemaTemplate/deduction-crash.cpp36
-rw-r--r--test/SemaTemplate/dependent-names-no-std.cpp21
-rw-r--r--test/SemaTemplate/dependent-names.cpp135
-rw-r--r--test/SemaTemplate/friend-template.cpp8
-rw-r--r--test/SemaTemplate/instantiate-call.cpp5
-rw-r--r--test/SemaTemplate/instantiate-function-1.cpp22
-rw-r--r--test/SemaTemplate/instantiate-init.cpp52
-rw-r--r--test/SemaTemplate/partial-spec-instantiate.cpp10
-rw-r--r--test/SemaTemplate/rdar9173693.cpp6
-rw-r--r--test/SemaTemplate/typename-specifier.cpp31
-rw-r--r--test/lit.cfg30
319 files changed, 7263 insertions, 572 deletions
diff --git a/test/Analysis/CFNumber.c b/test/Analysis/CFNumber.c
index dd57cd9..11af0747 100644
--- a/test/Analysis/CFNumber.c
+++ b/test/Analysis/CFNumber.c
@@ -22,10 +22,15 @@ CFNumberRef f1(unsigned char x) {
return CFNumberCreate(0, kCFNumberSInt16Type, &x); // expected-warning{{An 8 bit integer is used to initialize a CFNumber object that represents a 16 bit integer. 8 bits of the CFNumber value will be garbage.}}
}
-CFNumberRef f2(unsigned short x) {
+__attribute__((cf_returns_retained)) CFNumberRef f2(unsigned short x) {
return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{A 16 bit integer is used to initialize a CFNumber object that represents an 8 bit integer. 8 bits of the input integer will be lost.}}
}
+// test that the attribute overrides the naming convention.
+__attribute__((cf_returns_not_retained)) CFNumberRef CreateNum(unsigned char x) {
+ return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{leak}}
+}
+
CFNumberRef f3(unsigned i) {
return CFNumberCreate(0, kCFNumberLongType, &i); // expected-warning{{A 32 bit integer is used to initialize a CFNumber object that represents a 64 bit integer.}}
}
diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c
index 1f6839d..68bbb1a 100644
--- a/test/Analysis/bstring.c
+++ b/test/Analysis/bstring.c
@@ -136,13 +136,38 @@ void memcpy13() {
memcpy(a, 0, 0); // no-warning
}
+void memcpy_unknown_size (size_t n) {
+ char a[4], b[4] = {1};
+ if (memcpy(a, b, n) != a)
+ (void)*(char*)0; // no-warning
+}
+
+void memcpy_unknown_size_warn (size_t n) {
+ char a[4];
+ if (memcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to byte string function}}
+ (void)*(char*)0; // no-warning
+}
+
//===----------------------------------------------------------------------===
// mempcpy()
//===----------------------------------------------------------------------===
+#ifdef VARIANT
+
+#define __mempcpy_chk BUILTIN(__mempcpy_chk)
+void *__mempcpy_chk(void *restrict s1, const void *restrict s2, size_t n,
+ size_t destlen);
+
+#define mempcpy(a,b,c) __mempcpy_chk(a,b,c,(size_t)-1)
+
+#else /* VARIANT */
+
#define mempcpy BUILTIN(mempcpy)
void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
+#endif /* VARIANT */
+
+
void mempcpy0 () {
char src[] = {1, 2, 3, 4};
char dst[5] = {0};
@@ -233,6 +258,18 @@ void mempcpy13() {
mempcpy(a, 0, 0); // no-warning
}
+void mempcpy_unknown_size_warn (size_t n) {
+ char a[4];
+ if (mempcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to byte string function}}
+ (void)*(char*)0; // no-warning
+}
+
+void mempcpy_unknownable_size (char *src, float n) {
+ char a[4];
+ // This used to crash because we don't model floats.
+ mempcpy(a, src, (size_t)n);
+}
+
//===----------------------------------------------------------------------===
// memmove()
//===----------------------------------------------------------------------===
diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp
new file mode 100644
index 0000000..f21e82c
--- /dev/null
+++ b/test/Analysis/misc-ps-cxx0x.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang --analyze -std=c++0x %s -Xclang -verify
+
+void test_static_assert() {
+ static_assert(sizeof(void *) == sizeof(void*), "test_static_assert");
+}
+
+void test_analyzer_working() {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+
diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp
index b122bff..7959359 100644
--- a/test/Analysis/misc-ps-region-store.cpp
+++ b/test/Analysis/misc-ps-region-store.cpp
@@ -395,3 +395,22 @@ unsigned test_invalidate_in_ctor_new() {
return x; // no-warning
}
+// Test assigning into a symbolic offset.
+struct TestAssignIntoSymbolicOffset {
+ int **stuff[100];
+ void test(int x, int y);
+};
+
+void TestAssignIntoSymbolicOffset::test(int x, int y) {
+ x--;
+ if (x > 8 || x < 0)
+ return;
+ if (stuff[x])
+ return;
+ if (!stuff[x]) {
+ stuff[x] = new int*[y+1];
+ // Previously triggered a null dereference.
+ stuff[x][y] = 0; // no-warning
+ }
+}
+
diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m
index be0356d..27f12c9 100644
--- a/test/Analysis/misc-ps-region-store.m
+++ b/test/Analysis/misc-ps-region-store.m
@@ -1299,3 +1299,27 @@ RDar9163742_Rect RDar9163742_IntegralRect(RDar9163742_Rect frame)
return RDar9163742_RectIntegral(integralFrame); // no-warning; all fields initialized
}
+// Test correct handling of prefix '--' operator.
+void rdar9444714() {
+ int x;
+ char str[ 32 ];
+ char buf[ 32 ];
+ char * dst;
+ char * ptr;
+
+ x = 1234;
+ dst = str;
+ ptr = buf;
+ do
+ {
+ *ptr++ = (char)( '0' + ( x % 10 ) );
+ x /= 10;
+ } while( x > 0 );
+
+ while( ptr > buf )
+ {
+ *dst++ = *( --( ptr ) ); // no-warning
+ }
+ *dst = '\0';
+}
+
diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c
new file mode 100644
index 0000000..bef5b06
--- /dev/null
+++ b/test/Analysis/misc-ps.c
@@ -0,0 +1,83 @@
+// 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() {
+ int x;
+ int j = 0;
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ x = 1;
+
+ int extra = (2 + foo_rdar9373039 ("Clang") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("Clang")) % 4)) % 4)) + (2 + foo_rdar9373039 ("1.0") + ((4 - ((unsigned int) (2 + foo_rdar9373039 ("1.0")) % 4)) % 4)); // expected-warning {{never read}}
+
+ for (int i = 0 ; i < size_rdar9373039 ; ++i)
+ j += x; // expected-warning {{garbage}}
+
+ return j;
+}
+
+
+int PR8962 (int *t) {
+ // This should look through the __extension__ no-op.
+ if (__extension__ (t)) return 0;
+ return *t; // expected-warning {{null pointer}}
+}
+
+int PR8962_b (int *t) {
+ // This should still ignore the nested casts
+ // which aren't handled by a single IgnoreParens()
+ if (((int)((int)t))) return 0;
+ return *t; // expected-warning {{null pointer}}
+}
+
+int PR8962_c (int *t) {
+ // If the last element in a StmtExpr was a ParenExpr, it's still live
+ if (({ (t ? (_Bool)0 : (_Bool)1); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_d (int *t) {
+ // If the last element in a StmtExpr is an __extension__, it's still live
+ if (({ __extension__(t ? (_Bool)0 : (_Bool)1); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_e (int *t) {
+ // Redundant casts can mess things up!
+ // Environment used to skip through NoOp casts, but LiveVariables didn't!
+ if (({ (t ? (int)(int)0L : (int)(int)1L); })) return 0;
+ return *t; // no-warning
+}
+
+int PR8962_f (int *t) {
+ // The StmtExpr isn't a block-level expression here,
+ // the __extension__ is. But the value should be attached to the StmtExpr
+ // anyway. Make sure the block-level check is /before/ IgnoreParens.
+ if ( __extension__({
+ _Bool r;
+ if (t) r = 0;
+ else r = 1;
+ r;
+ }) ) return 0;
+ return *t; // no-warning
+}
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 9de4afb..da84b24 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -1301,3 +1301,28 @@ static void test(unsigned int bit_mask)
}
}
}
+
+// Don't crash on code containing __label__.
+int radar9414427_aux();
+void radar9414427() {
+ __label__ mylabel;
+ if (radar9414427_aux()) {
+ mylabel: do {}
+ while (0);
+ }
+}
+
+// Analyze methods in @implementation (category)
+@interface RDar9465344
+@end
+
+@implementation RDar9465344 (MyCategory)
+- (void) testcategoryImpl {
+ int *p = 0x0;
+ *p = 0xDEADBEEF; // expected-warning {{null}}
+}
+@end
+
+@implementation RDar9465344
+@end
+
diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m
index a7e3c3c..0f4d3ae 100644
--- a/test/Analysis/plist-output-alternate.m
+++ b/test/Analysis/plist-output-alternate.m
@@ -864,9 +864,9 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count (owning reference)</string>
+// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
// CHECK: <key>message</key>
-// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count (owning reference)</string>
+// CHECK: <string>Call to function &apos;CFNumberCreate&apos; returns a Core Foundation object with a +1 retain count</string>
// CHECK: </dict>
// CHECK: <dict>
// CHECK: <key>kind</key><string>control</string>
@@ -994,9 +994,9 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </array>
// CHECK: <key>extended_message</key>
-// CHECK: <string>Object allocated on line 53 and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1 (object leaked)</string>
+// 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 allocated on line 53 and stored into &apos;value&apos; is not referenced later in this execution path and has a retain count of +1 (object leaked)</string>
+// 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>
@@ -1012,3 +1012,4 @@ void rdar8331641(int x) {
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
+
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 6782c90..7af14f1 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -280,7 +280,7 @@ CFAbsoluteTime f1() {
CFRelease(date);
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;
}
@@ -291,7 +291,7 @@ CFAbsoluteTime f2() {
CFRelease(date);
CFDateGetAbsoluteTime(date); // no-warning
[((NSDate*) date) release];
- 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;
}
@@ -343,7 +343,7 @@ CFDateRef f6(int x) {
CFDateRef f7() {
CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}}
CFRetain(date);
- date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+ date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}}
return date;
}
@@ -357,8 +357,8 @@ CFDateRef f8() {
return date;
}
-CFDateRef f9() {
- CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
+__attribute__((cf_returns_retained)) CFDateRef f9() {
+ CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning
int *p = 0;
// When allocations fail, CFDateCreate can return null.
if (!date) *p = 1; // expected-warning{{null}}
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
new file mode 100644
index 0000000..0faeb1a
--- /dev/null
+++ b/test/Analysis/retain-release.mm
@@ -0,0 +1,306 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease -analyzer-store=region -fblocks -verify %s
+
+#if __has_feature(attribute_ns_returns_retained)
+#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
+#endif
+#if __has_feature(attribute_cf_returns_retained)
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#endif
+#if __has_feature(attribute_ns_returns_not_retained)
+#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
+#endif
+#if __has_feature(attribute_cf_returns_not_retained)
+#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
+#endif
+#if __has_feature(attribute_ns_consumes_self)
+#define NS_CONSUMES_SELF __attribute__((ns_consumes_self))
+#endif
+#if __has_feature(attribute_ns_consumed)
+#define NS_CONSUMED __attribute__((ns_consumed))
+#endif
+#if __has_feature(attribute_cf_consumed)
+#define CF_CONSUMED __attribute__((cf_consumed))
+#endif
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from Mac OS X headers:
+//
+// #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 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;
+@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;
+- ( 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);
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+class SmartPointer {
+ id x;
+public:
+ SmartPointer(id x) : x(x) {}
+ ~SmartPointer() { [x release]; }
+
+ void adopt(id x);
+ void noAdopt(id x);
+};
+
+void test_positive() {
+ id x = [[NSObject alloc] init]; // expected-warning {{leak}}
+}
+
+void test_smartpointer_1() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(x);
+}
+
+void test_smartpointer_2() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.adopt(x);
+}
+
+// FIXME: Eventually we want annotations to say whether or not
+// a C++ method claims ownership of an Objective-C object.
+void test_smartpointer_3() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.noAdopt(x);
+}
+
+
diff --git a/test/Analysis/string.c b/test/Analysis/string.c
index 19c838c..e6baf51 100644
--- a/test/Analysis/string.c
+++ b/test/Analysis/string.c
@@ -328,74 +328,6 @@ void strcpy_no_overflow(char *y) {
}
//===----------------------------------------------------------------------===
-// strncpy()
-//===----------------------------------------------------------------------===
-
-#ifdef VARIANT
-
-#define __strncpy_chk BUILTIN(__strncpy_chk)
-char *__strncpy_chk(char *restrict s1, const char *restrict s2, size_t n, size_t destlen);
-
-#define strncpy(a,b,c) __strncpy_chk(a,b,c, (size_t)-1)
-
-#else /* VARIANT */
-
-#define strncpy BUILTIN(strncpy)
-char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
-
-#endif /* VARIANT */
-
-
-void strncpy_null_dst(char *x) {
- strncpy(NULL, x, 1); // expected-warning{{Null pointer argument in call to byte string function}}
-}
-
-void strncpy_null_src(char *x) {
- strncpy(x, NULL, 1); // expected-warning{{Null pointer argument in call to byte string function}}
-}
-
-void strncpy_fn(char *x) {
- strncpy(x, (char*)&strncpy_fn, 1); // expected-warning{{Argument to byte string function is the address of the function 'strncpy_fn', which is not a null-terminated string}}
-}
-
-void strncpy_effects(char *x, char *y) {
- char a = x[0];
-
- if (strncpy(x, y, strlen(y)) != x)
- (void)*(char*)0; // no-warning
-
- if (strlen(x) != strlen(y))
- (void)*(char*)0; // no-warning
-
- if (a != x[0])
- (void)*(char*)0; // expected-warning{{null}}
-}
-
-void strncpy_overflow(char *y) {
- char x[4];
- if (strlen(y) == 4)
- strncpy(x, y, strlen(y)); // expected-warning{{Byte string function overflows destination buffer}}
-}
-
-void strncpy_len_overflow(char *y) {
- char x[4];
- if (strlen(y) == 3)
- strncpy(x, y, sizeof(x)); // no-warning
-}
-
-void strncpy_no_overflow(char *y) {
- char x[4];
- if (strlen(y) == 3)
- strncpy(x, y, strlen(y)); // no-warning
-}
-
-void strncpy_no_len_overflow(char *y) {
- char x[4];
- if (strlen(y) == 4)
- strncpy(x, y, sizeof(x)-1); // no-warning
-}
-
-//===----------------------------------------------------------------------===
// stpcpy()
//===----------------------------------------------------------------------===
@@ -872,3 +804,109 @@ void strcasecmp_diff_length_3() {
if (strcasecmp(x, y) != -1)
(void)*(char*)0; // no-warning
}
+
+//===----------------------------------------------------------------------===
+// strncasecmp()
+//===----------------------------------------------------------------------===
+
+#define strncasecmp BUILTIN(strncasecmp)
+int strncasecmp(const char *restrict s1, const char *restrict s2, size_t n);
+
+void strncasecmp_constant0() {
+ if (strncasecmp("abc", "Abc", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_constant_and_var_0() {
+ char *x = "abc";
+ if (strncasecmp(x, "Abc", 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_constant_and_var_1() {
+ char *x = "abc";
+ if (strncasecmp("Abc", x, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_0() {
+ char *x = "abc";
+ char *y = "Abc";
+ if (strncasecmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_1() {
+ char *x = "Bcd";
+ char *y = "abc";
+ if (strncasecmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_2() {
+ char *x = "abc";
+ char *y = "Bcd";
+ if (strncasecmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_null_0() {
+ char *x = NULL;
+ char *y = "123";
+ strncasecmp(x, y, 3); // expected-warning{{Null pointer argument in call to byte string function}}
+}
+
+void strncasecmp_null_1() {
+ char *x = "123";
+ char *y = NULL;
+ strncasecmp(x, y, 3); // expected-warning{{Null pointer argument in call to byte string function}}
+}
+
+void strncasecmp_diff_length_0() {
+ char *x = "abcde";
+ char *y = "aBd";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_1() {
+ char *x = "abc";
+ char *y = "aBdef";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_2() {
+ char *x = "aBcDe";
+ char *y = "abc";
+ if (strncasecmp(x, y, 5) != 1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_3() {
+ char *x = "aBc";
+ char *y = "abcde";
+ if (strncasecmp(x, y, 5) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_4() {
+ char *x = "abcde";
+ char *y = "aBc";
+ if (strncasecmp(x, y, 3) != 0)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_5() {
+ char *x = "abcde";
+ char *y = "aBd";
+ if (strncasecmp(x, y, 3) != -1)
+ (void)*(char*)0; // no-warning
+}
+
+void strncasecmp_diff_length_6() {
+ char *x = "aBDe";
+ char *y = "abc";
+ if (strncasecmp(x, y, 3) != 1)
+ (void)*(char*)0; // no-warning
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 544ed3d..e35413a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -75,19 +75,6 @@ if(PYTHONINTERP_FOUND)
add_custom_target(clang-test.deps)
set_target_properties(clang-test.deps PROPERTIES FOLDER "Clang tests")
- foreach(testdir ${CLANG_TEST_DIRECTORIES})
- add_custom_target(clang-test-${testdir}
- COMMAND ${PYTHON_EXECUTABLE}
- ${LIT}
- --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
- --param build_config=${CMAKE_CFG_INTDIR}
- ${LIT_ARGS}
- ${CMAKE_CURRENT_BINARY_DIR}/${testdir}
- DEPENDS clang c-index-test FileCheck not count
- COMMENT "Running Clang regression tests in ${testdir}")
- set_target_properties(clang-test-${testdir} PROPERTIES FOLDER "Clang tests")
- endforeach()
-
add_custom_target(clang-test
COMMAND ${PYTHON_EXECUTABLE}
${LIT}
@@ -100,17 +87,6 @@ if(PYTHONINTERP_FOUND)
COMMENT "Running Clang regression tests")
set_target_properties(clang-test PROPERTIES FOLDER "Clang tests")
- add_custom_target(clang-c++tests
- COMMAND ${PYTHON_EXECUTABLE}
- ${LIT}
- --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
- --param build_config=${CMAKE_CFG_INTDIR}
- ${LIT_ARGS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests
- DEPENDS clang c-index-test FileCheck not count
- COMMENT "Running Clang regression tests")
- set_target_properties(clang-c++tests PROPERTIES FOLDER "Clang tests")
-
if( NOT CLANG_BUILT_STANDALONE )
add_custom_target(check-all
COMMAND ${PYTHON_EXECUTABLE}
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 1e5a823..ccadf41 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
@@ -45,6 +45,9 @@ namespace Test {
namespace test1 {
template <class T> class A {
template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A<int>') would lose const qualifier}}
+
+ public:
+ A();
};
void test() {
diff --git a/test/CXX/class.access/class.friend/p2-cxx03.cpp b/test/CXX/class.access/class.friend/p2-cxx03.cpp
index 0391c4b..82cddc2 100644
--- a/test/CXX/class.access/class.friend/p2-cxx03.cpp
+++ b/test/CXX/class.access/class.friend/p2-cxx03.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
template<typename T>
class X0 {
- friend T; // expected-warning{{non-class type 'T' cannot be a friend}}
+ friend T; // expected-warning{{non-class friend type 'T' is a C++0x extension}}
};
class X1 { };
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index 4228a44..add3635 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -96,7 +96,7 @@ namespace test2 {
A a; // expected-error {{calling a private constructor}}
A A::foo; // okay
- class B : A { }; // expected-error {{base class 'test2::A' has private constructor}}
+ class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}}
B b; // expected-note{{implicit default constructor}}
class C : virtual A {
@@ -104,7 +104,7 @@ namespace test2 {
C();
};
- class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private constructor}}
+ class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}}
D d; // expected-note{{implicit default constructor}}
}
@@ -206,7 +206,7 @@ namespace test5 {
class Test1 { A a; }; // expected-error {{private member}}
void test1() {
- Test1 a;
+ Test1 a;
a = Test1(); // expected-note{{implicit default copy}}
}
diff --git a/test/CXX/class/class.friend/p2.cpp b/test/CXX/class/class.friend/p2.cpp
index eb5036f..87b69c0 100644
--- a/test/CXX/class/class.friend/p2.cpp
+++ b/test/CXX/class/class.friend/p2.cpp
@@ -4,7 +4,7 @@ struct B0;
class A {
friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
- friend int; // expected-warning {{non-class type 'int' cannot be a friend}}
- friend B0; // expected-warning {{must specify 'struct' to befriend}}
+ friend int; // expected-warning {{non-class friend type 'int' is a C++0x extension}}
+ friend B0; // expected-warning {{specify 'struct' to befriend 'B0'}}
friend class C; // okay
};
diff --git a/test/CXX/class/class.mem/p1b.cpp b/test/CXX/class/class.mem/p1b.cpp
index d3493f6..3e8c985 100644
--- a/test/CXX/class/class.mem/p1b.cpp
+++ b/test/CXX/class/class.mem/p1b.cpp
@@ -16,7 +16,7 @@ public:
void a3(int a = 42);
- // CHEKC: error: use of undeclared identifier 'first'
+ // CHECK: error: use of undeclared identifier 'first'
void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}}
class B {
diff --git a/test/CXX/class/class.mem/p5-0x.cpp b/test/CXX/class/class.mem/p5-0x.cpp
new file mode 100644
index 0000000..78560e2
--- /dev/null
+++ b/test/CXX/class/class.mem/p5-0x.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+int f();
+
+struct S
+{
+ int a = f(); // ok
+ int b = g(); // expected-error {{use of undeclared identifier 'g'}}
+};
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
index 198b013..e3d3d68 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp
@@ -3,7 +3,7 @@
namespace NIL {} // expected-note {{previous definition}}
inline namespace NIL {} // expected-error {{cannot be reopened as inline}}
inline namespace IL {} // expected-note {{previous definition}}
-namespace IL {} // expected-error {{cannot be reopened as non-inline}}
+namespace IL {} // expected-warning{{inline namespace cannot be re-opened as a non-inline namespace}}
namespace {} // expected-note {{previous definition}}
inline namespace {} // expected-error {{cannot be reopened as inline}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
new file mode 100644
index 0000000..40917b8
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// A storage-class-specifier shall not be specified in an explicit
+// specialization (14.7.3) or an explicit instantiation (14.7.2)
+// directive.
+template<typename T> void f(T) {}
+template<typename T> static void g(T) {}
+
+
+template<> static void f<int>(int); // expected-error{{explicit specialization cannot have a storage class}}
+template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void f<double>(double);
+template void f<long>(long);
+
+template<> static void g<int>(int); // expected-error{{explicit specialization cannot have a storage class}}
+template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> void g<double>(double);
+template void g<long>(long);
+
+template<typename T>
+struct X {
+ static int value;
+};
+
+template<typename T>
+int X<T>::value = 17;
+
+template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}}
+
+template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}}
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 34a1784..8a68e4b 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
@@ -22,14 +22,21 @@ void f() {
new const auto (0);
new (auto) (0.0);
-#if 0
- // When clang supports for-range:
- for (auto i : {1,2,3}) {
+ int arr[] = {1, 2, 3};
+ for (auto i : arr) {
}
-
- // When clang supports inline initialization of members.
- class X {
- static const auto &n = 'x';
- };
-#endif
}
+
+class X {
+ static const auto n = 'x';
+
+ auto m = 0; // expected-error {{'auto' not allowed in non-static class member}}
+};
+
+struct S {
+ static const auto a; // expected-error {{declaration of variable 'a' with type 'auto const' requires an initializer}}
+ static const auto b = 0;
+ static const int c;
+};
+const int S::b;
+const auto S::c = 0;
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 09245cf..fabfb53 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
@@ -3,13 +3,13 @@
struct S {
virtual ~S();
- auto a; // expected-error{{'auto' not allowed in struct member}}
- auto *b; // expected-error{{'auto' not allowed in struct member}}
- const auto c; // expected-error{{'auto' not allowed in struct member}}
+ auto a; // expected-error{{'auto' not allowed in non-static struct member}}
+ auto *b; // expected-error{{'auto' not allowed in non-static struct member}}
+ const auto c; // expected-error{{'auto' not allowed in non-static struct member}}
void f() throw (auto); // expected-error{{'auto' not allowed here}}
- friend auto; // expected-error{{'auto' not allowed in struct member}}
+ friend auto; // expected-error{{'auto' not allowed in non-static struct member}}
operator auto(); // expected-error{{'auto' not allowed here}}
};
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
new file mode 100644
index 0000000..81204d8
--- /dev/null
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct A { typedef int type; };
+template<typename T> using X = A; // expected-note {{declared here}}
+struct X<int>* p2; // expected-error {{elaborated type refers to a type alias template}}
+
+
+template<typename T> using Id = T; // expected-note {{declared here}}
+template<template<typename> class F>
+struct Y {
+ struct F<int> i; // expected-error {{elaborated type refers to a type alias template}}
+ typename F<A>::type j; // ok
+
+ // FIXME: don't produce the diagnostic both for the definition and the instantiation.
+ template<typename T> using U = F<char>; // expected-note 2{{declared here}}
+ struct Y<F>::template U<char> k; // expected-error 2{{elaborated type refers to a type alias template}}
+ typename Y<F>::template U<char> l; // ok
+};
+template struct Y<Id>; // expected-note {{requested here}}
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 10184a0..b93e8e3 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,15 +1,14 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-// FIXME: when clang supports alias-declarations.
-#if 0
using X = struct { // ok
};
-#endif
+template<typename T> using Y = struct { // expected-error {{can not be defined in a type alias template}}
+};
class K {
virtual ~K();
- // FIXME: the diagnostic here isn't very good
- operator struct S {} (); // expected-error 2{{}}
+ // FIXME: the diagnostic here is really bad
+ operator struct S {} (); // expected-error 2{{}} expected-note {{}}
};
void f() {
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
new file mode 100644
index 0000000..9b92340
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// An aggregate is an array or a class...
+struct Aggr {
+private:
+ static const int n;
+ void f();
+protected:
+ struct Inner { int m; };
+public:
+ bool &br;
+};
+bool b;
+Aggr ag = { b };
+
+// with no user-provided constructors, ...
+struct NonAggr1a {
+ NonAggr1a(int, int);
+ int k;
+};
+// In C++03, this is {{non-aggregate type 'NonAggr1a'}}.
+// In C++0x, 'user-provided' is only defined for special member functions, so
+// this type is considered to be an aggregate. This is probably a langauge
+// defect.
+NonAggr1a na1a = { 42 };
+
+struct NonAggr1b {
+ NonAggr1b(const NonAggr1b &);
+ int k;
+};
+NonAggr1b na1b = { 42 }; // expected-error {{non-aggregate type 'NonAggr1b'}}
+
+// no brace-or-equal-initializers for non-static data members, ...
+struct NonAggr2 {
+ int m = { 123 };
+};
+NonAggr2 na2 = { 42 }; // expected-error {{non-aggregate type 'NonAggr2'}}
+
+// no private...
+struct NonAggr3 {
+private:
+ int n;
+};
+NonAggr3 na3 = { 42 }; // expected-error {{non-aggregate type 'NonAggr3'}}
+
+// or protected non-static data members, ...
+struct NonAggr4 {
+protected:
+ int n;
+};
+NonAggr4 na4 = { 42 }; // expected-error {{non-aggregate type 'NonAggr4'}}
+
+// no base classes, ...
+struct NonAggr5 : Aggr {
+};
+NonAggr5 na5 = { b }; // expected-error {{non-aggregate type 'NonAggr5'}}
+
+// and no virtual functions.
+struct NonAggr6 {
+ virtual void f();
+ int n;
+};
+NonAggr6 na6 = { 42 }; // expected-error {{non-aggregate type 'NonAggr6'}}
diff --git a/test/CXX/dcl.decl/dcl.init/p14-0x.cpp b/test/CXX/dcl.decl/dcl.init/p14-0x.cpp
new file mode 100644
index 0000000..e5b5889
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.init/p14-0x.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+struct NoDefault {
+ NoDefault() = delete; // expected-note {{here}}
+ NoDefault(int);
+};
+struct Explicit { // expected-note {{candidate}} expected-note {{here}}
+ explicit Explicit(int);
+};
+struct NoCopy {
+ NoCopy();
+ NoCopy(const NoCopy &) = delete; // expected-note {{here}}
+};
+struct NoMove {
+ NoMove();
+ NoMove(NoMove &&) = delete; // expected-note {{here}}
+};
+class Private {
+ Private(int); // expected-note {{here}}
+public:
+ Private();
+};
+class Friend {
+ friend class S;
+ Friend(int);
+};
+
+
+class S {
+ NoDefault nd1;
+ NoDefault nd2 = 42;
+ Explicit e1; // expected-note {{here}}
+ Explicit e2 = 42; // expected-error {{no viable conversion}}
+ NoCopy nc = NoCopy(); // expected-error {{call to deleted}}
+ NoMove nm = NoMove(); // expected-error {{call to deleted}}
+ Private p = 42; // expected-error {{private constructor}}
+ Friend f = 42;
+
+ S() {} // expected-error {{call to deleted constructor of 'NoDefault'}} \
+ expected-error {{must explicitly initialize the member 'e1' which does not have a default constructor}}
+ S(int) : nd1(42), e1(42) {}
+};
+
+// FIXME: test the other forms which use copy-initialization
diff --git a/test/CXX/dcl.decl/dcl.init/p6.cpp b/test/CXX/dcl.decl/dcl.init/p6.cpp
index da6f5b5..514fd0c 100644
--- a/test/CXX/dcl.decl/dcl.init/p6.cpp
+++ b/test/CXX/dcl.decl/dcl.init/p6.cpp
@@ -14,3 +14,15 @@ void test_const_default_init() {
const HasUserDefault x2;
const int x3; // expected-error{{default initialization of an object of const type 'const int'}}
}
+
+// rdar://8501008
+struct s0 {};
+struct s1 { static const s0 foo; };
+const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' requires a user-provided default constructor}}
+
+template<typename T>
+struct s2 {
+ static const s0 foo;
+};
+
+template<> const struct s0 s2<int>::foo; // okay
diff --git a/test/CXX/except/except.spec/p1.cpp b/test/CXX/except/except.spec/p1.cpp
index 0559285..86924bb 100644
--- a/test/CXX/except/except.spec/p1.cpp
+++ b/test/CXX/except/except.spec/p1.cpp
@@ -58,3 +58,16 @@ namespace noex {
void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}}
}
+
+namespace noexcept_unevaluated {
+ template<typename T> void f(T) {
+ T* x = 1;
+ }
+
+ template<typename T>
+ void g(T x) noexcept((f(x), sizeof(T) == 4)) { }
+
+ void h() {
+ g(1);
+ }
+}
diff --git a/test/CXX/except/except.spec/p14.cpp b/test/CXX/except/except.spec/p14.cpp
index f5e83ea..f42fbe9 100644
--- a/test/CXX/except/except.spec/p14.cpp
+++ b/test/CXX/except/except.spec/p14.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify -std=c++0x %s
struct A { };
struct B { };
struct C { };
@@ -27,3 +27,15 @@ void test_CA() {
CA2 &(CA2::*captr3)(const CA2&) throw(A) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}}
CA2 &(CA2::*captr4)(const CA2&) throw(B) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}}
}
+
+// In-class member initializers.
+struct IC0 {
+ int inClassInit = 0;
+};
+struct IC1 {
+ int inClassInit = (throw B(), 0);
+};
+// FIXME: the exception specification on the default constructor is wrong:
+// we cannot currently compute the set of thrown types.
+static_assert(noexcept(IC0()), "IC0() does not throw");
+static_assert(!noexcept(IC1()), "IC1() throws");
diff --git a/test/CXX/except/except.spec/p9-dynamic.cpp b/test/CXX/except/except.spec/p9-dynamic.cpp
index 490d2fa..3f496f2 100644
--- a/test/CXX/except/except.spec/p9-dynamic.cpp
+++ b/test/CXX/except/except.spec/p9-dynamic.cpp
@@ -7,5 +7,5 @@ void target() throw(int)
// CHECK: invoke void @_Z8externalv()
external();
}
-// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} i8* bitcast (i8** @_ZTIi to i8*), i8* null) nounwind
+// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} i8* bitcast (i8** @_ZTIi to i8*)) nounwind
// CHECK: call void @__cxa_call_unexpected
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
new file mode 100644
index 0000000..1b38cf1
--- /dev/null
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s
+
+// PR9999
+template<bool v>
+class bitWidthHolding {
+public:
+ static const
+ unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1);
+};
+
+static const int width=bitWidthHolding<255>::width;
+
+template<bool b>
+struct always_false {
+ static const bool value = false;
+};
+
+template<bool b>
+struct and_or {
+ static const bool and_value = b && and_or<always_false<b>::value>::and_value;
+ static const bool or_value = !b || and_or<always_false<b>::value>::or_value;
+};
+
+static const bool and_value = and_or<true>::and_value;
+static const bool or_value = and_or<true>::or_value;
diff --git a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp
new file mode 100644
index 0000000..bb4726d
--- /dev/null
+++ b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+struct X1 {
+ X1();
+};
+
+struct X2 {
+ X2();
+ ~X2();
+};
+
+void vararg(...);
+
+void f(X1 x1, X2 x2) {
+ vararg(x1); // okay
+ vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
+}
diff --git a/test/CXX/expr/expr.prim/p12-0x.cpp b/test/CXX/expr/expr.prim/p12-0x.cpp
new file mode 100644
index 0000000..0ff29a1
--- /dev/null
+++ b/test/CXX/expr/expr.prim/p12-0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %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
new file mode 100644
index 0000000..13735fa
--- /dev/null
+++ b/test/CXX/expr/expr.prim/p4-0x.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %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.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
index 28ed62c..6d1e523 100644
--- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
+++ b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp
@@ -97,6 +97,8 @@ struct Bad2 {
void operator delete(void*) throw(int);
};
+typedef int X;
+
void implicits() {
N(new int);
P(new (0) int);
@@ -113,6 +115,7 @@ void implicits() {
N(static_cast<int>(s));
P(static_cast<float>(s));
N(Bad1());
+ P(X().~X());
}
struct V {
@@ -155,12 +158,16 @@ void gencon() {
N(G3());
}
+template <class T> void f(T&&) noexcept;
template <typename T, bool b>
void late() {
B(b, typeid(*(T*)0));
B(b, T(1));
B(b, static_cast<T>(S2(0, 0)));
B(b, S1() + T());
+ P(f(T()));
+ P(new (0) T);
+ P(delete (T*)0);
}
struct S3 {
virtual ~S3() throw();
@@ -168,9 +175,15 @@ struct S3 {
explicit S3(int);
S3(const S2&);
};
+template <class T> T&& f2() noexcept;
+template <typename T>
+void late2() {
+ P(dynamic_cast<S3&>(f2<T&>()));
+}
void operator +(const S1&, float) throw();
void operator +(const S1&, const S3&);
void tlate() {
late<float, true>();
late<S3, false>();
+ late2<S3>();
}
diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp
new file mode 100644
index 0000000..2123d16
--- /dev/null
+++ b/test/CXX/special/class.ctor/p5-0x.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
+
+struct DefaultedDefCtor1 {};
+struct DefaultedDefCtor2 { DefaultedDefCtor2() = default; };
+struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); };
+class PrivateDefCtor { PrivateDefCtor() = default; public: PrivateDefCtor(int); };
+struct DeletedDtor { ~DeletedDtor() = delete; };
+class PrivateDtor { ~PrivateDtor() = default; };
+class Friend {
+ Friend() = default; ~Friend() = default;
+ friend struct NotDeleted6c;
+ friend struct NotDeleted7i;
+ friend struct NotDeleted7j;
+ friend struct NotDeleted7k;
+};
+struct UserProvidedDefCtor { UserProvidedDefCtor() {} };
+int n;
+
+
+// A defaulted default constructor for a class X is defined as deleted if:
+
+// - 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}}
+// FIXME: treating this as having a deleted default constructor is probably a
+// bug in the standard.
+union Deleted1b { UserProvidedDefCtor u = UserProvidedDefCtor(); }; // expected-note {{deleted here}}
+Deleted1b d1b; // expected-error {{deleted 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}}
+
+// - 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 NotDeleted2a { int &a = n; };
+NotDeleted2a nd2a;
+class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}}
+NotDeleted2b nd2b;
+
+// - 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}} \
+ 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}}
+class NotDeleted3a { const int a = 0; };
+NotDeleted3a nd3a;
+class NotDeleted3b { const DefaultedDefCtor1 a[42] = {}; };
+NotDeleted3b nd3b;
+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}}
+
+// - 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;
+
+// - 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;
+
+// - 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 NotDeleted6a { DeletedDefCtor a = 0; };
+NotDeleted6a nd6a;
+struct Deleted6e { PrivateDefCtor a; }; // expected-note {{here}}
+Deleted6e d6e; // expected-error {{deleted constructor}}
+struct NotDeleted6b { PrivateDefCtor a = 0; };
+NotDeleted6b nd6b;
+struct NotDeleted6c { Friend a; };
+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 NotDeleted7i : Friend {};
+NotDeleted7i d7i;
+struct NotDeleted7j : virtual Friend {};
+NotDeleted7j d7j;
+struct NotDeleted7k { Friend a; };
+NotDeleted7k d7k;
+
+
+class Trivial { static const int n = 42; };
+static_assert(__has_trivial_constructor(Trivial), "Trivial is nontrivial");
+
+// A default constructor is trivial if it is not user-provided and if:
+class NonTrivialDefCtor1 { NonTrivialDefCtor1(); };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor1), "NonTrivialDefCtor1 is trivial");
+
+// - its class has no virtual functions (10.3) and no virtual base classes (10.1), and
+class NonTrivialDefCtor2 { virtual void f(); };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor2), "NonTrivialDefCtor2 is trivial");
+class NonTrivialDefCtor3 : virtual Trivial {};
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor3), "NonTrivialDefCtor3 is trivial");
+
+// - no non-static data member of its class has a brace-or-equal-initializer, and
+class NonTrivialDefCtor4 { int m = 52; };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor4), "NonTrivialDefCtor4 is trivial");
+
+// - all the direct base classes of its class have trivial default constructors, and
+class NonTrivialDefCtor5 : NonTrivialDefCtor1 {};
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor5), "NonTrivialDefCtor5 is trivial");
+
+// - for all the non-static data members of its class that are of class type (or array thereof), each such class
+// has a trivial default constructor.
+class NonTrivialDefCtor6 { NonTrivialDefCtor1 t; };
+static_assert(!__has_trivial_constructor(NonTrivialDefCtor6), "NonTrivialDefCtor5 is trivial");
+
+// 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");
+
+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");
diff --git a/test/CXX/special/class.dtor/p3-0x.cpp b/test/CXX/special/class.dtor/p3-0x.cpp
new file mode 100644
index 0000000..6cdd167
--- /dev/null
+++ b/test/CXX/special/class.dtor/p3-0x.cpp
@@ -0,0 +1,177 @@
+// RUN: %clang_cc1 -std=c++0x -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+struct A {
+ ~A();
+};
+
+struct B {
+ ~B() throw(int);
+};
+
+struct C {
+ B b;
+ ~C() {}
+};
+
+struct D {
+ ~D() noexcept(false);
+};
+
+struct E {
+ D d;
+ ~E() {}
+};
+
+void foo() {
+ A a;
+ C c;
+ E e;
+ // CHECK: invoke {{.*}} @_ZN1ED1Ev
+ // CHECK: invoke {{.*}} @_ZN1CD1Ev
+ // CHECK: call {{.*}} @_ZN1AD1Ev
+}
+
+struct F {
+ D d;
+ ~F();
+};
+F::~F() noexcept(false) {}
+
+struct G {
+ D d;
+ ~G();
+};
+G::~G() {}
+
+struct H {
+ B b;
+ ~H();
+};
+H::~H() throw(int) {}
+
+struct I {
+ B b;
+ ~I();
+};
+I::~I() {}
+
+// Template variants.
+
+template <typename T>
+struct TA {
+ ~TA();
+};
+
+template <typename T>
+struct TB {
+ ~TB() throw(int);
+};
+
+template <typename T>
+struct TC {
+ TB<T> b;
+ ~TC() {}
+};
+
+template <typename T>
+struct TD {
+ ~TD() noexcept(false);
+};
+
+template <typename T>
+struct TE {
+ TD<T> d;
+ ~TE() {}
+};
+
+void tfoo() {
+ TA<int> a;
+ TC<int> c;
+ TE<int> e;
+ // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev
+ // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev
+ // CHECK: call {{.*}} @_ZN2TAIiED1Ev
+}
+
+template <typename T>
+struct TF {
+ TD<T> d;
+ ~TF();
+};
+template <typename T>
+TF<T>::~TF() noexcept(false) {}
+
+template <typename T>
+struct TG {
+ TD<T> d;
+ ~TG();
+};
+template <typename T>
+TG<T>::~TG() {}
+
+template <typename T>
+struct TH {
+ TB<T> b;
+ ~TH();
+};
+template <typename T>
+TH<T>::~TH() {}
+
+void tinst() {
+ TF<int> f;
+ TG<int> g;
+ TH<int> h;
+}
+// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev
+// CHECK: _ZTIi
+// CHECK: __cxa_call_unexpected
+
+struct VX
+{ virtual ~VX() {} };
+
+struct VY : VX
+{ virtual ~VY() {} };
+
+template<typename T>
+struct TVY : VX
+{ virtual ~TVY() {} };
+
+
+struct VA {
+ B b;
+ virtual ~VA() {}
+};
+
+struct VB : VA
+{ virtual ~VB() {} };
+
+template<typename T>
+struct TVB : VA
+{ virtual ~TVB() {} };
+
+void tinst2() {
+ TVY<int> tvy;
+ TVB<int> tvb;
+}
+
+template <typename T>
+struct Sw {
+ T t;
+ ~Sw() {}
+};
+
+void tsw() {
+ Sw<int> swi;
+ Sw<B> swb;
+}
+// CHECK-NOT: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}} nounwind
+// CHECK: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}}
+// CHECK: _ZTIi
+// CHECK: __cxa_call_unexpected
+// CHECK: define linkonce_odr {{.*}} @_ZN2SwIiED1Ev({{.*}} nounwind
+
+template <typename T>
+struct TVC : VX
+{ virtual ~TVC(); };
+template <typename T>
+TVC<T>::~TVC() {}
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
new file mode 100644
index 0000000..8512a9f
--- /dev/null
+++ b/test/CXX/special/class.init/class.base.init/p8-0x.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+int n;
+struct S {
+ int &a; // expected-note 2{{here}}
+ int &b = n;
+
+ S() {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
+ S(int) : a(n) {} // ok
+ S(char) : b(n) {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}}
+ S(double) : a(n), b(n) {} // ok
+};
+
+union U {
+ int a = 0;
+ 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}}
+};
diff --git a/test/CXX/special/class.init/class.base.init/p9-0x.cpp b/test/CXX/special/class.init/class.base.init/p9-0x.cpp
new file mode 100644
index 0000000..039b1c2
--- /dev/null
+++ b/test/CXX/special/class.init/class.base.init/p9-0x.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++0x %s -O1 -emit-llvm -o - | FileCheck %s
+
+struct S {
+ int n = 10;
+ int m = 2 * n;
+
+ S() {}
+ S(int a) : n(a) {}
+ S(int a, int b) : n(a), m(b) {}
+
+ struct T {
+ T *that = this;
+ };
+};
+
+template<typename T>
+struct U {
+ T *r = &q;
+ T q = 42;
+ U *p = this;
+};
+
+S a;
+// CHECK: @a = {{.*}} { i32 10, i32 20 }
+
+S b(5);
+// CHECK: @b = {{.*}} { i32 5, i32 10 }
+
+S c(3, 9);
+// CHECK: @c = {{.*}} { i32 3, i32 9 }
+
+S::T d;
+// CHECK: @d = {{.*}} { {{.*}} @d }
+
+U<S> e;
+// CHECK: @e = {{.*}} { {{.*}} { i32 42, i32 84 }, {{.*}} @e }
diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
new file mode 100644
index 0000000..b415044
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+// PR10034
+struct X {};
+
+void exx(X) {}
+
+int test_ptr10034(int argc, char **argv)
+{
+ if (argc > 3)
+ goto end;
+
+ X x;
+ X xs[16];
+ exx(x);
+
+ end:
+ if (argc > 1) {
+ for (int i = 0; i < argc; ++i)
+ {
+
+ }
+ }
+ return 0;
+}
+
+struct Y {
+ ~Y();
+};
+
+void f();
+void test_Y() {
+ goto end;
+ Y y;
+ end:
+ f();
+ goto inner;
+ {
+ Y y2;
+ inner:
+ f();
+ }
+ return;
+}
+
+struct Z {
+ Z operator=(const Z&);
+};
+
+void test_Z() {
+ goto end;
+ Z z;
+ end:
+ return;
+}
diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
new file mode 100644
index 0000000..18fd340
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR10034
+struct X {};
+
+void exx(X) {}
+
+int test_ptr10034(int argc, char **argv)
+{
+ if (argc > 3)
+ goto end;
+
+ X x;
+ X xs[16];
+ exx(x);
+
+ end:
+ if (argc > 1) {
+ for (int i = 0; i < argc; ++i)
+ {
+
+ }
+ }
+ return 0;
+}
+
+struct Y {
+ ~Y();
+};
+
+void test_Y() {
+ goto end; // expected-error{{goto into protected scope}}
+ Y y; // expected-note{{jump bypasses variable initialization}}
+ end:
+ return;
+}
+
+struct Z {
+ Z operator=(const Z&);
+};
+
+void test_Z() {
+ goto end; // expected-error{{goto into protected scope}}
+ Z z; // expected-note{{jump bypasses variable initialization}}
+ 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 12acde1..7bfa6fe 100644
--- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
+++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
@@ -33,8 +33,8 @@ struct B {
int *alt_end();
};
-void f(); // expected-note {{candidate}}
-void f(int); // expected-note {{candidate}}
+void f();
+void f(int);
void g() {
for (int a : A())
@@ -44,7 +44,7 @@ void g() {
for (char *a : B()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}}
}
// FIXME: Terrible diagnostic here. auto deduction should fail, but does not!
- for (double a : f) { // expected-error {{address of overloaded function 'f' does not match required type '<overloaded function type>'}}
+ for (double a : f) { // expected-error {{cannot use type '<overloaded function type>' as a range}}
}
for (auto a : A()) {
}
diff --git a/test/CXX/temp/temp.decls/p3.cpp b/test/CXX/temp/temp.decls/p3.cpp
new file mode 100644
index 0000000..54800e4
--- /dev/null
+++ b/test/CXX/temp/temp.decls/p3.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<typename T> using A = int;
+template<typename T> using A<T*> = char; // expected-error {{partial specialization of alias templates is not permitted}}
+template<> using A<char> = char; // expected-error {{explicit specialization of alias templates is not permitted}}
+template using A<char> = char; // expected-error {{explicit instantiation of alias templates is not permitted}}
+using A<char> = char; // expected-error {{name defined in alias declaration must be an identifier}}
diff --git a/test/CXX/temp/temp.decls/temp.alias/p1.cpp b/test/CXX/temp/temp.decls/temp.alias/p1.cpp
new file mode 100644
index 0000000..80079b3
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.alias/p1.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<typename T> using U = T;
+
+// The name of the alias template is a template-name.
+U<char> x;
+void f(U<int>);
+typedef U<U<U<U<int>>>> I;
diff --git a/test/CXX/temp/temp.decls/temp.alias/p2.cpp b/test/CXX/temp/temp.decls/temp.alias/p2.cpp
new file mode 100644
index 0000000..e145727
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.alias/p2.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<typename T> using U = T;
+
+using I = U<U<U<U<int>>>>;
+using I = int;
+
+template<typename A, typename B> using Fst = A;
+template<typename A, typename B> using Snd = B;
+
+using I = Fst<Snd<char,int>,double>;
+
+namespace StdExample {
+ // Prerequisites for example.
+ template<class T, class A> struct vector { /* ... */ };
+
+
+ template<class T> struct Alloc {};
+ template<class T> using Vec = vector<T, Alloc<T>>;
+ Vec<int> v;
+
+ template<class T>
+ void process(Vec<T>& v) // expected-note {{previous definition is here}}
+ { /* ... */ }
+
+ template<class T>
+ void process(vector<T, Alloc<T>>& w) // expected-error {{redefinition of 'process'}}
+ { /* ... */ }
+
+ template<template<class> class TT>
+ void f(TT<int>); // expected-note {{candidate template ignored}}
+
+ template<template<class,class> class TT>
+ void g(TT<int, Alloc<int>>);
+
+ int h() {
+ f(v); // expected-error {{no matching function for call to 'f'}}
+ g(v); // OK: TT = vector
+ }
+
+
+ // v's type is same as vector<int, Alloc<int>>.
+ using VTest = vector<int, Alloc<int>>;
+ using VTest = decltype(v);
+}
diff --git a/test/CXX/temp/temp.decls/temp.alias/p3.cpp b/test/CXX/temp/temp.decls/temp.alias/p3.cpp
new file mode 100644
index 0000000..2e9e55c
--- /dev/null
+++ b/test/CXX/temp/temp.decls/temp.alias/p3.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+// The example given in the standard (this is rejected for other reasons anyway).
+template<class T> struct A;
+template<class T> using B = typename A<T>::U; // expected-error {{no type named 'U' in 'A<T>'}}
+template<class T> struct A {
+ typedef B<T> U; // expected-note {{in instantiation of template type alias 'B' requested here}}
+};
+B<short> b;
+
+template<typename T> using U = int;
+// FIXME: This is illegal, but probably only because CWG1044 missed this paragraph.
+template<typename T> using U = U<T>;
diff --git a/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/test/CXX/temp/temp.decls/temp.friend/p3.cpp
index d116e01..0b2a25e 100644
--- a/test/CXX/temp/temp.decls/temp.friend/p3.cpp
+++ b/test/CXX/temp/temp.decls/temp.friend/p3.cpp
@@ -8,5 +8,5 @@ class B {
template <class T> friend class A;
template <class T> friend class Undeclared;
- template <class T> friend typename A<T>::Member; // expected-warning {{non-class type 'typename A<T>::Member' cannot be a friend}}
+ template <class T> friend typename A<T>::Member; // expected-error {{friend type templates must use an elaborated type}}
};
diff --git a/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp b/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
index 62cf429..7375f98 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp
@@ -37,3 +37,10 @@ int f3(Args ...args) {
}
template int f3(const char*, int, float, double);
+
+template<typename ...Args>
+int PR9953(Args ...args) {
+ return ^(Args *...block_args) {
+ return f1(block_args); // expected-error{{expression contains unexpanded parameter pack 'block_args'}}
+ }(&args...);
+}
diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp
new file mode 100644
index 0000000..d3af0d4
--- /dev/null
+++ b/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+#if !__has_feature(cxx_access_control_sfinae)
+# error No support for access control as part of SFINAE?
+#endif
+
+typedef char yes_type;
+typedef char (&no_type)[2];
+
+template<unsigned N> struct unsigned_c { };
+
+template<typename T>
+class has_copy_constructor {
+ static T t;
+
+ template<typename U> static yes_type check(unsigned_c<sizeof(U(t))> * = 0);
+ template<typename U> static no_type check(...);
+
+public:
+ static const bool value = (sizeof(check<T>(0)) == sizeof(yes_type));
+};
+
+struct HasCopy { };
+
+struct HasNonConstCopy {
+ HasNonConstCopy(HasNonConstCopy&);
+};
+
+struct HasDeletedCopy {
+ HasDeletedCopy(const HasDeletedCopy&) = delete;
+};
+
+struct HasPrivateCopy {
+private:
+ HasPrivateCopy(const HasPrivateCopy&);
+};
+
+int check0[has_copy_constructor<HasCopy>::value? 1 : -1];
+int check1[has_copy_constructor<HasNonConstCopy>::value? 1 : -1];
+int check2[has_copy_constructor<HasDeletedCopy>::value? -1 : 1];
+int check3[has_copy_constructor<HasPrivateCopy>::value? -1 : 1];
diff --git a/test/CXX/temp/temp.param/p10-0x.cpp b/test/CXX/temp/temp.param/p10-0x.cpp
new file mode 100644
index 0000000..bc7e616
--- /dev/null
+++ b/test/CXX/temp/temp.param/p10-0x.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template<typename> struct Y1;
+template<typename, int> struct Y2;
+
+template<class T1, class T2 = int> using B2 = T1;
+template<class T1 = int, class T2> using B2 = T1;
+
+template<template<class> class F, template<class> class G = Y1> using B2t = F<G<int>>;
+template<template<class> class F = Y2, template<class> class G> using B2t = F<G<int>>;
+
+template<int N, int M = 5> using B2n = Y2<int, N + M>;
+template<int N = 5, int M> using B2n = Y2<int, N + M>;
diff --git a/test/CXX/temp/temp.param/p11-0x.cpp b/test/CXX/temp/temp.param/p11-0x.cpp
index 0bf4341..10a4438 100644
--- a/test/CXX/temp/temp.param/p11-0x.cpp
+++ b/test/CXX/temp/temp.param/p11-0x.cpp
@@ -1,29 +1,48 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
-// If a template-parameter of a class template has a default
-// template-argument, each subsequent template-parameter shall either
-// have a default template-argument supplied or be a template
-// parameter pack.
+// If a template-parameter of a class template or alias template has a default
+// template-argument, each subsequent template-parameter shall either have a
+// default template-argument supplied or be a template parameter pack.
template<typename> struct vector;
+template<typename T = int, typename> struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<typename T = int, typename> using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<int V = 0, int> struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<int V = 0, int> using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<template<class> class M = vector, template<class> class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+template<template<class> class M = vector, template<class> class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}}
+
template<typename T = int, typename ...Types> struct X2t;
+template<typename T = int, typename ...Types> using A2t = X2t<T, Types...>;
template<int V = 0, int ...Values> struct X2nt;
+template<int V = 0, int ...Values> using A2nt = X2nt<V, Values...>;
template<template<class> class M = vector, template<class> class... Metas>
struct X2tt;
+template<template<class> class M = vector, template<class> class... Metas>
+ using A2tt = X2tt<M, Metas...>;
-// If a template-parameter of a primary class template is a template
-// parameter pack, it shall be the last template-parameter .
+// 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>
struct X0t;
+template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0t = int;
template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}}
int After>
struct X0nt;
+template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0nt = int;
template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}}
int After>
struct X0tt;
+template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}}
+ int After>
+using A0tt = int;
// [ Note: These are not requirements for function templates or class
// template partial specializations because template arguments can be
diff --git a/test/CXX/temp/temp.param/p9-0x.cpp b/test/CXX/temp/temp.param/p9-0x.cpp
index 17eca7f..1dc6640 100644
--- a/test/CXX/temp/temp.param/p9-0x.cpp
+++ b/test/CXX/temp/temp.param/p9-0x.cpp
@@ -50,3 +50,12 @@ namespace PR8748 {
template<typename T = int> struct Inner::X3 { };
template<typename T = int> void Inner::f2() {}
}
+
+namespace PR10069 {
+ template<typename T, T a, T b=0, T c=1>
+ T f(T x);
+
+ void g() {
+ f<unsigned int, 0>(0);
+ }
+}
diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
new file mode 100644
index 0000000..1d1d350
--- /dev/null
+++ b/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// Examples from CWG1056.
+namespace Example1 {
+ template<class T> struct A;
+ template<class T> using B = A<T>;
+
+ template<class T> struct A {
+ struct C {};
+ B<T>::C bc; // ok, B<T> is the current instantiation.
+ };
+
+ template<class T> struct A<A<T>> {
+ struct C {};
+ B<B<T>>::C bc; // ok, B<B<T>> is the current instantiation.
+ };
+
+ template<class T> struct A<A<A<T>>> {
+ struct C {};
+ B<B<T>>::C bc; // expected-error {{missing 'typename'}}
+ };
+}
+
+namespace Example2 {
+ template<class T> struct A {
+ void g();
+ };
+ template<class T> using B = A<T>;
+ template<class T> void B<T>::g() {} // ok.
+}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
new file mode 100644
index 0000000..f04c544
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp
@@ -0,0 +1,209 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace PR5907 {
+ template<typename T> struct identity { typedef T type; };
+ struct A { A(); };
+ identity<A>::type::A() { }
+
+ struct B { void f(); };
+ template<typename T> struct C { typedef B type; };
+
+ void C<int>::type::f() { }
+}
+
+namespace PR9421 {
+ namespace N { template<typename T> struct S { void f(); }; }
+ typedef N::S<int> T;
+ namespace N { template<> void T::f() {} }
+}
+
+namespace PR8277 {
+ template< typename S >
+ struct C
+ {
+ template< int >
+ void F( void )
+ {
+ }
+ };
+
+ template< typename S >
+ struct D
+ {
+ typedef C< int > A;
+ };
+
+ typedef D< int >::A A;
+
+ template<>
+ template<>
+ void A::F< 0 >( void )
+ {
+ }
+}
+
+namespace PR8277b {
+ template<typename S> struct C {
+ void f();
+ };
+ template<typename S> struct D {
+ typedef C<int> A;
+ };
+ template<> void D<int>::A::f() {
+ }
+}
+
+namespace PR8708 {
+ template<typename T> struct A {
+ template<typename U> struct B {
+ // #2
+ void f();
+ };
+ };
+
+ // #A specialize the member template for
+ // implicit instantiation of A<int>,
+ // leaving the member template "unspecialized"
+ // (14.7.3/16). Specialization uses the syntax
+ // for explicit specialization (14.7.3/14)
+ template<> template<typename U>
+ struct A<int>::B {
+ // #1
+ void g();
+ };
+
+ // #1 define its function g. There is an enclosing
+ // class template, so we write template<> for each
+ // specialized template (14.7.3/15).
+ template<> template<typename U>
+ void A<int>::B<U>::g() { }
+
+ // #2 define the unspecialized member template's
+ // f
+ template<typename T> template<typename U>
+ void A<T>::B<U>::f() { }
+
+
+ // specialize the member template again, now
+ // specializing the member too. This specializes
+ // #A
+ template<> template<>
+ struct A<int>::B<int> {
+ // #3
+ void h();
+ };
+
+ // defines #3. There is no enclosing class template, so
+ // we write no "template<>".
+ void A<int>::B<int>::h() { }
+
+ void test() {
+ // calls #1
+ A<int>::B<float> a; a.g();
+
+ // calls #2
+ A<float>::B<int> b; b.f();
+
+ // calls #3
+ A<int>::B<int> c; c.h();
+ }
+}
+
+namespace PR9482 {
+ namespace N1 {
+ template <typename T> struct S {
+ void foo() {}
+ };
+ }
+
+ namespace N2 {
+ typedef N1::S<int> X;
+ }
+
+ namespace N1 {
+ template<> void N2::X::foo() {}
+ }
+}
+
+namespace PR9668 {
+ namespace First
+ {
+ template<class T>
+ class Bar
+ {
+ protected:
+
+ static const bool static_bool;
+ };
+ }
+
+ namespace Second
+ {
+ class Foo;
+ }
+
+ typedef First::Bar<Second::Foo> Special;
+
+ namespace
+ First
+ {
+ template<>
+ const bool Special::static_bool(false);
+ }
+}
+
+namespace PR9877 {
+ template<int>
+ struct X
+ {
+ struct Y;
+ };
+
+ template<> struct X<0>::Y { static const int Z = 1; };
+ template<> struct X<1>::Y { static const int Z = 1; };
+
+ const int X<0>::Y::Z;
+ template<> const int X<1>::Y::Z; // expected-error{{extraneous 'template<>' in declaration of variable 'Z'}}
+}
+
+namespace PR9913 {
+ template<class,class=int>struct S;
+ template<class X>struct S<X> {
+ template<class T> class F;
+ };
+
+ template<class A>
+ template<class B>
+ class S<A>::F{};
+}
+
+namespace template_class_spec_perClassDecl_nested
+{
+ template <typename T1> struct A {
+ template <typename T2> struct B {
+ template <typename T3> struct C {
+ static void foo();
+ };
+ };
+ };
+
+ template <> struct A<int> {
+ template <typename T2> struct B {
+ template <typename T3> struct C {
+ static void foo();
+ };
+ };
+ };
+
+ template <> template <typename T3> struct A<int>::B<int>::C {
+ static void foo();
+ };
+
+ template <> template <> struct A<int>::B<int>::C<int> {
+ static void foo();
+ };
+
+ template <> template<> template <typename T2> struct A<bool>::B<bool>::C {
+ static void foo();
+ };
+}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
index a5ecf5fc..72f33df 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
@@ -20,3 +20,14 @@ NonDefaultConstructible &test(bool b) {
return b? X<NonDefaultConstructible, int>::member // expected-note{{instantiation}}
: X<NonDefaultConstructible, long>::member;
}
+
+namespace rdar9422013 {
+ template<int>
+ struct X {
+ struct Inner {
+ static unsigned array[17];
+ };
+ };
+
+ template<> unsigned X<1>::Inner::array[]; // okay
+}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp
index 2f9a3cb..c7597e9 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
template<class T> struct A {
void f(T);
template<class X1> void g1(T, X1);
@@ -24,3 +24,15 @@ template<> template<>
// member specialization even if defined in class definition
template<> void A<int>::h(int) { }
+
+namespace PR10024 {
+ template <typename T>
+ struct Test{
+ template <typename U>
+ void get(U i) {}
+ };
+
+ template <typename T>
+ template <>
+ void Test<T>::get<double>(double i) {} // expected-error{{cannot specialize (with 'template<>') a member of an unspecialized template}}
+}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
index 88cfc5d..56231e2 100644
--- a/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp
@@ -24,12 +24,11 @@ namespace test1 {
template <> class A<double> {
public:
- static int foo; // expected-note{{attempt to specialize}}
+ static int foo;
static int bar;
};
typedef A<double> AB;
- template <> int AB::foo = 0; // expected-error{{extraneous 'template<>'}} \
- // expected-error{{does not specialize}}
+ template <> int AB::foo = 0; // expected-error{{extraneous 'template<>'}}
int AB::bar = 1;
}
diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp
new file mode 100644
index 0000000..f49190e
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<class T> struct A {
+ struct B { };
+ template<class U> struct C { };
+};
+ template<> struct A<int> {
+ void f(int);
+};
+void h() {
+ A<int> a;
+ a.f(16);
+}
+// A<int>::f must be defined somewhere
+// template<> not used for a member of an // explicitly specialized class template
+void A<int>::f(int) { /* ... */ }
+ template<> struct A<char>::B {
+ void f();
+};
+// template<> also not used when defining a member of // an explicitly specialized member class
+void A<char>::B::f() { /* ... */ }
+ template<> template<class U> struct A<char>::C {
+ void f();
+};
+
+template<>
+template<class U> void A<char>::C<U>::f() { /* ... */ }
+ template<> struct A<short>::B {
+ void f();
+};
+template<> void A<short>::B::f() { /* ... */ } // expected-error{{no function template matches function template specialization 'f'}}
+ template<> template<class U> struct A<short>::C {
+ void f();
+};
+template<class U> void A<short>::C<U>::f() { /* ... */ } // expected-error{{template parameter list matching the non-templated nested type 'A<short>' should be empty ('template<>')}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
index 70d338b..822f881 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 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// Example from the standard
template<class T> class Array { void mf() { } };
@@ -35,7 +35,7 @@ namespace N {
};
template<typename T>
- void f1(T) {}; // expected-note{{explicit instantiation refers here}}
+ void f1(T) {} // expected-note{{explicit instantiation refers here}}
}
using namespace N;
diff --git a/test/CXX/temp/temp.type/p1-0x.cpp b/test/CXX/temp/temp.type/p1-0x.cpp
new file mode 100644
index 0000000..c22af22
--- /dev/null
+++ b/test/CXX/temp/temp.type/p1-0x.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+namespace Old {
+ template<template<class> class TT> struct X { };
+ template<class> struct Y { };
+ template<class T> using Z = Y<T>;
+ X<Y> y;
+ X<Z> z;
+
+ using SameType = decltype(y); // expected-note {{here}}
+ using SameType = decltype(z); // expected-error {{different types}}
+}
+
+namespace New {
+ template<class T> struct X { };
+ template<class> struct Y { };
+ template<class T> using Z = Y<T>;
+ X<Y<int>> y;
+ X<Z<int>> z;
+
+ using SameType = decltype(y);
+ using SameType = decltype(z); // ok
+}
diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c
index 3c46bea..42f020e 100644
--- a/test/CodeGen/2009-10-20-GlobalDebug.c
+++ b/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: %clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s
int global;
// CHECK: ascii "localstatic" ## DW_AT_name
diff --git a/test/CodeGen/altivec.c b/test/CodeGen/altivec.c
index ec1efd9..c3b1f42 100644
--- a/test/CodeGen/altivec.c
+++ b/test/CodeGen/altivec.c
@@ -23,7 +23,7 @@ void test2()
// Check pre/post increment/decrement
void test3() {
vector int vi;
- vi++; // CHECK: add nsw <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
+ vi++; // CHECK: add <4 x i32> {{.*}} <i32 1, i32 1, i32 1, i32 1>
vector unsigned int vui;
--vui; // CHECK: add <4 x i32> {{.*}} <i32 -1, i32 -1, i32 -1, i32 -1>
vector float vf;
diff --git a/test/CodeGen/arm-asm.c b/test/CodeGen/arm-asm.c
new file mode 100644
index 0000000..9b1082a
--- /dev/null
+++ b/test/CodeGen/arm-asm.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s
+int t1() {
+ static float k = 1.0f;
+ // CHECK: flds s15
+ __asm__ volatile ("flds s15, %[k] \n" :: [k] "Uv" (k) : "s15");
+ return 0;
+}
diff --git a/test/CodeGen/asm-errors.c b/test/CodeGen/asm-errors.c
index c5b36c7..cd4d1ff 100644
--- a/test/CodeGen/asm-errors.c
+++ b/test/CodeGen/asm-errors.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s -o /dev/null > %t 2>&1
// RUN: FileCheck %s < %t
diff --git a/test/CodeGen/asm-label.c b/test/CodeGen/asm-label.c
new file mode 100644
index 0000000..7be2ad3
--- /dev/null
+++ b/test/CodeGen/asm-label.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple=i686-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm %s -o - | FileCheck %s --check-prefix=DARWIN
+
+char *strerror(int) asm("alias");
+
+void test(void)
+{
+ strerror(-1);
+}
+
+// LINUX: declare i8* @alias(i32)
+// DARWIN: declare i8* @"\01alias"(i32)
diff --git a/test/CodeGen/available-externally-suppress.c b/test/CodeGen/available-externally-suppress.c
index 747d3cd..46b6e74 100644
--- a/test/CodeGen/available-externally-suppress.c
+++ b/test/CodeGen/available-externally-suppress.c
@@ -11,17 +11,17 @@ void test() {
f0(17);
}
-inline int __attribute__((always_inline)) f1(int x) {
+inline int __attribute__((always_inline)) f1(int x) {
int blarg = 0;
for (int i = 0; i < x; ++i)
blarg = blarg + x * i;
- return blarg;
+ return blarg;
}
// CHECK: @test1
-int test1(int x) {
+int test1(int x) {
// CHECK: br i1
- // CHECK-NOT: call
+ // CHECK-NOT: call {{.*}} @f1
// CHECK: ret i32
- return f1(x);
+ return f1(x);
}
diff --git a/test/CodeGen/avx-cmp-builtins.c b/test/CodeGen/avx-cmp-builtins.c
new file mode 100644
index 0000000..1ac1c31
--- /dev/null
+++ b/test/CodeGen/avx-cmp-builtins.c
@@ -0,0 +1,46 @@
+// 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 cmpXY instructions
+//
+
+__m128d test_cmp_pd(__m128d a, __m128d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse2.cmp.pd({{.*}}, i8 13)
+ return _mm_cmp_pd(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_ps(__m128 a, __m128 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse.cmp.ps({{.*}}, i8 13)
+ return _mm_cmp_ps(a, b, _CMP_GE_OS);
+}
+
+__m256d test_cmp_pd256(__m256d a, __m256d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.avx.cmp.pd.256({{.*}}, i8 13)
+ return _mm256_cmp_pd(a, b, _CMP_GE_OS);
+}
+
+__m256d test_cmp_ps256(__m256 a, __m256 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.avx.cmp.ps.256({{.*}}, i8 13)
+ return _mm256_cmp_ps(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_sd(__m128d a, __m128d b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse2.cmp.sd({{.*}}, i8 13)
+ return _mm_cmp_sd(a, b, _CMP_GE_OS);
+}
+
+__m128d test_cmp_ss(__m128 a, __m128 b) {
+ // Expects that the third argument in LLVM IR is immediate expression
+ // CHECK: @llvm.x86.sse.cmp.ss({{.*}}, i8 13)
+ return _mm_cmp_ss(a, b, _CMP_GE_OS);
+}
diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c
index 586f113..b12ff01 100644
--- a/test/CodeGen/builtins-ppc-altivec.c
+++ b/test/CodeGen/builtins-ppc-altivec.c
@@ -44,13 +44,13 @@ int res_f;
void test1() {
/* vec_abs */
- vsc = vec_abs(vsc); // CHECK: sub nsw <16 x i8> zeroinitializer
+ vsc = vec_abs(vsc); // CHECK: sub <16 x i8> zeroinitializer
// CHECK: @llvm.ppc.altivec.vmaxsb
- vs = vec_abs(vs); // CHECK: sub nsw <8 x i16> zeroinitializer
+ vs = vec_abs(vs); // CHECK: sub <8 x i16> zeroinitializer
// CHECK: @llvm.ppc.altivec.vmaxsh
- vi = vec_abs(vi); // CHECK: sub nsw <4 x i32> zeroinitializer
+ vi = vec_abs(vi); // CHECK: sub <4 x i32> zeroinitializer
// CHECK: @llvm.ppc.altivec.vmaxsw
vf = vec_abs(vf); // CHECK: and <4 x i32>
@@ -66,40 +66,40 @@ void test1() {
// CHECK: @llvm.ppc.altivec.vmaxsw
/* vec_add */
- res_vsc = vec_add(vsc, vsc); // CHECK: add nsw <16 x i8>
- res_vsc = vec_add(vbc, vsc); // CHECK: add nsw <16 x i8>
- res_vsc = vec_add(vsc, vbc); // CHECK: add nsw <16 x i8>
+ res_vsc = vec_add(vsc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_add(vbc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_add(vsc, vbc); // CHECK: add <16 x i8>
res_vuc = vec_add(vuc, vuc); // CHECK: add <16 x i8>
res_vuc = vec_add(vbc, vuc); // CHECK: add <16 x i8>
res_vuc = vec_add(vuc, vbc); // CHECK: add <16 x i8>
- res_vs = vec_add(vs, vs); // CHECK: add nsw <8 x i16>
- res_vs = vec_add(vbs, vs); // CHECK: add nsw <8 x i16>
- res_vs = vec_add(vs, vbs); // CHECK: add nsw <8 x i16>
+ res_vs = vec_add(vs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_add(vbs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_add(vs, vbs); // CHECK: add <8 x i16>
res_vus = vec_add(vus, vus); // CHECK: add <8 x i16>
res_vus = vec_add(vbs, vus); // CHECK: add <8 x i16>
res_vus = vec_add(vus, vbs); // CHECK: add <8 x i16>
- res_vi = vec_add(vi, vi); // CHECK: add nsw <4 x i32>
- res_vi = vec_add(vbi, vi); // CHECK: add nsw <4 x i32>
- res_vi = vec_add(vi, vbi); // CHECK: add nsw <4 x i32>
+ res_vi = vec_add(vi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_add(vbi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_add(vi, vbi); // CHECK: add <4 x i32>
res_vui = vec_add(vui, vui); // CHECK: add <4 x i32>
res_vui = vec_add(vbi, vui); // CHECK: add <4 x i32>
res_vui = vec_add(vui, vbi); // CHECK: add <4 x i32>
res_vf = vec_add(vf, vf); // CHECK: fadd <4 x float>
- res_vsc = vec_vaddubm(vsc, vsc); // CHECK: add nsw <16 x i8>
- res_vsc = vec_vaddubm(vbc, vsc); // CHECK: add nsw <16 x i8>
- res_vsc = vec_vaddubm(vsc, vbc); // CHECK: add nsw <16 x i8>
+ res_vsc = vec_vaddubm(vsc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_vaddubm(vbc, vsc); // CHECK: add <16 x i8>
+ res_vsc = vec_vaddubm(vsc, vbc); // CHECK: add <16 x i8>
res_vuc = vec_vaddubm(vuc, vuc); // CHECK: add <16 x i8>
res_vuc = vec_vaddubm(vbc, vuc); // CHECK: add <16 x i8>
res_vuc = vec_vaddubm(vuc, vbc); // CHECK: add <16 x i8>
- res_vs = vec_vadduhm(vs, vs); // CHECK: add nsw <8 x i16>
- res_vs = vec_vadduhm(vbs, vs); // CHECK: add nsw <8 x i16>
- res_vs = vec_vadduhm(vs, vbs); // CHECK: add nsw <8 x i16>
+ res_vs = vec_vadduhm(vs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_vadduhm(vbs, vs); // CHECK: add <8 x i16>
+ res_vs = vec_vadduhm(vs, vbs); // CHECK: add <8 x i16>
res_vus = vec_vadduhm(vus, vus); // CHECK: add <8 x i16>
res_vus = vec_vadduhm(vbs, vus); // CHECK: add <8 x i16>
res_vus = vec_vadduhm(vus, vbs); // CHECK: add <8 x i16>
- res_vi = vec_vadduwm(vi, vi); // CHECK: add nsw <4 x i32>
- res_vi = vec_vadduwm(vbi, vi); // CHECK: add nsw <4 x i32>
- res_vi = vec_vadduwm(vi, vbi); // CHECK: add nsw <4 x i32>
+ res_vi = vec_vadduwm(vi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_vadduwm(vbi, vi); // CHECK: add <4 x i32>
+ res_vi = vec_vadduwm(vi, vbi); // CHECK: add <4 x i32>
res_vui = vec_vadduwm(vui, vui); // CHECK: add <4 x i32>
res_vui = vec_vadduwm(vbi, vui); // CHECK: add <4 x i32>
res_vui = vec_vadduwm(vui, vbi); // CHECK: add <4 x i32>
@@ -689,14 +689,14 @@ void test6() {
res_vus = vec_mladd(vus, vus, vus); // CHECK: mul <8 x i16>
// CHECK: add <8 x i16>
- res_vs = vec_mladd(vus, vs, vs); // CHECK: mul nsw <8 x i16>
- // CHECK: add nsw <8 x i16>
+ res_vs = vec_mladd(vus, vs, vs); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
- res_vs = vec_mladd(vs, vus, vus); // CHECK: mul nsw <8 x i16>
- // CHECK: add nsw <8 x i16>
+ res_vs = vec_mladd(vs, vus, vus); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
- res_vs = vec_mladd(vs, vs, vs); // CHECK: mul nsw <8 x i16>
- // CHECK: add nsw <8 x i16>
+ res_vs = vec_mladd(vs, vs, vs); // CHECK: mul <8 x i16>
+ // CHECK: add <8 x i16>
/* vec_mradds */
res_vs = vec_mradds(vs, vs, vs); // CHECK: @llvm.ppc.altivec.vmhraddshs
@@ -1592,40 +1592,40 @@ void test6() {
vec_stvxl(vf, 0, &param_f); // CHECK: @llvm.ppc.altivec.stvxl
/* vec_sub */
- res_vsc = vec_sub(vsc, vsc); // CHECK: sub nsw <16 x i8>
- res_vsc = vec_sub(vbc, vsc); // CHECK: sub nsw <16 x i8>
- res_vsc = vec_sub(vsc, vbc); // CHECK: sub nsw <16 x i8>
+ res_vsc = vec_sub(vsc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_sub(vbc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_sub(vsc, vbc); // CHECK: sub <16 x i8>
res_vuc = vec_sub(vuc, vuc); // CHECK: sub <16 x i8>
res_vuc = vec_sub(vbc, vuc); // CHECK: sub <16 x i8>
res_vuc = vec_sub(vuc, vbc); // CHECK: sub <16 x i8>
- res_vs = vec_sub(vs, vs); // CHECK: sub nsw <8 x i16>
- res_vs = vec_sub(vbs, vs); // CHECK: sub nsw <8 x i16>
- res_vs = vec_sub(vs, vbs); // CHECK: sub nsw <8 x i16>
+ res_vs = vec_sub(vs, vs); // CHECK: sub <8 x i16>
+ res_vs = vec_sub(vbs, vs); // CHECK: sub <8 x i16>
+ res_vs = vec_sub(vs, vbs); // CHECK: sub <8 x i16>
res_vus = vec_sub(vus, vus); // CHECK: sub <8 x i16>
res_vus = vec_sub(vbs, vus); // CHECK: sub <8 x i16>
res_vus = vec_sub(vus, vbs); // CHECK: sub <8 x i16>
- res_vi = vec_sub(vi, vi); // CHECK: sub nsw <4 x i32>
- res_vi = vec_sub(vbi, vi); // CHECK: sub nsw <4 x i32>
- res_vi = vec_sub(vi, vbi); // CHECK: sub nsw <4 x i32>
+ res_vi = vec_sub(vi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_sub(vbi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_sub(vi, vbi); // CHECK: sub <4 x i32>
res_vui = vec_sub(vui, vui); // CHECK: sub <4 x i32>
res_vui = vec_sub(vbi, vui); // CHECK: sub <4 x i32>
res_vui = vec_sub(vui, vbi); // CHECK: sub <4 x i32>
res_vf = vec_sub(vf, vf); // CHECK: fsub <4 x float>
- res_vsc = vec_vsububm(vsc, vsc); // CHECK: sub nsw <16 x i8>
- res_vsc = vec_vsububm(vbc, vsc); // CHECK: sub nsw <16 x i8>
- res_vsc = vec_vsububm(vsc, vbc); // CHECK: sub nsw <16 x i8>
+ res_vsc = vec_vsububm(vsc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_vsububm(vbc, vsc); // CHECK: sub <16 x i8>
+ res_vsc = vec_vsububm(vsc, vbc); // CHECK: sub <16 x i8>
res_vuc = vec_vsububm(vuc, vuc); // CHECK: sub <16 x i8>
res_vuc = vec_vsububm(vbc, vuc); // CHECK: sub <16 x i8>
res_vuc = vec_vsububm(vuc, vbc); // CHECK: sub <16 x i8>
- res_vs = vec_vsubuhm(vs, vs); // CHECK: sub nsw <8 x i16>
+ res_vs = vec_vsubuhm(vs, vs); // CHECK: sub <8 x i16>
res_vs = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16>
res_vs = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16>
res_vus = vec_vsubuhm(vus, vus); // CHECK: sub <8 x i16>
res_vus = vec_vsubuhm(vbs, vus); // CHECK: sub <8 x i16>
res_vus = vec_vsubuhm(vus, vbs); // CHECK: sub <8 x i16>
- res_vi = vec_vsubuwm(vi, vi); // CHECK: sub nsw <4 x i32>
- res_vi = vec_vsubuwm(vbi, vi); // CHECK: sub nsw <4 x i32>
- res_vi = vec_vsubuwm(vi, vbi); // CHECK: sub nsw <4 x i32>
+ res_vi = vec_vsubuwm(vi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_vsubuwm(vbi, vi); // CHECK: sub <4 x i32>
+ res_vi = vec_vsubuwm(vi, vbi); // CHECK: sub <4 x i32>
res_vui = vec_vsubuwm(vui, vui); // CHECK: sub <4 x i32>
res_vui = vec_vsubuwm(vbi, vui); // CHECK: sub <4 x i32>
res_vui = vec_vsubuwm(vui, vbi); // CHECK: sub <4 x i32>
diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c
index bb63048..728ade3 100644
--- a/test/CodeGen/builtins-x86.c
+++ b/test/CodeGen/builtins-x86.c
@@ -317,7 +317,6 @@ void f0() {
(void) __builtin_ia32_clflush(tmp_vCp);
(void) __builtin_ia32_lfence();
(void) __builtin_ia32_mfence();
- tmp_V16c = __builtin_ia32_loaddqu(tmp_cCp);
(void) __builtin_ia32_storedqu(tmp_cp, tmp_V16c);
tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
diff --git a/test/CodeGen/builtinshufflevector.c b/test/CodeGen/builtinshufflevector.c
index f365844..5c647df 100644
--- a/test/CodeGen/builtinshufflevector.c
+++ b/test/CodeGen/builtinshufflevector.c
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -emit-llvm < %s | grep 'shufflevector' | count 1
+// RUN: %clang_cc1 -emit-llvm -ftrapv < %s | grep 'shufflevector' | count 1
typedef int v4si __attribute__ ((vector_size (16)));
-v4si a(v4si x, v4si y) {return __builtin_shufflevector(x, y, 3, 2, 5, 7);}
+v4si a(v4si x, v4si y) {return __builtin_shufflevector(x, y, 3, 2, 5, (2*3)+1);}
diff --git a/test/CodeGen/byval-memcpy-elim.c b/test/CodeGen/byval-memcpy-elim.c
new file mode 100644
index 0000000..8aa08fb
--- /dev/null
+++ b/test/CodeGen/byval-memcpy-elim.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s
+
+struct Test1S {
+ long NumDecls;
+ long X;
+ long Y;
+};
+struct Test2S {
+ long NumDecls;
+ long X;
+};
+
+// Make sure we don't generate extra memcpy for lvalues
+void test1a(struct Test1S, struct Test2S);
+// CHECK: define void @test1(
+// CHECK-NOT: memcpy
+// CHECK: call void @test1a
+void test1(struct Test1S *A, struct Test2S *B) {
+ test1a(*A, *B);
+}
diff --git a/test/CodeGen/debug-info-crash.c b/test/CodeGen/debug-info-crash.c
index 8d6a360..f04548b 100644
--- a/test/CodeGen/debug-info-crash.c
+++ b/test/CodeGen/debug-info-crash.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -g -S %s -o -
// rdar://7590323
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index a84d0b2..876c6c2 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -o %t -emit-llvm -g %s
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o %t -emit-llvm -g %s
// RUN: FileCheck --input-file=%t %s
// PR3023
@@ -47,3 +47,10 @@ struct foo2 foo2;
typedef int barfoo;
barfoo foo() {
}
+
+// CHECK: __uint128_t
+__uint128_t foo128 ()
+{
+ __uint128_t int128 = 44;
+ return int128;
+}
diff --git a/test/CodeGen/decl.c b/test/CodeGen/decl.c
index 7a9971e..29520d7 100644
--- a/test/CodeGen/decl.c
+++ b/test/CodeGen/decl.c
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
// CHECK: @test1.x = internal constant [12 x i32] [i32 1
-// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
+// CHECK: @test2.x = internal unnamed_addr constant [13 x i32] [i32 1,
// CHECK: @test5w = global %0 { i32 2, [4 x i8] undef }
// CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
-// CHECK: @test6.x = internal constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
+// CHECK: @test6.x = internal unnamed_addr constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
// CHECK: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }]
diff --git a/test/CodeGen/ext-vector.c b/test/CodeGen/ext-vector.c
index 1abd9f2..a222f94 100644
--- a/test/CodeGen/ext-vector.c
+++ b/test/CodeGen/ext-vector.c
@@ -131,9 +131,9 @@ void test7(int4 *ap, int4 *bp, int c) {
int4 a = *ap;
int4 b = *bp;
- // CHECK: add nsw <4 x i32>
- // CHECK: sub nsw <4 x i32>
- // CHECK: mul nsw <4 x i32>
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
// CHECK: sdiv <4 x i32>
// CHECK: srem <4 x i32>
a = a + b;
@@ -142,9 +142,9 @@ void test7(int4 *ap, int4 *bp, int c) {
a = a / b;
a = a % b;
- // CHECK: add nsw <4 x i32>
- // CHECK: sub nsw <4 x i32>
- // CHECK: mul nsw <4 x i32>
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
// CHECK: sdiv <4 x i32>
// CHECK: srem <4 x i32>
a = a + c;
@@ -153,9 +153,9 @@ void test7(int4 *ap, int4 *bp, int c) {
a = a / c;
a = a % c;
- // CHECK: add nsw <4 x i32>
- // CHECK: sub nsw <4 x i32>
- // CHECK: mul nsw <4 x i32>
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
// CHECK: sdiv <4 x i32>
// CHECK: srem <4 x i32>
a += b;
@@ -164,9 +164,9 @@ void test7(int4 *ap, int4 *bp, int c) {
a /= b;
a %= b;
- // CHECK: add nsw <4 x i32>
- // CHECK: sub nsw <4 x i32>
- // CHECK: mul nsw <4 x i32>
+ // CHECK: add <4 x i32>
+ // CHECK: sub <4 x i32>
+ // CHECK: mul <4 x i32>
// CHECK: sdiv <4 x i32>
// CHECK: srem <4 x i32>
a += c;
@@ -220,7 +220,7 @@ int test9(int4 V) {
}
// CHECK: @test10
-// CHECK: add nsw <4 x i32>
+// CHECK: add <4 x i32>
// CHECK: extractelement <4 x i32>
int test10(int4 V) {
return (V+V).x;
diff --git a/test/CodeGen/extern-inline.c b/test/CodeGen/extern-inline.c
index 60f6d03..e3df996 100644
--- a/test/CodeGen/extern-inline.c
+++ b/test/CodeGen/extern-inline.c
@@ -1,4 +1,5 @@
// RUN: %clang -S -emit-llvm -std=gnu89 -o - %s | FileCheck %s
+// RUN: %clang -S -emit-llvm -fgnu89-inline -o - %s | FileCheck %s
// PR5253
// If an extern inline function is redefined, functions should call the
diff --git a/test/CodeGen/frame-pointer-elim.c b/test/CodeGen/frame-pointer-elim.c
index e9dc22b..4e8e946 100644
--- a/test/CodeGen/frame-pointer-elim.c
+++ b/test/CodeGen/frame-pointer-elim.c
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+
// RUN: %clang -ccc-host-triple i386-apple-darwin -S -o - %s | \
// RUN: FileCheck --check-prefix=DARWIN %s
// DARWIN: f0:
diff --git a/test/CodeGen/inline.c b/test/CodeGen/inline.c
index a6b4b3e..96f9c5c 100644
--- a/test/CodeGen/inline.c
+++ b/test/CodeGen/inline.c
@@ -29,7 +29,7 @@
// RUN: grep "define available_externally i32 @test5" %t
// RUN: echo "\nC++ tests:"
-// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=c++98
+// 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
// RUN: grep "define i32 @_Z3barv()" %t
diff --git a/test/CodeGen/mmx-builtins.c b/test/CodeGen/mmx-builtins.c
index 7934e77..b142684 100644
--- a/test/CodeGen/mmx-builtins.c
+++ b/test/CodeGen/mmx-builtins.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +ssse3 -S -o - | FileCheck %s
// FIXME: Disable inclusion of mm_malloc.h, our current implementation is broken
diff --git a/test/CodeGen/ms_struct-bitfield-1.c b/test/CodeGen/ms_struct-bitfield-1.c
new file mode 100644
index 0000000..0b15a24
--- /dev/null
+++ b/test/CodeGen/ms_struct-bitfield-1.c
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct {
+ unsigned int bf_1 : 12;
+ unsigned int : 0;
+ unsigned int bf_2 : 12;
+} ATTR t1;
+static int a1[(sizeof(t1) == 8) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar;
+} ATTR t2;
+static int a2[(sizeof(t2) == 4) -1];
+
+#pragma ms_struct on
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar;
+} t3;
+#pragma ms_struct off
+static int a3[(sizeof(t3) == 4) -1];
+
+struct
+{
+ char foo : 6;
+ long : 0;
+} ATTR t4;
+static int a4[(sizeof(t4) == 8) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ char bar : 8;
+} ATTR t5;
+static int a5[(sizeof(t5) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ long :0;
+ char bar;
+} ATTR t6;
+static int a6[(sizeof(t6) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ long :0;
+ short : 0;
+ char bar;
+} ATTR t7;
+static int a7[(sizeof(t7) == 16) -1];
+
+struct
+{
+ char foo : 4;
+ short : 0;
+ long :0;
+ char bar:7;
+} ATTR t8;
+static int a8[(sizeof(t8) == 4) -1];
+
+struct
+{
+ char foo : 4;
+ long :0;
+ short : 0;
+ char bar: 8;
+} ATTR t9;
+static int a9[(sizeof(t9) == 16) -1];
+
+struct
+{
+ char foo : 4;
+ char : 0;
+ short : 0;
+ int : 0;
+ long :0;
+ char bar;
+} ATTR t10;
+static int a10[(sizeof(t10) == 2) -1];
diff --git a/test/CodeGen/ms_struct-bitfield-2.c b/test/CodeGen/ms_struct-bitfield-2.c
new file mode 100644
index 0000000..36e0172
--- /dev/null
+++ b/test/CodeGen/ms_struct-bitfield-2.c
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+#define size_struct_0 1
+#define size_struct_1 4
+#define size_struct_2 24
+#define size_struct_3 8
+#define size_struct_4 32
+#define size_struct_5 12
+#define size_struct_6 40
+#define size_struct_7 8
+#define size_struct_8 20
+#define size_struct_9 32
+
+struct _struct_0
+{
+ char member_0;
+} ATTR;
+typedef struct _struct_0 struct_0;
+
+struct _struct_1
+{
+ char member_0;
+ short member_1:13;
+} ATTR;
+typedef struct _struct_1 struct_1;
+
+struct _struct_2
+{
+ double member_0;
+ unsigned char member_1:8;
+ int member_2:32;
+ unsigned char member_3:5;
+ short member_4:14;
+ short member_5:13;
+ unsigned char:0;
+} ATTR;
+typedef struct _struct_2 struct_2;
+
+struct _struct_3
+{
+ unsigned int member_0:26;
+ unsigned char member_1:2;
+
+} ATTR;
+typedef struct _struct_3 struct_3;
+
+struct _struct_4
+{
+ unsigned char member_0:7;
+ double member_1;
+ double member_2;
+ short member_3:5;
+ char member_4:2;
+
+} ATTR;
+typedef struct _struct_4 struct_4;
+
+struct _struct_5
+{
+ unsigned short member_0:12;
+ int member_1:1;
+ unsigned short member_2:6;
+
+} ATTR;
+typedef struct _struct_5 struct_5;
+
+struct _struct_6
+{
+ unsigned char member_0:7;
+ unsigned int member_1:25;
+ char member_2:1;
+ double member_3;
+ short member_4:9;
+ double member_5;
+
+} ATTR;
+typedef struct _struct_6 struct_6;
+
+struct _struct_7
+{
+ double member_0;
+
+} ATTR;
+typedef struct _struct_7 struct_7;
+
+struct _struct_8
+{
+ unsigned char member_0:7;
+ int member_1:11;
+ int member_2:5;
+ int:0;
+ char member_4:8;
+ unsigned short member_5:4;
+ unsigned char member_6:3;
+ int member_7:23;
+
+} ATTR;
+typedef struct _struct_8 struct_8;
+
+struct _struct_9
+{
+ double member_0;
+ unsigned int member_1:6;
+ int member_2:17;
+ double member_3;
+ unsigned int member_4:22;
+
+} ATTR;
+typedef struct _struct_9 struct_9;
+
+struct_0 test_struct_0 = { 123 };
+struct_1 test_struct_1 = { 82, 1081 };
+struct_2 test_struct_2 = { 20.0, 31, 407760, 1, 14916, 6712 };
+struct_3 test_struct_3 = { 64616999, 1 };
+struct_4 test_struct_4 = { 61, 20.0, 20.0, 12, 0 };
+struct_5 test_struct_5 = { 909, 1, 57 };
+struct_6 test_struct_6 = { 12, 21355796, 0, 20.0, 467, 20.0 };
+struct_7 test_struct_7 = { 20.0 };
+struct_8 test_struct_8 = { 126, 1821, 22, 125, 6, 0, 2432638 };
+struct_9 test_struct_9 = { 20.0, 3, 23957, 20.0, 1001631 };
+
+
+static int a0[(sizeof (struct_0) == size_struct_0) -1];
+static int a1[(sizeof (struct_1) == size_struct_1) -1];
+static int a2[(sizeof (struct_2) == size_struct_2) -1];
+static int a3[(sizeof (struct_3) == size_struct_3) -1];
+static int a4[(sizeof (struct_4) == size_struct_4) -1];
+static int a5[(sizeof (struct_5) == size_struct_5) -1];
+static int a6[(sizeof (struct_6) == size_struct_6) -1];
+static int a7[(sizeof (struct_7) == size_struct_7) -1];
+static int a8[(sizeof (struct_8) == size_struct_8) -1];
+static int a9[(sizeof (struct_9) == size_struct_9) -1];
diff --git a/test/CodeGen/ms_struct-bitfield-3.c b/test/CodeGen/ms_struct-bitfield-3.c
new file mode 100644
index 0000000..0eba435
--- /dev/null
+++ b/test/CodeGen/ms_struct-bitfield-3.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i386-apple-darwin9 %s
+// rdar://8823265
+
+#define ATTR __attribute__((__ms_struct__))
+
+struct _struct_0
+{
+ int member_0 : 25 ;
+ short member_1 : 6 ;
+ char member_2 : 2 ;
+ unsigned short member_3 : 1 ;
+ unsigned char member_4 : 7 ;
+ short member_5 : 16 ;
+ int : 0 ;
+ char member_7 ;
+
+} ATTR;
+
+typedef struct _struct_0 struct_0;
+
+#define size_struct_0 20
+
+struct_0 test_struct_0 = { 18557917, 17, 3, 0, 80, 6487, 93 };
+static int a[(size_struct_0 == sizeof (struct_0)) -1];
+
+struct _struct_1 {
+ int d;
+ unsigned char a;
+ unsigned short b:7;
+ char c;
+} ATTR;
+
+typedef struct _struct_1 struct_1;
+
+#define size_struct_1 12
+
+struct_1 test_struct_1 = { 18557917, 'a', 3, 'b' };
+
+static int a1[(size_struct_1 == sizeof (struct_1)) -1];
+
+struct ten {
+ long long a:3;
+ long long b:3;
+ char c;
+} __attribute__ ((ms_struct));
+
+#define size_struct_2 16
+
+static int a2[(size_struct_2 == sizeof (struct ten)) -1];
diff --git a/test/CodeGen/ms_struct-pack.c b/test/CodeGen/ms_struct-pack.c
new file mode 100644
index 0000000..da94f54
--- /dev/null
+++ b/test/CodeGen/ms_struct-pack.c
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i386-apple-darwin9 %s
+// rdar://8823265
+
+#pragma pack(1)
+struct _one_ms {
+ short m:9; // size is 2
+ int q:27; // size is 6
+ short w:13; // size is 8
+ short e:3; // size is 8
+ char r:4; // size is 9
+ char t:7; // size is 10
+ short y:16; // size is 12
+ short u:1; // size is 14
+ char i:2; // size is 15
+ int a; // size is 19
+ char o:6; // size is 20
+ char s:2; // size is 20
+ short d:10; // size is 22
+ short f:4; // size is 22
+ char b; // size is 23
+ char g:1; // size is 24
+ short h:13; // size is 26
+ char j:8; // size is 27
+ char k:5; // size is 28
+ char c; // size is 29
+ int l:28; // size is 33
+ char z:7; // size is 34
+ int x:20; // size is 38
+} __attribute__((__ms_struct__));
+typedef struct _one_ms one_ms;
+
+static int a1[(sizeof(one_ms) == 38) - 1];
+
+#pragma pack(2)
+struct _two_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+
+typedef struct _two_ms two_ms;
+
+static int a2[(sizeof(two_ms) == 42) - 1];
+
+#pragma pack(4)
+struct _four_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+typedef struct _four_ms four_ms;
+
+static int a4[(sizeof(four_ms) == 48) - 1];
+
+#pragma pack(8)
+struct _eight_ms {
+ short m:9;
+ int q:27;
+ short w:13;
+ short e:3;
+ char r:4;
+ char t:7;
+ short y:16;
+ short u:1;
+ char i:2;
+ int a;
+ char o:6;
+ char s:2;
+ short d:10;
+ short f:4;
+ char b;
+ char g:1;
+ short h:13;
+ char j:8;
+ char k:5;
+ char c;
+ int l:28;
+ char z:7;
+ int x:20;
+} __attribute__((__ms_struct__));
+
+typedef struct _eight_ms eight_ms;
+
+static int a8[(sizeof(eight_ms) == 48) - 1];
+
diff --git a/test/CodeGen/ms_struct.c b/test/CodeGen/ms_struct.c
new file mode 100644
index 0000000..a5f9606
--- /dev/null
+++ b/test/CodeGen/ms_struct.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
+
+#define ATTR __attribute__((__ms_struct__))
+struct s1 {
+ int f32;
+ long long f64;
+} ATTR s1;
+
+// CHECK: %struct.s1 = type { i32, [4 x i8], i64 }
+
+struct s2 {
+ int f32;
+ long long f64[4];
+} ATTR s2;
+
+// CHECK: %struct.s2 = type { i32, [4 x i8], [4 x i64] }
+
+struct s3 {
+ int f32;
+ struct s1 s;
+} ATTR s3;
+
+// CHECK: %struct.s3 = type { i32, [4 x i8], %struct.s1 }
diff --git a/test/CodeGen/packed-arrays.c b/test/CodeGen/packed-arrays.c
index 785db4d..0c8bb6c 100644
--- a/test/CodeGen/packed-arrays.c
+++ b/test/CodeGen/packed-arrays.c
@@ -34,10 +34,8 @@ int align3 = __alignof(struct s3);
// CHECK: @align0_x = global i32 1
int align0_x = __alignof(((struct s0*) 0)->x);
-// We are currently incompatible with GCC here. <rdar://problem/9217290>
//
-// CHECK-XFAIL: @align1_x = global i32 1
-// CHECK: @align1_x = global i32 4
+// CHECK: @align1_x = global i32 1
int align1_x = __alignof(((struct s1*) 0)->x);
// CHECK: @align2_x = global i32 1
int align2_x = __alignof(((struct s2*) 0)->x);
@@ -66,22 +64,22 @@ int f0_b(struct s0 *a) {
return *(a->x + 1);
}
+// Note that we are incompatible with GCC on this example.
+//
// CHECK: define i32 @f1_a
-// CHECK: load i32* %{{.*}}, align 4
+// CHECK: load i32* %{{.*}}, align 1
// CHECK: }
// CHECK: define i32 @f1_b
// CHECK: load i32* %{{.*}}, align 4
// CHECK: }
-// Note that we are incompatible with GCC on these two examples.
+// Note that we are incompatible with GCC on this example.
//
// CHECK: define i32 @f1_c
-// CHECK-XFAIL: load i32* %{{.*}}, align 1
// CHECK: load i32* %{{.*}}, align 4
// CHECK: }
// CHECK: define i32 @f1_d
-// CHECK-XFAIL: load i32* %{{.*}}, align 1
-// CHECK: load i32* %{{.*}}, align 4
+// CHECK: load i32* %{{.*}}, align 1
// CHECK: }
int f1_a(struct s1 *a) {
return a->x[1];
diff --git a/test/CodeGen/packed-structure.c b/test/CodeGen/packed-structure.c
index 731a50b..3aeaa23 100644
--- a/test/CodeGen/packed-structure.c
+++ b/test/CodeGen/packed-structure.c
@@ -10,8 +10,7 @@ struct s0 {
// CHECK-GLOBAL: @s0_align_x = global i32 4
-// FIXME: This should be 1 to match gcc. PR7951.
-// CHECK-GLOBAL: @s0_align_y = global i32 4
+// CHECK-GLOBAL: @s0_align_y = global i32 1
// CHECK-GLOBAL: @s0_align = global i32 4
int s0_align_x = __alignof(((struct s0*)0)->x);
@@ -27,7 +26,7 @@ int s0_load_x(struct s0 *a) { return a->x; }
// with align 1 (in 2363.1 at least).
//
// CHECK-FUNCTIONS: define i32 @s0_load_y
-// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 4
+// CHECK-FUNCTIONS: [[s0_load_y:%.*]] = load i32* {{.*}}, align 1
// CHECK-FUNCTIONS: ret i32 [[s0_load_y]]
int s0_load_y(struct s0 *a) { return a->y; }
// CHECK-FUNCTIONS: define void @s0_copy
@@ -92,11 +91,11 @@ struct __attribute__((packed, aligned)) s3 {
short aShort;
int anInt;
};
-// CHECK-GLOBAL: @s3_1 = global i32 2
+// CHECK-GLOBAL: @s3_1 = global i32 1
int s3_1 = __alignof(((struct s3*) 0)->anInt);
// CHECK-FUNCTIONS: define i32 @test3(
int test3(struct s3 *ptr) {
// CHECK-FUNCTIONS: [[PTR:%.*]] = getelementptr inbounds {{%.*}}* {{%.*}}, i32 0, i32 1
- // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 2
+ // CHECK-FUNCTIONS-NEXT: load i32* [[PTR]], align 1
return ptr->anInt;
}
diff --git a/test/CodeGen/palignr.c b/test/CodeGen/palignr.c
index ed86c9e..1712df5 100644
--- a/test/CodeGen/palignr.c
+++ b/test/CodeGen/palignr.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple=i686-apple-darwin -target-feature +ssse3 -O1 -S -o - | FileCheck %s
#define _mm_alignr_epi8(a, b, n) (__builtin_ia32_palignr128((a), (b), (n)))
diff --git a/test/CodeGen/string-literal-short-wstring.c b/test/CodeGen/string-literal-short-wstring.c
index 8c2e412..ce29904 100644
--- a/test/CodeGen/string-literal-short-wstring.c
+++ b/test/CodeGen/string-literal-short-wstring.c
@@ -3,7 +3,7 @@
int main() {
// This should convert to utf8.
- // CHECK: internal constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+ // CHECK: internal 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"
diff --git a/test/CodeGen/string-literal.c b/test/CodeGen/string-literal.c
index 6d02b0f..cc6c094 100644
--- a/test/CodeGen/string-literal.c
+++ b/test/CodeGen/string-literal.c
@@ -1,16 +1,16 @@
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
int main() {
- // CHECK: internal constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
+ // CHECK: internal unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
char a[10] = "abc";
// This should convert to utf8.
- // CHECK: internal constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+ // CHECK: internal 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 [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00"
+ // CHECK: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 1
void *foo = L"AB";
- // CHECK: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00"
+ // CHECK: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1
void *bar = L"\u1234\U0010F00B";
}
diff --git a/test/CodeGen/struct-passing.c b/test/CodeGen/struct-passing.c
index 3e173be..8e5c0ad 100644
--- a/test/CodeGen/struct-passing.c
+++ b/test/CodeGen/struct-passing.c
@@ -20,5 +20,5 @@ void *ps[] = { f0, f1, f2, f3, f4, f5 };
// CHECK: declare i32 @f1() readonly
// CHECK: declare void @f2({{.*}} sret)
// CHECK: declare void @f3({{.*}} sret)
-// CHECK: declare void @f4({{.*}} byval)
-// CHECK: declare void @f5({{.*}} byval)
+// CHECK: declare void @f4({{.*}} byval align 4)
+// CHECK: declare void @f5({{.*}} byval align 4)
diff --git a/test/CodeGen/transparent-union.c b/test/CodeGen/transparent-union.c
index 97a7318..afdb3d6 100644
--- a/test/CodeGen/transparent-union.c
+++ b/test/CodeGen/transparent-union.c
@@ -11,7 +11,7 @@ typedef union {
void f0(transp_t0 obj);
// CHECK: define void @f1_0(i32* %a0)
-// CHECK: call void @f0(%union.transp_t0* byval %{{.*}})
+// CHECK: call void @f0(%union.transp_t0* byval align 4 %{{.*}})
// CHECK: call void %{{.*}}(i8* %{{[a-z0-9]*}})
// CHECK: }
void f1_0(int *a0) {
diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c
index cf89de3..f7e2a53 100644
--- a/test/CodeGen/x86_32-arguments-darwin.c
+++ b/test/CodeGen/x86_32-arguments-darwin.c
@@ -53,7 +53,7 @@ void f8_2(struct s8 a0) {}
// FIXME: llvm-gcc expands this, this may have some value for the
// backend in terms of optimization but doesn't change the ABI.
-// CHECK: define void @f9_2(%struct.s9* byval %a0)
+// CHECK: define void @f9_2(%struct.s9* byval align 4 %a0)
struct s9 {
int a : 17;
int b;
@@ -229,7 +229,7 @@ typedef int v4i32 __attribute__((__vector_size__(16)));
v4i32 f55(v4i32 arg) { return arg+arg; }
// CHECK: define void @f56(
-// CHECK: i8 signext %a0, %struct.s56_0* byval %a1,
+// CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
// CHECK: i64 %a4.coerce, %struct.s56_2* byval align 4,
// CHECK: <4 x i32> %a6, %struct.s39* byval align 16 %a7,
@@ -238,7 +238,7 @@ v4i32 f55(v4i32 arg) { return arg+arg; }
// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
// CHECK: call void (i32, ...)* @f56_0(i32 1,
-// CHECK: i32 %{{[^ ]*}}, %struct.s56_0* byval %{{[^ ]*}},
+// CHECK: i32 %{{[^ ]*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
// CHECK: i64 %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s39* byval align 16 %{{[^ ]*}},
diff --git a/test/CodeGen/x86_32-arguments-linux.c b/test/CodeGen/x86_32-arguments-linux.c
index 230a20d..2f246f8 100644
--- a/test/CodeGen/x86_32-arguments-linux.c
+++ b/test/CodeGen/x86_32-arguments-linux.c
@@ -2,7 +2,7 @@
// RUN: FileCheck < %t %s
// CHECK: define void @f56(
-// CHECK: i8 signext %a0, %struct.s56_0* byval %a1,
+// CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
// CHECK: x86_mmx %a2.coerce, %struct.s56_1* byval align 4,
// CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
@@ -11,7 +11,7 @@
// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
// CHECK: call void (i32, ...)* @f56_0(i32 1,
-// CHECK: i32 %{{.*}}, %struct.s56_0* byval %{{[^ ]*}},
+// CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
// CHECK: x86_mmx %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c
index ebde884..75c4788 100644
--- a/test/CodeGen/x86_64-arguments.c
+++ b/test/CodeGen/x86_64-arguments.c
@@ -69,7 +69,7 @@ void f12_1(struct s12 a0) {}
// Check that sret parameter is accounted for when checking available integer
// registers.
-// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval %e, i32 %f)
+// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval align 8 %e, i32 %f)
struct s13_0 { long long f0[3]; };
struct s13_1 { long long f0[2]; };
diff --git a/test/CodeGenCXX/PR5050-constructor-conversion.cpp b/test/CodeGenCXX/PR5050-constructor-conversion.cpp
index aa75ea4..9b993f2 100644
--- a/test/CodeGenCXX/PR5050-constructor-conversion.cpp
+++ b/test/CodeGenCXX/PR5050-constructor-conversion.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/abstract-class-ctors-dtors.cpp b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp
new file mode 100644
index 0000000..e1c1a75
--- /dev/null
+++ b/test/CodeGenCXX/abstract-class-ctors-dtors.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// Check that we dont emit the complete constructor/destructor for this class.
+struct A {
+ virtual void f() = 0;
+ A();
+ ~A();
+};
+
+// CHECK-NOT: define void @_ZN1AC1Ev
+// CHECK: define void @_ZN1AC2Ev
+// CHECK-NOT: define void @_ZN1AD1Ev
+// CHECK: define void @_ZN1AD2Ev
+A::A() { }
+
+A::~A() { }
diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp
index 8d74d00..dcb27ce 100644
--- a/test/CodeGenCXX/arm.cpp
+++ b/test/CodeGenCXX/arm.cpp
@@ -136,8 +136,8 @@ namespace test3 {
void d(int n) {
// CHECK: define void @_ZN5test31dEi(
// CHECK: [[N:%.*]] = load i32*
- // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
// CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80)
+ // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
// CHECK: [[SZ:%.*]] = select
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
@@ -208,8 +208,8 @@ namespace test4 {
void d(int n) {
// CHECK: define void @_ZN5test41dEi(
// CHECK: [[N:%.*]] = load i32*
- // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
// CHECK: @llvm.umul.with.overflow.i32(i32 [[N]], i32 80)
+ // CHECK: [[NE:%.*]] = mul i32 [[N]], 20
// CHECK: @llvm.uadd.with.overflow.i32(i32 {{.*}}, i32 8)
// CHECK: [[SZ:%.*]] = select
// CHECK: call noalias i8* @_Znam(i32 [[SZ]])
@@ -310,7 +310,7 @@ namespace test7 {
// CHECK: call i8* @llvm.eh.exception()
// CHECK: call void @__cxa_guard_abort(i32* @_ZGVZN5test74testEvE1x)
- // CHECK: call void @_Unwind_Resume_or_Rethrow
+ // CHECK: call void @llvm.eh.resume(
}
}
@@ -349,7 +349,7 @@ namespace test8 {
// CHECK: call i8* @llvm.eh.exception()
// CHECK: call void @__cxa_guard_abort(i32* @_ZGVZN5test84testEvE1x)
- // CHECK: call void @_Unwind_Resume_or_Rethrow
+ // CHECK: call void @llvm.eh.resume(
}
}
diff --git a/test/CodeGenCXX/array-construction.cpp b/test/CodeGenCXX/array-construction.cpp
index d044ac5..5efe183 100644
--- a/test/CodeGenCXX/array-construction.cpp
+++ b/test/CodeGenCXX/array-construction.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/array-operator-delete-call.cpp b/test/CodeGenCXX/array-operator-delete-call.cpp
index ad60cf6..41b0118 100644
--- a/test/CodeGenCXX/array-operator-delete-call.cpp
+++ b/test/CodeGenCXX/array-operator-delete-call.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/call-arg-zero-temp.cpp b/test/CodeGenCXX/call-arg-zero-temp.cpp
index 88e7452..101e81f 100644
--- a/test/CodeGenCXX/call-arg-zero-temp.cpp
+++ b/test/CodeGenCXX/call-arg-zero-temp.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/cast-conversion.cpp b/test/CodeGenCXX/cast-conversion.cpp
index 27e34b9..b7a9740 100644
--- a/test/CodeGenCXX/cast-conversion.cpp
+++ b/test/CodeGenCXX/cast-conversion.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/constructor-conversion.cpp b/test/CodeGenCXX/constructor-conversion.cpp
index 405bba6..58d0d39 100644
--- a/test/CodeGenCXX/constructor-conversion.cpp
+++ b/test/CodeGenCXX/constructor-conversion.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/constructor-default-arg.cpp b/test/CodeGenCXX/constructor-default-arg.cpp
index 0c08c76..dc0ab50 100644
--- a/test/CodeGenCXX/constructor-default-arg.cpp
+++ b/test/CodeGenCXX/constructor-default-arg.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/constructor-for-array-members.cpp b/test/CodeGenCXX/constructor-for-array-members.cpp
index fd6dc6d..ef5900e 100644
--- a/test/CodeGenCXX/constructor-for-array-members.cpp
+++ b/test/CodeGenCXX/constructor-for-array-members.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/constructor-template.cpp b/test/CodeGenCXX/constructor-template.cpp
index a3f38a6..7472d7e 100644
--- a/test/CodeGenCXX/constructor-template.cpp
+++ b/test/CodeGenCXX/constructor-template.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/convert-to-fptr.cpp b/test/CodeGenCXX/convert-to-fptr.cpp
index f895dbc..c1c9f63 100644
--- a/test/CodeGenCXX/convert-to-fptr.cpp
+++ b/test/CodeGenCXX/convert-to-fptr.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/copy-assign-synthesis-1.cpp b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
index eb761c2..17abeb9 100644
--- a/test/CodeGenCXX/copy-assign-synthesis-1.cpp
+++ b/test/CodeGenCXX/copy-assign-synthesis-1.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/cxx0x-defaulted-templates.cpp b/test/CodeGenCXX/cxx0x-defaulted-templates.cpp
new file mode 100644
index 0000000..3d4000e
--- /dev/null
+++ b/test/CodeGenCXX/cxx0x-defaulted-templates.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++0x -emit-llvm -o - %s | FileCheck %s
+
+template <typename T>
+struct X {
+ X();
+};
+
+// CHECK: define void @_ZN1XIbEC1Ev
+// CHECK: define void @_ZN1XIbEC2Ev
+template <> X<bool>::X() = default;
+
+// CHECK: define weak_odr void @_ZN1XIiEC1Ev
+// CHECK: define weak_odr void @_ZN1XIiEC2Ev
+template <typename T> X<T>::X() = default;
+template X<int>::X();
+
+// CHECK: define linkonce_odr void @_ZN1XIcEC1Ev
+// CHECK: define linkonce_odr void @_ZN1XIcEC2Ev
+X<char> x;
diff --git a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
index 5b432c7..15c8e7f 100644
--- a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
+++ b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
@@ -2,10 +2,10 @@
struct non_trivial {
non_trivial();
- ~non_trivial();
+ ~non_trivial() noexcept(false);
};
non_trivial::non_trivial() {}
-non_trivial::~non_trivial() {}
+non_trivial::~non_trivial() noexcept(false) {}
// We use a virtual base to ensure that the constructor
// delegation optimization (complete->base) can't be
@@ -22,27 +22,35 @@ delegator::delegator() {
throw 0;
}
-// CHECK: define void @_ZN9delegatorC1Ei
-// CHECK: call void @_ZN9delegatorC1Ev
-// CHECK-NOT: lpad
-// CHECK: ret
-// CHECK-NOT: lpad
-// CHECK: define void @_ZN9delegatorC2Ei
-// CHECK: call void @_ZN9delegatorC2Ev
-// CHECK-NOT: lpad
-// CHECK: ret
-// CHECK-NOT: lpad
-delegator::delegator(int)
- : delegator()
-{}
delegator::delegator(bool)
{}
+// CHECK: define void @_ZN9delegatorC1Ec
+// CHECK: void @_ZN9delegatorC1Eb
+// CHECK: void @__cxa_throw
+// CHECK: void @_ZSt9terminatev
+// CHECK: void @_ZN9delegatorD1Ev
// CHECK: define void @_ZN9delegatorC2Ec
-// CHECK: call void @_ZN9delegatorC2Eb
-// CHECK: call void @__cxa_throw
+// CHECK: void @_ZN9delegatorC2Eb
+// CHECK: void @__cxa_throw
+// CHECK: void @_ZSt9terminatev
+// CHECK: void @_ZN9delegatorD2Ev
delegator::delegator(char)
: delegator(true) {
throw 0;
}
+
+// CHECK: define void @_ZN9delegatorC1Ei
+// CHECK: void @_ZN9delegatorC1Ev
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: ret
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: define void @_ZN9delegatorC2Ei
+// CHECK: void @_ZN9delegatorC2Ev
+// CHECK-NOT: void @_ZSt9terminatev
+// CHECK: ret
+// CHECK-NOT: void @_ZSt9terminatev
+delegator::delegator(int)
+ : delegator()
+{}
diff --git a/test/CodeGenCXX/debug-info-pubtypes.cpp b/test/CodeGenCXX/debug-info-pubtypes.cpp
new file mode 100644
index 0000000..35ba90b
--- /dev/null
+++ b/test/CodeGenCXX/debug-info-pubtypes.cpp
@@ -0,0 +1,15 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -S %s -o %t
+// RUN: FileCheck %s < %t
+
+//CHECK: .asciz "G"
+//CHECK-NEXT: .long 0
+//CHECK-NEXT: Lpubtypes_end1:
+
+class G {
+public:
+ void foo();
+};
+
+void G::foo() {
+}
diff --git a/test/CodeGenCXX/decl-ref-init.cpp b/test/CodeGenCXX/decl-ref-init.cpp
index 58fdeda..a066fbb 100644
--- a/test/CodeGenCXX/decl-ref-init.cpp
+++ b/test/CodeGenCXX/decl-ref-init.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/default-constructor-for-members.cpp b/test/CodeGenCXX/default-constructor-for-members.cpp
index a97764d..714811f 100644
--- a/test/CodeGenCXX/default-constructor-for-members.cpp
+++ b/test/CodeGenCXX/default-constructor-for-members.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp
index 006f264..c47c831 100644
--- a/test/CodeGenCXX/derived-to-base-conv.cpp
+++ b/test/CodeGenCXX/derived-to-base-conv.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp
index 353b610..94d8833 100644
--- a/test/CodeGenCXX/destructors.cpp
+++ b/test/CodeGenCXX/destructors.cpp
@@ -334,7 +334,7 @@ namespace test7 {
// CHECK: ret void
// CHECK: call i8* @llvm.eh.exception(
// CHECK: call void @_ZdlPv({{.*}}) nounwind
- // CHECK: call void @_Unwind_Resume_or_Rethrow
+ // CHECK: call void @llvm.eh.resume(
// Checked at top of file:
// @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
@@ -364,7 +364,7 @@ namespace test7 {
// CHECK: ret void
// CHECK: call i8* @llvm.eh.exception()
// CHECK: call void @_ZdlPv({{.*}}) nounwind
- // CHECK: call void @_Unwind_Resume_or_Rethrow(
+ // CHECK: call void @llvm.eh.resume(
// CHECK: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
// CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp
index 6c44c76..44219b4 100644
--- a/test/CodeGenCXX/eh.cpp
+++ b/test/CodeGenCXX/eh.cpp
@@ -30,7 +30,8 @@ void test2() {
}
// CHECK: define void @_Z5test2v()
-// CHECK: [[EXNSLOTVAR:%.*]] = alloca i8*
+// CHECK: [[EXNVAR:%.*]] = alloca i8*
+// CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32
// CHECK-NEXT: [[CLEANUPDESTVAR:%.*]] = alloca i32
// CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16)
// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
@@ -104,6 +105,7 @@ namespace test7 {
// CHECK: define i32 @_ZN5test73fooEv()
int foo() {
// CHECK: [[CAUGHTEXNVAR:%.*]] = alloca i8*
+// CHECK-NEXT: [[SELECTORVAR:%.*]] = alloca i32
// CHECK-NEXT: [[INTCATCHVAR:%.*]] = alloca i32
// CHECK-NEXT: [[EHCLEANUPDESTVAR:%.*]] = alloca i32
try {
@@ -117,7 +119,8 @@ namespace test7 {
// CHECK: [[CAUGHTEXN:%.*]] = call i8* @llvm.eh.exception()
// CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]]
-// CHECK-NEXT: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* [[CAUGHTEXN]], i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null)
+// CHECK-NEXT: [[SELECTOR:%.*]] = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* [[CAUGHTEXN]], i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null)
+// CHECK-NEXT: store i32 [[SELECTOR]], i32* [[SELECTORVAR]]
// CHECK-NEXT: call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
// CHECK-NEXT: icmp eq
// CHECK-NEXT: br i1
@@ -130,7 +133,8 @@ namespace test7 {
}
// CHECK: [[CAUGHTEXN:%.*]] = call i8* @llvm.eh.exception()
// CHECK-NEXT: store i8* [[CAUGHTEXN]], i8** [[CAUGHTEXNVAR]]
-// CHECK-NEXT: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* [[CAUGHTEXN]], i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null)
+// CHECK-NEXT: [[SELECTOR:%.*]] = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* [[CAUGHTEXN]], i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null)
+// CHECK-NEXT: store i32 [[SELECTOR]], i32* [[SELECTORVAR]]
// CHECK-NEXT: store i32 1, i32* [[EHCLEANUPDESTVAR]]
// CHECK-NEXT: call void @__cxa_end_catch()
// CHECK-NEXT: br label
@@ -159,7 +163,7 @@ namespace test8 {
// CHECK-NEXT: bitcast
// CHECK-NEXT: invoke void @_ZN5test81AC1ERKS0_(
// CHECK: call i8* @__cxa_begin_catch
- // CHECK-NEXT: invoke void @_ZN5test81AD1Ev(
+ // CHECK-NEXT: call void @_ZN5test81AD1Ev(
// CHECK: call void @__cxa_end_catch()
// CHECK: ret void
}
@@ -190,7 +194,7 @@ namespace test9 {
// landing pad from first call to invoke
// CHECK: call i8* @llvm.eh.exception
- // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* {{.*}}, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*), i8* null)
+ // CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* {{.*}}, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* bitcast (i8** @_ZTIi to i8*))
}
// __cxa_end_catch can throw for some kinds of caught exceptions.
@@ -255,6 +259,7 @@ namespace test11 {
void bar() {
try {
// CHECK: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
// CHECK-NEXT: [[P:%.*]] = alloca [[A:%.*]]**,
// CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]*
// CHECK-NEXT: invoke void @_ZN6test116opaqueEv()
@@ -272,7 +277,7 @@ namespace test11 {
// PR7686
namespace test12 {
- struct A { ~A(); };
+ struct A { ~A() noexcept(false); };
bool opaque(const A&);
// CHECK: define void @_ZN6test124testEv()
@@ -392,8 +397,8 @@ namespace test15 {
}
namespace test16 {
- struct A { A(); ~A(); };
- struct B { int x; B(const A &); ~B(); };
+ struct A { A(); ~A() noexcept(false); };
+ struct B { int x; B(const A &); ~B() noexcept(false); };
void foo();
bool cond();
@@ -403,6 +408,7 @@ namespace test16 {
// CHECK-NEXT: [[EXN_ACTIVE:%.*]] = alloca i1
// CHECK-NEXT: [[TEMP:%.*]] = alloca [[A:%.*]],
// CHECK-NEXT: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
// CHECK-NEXT: [[EHDEST:%.*]] = alloca i32
// CHECK-NEXT: [[TEMP_ACTIVE:%.*]] = alloca i1
diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp
index d9b8506..b32b90b 100644
--- a/test/CodeGenCXX/exceptions.cpp
+++ b/test/CodeGenCXX/exceptions.cpp
@@ -273,6 +273,7 @@ namespace test5 {
// CHECK: define void @_ZN5test54testEv()
// CHECK: [[EXNSLOT:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SELECTORSLOT:%.*]] = alloca i32
// CHECK-NEXT: [[A:%.*]] = alloca [[A_T:%.*]], align 1
// CHECK-NEXT: [[T:%.*]] = alloca [[T_T:%.*]], align 1
// CHECK-NEXT: alloca i32
@@ -324,6 +325,7 @@ namespace test7 {
// CHECK-NEXT: alloca [[A:%.*]],
// CHECK-NEXT: alloca i8*
// CHECK-NEXT: alloca i32
+ // CHECK-NEXT: alloca i32
// CHECK-NEXT: [[OUTER_A:%.*]] = alloca i1
// CHECK-NEXT: alloca i8*
// CHECK-NEXT: [[INNER_NEW:%.*]] = alloca i1
diff --git a/test/CodeGenCXX/global-array-destruction.cpp b/test/CodeGenCXX/global-array-destruction.cpp
index c77551c..bbe574d 100644
--- a/test/CodeGenCXX/global-array-destruction.cpp
+++ b/test/CodeGenCXX/global-array-destruction.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
diff --git a/test/CodeGenCXX/global-llvm-constant.cpp b/test/CodeGenCXX/global-llvm-constant.cpp
index ef1dcf0..2bd43b9 100644
--- a/test/CodeGenCXX/global-llvm-constant.cpp
+++ b/test/CodeGenCXX/global-llvm-constant.cpp
@@ -8,3 +8,25 @@ struct A {
const A x;
// CHECK: @_ZL1x = internal global
+
+struct X {
+ int (*fp)(int, int);
+};
+
+int add(int x, int y) { return x + y; }
+
+// CHECK: @x2 = constant
+extern const X x2;
+const X x2 = { &add };
+
+struct X1 {
+ mutable int i;
+};
+
+struct X2 {
+ X1 array[3];
+};
+
+// CHECK: @x2b = global
+extern const X2 x2b;
+const X2 x2b = { { { 1 }, { 2 }, { 3 } } };
diff --git a/test/CodeGenCXX/goto.cpp b/test/CodeGenCXX/goto.cpp
index 3286b22..9a12a91 100644
--- a/test/CodeGenCXX/goto.cpp
+++ b/test/CodeGenCXX/goto.cpp
@@ -12,6 +12,7 @@ namespace test0 {
// CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]],
// CHECK-NEXT: [[Z:%.*]] = alloca [[A]]
// CHECK-NEXT: [[EXN:%.*]] = alloca i8*
+ // CHECK-NEXT: [[SEL:%.*]] = alloca i32
// CHECK-NEXT: alloca i32
// CHECK-NEXT: [[V:%.*]] = alloca [[V:%.*]]*,
// CHECK-NEXT: [[TMP:%.*]] = alloca [[A]]
diff --git a/test/CodeGenCXX/instrument-functions.cpp b/test/CodeGenCXX/instrument-functions.cpp
new file mode 100644
index 0000000..253e096
--- /dev/null
+++ b/test/CodeGenCXX/instrument-functions.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s -finstrument-functions | FileCheck %s
+
+// CHECK: @_Z5test1i
+int test1(int x) {
+// CHECK: __cyg_profile_func_enter
+// CHECK: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
+
+// CHECK: @_Z5test2i
+int test2(int) __attribute__((no_instrument_function));
+int test2(int x) {
+// CHECK-NOT: __cyg_profile_func_enter
+// CHECK-NOT: __cyg_profile_func_exit
+// CHECK: ret
+ return x;
+}
+
+// This test case previously crashed code generation. It exists solely
+// to test -finstrument-function does not crash codegen for this trivial
+// case.
+namespace rdar9445102 {
+ class Rdar9445102 {
+ public:
+ Rdar9445102();
+ };
+}
+static rdar9445102::Rdar9445102 s_rdar9445102Initializer;
+
diff --git a/test/CodeGenCXX/internal-linkage.cpp b/test/CodeGenCXX/internal-linkage.cpp
index 39bce85..56cb810 100644
--- a/test/CodeGenCXX/internal-linkage.cpp
+++ b/test/CodeGenCXX/internal-linkage.cpp
@@ -54,3 +54,11 @@ char const * *test4()
// CHECK: @extern_nonconst_xyzzy = global
return &extern_nonconst_xyzzy;
}
+
+// PR10120
+template <typename T> class klass {
+ virtual void f();
+};
+namespace { struct S; }
+void foo () { klass<S> x; }
+// CHECK: @_ZTV5klassIN12_GLOBAL__N_11SEE = internal unnamed_addr constant
diff --git a/test/CodeGenCXX/mangle-alias-template.cpp b/test/CodeGenCXX/mangle-alias-template.cpp
new file mode 100644
index 0000000..2020a0a
--- /dev/null
+++ b/test/CodeGenCXX/mangle-alias-template.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++0x -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+template<typename T> struct alloc {};
+template<typename T> using Alloc = alloc<T>;
+template<typename T, typename A = Alloc<T>> struct vector {};
+
+template<typename T> using Vec = vector<T>;
+
+template<typename T> void f(Vec<T> v);
+template<typename T> void g(T);
+
+template<template<typename> class F> void h(F<int>);
+
+// CHECK: define void @_Z1zv(
+void z() {
+ vector<int> VI;
+ f(VI);
+ // CHECK: call void @_Z1fIiEv6vectorIT_5allocIS1_EE(
+
+ Vec<double> VD;
+ g(VD);
+ // CHECK: call void @_Z1gI6vectorId5allocIdEEEvT_(
+
+ h<Vec>(VI);
+ // CHECK: call void @_Z1hI3VecEvT_IiE(
+
+ Alloc<int> AC;
+ h(AC);
+ // CHECK: call void @_Z1hI5allocEvT_IiE(
+
+ h<Alloc>(AC);
+ // CHECK: call void @_Z1hI5AllocEvT_IiE(
+
+ Vec<char> VC;
+ g<Vec<char>>(VC);
+ // CHECK: call void @_Z1gI6vectorIc5allocIcEEEvT_(
+
+ Vec<Vec<int>> VVI;
+ g(VVI);
+ // CHECK: call void @_Z1gI6vectorIS0_Ii5allocIiEES1_IS3_EEEvT_(
+}
diff --git a/test/CodeGenCXX/mangle-exprs.cpp b/test/CodeGenCXX/mangle-exprs.cpp
index 46c46f0..75294e0 100644
--- a/test/CodeGenCXX/mangle-exprs.cpp
+++ b/test/CodeGenCXX/mangle-exprs.cpp
@@ -109,3 +109,19 @@ namespace test2 {
// CHECK: store float {{.*}}, float* @_ZZN5test21gIPFfvEEEvT_DTclfL0p_EEE8variable,
}
+
+namespace test3 {
+ template <class T, class U> void a(T x, U y, decltype(x.*y) z) {}
+
+ struct X {
+ int *member;
+ };
+
+ // CHECK: define void @_ZN5test311instantiateEv
+ void instantiate() {
+ X x;
+ int *ip;
+ // CHECK: call void @_ZN5test31aINS_1XEMS1_PiEEvT_T0_DTdsfL0p_fL0p0_E
+ a(x, &X::member, ip);
+ }
+}
diff --git a/test/CodeGenCXX/mangle-subst-std.cpp b/test/CodeGenCXX/mangle-subst-std.cpp
index fea3582..837d4fa 100644
--- a/test/CodeGenCXX/mangle-subst-std.cpp
+++ b/test/CodeGenCXX/mangle-subst-std.cpp
@@ -11,6 +11,7 @@
// CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant
// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant
// CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant
+
namespace std {
struct A { A(); };
diff --git a/test/CodeGenCXX/mangle-unnameable-conversions.cpp b/test/CodeGenCXX/mangle-unnameable-conversions.cpp
new file mode 100644
index 0000000..2132eff
--- /dev/null
+++ b/test/CodeGenCXX/mangle-unnameable-conversions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++0x -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+
+template<typename T> using id = T;
+struct S {
+ template<typename T, int N>
+ operator id<T[N]>&();
+ template<typename T, typename U>
+ operator id<T (U::*)()>() const;
+};
+
+void f() {
+ int (&a)[42] = S(); // CHECK: @_ZN1ScvRAT0__T_IiLi42EEEv(
+ char (S::*fp)() = S(); // CHECK: @_ZNK1ScvMT0_FT_vEIcS_EEv(
+};
diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp
index 27777a5..01dcf8b 100644
--- a/test/CodeGenCXX/mangle.cpp
+++ b/test/CodeGenCXX/mangle.cpp
@@ -397,16 +397,16 @@ namespace test3 {
struct Path2 : AmbiguousBase { double p; };
struct Derived : Path1, Path2 { };
- // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_1INS_7DerivedEEEDtptcvPT_Li0EsrNS_5Path1E2abERS2_(
+ // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E2abERS2_(
template <class T> decltype(((T*) 0)->Path1::ab) get_ab_1(T &ref) { return ref.Path1::ab; }
- // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_2INS_7DerivedEEEDtptcvPT_Li0EsrNS_5Path2E2abERS2_(
+ // CHECK: define linkonce_odr i32 @_ZN5test38get_ab_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E2abERS2_(
template <class T> decltype(((T*) 0)->Path2::ab) get_ab_2(T &ref) { return ref.Path2::ab; }
- // CHECK: define linkonce_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0EsrNS_5Path1E1pERS2_(
+ // CHECK: define linkonce_odr float @_ZN5test37get_p_1INS_7DerivedEEEDtptcvPT_Li0Esr5Path1E1pERS2_(
template <class T> decltype(((T*) 0)->Path1::p) get_p_1(T &ref) { return ref.Path1::p; }
- // CHECK: define linkonce_odr double @_ZN5test37get_p_2INS_7DerivedEEEDtptcvPT_Li0EsrNS_5Path2E1pERS2_(
+ // CHECK: define linkonce_odr double @_ZN5test37get_p_2INS_7DerivedEEEDtptcvPT_Li0Esr5Path2E1pERS2_(
template <class T> decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; }
Derived obj;
@@ -676,3 +676,38 @@ namespace test25 {
A<foo>::call();
}
}
+
+namespace test26 {
+ template <template <class> class T> void foo(decltype(T<float>::object) &object) {}
+
+ template <class T> struct holder { static T object; };
+
+ void test() {
+ float f;
+
+ // CHECK: call void @_ZN6test263fooINS_6holderEEEvRDtsrT_IfE6objectE(
+ foo<holder>(f);
+ }
+}
+
+namespace test27 {
+ struct A {
+ struct inner {
+ float object;
+ };
+
+ float meth();
+ };
+ typedef A Alias;
+
+ template <class T> void a(decltype(T::inner::object) &object) {}
+ template <class T> void b(decltype(T().Alias::meth()) &object) {}
+
+ void test() {
+ float f;
+ // CHECK: call void @_ZN6test271aINS_1AEEEvRDtsrNT_5innerE6objectE(
+ a<A>(f);
+ // CHECK: call void @_ZN6test271bINS_1AEEEvRDTcldtcvT__Esr5AliasE4methEE(
+ b<A>(f);
+ }
+}
diff --git a/test/CodeGenCXX/member-init-ctor.cpp b/test/CodeGenCXX/member-init-ctor.cpp
new file mode 100644
index 0000000..d9a6734
--- /dev/null
+++ b/test/CodeGenCXX/member-init-ctor.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++0x -emit-llvm -o - | FileCheck %s
+
+bool b();
+struct S {
+ int n = b() ? S().n + 1 : 0;
+};
+
+S s;
+
+// CHECK: define{{.*}} void @_ZN1SC2Ev(
+// CHECK-NOT }
+// CHECK: call {{.*}} @_Z1bv()
+// CHECK-NOT }
+// CHECK: call {{.*}} @_ZN1SC1Ev(
diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp
index 10a6f7f..d14a5e2 100644
--- a/test/CodeGenCXX/new.cpp
+++ b/test/CodeGenCXX/new.cpp
@@ -1,12 +1,16 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | FileCheck %s
-#include <stddef.h>
+
+typedef __typeof__(sizeof(0)) size_t;
void t1() {
int* a = new int;
}
-// Placement.
-void* operator new(size_t, void*) throw();
+// Declare the reserved placement operators.
+void *operator new(size_t, void*) throw();
+void operator delete(void*, void*) throw();
+void *operator new[](size_t, void*) throw();
+void operator delete[](void*, void*) throw();
void t2(int* a) {
int* b = new (a) int;
@@ -163,3 +167,45 @@ void f() {
delete new bool;
// CHECK: ret void
}
+
+namespace test15 {
+ struct A { A(); ~A(); };
+
+ // CHECK: define void @_ZN6test155test0EPv(
+ // CHECK: [[P:%.*]] = load i8*
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[T0:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[T0]])
+ void test0(void *p) {
+ new (p) A();
+ }
+
+ // CHECK: define void @_ZN6test155test1EPv(
+ // CHECK: [[P:%.*]] = load i8*
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[T0:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK: [[T1:%.*]] = getelementptr inbounds [[A]]* [[T0]],
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[T1]])
+ void test1(void *p) {
+ new (p) A[5];
+ }
+
+ // TODO: it's okay if all these size calculations get dropped.
+ // FIXME: maybe we should try to throw on overflow?
+ // CHECK: define void @_ZN6test155test2EPvi(
+ // CHECK: [[N:%.*]] = load i32*
+ // CHECK-NEXT: [[T0:%.*]] = sext i32 [[N]] to i64
+ // CHECK-NEXT: [[T1:%.*]] = icmp slt i64 [[T0]], 0
+ // CHECK-NEXT: [[T2:%.*]] = select i1 [[T1]], i64 -1, i64 [[T0]]
+ // CHECK-NEXT: [[P:%.*]] = load i8*
+ // CHECK-NEXT: icmp eq i8* [[P]], null
+ // CHECK-NEXT: br i1
+ // CHECK: [[T0:%.*]] = bitcast i8* [[P]] to [[A:%.*]]*
+ // CHECK: [[T1:%.*]] = getelementptr inbounds [[A]]* [[T0]],
+ // CHECK-NEXT: call void @_ZN6test151AC1Ev([[A]]* [[T1]])
+ void test2(void *p, int n) {
+ new (p) A[n];
+ }
+}
diff --git a/test/CodeGenCXX/nrvo.cpp b/test/CodeGenCXX/nrvo.cpp
index ad6fa4f..82caff8 100644
--- a/test/CodeGenCXX/nrvo.cpp
+++ b/test/CodeGenCXX/nrvo.cpp
@@ -95,7 +95,7 @@ X test2(bool B) {
// %invoke.cont17: rethrow block for %eh.cleanup.
// This really should be elsewhere in the function.
- // CHECK-EH: call void @_Unwind_Resume_or_Rethrow
+ // CHECK-EH: call void @llvm.eh.resume(
// CHECK-EH-NEXT: unreachable
// %terminate.lpad: terminate landing pad.
diff --git a/test/CodeGenCXX/pr9965.cpp b/test/CodeGenCXX/pr9965.cpp
new file mode 100644
index 0000000..b87fcf4
--- /dev/null
+++ b/test/CodeGenCXX/pr9965.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++0x -emit-llvm -o - %s | FileCheck %s
+template<typename T>
+struct X
+{
+ X() = default;
+};
+
+X<int> x;
+// CHECK: define internal void @__cxx_global_var_init()
+// CHECK: call void @_ZN1XIiEC1Ev
+// CHECK: define linkonce_odr void @_ZN1XIiEC1Ev
+// CHECK: define linkonce_odr void @_ZN1XIiEC2Ev
diff --git a/test/CodeGenCXX/ptr-to-member-function.cpp b/test/CodeGenCXX/ptr-to-member-function.cpp
index 89db142..d012fb9 100644
--- a/test/CodeGenCXX/ptr-to-member-function.cpp
+++ b/test/CodeGenCXX/ptr-to-member-function.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s
diff --git a/test/CodeGenCXX/scoped-enums.cpp b/test/CodeGenCXX/scoped-enums.cpp
new file mode 100644
index 0000000..d40ab36
--- /dev/null
+++ b/test/CodeGenCXX/scoped-enums.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -std=c++0x -emit-llvm -o - %s
+
+// PR9923
+enum class Color { red, blue, green };
+
+void f(Color);
+void g() {
+ f(Color::red);
+}
diff --git a/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp b/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
new file mode 100644
index 0000000..84697be
--- /dev/null
+++ b/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
@@ -0,0 +1,200 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+
+// See Test9 for test description.
+// CHECK: @_ZTTN5Test91BE = linkonce_odr unnamed_addr constant
+namespace Test1 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial.
+struct A {
+ virtual void f();
+ ~A();
+};
+
+// CHECK: define void @_ZN5Test11AD2Ev
+// CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test11AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test2 {
+
+// Check that we do initialize the vtable pointer in A::~A() since the destructor body isn't trivial.
+struct A {
+ virtual void f();
+ ~A();
+};
+
+// CHECK: define void @_ZN5Test21AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test21AE, i64 0, i64 2), i8***
+A::~A() {
+ f();
+}
+
+}
+
+namespace Test3 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial
+// and Field's destructor body is also trivial.
+struct Field {
+ ~Field() { }
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test31AD2Ev
+// CHECK-NOT: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test31AE, i64 0, i64 2), i8***
+A::~A() {
+
+}
+
+}
+
+namespace Test4 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field's destructor body
+// isn't trivial.
+
+void f();
+
+struct Field {
+ ~Field() { f(); }
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test41AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test41AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test5 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field's destructor isn't
+// available in this translation unit.
+
+struct Field {
+ ~Field();
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test51AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test51AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test6 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a member
+// variable with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field {
+ NonTrivialDestructorBody nonTrivialDestructorBody;
+};
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test61AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test61AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test7 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a base
+// class with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field : NonTrivialDestructorBody { };
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test71AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test71AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test8 {
+
+// Check that we do initialize the vtable pointer in A::~A(), since Field has a virtual base
+// class with a non-trivial destructor body.
+
+struct NonTrivialDestructorBody {
+ ~NonTrivialDestructorBody();
+};
+
+struct Field : virtual NonTrivialDestructorBody { };
+
+struct A {
+ virtual void f();
+ ~A();
+
+ Field field;
+};
+
+// CHECK: define void @_ZN5Test81AD2Ev
+// CHECK: store i8** getelementptr inbounds ([3 x i8*]* @_ZTVN5Test81AE, i64 0, i64 2), i8***
+A::~A()
+{
+}
+
+}
+
+namespace Test9 {
+
+// Check that we emit a VTT for B, even though we don't initialize the vtable pointer in the destructor.
+struct A { virtual ~A () { } };
+struct B : virtual A {};
+struct C : virtual B {
+ virtual ~C();
+};
+C::~C() {}
+
+}
diff --git a/test/CodeGenCXX/static-init-2.cpp b/test/CodeGenCXX/static-init-2.cpp
index 65ab3bb..768e6de 100644
--- a/test/CodeGenCXX/static-init-2.cpp
+++ b/test/CodeGenCXX/static-init-2.cpp
@@ -3,4 +3,4 @@
// Make sure we don't crash generating y; its value is constant, but the
// initializer has side effects, so EmitConstantExpr should fail.
int x();
-int y = x() && 0;
+int y = x() & 0;
diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp
index 635e1d2..cc30af0 100644
--- a/test/CodeGenCXX/template-instantiation.cpp
+++ b/test/CodeGenCXX/template-instantiation.cpp
@@ -1,9 +1,15 @@
// RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// CHECK: @_ZN7PR100011xE = global
+// CHECK-NOT: @_ZN7PR100014kBarE = external global i32
+//
// CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
// CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE
// CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = unnamed_addr constant
+// CHECK: @_ZN7PR100011SIiE3arrE = weak_odr global [3 x i32]
+// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = weak_odr global [3 x i32]A
+
// CHECK-NOT: _ZTVN5test31SIiEE
// CHECK-NOT: _ZTSN5test31SIiEE
@@ -122,3 +128,27 @@ class B {
// CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv
template class A<0>;
}
+
+// Ensure that when instantiating initializers for static data members to
+// complete their type in an unevaluated context, we *do* emit initializers with
+// side-effects, but *don't* emit initializers and variables which are otherwise
+// unused in the program.
+namespace PR10001 {
+ template <typename T> struct S {
+ static const int arr[];
+ static const int arr2[];
+ static const int x, y;
+ static int f();
+ };
+
+ extern int foo();
+ extern int kBar;
+
+ template <typename T> const int S<T>::arr[] = { 1, 2, foo() }; // possible side effects
+ template <typename T> const int S<T>::arr2[] = { 1, 2, kBar }; // no side effects
+ template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
+ template <typename T> const int S<T>::y = sizeof(arr2) / sizeof(arr2[0]);
+ template <typename T> int S<T>::f() { return x + y; }
+
+ int x = S<int>::f();
+}
diff --git a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp
index 0bd810e..aa79a4f 100644
--- a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp
+++ b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp
@@ -24,6 +24,6 @@ void f() {
// CHECK: call i8* @llvm.eh.exception()
// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector
// CHECK: call void @__cxa_guard_abort(i64* @_ZGVZ1fvE1x)
- // CHECK: call void @_Unwind_Resume_or_Rethrow
+ // CHECK: call void @llvm.eh.resume(
// CHECK: unreachable
}
diff --git a/test/CodeGenCXX/thunks.cpp b/test/CodeGenCXX/thunks.cpp
index a74cc05..7c80b96 100644
--- a/test/CodeGenCXX/thunks.cpp
+++ b/test/CodeGenCXX/thunks.cpp
@@ -265,18 +265,42 @@ namespace Test11 {
struct C : B { virtual C* f(); };
C* C::f() { return 0; }
+ // C::f itself.
+ // CHECK: define {{.*}} @_ZN6Test111C1fEv(
+
// The this-adjustment and return-adjustment thunk required when
// C::f appears in a vtable where A is at a nonzero offset from C.
// CHECK: define {{.*}} @_ZTcv0_n24_v0_n32_N6Test111C1fEv(
- // C::f itself.
- // CHECK: define {{.*}} @_ZN6Test111C1fEv(
-
// The return-adjustment thunk required when C::f appears in a vtable
// where A is at a zero offset from C.
// CHECK: define {{.*}} @_ZTch0_v0_n32_N6Test111C1fEv(
}
+// Varargs thunk test.
+namespace Test12 {
+ struct A {
+ virtual A* f(int x, ...);
+ };
+ struct B {
+ virtual B* f(int x, ...);
+ };
+ struct C : A, B {
+ virtual void c();
+ virtual C* f(int x, ...);
+ };
+ C* C::f(int x, ...) { return this; }
+
+ // C::f
+ // CHECK: define {{.*}} @_ZN6Test121C1fEiz
+
+ // Varargs thunk; check that both the this and covariant adjustments
+ // are generated.
+ // CHECK: define {{.*}} @_ZTchn8_h8_N6Test121C1fEiz
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
+ // CHECK: getelementptr inbounds i8* {{.*}}, i64 8
+}
+
/**** The following has to go at the end of the file ****/
// This is from Test5:
diff --git a/test/CodeGenCXX/vararg-non-pod.cpp b/test/CodeGenCXX/vararg-non-pod.cpp
new file mode 100644
index 0000000..6c6f459
--- /dev/null
+++ b/test/CodeGenCXX/vararg-non-pod.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -Wno-error=non-pod-varargs -emit-llvm -o - %s | FileCheck %s
+
+struct X {
+ X();
+ X(const X&);
+ ~X();
+};
+
+void vararg(...);
+
+// CHECK: define void @_Z4test1X
+void test(X x) {
+ // CHECK: call void @llvm.trap()
+ vararg(x);
+ // CHECK: ret void
+}
diff --git a/test/CodeGenCXX/virtual-base-destructor-call.cpp b/test/CodeGenCXX/virtual-base-destructor-call.cpp
index 807eaff..f028e4c 100644
--- a/test/CodeGenCXX/virtual-base-destructor-call.cpp
+++ b/test/CodeGenCXX/virtual-base-destructor-call.cpp
@@ -27,11 +27,6 @@ int main() {
// CHECK: call void @_ZN13basic_istreamIcED2Ev
// CHECK: }
-// basic_istream's base dtor is a no-op.
-// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr
-// CHECK-NOT: call
-// CHECK: }
-
// basic_iostream's deleting dtor calls its complete dtor, then
// operator delete().
// CHECK: define linkonce_odr void @_ZN14basic_iostreamIcED0Ev(%struct.basic_iostream* %this) unnamed_addr
@@ -49,3 +44,8 @@ int main() {
// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED0Ev(%struct.basic_istream* %this) unnamed_addr
// CHECK: call void @_ZN13basic_istreamIcED1Ev
// CHECK: call void @_ZdlPv
+
+// basic_istream's base dtor is a no-op.
+// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr
+// CHECK-NOT: call
+// CHECK: }
diff --git a/test/CodeGenCXX/x86_32-arguments.cpp b/test/CodeGenCXX/x86_32-arguments.cpp
index e94e2ca..4c06033 100644
--- a/test/CodeGenCXX/x86_32-arguments.cpp
+++ b/test/CodeGenCXX/x86_32-arguments.cpp
@@ -31,7 +31,7 @@ void f(C) { }
// CHECK: define void @_ZThn4_N18BasicAliasAnalysis13getModRefInfoE8CallSite
// ...
-// CHECK: %struct.CallSite* byval %CS)
+// CHECK: %struct.CallSite* byval align 4 %CS)
struct CallSite {
unsigned Ptr;
CallSite(unsigned XX) : Ptr(XX) {}
@@ -89,7 +89,7 @@ struct s5 { s5(); int &x; };
s5 f5() { return s5(); }
// CHECK: define i32 @_Z4f6_0M2s6i(i32 %a)
-// CHECK: define i64 @_Z4f6_1M2s6FivE(%{{.*}} byval)
+// CHECK: define i64 @_Z4f6_1M2s6FivE(%{{.*}} byval align 4)
// FIXME: It would be nice to avoid byval on the previous case.
struct s6 {};
typedef int s6::* s6_mdp;
diff --git a/test/CodeGenObjC/bitfield-ivar-offsets.m b/test/CodeGenObjC/bitfield-ivar-offsets.m
index e0eebe1..ce6f17b 100644
--- a/test/CodeGenObjC/bitfield-ivar-offsets.m
+++ b/test/CodeGenObjC/bitfield-ivar-offsets.m
@@ -1,12 +1,12 @@
// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s
-// RUN: grep -F '@"OBJC_IVAR_$_I0._b0" = global i64 0, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._b1" = global i64 0, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._b2" = global i64 1, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._x" = global i64 2, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._b3" = global i64 4, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._y" = global i64 6, section "__DATA, __objc_const", align 8' %t
-// RUN: grep -F '@"OBJC_IVAR_$_I0._b4" = global i64 7, section "__DATA, __objc_const", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b1" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b2" = global i64 1, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._x" = global i64 2, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b3" = global i64 4, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._y" = global i64 6, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep -F '@"OBJC_IVAR_$_I0._b4" = global i64 7, section "__DATA, __objc_ivar", align 8' %t
// RUN: grep -F '@"OBJC_IVAR_$_I0." = global' %t | count 0
@interface I0 {
diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m
index 38b8635..5d63e91 100644
--- a/test/CodeGenObjC/blocks-2.m
+++ b/test/CodeGenObjC/blocks-2.m
@@ -33,5 +33,5 @@ void test1() {
// CHECK: call i8* @llvm.eh.exception()
// CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8*
// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
- // CHECK: call void @_Unwind_Resume_or_Rethrow(
+ // CHECK: call void @llvm.eh.resume(
}
diff --git a/test/CodeGenObjC/constant-string-class-1.m b/test/CodeGenObjC/constant-string-class-1.m
new file mode 100644
index 0000000..8ff605e
--- /dev/null
+++ b/test/CodeGenObjC/constant-string-class-1.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fno-constant-cfstrings -fconstant-string-class OFConstantString -emit-llvm -o %t %s
+// pr9914
+
+@interface OFConstantString
++ class;
+@end
+
+@interface OFString
+- (void)XMLElementBySerializing;
+@end
+
+@implementation OFString
+
+- (void)XMLElementBySerializing
+{
+ id str = @"object";
+
+ [OFConstantString class];
+}
+
+@end
+
+// CHECK: @"OBJC_CLASS_$_OFConstantString" = external global
diff --git a/test/CodeGenObjC/constant-string-class.m b/test/CodeGenObjC/constant-string-class.m
index 12253d6..489f511 100644
--- a/test/CodeGenObjC/constant-string-class.m
+++ b/test/CodeGenObjC/constant-string-class.m
@@ -32,4 +32,4 @@ int main () {
// CHECK-FRAGILE: @_FooClassReference = common global
// CHECK-NONFRAGILE: @"OBJC_CLASS_$_Object" = external global
-// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = unnamed_addr global
+// CHECK-NONFRAGILE: "OBJC_CLASS_$_Foo" = global
diff --git a/test/CodeGenObjC/debug-info-block-helper.m b/test/CodeGenObjC/debug-info-block-helper.m
new file mode 100644
index 0000000..136af14
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-block-helper.m
@@ -0,0 +1,30 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -masm-verbose -S -fblocks -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+extern void foo(void(^)(void));
+
+// CHECK: .ascii "__destroy_helper_block_" ## DW_AT_name
+
+@interface NSObject {
+ struct objc_object *isa;
+}
+@end
+
+@interface A:NSObject @end
+@implementation A
+- (void) helper {
+ int master = 0;
+ __block int m2 = 0;
+ __block int dbTransaction = 0;
+ int (^x)(void) = ^(void) { (void) self;
+ (void) master;
+ (void) dbTransaction;
+ m2++;
+ return m2;
+
+ };
+ master = x();
+}
+@end
+
+void foo(void(^x)(void)) {}
+
diff --git a/test/CodeGenObjC/debug-info-blocks.m b/test/CodeGenObjC/debug-info-blocks.m
new file mode 100644
index 0000000..fc8e962
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-blocks.m
@@ -0,0 +1,55 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang_cc1 -masm-verbose -S -fblocks -g -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-dispatch-method=mixed %s -o - | FileCheck %s
+
+//Radar 9279956
+//CHECK: ## DW_OP_deref
+//CHECK-NEXT: ## DW_OP_plus_uconst
+
+typedef unsigned int NSUInteger;
+
+@protocol NSObject
+@end
+
+@interface NSObject <NSObject>
+- (id)init;
++ (id)alloc;
+@end
+
+@interface NSDictionary : NSObject
+- (NSUInteger)count;
+@end
+
+@interface NSMutableDictionary : NSDictionary
+@end
+
+@interface A : NSObject {
+@public
+ int ivar;
+}
+@end
+
+static void run(void (^block)(void))
+{
+ block();
+}
+
+@implementation A
+
+- (id)init
+{
+ if ((self = [super init])) {
+ run(^{
+ NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
+ ivar = 42 + (int)[d count];
+ });
+ }
+ return self;
+}
+
+@end
+
+int main()
+{
+ A *a = [[A alloc] init];
+ return 0;
+}
diff --git a/test/CodeGenObjC/debug-info-class-extension.m b/test/CodeGenObjC/debug-info-class-extension.m
new file mode 100644
index 0000000..cf0445d
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-class-extension.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK: AT_APPLE_objc_complete_type
+
+@interface I1
+@end
+
+@implementation I1 {
+int myi2;
+}
+int myi;
+@end
+
+void foo(I1 *iptr) {}
+
diff --git a/test/CodeGenObjC/debug-info-class-extension2.m b/test/CodeGenObjC/debug-info-class-extension2.m
new file mode 100644
index 0000000..4cef88f
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-class-extension2.m
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -masm-verbose -S -g %s -o - | FileCheck %s
+// CHECK: AT_APPLE_objc_complete_type
+
+@interface Foo {} @end
+
+@interface Foo () {
+ int *bar;
+}
+@end
+
+@implementation Foo
+@end
+
+void bar(Foo *fptr) {}
diff --git a/test/CodeGenObjC/debug-info-class-extension3.m b/test/CodeGenObjC/debug-info-class-extension3.m
new file mode 100644
index 0000000..595c7bd
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-class-extension3.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fobjc-nonfragile-abi -masm-verbose -S -g %s -o - | FileCheck %s
+
+// CHECK-NOT: AT_APPLE_objc_complete_type
+
+@interface Foo {} @end
+
+@interface Foo () {
+ int *bar;
+}
+@end
+
+void bar(Foo *fptr) {}
diff --git a/test/CodeGenObjC/debug-info-crash.m b/test/CodeGenObjC/debug-info-crash.m
index 92f9c0e..eb2143f 100644
--- a/test/CodeGenObjC/debug-info-crash.m
+++ b/test/CodeGenObjC/debug-info-crash.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -g -S %s -o -
// rdar://7556129
diff --git a/test/CodeGenObjC/debug-info-getter-name.m b/test/CodeGenObjC/debug-info-getter-name.m
index 746fcee..ec784e3 100644
--- a/test/CodeGenObjC/debug-info-getter-name.m
+++ b/test/CodeGenObjC/debug-info-getter-name.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -fno-dwarf2-cfi-asm -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S -g %s -o - | FileCheck %s
//CHECK: "-[InstanceVariablesEverywhereButTheInterface someString]":
@@ -43,6 +44,8 @@
@end
@implementation AutomaticSynthesis
+@synthesize someString;
+@synthesize someNumber;
- init
{
return self;
diff --git a/test/CodeGenObjC/debug-info-pubtypes.m b/test/CodeGenObjC/debug-info-pubtypes.m
new file mode 100644
index 0000000..744a366
--- /dev/null
+++ b/test/CodeGenObjC/debug-info-pubtypes.m
@@ -0,0 +1,19 @@
+// REQUIRES: x86-64-registered-target
+// RUN: %clang -cc1 -triple x86_64-apple-darwin10 -g -S %s -o %t
+// RUN: FileCheck %s < %t
+
+//CHECK: .long Lset6
+//CHECK-NEXT: .long
+//CHECK-NEXT: .asciz "H"
+//CHECK-NEXT: .long 0
+//CHECK-NEXT: Lpubtypes_end1:
+
+@interface H
+-(void) foo;
+@end
+
+@implementation H
+-(void) foo {
+}
+@end
+
diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m
index 3bcf5fd..94513f2 100644
--- a/test/CodeGenObjC/debug-info-static-var.m
+++ b/test/CodeGenObjC/debug-info-static-var.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -S -masm-verbose -o - %s | FileCheck %s
// Radar 8801045
// Do not emit AT_MIPS_linkage_name for static variable i
diff --git a/test/CodeGenObjC/debug-property-synth.m b/test/CodeGenObjC/debug-property-synth.m
new file mode 100644
index 0000000..05852b7
--- /dev/null
+++ b/test/CodeGenObjC/debug-property-synth.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s
+// Radar 9468526
+@interface I {
+ int _p1;
+}
+@property int p1;
+@end
+
+@implementation I
+@synthesize p1 = _p1;
+@end
+
+int main() {
+ I *myi;
+ myi.p1 = 2;
+ return 0;
+}
+
+// CHECK: .loc 2 10 0
diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m
index 24a90a0..ade0c61 100644
--- a/test/CodeGenObjC/encode-test.m
+++ b/test/CodeGenObjC/encode-test.m
@@ -144,3 +144,20 @@ struct s8 {
long double x;
};
const char g8[] = @encode(struct s8);
+
+// CHECK: @g9 = constant [11 x i8] c"{S9=i[0i]}\00"
+struct S9 {
+ int x;
+ int flex[];
+};
+const char g9[] = @encode(struct S9);
+
+struct f
+{
+ int i;
+ struct{} g[4];
+ int tt;
+};
+
+// CHECK: @g10 = constant [14 x i8] c"{f=i[0{?=}]i}\00"
+const char g10[] = @encode(struct f);
diff --git a/test/CodeGenObjC/forward-decl-param.m b/test/CodeGenObjC/forward-decl-param.m
new file mode 100644
index 0000000..d54a888
--- /dev/null
+++ b/test/CodeGenObjC/forward-decl-param.m
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// <rdar://problem/9123036> crash due to forward-declared struct in
+// protocol method parameter.
+
+@protocol P
+- (void) A:(struct z) z;
+@end
+@interface I < P >
+@end
+@implementation I
+@end
+
+@interface I2
+- (void) A:(struct z2) z2;
+@end
+@implementation I2
+@end
+
diff --git a/test/CodeGenObjC/instance-method-metadata.m b/test/CodeGenObjC/instance-method-metadata.m
index ae87c7a..4e752c0 100644
--- a/test/CodeGenObjC/instance-method-metadata.m
+++ b/test/CodeGenObjC/instance-method-metadata.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S -o %t %s
// RUN: FileCheck < %t %s
diff --git a/test/CodeGenObjC/interface-layout-64.m b/test/CodeGenObjC/interface-layout-64.m
index af898bb..5158c61 100644
--- a/test/CodeGenObjC/interface-layout-64.m
+++ b/test/CodeGenObjC/interface-layout-64.m
@@ -1,17 +1,17 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s
// RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s &&
-// RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_const", align 8' %t
-// RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t
// RUN: grep '_OBJC_CLASS_RO_$_I3" = internal global .* { i32 0, i32 8, i32 13, .*' %t
// RUN: grep '_OBJC_CLASS_RO_$_I4" = internal global .* { i32 0, i32 13, i32 14, .*' %t
// RUN: grep '_OBJC_CLASS_RO_$_I5" = internal global .* { i32 0, i32 14, i32 24, .*' %t
diff --git a/test/CodeGenObjC/ivar-layout-array0-struct.m b/test/CodeGenObjC/ivar-layout-array0-struct.m
index 4300db3..a9ae0ac 100644
--- a/test/CodeGenObjC/ivar-layout-array0-struct.m
+++ b/test/CodeGenObjC/ivar-layout-array0-struct.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
diff --git a/test/CodeGenObjC/ivar-layout-no-optimize.m b/test/CodeGenObjC/ivar-layout-no-optimize.m
index 7760f94..2851e79 100644
--- a/test/CodeGenObjC/ivar-layout-no-optimize.m
+++ b/test/CodeGenObjC/ivar-layout-no-optimize.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s
diff --git a/test/CodeGenObjC/messages-2.m b/test/CodeGenObjC/messages-2.m
index 5ef2261..e4e8cfb 100644
--- a/test/CodeGenObjC/messages-2.m
+++ b/test/CodeGenObjC/messages-2.m
@@ -147,17 +147,29 @@ typedef struct {
// rdar://problem/7854674
// CHECK: define void @test0([[A:%.*]]*
// CHECK-NF: define void @test0([[A:%.*]]*
-void test0(A *a) {
- // CHECK: alloca [[A]]*
+void test0(A *x) {
+ // CHECK: [[X:%.*]] = alloca [[A]]*
// CHECK-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
- // CHECK-NF: alloca [[A]]*
- // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
-
+ // CHECK: [[T0:%.*]] = load [[A]]** [[X]]
+ // CHECK: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+ // CHECK-NEXT: icmp eq i8* [[T1]], null
+ // CHECK-NEXT: br i1
+ // CHECK: call {{.*}} @objc_msgSend_stret to
+ // CHECK-NEXT: br label
// CHECK: [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
// CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
- // CHECK-NEXT: call {{.*}} @objc_msgSend_stret to
+ // CHECK-NEXT: br label
+
+ // CHECK-NF: [[X:%.*]] = alloca [[A]]*
+ // CHECK-NF-NEXT: [[POINT:%.*]] = alloca [[POINT_T:%.*]],
+ // CHECK-NF: [[T0:%.*]] = load [[A]]** [[X]]
+ // CHECK-NF: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8*
+ // CHECK-NF-NEXT: icmp eq i8* [[T1]], null
+ // CHECK-NF-NEXT: br i1
+ // CHECK-NF: call {{.*}} @objc_msgSend_stret to
+ // CHECK-NF-NEXT: br label
// CHECK-NF: [[T0:%.*]] = bitcast [[POINT_T]]* [[POINT]] to i8*
// CHECK-NF-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 48, i32 4, i1 false)
- // CHECK-NF-NEXT: call {{.*}} @objc_msgSend_stret to
- MyPoint point = [a returnAPoint];
+ // CHECK-NF-NEXT: br label
+ MyPoint point = [x returnAPoint];
}
diff --git a/test/CodeGenObjC/metadata-symbols-64.m b/test/CodeGenObjC/metadata-symbols-64.m
index 908c95c..4bc41fa 100644
--- a/test/CodeGenObjC/metadata-symbols-64.m
+++ b/test/CodeGenObjC/metadata-symbols-64.m
@@ -3,7 +3,7 @@
// RUN: grep '@"OBJC_CLASS_$_A" = global' %t
// RUN: grep '@"OBJC_CLASS_$_B" = external global' %t
-// RUN: grep '@"OBJC_IVAR_$_A._ivar" = global .* section "__DATA, __objc_const", align 8' %t
+// RUN: grep '@"OBJC_IVAR_$_A._ivar" = global .* section "__DATA, __objc_ivar", align 8' %t
// RUN: grep '@"OBJC_METACLASS_$_A" = global .* section "__DATA, __objc_data", align 8' %t
// RUN: grep '@"\\01L_OBJC_CLASSLIST_REFERENCES_$_[0-9]*" = internal global .* section "__DATA, __objc_classrefs, regular, no_dead_strip", align 8' %t
// RUN: grep '@"\\01L_OBJC_CLASSLIST_SUP_REFS_$_[0-9]*" = internal global .* section "__DATA, __objc_superrefs, regular, no_dead_strip", align 8' %t | count 2
diff --git a/test/CodeGenObjC/no-vararg-messaging.m b/test/CodeGenObjC/no-vararg-messaging.m
index f72820a..6747c0c 100644
--- a/test/CodeGenObjC/no-vararg-messaging.m
+++ b/test/CodeGenObjC/no-vararg-messaging.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S -o - %s | FileCheck %s
// rdar://9048030
diff --git a/test/CodeGenObjC/objc-read-weak-byref.m b/test/CodeGenObjC/objc-read-weak-byref.m
index fa7a6f9..c89fcd5 100644
--- a/test/CodeGenObjC/objc-read-weak-byref.m
+++ b/test/CodeGenObjC/objc-read-weak-byref.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -S %s -o %t-32.s
diff --git a/test/CodeGenObjC/protocol-in-extended-class.m b/test/CodeGenObjC/protocol-in-extended-class.m
index d2955b1..daf4d4c 100644
--- a/test/CodeGenObjC/protocol-in-extended-class.m
+++ b/test/CodeGenObjC/protocol-in-extended-class.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -S %s -o %t-64.s
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s
// RUN: %clang_cc1 -triple i386-apple-darwin -S %s -o %t-32.s
diff --git a/test/CodeGenObjC/try.m b/test/CodeGenObjC/try.m
index ba79d62..56b8e64 100644
--- a/test/CodeGenObjC/try.m
+++ b/test/CodeGenObjC/try.m
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target,x86-64-registered-target
// RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=i686-apple-darwin9
// RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=x86_64-apple-darwin9
diff --git a/test/CodeGenObjC/unwind-fn.m b/test/CodeGenObjC/unwind-fn.m
deleted file mode 100644
index 5e4a7a5..0000000
--- a/test/CodeGenObjC/unwind-fn.m
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck --check-prefix=DEFAULT_EH %s
-// RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s
-
-// DEFAULT_EH: declare void @_Unwind_Resume_or_Rethrow(i8*)
-// SJLJ_EH: declare void @_Unwind_SjLj_Resume_or_Rethrow(i8*)
-
-void f1(), f2();
-void f0() {
- @try {
- f1();
- } @catch (...) {
- f2();
- }
-}
diff --git a/test/CodeGenObjCXX/block-in-template-inst.mm b/test/CodeGenObjCXX/block-in-template-inst.mm
new file mode 100644
index 0000000..72042fc
--- /dev/null
+++ b/test/CodeGenObjCXX/block-in-template-inst.mm
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -emit-llvm-only -std=c++0x -fblocks -o - -triple x86_64-apple-darwin10 %s
+// rdar://9362021
+
+@class DYFuture;
+@interface NSCache
+- (void)setObject:(id)obj forKey:(id)key;
+@end
+
+template <typename T>
+class ResourceManager
+{
+public:
+ ~ResourceManager();
+ DYFuture* XXX();
+ NSCache* _spDeviceCache;
+};
+
+template <typename T>
+DYFuture* ResourceManager<T>::XXX()
+{
+ ^ {
+ [_spDeviceCache setObject:0 forKey:0];
+ }();
+
+ return 0;
+}
+
+struct AnalyzerBaseObjectTypes { };
+
+void FUNC()
+{
+ ResourceManager<AnalyzerBaseObjectTypes> *rm;
+ ^(void) { rm->XXX(); }();
+}
+
+namespace PR9982 {
+ template<typename T> struct Curry;
+
+ template<typename R, typename Arg0, typename Arg1, typename Arg2>
+ struct Curry<R (^)(Arg0, Arg1, Arg2)>
+ {
+ typedef R (^FType)(Arg0, Arg1, Arg2);
+
+ Curry(FType _f) : f(_f) {}
+ ~Curry() {;}
+
+ R (^(^operator()(Arg0 a))(Arg1))(Arg2)
+ {
+ auto block = ^(Arg1 b) {
+ auto inner_block = ^(Arg2 c) {
+ return f(a, b, c);
+ };
+ return inner_block;
+ };
+ return block;
+ }
+
+ private:
+ FType f;
+ };
+
+ auto add = ^(int a, int b, int c)
+ {
+ return a + b + c;
+ };
+
+ void curry() {
+ Curry<__decltype(add)> c = Curry<__decltype(add)>(add);
+ auto t = c(1)(10)(100);
+ }
+}
diff --git a/test/CodeGenObjCXX/blocks.mm b/test/CodeGenObjCXX/blocks.mm
index ffb916b..e220753 100644
--- a/test/CodeGenObjCXX/blocks.mm
+++ b/test/CodeGenObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin %s -verify -emit-llvm -o %t
// rdar://8979379
@interface A
@@ -28,3 +28,19 @@ void foo(id <NSObject>(^objectCreationBlock)(void)) {
return bar(objectCreationBlock);
}
+// Test4
+struct S {
+ S *(^a)() = ^{ // expected-warning {{C++0x}}
+ return this;
+ };
+};
+S s;
+
+// Test5
+struct X {
+ void f() {
+ ^ {
+ struct Nested { Nested *ptr = this; }; // expected-warning {{C++0x}}
+ } ();
+ };
+};
diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm
index 5a49feb..dce3d70 100644
--- a/test/CodeGenObjCXX/encode.mm
+++ b/test/CodeGenObjCXX/encode.mm
@@ -62,3 +62,73 @@ typedef float HGVec4f __attribute__ ((vector_size(16)));
@implementation RedBalloonHGXFormWrapper
@end
+// rdar://9357400
+namespace rdar9357400 {
+ template<int Dim1 = -1, int Dim2 = -1> struct fixed {
+ template<int D> struct rebind { typedef fixed<D> other; };
+ };
+
+ template<typename Element, int Size>
+ class fixed_1D
+ {
+ public:
+ typedef Element value_type;
+ typedef value_type array_impl[Size];
+ protected:
+ array_impl m_data;
+ };
+
+ template<typename Element, typename Alloc>
+ class vector;
+
+ template<typename Element, int Size>
+ class vector< Element, fixed<Size> >
+ : public fixed_1D<Element,Size> { };
+
+ typedef vector< float, fixed<4> > vector4f;
+
+ // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00"
+ const char gg[] = @encode(vector4f);
+}
+
+struct Base1 {
+ char x;
+};
+
+struct DBase : public Base1 {
+ double x;
+ virtual ~DBase();
+};
+
+struct Sub_with_virt : virtual DBase {
+ long x;
+};
+
+struct Sub2 : public Sub_with_virt, public Base1, virtual DBase {
+ float x;
+};
+
+// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00"
+const char g1[] = @encode(Base1);
+
+// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00"
+const char g2[] = @encode(DBase);
+
+// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00"
+const char g3[] = @encode(Sub_with_virt);
+
+// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00"
+const char g4[] = @encode(Sub2);
+
+// http://llvm.org/PR9927
+class allocator {
+};
+class basic_string {
+struct _Alloc_hider : allocator {
+char* _M_p;
+};
+_Alloc_hider _M_dataplus;
+};
+
+// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00"
+const char g5[] = @encode(basic_string);
diff --git a/test/CodeGenObjCXX/mangle.mm b/test/CodeGenObjCXX/mangle.mm
index 7a75a5b..2521c60 100644
--- a/test/CodeGenObjCXX/mangle.mm
+++ b/test/CodeGenObjCXX/mangle.mm
@@ -42,3 +42,15 @@
}
@end
+// rdar://9566314
+@interface NX
+- (void)Meth;
+@end
+
+@implementation NX
+- (void)Meth {
+ void uiIsVisible();
+// CHECK: call void @_Z11uiIsVisiblev
+ uiIsVisible();
+}
+@end
diff --git a/test/CodeGenObjCXX/property-object-conditional-exp.mm b/test/CodeGenObjCXX/property-object-conditional-exp.mm
index 826c351..a3c1027 100644
--- a/test/CodeGenObjCXX/property-object-conditional-exp.mm
+++ b/test/CodeGenObjCXX/property-object-conditional-exp.mm
@@ -23,7 +23,12 @@ extern "C" bool CGRectIsEmpty(CGRect);
CGRect virtualBounds;
// CHECK: [[SRC:%.*]] = call %struct.CGRect bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
-// CHECK-NEXT:store %struct.CGRect [[SRC]], %struct.CGRect*
+// CHECK-NEXT:getelementptr %struct.CGRect* [[SRC:%.*]]
+// CHECK-NEXT:extractvalue
+// CHECK-NEXT:store
+// CHECK-NEXT:getelementptr %struct.CGRect* [[SRC:%.*]]
+// CHECK-NEXT:extractvalue
+// CHECK-NEXT:store
dataRect = CGRectIsEmpty(virtualBounds) ? self.bounds : virtualBounds;
dataRect = CGRectIsEmpty(virtualBounds) ? [self bounds] : virtualBounds;
dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.bounds;
diff --git a/test/Driver/cc-log-diagnostics.c b/test/Driver/cc-log-diagnostics.c
index a70686a..6c1b8ed 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 \
-// RUN: CC_LOG_DIAGNOSTICS_FILE=%t.log \
-// RUN: %clang -no-canonical-prefixes -ccc-host-triple x86_64-apple-darwin10 -fsyntax-only %s
+// 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: FileCheck %s < %t.log
int f0() {}
@@ -16,6 +16,12 @@ int f0() {}
// CHECK: <dict>
// CHECK: <key>level</key>
// CHECK: <string>warning</string>
+// CHECK: <key>message</key>
+// CHECK: <string>unknown warning option '-Wfoobar'</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>level</key>
+// CHECK: <string>warning</string>
// CHECK: <key>filename</key>
// CHECK: <string>{{.*}}cc-log-diagnostics.c</string>
// CHECK: <key>line</key>
diff --git a/test/Driver/cfi.c b/test/Driver/cfi.c
new file mode 100644
index 0000000..b5c0c03
--- /dev/null
+++ b/test/Driver/cfi.c
@@ -0,0 +1,8 @@
+// RUN: %clang -ccc-host-triple i386-apple-darwin10 -static -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-DARWIN %s
+
+// RUN: %clang -ccc-host-triple i386-pc-linux-gnu -static -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-LINUX %s
+
+// CHECK-DARWIN: -fno-dwarf2-cfi-asm
+// CHECK-LINUX-NOT: -fno-dwarf2-cfi-asm
diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c
index 3394e4e..326ca47 100644
--- a/test/Driver/darwin-debug-flags.c
+++ b/test/Driver/darwin-debug-flags.c
@@ -1,7 +1,7 @@
// RUN: env RC_DEBUG_OPTIONS=1 %clang -ccc-host-triple i386-apple-darwin9 -g -Os %s -emit-llvm -S -o - | FileCheck %s
// <rdar://problem/7256886>
-// CHECK: !1 = metadata !{
+// CHECK: !0 = metadata !{
// CHECK: -g -Os
// CHECK: -mmacosx-version-min=10.5.0
// CHECK: [ DW_TAG_compile_unit ]
diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c
index 3f2b691..91d47ea 100644
--- a/test/Driver/darwin-ld.c
+++ b/test/Driver/darwin-ld.c
@@ -5,9 +5,9 @@
// 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: grep '".*dsymutil" "BAR"' %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: grep '".*dsymutil" "BAR"' %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
@@ -19,7 +19,8 @@
// 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 -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: grep '".*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" "-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" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-FARG1"' %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" "-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.a" "-T" "ARG4" "-FARG1"}}
// Check linker changes that came with new linkedit format.
// RUN: touch %t.o
diff --git a/test/Driver/nostdlib.c b/test/Driver/nostdlib.c
new file mode 100644
index 0000000..c73212f
--- /dev/null
+++ b/test/Driver/nostdlib.c
@@ -0,0 +1,4 @@
+// RUN: %clang -ccc-host-triple i686-pc-linux-gnu -### -nostdlib %s 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK-NOT: start-group
diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m
index e3d2c0f..2fe2cce 100644
--- a/test/Driver/rewrite-objc.m
+++ b/test/Driver/rewrite-objc.m
@@ -3,7 +3,7 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-fmessage-length" "0" "-fobjc-exceptions" "-fdiagnostics-show-option"
+// TEST0: "-fmessage-length" "0" "-fobjc-infer-related-result-type" "-fobjc-exceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m"
// RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \
diff --git a/test/Driver/sysroot.c b/test/Driver/sysroot.c
new file mode 100644
index 0000000..34f3100
--- /dev/null
+++ b/test/Driver/sysroot.c
@@ -0,0 +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: 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: -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: -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/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index 90bf9f5..77e9e58 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -verify -std=c++0x %s
// RUN: cp %s %t
-// RUN: %clang_cc1 -std=c++0x -fixit %t || true
+// RUN: %clang_cc1 -x c++ -std=c++0x -fixit %t || true
// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++0x %t
/* This is a test of the various code modification hints that only
diff --git a/test/Frontend/diagnostic-name.c b/test/Frontend/diagnostic-name.c
index 7f43f65..ae6cb0d 100644
--- a/test/Frontend/diagnostic-name.c
+++ b/test/Frontend/diagnostic-name.c
@@ -1,5 +1,5 @@
-// RUN: %clang -Wunused-parameter -fdiagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 1
-// RUN: %clang -Wunused-parameter -fno-diagnostics-show-name %s 2>&1 | grep "\[warn_unused_parameter\]" | count 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/ir-support-codegen.ll b/test/Frontend/ir-support-codegen.ll
index 046b3af..e5e5b62 100644
--- a/test/Frontend/ir-support-codegen.ll
+++ b/test/Frontend/ir-support-codegen.ll
@@ -1,3 +1,4 @@
+; REQUIRES: x86-64-registered-target
; RUN: %clang_cc1 -S -o - %s | FileCheck %s
target triple = "x86_64-apple-darwin10"
diff --git a/test/Frontend/undef.c b/test/Frontend/undef.c
new file mode 100644
index 0000000..f539cdc
--- /dev/null
+++ b/test/Frontend/undef.c
@@ -0,0 +1,4 @@
+// RUN: %clang -undef -x assembler-with-cpp -E %s
+#ifndef __ASSEMBLER__
+#error "Must be preprocessed as assembler."
+#endif
diff --git a/test/Index/Inputs/guarded.h b/test/Index/Inputs/guarded.h
new file mode 100644
index 0000000..0a1a6ac
--- /dev/null
+++ b/test/Index/Inputs/guarded.h
@@ -0,0 +1,6 @@
+#ifndef GUARDED_HEADER_H
+#define GUARDED_HEADER_H
+
+int y;
+
+#endif // GUARDED_HEADER_H
diff --git a/test/Index/Inputs/pragma-once.h b/test/Index/Inputs/pragma-once.h
new file mode 100644
index 0000000..503cb3f
--- /dev/null
+++ b/test/Index/Inputs/pragma-once.h
@@ -0,0 +1,3 @@
+#pragma once
+int i;
+
diff --git a/test/Index/annotate-context-sensitive.cpp b/test/Index/annotate-context-sensitive.cpp
index 307bced..151914c 100644
--- a/test/Index/annotate-context-sensitive.cpp
+++ b/test/Index/annotate-context-sensitive.cpp
@@ -28,12 +28,12 @@ struct Derived2 : Base2 {
// CHECK-OVERRIDE-FINAL: Identifier: "Base" [6:30 - 6:34] TypeRef=class Base:1:7
// CHECK-OVERRIDE-FINAL: Punctuation: "{" [6:35 - 6:36] ClassDecl=Derived:6:7 (Definition)
// CHECK-OVERRIDE-FINAL: Keyword: "virtual" [7:3 - 7:10] ClassDecl=Derived:6:7 (Definition)
-// CHECK-OVERRIDE-FINAL: Keyword: "void" [7:11 - 7:15] CXXMethod=f:7:16 [Overrides @3:16]
-// CHECK-OVERRIDE-FINAL: Identifier: "f" [7:16 - 7:17] CXXMethod=f:7:16 [Overrides @3:16]
-// CHECK-OVERRIDE-FINAL: Punctuation: "(" [7:17 - 7:18] CXXMethod=f:7:16 [Overrides @3:16]
-// CHECK-OVERRIDE-FINAL: Punctuation: ")" [7:18 - 7:19] CXXMethod=f:7:16 [Overrides @3:16]
-// CHECK-OVERRIDE-FINAL: Keyword: "override" [7:20 - 7:28] CXXMethod=f:7:16 [Overrides @3:16]
-// CHECK-OVERRIDE-FINAL: Keyword: "final" [7:29 - 7:34] CXXMethod=f:7:16 [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Keyword: "void" [7:11 - 7:15] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Identifier: "f" [7:16 - 7:17] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Punctuation: "(" [7:17 - 7:18] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Punctuation: ")" [7:18 - 7:19] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Keyword: "override" [7:20 - 7:28] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
+// CHECK-OVERRIDE-FINAL: Keyword: "final" [7:29 - 7:34] CXXMethod=f:7:16 (virtual) [Overrides @3:16]
// CHECK-OVERRIDE-FINAL: Punctuation: ";" [7:34 - 7:35] ClassDecl=Derived:6:7 (Definition)
// CHECK-OVERRIDE-FINAL: Keyword: "struct" [9:3 - 9:9] StructDecl=final:9:10 (Definition)
// CHECK-OVERRIDE-FINAL: Identifier: "final" [9:10 - 9:15] StructDecl=final:9:10 (Definition)
diff --git a/test/Index/annotate-tokens-pp.c b/test/Index/annotate-tokens-pp.c
index 3dd9ffe..01a615f 100644
--- a/test/Index/annotate-tokens-pp.c
+++ b/test/Index/annotate-tokens-pp.c
@@ -25,7 +25,10 @@ void test() {
fun_with_macro_bodies(x, { int z = x; ++z; });
}
-// RUN: c-index-test -test-annotate-tokens=%s:2:1:26:1 -I%S/Inputs %s | FileCheck %s
+#include "pragma-once.h"
+#include "guarded.h"
+
+// RUN: c-index-test -test-annotate-tokens=%s:2:1:30:1 -I%S/Inputs %s | FileCheck %s
// CHECK: Punctuation: "#" [2:1 - 2:2] preprocessing directive=
// CHECK: Identifier: "define" [2:2 - 2:8] preprocessing directive=
// CHECK: Identifier: "STILL_NOTHING" [2:9 - 2:22] macro definition=STILL_NOTHING
@@ -184,4 +187,5 @@ void test() {
// CHECK: Punctuation: ")" [25:47 - 25:48] UnexposedStmt=
// CHECK: Punctuation: ";" [25:48 - 25:49] UnexposedStmt=
// CHECK: Punctuation: "}" [26:1 - 26:2] UnexposedStmt=
-
+// CHECK: {{28:1.*inclusion directive=pragma-once.h.*multi-include guarded}}
+// CHECK: {{29:1.*inclusion directive=guarded.h.*multi-include guarded}}
diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m
index f977e5c..1eb7794 100644
--- a/test/Index/annotate-tokens.m
+++ b/test/Index/annotate-tokens.m
@@ -500,10 +500,10 @@ static Rdar8595462_A * Rdar8595462_staticVar;
// CHECK: Punctuation: "*" [111:26 - 111:27] ObjCPropertyDecl=foo2:111:27
// CHECK: Identifier: "foo2" [111:27 - 111:31] ObjCPropertyDecl=foo2:111:27
-// CHECK: Punctuation: "@" [115:1 - 115:2] UnexposedDecl=foo:110:33 (Definition)
-// CHECK: Keyword: "synthesize" [115:2 - 115:12] UnexposedDecl=foo:110:33 (Definition)
-// CHECK: Identifier: "foo" [115:13 - 115:16] UnexposedDecl=foo:110:33 (Definition)
-// CHECK: Punctuation: "=" [115:17 - 115:18] UnexposedDecl=foo:110:33 (Definition)
+// CHECK: Punctuation: "@" [115:1 - 115:2] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Keyword: "synthesize" [115:2 - 115:12] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Identifier: "foo" [115:13 - 115:16] ObjCSynthesizeDecl=foo:110:33 (Definition)
+// CHECK: Punctuation: "=" [115:17 - 115:18] ObjCSynthesizeDecl=foo:110:33 (Definition)
// CHECK: Identifier: "_foo" [115:19 - 115:23] MemberRef=_foo:107:8
// CHECK: Punctuation: ";" [115:23 - 115:24] ObjCImplementationDecl=Rdar8595386:114:1 (Definition)
diff --git a/test/Index/complete-kvc.m b/test/Index/complete-kvc.m
index 43a874b..62d98a9 100644
--- a/test/Index/complete-kvc.m
+++ b/test/Index/complete-kvc.m
@@ -41,6 +41,17 @@ typedef signed char BOOL;
+ (NSSet *)keyPathsForValuesAffectingIntProperty { return 0; }
@end
+@interface MySubClass : MyClass
+@end
+
+@interface MySubClass ()
+@property int intProperty;
+@end
+
+@implementation MySubClass
+- (int)intProperty { return 0; }
+@end
+
// RUN: c-index-test -code-completion-at=%s:39:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText addMutableArrayPropertyObject:}{LeftParen (}{Placeholder object-type}{Text *}{RightParen )}{Text object} (55)
// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText addMutableSetProperty:}{LeftParen (}{Text NSSet *}{RightParen )}{Text objects} (40)
@@ -84,4 +95,11 @@ typedef signed char BOOL;
// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceObjectInMySetPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index}{HorizontalSpace }{TypedText withObject:}{LeftParen (}{Text id}{RightParen )}{Text object} (55)
// RUN: c-index-test -code-completion-at=%s:41:3 %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: ObjCInstanceMethodDecl:{LeftParen (}{Text NSSet *}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfMutableArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text NSSet *}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40)
+
+// RUN: c-index-test -code-completion-at=%s:52:8 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText countOfIntProperty} (55)
+// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText intProperty} (40)
+// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText isIntProperty} (40)
diff --git a/test/Index/complete-member-access.m b/test/Index/complete-member-access.m
index ad2998c..bd68deb 100644
--- a/test/Index/complete-member-access.m
+++ b/test/Index/complete-member-access.m
@@ -22,9 +22,26 @@ void test_props(Int* ptr) {
ptr->IVar = 0;
}
+@interface Sub : Int
+@property int myProp;
+
+- (int)myProp;
+- (int)myOtherPropLikeThing;
+- (int)myOtherNonPropThing:(int)value;
+@end
+
+int test_more_props(Sub *s) {
+ return s.myOtherPropLikeThing;
+}
+
// 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}
// RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: ObjCIvarDecl:{ResultType int}{TypedText IVar} (35)
// CHECK-CC2: ObjCIvarDecl:{ResultType int}{TypedText SuperIVar} (37)
+// RUN: c-index-test -code-completion-at=%s:34:12 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType int}{TypedText myOtherPropLikeThing} (37)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType int}{TypedText myProp} (35)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType int}{TypedText prop1} (35)
+// CHECK-CC3: ObjCPropertyDecl:{ResultType float}{TypedText ProtoProp} (35)
diff --git a/test/Index/complete-property-flags.m b/test/Index/complete-property-flags.m
index cd3696f..af9e214 100644
--- a/test/Index/complete-property-flags.m
+++ b/test/Index/complete-property-flags.m
@@ -8,6 +8,7 @@
@property(retain, nonatomic) id xx;
// RUN: c-index-test -code-completion-at=%s:7:11 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: {TypedText assign}
+// CHECK-CC1-NEXT: {TypedText atomic}
// CHECK-CC1-NEXT: {TypedText copy}
// CHECK-CC1-NEXT: {TypedText getter}{Text = }{Placeholder method}
// CHECK-CC1-NEXT: {TypedText nonatomic}
diff --git a/test/Index/nested-macro-instantiations.cpp b/test/Index/nested-macro-instantiations.cpp
new file mode 100644
index 0000000..d0c9bbb1
--- /dev/null
+++ b/test/Index/nested-macro-instantiations.cpp
@@ -0,0 +1,20 @@
+#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 instantiation=WIBBLE:3:9 Extent=[5:1 - 5:7]
+// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:3:19: macro instantiation=BAR:2:9 Extent=[3:19 - 5:14]
+// CHECK-WITH-NESTED: nested-macro-instantiations.cpp:2:16: macro instantiation=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 instantiation=WIBBLE:3:9 Extent=[5:1 - 5:7]
+// CHECK-WITHOUT-NESTED-NOT: nested-macro-instantiations.cpp:3:19: macro instantiation=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.cpp b/test/Index/overrides.cpp
index ed24cc5..698b256 100644
--- a/test/Index/overrides.cpp
+++ b/test/Index/overrides.cpp
@@ -16,5 +16,5 @@ struct D : C {
};
// RUN: c-index-test -test-load-source local %s | FileCheck %s
-// CHECK: overrides.cpp:11:16: CXXMethod=g:11:16 [Overrides @7:16] Extent=[11:3 - 11:19]
-// CHECK: overrides.cpp:15:16: CXXMethod=f:15:16 [Overrides @2:16, @6:16] Extent=[15:3 - 15:22]
+// CHECK: overrides.cpp:11:16: CXXMethod=g:11:16 (virtual) [Overrides @7:16] Extent=[11:3 - 11:19]
+// CHECK: overrides.cpp:15:16: CXXMethod=f:15:16 (virtual) [Overrides @2:16, @6:16] Extent=[15:3 - 15:22]
diff --git a/test/Index/properties-class-extensions.m b/test/Index/properties-class-extensions.m
index ecedc60..de61242 100644
--- a/test/Index/properties-class-extensions.m
+++ b/test/Index/properties-class-extensions.m
@@ -95,5 +95,5 @@
// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=qux:38:34 Extent=[38:34 - 38:37]
// CHECK: properties-class-extensions.m:38:34: ObjCInstanceMethodDecl=setQux::38:34 Extent=[38:34 - 38:37]
// CHECK: properties-class-extensions.m:38:34: ParmDecl=qux:38:34 (Definition) Extent=[38:34 - 38:37]
-// CHECK: properties-class-extensions.m:42:10: UnexposedDecl=qux:38:34 (Definition) Extent=[42:1 - 42:13]
+// CHECK: properties-class-extensions.m:42:10: ObjCDynamicDecl=qux:38:34 (Definition) Extent=[42:1 - 42:13]
diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp
index 6170fdc..4c24083 100644
--- a/test/Index/recursive-cxx-member-calls.cpp
+++ b/test/Index/recursive-cxx-member-calls.cpp
@@ -399,13 +399,13 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK-tokens: Punctuation: ";" [32:6 - 32:7] ClassDecl=AttributeList:12:9 (Definition)
// CHECK-tokens: Keyword: "static" [33:5 - 33:11] ClassDecl=AttributeList:12:9 (Definition)
// CHECK-tokens: Identifier: "Kind" [33:12 - 33:16] TypeRef=enum clang::AttributeList::Kind:13:10
-// CHECK-tokens: Identifier: "getKind" [33:17 - 33:24] CXXMethod=getKind:33:17
-// CHECK-tokens: Punctuation: "(" [33:24 - 33:25] CXXMethod=getKind:33:17
-// CHECK-tokens: Keyword: "const" [33:25 - 33:30] CXXMethod=getKind:33:17
+// CHECK-tokens: Identifier: "getKind" [33:17 - 33:24] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Punctuation: "(" [33:24 - 33:25] CXXMethod=getKind:33:17 (static)
+// CHECK-tokens: Keyword: "const" [33:25 - 33:30] CXXMethod=getKind:33:17 (static)
// CHECK-tokens: Identifier: "IdentifierInfo" [33:31 - 33:45] TypeRef=class clang::IdentifierInfo:66:7
// CHECK-tokens: Punctuation: "*" [33:46 - 33:47] ParmDecl=Name:33:48 (Definition)
// CHECK-tokens: Identifier: "Name" [33:48 - 33:52] ParmDecl=Name:33:48 (Definition)
-// CHECK-tokens: Punctuation: ")" [33:52 - 33:53] CXXMethod=getKind:33:17
+// CHECK-tokens: Punctuation: ")" [33:52 - 33:53] CXXMethod=getKind:33:17 (static)
// CHECK-tokens: Punctuation: ";" [33:53 - 33:54] ClassDecl=AttributeList:12:9 (Definition)
// CHECK-tokens: Punctuation: "}" [34:3 - 34:4] ClassDecl=AttributeList:12:9 (Definition)
// CHECK-tokens: Punctuation: ";" [34:4 - 34:5] Namespace=clang:10:17 (Definition)
@@ -456,14 +456,14 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK-tokens: Punctuation: ";" [44:16 - 44:17] ClassDecl=StringRef:38:7 (Definition)
// CHECK-tokens: Keyword: "static" [45:3 - 45:9] ClassDecl=StringRef:38:7 (Definition)
// CHECK-tokens: Identifier: "size_t" [45:10 - 45:16] TypeRef=size_t:2:25
-// CHECK-tokens: Identifier: "min" [45:17 - 45:20] CXXMethod=min:45:17 (Definition)
-// CHECK-tokens: Punctuation: "(" [45:20 - 45:21] CXXMethod=min:45:17 (Definition)
+// CHECK-tokens: Identifier: "min" [45:17 - 45:20] CXXMethod=min:45:17 (Definition) (static)
+// CHECK-tokens: Punctuation: "(" [45:20 - 45:21] CXXMethod=min:45:17 (Definition) (static)
// CHECK-tokens: Identifier: "size_t" [45:21 - 45:27] TypeRef=size_t:2:25
// CHECK-tokens: Identifier: "a" [45:28 - 45:29] ParmDecl=a:45:28 (Definition)
-// CHECK-tokens: Punctuation: "," [45:29 - 45:30] CXXMethod=min:45:17 (Definition)
+// CHECK-tokens: Punctuation: "," [45:29 - 45:30] CXXMethod=min:45:17 (Definition) (static)
// CHECK-tokens: Identifier: "size_t" [45:31 - 45:37] TypeRef=size_t:2:25
// CHECK-tokens: Identifier: "b" [45:38 - 45:39] ParmDecl=b:45:38 (Definition)
-// CHECK-tokens: Punctuation: ")" [45:39 - 45:40] CXXMethod=min:45:17 (Definition)
+// CHECK-tokens: Punctuation: ")" [45:39 - 45:40] CXXMethod=min:45:17 (Definition) (static)
// CHECK-tokens: Punctuation: "{" [45:41 - 45:42] UnexposedStmt=
// CHECK-tokens: Keyword: "return" [45:43 - 45:49] UnexposedStmt=
// CHECK-tokens: Identifier: "a" [45:50 - 45:51] DeclRefExpr=a:45:28
@@ -893,17 +893,17 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK-tokens: Identifier: "clang" [98:17 - 98:22] NamespaceRef=clang:10:17
// CHECK-tokens: Punctuation: ";" [98:22 - 98:23]
// CHECK-tokens: Identifier: "AttributeList" [100:1 - 100:14] TypeRef=class clang::AttributeList:12:9
-// CHECK-tokens: Punctuation: "::" [100:14 - 100:16] CXXMethod=getKind:100:36 (Definition)
+// CHECK-tokens: Punctuation: "::" [100:14 - 100:16] CXXMethod=getKind:100:36 (Definition) (static)
// CHECK-tokens: Identifier: "Kind" [100:16 - 100:20] TypeRef=enum clang::AttributeList::Kind:13:10
// CHECK-tokens: Identifier: "AttributeList" [100:21 - 100:34] TypeRef=class clang::AttributeList:12:9
-// CHECK-tokens: Punctuation: "::" [100:34 - 100:36] CXXMethod=getKind:100:36 (Definition)
-// CHECK-tokens: Identifier: "getKind" [100:36 - 100:43] CXXMethod=getKind:100:36 (Definition)
-// CHECK-tokens: Punctuation: "(" [100:43 - 100:44] CXXMethod=getKind:100:36 (Definition)
-// CHECK-tokens: Keyword: "const" [100:44 - 100:49] CXXMethod=getKind:100:36 (Definition)
+// CHECK-tokens: Punctuation: "::" [100:34 - 100:36] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Identifier: "getKind" [100:36 - 100:43] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Punctuation: "(" [100:43 - 100:44] CXXMethod=getKind:100:36 (Definition) (static)
+// CHECK-tokens: Keyword: "const" [100:44 - 100:49] CXXMethod=getKind:100:36 (Definition) (static)
// CHECK-tokens: Identifier: "IdentifierInfo" [100:50 - 100:64] TypeRef=class clang::IdentifierInfo:66:7
// CHECK-tokens: Punctuation: "*" [100:65 - 100:66] ParmDecl=Name:100:67 (Definition)
// CHECK-tokens: Identifier: "Name" [100:67 - 100:71] ParmDecl=Name:100:67 (Definition)
-// CHECK-tokens: Punctuation: ")" [100:71 - 100:72] CXXMethod=getKind:100:36 (Definition)
+// CHECK-tokens: Punctuation: ")" [100:71 - 100:72] CXXMethod=getKind:100:36 (Definition) (static)
// CHECK-tokens: Punctuation: "{" [100:73 - 100:74] UnexposedStmt=
// CHECK-tokens: Identifier: "llvm" [101:3 - 101:7] NamespaceRef=llvm:82:11
// CHECK-tokens: Punctuation: "::" [101:7 - 101:9] VarDecl=AttrName:101:19 (Definition)
@@ -1616,7 +1616,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK: 30:40: EnumConstantDecl=AT_init_priority:30:40 (Definition) Extent=[30:40 - 30:56]
// CHECK: 31:7: EnumConstantDecl=IgnoredAttribute:31:7 (Definition) Extent=[31:7 - 31:23]
// CHECK: 31:25: EnumConstantDecl=UnknownAttribute:31:25 (Definition) Extent=[31:25 - 31:41]
-// CHECK: 33:17: CXXMethod=getKind:33:17 Extent=[33:5 - 33:53]
+// CHECK: 33:17: CXXMethod=getKind:33:17 (static) Extent=[33:5 - 33:53]
// CHECK: 33:12: TypeRef=enum clang::AttributeList::Kind:13:10 Extent=[33:12 - 33:16]
// CHECK: 33:48: ParmDecl=Name:33:48 (Definition) Extent=[33:25 - 33:52]
// CHECK: 33:31: TypeRef=class clang::IdentifierInfo:66:7 Extent=[33:31 - 33:45]
@@ -1638,7 +1638,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK: 43:15: FieldDecl=Data:43:15 (Definition) Extent=[43:3 - 43:19]
// CHECK: 44:10: FieldDecl=Length:44:10 (Definition) Extent=[44:3 - 44:16]
// CHECK: 44:3: TypeRef=size_t:2:25 Extent=[44:3 - 44:9]
-// CHECK: 45:17: CXXMethod=min:45:17 (Definition) Extent=[45:3 - 45:66]
+// CHECK: 45:17: CXXMethod=min:45:17 (Definition) (static) Extent=[45:3 - 45:66]
// CHECK: 45:10: TypeRef=size_t:2:25 Extent=[45:10 - 45:16]
// CHECK: 45:28: ParmDecl=a:45:28 (Definition) Extent=[45:21 - 45:29]
// CHECK: 45:21: TypeRef=size_t:2:25 Extent=[45:21 - 45:27]
@@ -1865,7 +1865,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
// CHECK: 93:12: DeclRefExpr=Value:92:23 Extent=[93:12 - 93:17]
// CHECK: 98:17: UsingDirective=:98:17 Extent=[98:1 - 98:22]
// CHECK: 98:17: NamespaceRef=clang:10:17 Extent=[98:17 - 98:22]
-// CHECK: 100:36: CXXMethod=getKind:100:36 (Definition) Extent=[100:1 - 186:2]
+// CHECK: 100:36: CXXMethod=getKind:100:36 (Definition) (static) Extent=[100:1 - 186:2]
// CHECK: 100:21: TypeRef=class clang::AttributeList:12:9 Extent=[100:21 - 100:34]
// CHECK: 100:67: ParmDecl=Name:100:67 (Definition) Extent=[100:44 - 100:71]
// CHECK: 100:50: TypeRef=class clang::IdentifierInfo:66:7 Extent=[100:50 - 100:64]
diff --git a/test/Index/usrs.cpp b/test/Index/usrs.cpp
index a43b689..023818c 100644
--- a/test/Index/usrs.cpp
+++ b/test/Index/usrs.cpp
@@ -65,6 +65,20 @@ using foo::ClsB;
namespace foo_alias3 = foo;
+namespace {
+class RDar9371763_Foo {
+public:
+ void bar();
+};
+}
+
+void RDar9371763_Foo::bar() {}
+
+void rdar9371763() {
+ RDar9371763_Foo foo;
+ foo.bar();
+}
+
// RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s
// CHECK: usrs.cpp c:@N@foo Extent=[1:1 - 4:2]
// CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8]
@@ -122,3 +136,11 @@ namespace foo_alias3 = foo;
// CHECK: usrs.cpp c:@NA@foo_alias2
// CHECK-NOT: ClsB
// CHECK: usrs.cpp c:@NA@foo_alias3
+// CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2]
+// CHECK: usrs.cpp c:@aN@C@RDar9371763_Foo Extent=[69:1 - 72:2]
+// CHECK: usrs.cpp c: Extent=[70:1 - 70:8]
+// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[71:3 - 71:13]
+// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[75:1 - 75:31]
+// CHECK: usrs.cpp c:@F@rdar9371763# Extent=[77:1 - 80:2]
+// CHECK: usrs.cpp c:usrs.cpp@1204@F@rdar9371763#@foo Extent=[78:3 - 78:22]
+
diff --git a/test/Index/usrs.m b/test/Index/usrs.m
index 4b79fdc..2830647 100644
--- a/test/Index/usrs.m
+++ b/test/Index/usrs.m
@@ -195,7 +195,7 @@ int test_multi_declaration(void) {
// CHECK-source: usrs.m:42:10: UnexposedExpr= Extent=[42:10 - 42:11]
// CHECK-source: usrs.m:42:10: UnexposedExpr= Extent=[42:10 - 42:11]
// CHECK-source: usrs.m:44:13: ObjCIvarDecl=d1:44:13 (Definition) Extent=[44:13 - 44:15]
-// CHECK-source: usrs.m:44:13: UnexposedDecl=d1:31:15 (Definition) Extent=[44:1 - 44:15]
+// CHECK-source: usrs.m:44:13: ObjCSynthesizeDecl=d1:31:15 (Definition) Extent=[44:1 - 44:15]
// CHECK-source: usrs.m:47:5: VarDecl=z:47:5 Extent=[47:1 - 47:6]
// CHECK-source: usrs.m:49:12: FunctionDecl=local_func:49:12 (Definition) Extent=[49:1 - 49:43]
// CHECK-source: usrs.m:49:27: ParmDecl=x:49:27 (Definition) Extent=[49:23 - 49:28]
diff --git a/test/Lexer/block_cmt_end.c b/test/Lexer/block_cmt_end.c
index b03fb23..f54b6a4 100644
--- a/test/Lexer/block_cmt_end.c
+++ b/test/Lexer/block_cmt_end.c
@@ -1,7 +1,7 @@
/*
RUN: %clang_cc1 -E -trigraphs %s | grep bar
RUN: %clang_cc1 -E -trigraphs %s | grep foo
- RUN: %clang_cc1 -E -trigraphs %s | not grep abc
+ RUN: %clang_cc1 -E -trigraphs %s | not grep qux
RUN: %clang_cc1 -E -trigraphs %s | not grep xyz
RUN: %clang_cc1 -fsyntax-only -trigraphs -verify %s
*/
@@ -9,7 +9,7 @@
// This is a simple comment, /*/ does not end a comment, the trailing */ does.
int i = /*/ */ 1;
-/* abc
+/* qux
next comment ends with normal escaped newline:
*/
@@ -32,7 +32,3 @@ foo
// rdar://6060752 - We should not get warnings about trigraphs in comments:
// '????'
/* ???? */
-
-
-
-
diff --git a/test/Lexer/has_extension.c b/test/Lexer/has_extension.c
new file mode 100644
index 0000000..bc75a4a
--- /dev/null
+++ b/test/Lexer/has_extension.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-PED-NONE %s
+// RUN: %clang_cc1 -pedantic-errors -E %s -o - | FileCheck --check-prefix=CHECK-PED-ERR %s
+
+// CHECK-PED-NONE: no_dummy_extension
+#if !__has_extension(dummy_extension)
+int no_dummy_extension();
+#endif
+
+// Arbitrary feature to test that has_extension is a superset of has_feature
+// CHECK-PED-NONE: attribute_overloadable
+#if __has_extension(attribute_overloadable)
+int attribute_overloadable();
+#endif
+
+// CHECK-PED-NONE: has_c_static_assert
+// CHECK-PED-ERR: no_c_static_assert
+#if __has_extension(c_static_assert)
+int has_c_static_assert();
+#else
+int no_c_static_assert();
+#endif
+
+// CHECK-PED-NONE: has_c_generic_selections
+// CHECK-PED-ERR: no_c_generic_selections
+#if __has_extension(c_generic_selections)
+int has_c_generic_selections();
+#else
+int no_c_generic_selections();
+#endif
+
diff --git a/test/Lexer/has_extension_cxx.cpp b/test/Lexer/has_extension_cxx.cpp
new file mode 100644
index 0000000..77efa35
--- /dev/null
+++ b/test/Lexer/has_extension_cxx.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -E %s -o - | FileCheck %s
+
+// CHECK: c_static_assert
+#if __has_extension(c_static_assert)
+int c_static_assert();
+#endif
+
+// CHECK: c_generic_selections
+#if __has_extension(c_generic_selections)
+int c_generic_selections();
+#endif
+
+// CHECK: has_deleted_functions
+#if __has_extension(cxx_deleted_functions)
+int has_deleted_functions();
+#endif
+
+// CHECK: has_inline_namespaces
+#if __has_extension(cxx_inline_namespaces)
+int has_inline_namespaces();
+#endif
+
+// CHECK: has_override_control
+#if __has_extension(cxx_override_control)
+int has_override_control();
+#endif
+
+// CHECK: has_reference_qualified_functions
+#if __has_extension(cxx_reference_qualified_functions)
+int has_reference_qualified_functions();
+#endif
+
+// CHECK: has_rvalue_references
+#if __has_extension(cxx_rvalue_references)
+int has_rvalue_references();
+#endif
diff --git a/test/Lexer/has_feature_c1x.c b/test/Lexer/has_feature_c1x.c
new file mode 100644
index 0000000..6c0fb21
--- /dev/null
+++ b/test/Lexer/has_feature_c1x.c
@@ -0,0 +1,20 @@
+// 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_static_assert)
+int has_static_assert();
+#else
+int no_static_assert();
+#endif
+
+// CHECK-1X: has_static_assert
+// CHECK-NO-1X: no_static_assert
+
+#if __has_feature(c_generic_selections)
+int has_generic_selections();
+#else
+int no_generic_selections();
+#endif
+
+// CHECK-1X: has_generic_selections
+// CHECK-NO-1X: no_generic_selections
diff --git a/test/Lexer/has_feature_cxx0x.cpp b/test/Lexer/has_feature_cxx0x.cpp
index 57949e3..ca5f868 100644
--- a/test/Lexer/has_feature_cxx0x.cpp
+++ b/test/Lexer/has_feature_cxx0x.cpp
@@ -17,7 +17,7 @@ int has_nullptr();
int no_nullptr();
#endif
-// CHECK-0X: no_nullptr
+// CHECK-0X: has_nullptr
// CHECK-NO-0X: no_nullptr
@@ -155,3 +155,12 @@ int no_override_control();
// CHECK-0X: has_override_control
// CHECK-NO-0X: no_override_control
+
+#if __has_feature(cxx_alias_templates)
+int has_alias_templates();
+#else
+int no_alias_templates();
+#endif
+
+// CHECK-0X: has_alias_templates
+// CHECK-NO-0X: no_alias_templates
diff --git a/test/Lexer/has_feature_type_traits.cpp b/test/Lexer/has_feature_type_traits.cpp
index 3cfc602..5da845f 100644
--- a/test/Lexer/has_feature_type_traits.cpp
+++ b/test/Lexer/has_feature_type_traits.cpp
@@ -89,3 +89,13 @@ int is_union();
int is_literal();
#endif
// CHECK: int is_literal();
+
+#if __has_feature(is_standard_layout)
+int is_standard_layout();
+#endif
+// CHECK: int is_standard_layout();
+
+#if __has_feature(is_trivially_copyable)
+int is_trivially_copyable();
+#endif
+// CHECK: int is_trivially_copyable();
diff --git a/test/Misc/Inputs/include.h b/test/Misc/Inputs/include.h
index d325775..72835e9 100644
--- a/test/Misc/Inputs/include.h
+++ b/test/Misc/Inputs/include.h
@@ -1 +1,3 @@
+#define EQUALS(a,b) a == b
+
int foo(int x) { return x; }
diff --git a/test/Misc/diag-format.c b/test/Misc/diag-format.c
new file mode 100644
index 0000000..39760b1
--- /dev/null
+++ b/test/Misc/diag-format.c
@@ -0,0 +1,34 @@
+// 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=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=vi %s 2>&1 | FileCheck %s -check-prefix=VI
+//
+// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=MSVC_ORIG
+//
+// RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=NO_COLUMN
+//
+
+
+
+
+
+
+
+
+
+
+
+
+#ifdef foo
+#endif bad // extension!
+// DEFAULT: {{.*}}:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC: {{.*}}(28,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// VI: {{.*}} +28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// MSVC_ORIG: {{.*}}(28) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
+// NO_COLUMN: {{.*}}:28: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+int x;
diff --git a/test/Misc/include-stack-for-note-flag.cpp b/test/Misc/include-stack-for-note-flag.cpp
index f8d0080..328999d 100644
--- a/test/Misc/include-stack-for-note-flag.cpp
+++ b/test/Misc/include-stack-for-note-flag.cpp
@@ -9,10 +9,20 @@ int test() {
return foo(1, 1);
}
+bool macro(int x, int y) {
+ return EQUALS(&x, y);
+}
+
// STACK: error: no matching function for call to 'foo'
// STACK: In file included from
// STACK: note: candidate function not viable
+// STACK: error: comparison between pointer and integer
+// STACK: In file included from
+// STACK: note: instantiated from:
// 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: instantiated from:
diff --git a/test/PCH/cxx-alias-decl.cpp b/test/PCH/cxx-alias-decl.cpp
new file mode 100644
index 0000000..e30311c
--- /dev/null
+++ b/test/PCH/cxx-alias-decl.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-alias-decl.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-alias-decl.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+template struct T<S>;
+C<A>::A<char> a;
+
+using T1 = decltype(a);
+using T1 = D<int, char>;
+
+using T2 = B<A>;
+using T2 = S;
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/test/PCH/cxx-alias-decl.h b/test/PCH/cxx-alias-decl.h
new file mode 100644
index 0000000..26bc716
--- /dev/null
+++ b/test/PCH/cxx-alias-decl.h
@@ -0,0 +1,11 @@
+// Header for PCH test cxx-alias-decl.cpp
+
+struct S {};
+template<typename U> struct T {
+ template<typename V> using A = T<V>;
+};
+
+using A = int;
+template<typename U> using B = S;
+template<typename U> using C = T<U>;
+template<typename U, typename V> using D = typename T<U>::template A<V>;
diff --git a/test/PCH/cxx-for-range.cpp b/test/PCH/cxx-for-range.cpp
index 5854917..46e217c 100644
--- a/test/PCH/cxx-for-range.cpp
+++ b/test/PCH/cxx-for-range.cpp
@@ -1,9 +1,9 @@
// Test this without pch.
-// RUN: %clang_cc1 -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s
// Test with pch.
-// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-for-range.h
-// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-for-range.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
void h() {
f();
diff --git a/test/PCH/cxx-member-init.cpp b/test/PCH/cxx-member-init.cpp
new file mode 100644
index 0000000..70392a2
--- /dev/null
+++ b/test/PCH/cxx-member-init.cpp
@@ -0,0 +1,22 @@
+// Test this without pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -DSOURCE -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s
+
+#ifdef HEADER
+int n;
+struct S {
+ int *p = &m;
+ int &m = n;
+ S *that = this;
+};
+#endif
+
+#ifdef SOURCE
+S s;
+#elif HEADER
+#undef HEADER
+#define SOURCE
+#endif
diff --git a/test/PCH/cxx-reference.cpp b/test/PCH/cxx-reference.cpp
index 90d00d7..2dfbcdc 100644
--- a/test/PCH/cxx-reference.cpp
+++ b/test/PCH/cxx-reference.cpp
@@ -1,6 +1,6 @@
// Test this without pch.
-// RUN: %clang_cc1 -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
// Test with pch.
-// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-reference.h
-// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-reference.h
+// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp
index 3440921..464da40 100644
--- a/test/PCH/cxx-static_assert.cpp
+++ b/test/PCH/cxx-static_assert.cpp
@@ -1,11 +1,20 @@
// Test this without pch.
-// RUN: %clang_cc1 -include %S/cxx-static_assert.h -verify -std=c++0x %s
+// RUN: %clang_cc1 -include %s -verify -std=c++0x %s
// Test with pch.
-// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %S/cxx-static_assert.h
+// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %s
// RUN: %clang_cc1 -include-pch %t -verify -std=c++0x %s
-// expected-error {{static_assert failed "N is not 2!"}}
+#ifndef HEADER
+#define HEADER
+
+template<int N> struct T {
+ static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}}
+};
+
+#else
T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
T<2> t2;
+
+#endif
diff --git a/test/PCH/cxx-static_assert.h b/test/PCH/cxx-static_assert.h
deleted file mode 100644
index ba41ab8..0000000
--- a/test/PCH/cxx-static_assert.h
+++ /dev/null
@@ -1,9 +0,0 @@
-// Header for PCH test cxx-static_assert.cpp
-
-
-
-
-
-template<int N> struct T {
- static_assert(N == 2, "N is not 2!");
-};
diff --git a/test/PCH/cxx0x-default-delete.cpp b/test/PCH/cxx0x-default-delete.cpp
new file mode 100644
index 0000000..753ac47
--- /dev/null
+++ b/test/PCH/cxx0x-default-delete.cpp
@@ -0,0 +1,23 @@
+// Without PCH
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include %s %s
+// With PCH
+// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include-pch %t %s
+
+#ifndef PASS1
+#define PASS1
+
+struct foo {
+ foo() = default;
+ void bar() = delete; // expected-note{{deleted here}}
+};
+
+#else
+
+foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
+foo f;
+void fn() {
+ f.bar(); // expected-error{{deleted function}}
+}
+
+#endif
diff --git a/test/PCH/cxx0x-delegating-ctors.cpp b/test/PCH/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..15311f8
--- /dev/null
+++ b/test/PCH/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,20 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -std=c++0x -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -verify %s
+
+#ifndef PASS1
+#define PASS1
+struct foo {
+ foo(int) : foo() { } // expected-note{{it delegates to}}
+ foo();
+ foo(bool) : foo('c') { } // expected-note{{it delegates to}}
+ foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+};
+#else
+foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \
+ // expected-note{{which delegates to}}
+#endif
diff --git a/test/PCH/modified-header-error.c b/test/PCH/modified-header-error.c
new file mode 100644
index 0000000..6335fb1
--- /dev/null
+++ b/test/PCH/modified-header-error.c
@@ -0,0 +1,11 @@
+// RUN: mkdir -p %t.dir
+// RUN: echo '#include "header2.h"' > %t.dir/header1.h
+// RUN: echo > %t.dir/header2.h
+// RUN: cp %s %t.dir/t.c
+// RUN: %clang_cc1 -x c-header %t.dir/header1.h -emit-pch -o %t.pch
+// RUN: echo >> %t.dir/header2.h
+// RUN: %clang_cc1 %t.dir/t.c -include-pch %t.pch -fsyntax-only 2>&1 | FileCheck %s
+
+#include "header2.h"
+
+// CHECK: fatal error: file {{.*}} has been modified since the precompiled header was built
diff --git a/test/PCH/objc_methods.h b/test/PCH/objc_methods.h
index 4c6b1e1..bd77535 100644
--- a/test/PCH/objc_methods.h
+++ b/test/PCH/objc_methods.h
@@ -2,7 +2,7 @@
@interface TestPCH
+ alloc;
-- (void)instMethod;
+- (id)init;
@end
@class TestForwardClassDecl;
diff --git a/test/PCH/objc_methods.m b/test/PCH/objc_methods.m
index e90a463..3311813 100644
--- a/test/PCH/objc_methods.m
+++ b/test/PCH/objc_methods.m
@@ -12,5 +12,5 @@ void func() {
// AliasForTestPCH *zz;
xx = [TestPCH alloc];
- [xx instMethod];
+ [xx init];
}
diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm
index 89d3e08..8214957 100644
--- a/test/PCH/objcxx-ivar-class.mm
+++ b/test/PCH/objcxx-ivar-class.mm
@@ -6,7 +6,7 @@
// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
// CHECK: [C position]
-// CHECK: call void @_ZN1SC1ERKS_
+// CHECK: call {{.*}} @_ZN1SC1ERKS_
// CHECK: [C setPosition:]
// CHECK: call %struct.S* @_ZN1SaSERKS_
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index 32ed375..3a72ea0 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -105,6 +105,13 @@ template <class T, const GUID& g>
class COM_CLASS_TEMPLATE_REF { };
typedef COM_CLASS_TEMPLATE<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
+ struct late_defined_uuid;
+ template<typename T>
+ void test_late_defined_uuid() {
+ __uuidof(late_defined_uuid);
+ }
+ struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid;
+
class CtorCall {
public:
@@ -136,7 +143,7 @@ class C2 {
};
template <class T>
-void f(){
+void missing_template_keyword(){
typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
}
@@ -151,11 +158,6 @@ void redundant_typename() {
t = 3;
}
-int main() {
- redundant_typename<int>();
- f<int>();
-}
-
__interface MicrosoftInterface;
__interface MicrosoftInterface {
@@ -164,3 +166,87 @@ __interface MicrosoftInterface {
};
__int64 x7 = __int64(0);
+
+
+namespace If_exists_test {
+
+class IF_EXISTS {
+private:
+ typedef int Type;
+};
+
+int __if_exists_test() {
+ int b=0;
+ __if_exists(IF_EXISTS::Type) {
+ b++;
+ b++;
+ }
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type_not) {
+ b++;
+ b++;
+ }
+}
+
+
+__if_exists(IF_EXISTS::Type) {
+ int var23;
+}
+
+__if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+}
+
+class IF_EXISTS_CLASS_TEST {
+ __if_exists(IF_EXISTS::Type) {
+ // __if_exists, __if_not_exists can nest
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var123;
+ }
+ int var23;
+ }
+
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+ }
+};
+
+}
+
+
+int __identifier(generic) = 3;
+
+class inline_definition_pure_spec {
+ virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
+ virtual int f2() = 0;
+};
+
+
+int main () {
+ // Necessary to force instantiation in -fdelayed-template-parsing mode.
+ test_late_defined_uuid<int>();
+ redundant_typename<int>();
+ missing_template_keyword<int>();
+}
+
diff --git a/test/Parser/cxx-default-delete.cpp b/test/Parser/cxx-default-delete.cpp
new file mode 100644
index 0000000..a3d5b2c
--- /dev/null
+++ b/test/Parser/cxx-default-delete.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+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}}
+
+struct foo {
+ foo() = default;
+ ~foo() = delete;
+ void bar() = delete;
+};
+
+void baz() = delete;
diff --git a/test/Parser/cxx-ext-delete-default.cpp b/test/Parser/cxx-ext-delete-default.cpp
new file mode 100644
index 0000000..0627238
--- /dev/null
+++ b/test/Parser/cxx-ext-delete-default.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+
+struct A {
+ A(const A&) = delete; // expected-warning {{accepted as a C++0x extension}}
+ A& operator=(const A&) = delete; // expected-warning {{accepted as a C++0x extension}}
+ A() = default; // expected-warning {{accepted as a C++0x extension}}
+ ~A();
+};
+
+void f() = delete; // expected-warning {{accepted as a C++0x extension}}
+A::~A() = default; //expected-warning {{accepted as a C++0x extension}}
diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp
index 59350b5..a13e7ba 100644
--- a/test/Parser/cxx-friend.cpp
+++ b/test/Parser/cxx-friend.cpp
@@ -21,9 +21,9 @@ class B {
// 'A' here should refer to the declaration above.
friend class A;
- friend C; // expected-warning {{must specify 'class' to befriend}}
- friend U; // expected-warning {{must specify 'union' to befriend}}
- friend int; // expected-warning {{non-class type 'int' cannot be a friend}}
+ friend C; // expected-warning {{specify 'class' to befriend}}
+ friend U; // expected-warning {{specify 'union' to befriend}}
+ friend int; // expected-warning {{non-class friend type 'int'}}
friend void myfunc();
diff --git a/test/Parser/cxx0x-member-initializers.cpp b/test/Parser/cxx0x-member-initializers.cpp
new file mode 100644
index 0000000..6c3492e
--- /dev/null
+++ b/test/Parser/cxx0x-member-initializers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// Make sure we don't run off the end of the stream when parsing a deferred
+// initializer.
+int a; // expected-note {{previous}}
+struct S {
+ int n = 4 + ; // expected-error {{expected expression}}
+} a; // expected-error {{redefinition}}
+
+// Make sure we use all of the tokens.
+struct T {
+ int a = 1 // expected-error {{expected ';' at end of declaration list}}
+ int b = 2;
+ int c = b; // expected-error {{undeclared identifier}}
+};
diff --git a/test/Parser/nested-namespaces-recovery.cpp b/test/Parser/nested-namespaces-recovery.cpp
new file mode 100644
index 0000000..d45938b
--- /dev/null
+++ b/test/Parser/nested-namespaces-recovery.cpp
@@ -0,0 +1,24 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -x c++ -fixit %t
+// RUN: %clang_cc1 -x c++ %t
+
+namespace foo1::foo2::foo3 { // expected-error {{nested namespace definition must define each namespace separately}}
+ int foo(int x) { return x; }
+}
+
+int foo(int x) {
+ return foo1::foo2::foo3::foo(x);
+}
+
+namespace bar1 {
+ namespace bar2 {
+ namespace bar3 {
+ int bar(int x) { return x; }
+ }
+ }
+}
+
+int bar(int x) {
+ return bar1::bar2::bar3::bar(x);
+}
diff --git a/test/Parser/opencl-astype.cl b/test/Parser/opencl-astype.cl
new file mode 100644
index 0000000..d4c547e
--- /dev/null
+++ b/test/Parser/opencl-astype.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void test_astype() {
+ float f = 1.0f;
+ unsigned int i = __builtin_astype(f, unsigned int);
+
+ typedef __attribute__(( ext_vector_type(4) )) int int4;
+ typedef __attribute__(( ext_vector_type(3) )) float float3;
+ typedef __attribute__(( ext_vector_type(4) )) float float4;
+ typedef __attribute__(( ext_vector_type(4) )) double double4;
+
+ float4 f4;
+ double4 d4 = __builtin_astype(f4, double4); // expected-error{{invalid reinterpretation: sizes of 'double4' and 'float4' must match}}
+
+ // Verify int4->float3, float3->int4 works.
+ int4 i4;
+ float3 f3 = __builtin_astype(i4, float3);
+ i4 = __builtin_astype(f3, int4);
+}
diff --git a/test/Preprocessor/if_warning.c b/test/Preprocessor/if_warning.c
index 345ac95..641ec3b 100644
--- a/test/Preprocessor/if_warning.c
+++ b/test/Preprocessor/if_warning.c
@@ -20,6 +20,10 @@ extern int x;
#endif
#endif
+// rdar://9475098
+#if 0
+#else 1 // expected-warning {{extra tokens}}
+#endif
// PR6852
#if 'somesillylongthing' // expected-warning {{character constant too long for its type}} \
diff --git a/test/Preprocessor/pragma_sysheader.c b/test/Preprocessor/pragma_sysheader.c
index cf2843b..2641682 100644
--- a/test/Preprocessor/pragma_sysheader.c
+++ b/test/Preprocessor/pragma_sysheader.c
@@ -1,3 +1,12 @@
// RUN: %clang -verify -pedantic %s -fsyntax-only
+// RUN: %clang_cc1 -E %s | FileCheck %s
// rdar://6899937
#include "pragma_sysheader.h"
+
+
+// PR9861: Verify that line markers are not messed up in -E mode.
+// CHECK: # 1 "{{.*}}pragma_sysheader.h" 1
+// CHECK-NEXT: # 1 "{{.*}}pragma_sysheader.h" 3
+// CHECK-NEXT: typedef int x;
+// CHECK-NEXT: typedef int x;
+// CHECK-NEXT: # 5 "{{.*}}pragma_sysheader.c" 2
diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c
index cb9fee9..7438f7f5 100644
--- a/test/Sema/MicrosoftExtensions.c
+++ b/test/Sema/MicrosoftExtensions.c
@@ -79,3 +79,11 @@ struct X0 {
enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
SomeValue = 0x100000000
};
+
+
+void pointer_to_integral_type_conv(char* ptr) {
+ char ch = (char)ptr;
+ short sh = (short)ptr;
+ ch = (char)ptr;
+ sh = (short)ptr;
+}
diff --git a/test/Sema/arm-neon-types.c b/test/Sema/arm-neon-types.c
index 152d4c9..1e8c9bf 100644
--- a/test/Sema/arm-neon-types.c
+++ b/test/Sema/arm-neon-types.c
@@ -9,5 +9,12 @@ int32x2_t test(int32x2_t x) {
// ...but should warn when the types really do not match.
float32x2_t test2(uint32x2_t x) {
- return vcvt_n_f32_s32(x, 0); // expected-warning {{incompatible vector types}}
+ return vcvt_n_f32_s32(x, 9); // expected-warning {{incompatible vector types}}
+}
+
+// Check immediate range for vcvt_n intrinsics is 1 to 32. Radar 9558930.
+float32x2_t test3(uint32x2_t x) {
+ // FIXME: The "incompatible result type" error is due to pr10112 and should be
+ // removed when that is fixed.
+ return vcvt_n_f32_u32(x, 0); // expected-error {{argument should be a value from 1 to 32}} expected-error {{incompatible result type}}
}
diff --git a/test/Sema/asm.c b/test/Sema/asm.c
index 7f0f396..d8161c8 100644
--- a/test/Sema/asm.c
+++ b/test/Sema/asm.c
@@ -105,3 +105,11 @@ void test10(void){
register int r asm ("cx");
register int rr asm ("rr_asm"); // expected-error{{unknown register name 'rr_asm' in asm}}
}
+
+// This is just an assert because of the boolean conversion.
+// Feel free to change the assembly to something sensible if it causes a problem.
+// rdar://problem/9414925
+void test11(void) {
+ _Bool b;
+ asm volatile ("movb %%gs:%P2,%b0" : "=q"(b) : "0"(0), "i"(5L));
+}
diff --git a/test/Sema/attr-unknown.c b/test/Sema/attr-unknown.c
index bec2e29..d1a831d 100644
--- a/test/Sema/attr-unknown.c
+++ b/test/Sema/attr-unknown.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunknown-attributes %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
int x __attribute__((foobar)); // expected-warning {{unknown attribute 'foobar' ignored}}
void z() __attribute__((bogusattr)); // expected-warning {{unknown attribute 'bogusattr' ignored}}
diff --git a/test/Sema/builtins-arm.c b/test/Sema/builtins-arm.c
index 4dd31e7..4077240 100644
--- a/test/Sema/builtins-arm.c
+++ b/test/Sema/builtins-arm.c
@@ -9,3 +9,8 @@ void __clear_cache(char*, char*);
void __clear_cache(void*, void*);
#endif
+// va_list on ARM is void*.
+void test2() {
+ __builtin_va_list ptr = "x";
+ *ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
+}
diff --git a/test/Sema/carbon.c b/test/Sema/carbon.c
index f0affd2..045d72c 100644
--- a/test/Sema/carbon.c
+++ b/test/Sema/carbon.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -target-cpu pentium4 %s -print-stats
+// RUN: %clang -fsyntax-only %s -print-stats
#ifdef __APPLE__
#include <Carbon/Carbon.h>
#endif
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index e4eeaec..9ce1481 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -189,6 +189,24 @@ int test20(int x) {
// no warning, this is an idiom for "true" in old C style.
return x && (signed char)1;
+
+ return x || 0;
+ return x || 1;
+ return x || -1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || 5; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x && 0;
+ return x && 1;
+ return x && -1; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && 5; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x || (0);
+ return x || (1);
+ return x || (-1); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || (5); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x && (0);
+ return x && (1);
+ return x && (-1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && (5); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+
}
struct Test21; // expected-note 2 {{forward declaration}}
diff --git a/test/Sema/illegal-types.c b/test/Sema/illegal-types.c
index 3c59df8..819b38a 100644
--- a/test/Sema/illegal-types.c
+++ b/test/Sema/illegal-types.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++98 %s
void a (void []()); // expected-error{{'type name' declared as array of functions}}
void b (void p[]()); // expected-error{{'p' declared as array of functions}}
diff --git a/test/Sema/parentheses.c b/test/Sema/parentheses.c
index a25ded6..fa3c3c2 100644
--- a/test/Sema/parentheses.c
+++ b/test/Sema/parentheses.c
@@ -39,6 +39,28 @@ void bitwise_rel(unsigned i) {
(void)(0 || i && i); // no warning.
}
+_Bool someConditionFunc();
+
+void conditional_op(int x, int y, _Bool b) {
+ (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the + expression to silence this warning}}
+
+ (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the - expression to silence this warning}}
+
+ (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the * expression to silence this warning}}
+
+ (void)(x / !x ? 1 : 2); // expected-warning {{?: has lower precedence than /}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the / expression to silence this warning}}
+
+
+ (void)(x % 2 ? 1 : 2); // no warning
+}
+
// RUN: %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s
// CHECK: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
-
diff --git a/test/Sema/parentheses.cpp b/test/Sema/parentheses.cpp
new file mode 100644
index 0000000..a25f2a0
--- /dev/null
+++ b/test/Sema/parentheses.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -fixit %s -o - | %clang_cc1 -Wparentheses -Werror -
+
+bool someConditionFunc();
+
+void conditional_op(int x, int y, bool b) {
+ (void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{?: has lower precedence than +}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the + expression to silence this warning}}
+
+ (void)(x - b ? 1 : 2); // expected-warning {{?: has lower precedence than -}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the - expression to silence this warning}}
+
+ (void)(x * (x == y) ? 1 : 2); // expected-warning {{?: has lower precedence than *}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the * expression to silence this warning}}
+}
+
+class Stream {
+public:
+ operator int();
+ Stream &operator<<(int);
+ Stream &operator<<(const char*);
+};
+
+void f(Stream& s, bool b) {
+ (void)(s << b ? "foo" : "bar"); // expected-warning {{?: has lower precedence than <<}} \
+ // expected-note {{place parentheses around the ?: expression to evaluate it first}} \
+ // expected-note {{place parentheses around the << expression to silence this warning}}
+}
diff --git a/test/Sema/stdcall-fastcall.c b/test/Sema/stdcall-fastcall.c
index 4531eb2..eeacf94 100644
--- a/test/Sema/stdcall-fastcall.c
+++ b/test/Sema/stdcall-fastcall.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin10 %s
// CC qualifier can be applied only to functions
int __attribute__((stdcall)) var1; // expected-warning{{'stdcall' only applies to function types; type here is 'int'}}
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 60cae80..b70a295 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -339,3 +339,16 @@ int test51(void)
return a; // no-warning
}
+// FIXME: This is a false positive, but it tests logical operations in switch statements.
+int test52(int a, int b) {
+ int x; // expected-note {{variable 'x' is declared here}} expected-note {{add initialization to silence this warning}}
+ switch (a || b) { // expected-warning {{switch condition has boolean value}}
+ case 0:
+ x = 1;
+ break;
+ case 1:
+ x = 2;
+ break;
+ }
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}
diff --git a/test/Sema/x86-builtin-palignr.c b/test/Sema/x86-builtin-palignr.c
index 2344306..83719a3 100644
--- a/test/Sema/x86-builtin-palignr.c
+++ b/test/Sema/x86-builtin-palignr.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +ssse3 -verify %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +ssse3 -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -target-feature +ssse3 -verify -triple i686-apple-darwin10 %s
#include <tmmintrin.h>
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index 2d620b6..9b03feb 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -6,6 +6,8 @@ void f(const type_info &a);
// Microsoft doesn't validate exception specification.
+namespace microsoft_exception_spec {
+
void foo(); // expected-note {{previous declaration}}
void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
@@ -22,6 +24,15 @@ struct Derived : Base {
virtual void f3();
};
+class A {
+ virtual ~A() throw(); // expected-note {{overridden virtual function is here}}
+};
+
+class B : public A {
+ virtual ~B(); // expected-warning {{exception specification of overriding function is more lax than base version}}
+};
+
+}
// MSVC allows type definition in anonymous union and struct
struct A
@@ -179,4 +190,65 @@ void static_func(); // expected-note {{previous declaration is here}}
static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
{
-} \ No newline at end of file
+}
+
+long function_prototype(int a);
+long (*function_ptr)(int a);
+
+void function_to_voidptr_conv() {
+ void *a1 = function_prototype;
+ void *a2 = &function_prototype;
+ void *a3 = function_ptr;
+}
+
+
+void pointer_to_integral_type_conv(char* ptr) {
+ char ch = (char)ptr;
+ short sh = (short)ptr;
+ ch = (char)ptr;
+ sh = (short)ptr;
+}
+
+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 friend_as_a_forward_decl {
+
+class A {
+ class Nested {
+ friend class B;
+ B* b;
+ };
+ B* b;
+};
+B* global_b;
+
+
+void f()
+{
+ class Local {
+ friend class Z;
+ Z* b;
+ };
+ Z* b;
+}
+
+ } \ No newline at end of file
diff --git a/test/SemaCXX/PR9572.cpp b/test/SemaCXX/PR9572.cpp
index d1b7077..25c0c01 100644
--- a/test/SemaCXX/PR9572.cpp
+++ b/test/SemaCXX/PR9572.cpp
@@ -1,13 +1,13 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
class Base {
- virtual ~Base();
+ virtual ~Base(); // expected-note {{implicitly declared private here}}
};
-struct Foo : public Base {
- const int kBlah = 3; // expected-error{{fields can only be initialized in constructors}}
+struct Foo : public Base { // expected-error {{base class 'Base' has private destructor}}
+ const int kBlah = 3; // expected-warning {{accepted as a C++0x extension}}
Foo();
};
struct Bar : public Foo {
- Bar() { }
+ Bar() { } // expected-note {{implicit default destructor for 'Foo' first required here}}
};
struct Baz {
Foo f;
diff --git a/test/SemaCXX/PR9884.cpp b/test/SemaCXX/PR9884.cpp
new file mode 100644
index 0000000..ab883c4
--- /dev/null
+++ b/test/SemaCXX/PR9884.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class Base {
+protected:
+ Base(int val);
+};
+
+
+class Derived : public Base {
+public:
+ Derived(int val);
+};
+
+
+Derived::Derived(int val)
+ : Base( val )
+{
+}
diff --git a/test/SemaCXX/PR9902.cpp b/test/SemaCXX/PR9902.cpp
new file mode 100644
index 0000000..ec76789
--- /dev/null
+++ b/test/SemaCXX/PR9902.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template <class _Tp, class _Up, bool = false>
+struct __allocator_traits_rebind
+{
+};
+
+template <template <class, class...> class _Alloc, class _Tp, class ..._Args,
+class _Up>
+struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
+{
+ typedef _Alloc<_Up, _Args...> type;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+ template <class T> using rebind_alloc = typename __allocator_traits_rebind<Alloc, T>::type;
+ template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+};
+
+template <class T>
+struct allocator {};
+
+int main()
+{
+ allocator_traits<allocator<char>>::rebind_alloc<int> a;
+}
diff --git a/test/SemaCXX/PR9908.cpp b/test/SemaCXX/PR9908.cpp
new file mode 100644
index 0000000..3b98b72
--- /dev/null
+++ b/test/SemaCXX/PR9908.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template <class _Tp, class _Up>
+struct __allocator_traits_rebind
+{
+ typedef typename _Tp::template rebind<_Up>::other type;
+};
+
+template <class Alloc>
+struct allocator_traits
+{
+ typedef Alloc allocator_type;
+ template <class T> using rebind_alloc = typename
+__allocator_traits_rebind<allocator_type, T>::type;
+ template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
+};
+
+template <class T>
+struct ReboundA {};
+
+template <class T>
+struct A
+{
+ typedef T value_type;
+
+ template <class U> struct rebind {typedef ReboundA<U> other;};
+};
+
+int main()
+{
+ allocator_traits<A<char> >::rebind_traits<double> a;
+}
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp
index 4c34447..b9e69b0 100644
--- a/test/SemaCXX/aggregate-initialization.cpp
+++ b/test/SemaCXX/aggregate-initialization.cpp
@@ -2,6 +2,8 @@
// Verify that we can't initialize non-aggregates with an initializer
// list.
+// FIXME: Note that due to a (likely) standard bug, this is technically an
+// aggregate.
struct NonAggr1 {
NonAggr1(int) { }
@@ -22,7 +24,7 @@ struct NonAggr4 {
virtual void f();
};
-NonAggr1 na1 = { 17 }; // expected-error{{non-aggregate type 'NonAggr1' cannot be initialized with an initializer list}}
+NonAggr1 na1 = { 17 };
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}}
diff --git a/test/SemaCXX/alias-template.cpp b/test/SemaCXX/alias-template.cpp
new file mode 100644
index 0000000..f29a932
--- /dev/null
+++ b/test/SemaCXX/alias-template.cpp
@@ -0,0 +1,147 @@
+// RUN: %clang_cc1 -verify -std=c++0x %s
+
+namespace RedeclAliasTypedef {
+ template<typename U> using T = int;
+ template<typename U> using T = int;
+ template<typename U> using T = T<U>;
+}
+
+namespace IllegalTypeIds {
+ template<typename U> using A = void(int n = 0); // expected-error {{default arguments can only be specified for parameters in a function declaration}}
+ template<typename U> using B = inline void(int n); // expected-error {{type name does not allow function specifier}}
+ 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 G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}}
+
+ template<typename U> using H = void(int n); // ok
+ template<typename U> using I = void(int n) &&; // ok
+}
+
+namespace IllegalSyntax {
+ template<typename Z> using ::T = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using operator int = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename ::V = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+ template<typename Z> using typename ::operator bool = void(int n); // expected-error {{name defined in alias declaration must be an identifier}}
+}
+
+namespace VariableLengthArrays {
+ template<typename Z> using T = int[42]; // ok
+
+ int n = 32;
+ template<typename Z> using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}}
+
+ const int m = 42;
+ template<typename Z> using U = int[m]; // expected-note {{previous definition}}
+ template<typename Z> using U = int[42]; // ok
+ template<typename Z> using U = int; // expected-error {{type alias template redefinition with different types ('int' vs 'int [42]')}}
+}
+
+namespace RedeclFunc {
+ int f(int, char**);
+ template<typename Z> using T = int;
+ T<char> f(int, char **); // ok
+}
+
+namespace LookupFilter {
+ namespace N { template<typename U> using S = int; }
+ using namespace N;
+ template<typename U> using S = S<U>*; // ok
+}
+
+namespace InFunctions {
+ template<typename...T> struct S0 {
+ template<typename Z> using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ U<char> u;
+ };
+
+ template<typename Z> using T1 = int;
+ template<typename Z> using T2 = int[-1]; // expected-error {{array size is negative}}
+ template<typename...T> struct S3 { // expected-note {{template parameter is declared here}}
+ template<typename Z> using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ template<typename Z> using Z = Z;
+}
+
+namespace ClassNameRedecl {
+ class C0 {
+ // FIXME: this diagnostic is pretty poor
+ template<typename U> using C0 = int; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C1 {
+ // FIXME: this diagnostic is pretty poor
+ template<typename U> using C1 = C1; // expected-error {{name defined in alias declaration must be an identifier}}
+ };
+ class C2 {
+ template<typename U> using C0 = C1; // ok
+ };
+ template<typename...T> class C3 {
+ template<typename U> using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}}
+ };
+ template<typename T> class C4 { // expected-note {{template parameter is declared here}}
+ template<typename U> using T = int; // expected-error {{declaration of 'T' shadows template parameter}}
+ };
+ class C5 {
+ class c; // expected-note {{previous definition}}
+ template<typename U> using c = int; // expected-error {{redefinition of 'c' as different kind of symbol}}
+ class d; // expected-note {{previous definition}}
+ template<typename U> using d = d; // expected-error {{redefinition of 'd' as different kind of symbol}}
+ };
+ class C6 {
+ class c { template<typename U> using C6 = int; }; // ok
+ };
+}
+
+class CtorDtorName {
+ template<typename T> using X = CtorDtorName;
+ X<int>(); // expected-error {{expected member name}}
+ ~X<int>(); // expected-error {{destructor cannot be declared using a type alias}}
+};
+
+namespace TagName {
+ template<typename Z> using S = struct { int n; }; // expected-error {{can not be defined}}
+ template<typename Z> using T = class { int n; }; // expected-error {{can not be defined}}
+ template<typename Z> using U = enum { a, b, c }; // expected-error {{can not be defined}}
+ template<typename Z> using V = struct V { int n; }; // expected-error {{redefinition of 'V' as different kind of symbol}} \
+ expected-error {{'TagName::V' can not be defined in a type alias template}} \
+ expected-note {{previous definition is here}}
+}
+
+namespace StdExample {
+ template<typename T, typename U> struct pair;
+
+ template<typename T> using handler_t = void (*)(T);
+ extern handler_t<int> ignore;
+ extern void (*ignore)(int);
+ // FIXME: we recover as if cell is an undeclared variable. the diagnostics are terrible!
+ template<typename T> using cell = pair<T*, cell<T>*>; // expected-error {{use of undeclared identifier 'cell'}} \
+ expected-error {{'T' does not refer to a value}} \
+ expected-note {{declared here}} \
+ expected-error {{expected ';' after alias declaration}}
+}
+
+namespace Access {
+ class C0 {
+ template<typename Z> using U = int; // expected-note {{declared private here}}
+ };
+ C0::U<int> v; // expected-error {{'U' is a private member}}
+ class C1 {
+ public:
+ template<typename Z> using U = int;
+ };
+ C1::U<int> w; // ok
+}
+
+namespace VoidArg {
+ template<typename Z> using V = void;
+ V<int> f(int); // ok
+ V<char> g(V<double>); // expected-error {{empty parameter list defined with a type alias of 'void' not allowed}}
+}
+
+namespace Curried {
+ template<typename T, typename U> struct S;
+ template<typename T> template<typename U> using SS = S<T, U>; // expected-error {{extraneous template parameter list in alias template declaration}}
+}
diff --git a/test/SemaCXX/anonymous-union.cpp b/test/SemaCXX/anonymous-union.cpp
index 553ae65..2dd7ab8 100644
--- a/test/SemaCXX/anonymous-union.cpp
+++ b/test/SemaCXX/anonymous-union.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
struct X {
union {
float f3;
@@ -17,7 +17,7 @@ struct X {
void test_unqual_references();
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int a;
float b;
};
@@ -125,7 +125,7 @@ typedef struct _s {
// <rdar://problem/7987650>
namespace test4 {
class A {
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int s0; // expected-note {{declared private here}}
double s1; // expected-note {{declared private here}}
union {
@@ -136,7 +136,7 @@ namespace test4 {
union {
int u0; // expected-note {{declared private here}}
double u1; // expected-note {{declared private here}}
- struct {
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
int us0; // expected-note {{declared private here}}
double us1; // expected-note {{declared private here}}
};
@@ -175,3 +175,25 @@ void foo_PR6741() {
};
}
}
+
+namespace PR8326 {
+ template <class T>
+ class Foo {
+ public:
+ Foo()
+ : x(0)
+ , y(1){
+ }
+
+ private:
+ const union { // expected-warning{{anonymous union cannot be 'const'}}
+ struct { // expected-warning{{anonymous structs are a GNU extension}}
+ T x;
+ T y;
+ };
+ T v[2];
+ };
+ };
+
+ Foo<int> baz;
+}
diff --git a/test/SemaCXX/attr-cxx0x.cpp b/test/SemaCXX/attr-cxx0x.cpp
index 40fe0e0..725f018 100644
--- a/test/SemaCXX/attr-cxx0x.cpp
+++ b/test/SemaCXX/attr-cxx0x.cpp
@@ -9,8 +9,13 @@ struct align_member {
int member [[align(8)]];
};
+typedef char align_typedef [[align(8)]];
+template<typename T> using align_alias_template = align_typedef;
+
static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong");
static_assert(alignof(align_small) == 1, "j's alignment is wrong");
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_alias_template<int>) == 8, "alias template's alignment is wrong");
diff --git a/test/SemaCXX/attr-noreturn.cpp b/test/SemaCXX/attr-noreturn.cpp
index b7d3999..eaf0d0c 100644
--- a/test/SemaCXX/attr-noreturn.cpp
+++ b/test/SemaCXX/attr-noreturn.cpp
@@ -1,5 +1,22 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Reachability tests have to come first because they get suppressed
+// if any errors have occurred.
+namespace test5 {
+ struct A {
+ __attribute__((noreturn)) void fail();
+ void nofail();
+ } a;
+
+ int &test1() {
+ a.nofail();
+ } // expected-warning {{control reaches end of non-void function}}
+
+ int &test2() {
+ a.fail();
+ }
+}
+
// PR5620
void f0() __attribute__((__noreturn__));
void f1(void (*)());
diff --git a/test/SemaCXX/attr-regparm.cpp b/test/SemaCXX/attr-regparm.cpp
index b98631a..91ee613 100644
--- a/test/SemaCXX/attr-regparm.cpp
+++ b/test/SemaCXX/attr-regparm.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin10 %s
// PR7025
struct X0 {
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 52140cb..44fa0ce 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -34,7 +34,7 @@ public:
enum E1 { en1, en2 };
- int i = 0; // expected-error {{fields can only be initialized in constructors}}
+ int i = 0; // expected-warning {{in-class initialization of non-static data member accepted as a C++0x 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}}
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
index fdda7ac..b069abc 100644
--- a/test/SemaCXX/conversion.cpp
+++ b/test/SemaCXX/conversion.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
+#include <stddef.h>
+
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
@@ -50,3 +52,12 @@ namespace test2 {
A() : x(10) {} // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
};
}
+
+void test3() {
+ int a = NULL; // expected-warning {{implicit conversion of NULL constant to integer}}
+ 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}}
+ int d;
+ d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to integer}}
+}
diff --git a/test/SemaCXX/copy-constructor-error.cpp b/test/SemaCXX/copy-constructor-error.cpp
index 9809bfc..64a7d58 100644
--- a/test/SemaCXX/copy-constructor-error.cpp
+++ b/test/SemaCXX/copy-constructor-error.cpp
@@ -13,10 +13,10 @@ void g() {
namespace PR6064 {
struct A {
A() { }
- inline A(A&, int);
+ inline A(A&, int); // expected-note {{was not a special member function}}
};
- A::A(A&, int = 0) { }
+ A::A(A&, int = 0) { } // expected-warning {{makes this constructor a copy constructor}}
void f() {
A const a;
diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
new file mode 100644
index 0000000..61aee0e
--- /dev/null
+++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct non_copiable {
+ non_copiable(const non_copiable&) = delete; // expected-note {{marked deleted here}}
+ non_copiable& operator = (const non_copiable&) = delete; // expected-note {{explicitly deleted}}
+ non_copiable() = default;
+};
+
+struct non_const_copy {
+ non_const_copy(non_const_copy&) = default; // expected-note {{not viable}}
+ non_const_copy& operator = (non_const_copy&) & = default; // expected-note {{not viable}}
+ non_const_copy& operator = (non_const_copy&) && = default; // expected-note {{not viable}}
+ non_const_copy() = default; // expected-note {{not viable}}
+};
+
+void fn1 () {
+ non_copiable nc;
+ non_copiable nc2 = nc; // expected-error {{deleted constructor}}
+ nc = nc; // expected-error {{deleted operator}}
+
+ non_const_copy ncc;
+ non_const_copy ncc2 = ncc;
+ ncc = ncc2;
+ const non_const_copy cncc;
+ non_const_copy ncc3 = cncc; // expected-error {{no matching}}
+ ncc = cncc; // expected-error {{no viable overloaded}}
+};
+
+struct non_const_derived : non_const_copy {
+ non_const_derived(const non_const_derived&) = default; // expected-error {{requires it to be non-const}}
+ non_const_derived& operator =(non_const_derived&) = default;
+};
+
+struct bad_decls {
+ bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}}
+ bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}}
+ bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}}
+ bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const' or 'volatile' qualifiers}}
+};
+
+struct A {}; struct B {};
+
+struct except_spec_a {
+ virtual ~except_spec_a() throw(A);
+ except_spec_a() throw(A);
+};
+struct except_spec_b {
+ virtual ~except_spec_b() throw(B);
+ except_spec_b() throw(B);
+};
+
+struct except_spec_d_good : except_spec_a, except_spec_b {
+ ~except_spec_d_good();
+};
+except_spec_d_good::~except_spec_d_good() = default;
+// FIXME: This should error in the virtual override check.
+// It doesn't because we generate the implicit specification later than
+// appropriate.
+struct except_spec_d_bad : except_spec_a, except_spec_b {
+ ~except_spec_d_bad() = default;
+};
+
+// FIXME: This should error because the exceptions spec doesn't match.
+struct except_spec_d_mismatch : except_spec_a, except_spec_b {
+ except_spec_d_mismatch() throw(A) = default;
+};
+struct except_spec_d_match : except_spec_a, except_spec_b {
+ except_spec_d_match() throw(A, B) = default;
+};
diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp
new file mode 100644
index 0000000..86c5fd1
--- /dev/null
+++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+void fn() = default; // expected-error {{only special member}}
+struct foo {
+ void fn() = default; // expected-error {{only special member}}
+
+ foo() = default;
+ foo(const foo&) = default;
+ foo(foo&) = default;
+ foo& operator = (const foo&) = default;
+ foo& operator = (foo&) = default;
+ ~foo() = default;
+};
+
+struct bar {
+ bar();
+ bar(const bar&);
+ bar(bar&);
+ bar& operator = (const bar&);
+ bar& operator = (bar&);
+ ~bar();
+};
+
+bar::bar() = default;
+bar::bar(const bar&) = default;
+bar::bar(bar&) = default;
+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(!__has_trivial_destructor(bar), "bar's destructor isn't trivial");
+static_assert(!__has_trivial_constructor(bar),
+ "bar's default constructor isn't trivial");
+static_assert(!__has_trivial_copy(bar), "bar has no trivial copy");
+static_assert(!__has_trivial_assign(bar), "bar has no trivial assign");
+
+void tester() {
+ foo f, g(f);
+ bar b, c(b);
+ f = g;
+ b = c;
+}
+
diff --git a/test/SemaCXX/cxx0x-delegating-ctors.cpp b/test/SemaCXX/cxx0x-delegating-ctors.cpp
index b211cb1..a3e6ff3 100644
--- a/test/SemaCXX/cxx0x-delegating-ctors.cpp
+++ b/test/SemaCXX/cxx0x-delegating-ctors.cpp
@@ -7,8 +7,9 @@ struct foo {
foo(int, int);
foo(bool);
foo(char);
- foo(float*);
- foo(float&);
+ foo(const float*);
+ foo(const float&);
+ foo(void*);
};
// Good
@@ -21,16 +22,27 @@ foo::foo () : foo(-1) {
foo::foo (int, int) : foo() {
}
-foo::foo (bool) : foo(true) { // expected-error{{delegates to itself}}
+foo::foo (bool) : foo(true) { // expected-error{{creates a delegation cycle}}
}
// Good
-foo::foo (float* f) : foo(*f) {
+foo::foo (const float* f) : foo(*f) { // expected-note{{it delegates to}}
}
-// FIXME: This should error
-foo::foo (float &f) : foo(&f) {
+foo::foo (const float &f) : foo(&f) { //expected-error{{creates a delegation cycle}} \
+ //expected-note{{which delegates to}}
}
foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}}
}
+
+// This should not cause an infinite loop
+foo::foo (void*) : foo(4.0f) {
+}
+
+struct deleted_dtor {
+ ~deleted_dtor() = delete; // expected-note{{function has been explicitly marked deleted here}}
+ deleted_dtor();
+ deleted_dtor(int) : deleted_dtor() // expected-error{{attempt to use a deleted function}}
+ {}
+};
diff --git a/test/SemaCXX/cxx0x-deleted-default-ctor.cpp b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
new file mode 100644
index 0000000..dcb6ba2
--- /dev/null
+++ b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct non_trivial {
+ non_trivial();
+ non_trivial(const non_trivial&);
+ non_trivial& operator = (const non_trivial&);
+ ~non_trivial();
+};
+
+union bad_union { // expected-note {{marked deleted here}}
+ non_trivial nt;
+};
+bad_union u; // expected-error {{call to deleted constructor}}
+union bad_union2 { // expected-note {{marked deleted here}}
+ const int i;
+};
+bad_union2 u2; // expected-error {{call to deleted constructor}}
+
+struct bad_anon { // expected-note {{marked deleted here}}
+ union {
+ non_trivial nt;
+ };
+};
+bad_anon a; // expected-error {{call to deleted constructor}}
+struct bad_anon2 { // expected-note {{marked deleted here}}
+ union {
+ const int i;
+ };
+};
+bad_anon2 a2; // expected-error {{call to deleted constructor}}
+
+// This would be great except that we implement
+union good_union {
+ const int i;
+ float f;
+};
+good_union gu;
+struct good_anon {
+ union {
+ const int i;
+ float f;
+ };
+};
+good_anon ga;
+
+struct good : non_trivial {
+ non_trivial nt;
+};
+good g;
+
+struct bad_const { // expected-note {{marked deleted here}}
+ const good g;
+};
+bad_const bc; // expected-error {{call to deleted constructor}}
+
+struct good_const {
+ const non_trivial nt;
+};
+good_const gc;
+
+struct no_default {
+ no_default() = delete;
+};
+struct no_dtor {
+ ~no_dtor() = delete;
+};
+
+struct bad_field_default { // expected-note {{marked deleted here}}
+ no_default nd;
+};
+bad_field_default bfd; // expected-error {{call to deleted constructor}}
+struct bad_base_default : no_default { // expected-note {{marked deleted here}}
+};
+bad_base_default bbd; // expected-error {{call to deleted constructor}}
+
+struct bad_field_dtor { // expected-note {{marked deleted here}}
+ no_dtor nd;
+};
+bad_field_dtor bfx; // expected-error {{call to deleted constructor}}
+struct bad_base_dtor : no_dtor { // expected-note {{marked deleted here}}
+};
+bad_base_dtor bbx; // expected-error {{call to deleted constructor}}
+
+struct ambiguous_default {
+ ambiguous_default();
+ ambiguous_default(int = 2);
+};
+struct has_amb_field { // expected-note {{marked deleted here}}
+ ambiguous_default ad;
+};
+has_amb_field haf; // expected-error {{call to deleted constructor}}
+
+class inaccessible_default {
+ inaccessible_default();
+};
+struct has_inacc_field { // expected-note {{marked deleted here}}
+ inaccessible_default id;
+};
+has_inacc_field hif; // expected-error {{call to deleted constructor}}
+
+class friend_default {
+ friend struct has_friend;
+ friend_default();
+};
+struct has_friend {
+ friend_default fd;
+};
+has_friend hf;
+
+struct defaulted_delete {
+ no_default nd;
+ defaulted_delete() = default; // expected-note {{marked deleted here}}
+};
+defaulted_delete dd; // expected-error {{call to deleted constructor}}
+
+struct late_delete {
+ no_default nd;
+ late_delete();
+};
+late_delete::late_delete() = default; // expected-error {{would delete it}}
diff --git a/test/SemaCXX/cxx0x-nontrivial-union.cpp b/test/SemaCXX/cxx0x-nontrivial-union.cpp
new file mode 100644
index 0000000..666e64b
--- /dev/null
+++ b/test/SemaCXX/cxx0x-nontrivial-union.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+struct non_trivial {
+ non_trivial();
+ non_trivial(const non_trivial&);
+ non_trivial& operator = (const non_trivial&);
+ ~non_trivial();
+};
+
+union u {
+ non_trivial nt;
+};
+
+union bad {
+ static int i; // expected-error {{static data member}}
+};
+
+struct s {
+ union {
+ non_trivial nt;
+ };
+};
diff --git a/test/SemaCXX/default-arg-special-member.cpp b/test/SemaCXX/default-arg-special-member.cpp
new file mode 100644
index 0000000..8402d382
--- /dev/null
+++ b/test/SemaCXX/default-arg-special-member.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wno-default-arg-special-member -Werror -fsyntax-only %s
+
+class foo {
+ foo(foo&, int); // expected-note {{was not a special member function}}
+ foo(int); // expected-note {{was not a special member function}}
+ foo(const foo&); // expected-note {{was a copy constructor}}
+};
+
+foo::foo(foo&, int = 0) { } // expected-warning {{makes this constructor a copy constructor}}
+foo::foo(int = 0) { } // expected-warning {{makes this constructor a default constructor}}
+foo::foo(const foo& = 0) { } //expected-warning {{makes this constructor a default constructor}}
diff --git a/test/SemaCXX/default-constructor-initializers.cpp b/test/SemaCXX/default-constructor-initializers.cpp
index 9da8556..e783f49 100644
--- a/test/SemaCXX/default-constructor-initializers.cpp
+++ b/test/SemaCXX/default-constructor-initializers.cpp
@@ -59,3 +59,10 @@ namespace PR7948 {
struct S { const int x; ~S(); };
const S arr[2] = { { 42 } };
}
+
+// This is valid
+union U {
+ const int i;
+ float f;
+};
+U u;
diff --git a/test/SemaCXX/defaulted-ctor-loop.cpp b/test/SemaCXX/defaulted-ctor-loop.cpp
new file mode 100644
index 0000000..6a41972
--- /dev/null
+++ b/test/SemaCXX/defaulted-ctor-loop.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// WARNING: This test may recurse infinitely if failing.
+
+struct foo;
+struct bar {
+ bar(foo&);
+};
+struct foo {
+ bar b;
+ foo()
+ : b(b) // expected-warning{{field is uninitialized}}
+ {}
+};
diff --git a/test/SemaCXX/deleted-function-extension.cpp b/test/SemaCXX/deleted-function-extension.cpp
deleted file mode 100644
index fdf5ac8..0000000
--- a/test/SemaCXX/deleted-function-extension.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
-
-struct A {
- A(const A&) = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
- A& operator=(const A&) = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
-};
-
-void f() = delete; // expected-warning {{deleted function definition accepted as a C++0x extension}}
diff --git a/test/SemaCXX/deleted-function.cpp b/test/SemaCXX/deleted-function.cpp
index b3e1296..6a8965c 100644
--- a/test/SemaCXX/deleted-function.cpp
+++ b/test/SemaCXX/deleted-function.cpp
@@ -7,9 +7,8 @@ void fn() = delete; // expected-note {{candidate function has been explicitly de
void fn2(); // expected-note {{previous declaration is here}}
void fn2() = delete; // expected-error {{deleted definition must be first declaration}}
-void fn3() = delete;
-void fn3() {
- // FIXME: This definition should be invalid.
+void fn3() = delete; // expected-note {{previous definition is here}}
+void fn3() { // expected-error {{redefinition}}
}
void ov(int) {} // expected-note {{candidate function}}
diff --git a/test/SemaCXX/dependent-noexcept-unevaluated.cpp b/test/SemaCXX/dependent-noexcept-unevaluated.cpp
new file mode 100644
index 0000000..5bf6f9e
--- /dev/null
+++ b/test/SemaCXX/dependent-noexcept-unevaluated.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x %s
+
+template <class T>
+T&&
+declval() noexcept;
+
+template <class T>
+struct some_trait
+{
+ static const bool value = false;
+};
+
+template <class T>
+void swap(T& x, T& y) noexcept(some_trait<T>::value)
+{
+ T tmp(static_cast<T&&>(x));
+ x = static_cast<T&&>(y);
+ y = static_cast<T&&>(tmp);
+}
+
+template <class T, unsigned N>
+struct array
+{
+ T data[N];
+
+ void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
+};
+
+struct DefaultOnly
+{
+ DefaultOnly() = default;
+ DefaultOnly(const DefaultOnly&) = delete;
+ DefaultOnly& operator=(const DefaultOnly&) = delete;
+ ~DefaultOnly() = default;
+};
+
+int main()
+{
+ array<DefaultOnly, 1> a, b;
+}
+
diff --git a/test/SemaCXX/dependent-types.cpp b/test/SemaCXX/dependent-types.cpp
index d9b5323..053e79b 100644
--- a/test/SemaCXX/dependent-types.cpp
+++ b/test/SemaCXX/dependent-types.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++0x %s
+
+template<typename T> using U = int &;
template<typename T, int Size> void f() {
T x1;
@@ -7,4 +9,5 @@ template<typename T, int Size> void f() {
T x4[]; // expected-error{{needs an explicit size or an initializer}}
T x5[Size];
int x6[Size];
+ U<T> x7; // expected-error{{declaration of reference variable 'x7' requires an initializer}}
}
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 01f21de..ec0539b 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wnon-virtual-dtor -verify %s
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -verify %s
class A {
public:
~A();
@@ -173,6 +173,179 @@ template<class T> class TS2 { // expected-warning {{'nonvirtualdtor::TS2<int>' h
TS2<int> foo; // expected-note {{instantiation}}
}
+namespace dnvd { // delete-non-virtual-dtor warning
+struct NP {};
+
+struct B { // expected-warning {{has virtual functions but non-virtual destructor}}
+ virtual void foo();
+};
+
+struct D: B {}; // expected-warning {{has virtual functions but non-virtual destructor}}
+
+struct F final: B {}; // expected-warning {{has virtual functions but non-virtual destructor}}
+
+struct VB {
+ virtual void foo();
+ virtual ~VB();
+};
+
+struct VD: VB {};
+
+struct VF final: VB {};
+
+template <typename T>
+class simple_ptr {
+public:
+ simple_ptr(T* t): _ptr(t) {}
+ ~simple_ptr() { delete _ptr; } // \
+ // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}} \
+ // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ T& operator*() const { return *_ptr; }
+private:
+ T* _ptr;
+};
+
+template <typename T>
+class simple_ptr2 {
+public:
+ simple_ptr2(T* t): _ptr(t) {}
+ ~simple_ptr2() { delete _ptr; } // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ T& operator*() const { return *_ptr; }
+private:
+ T* _ptr;
+};
+
+void use(B&);
+void use(VB&);
+
+void nowarnstack() {
+ B b; use(b);
+ D d; use(d);
+ F f; use(f);
+ VB vb; use(vb);
+ VD vd; use(vd);
+ VF vf; use(vf);
+}
+
+void nowarnnonpoly() {
+ {
+ NP* np = new NP();
+ delete np;
+ }
+ {
+ NP* np = new NP[4];
+ delete[] np;
+ }
+}
+
+void nowarnarray() {
+ {
+ B* b = new B[4];
+ delete[] b;
+ }
+ {
+ D* d = new D[4];
+ delete[] d;
+ }
+ {
+ VB* vb = new VB[4];
+ delete[] vb;
+ }
+ {
+ VD* vd = new VD[4];
+ delete[] vd;
+ }
+}
+
+template <typename T>
+void nowarntemplate() {
+ {
+ T* t = new T();
+ delete t;
+ }
+ {
+ T* t = new T[4];
+ delete[] t;
+ }
+}
+
+void nowarn0() {
+ {
+ F* f = new F();
+ delete f;
+ }
+ {
+ VB* vb = new VB();
+ delete vb;
+ }
+ {
+ VB* vb = new VD();
+ delete vb;
+ }
+ {
+ VD* vd = new VD();
+ delete vd;
+ }
+ {
+ VF* vf = new VF();
+ delete vf;
+ }
+}
+
+void warn0() {
+ {
+ B* b = new B();
+ delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ }
+ {
+ B* b = new D();
+ delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ }
+ {
+ D* d = new D();
+ delete d; // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ }
+}
+
+void nowarn1() {
+ {
+ simple_ptr<F> f(new F());
+ use(*f);
+ }
+ {
+ simple_ptr<VB> vb(new VB());
+ use(*vb);
+ }
+ {
+ simple_ptr<VB> vb(new VD());
+ use(*vb);
+ }
+ {
+ simple_ptr<VD> vd(new VD());
+ use(*vd);
+ }
+ {
+ simple_ptr<VF> vf(new VF());
+ use(*vf);
+ }
+}
+
+void warn1() {
+ {
+ simple_ptr<B> b(new B()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr<dnvd::B>::~simple_ptr' requested here}}
+ use(*b);
+ }
+ {
+ simple_ptr2<B> b(new D()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr2<dnvd::B>::~simple_ptr2' requested here}}
+ use(*b);
+ }
+ {
+ simple_ptr<D> d(new D()); // expected-note {{in instantiation of member function 'dnvd::simple_ptr<dnvd::D>::~simple_ptr' requested here}}
+ use(*d);
+ }
+}
+}
+
namespace PR9238 {
class B { public: ~B(); };
class C : virtual B { public: ~C() { } };
diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp
index 8c4bfe7..fc871cf 100644
--- a/test/SemaCXX/enum-scoped.cpp
+++ b/test/SemaCXX/enum-scoped.cpp
@@ -109,3 +109,13 @@ void PR9333() {
scoped_enum e = scoped_enum::yes;
if (e == scoped_enum::no) { }
}
+
+// <rdar://problem/9366066>
+namespace rdar9366066 {
+ enum class X : unsigned { value };
+
+ void f(X x) {
+ x % X::value; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'rdar9366066::X')}}
+ x % 8; // expected-error{{invalid operands to binary expression ('rdar9366066::X' and 'int')}}
+ }
+}
diff --git a/test/SemaCXX/expressions.cpp b/test/SemaCXX/expressions.cpp
index c4e9dcc..95ece48 100644
--- a/test/SemaCXX/expressions.cpp
+++ b/test/SemaCXX/expressions.cpp
@@ -32,3 +32,34 @@ namespace test1 {
bar(x += E_zero); // expected-error {{incompatible type}}
}
}
+
+int test2(int x) {
+ return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+
+ return x && sizeof(int) == 4; // no warning, RHS is logical op.
+ return x && true;
+ return x && false;
+ return x || true;
+ return x || false;
+
+ return x && (unsigned)0; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+
+ return x || (unsigned)1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+
+ return x || 0; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || 1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || -1; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || 5; // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x && 0; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && 1; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && -1; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && 5; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x || (0); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || (1); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || (-1); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x || (5); // expected-warning {{use of logical || with constant operand; switch to bitwise | or remove constant}}
+ return x && (0); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && (1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && (-1); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+ return x && (5); // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
+}
diff --git a/test/SemaCXX/generalized-initializers.cpp b/test/SemaCXX/generalized-initializers.cpp
new file mode 100644
index 0000000..ec37a0c
--- /dev/null
+++ b/test/SemaCXX/generalized-initializers.cpp
@@ -0,0 +1,174 @@
+// RUN: %clang_cc1 -std=c++0x -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 {
+
+ void initialization() {
+ { const int a{}; static_assert(a == 0, ""); }
+ { const int a = {}; static_assert(a == 0, ""); }
+ { const int a{1}; static_assert(a == 1, ""); }
+ { const int a = {1}; static_assert(a == 1, ""); }
+ { const int a{1, 2}; } // expected-error {{excess elements}}
+ { const int a = {1, 2}; } // expected-error {{excess elements}}
+ { const short a{100000}; } // expected-error {{narrowing conversion}}
+ { const short a = {100000}; } // expected-error {{narrowing conversion}}
+ }
+
+ int function_call() {
+ void takes_int(int);
+ takes_int({1});
+
+ int ar[10];
+ (void) ar[{1}]; // expected-error {{initializer list is illegal with the built-in index operator}}
+
+ return {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}) {}
+ }
+
+ struct A {
+ int i;
+ A() : i{1} {}
+ };
+
+}
+
+namespace objects {
+
+ template <int N>
+ struct A {
+ A() { static_assert(N == 0, ""); }
+ A(int, double) { static_assert(N == 1, ""); }
+ A(int, int) { static_assert(N == 2, ""); }
+ A(std::initializer_list<int>) { static_assert(N == 3, ""); }
+ };
+
+ void initialization() {
+ { A<0> a{}; }
+ { A<0> a = {}; }
+ { A<1> a{1, 1.0}; }
+ { A<1> a = {1, 1.0}; }
+ { 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}; }
+ }
+
+ 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});
+
+}
diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp
new file mode 100644
index 0000000..81babc0
--- /dev/null
+++ b/test/SemaCXX/implicit-exception-spec.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++0x -Wall %s
+
+template<bool b> struct ExceptionIf { static int f(); };
+template<> struct ExceptionIf<false> { typedef int f; };
+
+// The exception specification of a defaulted default constructor depends on
+// the contents of in-class member initializers. However, the in-class member
+// initializers can depend on the exception specification of the constructor,
+// since the class is considered complete within them. We reject any such cases.
+namespace InClassInitializers {
+ // Noexcept::Noexcept() is implicitly declared as noexcept(false), because it
+ // directly invokes ThrowSomething(). However...
+ //
+ // If noexcept(Noexcept()) is false, then Noexcept() is a constant expression,
+ // so noexcept(Noexcept()) is true. But if noexcept(Noexcept()) is true, then
+ // Noexcept::Noexcept is not declared constexpr, therefore noexcept(Noexcept())
+ // is false.
+ bool ThrowSomething() noexcept(false);
+ struct ConstExpr {
+ bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{exception specification is not available until end of class definition}}
+ };
+ // We can use it now.
+ bool w = noexcept(ConstExpr());
+
+ // Much more obviously broken: we can't parse the initializer without already
+ // knowing whether it produces a noexcept expression.
+ struct TemplateArg {
+ int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{exception specification is not available until end of class definition}}
+ };
+ bool x = noexcept(TemplateArg());
+
+ // And within a nested class.
+ struct Nested {
+ struct Inner {
+ int n = ExceptionIf<noexcept(Nested())>::f(); // expected-error {{exception specification is not available until end of class definition}}
+ } inner;
+ };
+ bool y = noexcept(Nested());
+ bool z = noexcept(Nested::Inner());
+}
+
+// FIXME:
+// The same problem arises in delayed parsing of exception specifications,
+// which clang does not yet support.
+namespace ExceptionSpecification {
+ struct Nested { // expected-note {{not complete}}
+ struct T {
+ T() noexcept(!noexcept(Nested())); // expected-error {{incomplete type}}
+ } t;
+ };
+}
+
+// FIXME:
+// 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 T {
+ T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to deleted constructor}}
+ } t;
+ };
+}
diff --git a/test/SemaCXX/implicit-member-functions.cpp b/test/SemaCXX/implicit-member-functions.cpp
index 5333094..8451739 100644
--- a/test/SemaCXX/implicit-member-functions.cpp
+++ b/test/SemaCXX/implicit-member-functions.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A { };
-A::A() { } // expected-error {{definition of implicitly declared constructor}}
+A::A() { } // expected-error {{definition of implicitly declared default constructor}}
struct B { };
B::B(const B&) { } // expected-error {{definition of implicitly declared copy constructor}}
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 68af415..981bae7 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -124,10 +124,10 @@ namespace PR9025 {
return fun.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it with no arguments?}}
}
- S fun2(); // expected-note{{possibly valid overload here}}
- S fun2(int i); // expected-note{{possibly valid overload here}}
+ S fun2();
+ S fun2(int i);
int g2() {
- return fun2.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it?}}
+ return fun2.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it with no arguments?}}
}
S fun3(int i=0);
@@ -140,4 +140,10 @@ namespace PR9025 {
int g4() {
return fun4.x; // expected-error{{base of member reference is a function; perhaps you meant to call it?}}
}
+
+ S fun5(int i); // expected-note{{possibly valid overload here}}
+ S fun5(float f); // expected-note{{possibly valid overload here}}
+ int g5() {
+ return fun5.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it?}}
+ }
}
diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp
new file mode 100644
index 0000000..1b8c523
--- /dev/null
+++ b/test/SemaCXX/member-init.cpp
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++0x -Wall %s
+
+struct Bitfield {
+ int n : 3 = 7; // expected-error {{bitfield member cannot have an in-class initializer}}
+};
+
+int a;
+class NoWarning {
+ int &n = a;
+public:
+ int &GetN() { return n; }
+};
+
+bool b();
+int k;
+struct Recurse {
+ int &n = b() ? Recurse().n : k; // ok
+};
+
+struct UnknownBound {
+ int as[] = { 1, 2, 3 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+ int bs[4] = { 4, 5, 6, 7 };
+ int cs[] = { 8, 9, 10 }; // expected-error {{array bound cannot be deduced from an in-class initializer}}
+};
+
+template<int n> struct T { static const int B; };
+template<> struct T<2> { template<int C, int D> using B = int; };
+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}}
+};
+
+struct ThrowCtor { ThrowCtor(int) noexcept(false); };
+struct NoThrowCtor { NoThrowCtor(int) noexcept(true); };
+
+struct Throw { ThrowCtor tc = 42; };
+struct NoThrow { NoThrowCtor tc = 42; };
+
+static_assert(!noexcept(Throw()), "incorrect exception specification");
+static_assert(noexcept(NoThrow()), "incorrect exception specification");
+
+struct CheckExcSpec {
+ CheckExcSpec() noexcept(true) = default;
+ int n = 0;
+};
+struct CheckExcSpecFail {
+ CheckExcSpecFail() noexcept(true) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}}
+ ThrowCtor tc = 123;
+};
diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp
index 31c651a..de3b211 100644
--- a/test/SemaCXX/member-pointer.cpp
+++ b/test/SemaCXX/member-pointer.cpp
@@ -271,3 +271,28 @@ namespace rdar8358512 {
template void B<int>::test0b(); // expected-note {{in instantiation}}
}
+
+namespace PR9973 {
+ template<class R, class T> struct dm
+ {
+ 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>'}}
+
+ template<class U> int operator()(U u)
+ { call(u); } // expected-note{{in instantiation of}}
+ };
+
+ template<class R, class T>
+ dm<R, T> mem_fn(R T::*) ;
+
+ struct test
+ { int nullary_v(); };
+
+ void f()
+ {
+ test* t;
+ mem_fn(&test::nullary_v)(t); // expected-note{{in instantiation of}}
+ }
+}
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp
index 84c80aa..d69af58 100644
--- a/test/SemaCXX/nullptr.cpp
+++ b/test/SemaCXX/nullptr.cpp
@@ -60,6 +60,10 @@ nullptr_t f(nullptr_t null)
// You can reinterpret_cast nullptr to an integer.
(void)reinterpret_cast<uintptr_t>(nullptr);
+ (void)reinterpret_cast<uintptr_t>(*pn);
+
+ int *ip = *pn;
+ if (*pn) { }
// You can throw nullptr.
throw nullptr;
@@ -104,3 +108,56 @@ namespace test3 {
f("%p", nullptr);
}
}
+
+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
+
+namespace overloading {
+ int &f1(int*);
+ float &f1(bool);
+
+ void test_f1() {
+ int &ir = (f1)(nullptr);
+ }
+
+ struct ConvertsToNullPtr {
+ operator nullptr_t() const;
+ };
+
+ void test_conversion(ConvertsToNullPtr ctn) {
+ (void)(ctn == ctn);
+ (void)(ctn != ctn);
+ (void)(ctn <= ctn);
+ (void)(ctn >= ctn);
+ (void)(ctn < ctn);
+ (void)(ctn > ctn);
+ }
+}
+
+namespace templates {
+ template<typename T, nullptr_t Value>
+ struct X {
+ X() { ptr = Value; }
+
+ T *ptr;
+ };
+
+ X<int, nullptr> x;
+
+
+ template<int (*fp)(int), int* p, int A::* pmd, int (A::*pmf)(int)>
+ struct X2 {};
+
+ X2<nullptr, nullptr, nullptr, nullptr> x2;
+}
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 81a88a3..9cc4899 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -503,3 +503,25 @@ namespace rdar8499524 {
g(W());
}
}
+
+namespace rdar9173984 {
+ template <typename T, unsigned long N> int &f(const T (&)[N]);
+ template <typename T> float &f(const T *);
+
+ void test() {
+ int arr[2] = {0, 0};
+ int *arrp = arr;
+ int &ir = f(arr);
+ float &fr = f(arrp);
+ }
+}
+
+namespace PR9507 {
+ void f(int * const&); // expected-note{{candidate function}}
+ void f(int const(&)[1]); // expected-note{{candidate function}}
+
+ int main() {
+ int n[1];
+ f(n); // expected-error{{call to 'f' is ambiguous}}
+ }
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 44d013f..462d023 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -33,7 +33,7 @@ struct A {
A make_A();
-bool operator==(A&, Z&); // expected-note 2{{candidate function}}
+bool operator==(A&, Z&); // expected-note 3{{candidate function}}
void h(A a, const A ac, Z z) {
make_A() == z;
@@ -68,7 +68,7 @@ struct E2 {
};
// C++ [over.match.oper]p3 - enum restriction.
-float& operator==(E1, E2);
+float& operator==(E1, E2); // expected-note{{candidate function}}
void enum_test(Enum1 enum1, Enum2 enum2, E1 e1, E2 e2, Enum1 next_enum1) {
float &f1 = (e1 == e2);
@@ -85,8 +85,8 @@ class pr5244_foo
pr5244_foo(char);
};
-bool operator==(const pr5244_foo& s1, const pr5244_foo& s2);
-bool operator==(char c, const pr5244_foo& s);
+bool operator==(const pr5244_foo& s1, const pr5244_foo& s2); // expected-note{{candidate function}}
+bool operator==(char c, const pr5244_foo& s); // expected-note{{candidate function}}
enum pr5244_bar
{
@@ -399,3 +399,12 @@ namespace rdar9136502 {
y << x.i; // expected-error{{a bound member function may only be called}}
}
}
+
+namespace rdar9222009 {
+class StringRef {
+ inline bool operator==(StringRef LHS, StringRef RHS) { // expected-error{{overloaded 'operator==' must be a binary operator (has 3 parameters)}}
+ return !(LHS == RHS); // expected-error{{invalid operands to binary expression ('rdar9222009::StringRef' and 'rdar9222009::StringRef')}}
+ }
+};
+
+}
diff --git a/test/SemaCXX/redeclared-alias-template.cpp b/test/SemaCXX/redeclared-alias-template.cpp
new file mode 100644
index 0000000..b368fcf
--- /dev/null
+++ b/test/SemaCXX/redeclared-alias-template.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template<typename T> using A = int; // expected-note 2{{previous}}
+template<typename T> using A = char; // expected-error {{type alias template redefinition with different types ('char' vs 'int')}}
+template<typename T1, typename T2> using A = T1; // expected-error {{too many template parameters in template redeclaration}}
+
+template<typename T1, typename T2> using B = T1; // expected-note {{previous}}
+template<typename T2, typename T1> using B = T1; // expected-error {{type alias template redefinition with different types}}
+
+
+template<typename> struct S;
+template<template<typename> class F> using FInt = F<int>;
+template<typename X> using SXRInt = FInt<S<X>::template R>;
+template<typename X> using SXRInt = typename S<X>::template R<int>; // ok, redeclaration.
+
+template<template<typename> class> struct TT;
+
+namespace FilterLookup {
+ TT<A> f(); // expected-note {{previous declaration is here}}
+
+ template<typename> using A = int;
+ TT<A> f(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
+}
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index f526249..68005a5 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding -Wundefined-reinterpret-cast %s
#include <stdint.h>
@@ -116,3 +116,163 @@ namespace PR9564 {
__attribute((ext_vector_type(4))) typedef float v4;
float& w(v4 &a) { return reinterpret_cast<float&>(a[1]); } // expected-error {{not allowed}}
}
+
+void dereference_reinterpret_cast() {
+ struct A {};
+ typedef A A2;
+ class B {};
+ typedef B B2;
+ A a;
+ B b;
+ A2 a2;
+ B2 b2;
+ long l;
+ double d;
+ float f;
+ char c;
+ unsigned char uc;
+ void* v_ptr;
+ (void)reinterpret_cast<double&>(l); // expected-warning {{reinterpret_cast from 'long' to 'double &' has undefined behavior}}
+ (void)*reinterpret_cast<double*>(&l); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'long *' has undefined behavior}}
+ (void)reinterpret_cast<double&>(f); // expected-warning {{reinterpret_cast from 'float' to 'double &' has undefined behavior}}
+ (void)*reinterpret_cast<double*>(&f); // expected-warning {{dereference of type 'double *' that was reinterpret_cast from type 'float *' has undefined behavior}}
+ (void)reinterpret_cast<float&>(l); // expected-warning {{reinterpret_cast from 'long' to 'float &' has undefined behavior}}
+ (void)*reinterpret_cast<float*>(&l); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'long *' has undefined behavior}}
+ (void)reinterpret_cast<float&>(d); // expected-warning {{reinterpret_cast from 'double' to 'float &' has undefined behavior}}
+ (void)*reinterpret_cast<float*>(&d); // expected-warning {{dereference of type 'float *' that was reinterpret_cast from type 'double *' has undefined behavior}}
+
+ // TODO: add warning for tag types
+ (void)reinterpret_cast<A&>(b);
+ (void)*reinterpret_cast<A*>(&b);
+ (void)reinterpret_cast<B&>(a);
+ (void)*reinterpret_cast<B*>(&a);
+ (void)reinterpret_cast<A2&>(b2);
+ (void)*reinterpret_cast<A2*>(&b2);
+ (void)reinterpret_cast<B2&>(a2);
+ (void)*reinterpret_cast<B2*>(&a2);
+
+ // Casting to itself is allowed
+ (void)reinterpret_cast<A&>(a);
+ (void)*reinterpret_cast<A*>(&a);
+ (void)reinterpret_cast<B&>(b);
+ (void)*reinterpret_cast<B*>(&b);
+ (void)reinterpret_cast<long&>(l);
+ (void)*reinterpret_cast<long*>(&l);
+ (void)reinterpret_cast<double&>(d);
+ (void)*reinterpret_cast<double*>(&d);
+ (void)reinterpret_cast<char&>(c);
+ (void)*reinterpret_cast<char*>(&c);
+
+ // Casting to and from chars are allowable
+ (void)reinterpret_cast<A&>(c);
+ (void)*reinterpret_cast<A*>(&c);
+ (void)reinterpret_cast<B&>(c);
+ (void)*reinterpret_cast<B*>(&c);
+ (void)reinterpret_cast<long&>(c);
+ (void)*reinterpret_cast<long*>(&c);
+ (void)reinterpret_cast<double&>(c);
+ (void)*reinterpret_cast<double*>(&c);
+ (void)reinterpret_cast<char&>(l);
+ (void)*reinterpret_cast<char*>(&l);
+ (void)reinterpret_cast<char&>(d);
+ (void)*reinterpret_cast<char*>(&d);
+ (void)reinterpret_cast<char&>(f);
+ (void)*reinterpret_cast<char*>(&f);
+
+ // Casting from void pointer.
+ (void)*reinterpret_cast<A*>(v_ptr);
+ (void)*reinterpret_cast<B*>(v_ptr);
+ (void)*reinterpret_cast<long*>(v_ptr);
+ (void)*reinterpret_cast<double*>(v_ptr);
+ (void)*reinterpret_cast<float*>(v_ptr);
+
+ // Casting to void pointer
+ (void)*reinterpret_cast<void*>(&a);
+ (void)*reinterpret_cast<void*>(&b);
+ (void)*reinterpret_cast<void*>(&l);
+ (void)*reinterpret_cast<void*>(&d);
+ (void)*reinterpret_cast<void*>(&f);
+}
+
+void reinterpret_cast_whitelist () {
+ // the dynamic type of the object
+ int a;
+ float b;
+ (void)reinterpret_cast<int&>(a);
+ (void)*reinterpret_cast<int*>(&a);
+ (void)reinterpret_cast<float&>(b);
+ (void)*reinterpret_cast<float*>(&b);
+
+ // a cv-qualified version of the dynamic object
+ (void)reinterpret_cast<const int&>(a);
+ (void)*reinterpret_cast<const int*>(&a);
+ (void)reinterpret_cast<volatile int&>(a);
+ (void)*reinterpret_cast<volatile int*>(&a);
+ (void)reinterpret_cast<const volatile int&>(a);
+ (void)*reinterpret_cast<const volatile int*>(&a);
+ (void)reinterpret_cast<const float&>(b);
+ (void)*reinterpret_cast<const float*>(&b);
+ (void)reinterpret_cast<volatile float&>(b);
+ (void)*reinterpret_cast<volatile float*>(&b);
+ (void)reinterpret_cast<const volatile float&>(b);
+ (void)*reinterpret_cast<const volatile float*>(&b);
+
+ // a type that is the signed or unsigned type corresponding to the dynamic
+ // type of the object
+ signed d;
+ unsigned e;
+ (void)reinterpret_cast<signed&>(d);
+ (void)*reinterpret_cast<signed*>(&d);
+ (void)reinterpret_cast<signed&>(e);
+ (void)*reinterpret_cast<signed*>(&e);
+ (void)reinterpret_cast<unsigned&>(d);
+ (void)*reinterpret_cast<unsigned*>(&d);
+ (void)reinterpret_cast<unsigned&>(e);
+ (void)*reinterpret_cast<unsigned*>(&e);
+
+ // a type that is the signed or unsigned type corresponding a cv-qualified
+ // version of the dynamic type the object
+ (void)reinterpret_cast<const signed&>(d);
+ (void)*reinterpret_cast<const signed*>(&d);
+ (void)reinterpret_cast<const signed&>(e);
+ (void)*reinterpret_cast<const signed*>(&e);
+ (void)reinterpret_cast<const unsigned&>(d);
+ (void)*reinterpret_cast<const unsigned*>(&d);
+ (void)reinterpret_cast<const unsigned&>(e);
+ (void)*reinterpret_cast<const unsigned*>(&e);
+ (void)reinterpret_cast<volatile signed&>(d);
+ (void)*reinterpret_cast<volatile signed*>(&d);
+ (void)reinterpret_cast<volatile signed&>(e);
+ (void)*reinterpret_cast<volatile signed*>(&e);
+ (void)reinterpret_cast<volatile unsigned&>(d);
+ (void)*reinterpret_cast<volatile unsigned*>(&d);
+ (void)reinterpret_cast<volatile unsigned&>(e);
+ (void)*reinterpret_cast<volatile unsigned*>(&e);
+ (void)reinterpret_cast<const volatile signed&>(d);
+ (void)*reinterpret_cast<const volatile signed*>(&d);
+ (void)reinterpret_cast<const volatile signed&>(e);
+ (void)*reinterpret_cast<const volatile signed*>(&e);
+ (void)reinterpret_cast<const volatile unsigned&>(d);
+ (void)*reinterpret_cast<const volatile unsigned*>(&d);
+ (void)reinterpret_cast<const volatile unsigned&>(e);
+ (void)*reinterpret_cast<const volatile unsigned*>(&e);
+
+ // an aggregate or union type that includes one of the aforementioned types
+ // among its members (including, recursively, a member of a subaggregate or
+ // contained union)
+ // TODO: checking is not implemented for tag types
+
+ // a type that is a (possible cv-qualified) base class type of the dynamic
+ // type of the object
+ // TODO: checking is not implemented for tag types
+
+ // a char or unsigned char type
+ (void)reinterpret_cast<char&>(a);
+ (void)*reinterpret_cast<char*>(&a);
+ (void)reinterpret_cast<unsigned char&>(a);
+ (void)*reinterpret_cast<unsigned char*>(&a);
+ (void)reinterpret_cast<char&>(b);
+ (void)*reinterpret_cast<char*>(&b);
+ (void)reinterpret_cast<unsigned char&>(b);
+ (void)*reinterpret_cast<unsigned char*>(&b);
+}
diff --git a/test/SemaCXX/return.cpp b/test/SemaCXX/return.cpp
index af7f50c..b457f6a 100644
--- a/test/SemaCXX/return.cpp
+++ b/test/SemaCXX/return.cpp
@@ -39,6 +39,11 @@ g();
char* const h(); // expected-warning{{'const' type qualifier on return type has no effect}}
char* volatile i(); // expected-warning{{'volatile' type qualifier on return type has no effect}}
+char*
+volatile // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+const
+j();
+
const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
}
@@ -53,3 +58,14 @@ namespace PR9328 {
class foo {
operator int * const ();
};
+
+namespace PR10057 {
+ struct S {
+ ~S();
+ };
+
+ template <class VarType>
+ void Test(const VarType& value) {
+ return S() = value;
+ }
+}
diff --git a/test/SemaCXX/struct-class-redecl.cpp b/test/SemaCXX/struct-class-redecl.cpp
index d3d6d79..5c59578 100644
--- a/test/SemaCXX/struct-class-redecl.cpp
+++ b/test/SemaCXX/struct-class-redecl.cpp
@@ -1,8 +1,164 @@
// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s
class X; // expected-note 2{{here}}
typedef struct X * X_t; // expected-warning{{previously declared}}
+union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}}
-template<typename T> struct Y; // expected-note{{previous}}
+template<typename T> struct Y; // expected-note{{did you mean class here?}}
template<class U> class Y { }; // expected-warning{{previously declared}}
-union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}}
+class A;
+class A; // expected-note{{previous use is here}}
+struct A; // expected-warning{{struct 'A' was previously declared as a class}}
+
+class B; // expected-note{{did you mean struct here?}}
+class B; // expected-note{{previous use is here}}\
+ // expected-note{{did you mean struct here?}}
+struct B; // expected-warning{{struct 'B' was previously declared as a class}}
+struct B {}; // expected-warning{{'B' defined as a struct here but previously declared as a class}}
+
+class C; // expected-note{{previous use is here}}
+struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
+ // expected-note{{previous use is here}}\
+ // expected-note{{did you mean class here?}}
+class C; // expected-warning{{class 'C' was previously declared as a struct}}\
+ // expected-note{{previous use is here}}
+struct C; // expected-warning{{struct 'C' was previously declared as a class}}\
+ // expected-note{{did you mean class here?}}
+class C {}; // expected-warning{{'C' defined as a class here but previously declared as a struct}}
+
+struct D {}; // expected-note{{previous definition is here}}\
+ // expected-note{{previous use is here}}
+class D {}; // expected-error{{redefinition of 'D'}}
+struct D;
+class D; // expected-warning{{class 'D' was previously declared as a struct}}\
+ // expected-note{{did you mean struct here?}}
+
+class E;
+class E;
+class E {};
+class E;
+
+struct F;
+struct F;
+struct F {};
+struct F;
+
+template<class U> class G; // expected-note{{previous use is here}}\
+ // expected-note{{did you mean struct here?}}
+template<class U> struct G; // expected-warning{{struct template 'G' was previously declared as a class template}}
+template<class U> struct G {}; // expected-warning{{'G' defined as a struct template here but previously declared as a class template}}
+
+/*
+*** 'X' messages ***
+CHECK: warning: struct 'X' was previously declared as a class
+CHECK: {{^}}typedef struct X * X_t;
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class X;
+CHECK: {{^}} ^{{$}}
+CHECK: error: use of 'X' with tag type that does not match previous declaration
+CHECK: {{^}}union X { int x; float y; };
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}class{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class X;
+CHECK: {{^}} ^{{$}}
+*** 'Y' messages ***
+CHECK: warning: 'Y' defined as a class template here but
+ previously declared as a struct template
+CHECK: {{^}}template<class U> class Y { };
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}template<typename T> struct Y;
+CHECK: {{^}} ^~~~~~{{$}}
+CHECK: {{^}} class{{$}}
+*** 'A' messages ***
+CHECK: warning: struct 'A' was previously declared as a class
+CHECK: {{^}}struct A;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class A;
+CHECK: {{^}} ^{{$}}
+*** 'B' messages ***
+CHECK: warning: struct 'B' was previously declared as a class
+CHECK: {{^}}struct B;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class B;
+CHECK: {{^}} ^{{$}}
+CHECK: 'B' defined as a struct here but previously declared as a class
+CHECK: {{^}}struct B {};
+CHECK: {{^}}^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class B;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class B;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+*** 'C' messages ***
+CHECK: warning: struct 'C' was previously declared as a class
+CHECK: {{^}}struct C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: class 'C' was previously declared as a struct
+CHECK: {{^}}class C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}struct C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: struct 'C' was previously declared as a class
+CHECK: {{^}}struct C;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}class C;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: 'C' defined as a class here but previously declared as a struct
+CHECK: {{^}}class C {};
+CHECK: {{^}}^{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}struct C;
+CHECK: {{^}}^~~~~~{{$}}
+CHECK: {{^}}class{{$}}
+CHECK: note: did you mean class here?
+CHECK: {{^}}struct C;
+CHECK: {{^}}^~~~~~{{$}}
+CHECK: {{^}}class{{$}}
+*** 'D' messages ***
+CHECK: error: redefinition of 'D'
+CHECK: {{^}}class D {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous definition is here
+CHECK: {{^}}struct D {};
+CHECK: {{^}} ^{{$}}
+CHECK: warning: class 'D' was previously declared as a struct
+CHECK: {{^}}class D;
+CHECK: {{^}}^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}struct D {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}class D;
+CHECK: {{^}}^~~~~{{$}}
+CHECK: {{^}}struct{{$}}
+*** 'E' messages ***
+*** 'F' messages ***
+*** 'G' messages ***
+CHECK: warning: struct template 'G' was previously declared as a class template
+CHECK: {{^}}template<class U> struct G;
+CHECK: {{^}} ^{{$}}
+CHECK: note: previous use is here
+CHECK: {{^}}template<class U> class G;
+CHECK: {{^}} ^{{$}}
+CHECK: warning: 'G' defined as a struct template here but previously declared as a class template
+CHECK: {{^}}template<class U> struct G {};
+CHECK: {{^}} ^{{$}}
+CHECK: note: did you mean struct here?
+CHECK: {{^}}template<class U> class G;
+CHECK: {{^}} ^~~~~
+CHECK: {{^}} struct
+*/
diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp
index 3882a1f..8a8cf33 100644
--- a/test/SemaCXX/switch.cpp
+++ b/test/SemaCXX/switch.cpp
@@ -8,7 +8,7 @@ void test() {
}
int n = 3;
- switch (n && 1) { // expected-warning {{bool}}
+ switch (n && true) { // expected-warning {{bool}}
case 1:
break;
}
diff --git a/test/SemaCXX/tag-ambig.cpp b/test/SemaCXX/tag-ambig.cpp
new file mode 100644
index 0000000..6403cf3
--- /dev/null
+++ b/test/SemaCXX/tag-ambig.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9168556>
+typedef struct Point Point;
+
+namespace NameSpace {
+ class Point;
+}
+
+using namespace NameSpace;
+
+class Test
+{
+public:
+ struct Point { };
+ virtual bool testMethod (Test::Point& p) = 0;
+};
+
+// PR8151
+namespace A { struct Face {}; }
+namespace B { struct Face {}; }
+using namespace A;
+using namespace B;
+
+class C {
+ struct Face;
+ Face *mFaces;
+};
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 96e9696..30cc6a3 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++0x %s
#define T(b) (b) ? 1 : -1
#define F(b) (b) ? -1 : 1
@@ -38,8 +38,7 @@ typedef Derives DerivesArNB[];
struct DerivesEmpty : Empty {};
struct HasCons { HasCons(int); };
struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
-struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); }; // \
- // expected-warning {{rvalue references}}
+struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
struct HasDest { ~HasDest(); };
class HasPriv { int priv; };
class HasProt { protected: int prot; };
@@ -870,6 +869,15 @@ struct NonTrivialStruct {
}
};
+struct SuperNonTrivialStruct {
+ SuperNonTrivialStruct() { }
+ ~SuperNonTrivialStruct() { }
+};
+
+struct NonTCStruct {
+ NonTCStruct(const NonTCStruct&) {}
+};
+
void is_trivial2()
{
int t01[T(__is_trivial(char))];
@@ -897,6 +905,39 @@ void is_trivial2()
int t30[F(__is_trivial(void))];
int t31[F(__is_trivial(NonTrivialStruct))];
+ int t32[F(__is_trivial(SuperNonTrivialStruct))];
+ int t33[F(__is_trivial(NonTCStruct))];
+}
+
+void is_trivially_copyable2()
+{
+ int t01[T(__is_trivially_copyable(char))];
+ int t02[T(__is_trivially_copyable(int))];
+ int t03[T(__is_trivially_copyable(long))];
+ int t04[T(__is_trivially_copyable(short))];
+ int t05[T(__is_trivially_copyable(signed char))];
+ int t06[T(__is_trivially_copyable(wchar_t))];
+ int t07[T(__is_trivially_copyable(bool))];
+ int t08[T(__is_trivially_copyable(float))];
+ int t09[T(__is_trivially_copyable(double))];
+ int t10[T(__is_trivially_copyable(long double))];
+ int t11[T(__is_trivially_copyable(unsigned char))];
+ int t12[T(__is_trivially_copyable(unsigned int))];
+ int t13[T(__is_trivially_copyable(unsigned long long))];
+ int t14[T(__is_trivially_copyable(unsigned long))];
+ int t15[T(__is_trivially_copyable(unsigned short))];
+ int t16[T(__is_trivially_copyable(ClassType))];
+ int t17[T(__is_trivially_copyable(Derives))];
+ int t18[T(__is_trivially_copyable(Enum))];
+ int t19[T(__is_trivially_copyable(IntAr))];
+ int t20[T(__is_trivially_copyable(Union))];
+ int t21[T(__is_trivially_copyable(UnionAr))];
+ int t22[T(__is_trivially_copyable(TrivialStruct))];
+ int t23[T(__is_trivially_copyable(NonTrivialStruct))];
+
+ int t30[F(__is_trivially_copyable(void))];
+ int t32[F(__is_trivially_copyable(SuperNonTrivialStruct))];
+ int t31[F(__is_trivially_copyable(NonTCStruct))];
}
struct CStruct {
@@ -1027,7 +1068,7 @@ struct HasCopy {
};
struct HasMove {
- HasMove(HasMove&& cp); // expected-warning {{rvalue references}}
+ HasMove(HasMove&& cp);
};
struct HasTemplateCons {
@@ -1211,6 +1252,9 @@ void has_nothrow_copy() {
{ int arr[F(__has_nothrow_copy(cvoid))]; }
}
+template<bool b> struct assert_expr;
+template<> struct assert_expr<true> {};
+
void has_nothrow_constructor() {
{ int arr[T(__has_nothrow_constructor(Int))]; }
{ int arr[T(__has_nothrow_constructor(IntAr))]; }
@@ -1238,6 +1282,11 @@ void has_nothrow_constructor() {
{ int arr[F(__has_nothrow_constructor(void))]; }
{ int arr[F(__has_nothrow_constructor(cvoid))]; }
{ int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
+
+ // While parsing an in-class initializer, the constructor is not known to be
+ // non-throwing yet.
+ struct HasInClassInit { int n = (assert_expr<!__has_nothrow_constructor(HasInClassInit)>(), 0); };
+ { int arr[T(__has_nothrow_constructor(HasInClassInit))]; }
}
void has_virtual_destructor() {
@@ -1474,6 +1523,51 @@ void is_trivial()
{ int arr[F(__is_trivial(cvoid))]; }
}
+void is_trivially_copyable()
+{
+ { int arr[T(__is_trivially_copyable(int))]; }
+ { int arr[T(__is_trivially_copyable(Enum))]; }
+ { int arr[T(__is_trivially_copyable(POD))]; }
+ { int arr[T(__is_trivially_copyable(Int))]; }
+ { int arr[T(__is_trivially_copyable(IntAr))]; }
+ { int arr[T(__is_trivially_copyable(IntArNB))]; }
+ { int arr[T(__is_trivially_copyable(Statics))]; }
+ { int arr[T(__is_trivially_copyable(Empty))]; }
+ { int arr[T(__is_trivially_copyable(EmptyUnion))]; }
+ { int arr[T(__is_trivially_copyable(Union))]; }
+ { int arr[T(__is_trivially_copyable(Derives))]; }
+ { int arr[T(__is_trivially_copyable(DerivesAr))]; }
+ { int arr[T(__is_trivially_copyable(DerivesArNB))]; }
+ { int arr[T(__is_trivially_copyable(DerivesEmpty))]; }
+ { int arr[T(__is_trivially_copyable(HasFunc))]; }
+ { int arr[T(__is_trivially_copyable(HasOp))]; }
+ { int arr[T(__is_trivially_copyable(HasConv))]; }
+ { int arr[T(__is_trivially_copyable(HasAssign))]; }
+ { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; }
+ { int arr[T(__is_trivially_copyable(HasPriv))]; }
+ { int arr[T(__is_trivially_copyable(HasProt))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasProt))]; }
+ { int arr[T(__is_trivially_copyable(Vector))]; }
+ { int arr[T(__is_trivially_copyable(VectorExt))]; }
+ { int arr[T(__is_trivially_copyable(HasCons))]; }
+ { int arr[T(__is_trivially_copyable(HasRef))]; }
+ { int arr[T(__is_trivially_copyable(HasNonPOD))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasCons))]; }
+ { int arr[T(__is_trivially_copyable(DerivesHasRef))]; }
+
+ { int arr[F(__is_trivially_copyable(HasCopyAssign))]; }
+ { int arr[F(__is_trivially_copyable(HasMoveAssign))]; }
+ { int arr[F(__is_trivially_copyable(HasDest))]; }
+ { int arr[F(__is_trivially_copyable(HasVirt))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasDest))]; }
+ { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
+ { int arr[F(__is_trivially_copyable(void))]; }
+ { int arr[F(__is_trivially_copyable(cvoid))]; }
+}
+
void array_rank() {
int t01[T(__array_rank(IntAr) == 1)];
int t02[T(__array_rank(ConstIntArAr) == 2)];
diff --git a/test/SemaCXX/underlying_type.cpp b/test/SemaCXX/underlying_type.cpp
new file mode 100644
index 0000000..607d9ad
--- /dev/null
+++ b/test/SemaCXX/underlying_type.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c++0x %s
+
+#include "limits.h"
+
+template<typename T, typename U>
+struct is_same_type {
+ static const bool value = false;
+};
+template <typename T>
+struct is_same_type<T, T> {
+ static const bool value = true;
+};
+
+__underlying_type(int) a; // expected-error {{only enumeration types}}
+__underlying_type(struct b) c; // expected-error {{only enumeration types}}
+
+enum class f : char;
+static_assert(is_same_type<char, __underlying_type(f)>::value,
+ "f has the wrong underlying type");
+
+enum g {d = INT_MIN };
+static_assert(is_same_type<int, __underlying_type(g)>::value,
+ "g has the wrong underlying type");
+
+__underlying_type(f) h;
+static_assert(is_same_type<char, decltype(h)>::value,
+ "h has the wrong type");
+
+template <typename T>
+struct underlying_type {
+ typedef __underlying_type(T) type; // expected-error {{only enumeration types}}
+};
+
+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}}
diff --git a/test/SemaCXX/value-initialization.cpp b/test/SemaCXX/value-initialization.cpp
index 10520fb..dfe0f46 100644
--- a/test/SemaCXX/value-initialization.cpp
+++ b/test/SemaCXX/value-initialization.cpp
@@ -1,12 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
-struct A { // expected-error {{implicit default constructor for 'A' must explicitly initialize the const member 'i'}} \
- // expected-warning{{struct 'A' does not declare any constructor to initialize its non-modifiable members}}
- const int i; // expected-note {{declared here}} \
- // expected-note{{const member 'i' will never be initialized}}
+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}}
virtual void f() { }
};
int main () {
- (void)A(); // expected-note {{first required here}}
+ (void)A(); // expected-error {{call to deleted constructor}}
}
diff --git a/test/SemaCXX/vararg-non-pod.cpp b/test/SemaCXX/vararg-non-pod.cpp
index 55ec941..df0080f 100644
--- a/test/SemaCXX/vararg-non-pod.cpp
+++ b/test/SemaCXX/vararg-non-pod.cpp
@@ -56,15 +56,18 @@ void t4()
}
class E {
- E(int, ...);
+ E(int, ...); // expected-note 2{{implicitly declared private here}}
};
void t5()
{
C c(10);
- E e(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}}
- (void)E(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}}
+ E e(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}} \
+ // expected-error{{calling a private constructor of class 'E'}}
+ (void)E(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic constructor; call will abort at runtime}} \
+ // expected-error{{calling a private constructor of class 'E'}}
+
}
// PR5761: unevaluated operands and the non-POD warning
diff --git a/test/SemaCXX/vtable-instantiation.cc b/test/SemaCXX/vtable-instantiation.cc
index 49949a7..2a1b989 100644
--- a/test/SemaCXX/vtable-instantiation.cc
+++ b/test/SemaCXX/vtable-instantiation.cc
@@ -1,21 +1,22 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-// PR8640
-template<class T1> struct C1 {
- virtual void c1() {
- T1 t1 = 3; // expected-error {{cannot initialize a variable}}
- }
-};
+namespace PR8640 {
+ template<class T1> struct C1 {
+ virtual void c1() {
+ T1 t1 = 3; // expected-error {{cannot initialize a variable}}
+ }
+ };
-template<class T2> struct C2 {
- void c2() {
- new C1<T2>(); // expected-note {{in instantiation of member function}}
- }
-};
+ template<class T2> struct C2 {
+ void c2() {
+ new C1<T2>(); // expected-note {{in instantiation of member function}}
+ }
+ };
-void f() {
- C2<int*> c2;
- c2.c2(); // expected-note {{in instantiation of member function}}
+ void f() {
+ C2<int*> c2;
+ c2.c2(); // expected-note {{in instantiation of member function}}
+ }
}
namespace PR9325 {
@@ -42,5 +43,26 @@ namespace PR9325 {
{
Target<int*>* traits = &Provider<int*>::Instance;
}
+}
+namespace PR10020 {
+ struct MG {
+ virtual void Accept(int) = 0;
+ };
+
+ template <typename Type>
+ struct GMG : MG {
+ void Accept(int i) {
+ static_cast<Type *>(0)->Accept(i); // expected-error{{member reference base}}
+ }
+ static GMG* Method() { return &singleton; } // expected-note{{in instantiation of}}
+ static GMG singleton;
+ };
+
+ template <typename Type>
+ GMG<Type> GMG<Type>::singleton;
+
+ void test(void) {
+ GMG<int>::Method(); // expected-note{{in instantiation of}}
+ }
}
diff --git a/test/SemaCXX/warn-bad-memaccess.cpp b/test/SemaCXX/warn-bad-memaccess.cpp
new file mode 100644
index 0000000..e7d095f
--- /dev/null
+++ b/test/SemaCXX/warn-bad-memaccess.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdynamic-class-memaccess -verify %s
+
+extern "C" void *memset(void *, int, unsigned);
+extern "C" void *memmove(void *s1, const void *s2, unsigned n);
+extern "C" void *memcpy(void *s1, const void *s2, unsigned n);
+
+// Several types that should not warn.
+struct S1 {} s1;
+struct S2 { int x; } s2;
+struct S3 { float x, y; S1 s[4]; void (*f)(S1**); } s3;
+
+class C1 {
+ int x, y, z;
+public:
+ void foo() {}
+} c1;
+
+struct X1 { virtual void f(); } x1;
+struct X2 : virtual S1 {} x2;
+
+void test_warn() {
+ memset(&x1, 0, sizeof x1); // \
+ // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x2, 0, sizeof x2); // \
+ // expected-warning {{destination for this 'memset' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+
+ memmove(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this 'memmove' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memmove(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this 'memmove' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcpy(&x1, 0, sizeof x1); // \
+ // expected-warning{{destination for this 'memcpy' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memcpy(0, &x1, sizeof x1); // \
+ // expected-warning{{source of this 'memcpy' call is a pointer to dynamic class}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+}
+
+void test_nowarn(void *void_ptr) {
+ int i, *iptr;
+ float y;
+ char c;
+
+ memset(&i, 0, sizeof i);
+ memset(&iptr, 0, sizeof iptr);
+ memset(&y, 0, sizeof y);
+ memset(&c, 0, sizeof c);
+ memset(void_ptr, 0, 42);
+ memset(&s1, 0, sizeof s1);
+ memset(&s2, 0, sizeof s2);
+ memset(&s3, 0, sizeof s3);
+ memset(&c1, 0, sizeof c1);
+
+ // Unevaluated code shouldn't warn.
+ (void)sizeof memset(&x1, 0, sizeof x1);
+
+ // Dead code shouldn't warn.
+ if (false) memset(&x1, 0, sizeof x1);
+}
+
+namespace N {
+ void *memset(void *, int, unsigned);
+ void test_nowarn() {
+ N::memset(&x1, 0, sizeof x1);
+ }
+}
diff --git a/test/SemaCXX/warn-non-pod-memset.cpp b/test/SemaCXX/warn-non-pod-memset.cpp
deleted file mode 100644
index fbdcead..0000000
--- a/test/SemaCXX/warn-non-pod-memset.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memset -verify %s
-
-extern void *memset(void *, int, unsigned);
-
-// Several POD types that should not warn.
-struct S1 {} s1;
-struct S2 { int x; } s2;
-struct S3 { float x, y; S1 s[4]; void (*f)(S1**); } s3;
-
-// We use the C++11 concept of POD for this warning, so ensure a non-aggregate
-// still warns.
-class C1 {
- int x, y, z;
-public:
- void foo() {}
-} c1;
-
-// Non-POD types that should warn.
-struct X1 { X1(); } x1;
-struct X2 { ~X2(); } x2;
-struct X3 { virtual void f(); } x3;
-struct X4 : X2 {} x4;
-struct X5 : virtual S1 {} x5;
-
-void test_warn() {
- memset(&x1, 0, sizeof x1); // \
- // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
- // expected-note {{explicitly cast the pointer to silence this warning}}
- memset(&x2, 0, sizeof x2); // \
- // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
- // expected-note {{explicitly cast the pointer to silence this warning}}
- memset(&x3, 0, sizeof x3); // \
- // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
- // expected-note {{explicitly cast the pointer to silence this warning}}
- memset(&x4, 0, sizeof x4); // \
- // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
- // expected-note {{explicitly cast the pointer to silence this warning}}
- memset(&x5, 0, sizeof x5); // \
- // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
- // expected-note {{explicitly cast the pointer to silence this warning}}
-}
-
-void test_nowarn(void *void_ptr) {
- int i, *iptr;
- float y;
- char c;
-
- memset(&i, 0, sizeof i);
- memset(&iptr, 0, sizeof iptr);
- memset(&y, 0, sizeof y);
- memset(&c, 0, sizeof c);
- memset(void_ptr, 0, 42);
- memset(&s1, 0, sizeof s1);
- memset(&s2, 0, sizeof s2);
- memset(&s3, 0, sizeof s3);
- memset(&c1, 0, sizeof c1);
-
- // Unevaluated code shouldn't warn.
- (void)sizeof memset(&x1, 0, sizeof x1);
-
- // Dead code shouldn't warn.
- if (false) memset(&x1, 0, sizeof x1);
-}
diff --git a/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
new file mode 100644
index 0000000..698eccd
--- /dev/null
+++ b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify
+struct A {
+ A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
+ ~A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
+
+ virtual void f() = 0; // expected-note 2 {{'f' declared here}}
+};
diff --git a/test/SemaObjC/exprs.m b/test/SemaObjC/exprs.m
index d7c1223..2b505e0 100644
--- a/test/SemaObjC/exprs.m
+++ b/test/SemaObjC/exprs.m
@@ -32,3 +32,13 @@ void test3(Object *o) {
// this is ok.
__sync_bool_compare_and_swap(&g, 0, o);
}
+
+@class Incomplete_ObjC_class;
+struct Incomplete_struct; // expected-note {{forward declaration}}
+
+void test_encode() {
+ (void)@encode(Incomplete_ObjC_class); // expected-error {{incomplete type}}
+ (void)@encode(struct Incomplete_struct); // expected-error {{incomplete type}}
+ (void)@encode(Incomplete_ObjC_class*);
+ (void)@encode(id);
+}
diff --git a/test/SemaObjC/gc-attributes.m b/test/SemaObjC/gc-attributes.m
new file mode 100644
index 0000000..2f54328
--- /dev/null
+++ b/test/SemaObjC/gc-attributes.m
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void f0(__strong A**); // expected-note{{passing argument to parameter here}}
+
+void test_f0() {
+ A *a;
+ static __weak A *a2;
+ f0(&a);
+ f0(&a2); // expected-warning{{passing 'A *__weak *' to parameter of type 'A *__strong *' discards qualifiers}}
+}
+
+void f1(__weak A**); // expected-note{{passing argument to parameter here}}
+
+void test_f1() {
+ A *a;
+ __strong A *a2;
+ f1(&a);
+ f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}}
+}
diff --git a/test/SemaObjC/objc2-warn-weak-decl.m b/test/SemaObjC/objc2-warn-weak-decl.m
index 22a3fca..b85f768 100644
--- a/test/SemaObjC/objc2-warn-weak-decl.m
+++ b/test/SemaObjC/objc2-warn-weak-decl.m
@@ -6,6 +6,6 @@ struct S {
int main ()
{
- __weak id local; // expected-warning {{__weak attribute cannot be specified on an automatic variable}}
+ __weak id local; // expected-warning {{Objective-C GC does not allow weak variables on the stack}}
}
diff --git a/test/SemaObjC/related-result-type-inference.m b/test/SemaObjC/related-result-type-inference.m
new file mode 100644
index 0000000..f539918
--- /dev/null
+++ b/test/SemaObjC/related-result-type-inference.m
@@ -0,0 +1,171 @@
+// RUN: %clang_cc1 -fobjc-infer-related-result-type -verify %s
+
+@interface Unrelated
+@end
+
+@interface NSObject
++ (id)new;
++ (id)alloc;
+- (NSObject *)init;
+
+- (id)retain; // expected-note{{instance method 'retain' is assumed to return an instance of its receiver type ('NSArray *')}}
+- autorelease;
+
+- (id)self;
+
+- (id)copy;
+- (id)mutableCopy;
+
+// Do not infer when instance/class mismatches
+- (id)newNotInferred;
+- (id)alloc;
++ (id)initWithBlarg;
++ (id)self;
+
+// Do not infer when the return types mismatch.
+- (Unrelated *)initAsUnrelated;
+@end
+
+@interface NSString : NSObject
+- (id)init;
+- (id)initWithCString:(const char*)string;
+@end
+
+@interface NSArray : NSObject
+- (unsigned)count;
+@end
+
+@interface NSBlah
+@end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface NSBlah ()
++ (Unrelated *)newUnrelated;
+@end
+
+void test_inference() {
+ // Inference based on method family
+ __typeof__(([[NSString alloc] init])) *str = (NSString**)0;
+ __typeof__(([[[[NSString new] self] retain] autorelease])) *str2 = (NSString **)0;
+ __typeof__(([[NSString alloc] initWithCString:"blah"])) *str3 = (NSString**)0;
+
+ // Not inferred
+ __typeof__(([[NSString new] copy])) *id1 = (id*)0;
+
+ // Not inferred due to instance/class mismatches
+ __typeof__(([[NSString new] newNotInferred])) *id2 = (id*)0;
+ __typeof__(([[NSString new] alloc])) *id3 = (id*)0;
+ __typeof__(([NSString self])) *id4 = (id*)0;
+ __typeof__(([NSString initWithBlarg])) *id5 = (id*)0;
+
+ // Not inferred due to return type mismatch
+ __typeof__(([[NSString alloc] initAsUnrelated])) *unrelated = (Unrelated**)0;
+ __typeof__(([NSBlah newUnrelated])) *unrelated2 = (Unrelated**)0;
+
+
+ NSArray *arr = [[NSMutableArray alloc] init];
+ NSMutableArray *marr = [arr retain]; // expected-warning{{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+}
+
+@implementation NSBlah
++ (Unrelated *)newUnrelated {
+ return (Unrelated *)0;
+}
+@end
+
+@implementation NSBlah (Cat)
++ (Unrelated *)newUnrelated2 {
+ return (Unrelated *)0;
+}
+@end
+
+@interface A
+- (id)initBlah; // expected-note 2{{overridden method is part of the 'init' method family}}
+@end
+
+@interface B : A
+- (Unrelated *)initBlah; // expected-warning{{method is expected to return an instance of its class type 'B', but is declared to return 'Unrelated *'}}
+@end
+
+@interface C : A
+@end
+
+@implementation C
+- (Unrelated *)initBlah { // expected-warning{{method is expected to return an instance of its class type 'C', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+@end
+
+@interface D
++ (id)newBlarg; // expected-note{{overridden method is part of the 'new' method family}}
+@end
+
+@interface D ()
++ alloc; // expected-note{{overridden method is part of the 'alloc' method family}}
+@end
+
+@implementation D
++ (Unrelated *)newBlarg { // expected-warning{{method is expected to return an instance of its class type 'D', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+
++ (Unrelated *)alloc { // expected-warning{{method is expected to return an instance of its class type 'D', but is declared to return 'Unrelated *'}}
+ return (Unrelated *)0;
+}
+@end
+
+@protocol P1
+- (id)initBlah; // expected-note{{overridden method is part of the 'init' method family}}
+- (int)initBlarg;
+@end
+
+@protocol P2 <P1>
+- (int)initBlah; // expected-warning{{protocol method is expected to return an instance of the implementing class, but is declared to return 'int'}}
+- (int)initBlarg;
+- (int)initBlech;
+@end
+
+@interface E
+- init;
+@end
+
+@implementation E
+- init {
+ return self;
+}
+@end
+
+@protocol P3
++ (NSString *)newString;
+@end
+
+@interface F<P3>
+@end
+
+@implementation F
++ (NSString *)newString { return @"blah"; }
+@end
+
+// <rdar://problem/9340699>
+@interface G
+- (id)_ABC_init __attribute__((objc_method_family(init)));
+@end
+
+@interface G (Additions)
+- (id)_ABC_init2 __attribute__((objc_method_family(init)));
+@end
+
+@implementation G (Additions)
+- (id)_ABC_init {
+ return 0;
+}
+- (id)_ABC_init2 {
+ return 0;
+}
+- (id)_ABC_init3 {
+ return 0;
+}
+@end
+
diff --git a/test/SemaObjCXX/blocks.mm b/test/SemaObjCXX/blocks.mm
index 6c2343d..c91fd10 100644
--- a/test/SemaObjCXX/blocks.mm
+++ b/test/SemaObjCXX/blocks.mm
@@ -118,3 +118,29 @@ void f(int (^bl)(A* a)); // expected-note {{candidate function not viable: no kn
void g() {
f(^(B* b) { return 0; }); // expected-error {{no matching function for call to 'f'}}
}
+
+namespace DependentReturn {
+ template<typename T>
+ void f(T t) {
+ (void)^(T u) {
+ if (t != u)
+ return t + u;
+ else
+ return;
+ };
+
+ (void)^(T u) {
+ if (t == u)
+ return;
+ else
+ return t + u;
+ };
+ }
+
+ struct X { };
+ void operator+(X, X);
+ bool operator==(X, X);
+ bool operator!=(X, X);
+
+ template void f<X>(X);
+}
diff --git a/test/SemaObjCXX/gc-attributes.mm b/test/SemaObjCXX/gc-attributes.mm
new file mode 100644
index 0000000..70a93b2
--- /dev/null
+++ b/test/SemaObjCXX/gc-attributes.mm
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void f0(__strong A**); // expected-note{{candidate function not viable: 1st argument ('A *__weak *') has __weak lifetime, but parameter has __strong lifetime}}
+
+void test_f0() {
+ A *a;
+ static __weak A *a2;
+ f0(&a);
+ f0(&a2); // expected-error{{no matching function}}
+}
+
+void f1(__weak A**); // expected-note{{candidate function not viable: 1st argument ('A *__strong *') has __strong lifetime, but parameter has __weak lifetime}}
+
+void test_f1() {
+ A *a;
+ __strong A *a2;
+ f1(&a);
+ f1(&a2); // expected-error{{no matching function}}
+}
diff --git a/test/SemaObjCXX/namespace-lookup.mm b/test/SemaObjCXX/namespace-lookup.mm
new file mode 100644
index 0000000..205b443
--- /dev/null
+++ b/test/SemaObjCXX/namespace-lookup.mm
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9388207>
+@interface A
+@end
+
+@interface A(N)
+@end
+
+@protocol M
+@end
+
+namespace N { }
+namespace M { }
diff --git a/test/SemaObjCXX/nullptr.mm b/test/SemaObjCXX/nullptr.mm
new file mode 100644
index 0000000..4cd5669
--- /dev/null
+++ b/test/SemaObjCXX/nullptr.mm
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+@interface A
+@end
+
+void comparisons(A *a) {
+ (void)(a == nullptr);
+ (void)(nullptr == a);
+}
+
+void assignment(A *a) {
+ a = nullptr;
+}
diff --git a/test/SemaObjCXX/overload-gc.mm b/test/SemaObjCXX/overload-gc.mm
index d2ddd40..5488ea5 100644
--- a/test/SemaObjCXX/overload-gc.mm
+++ b/test/SemaObjCXX/overload-gc.mm
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -triple i386-apple-darwin9 -fobjc-gc -verify %s
-void f0(__weak id *); // expected-note{{candidate function not viable: 1st argument ('id *') has no lifetime, but parameter has __weak lifetime}}
+void f0(__weak id *);
void test_f0(id *x) {
- f0(x); // expected-error{{no matching function for call to 'f0'}}
+ f0(x);
}
@interface A
diff --git a/test/SemaObjCXX/overload.mm b/test/SemaObjCXX/overload.mm
index 960a7b2..ea5f0e5 100644
--- a/test/SemaObjCXX/overload.mm
+++ b/test/SemaObjCXX/overload.mm
@@ -52,12 +52,12 @@ void test0(A* a, B* b, id val) {
void test1(A* a) {
B* b = a; // expected-warning{{incompatible pointer types initializing 'B *' with an expression of type 'A *'}}
- B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'A *' from 'B *'}}
+ B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'B *' from 'A *'}}
}
void test2(A** ap) {
B** bp = ap; // expected-warning{{incompatible pointer types initializing 'B **' with an expression of type 'A **'}}
- bp = ap; // expected-warning{{incompatible pointer types assigning to 'A **' from 'B **'}}
+ bp = ap; // expected-warning{{incompatible pointer types assigning to 'B **' from 'A **'}}
}
// FIXME: we should either allow overloading here or give a better diagnostic
diff --git a/test/SemaObjCXX/related-result-type-inference.mm b/test/SemaObjCXX/related-result-type-inference.mm
new file mode 100644
index 0000000..c3cab05
--- /dev/null
+++ b/test/SemaObjCXX/related-result-type-inference.mm
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -fobjc-infer-related-result-type -verify %s
+
+@interface Unrelated
+@end
+
+@interface NSObject
++ (id)new;
++ (id)alloc;
+- (NSObject *)init;
+
+- (id)retain; // expected-note 2{{instance method 'retain' is assumed to return an instance of its receiver type ('NSArray *')}}
+- autorelease;
+
+- (id)self;
+
+- (id)copy;
+- (id)mutableCopy;
+
+// Do not infer when instance/class mismatches
+- (id)newNotInferred;
+- (id)alloc;
++ (id)initWithBlarg;
++ (id)self;
+
+// Do not infer when the return types mismatch.
+- (Unrelated *)initAsUnrelated;
+@end
+
+@interface NSString : NSObject
+- (id)init;
+- (id)initWithCString:(const char*)string;
+@end
+
+@interface NSArray : NSObject
+- (unsigned)count;
+@end
+
+@interface NSBlah
+@end
+
+@interface NSMutableArray : NSArray
+@end
+
+@interface NSBlah ()
++ (Unrelated *)newUnrelated;
+@end
+
+void test_inference() {
+ // Inference based on method family
+ __typeof__(([[NSString alloc] init])) *str = (NSString**)0;
+ __typeof__(([[[[NSString new] self] retain] autorelease])) *str2 = (NSString **)0;
+ __typeof__(([[NSString alloc] initWithCString:"blah"])) *str3 = (NSString**)0;
+
+ // Not inferred
+ __typeof__(([[NSString new] copy])) *id1 = (id*)0;
+
+ // Not inferred due to instance/class mismatches
+ __typeof__(([[NSString new] newNotInferred])) *id2 = (id*)0;
+ __typeof__(([[NSString new] alloc])) *id3 = (id*)0;
+ __typeof__(([NSString self])) *id4 = (id*)0;
+ __typeof__(([NSString initWithBlarg])) *id5 = (id*)0;
+
+ // Not inferred due to return type mismatch
+ __typeof__(([[NSString alloc] initAsUnrelated])) *unrelated = (Unrelated**)0;
+ __typeof__(([NSBlah newUnrelated])) *unrelated2 = (Unrelated**)0;
+
+ NSArray *arr = [[NSMutableArray alloc] init];
+ NSMutableArray *marr = [arr retain]; // expected-warning{{incompatible pointer types initializing 'NSMutableArray *' with an expression of type 'NSArray *'}}
+ marr = [arr retain]; // expected-warning{{incompatible pointer types assigning to 'NSMutableArray *' from 'NSArray *'}}
+ arr = [marr retain];
+}
diff --git a/test/SemaTemplate/alias-church-numerals.cpp b/test/SemaTemplate/alias-church-numerals.cpp
new file mode 100644
index 0000000..751cac7
--- /dev/null
+++ b/test/SemaTemplate/alias-church-numerals.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<template<template<typename> class, typename> class T, template<typename> class V> struct PartialApply {
+ template<typename W> using R = T<V, W>;
+};
+
+template<typename T> using Id = T;
+template<template<typename> class, typename X> using Zero = X;
+template<template<template<typename> class, typename> class N, template<typename> class F, typename X> using Succ = F<N<F,X>>;
+
+template<template<typename> class F, typename X> using One = Succ<Zero, F, X>;
+template<template<typename> class F, typename X> using Two = Succ<One, F, X>;
+
+template<template<template<typename> class, typename> class A,
+ template<template<typename> class, typename> class B,
+ template<typename> class F,
+ typename X> using Add = A<F, B<F, X>>;
+
+template<template<template<typename> class, typename> class A,
+ template<template<typename> class, typename> class B,
+ template<typename> class F,
+ typename X> using Mul = A<PartialApply<B,F>::template R, X>;
+
+template<template<typename> class F, typename X> using Four = Add<Two, Two, F, X>;
+template<template<typename> class F, typename X> using Sixteen = Mul<Four, Four, F, X>;
+template<template<typename> class F, typename X> using TwoHundredAndFiftySix = Mul<Sixteen, Sixteen, F, X>;
+
+template<typename T, T N> struct Const { static const T value = N; };
+template<typename A> struct IncrementHelper;
+template<typename T, T N> struct IncrementHelper<Const<T, N>> { using Result = Const<T, N+1>; };
+template<typename A> using Increment = typename IncrementHelper<A>::Result;
+
+using Arr = int[TwoHundredAndFiftySix<Increment, Const<int, 0>>::value];
+using Arr = int[256];
diff --git a/test/SemaTemplate/alias-nested-nontag.cpp b/test/SemaTemplate/alias-nested-nontag.cpp
new file mode 100644
index 0000000..1bb5ce3
--- /dev/null
+++ b/test/SemaTemplate/alias-nested-nontag.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template<typename T> using Id = T; // expected-note {{type alias template 'Id' declared here}}
+struct U { static Id<int> V; };
+Id<int> ::U::V; // expected-error {{type 'Id<int>' (aka 'int') cannot be used prior to '::' because it has no members}} \
+ expected-error {{C++ requires a type specifier}}
diff --git a/test/SemaTemplate/alias-template-template-param.cpp b/test/SemaTemplate/alias-template-template-param.cpp
new file mode 100644
index 0000000..a847b06
--- /dev/null
+++ b/test/SemaTemplate/alias-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+template<template<typename> class D> using C = D<int>;
+
+// Substitution of the alias template transforms the TemplateSpecializationType
+// 'D<int>' into the DependentTemplateSpecializationType 'T::template U<int>'.
+template<typename T> void f(C<T::template U>);
diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp
new file mode 100644
index 0000000..f4c917c
--- /dev/null
+++ b/test/SemaTemplate/alias-templates.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template<typename S>
+struct A {
+ typedef S B;
+ template<typename T> using C = typename T::B;
+ template<typename T> struct D {
+ template<typename U> using E = typename A<U>::template C<A<T>>;
+ template<typename U> using F = A<E<U>>;
+ template<typename U> using G = C<F<U>>;
+ G<T> g;
+ };
+ typedef decltype(D<B>().g) H;
+ D<H> h;
+ template<typename T> using I = A<decltype(h.g)>;
+ template<typename T> using J = typename A<decltype(h.g)>::template C<I<T>>;
+};
+
+A<int> a;
+A<char>::D<double> b;
+
+template<typename T> T make();
+
+namespace X {
+ template<typename T> struct traits {
+ typedef T thing;
+ typedef decltype(val(make<thing>())) inner_ptr;
+
+ template<typename U> using rebind_thing = typename thing::template rebind<U>;
+ template<typename U> using rebind = traits<rebind_thing<U>>;
+
+ inner_ptr &&alloc();
+ void free(inner_ptr&&);
+ };
+
+ template<typename T> struct ptr_traits {
+ typedef T *type;
+ };
+ template<typename T> using ptr = typename ptr_traits<T>::type;
+
+ template<typename T> struct thing {
+ typedef T inner;
+ typedef ptr<inner> inner_ptr;
+ typedef traits<thing<inner>> traits_type;
+
+ template<typename U> using rebind = thing<U>;
+
+ thing(traits_type &traits) : traits(traits), val(traits.alloc()) {}
+ ~thing() { traits.free(static_cast<inner_ptr&&>(val)); }
+
+ traits_type &traits;
+ inner_ptr val;
+
+ friend inner_ptr val(const thing &t) { return t.val; }
+ };
+
+ template<> struct ptr_traits<bool> {
+ typedef bool &type;
+ };
+ template<> bool &traits<thing<bool>>::alloc() { static bool b; return b; }
+ template<> void traits<thing<bool>>::free(bool&) {}
+}
+
+typedef X::traits<X::thing<int>> itt;
+
+itt::thing::traits_type itr;
+itt::thing ith(itr);
+
+itt::rebind<bool> btr;
+itt::rebind_thing<bool> btt(btr);
diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp
index ec97311..fb23eda 100644
--- a/test/SemaTemplate/deduction-crash.cpp
+++ b/test/SemaTemplate/deduction-crash.cpp
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -fsyntax-only %s 2>&1| FileCheck %s
-// PR7511
-
// Note that the error count below doesn't matter. We just want to
// make sure that the parser doesn't crash.
-// CHECK: 13 errors
+// CHECK: 14 errors
+
+// PR7511
template<a>
struct int_;
@@ -57,3 +57,33 @@ int a()
state_machine<int> p;
p.ant(0);
}
+
+// PR9974
+template <int> struct enable_if;
+template <class > struct remove_reference ;
+template <class _Tp> struct remove_reference<_Tp&> ;
+
+template <class > struct __tuple_like;
+
+template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value>
+struct __tuple_convertible;
+
+struct pair
+{
+template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
+pair(_Tuple&& );
+};
+
+template <class> struct basic_ostream;
+
+template <int>
+void endl( ) ;
+
+extern basic_ostream<char> cout;
+
+int operator<<( basic_ostream<char> , pair ) ;
+
+void register_object_imp ( )
+{
+cout << endl<1>;
+}
diff --git a/test/SemaTemplate/dependent-names-no-std.cpp b/test/SemaTemplate/dependent-names-no-std.cpp
new file mode 100644
index 0000000..e9ac99f
--- /dev/null
+++ b/test/SemaTemplate/dependent-names-no-std.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+//
+// The whole point of this test is to verify certain diagnostics work in the
+// absence of namespace 'std'.
+
+namespace PR10053 {
+ namespace ns {
+ struct Data {};
+ }
+
+ template<typename T> struct A {
+ T t;
+ A() {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}}
+ }
+ };
+
+ void f(ns::Data); // expected-note {{in namespace 'PR10053::ns'}}
+
+ A<ns::Data> a; // expected-note {{in instantiation of member function}}
+}
diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp
index 5776ddc..2a50df5 100644
--- a/test/SemaTemplate/dependent-names.cpp
+++ b/test/SemaTemplate/dependent-names.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
typedef double A;
template<typename T> class B {
@@ -129,3 +129,136 @@ namespace PR8966 {
template <class T>
const char* MyClass<T>::array [MyClass<T>::N] = { "A", "B", "C" };
}
+
+namespace std {
+ inline namespace v1 {
+ template<typename T> struct basic_ostream;
+ }
+ namespace inner {
+ template<typename T> struct vector {};
+ }
+ using inner::vector;
+ template<typename T, typename U> struct pair {};
+ typedef basic_ostream<char> ostream;
+ extern ostream cout;
+ std::ostream &operator<<(std::ostream &out, const char *);
+}
+
+namespace PR10053 {
+ template<typename T> struct A {
+ T t;
+ A() {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}}
+ }
+ };
+
+ void f(int&); // expected-note {{'f' should be declared prior to the call site}}
+
+ A<int> a; // expected-note {{in instantiation of member function}}
+
+
+ namespace N {
+ namespace M {
+ template<typename T> int g(T t) {
+ f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}}
+ };
+ }
+
+ void f(char&); // expected-note {{'f' should be declared prior to the call site}}
+ }
+
+ void f(char&);
+
+ int k = N::M::g<char>(0);; // expected-note {{in instantiation of function}}
+
+
+ namespace O {
+ void f(char&); // expected-note {{candidate function not viable}}
+
+ template<typename T> struct C {
+ static const int n = f(T()); // expected-error {{no matching function}}
+ };
+ }
+
+ int f(double); // no note, shadowed by O::f
+ O::C<double> c; // expected-note {{requested here}}
+
+
+ // Example from www/compatibility.html
+ namespace my_file {
+ template <typename T> T Squared(T x) {
+ return Multiply(x, x); // expected-error {{neither visible in the template definition nor found by argument dependent lookup}}
+ }
+
+ int Multiply(int x, int y) { // expected-note {{should be declared prior to the call site}}
+ return x * y;
+ }
+
+ int main() {
+ Squared(5); // expected-note {{here}}
+ }
+ }
+
+ // Example from www/compatibility.html
+ namespace my_file2 {
+ template<typename T>
+ void Dump(const T& value) {
+ std::cout << value << "\n"; // expected-error {{neither visible in the template definition nor found by argument dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+
+ std::ostream& operator<<(std::ostream& out, ns::Data data) { // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2::ns'}}
+ return out << "Some data";
+ }
+
+ void Use() {
+ Dump(ns::Data()); // expected-note {{here}}
+ }
+ }
+
+ namespace my_file2_a {
+ template<typename T>
+ void Dump(const T &value) {
+ print(std::cout, value); // expected-error 4{{neither visible in the template definition nor found by argument dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+ namespace ns2 {
+ struct Data {};
+ }
+
+ std::ostream &print(std::ostream &out, int); // expected-note-re {{should be declared prior to the call site$}}
+ std::ostream &print(std::ostream &out, ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns'}}
+ std::ostream &print(std::ostream &out, std::vector<ns2::Data>); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::my_file2_a::ns2'}}
+ std::ostream &print(std::ostream &out, std::pair<ns::Data, ns2::Data>); // expected-note {{should be declared prior to the call site or in an associated namespace of one of its arguments}}
+
+ void Use() {
+ Dump(0); // expected-note {{requested here}}
+ Dump(ns::Data()); // expected-note {{requested here}}
+ Dump(std::vector<ns2::Data>()); // expected-note {{requested here}}
+ Dump(std::pair<ns::Data, ns2::Data>()); // expected-note {{requested here}}
+ }
+ }
+
+ namespace unary {
+ template<typename T>
+ T Negate(const T& value) {
+ return !value; // expected-error {{call to function 'operator!' that is neither visible in the template definition nor found by argument dependent lookup}}
+ }
+
+ namespace ns {
+ struct Data {};
+ }
+
+ ns::Data operator!(ns::Data); // expected-note {{should be declared prior to the call site or in namespace 'PR10053::unary::ns'}}
+
+ void Use() {
+ Negate(ns::Data()); // expected-note {{requested here}}
+ }
+ }
+}
diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp
index 703daea..d1284de 100644
--- a/test/SemaTemplate/friend-template.cpp
+++ b/test/SemaTemplate/friend-template.cpp
@@ -216,3 +216,11 @@ namespace PR8649 {
X<int, float, 7> x;
}
+
+// Don't crash, and error on invalid friend type template.
+namespace friend_type_template_no_tag {
+ template <typename T> struct S {
+ template <typename U> friend S<U>; // expected-error{{friend type templates must use an elaborated type}}
+ };
+ template struct S<int>;
+}
diff --git a/test/SemaTemplate/instantiate-call.cpp b/test/SemaTemplate/instantiate-call.cpp
index ad06be3..a0e48c8 100644
--- a/test/SemaTemplate/instantiate-call.cpp
+++ b/test/SemaTemplate/instantiate-call.cpp
@@ -24,7 +24,8 @@ namespace N3 {
template<typename T, typename Result>
struct call_f0 {
void test_f0(T t) {
- Result &result = f0(t); // expected-error 2{{undeclared identifier}}
+ Result &result = f0(t); // expected-error {{undeclared identifier}} \
+ expected-error {{neither visible in the template definition nor found by argument dependent lookup}}
}
};
}
@@ -32,7 +33,7 @@ namespace N3 {
template struct N3::call_f0<int, char&>; // expected-note{{instantiation}}
template struct N3::call_f0<N1::X0, int&>;
-short& f0(char);
+short& f0(char); // expected-note {{should be declared prior to the call site}}
namespace N4 {
template<typename T, typename Result>
struct call_f0 {
diff --git a/test/SemaTemplate/instantiate-function-1.cpp b/test/SemaTemplate/instantiate-function-1.cpp
index 688d009..5406fbc 100644
--- a/test/SemaTemplate/instantiate-function-1.cpp
+++ b/test/SemaTemplate/instantiate-function-1.cpp
@@ -225,3 +225,25 @@ namespace PR7016 {
template<typename T> void f() { T x = x; }
template void f<int>();
}
+
+namespace PR9880 {
+ struct lua_State;
+ struct no_tag { char a; }; // (A)
+ struct yes_tag { long a; long b; }; // (A)
+
+ template <typename T>
+ struct HasIndexMetamethod {
+ template <typename U>
+ static no_tag check(...);
+ template <typename U>
+ static yes_tag check(char[sizeof(&U::luaIndex)]);
+ enum { value = sizeof(check<T>(0)) == sizeof(yes_tag) };
+ };
+
+ class SomeClass {
+ public:
+ int luaIndex(lua_State* L);
+ };
+
+ int i = HasIndexMetamethod<SomeClass>::value;
+}
diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp
index e292aa3..f0ca9a5 100644
--- a/test/SemaTemplate/instantiate-init.cpp
+++ b/test/SemaTemplate/instantiate-init.cpp
@@ -55,3 +55,55 @@ namespace PR6657 {
f0<int>();
}
}
+
+// Instantiate out-of-line definitions of static data members which complete
+// types through an initializer even when the only use of the member that would
+// cause instantiation is in an unevaluated context, but one requiring its
+// complete type.
+namespace PR10001 {
+ template <typename T> struct S {
+ static const int arr[];
+ static const int x;
+ static int f();
+ };
+
+ template <typename T> const int S<T>::arr[] = { 1, 2, 3 };
+ template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]);
+ template <typename T> int S<T>::f() { return x; }
+
+ int x = S<int>::f();
+}
+
+namespace PR7985 {
+ template<int N> struct integral_c { };
+
+ template <typename T, int N>
+ integral_c<N> array_lengthof(T (&x)[N]) { return integral_c<N>(); } // expected-note 2{{candidate template ignored: failed template argument deduction}}
+
+ template<typename T>
+ struct Data {
+ T x;
+ };
+
+ template<typename T>
+ struct Description {
+ static const Data<T> data[];
+ };
+
+ template<typename T>
+ const Data<T> Description<T>::data[] = {{ 1 }}; // expected-error{{cannot initialize a member subobject of type 'int *' with an rvalue of type 'int'}}
+
+ template<>
+ Data<float*> Description<float*>::data[];
+
+ void test() {
+ integral_c<1> ic1 = array_lengthof(Description<int>::data);
+ (void)sizeof(array_lengthof(Description<float>::data));
+
+ sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+ Description<int*>::data // expected-note{{in instantiation of static data member 'PR7985::Description<int *>::data' requested here}}
+ ));
+
+ array_lengthof(Description<float*>::data); // expected-error{{no matching function for call to 'array_lengthof'}}
+ }
+}
diff --git a/test/SemaTemplate/partial-spec-instantiate.cpp b/test/SemaTemplate/partial-spec-instantiate.cpp
index 68b4964..a93af50 100644
--- a/test/SemaTemplate/partial-spec-instantiate.cpp
+++ b/test/SemaTemplate/partial-spec-instantiate.cpp
@@ -38,3 +38,13 @@ namespace WonkyAccess {
return y.m + y2.m;
}
}
+
+// <rdar://problem/9169404>
+namespace rdar9169404 {
+ template<typename T, T N> struct X { };
+ template<bool C> struct X<bool, C> {
+ typedef int type;
+ };
+
+ X<bool, -1>::type value;
+}
diff --git a/test/SemaTemplate/rdar9173693.cpp b/test/SemaTemplate/rdar9173693.cpp
new file mode 100644
index 0000000..86b4954
--- /dev/null
+++ b/test/SemaTemplate/rdar9173693.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/9173693>
+template< bool C > struct assert { };
+template< bool > struct assert_arg_pred_impl { }; // expected-note 3 {{declared here}}
+template< typename Pred > assert<false> assert_not_arg( void (*)(Pred), typename assert_arg_pred<Pred>::type ); // expected-error 5 {{}}
diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp
index 4c788f6..7898a20 100644
--- a/test/SemaTemplate/typename-specifier.cpp
+++ b/test/SemaTemplate/typename-specifier.cpp
@@ -71,3 +71,34 @@ struct C {
::Y<A>::type ip7 = &i;
::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'Y<B>' requested here}}
::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'Y<C>' requested here}}
+
+template<typename T> struct D {
+ typedef typename T::foo foo; // expected-error {{type 'long' cannot be used prior to '::' because it has no members}}
+ typedef typename foo::bar bar;
+};
+
+D<long> struct_D; // expected-note {{in instantiation of template class 'D<long>' requested here}}
+
+template<typename T> struct E {
+ typedef typename T::foo foo;
+ typedef typename foo::bar bar; // expected-error {{type 'foo' (aka 'double') cannot be used prior to '::' because it has no members}}
+};
+
+struct F {
+ typedef double foo;
+};
+
+E<F> struct_E; // expected-note {{in instantiation of template class 'E<F>' requested here}}
+
+template<typename T> struct G {
+ typedef typename T::foo foo;
+ typedef typename foo::bar bar;
+};
+
+struct H {
+ struct foo {
+ typedef double bar;
+ };
+};
+
+G<H> struct_G;
diff --git a/test/lit.cfg b/test/lit.cfg
index 4b9d529..e18105d 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -171,3 +171,33 @@ if platform.system() != 'Windows':
# Shell execution
if platform.system() not in ['Windows'] or lit.getBashPath() != '':
config.available_features.add('shell')
+
+# Registered Targets
+import subprocess
+import re
+import os
+
+def getRegisteredTargets(tool):
+ set_of_targets = set()
+
+ cmd = subprocess.Popen([tool, '-version'], stdout=subprocess.PIPE)
+
+ # Parse the stdout to get the list of registered targets.
+ parse_targets = False
+ for line in cmd.stdout:
+ if parse_targets:
+ m = re.match( r'(.*) - ', line)
+ if m is not None:
+ set_of_targets.add(m.group(1).strip() + '-registered-target')
+ else:
+ break
+ elif "Registered Targets:" in line:
+ parse_targets = True
+
+ return set_of_targets
+
+registered_targets = getRegisteredTargets(os.path.join(llvm_tools_dir, 'llc'))
+if len(registered_targets) > 0:
+ config.available_features.update(registered_targets)
+else:
+ lit.fatal('No Targets Registered with the LLVM Tools!')
OpenPOWER on IntegriCloud