From c49018d9cce52d8c9f34b44865ec3ba8e89a1488 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 12 Jun 2011 15:46:16 +0000 Subject: Vendor import of clang trunk r132879: http://llvm.org/svn/llvm-project/cfe/trunk@132879 --- test/Analysis/CFNumber.c | 7 +- test/Analysis/bstring.c | 37 +++ test/Analysis/misc-ps-cxx0x.cpp | 11 + test/Analysis/misc-ps-region-store.cpp | 19 ++ test/Analysis/misc-ps-region-store.m | 24 ++ test/Analysis/misc-ps.c | 83 ++++++ test/Analysis/misc-ps.m | 25 ++ test/Analysis/plist-output-alternate.m | 9 +- test/Analysis/retain-release.m | 10 +- test/Analysis/retain-release.mm | 306 +++++++++++++++++++++ test/Analysis/string.c | 174 +++++++----- test/CMakeLists.txt | 24 -- .../basic/basic.lookup/basic.lookup.argdep/p4.cpp | 3 + test/CXX/class.access/class.friend/p2-cxx03.cpp | 2 +- test/CXX/class.access/p4.cpp | 6 +- test/CXX/class/class.friend/p2.cpp | 4 +- test/CXX/class/class.mem/p1b.cpp | 2 +- test/CXX/class/class.mem/p5-0x.cpp | 9 + .../dcl.dcl/basic.namespace/namespace.def/p7.cpp | 2 +- test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp | 32 +++ .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp | 25 +- .../dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp | 8 +- .../dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp | 19 ++ test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp | 9 +- test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp | 63 +++++ test/CXX/dcl.decl/dcl.init/p14-0x.cpp | 44 +++ test/CXX/dcl.decl/dcl.init/p6.cpp | 12 + test/CXX/except/except.spec/p1.cpp | 13 + test/CXX/except/except.spec/p14.cpp | 14 +- test/CXX/except/except.spec/p9-dynamic.cpp | 2 +- test/CXX/expr/expr.const/p2-0x.cpp | 25 ++ test/CXX/expr/expr.post/expr.call/p7-0x.cpp | 17 ++ test/CXX/expr/expr.prim/p12-0x.cpp | 12 + test/CXX/expr/expr.prim/p4-0x.cpp | 10 + .../expr/expr.unary/expr.unary.noexcept/sema.cpp | 13 + test/CXX/special/class.ctor/p5-0x.cpp | 173 ++++++++++++ test/CXX/special/class.dtor/p3-0x.cpp | 177 ++++++++++++ .../special/class.init/class.base.init/p8-0x.cpp | 23 ++ .../special/class.init/class.base.init/p9-0x.cpp | 36 +++ test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp | 55 ++++ test/CXX/stmt.stmt/stmt.dcl/p3.cpp | 47 ++++ test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 6 +- test/CXX/temp/temp.decls/p3.cpp | 7 + test/CXX/temp/temp.decls/temp.alias/p1.cpp | 8 + test/CXX/temp/temp.decls/temp.alias/p2.cpp | 45 +++ test/CXX/temp/temp.decls/temp.alias/p3.cpp | 13 + test/CXX/temp/temp.decls/temp.friend/p3.cpp | 2 +- .../temp/temp.decls/temp.variadic/ext-blocks.cpp | 7 + .../CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp | 41 +++ test/CXX/temp/temp.param/p10-0x.cpp | 13 + test/CXX/temp/temp.param/p11-0x.cpp | 31 ++- test/CXX/temp/temp.param/p9-0x.cpp | 9 + .../temp/temp.res/temp.dep/temp.dep.type/p1.cpp | 30 ++ .../CXX/temp/temp.spec/temp.expl.spec/examples.cpp | 209 ++++++++++++++ test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp | 11 + test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp | 14 +- test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp | 5 +- .../temp/temp.spec/temp.expl.spec/p5-example.cpp | 34 +++ test/CXX/temp/temp.spec/temp.explicit/p2.cpp | 4 +- test/CXX/temp/temp.type/p1-0x.cpp | 23 ++ test/CodeGen/2009-10-20-GlobalDebug.c | 1 + test/CodeGen/altivec.c | 2 +- test/CodeGen/arm-asm.c | 7 + test/CodeGen/asm-errors.c | 1 + test/CodeGen/asm-label.c | 12 + test/CodeGen/available-externally-suppress.c | 10 +- test/CodeGen/avx-cmp-builtins.c | 46 ++++ test/CodeGen/builtins-ppc-altivec.c | 86 +++--- test/CodeGen/builtins-x86.c | 1 - test/CodeGen/builtinshufflevector.c | 3 +- test/CodeGen/byval-memcpy-elim.c | 20 ++ test/CodeGen/debug-info-crash.c | 1 + test/CodeGen/debug-info.c | 9 +- test/CodeGen/decl.c | 4 +- test/CodeGen/ext-vector.c | 26 +- test/CodeGen/extern-inline.c | 1 + test/CodeGen/frame-pointer-elim.c | 2 + test/CodeGen/inline.c | 2 +- test/CodeGen/mmx-builtins.c | 1 + test/CodeGen/ms_struct-bitfield-1.c | 91 ++++++ test/CodeGen/ms_struct-bitfield-2.c | 135 +++++++++ test/CodeGen/ms_struct-bitfield-3.c | 49 ++++ test/CodeGen/ms_struct-pack.c | 125 +++++++++ test/CodeGen/ms_struct.c | 23 ++ test/CodeGen/packed-arrays.c | 14 +- test/CodeGen/packed-structure.c | 9 +- test/CodeGen/palignr.c | 1 + test/CodeGen/string-literal-short-wstring.c | 2 +- test/CodeGen/string-literal.c | 8 +- test/CodeGen/struct-passing.c | 4 +- test/CodeGen/transparent-union.c | 2 +- test/CodeGen/x86_32-arguments-darwin.c | 6 +- test/CodeGen/x86_32-arguments-linux.c | 4 +- test/CodeGen/x86_64-arguments.c | 2 +- test/CodeGenCXX/PR5050-constructor-conversion.cpp | 1 + test/CodeGenCXX/abstract-class-ctors-dtors.cpp | 16 ++ test/CodeGenCXX/arm.cpp | 8 +- test/CodeGenCXX/array-construction.cpp | 1 + test/CodeGenCXX/array-operator-delete-call.cpp | 1 + test/CodeGenCXX/call-arg-zero-temp.cpp | 1 + test/CodeGenCXX/cast-conversion.cpp | 1 + test/CodeGenCXX/constructor-conversion.cpp | 1 + test/CodeGenCXX/constructor-default-arg.cpp | 1 + test/CodeGenCXX/constructor-for-array-members.cpp | 1 + test/CodeGenCXX/constructor-template.cpp | 1 + test/CodeGenCXX/convert-to-fptr.cpp | 1 + test/CodeGenCXX/copy-assign-synthesis-1.cpp | 1 + test/CodeGenCXX/cxx0x-defaulted-templates.cpp | 19 ++ test/CodeGenCXX/cxx0x-delegating-ctors.cpp | 42 +-- test/CodeGenCXX/debug-info-pubtypes.cpp | 15 + test/CodeGenCXX/decl-ref-init.cpp | 1 + .../CodeGenCXX/default-constructor-for-members.cpp | 1 + test/CodeGenCXX/derived-to-base-conv.cpp | 1 + test/CodeGenCXX/destructors.cpp | 4 +- test/CodeGenCXX/eh.cpp | 22 +- test/CodeGenCXX/exceptions.cpp | 2 + test/CodeGenCXX/global-array-destruction.cpp | 1 + test/CodeGenCXX/global-llvm-constant.cpp | 22 ++ test/CodeGenCXX/goto.cpp | 1 + test/CodeGenCXX/instrument-functions.cpp | 30 ++ test/CodeGenCXX/internal-linkage.cpp | 8 + test/CodeGenCXX/mangle-alias-template.cpp | 41 +++ test/CodeGenCXX/mangle-exprs.cpp | 16 ++ test/CodeGenCXX/mangle-subst-std.cpp | 1 + test/CodeGenCXX/mangle-unnameable-conversions.cpp | 14 + test/CodeGenCXX/mangle.cpp | 43 ++- test/CodeGenCXX/member-init-ctor.cpp | 14 + test/CodeGenCXX/new.cpp | 52 +++- test/CodeGenCXX/nrvo.cpp | 2 +- test/CodeGenCXX/pr9965.cpp | 12 + test/CodeGenCXX/ptr-to-member-function.cpp | 1 + test/CodeGenCXX/scoped-enums.cpp | 9 + .../skip-vtable-pointer-initialization.cpp | 200 ++++++++++++++ test/CodeGenCXX/static-init-2.cpp | 2 +- test/CodeGenCXX/template-instantiation.cpp | 30 ++ test/CodeGenCXX/threadsafe-statics-exceptions.cpp | 2 +- test/CodeGenCXX/thunks.cpp | 30 +- test/CodeGenCXX/vararg-non-pod.cpp | 16 ++ test/CodeGenCXX/virtual-base-destructor-call.cpp | 10 +- test/CodeGenCXX/x86_32-arguments.cpp | 4 +- test/CodeGenObjC/bitfield-ivar-offsets.m | 14 +- test/CodeGenObjC/blocks-2.m | 2 +- test/CodeGenObjC/constant-string-class-1.m | 23 ++ test/CodeGenObjC/constant-string-class.m | 2 +- test/CodeGenObjC/debug-info-block-helper.m | 30 ++ test/CodeGenObjC/debug-info-blocks.m | 55 ++++ test/CodeGenObjC/debug-info-class-extension.m | 15 + test/CodeGenObjC/debug-info-class-extension2.m | 14 + test/CodeGenObjC/debug-info-class-extension3.m | 12 + test/CodeGenObjC/debug-info-crash.m | 1 + test/CodeGenObjC/debug-info-getter-name.m | 3 + test/CodeGenObjC/debug-info-pubtypes.m | 19 ++ test/CodeGenObjC/debug-info-static-var.m | 1 + test/CodeGenObjC/debug-property-synth.m | 19 ++ test/CodeGenObjC/encode-test.m | 17 ++ test/CodeGenObjC/forward-decl-param.m | 19 ++ test/CodeGenObjC/instance-method-metadata.m | 1 + test/CodeGenObjC/interface-layout-64.m | 22 +- test/CodeGenObjC/ivar-layout-array0-struct.m | 1 + test/CodeGenObjC/ivar-layout-no-optimize.m | 1 + test/CodeGenObjC/messages-2.m | 28 +- test/CodeGenObjC/metadata-symbols-64.m | 2 +- test/CodeGenObjC/no-vararg-messaging.m | 1 + test/CodeGenObjC/objc-read-weak-byref.m | 1 + test/CodeGenObjC/protocol-in-extended-class.m | 1 + test/CodeGenObjC/try.m | 1 + test/CodeGenObjC/unwind-fn.m | 14 - test/CodeGenObjCXX/block-in-template-inst.mm | 71 +++++ test/CodeGenObjCXX/blocks.mm | 18 +- test/CodeGenObjCXX/encode.mm | 70 +++++ test/CodeGenObjCXX/mangle.mm | 12 + .../property-object-conditional-exp.mm | 7 +- test/Driver/cc-log-diagnostics.c | 12 +- test/Driver/cfi.c | 8 + test/Driver/darwin-debug-flags.c | 2 +- test/Driver/darwin-ld.c | 7 +- test/Driver/nostdlib.c | 4 + test/Driver/rewrite-objc.m | 2 +- test/Driver/sysroot.c | 18 ++ test/FixIt/fixit-cxx0x.cpp | 2 +- test/Frontend/diagnostic-name.c | 4 +- test/Frontend/ir-support-codegen.ll | 1 + test/Frontend/undef.c | 4 + test/Index/Inputs/guarded.h | 6 + test/Index/Inputs/pragma-once.h | 3 + test/Index/annotate-context-sensitive.cpp | 12 +- test/Index/annotate-tokens-pp.c | 8 +- test/Index/annotate-tokens.m | 8 +- test/Index/complete-kvc.m | 20 +- test/Index/complete-member-access.m | 17 ++ test/Index/complete-property-flags.m | 1 + test/Index/nested-macro-instantiations.cpp | 20 ++ test/Index/overrides.cpp | 4 +- test/Index/properties-class-extensions.m | 2 +- test/Index/recursive-cxx-member-calls.cpp | 34 +-- test/Index/usrs.cpp | 22 ++ test/Index/usrs.m | 2 +- test/Lexer/block_cmt_end.c | 8 +- test/Lexer/has_extension.c | 30 ++ test/Lexer/has_extension_cxx.cpp | 36 +++ test/Lexer/has_feature_c1x.c | 20 ++ test/Lexer/has_feature_cxx0x.cpp | 11 +- test/Lexer/has_feature_type_traits.cpp | 10 + test/Misc/Inputs/include.h | 2 + test/Misc/diag-format.c | 34 +++ test/Misc/include-stack-for-note-flag.cpp | 10 + test/PCH/cxx-alias-decl.cpp | 20 ++ test/PCH/cxx-alias-decl.h | 11 + test/PCH/cxx-for-range.cpp | 6 +- test/PCH/cxx-member-init.cpp | 22 ++ test/PCH/cxx-reference.cpp | 6 +- test/PCH/cxx-static_assert.cpp | 15 +- test/PCH/cxx-static_assert.h | 9 - test/PCH/cxx0x-default-delete.cpp | 23 ++ test/PCH/cxx0x-delegating-ctors.cpp | 20 ++ test/PCH/modified-header-error.c | 11 + test/PCH/objc_methods.h | 2 +- test/PCH/objc_methods.m | 2 +- test/PCH/objcxx-ivar-class.mm | 2 +- test/Parser/MicrosoftExtensions.cpp | 100 ++++++- test/Parser/cxx-default-delete.cpp | 15 + test/Parser/cxx-ext-delete-default.cpp | 11 + test/Parser/cxx-friend.cpp | 6 +- test/Parser/cxx0x-member-initializers.cpp | 15 + test/Parser/nested-namespaces-recovery.cpp | 24 ++ test/Parser/opencl-astype.cl | 20 ++ test/Preprocessor/if_warning.c | 4 + test/Preprocessor/pragma_sysheader.c | 9 + test/Sema/MicrosoftExtensions.c | 8 + test/Sema/arm-neon-types.c | 9 +- test/Sema/asm.c | 8 + test/Sema/attr-unknown.c | 2 +- test/Sema/builtins-arm.c | 5 + test/Sema/carbon.c | 2 +- test/Sema/exprs.c | 18 ++ test/Sema/illegal-types.c | 2 +- test/Sema/parentheses.c | 24 +- test/Sema/parentheses.cpp | 31 +++ test/Sema/stdcall-fastcall.c | 3 +- test/Sema/uninit-variables.c | 13 + test/Sema/x86-builtin-palignr.c | 3 +- test/SemaCXX/MicrosoftExtensions.cpp | 74 ++++- test/SemaCXX/PR9572.cpp | 8 +- test/SemaCXX/PR9884.cpp | 17 ++ test/SemaCXX/PR9902.cpp | 28 ++ test/SemaCXX/PR9908.cpp | 32 +++ test/SemaCXX/aggregate-initialization.cpp | 4 +- test/SemaCXX/alias-template.cpp | 147 ++++++++++ test/SemaCXX/anonymous-union.cpp | 30 +- test/SemaCXX/attr-cxx0x.cpp | 5 + test/SemaCXX/attr-noreturn.cpp | 17 ++ test/SemaCXX/attr-regparm.cpp | 3 +- test/SemaCXX/class.cpp | 2 +- test/SemaCXX/conversion.cpp | 11 + test/SemaCXX/copy-constructor-error.cpp | 4 +- test/SemaCXX/cxx0x-cursory-default-delete.cpp | 69 +++++ test/SemaCXX/cxx0x-defaulted-functions.cpp | 45 +++ test/SemaCXX/cxx0x-delegating-ctors.cpp | 24 +- test/SemaCXX/cxx0x-deleted-default-ctor.cpp | 120 ++++++++ test/SemaCXX/cxx0x-nontrivial-union.cpp | 22 ++ test/SemaCXX/default-arg-special-member.cpp | 12 + test/SemaCXX/default-constructor-initializers.cpp | 7 + test/SemaCXX/defaulted-ctor-loop.cpp | 14 + test/SemaCXX/deleted-function-extension.cpp | 8 - test/SemaCXX/deleted-function.cpp | 5 +- test/SemaCXX/dependent-noexcept-unevaluated.cpp | 41 +++ test/SemaCXX/dependent-types.cpp | 5 +- test/SemaCXX/destructor.cpp | 175 +++++++++++- test/SemaCXX/enum-scoped.cpp | 10 + test/SemaCXX/expressions.cpp | 31 +++ test/SemaCXX/generalized-initializers.cpp | 174 ++++++++++++ test/SemaCXX/implicit-exception-spec.cpp | 63 +++++ test/SemaCXX/implicit-member-functions.cpp | 2 +- test/SemaCXX/member-expr.cpp | 12 +- test/SemaCXX/member-init.cpp | 50 ++++ test/SemaCXX/member-pointer.cpp | 25 ++ test/SemaCXX/nullptr.cpp | 57 ++++ test/SemaCXX/overload-call.cpp | 22 ++ test/SemaCXX/overloaded-operator.cpp | 17 +- test/SemaCXX/redeclared-alias-template.cpp | 23 ++ test/SemaCXX/reinterpret-cast.cpp | 162 ++++++++++- test/SemaCXX/return.cpp | 16 ++ test/SemaCXX/struct-class-redecl.cpp | 160 ++++++++++- test/SemaCXX/switch.cpp | 2 +- test/SemaCXX/tag-ambig.cpp | 28 ++ test/SemaCXX/type-traits.cpp | 102 ++++++- test/SemaCXX/underlying_type.cpp | 37 +++ test/SemaCXX/value-initialization.cpp | 9 +- test/SemaCXX/vararg-non-pod.cpp | 9 +- test/SemaCXX/vtable-instantiation.cc | 50 +++- test/SemaCXX/warn-bad-memaccess.cpp | 70 +++++ test/SemaCXX/warn-non-pod-memset.cpp | 63 ----- .../warn-pure-virtual-call-from-ctor-dtor.cpp | 7 + test/SemaObjC/exprs.m | 10 + test/SemaObjC/gc-attributes.m | 22 ++ test/SemaObjC/objc2-warn-weak-decl.m | 2 +- test/SemaObjC/related-result-type-inference.m | 171 ++++++++++++ test/SemaObjCXX/blocks.mm | 26 ++ test/SemaObjCXX/gc-attributes.mm | 22 ++ test/SemaObjCXX/namespace-lookup.mm | 14 + test/SemaObjCXX/nullptr.mm | 13 + test/SemaObjCXX/overload-gc.mm | 4 +- test/SemaObjCXX/overload.mm | 4 +- test/SemaObjCXX/related-result-type-inference.mm | 71 +++++ test/SemaTemplate/alias-church-numerals.cpp | 34 +++ test/SemaTemplate/alias-nested-nontag.cpp | 6 + .../SemaTemplate/alias-template-template-param.cpp | 7 + test/SemaTemplate/alias-templates.cpp | 70 +++++ test/SemaTemplate/deduction-crash.cpp | 36 ++- test/SemaTemplate/dependent-names-no-std.cpp | 21 ++ test/SemaTemplate/dependent-names.cpp | 135 ++++++++- test/SemaTemplate/friend-template.cpp | 8 + test/SemaTemplate/instantiate-call.cpp | 5 +- test/SemaTemplate/instantiate-function-1.cpp | 22 ++ test/SemaTemplate/instantiate-init.cpp | 52 ++++ test/SemaTemplate/partial-spec-instantiate.cpp | 10 + test/SemaTemplate/rdar9173693.cpp | 6 + test/SemaTemplate/typename-specifier.cpp | 31 +++ test/lit.cfg | 30 ++ 319 files changed, 7263 insertions(+), 572 deletions(-) create mode 100644 test/Analysis/misc-ps-cxx0x.cpp create mode 100644 test/Analysis/misc-ps.c create mode 100644 test/Analysis/retain-release.mm create mode 100644 test/CXX/class/class.mem/p5-0x.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp create mode 100644 test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/p14-0x.cpp create mode 100644 test/CXX/expr/expr.const/p2-0x.cpp create mode 100644 test/CXX/expr/expr.post/expr.call/p7-0x.cpp create mode 100644 test/CXX/expr/expr.prim/p12-0x.cpp create mode 100644 test/CXX/expr/expr.prim/p4-0x.cpp create mode 100644 test/CXX/special/class.ctor/p5-0x.cpp create mode 100644 test/CXX/special/class.dtor/p3-0x.cpp create mode 100644 test/CXX/special/class.init/class.base.init/p8-0x.cpp create mode 100644 test/CXX/special/class.init/class.base.init/p9-0x.cpp create mode 100644 test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp create mode 100644 test/CXX/stmt.stmt/stmt.dcl/p3.cpp create mode 100644 test/CXX/temp/temp.decls/p3.cpp create mode 100644 test/CXX/temp/temp.decls/temp.alias/p1.cpp create mode 100644 test/CXX/temp/temp.decls/temp.alias/p2.cpp create mode 100644 test/CXX/temp/temp.decls/temp.alias/p3.cpp create mode 100644 test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp create mode 100644 test/CXX/temp/temp.param/p10-0x.cpp create mode 100644 test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp create mode 100644 test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp create mode 100644 test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp create mode 100644 test/CXX/temp/temp.type/p1-0x.cpp create mode 100644 test/CodeGen/arm-asm.c create mode 100644 test/CodeGen/asm-label.c create mode 100644 test/CodeGen/avx-cmp-builtins.c create mode 100644 test/CodeGen/byval-memcpy-elim.c create mode 100644 test/CodeGen/ms_struct-bitfield-1.c create mode 100644 test/CodeGen/ms_struct-bitfield-2.c create mode 100644 test/CodeGen/ms_struct-bitfield-3.c create mode 100644 test/CodeGen/ms_struct-pack.c create mode 100644 test/CodeGen/ms_struct.c create mode 100644 test/CodeGenCXX/abstract-class-ctors-dtors.cpp create mode 100644 test/CodeGenCXX/cxx0x-defaulted-templates.cpp create mode 100644 test/CodeGenCXX/debug-info-pubtypes.cpp create mode 100644 test/CodeGenCXX/instrument-functions.cpp create mode 100644 test/CodeGenCXX/mangle-alias-template.cpp create mode 100644 test/CodeGenCXX/mangle-unnameable-conversions.cpp create mode 100644 test/CodeGenCXX/member-init-ctor.cpp create mode 100644 test/CodeGenCXX/pr9965.cpp create mode 100644 test/CodeGenCXX/scoped-enums.cpp create mode 100644 test/CodeGenCXX/skip-vtable-pointer-initialization.cpp create mode 100644 test/CodeGenCXX/vararg-non-pod.cpp create mode 100644 test/CodeGenObjC/constant-string-class-1.m create mode 100644 test/CodeGenObjC/debug-info-block-helper.m create mode 100644 test/CodeGenObjC/debug-info-blocks.m create mode 100644 test/CodeGenObjC/debug-info-class-extension.m create mode 100644 test/CodeGenObjC/debug-info-class-extension2.m create mode 100644 test/CodeGenObjC/debug-info-class-extension3.m create mode 100644 test/CodeGenObjC/debug-info-pubtypes.m create mode 100644 test/CodeGenObjC/debug-property-synth.m create mode 100644 test/CodeGenObjC/forward-decl-param.m delete mode 100644 test/CodeGenObjC/unwind-fn.m create mode 100644 test/CodeGenObjCXX/block-in-template-inst.mm create mode 100644 test/Driver/cfi.c create mode 100644 test/Driver/nostdlib.c create mode 100644 test/Driver/sysroot.c create mode 100644 test/Frontend/undef.c create mode 100644 test/Index/Inputs/guarded.h create mode 100644 test/Index/Inputs/pragma-once.h create mode 100644 test/Index/nested-macro-instantiations.cpp create mode 100644 test/Lexer/has_extension.c create mode 100644 test/Lexer/has_extension_cxx.cpp create mode 100644 test/Lexer/has_feature_c1x.c create mode 100644 test/Misc/diag-format.c create mode 100644 test/PCH/cxx-alias-decl.cpp create mode 100644 test/PCH/cxx-alias-decl.h create mode 100644 test/PCH/cxx-member-init.cpp delete mode 100644 test/PCH/cxx-static_assert.h create mode 100644 test/PCH/cxx0x-default-delete.cpp create mode 100644 test/PCH/cxx0x-delegating-ctors.cpp create mode 100644 test/PCH/modified-header-error.c create mode 100644 test/Parser/cxx-default-delete.cpp create mode 100644 test/Parser/cxx-ext-delete-default.cpp create mode 100644 test/Parser/cxx0x-member-initializers.cpp create mode 100644 test/Parser/nested-namespaces-recovery.cpp create mode 100644 test/Parser/opencl-astype.cl create mode 100644 test/Sema/parentheses.cpp create mode 100644 test/SemaCXX/PR9884.cpp create mode 100644 test/SemaCXX/PR9902.cpp create mode 100644 test/SemaCXX/PR9908.cpp create mode 100644 test/SemaCXX/alias-template.cpp create mode 100644 test/SemaCXX/cxx0x-cursory-default-delete.cpp create mode 100644 test/SemaCXX/cxx0x-defaulted-functions.cpp create mode 100644 test/SemaCXX/cxx0x-deleted-default-ctor.cpp create mode 100644 test/SemaCXX/cxx0x-nontrivial-union.cpp create mode 100644 test/SemaCXX/default-arg-special-member.cpp create mode 100644 test/SemaCXX/defaulted-ctor-loop.cpp delete mode 100644 test/SemaCXX/deleted-function-extension.cpp create mode 100644 test/SemaCXX/dependent-noexcept-unevaluated.cpp create mode 100644 test/SemaCXX/generalized-initializers.cpp create mode 100644 test/SemaCXX/implicit-exception-spec.cpp create mode 100644 test/SemaCXX/member-init.cpp create mode 100644 test/SemaCXX/redeclared-alias-template.cpp create mode 100644 test/SemaCXX/tag-ambig.cpp create mode 100644 test/SemaCXX/underlying_type.cpp create mode 100644 test/SemaCXX/warn-bad-memaccess.cpp delete mode 100644 test/SemaCXX/warn-non-pod-memset.cpp create mode 100644 test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp create mode 100644 test/SemaObjC/gc-attributes.m create mode 100644 test/SemaObjC/related-result-type-inference.m create mode 100644 test/SemaObjCXX/gc-attributes.mm create mode 100644 test/SemaObjCXX/namespace-lookup.mm create mode 100644 test/SemaObjCXX/nullptr.mm create mode 100644 test/SemaObjCXX/related-result-type-inference.mm create mode 100644 test/SemaTemplate/alias-church-numerals.cpp create mode 100644 test/SemaTemplate/alias-nested-nontag.cpp create mode 100644 test/SemaTemplate/alias-template-template-param.cpp create mode 100644 test/SemaTemplate/alias-templates.cpp create mode 100644 test/SemaTemplate/dependent-names-no-std.cpp create mode 100644 test/SemaTemplate/rdar9173693.cpp (limited to 'test') 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: // CHECK: // CHECK: extended_message -// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference) +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count // CHECK: message -// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count (owning reference) +// CHECK: Call to function 'CFNumberCreate' returns a Core Foundation object with a +1 retain count // CHECK: // CHECK: // CHECK: kindcontrol @@ -994,9 +994,9 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: extended_message -// CHECK: Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked) +// CHECK: Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1 // CHECK: message -// CHECK: Object allocated on line 53 and stored into 'value' is not referenced later in this execution path and has a retain count of +1 (object leaked) +// CHECK: Object leaked: object allocated and stored into 'value' is not referenced later in this execution path and has a retain count of +1 // CHECK: // CHECK: // CHECK: descriptionPotential leak of an object allocated on line 53 and stored into 'value' @@ -1012,3 +1012,4 @@ void rdar8331641(int x) { // CHECK: // CHECK: // CHECK: + 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 +// #include +// #include +// #include +// #include +// #include +// +// 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 {} ++ (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 - (void)getValue:(void *)value; +@end @interface NSNumber : NSValue - (char)charValue; +- (id)initWithInt:(int)value; +@end @class NSString; +@interface NSArray : NSObject - (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 - (NSTimeInterval)timeIntervalSinceReferenceDate; +@end typedef unsigned short unichar; +@interface NSString : NSObject - (NSUInteger)length; +- ( const char *)UTF8String; +- (id)initWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end @class NSString, NSURL, NSError; +@interface NSData : NSObject - (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 - (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 { +} +@end @protocol NSAnimatablePropertyContainer - (id)animator; +@end extern NSString *NSAnimationTriggerOrderIn ; +@interface NSView : NSResponder { +} +@end @protocol NSValidatedUserInterfaceItem - (SEL)action; +@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id )anItem; +@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@interface NSApplication : NSResponder { +} +@end enum { +NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; +typedef NSUInteger NSApplicationTerminateReply; +@protocol NSApplicationDelegate @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; +@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; +@interface NSCell : NSObject { +} +@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +typedef struct { +} +CVTimeStamp; +@interface CIImage : NSObject { +} +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 { +} +- (id) createSnapshotImageOfType:(NSString*)type; +@end extern NSString* const QCViewDidStartRenderingNotification; +@interface QCView : NSView { +} +- (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 @required - (void)didRemoveDevice:(ICDevice*)device; +@end extern NSString *const ICScannerStatusWarmingUp; +@class ICScannerDevice; +@protocol ICScannerDeviceDelegate @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 A { template friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A') 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 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 void f(T) {} +template static void g(T) {} + + +template<> static void f(int); // expected-error{{explicit specialization cannot have a storage class}} +template static void f(float); // expected-error{{explicit instantiation cannot have a storage class}} + +template<> void f(double); +template void f(long); + +template<> static void g(int); // expected-error{{explicit specialization cannot have a storage class}} +template static void g(float); // expected-error{{explicit instantiation cannot have a storage class}} + +template<> void g(double); +template void g(long); + +template +struct X { + static int value; +}; + +template +int X::value = 17; + +template static int X::value; // expected-error{{explicit instantiation cannot have a storage class}} + +template<> static int X::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 using X = A; // expected-note {{declared here}} +struct X* p2; // expected-error {{elaborated type refers to a type alias template}} + + +template using Id = T; // expected-note {{declared here}} +template class F> +struct Y { + struct F i; // expected-error {{elaborated type refers to a type alias template}} + typename F::type j; // ok + + // FIXME: don't produce the diagnostic both for the definition and the instantiation. + template using U = F; // expected-note 2{{declared here}} + struct Y::template U k; // expected-error 2{{elaborated type refers to a type alias template}} + typename Y::template U l; // ok +}; +template struct Y; // 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 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 +struct s2 { + static const s0 foo; +}; + +template<> const struct s0 s2::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 void f(T) { + T* x = 1; + } + + template + 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 +class bitWidthHolding { +public: + static const + unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1); +}; + +static const int width=bitWidthHolding<255>::width; + +template +struct always_false { + static const bool value = false; +}; + +template +struct and_or { + static const bool and_value = b && and_or::value>::and_value; + static const bool or_value = !b || and_or::value>::or_value; +}; + +static const bool and_value = and_or::and_value; +static const bool or_value = and_or::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(s)); P(static_cast(s)); N(Bad1()); + P(X().~X()); } struct V { @@ -155,12 +158,16 @@ void gencon() { N(G3()); } +template void f(T&&) noexcept; template void late() { B(b, typeid(*(T*)0)); B(b, T(1)); B(b, static_cast(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 T&& f2() noexcept; +template +void late2() { + P(dynamic_cast(f2())); +} void operator +(const S1&, float) throw(); void operator +(const S1&, const S3&); void tlate() { late(); late(); + late2(); } 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 +struct TA { + ~TA(); +}; + +template +struct TB { + ~TB() throw(int); +}; + +template +struct TC { + TB b; + ~TC() {} +}; + +template +struct TD { + ~TD() noexcept(false); +}; + +template +struct TE { + TD d; + ~TE() {} +}; + +void tfoo() { + TA a; + TC c; + TE e; + // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev + // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev + // CHECK: call {{.*}} @_ZN2TAIiED1Ev +} + +template +struct TF { + TD d; + ~TF(); +}; +template +TF::~TF() noexcept(false) {} + +template +struct TG { + TD d; + ~TG(); +}; +template +TG::~TG() {} + +template +struct TH { + TB b; + ~TH(); +}; +template +TH::~TH() {} + +void tinst() { + TF f; + TG g; + TH h; +} +// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev +// CHECK: _ZTIi +// CHECK: __cxa_call_unexpected + +struct VX +{ virtual ~VX() {} }; + +struct VY : VX +{ virtual ~VY() {} }; + +template +struct TVY : VX +{ virtual ~TVY() {} }; + + +struct VA { + B b; + virtual ~VA() {} +}; + +struct VB : VA +{ virtual ~VB() {} }; + +template +struct TVB : VA +{ virtual ~TVB() {} }; + +void tinst2() { + TVY tvy; + TVB tvb; +} + +template +struct Sw { + T t; + ~Sw() {} +}; + +void tsw() { + Sw swi; + Sw 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 +struct TVC : VX +{ virtual ~TVC(); }; +template +TVC::~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 +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 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 ''}} + for (double a : f) { // expected-error {{cannot use 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 using A = int; +template using A = char; // expected-error {{partial specialization of alias templates is not permitted}} +template<> using A = char; // expected-error {{explicit specialization of alias templates is not permitted}} +template using A = char; // expected-error {{explicit instantiation of alias templates is not permitted}} +using A = 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 using U = T; + +// The name of the alias template is a template-name. +U x; +void f(U); +typedef U>>> 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 using U = T; + +using I = U>>>; +using I = int; + +template using Fst = A; +template using Snd = B; + +using I = Fst,double>; + +namespace StdExample { + // Prerequisites for example. + template struct vector { /* ... */ }; + + + template struct Alloc {}; + template using Vec = vector>; + Vec v; + + template + void process(Vec& v) // expected-note {{previous definition is here}} + { /* ... */ } + + template + void process(vector>& w) // expected-error {{redefinition of 'process'}} + { /* ... */ } + + template class TT> + void f(TT); // expected-note {{candidate template ignored}} + + template class TT> + void g(TT>); + + 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>. + using VTest = vector>; + 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 struct A; +template using B = typename A::U; // expected-error {{no type named 'U' in 'A'}} +template struct A { + typedef B U; // expected-note {{in instantiation of template type alias 'B' requested here}} +}; +B b; + +template using U = int; +// FIXME: This is illegal, but probably only because CWG1044 missed this paragraph. +template using U = U; 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 friend class A; template friend class Undeclared; - template friend typename A::Member; // expected-warning {{non-class type 'typename A::Member' cannot be a friend}} + template friend typename A::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 +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 struct unsigned_c { }; + +template +class has_copy_constructor { + static T t; + + template static yes_type check(unsigned_c * = 0); + template static no_type check(...); + +public: + static const bool value = (sizeof(check(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::value? 1 : -1]; +int check1[has_copy_constructor::value? 1 : -1]; +int check2[has_copy_constructor::value? -1 : 1]; +int check3[has_copy_constructor::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 struct Y1; +template struct Y2; + +template using B2 = T1; +template using B2 = T1; + +template class F, template class G = Y1> using B2t = F>; +template class F = Y2, template class G> using B2t = F>; + +template using B2n = Y2; +template using B2n = Y2; 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 struct vector; +template struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template class M = vector, template class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} +template class M = vector, template class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} + template struct X2t; +template using A2t = X2t; template struct X2nt; +template using A2nt = X2nt; template class M = vector, template class... Metas> struct X2tt; +template class M = vector, template class... Metas> + using A2tt = X2tt; -// 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 struct X0t; +template +using A0t = int; template struct X0nt; +template +using A0nt = int; template class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} int After> struct X0tt; +template 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 struct Inner::X3 { }; template void Inner::f2() {} } + +namespace PR10069 { + template + T f(T x); + + void g() { + f(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 struct A; + template using B = A; + + template struct A { + struct C {}; + B::C bc; // ok, B is the current instantiation. + }; + + template struct A> { + struct C {}; + B>::C bc; // ok, B> is the current instantiation. + }; + + template struct A>> { + struct C {}; + B>::C bc; // expected-error {{missing 'typename'}} + }; +} + +namespace Example2 { + template struct A { + void g(); + }; + template using B = A; + template void B::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 struct identity { typedef T type; }; + struct A { A(); }; + identity::type::A() { } + + struct B { void f(); }; + template struct C { typedef B type; }; + + void C::type::f() { } +} + +namespace PR9421 { + namespace N { template struct S { void f(); }; } + typedef N::S 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 struct C { + void f(); + }; + template struct D { + typedef C A; + }; + template<> void D::A::f() { + } +} + +namespace PR8708 { + template struct A { + template struct B { + // #2 + void f(); + }; + }; + + // #A specialize the member template for + // implicit instantiation of A, + // leaving the member template "unspecialized" + // (14.7.3/16). Specialization uses the syntax + // for explicit specialization (14.7.3/14) + template<> template + struct A::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 + void A::B::g() { } + + // #2 define the unspecialized member template's + // f + template template + void A::B::f() { } + + + // specialize the member template again, now + // specializing the member too. This specializes + // #A + template<> template<> + struct A::B { + // #3 + void h(); + }; + + // defines #3. There is no enclosing class template, so + // we write no "template<>". + void A::B::h() { } + + void test() { + // calls #1 + A::B a; a.g(); + + // calls #2 + A::B b; b.f(); + + // calls #3 + A::B c; c.h(); + } +} + +namespace PR9482 { + namespace N1 { + template struct S { + void foo() {} + }; + } + + namespace N2 { + typedef N1::S X; + } + + namespace N1 { + template<> void N2::X::foo() {} + } +} + +namespace PR9668 { + namespace First + { + template + class Bar + { + protected: + + static const bool static_bool; + }; + } + + namespace Second + { + class Foo; + } + + typedef First::Bar Special; + + namespace + First + { + template<> + const bool Special::static_bool(false); + } +} + +namespace PR9877 { + template + 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 { + templatestruct S; + templatestruct S { + template class F; + }; + + template + template + class S::F{}; +} + +namespace template_class_spec_perClassDecl_nested +{ + template struct A { + template struct B { + template struct C { + static void foo(); + }; + }; + }; + + template <> struct A { + template struct B { + template struct C { + static void foo(); + }; + }; + }; + + template <> template struct A::B::C { + static void foo(); + }; + + template <> template <> struct A::B::C { + static void foo(); + }; + + template <> template<> template struct A::B::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::member // expected-note{{instantiation}} : X::member; } + +namespace rdar9422013 { + template + 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 struct A { void f(T); template void g1(T, X1); @@ -24,3 +24,15 @@ template<> template<> // member specialization even if defined in class definition template<> void A::h(int) { } + +namespace PR10024 { + template + struct Test{ + template + void get(U i) {} + }; + + template + template <> + void Test::get(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 { public: - static int foo; // expected-note{{attempt to specialize}} + static int foo; static int bar; }; typedef A 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 struct A { + struct B { }; + template struct C { }; +}; + template<> struct A { + void f(int); +}; +void h() { + A a; + a.f(16); +} +// A::f must be defined somewhere +// template<> not used for a member of an // explicitly specialized class template +void A::f(int) { /* ... */ } + template<> struct A::B { + void f(); +}; +// template<> also not used when defining a member of // an explicitly specialized member class +void A::B::f() { /* ... */ } + template<> template struct A::C { + void f(); +}; + +template<> +template void A::C::f() { /* ... */ } + template<> struct A::B { + void f(); +}; +template<> void A::B::f() { /* ... */ } // expected-error{{no function template matches function template specialization 'f'}} + template<> template struct A::C { + void f(); +}; +template void A::C::f() { /* ... */ } // expected-error{{template parameter list matching the non-templated nested type 'A' 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 Array { void mf() { } }; @@ -35,7 +35,7 @@ namespace N { }; template - 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 class TT> struct X { }; + template struct Y { }; + template using Z = Y; + X y; + X z; + + using SameType = decltype(y); // expected-note {{here}} + using SameType = decltype(z); // expected-error {{different types}} +} + +namespace New { + template struct X { }; + template struct Y { }; + template using Z = Y; + X> y; + X> 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> {{.*}} + vi++; // CHECK: add <4 x i32> {{.*}} vector unsigned int vui; --vui; // CHECK: add <4 x i32> {{.*}} 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 + +// +// 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, ¶m_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. // -// 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 +struct X { + X(); +}; + +// CHECK: define void @_ZN1XIbEC1Ev +// CHECK: define void @_ZN1XIbEC2Ev +template <> X::X() = default; + +// CHECK: define weak_odr void @_ZN1XIiEC1Ev +// CHECK: define weak_odr void @_ZN1XIiEC2Ev +template X::X() = default; +template X::X(); + +// CHECK: define linkonce_odr void @_ZN1XIcEC1Ev +// CHECK: define linkonce_odr void @_ZN1XIcEC2Ev +X 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 class klass { + virtual void f(); +}; +namespace { struct S; } +void foo () { klass 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 struct alloc {}; +template using Alloc = alloc; +template> struct vector {}; + +template using Vec = vector; + +template void f(Vec v); +template void g(T); + +template class F> void h(F); + +// CHECK: define void @_Z1zv( +void z() { + vector VI; + f(VI); + // CHECK: call void @_Z1fIiEv6vectorIT_5allocIS1_EE( + + Vec VD; + g(VD); + // CHECK: call void @_Z1gI6vectorId5allocIdEEEvT_( + + h(VI); + // CHECK: call void @_Z1hI3VecEvT_IiE( + + Alloc AC; + h(AC); + // CHECK: call void @_Z1hI5allocEvT_IiE( + + h(AC); + // CHECK: call void @_Z1hI5AllocEvT_IiE( + + Vec VC; + g>(VC); + // CHECK: call void @_Z1gI6vectorIc5allocIcEEEvT_( + + Vec> 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 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 using id = T; +struct S { + template + operator id&(); + template + operator id() 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 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 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 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 decltype(((T*) 0)->Path2::p) get_p_2(T &ref) { return ref.Path2::p; } Derived obj; @@ -676,3 +676,38 @@ namespace test25 { A::call(); } } + +namespace test26 { + template