From 8aaf5818a64e9f7687798852af5945b053c68a54 Mon Sep 17 00:00:00 2001 From: rdivacky Date: Tue, 4 May 2010 16:12:48 +0000 Subject: Update clang to r103004. --- test/ASTMerge/category.m | 2 +- test/ASTMerge/enum.c | 2 +- test/ASTMerge/function.c | 2 +- test/ASTMerge/interface.m | 2 +- test/ASTMerge/property.m | 2 +- test/ASTMerge/struct.c | 2 +- test/ASTMerge/typedef.c | 2 +- test/ASTMerge/var.c | 2 +- test/Analysis/inline.c | 4 +- test/Analysis/inline2.c | 3 +- test/Analysis/inline3.c | 4 +- test/Analysis/inline4.c | 4 +- test/Analysis/method-call.cpp | 18 + test/Analysis/misc-ps-region-store.m | 59 ++ test/Analysis/misc-ps.m | 24 + test/Analysis/new.cpp | 14 + ...il-receiver-undefined-larger-than-voidptr-ret.m | 6 +- test/Analysis/null-deref-ps.c | 4 +- test/Analysis/override-werror.c | 2 +- test/Analysis/unix-fns.c | 37 +- .../basic/basic.lookup/basic.lookup.argdep/p2.cpp | 15 + .../basic/basic.lookup/basic.lookup.elab/p2.cpp | 60 ++ .../basic.lookup.qual/namespace.qual/p2.cpp | 2 +- .../basic/basic.lookup/basic.lookup.unqual/p7.cpp | 4 +- test/CXX/class.access/class.access.base/p1.cpp | 2 +- test/CXX/class.access/class.access.base/p5.cpp | 2 +- test/CXX/class.access/class.access.nest/p1.cpp | 2 +- test/CXX/class.access/class.friend/p1.cpp | 97 ++- test/CXX/class.access/class.friend/p2-cxx03.cpp | 13 + test/CXX/class.access/class.friend/p3-cxx0x.cpp | 29 + test/CXX/class.access/class.protected/p1.cpp | 387 ++++++++++++ test/CXX/class.access/p4.cpp | 99 ++- test/CXX/class.access/p6.cpp | 69 +- test/CXX/class/class.friend/p2.cpp | 4 +- test/CXX/class/class.local/p2.cpp | 2 +- .../class/class.mfct/class.mfct.non-static/p3.cpp | 2 +- test/CXX/conv/conv.mem/p4.cpp | 2 +- .../namespace.def/namespace.memdef/p3.cpp | 12 + .../dcl.dcl/basic.namespace/namespace.udecl/p1.cpp | 7 +- .../dcl.dcl/basic.namespace/namespace.udecl/p4.cpp | 2 +- .../dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp | 2 +- .../dcl.init.ref/p16-cxx0x-no-extra-copy.cpp | 50 ++ .../dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp | 61 ++ .../dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp | 8 +- test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp | 16 + .../dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp | 3 +- .../dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp | 1 + test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp | 6 +- test/CXX/except/except.handle/p16.cpp | 4 +- test/CXX/expr/expr.unary/expr.delete/p5.cpp | 2 +- test/CXX/expr/expr.unary/expr.new/p19.cpp | 2 +- test/CXX/expr/expr.unary/expr.new/p20-0x.cpp | 2 +- test/CXX/expr/expr.unary/expr.new/p20.cpp | 2 +- .../over.best.ics/over.ics.user/p3-0x.cpp | 14 + test/CXX/stmt.stmt/stmt.select/p3.cpp | 8 + .../temp.class.spec/temp.class.order/p2.cpp | 38 +- test/CXX/temp/temp.decls/temp.friend/p1.cpp | 83 ++- test/CXX/temp/temp.decls/temp.friend/p3.cpp | 3 +- test/CXX/temp/temp.decls/temp.mem/p1.cpp | 6 +- test/CXX/temp/temp.param/p3.cpp | 12 + test/CXX/temp/temp.res/temp.local/p3.cpp | 32 + test/CXX/temp/temp.spec/p5.cpp | 17 + test/CXX/temp/temp.spec/temp.explicit/p3.cpp | 16 +- test/CXX/temp/temp.spec/temp.explicit/p4.cpp | 22 +- test/CXX/temp/temp.spec/temp.inst/p11.cpp | 15 + test/CodeCompletion/call.cpp | 1 + test/CodeCompletion/macros.c | 4 - test/CodeCompletion/ordinary-name.cpp | 18 +- test/CodeGen/2009-10-20-GlobalDebug.c | 8 +- test/CodeGen/arm-arguments.c | 30 +- test/CodeGen/arm_asm_clobber.c | 21 - test/CodeGen/asm-errors.c | 8 + test/CodeGen/asm.c | 21 + test/CodeGen/asm_arm.c | 32 + test/CodeGen/bitfield-2.c | 368 +++++++++++ test/CodeGen/blocks.c | 2 +- test/CodeGen/builtins-ppc-altivec.c | 332 ++++++++++ test/CodeGen/catch-undef-behavior.c | 7 + test/CodeGen/const-unordered-compare.c | 7 + test/CodeGen/decl.c | 32 +- test/CodeGen/designated-initializers.c | 37 +- test/CodeGen/functions.c | 12 + test/CodeGen/global-init.c | 30 +- test/CodeGen/init.c | 6 +- test/CodeGen/libcalls.c | 50 +- test/CodeGen/palignr.c | 19 +- test/CodeGen/struct-passing.c | 4 +- test/CodeGen/union-init2.c | 11 +- test/CodeGen/x86_32-arguments.c | 126 ++-- test/CodeGen/x86_64-arguments.c | 81 ++- test/CodeGenCXX/PR6747.cpp | 11 + test/CodeGenCXX/address-of-fntemplate.cpp | 14 + .../anonymous-union-member-initializer.cpp | 26 +- test/CodeGenCXX/arm.cpp | 20 + test/CodeGenCXX/assign-operator.cpp | 14 +- test/CodeGenCXX/bitfield-layout.cpp | 43 ++ test/CodeGenCXX/block-destruct.cpp | 9 + test/CodeGenCXX/c-linkage.cpp | 13 + test/CodeGenCXX/constructor-init-reference.cpp | 2 +- test/CodeGenCXX/constructors.cpp | 14 +- test/CodeGenCXX/default-arg-temps.cpp | 50 +- test/CodeGenCXX/default-destructor-nested.cpp | 2 +- test/CodeGenCXX/delete.cpp | 26 +- test/CodeGenCXX/destructor-debug-info.cpp | 21 + test/CodeGenCXX/eh.cpp | 87 ++- test/CodeGenCXX/empty-classes.cpp | 69 ++ test/CodeGenCXX/exceptions-no-rtti.cpp | 48 ++ test/CodeGenCXX/field-access-debug-info.cpp | 11 + test/CodeGenCXX/implicit-copy-assign-operator.cpp | 56 ++ test/CodeGenCXX/instantiate-init-list.cpp | 2 +- test/CodeGenCXX/mangle-template.cpp | 40 ++ test/CodeGenCXX/mangle.cpp | 11 +- test/CodeGenCXX/member-function-pointer-calls.cpp | 11 +- test/CodeGenCXX/member-function-pointers.cpp | 37 +- test/CodeGenCXX/member-initializers.cpp | 2 +- test/CodeGenCXX/namespace-aliases.cpp | 6 + test/CodeGenCXX/new-operator-phi.cpp | 2 +- test/CodeGenCXX/new.cpp | 12 +- test/CodeGenCXX/operator-new.cpp | 1 + test/CodeGenCXX/reference-in-blocks.cpp | 21 + test/CodeGenCXX/rtti-fundamental.cpp | 4 +- test/CodeGenCXX/static-init.cpp | 11 + test/CodeGenCXX/static-local-in-local-class.cpp | 21 + ...template-anonymous-union-member-initializer.cpp | 1 + test/CodeGenCXX/template-instantiation.cpp | 1 + test/CodeGenCXX/temporaries.cpp | 19 + test/CodeGenCXX/value-init.cpp | 26 + test/CodeGenCXX/virt-template-vtable.cpp | 1 + test/CodeGenCXX/virt.cpp | 696 --------------------- test/CodeGenCXX/vtable-layout.cpp | 334 ++++++++++ test/CodeGenCXX/x86_32-arguments.cpp | 4 +- test/CodeGenObjC/atomic-aggregate-property.m | 28 + test/CodeGenObjC/blocks.m | 2 +- test/CodeGenObjC/encode-cstyle-method.m | 11 + test/CodeGenObjC/exceptions.m | 18 + test/CodeGenObjC/image-info.m | 10 +- test/CodeGenObjC/metadata-symbols-64.m | 2 +- test/CodeGenObjC/metadata_symbols.m | 51 +- test/CodeGenObjC/next-objc-dispatch.m | 73 +++ test/CodeGenObjC/non-lazy-classes.m | 2 +- test/CodeGenObjC/ns-constant-strings.m | 33 + test/CodeGenObjC/objc-gc-aggr-assign.m | 46 -- test/CodeGenObjC/objc2-legacy-dispatch.m | 4 +- test/CodeGenObjC/x86_64-struct-return-gc.m | 2 +- test/CodeGenObjCXX/ivar-objects.mm | 71 +++ test/CodeGenObjCXX/mangle.mm | 12 + test/Coverage/ast-printing.cpp | 2 +- test/Driver/darwin-ld.c | 2 +- test/Driver/darwin-objc-defaults.m | 88 +++ test/Driver/darwin-objc-gc.m | 19 + test/Driver/darwin-objc-options.m | 19 + test/FixIt/fixit-at.c | 5 - test/FixIt/fixit-c90.c | 8 +- test/FixIt/fixit-cxx0x.cpp | 10 +- test/FixIt/fixit-errors-1.c | 5 +- test/FixIt/fixit-errors.c | 5 +- test/FixIt/fixit-objc.m | 7 +- test/FixIt/fixit-pmem.cpp | 5 +- test/FixIt/fixit-suffix.c | 5 + test/FixIt/fixit-unrecoverable.c | 10 + test/FixIt/fixit-unrecoverable.cpp | 11 + test/FixIt/fixit.c | 19 +- test/FixIt/fixit.cpp | 15 +- test/FixIt/typo.c | 4 +- test/FixIt/typo.cpp | 5 +- test/FixIt/typo.m | 60 +- test/Index/Inputs/complete-pch.h | 10 + test/Index/annotate-tokens.m | 18 +- test/Index/complete-at-directives.m | 4 +- test/Index/complete-at-exprstmt.m | 4 +- test/Index/complete-exprs.c | 15 + test/Index/complete-method-decls.m | 82 +++ test/Index/complete-objc-message-id.m | 42 ++ test/Index/complete-objc-message.m | 78 +++ test/Index/complete-pch.m | 26 + test/Index/invalid-code-rdar_7833619.m | 4 + test/Index/load-exprs.c | 39 +- test/Index/local-symbols.m | 26 + test/Index/print-usrs.c | 4 +- test/Index/usrs.m | 87 +++ test/Lexer/gnu_keywords.c | 12 + test/Lexer/utf-16.c | 6 + test/Lexer/utf-16.c.txt | Bin 0 -> 48 bytes test/Misc/message-length.c | 16 +- test/Misc/tabstop.c | 3 - test/Misc/verify.c | 14 + test/PCH/exprs.c | 4 + test/PCH/exprs.h | 13 + test/PCH/functions.c | 4 +- test/PCH/functions.h | 5 +- test/PCH/objc_stmts.h | 22 + test/PCH/objc_stmts.m | 12 + test/PCH/pr4489.c | 7 + test/PCH/types.c | 2 +- test/Parser/altivec.c | 8 +- test/Parser/attributes.c | 4 + test/Parser/builtin_types_compatible.c | 2 +- test/Parser/check-syntax-1.m | 4 +- test/Parser/cxx-altivec.cpp | 9 +- test/Parser/cxx-casting.cpp | 9 +- test/Parser/cxx-class.cpp | 2 +- test/Parser/cxx-friend.cpp | 6 +- test/Parser/cxx-template-decl.cpp | 2 +- test/Parser/declarators.c | 2 +- test/Parser/implicit-casts.c | 2 +- test/Parser/objc-init.m | 3 +- test/Parser/objc-quirks.m | 18 + test/Preprocessor/expr_usual_conversions.c | 5 +- test/Preprocessor/if_warning.c | 6 + test/Preprocessor/init.c | 10 +- test/Preprocessor/line-directive-output.c | 71 +++ test/Preprocessor/non_fragile_feature.m | 4 + test/Preprocessor/output_paste_avoid.c | 5 +- test/Rewriter/dllimport-typedef.c | 4 +- test/Rewriter/missing-dllimport.c | 4 +- test/Rewriter/rewrite-super-message.mm | 2 +- test/Sema/address_spaces.c | 2 +- test/Sema/altivec-init.c | 4 +- test/Sema/anonymous-struct-union.c | 12 +- test/Sema/arm-layout.c | 49 +- test/Sema/array-constraint.c | 4 +- test/Sema/array-init.c | 14 +- test/Sema/attr-format.c | 2 +- test/Sema/attr-noreturn.c | 2 + test/Sema/attr-section.c | 2 +- test/Sema/bitfield.c | 4 +- test/Sema/block-call.c | 12 +- test/Sema/block-misc.c | 12 +- test/Sema/block-return.c | 14 +- test/Sema/builtin-prefetch.c | 4 +- test/Sema/builtin-stackaddress.c | 4 +- test/Sema/builtins.c | 2 +- test/Sema/cast-to-union.c | 2 +- test/Sema/compare.c | 5 + test/Sema/compound-literal.c | 2 +- test/Sema/conditional-expr.c | 8 +- test/Sema/conditional.c | 4 +- test/Sema/decl-invalid.c | 12 +- test/Sema/declspec.c | 2 +- test/Sema/enum.c | 3 +- test/Sema/exprs.c | 8 +- test/Sema/ext_vector_casts.c | 2 +- test/Sema/format-strings.c | 4 +- test/Sema/function-ptr.c | 6 +- test/Sema/function-redecl.c | 2 +- test/Sema/incompatible-sign.c | 4 +- test/Sema/invalid-init-diag.c | 2 +- test/Sema/offsetof.c | 13 +- test/Sema/parentheses.c | 12 +- test/Sema/pointer-conversion.c | 6 +- test/Sema/predef.c | 2 +- test/Sema/predefined-function.c | 5 +- test/Sema/return.c | 2 +- test/Sema/statements.c | 12 +- test/Sema/struct-compat.c | 2 +- test/Sema/transparent-union.c | 2 +- test/Sema/typedef-retain.c | 4 +- test/Sema/unused-expr.c | 6 + test/Sema/vector-assign.c | 44 +- test/Sema/vector-cast.c | 4 +- test/Sema/warn-missing-braces.c | 2 +- test/Sema/warn-unused-function.c | 7 + test/Sema/warn-unused-parameters.c | 15 +- test/Sema/warn-unused-value.c | 15 + test/Sema/warn-write-strings.c | 2 +- test/Sema/x86-builtin-palignr.c | 10 + test/SemaCXX/abstract.cpp | 9 +- test/SemaCXX/access-base-class.cpp | 2 +- test/SemaCXX/access-control-check.cpp | 2 +- test/SemaCXX/addr-of-overloaded-function.cpp | 32 + test/SemaCXX/aggregate-initialization.cpp | 17 +- test/SemaCXX/anonymous-union.cpp | 2 +- test/SemaCXX/bitfield-layout.cpp | 30 + test/SemaCXX/class-base-member-init.cpp | 23 + test/SemaCXX/class.cpp | 2 +- test/SemaCXX/conditional-expr.cpp | 10 +- test/SemaCXX/constant-expression.cpp | 10 +- test/SemaCXX/constructor-initializer.cpp | 48 +- test/SemaCXX/conversion-function.cpp | 88 ++- test/SemaCXX/copy-assignment.cpp | 2 +- test/SemaCXX/copy-initialization.cpp | 21 +- test/SemaCXX/cstyle-cast.cpp | 2 +- test/SemaCXX/default-assignment-operator.cpp | 22 +- test/SemaCXX/default-constructor-initializers.cpp | 6 +- test/SemaCXX/default1.cpp | 9 +- test/SemaCXX/default2.cpp | 3 +- test/SemaCXX/derived-to-base-ambig.cpp | 4 +- test/SemaCXX/direct-initializer.cpp | 2 +- test/SemaCXX/elaborated-type-specifier.cpp | 2 +- test/SemaCXX/exceptions.cpp | 23 + test/SemaCXX/functional-cast.cpp | 2 +- test/SemaCXX/illegal-member-initialization.cpp | 6 +- test/SemaCXX/implicit-member-functions.cpp | 35 +- test/SemaCXX/inc-decrement-qualifiers.cpp | 9 + test/SemaCXX/libstdcxx_is_pod_hack.cpp | 6 + test/SemaCXX/libstdcxx_map_base_hack.cpp | 25 + test/SemaCXX/local-classes.cpp | 9 + test/SemaCXX/member-expr.cpp | 22 +- test/SemaCXX/member-location.cpp | 5 +- test/SemaCXX/member-pointer.cpp | 16 +- test/SemaCXX/missing-header.cpp | 9 + test/SemaCXX/namespace-alias.cpp | 10 + test/SemaCXX/nested-name-spec.cpp | 16 +- test/SemaCXX/new-delete.cpp | 23 +- test/SemaCXX/no-exceptions.cpp | 21 + test/SemaCXX/offsetof.cpp | 37 +- test/SemaCXX/overload-call.cpp | 30 +- test/SemaCXX/overloaded-operator.cpp | 30 +- test/SemaCXX/qual-id-test.cpp | 6 +- test/SemaCXX/qualified-id-lookup.cpp | 22 + test/SemaCXX/ref-init-ambiguous.cpp | 2 +- test/SemaCXX/references.cpp | 4 +- test/SemaCXX/static-cast.cpp | 2 +- test/SemaCXX/storage-class.cpp | 4 + test/SemaCXX/typedef-redecl.cpp | 13 +- test/SemaCXX/typeid-ref.cpp | 12 + test/SemaCXX/typeid.cpp | 1 - test/SemaCXX/unused-functions.cpp | 8 + test/SemaCXX/user-defined-conversions.cpp | 15 + test/SemaCXX/value-initialization.cpp | 6 +- test/SemaCXX/virtual-override.cpp | 2 +- test/SemaCXX/warn-assignment-condition.cpp | 49 +- test/SemaCXX/warn-missing-noreturn.cpp | 14 + test/SemaCXX/warn-reorder-ctor-initialization.cpp | 57 +- test/SemaCXX/warn-unused-parameters.cpp | 26 + test/SemaCXX/warn-unused-variables.cpp | 8 + test/SemaCXX/warn-weak-vtables.cpp | 2 +- test/SemaObjC/argument-checking.m | 19 +- test/SemaObjC/block-type-safety.m | 18 +- test/SemaObjC/blocks.m | 12 +- test/SemaObjC/call-super-2.m | 2 +- test/SemaObjC/catch-stmt.m | 4 +- test/SemaObjC/class-bitfield.m | 2 +- test/SemaObjC/class-method-lookup.m | 2 +- test/SemaObjC/class-method-self.m | 6 +- .../SemaObjC/compatible-protocol-qualified-types.m | 4 +- test/SemaObjC/compound-init.m | 7 + test/SemaObjC/comptypes-1.m | 12 +- test/SemaObjC/comptypes-3.m | 18 +- test/SemaObjC/comptypes-6.m | 2 +- test/SemaObjC/comptypes-7.m | 32 +- test/SemaObjC/comptypes-legal.m | 4 +- test/SemaObjC/conditional-expr-2.m | 2 +- test/SemaObjC/conditional-expr-3.m | 4 +- test/SemaObjC/conditional-expr-4.m | 2 +- test/SemaObjC/conditional-expr.m | 4 +- test/SemaObjC/continuation-class-err.m | 6 +- test/SemaObjC/default-synthesize.m | 24 + test/SemaObjC/ibaction.m | 15 + test/SemaObjC/id.m | 4 +- .../incompatible-protocol-qualified-types.m | 8 +- test/SemaObjC/invalid-code.m | 7 + test/SemaObjC/invalid-objc-decls-1.m | 4 +- test/SemaObjC/invalid-receiver.m | 2 +- test/SemaObjC/ivar-in-class-extension-error.m | 8 +- test/SemaObjC/ivar-in-class-extension.m | 6 +- test/SemaObjC/ivar-lookup.m | 19 + test/SemaObjC/message.m | 2 +- test/SemaObjC/method-arg-qualifier-warning.m | 6 +- test/SemaObjC/method-bad-param.m | 12 +- test/SemaObjC/objc-cstyle-args-in-methods.m | 20 + test/SemaObjC/pedantic-dynamic-test.m | 16 + test/SemaObjC/property-9.m | 4 +- test/SemaObjC/property-typecheck-1.m | 6 +- test/SemaObjC/protocol-id-test-3.m | 14 +- test/SemaObjC/protocol-typecheck.m | 4 +- test/SemaObjC/protocol-warn.m | 2 +- test/SemaObjC/stmts.m | 4 + test/SemaObjC/super-class-protocol-conformance.m | 47 ++ test/SemaObjC/super.m | 47 +- test/SemaObjC/synthesized-ivar.m | 3 + test/SemaObjC/transparent-union.m | 22 + test/SemaObjC/unused.m | 4 +- test/SemaObjC/warn-incompatible-builtin-types.m | 20 +- test/SemaObjC/warn-selector-selection.m | 2 +- test/SemaObjC/warn-superclass-method-mismatch.m | 2 +- test/SemaObjC/warn-unused-exception-param.m | 4 + test/SemaObjC/warn-write-strings.m | 2 +- test/SemaObjCXX/blocks.mm | 4 +- test/SemaObjCXX/instantiate-expr.mm | 73 +++ test/SemaObjCXX/instantiate-message.mm | 50 ++ test/SemaObjCXX/instantiate-stmt.mm | 77 +++ test/SemaObjCXX/ivar-lookup.mm | 18 + test/SemaObjCXX/ivar-reference-type.mm | 5 + test/SemaObjCXX/linkage-spec.mm | 8 + test/SemaObjCXX/message.mm | 77 ++- test/SemaObjCXX/objc-pointer-conv.mm | 4 +- test/SemaObjCXX/overload-1.mm | 25 + test/SemaObjCXX/parameters.mm | 12 + test/SemaObjCXX/void_to_obj.mm | 2 +- test/SemaTemplate/class-template-decl.cpp | 5 + test/SemaTemplate/constructor-template.cpp | 15 + test/SemaTemplate/default-expr-arguments-2.cpp | 19 + test/SemaTemplate/default-expr-arguments.cpp | 30 +- test/SemaTemplate/dependent-names.cpp | 4 + test/SemaTemplate/destructor-template.cpp | 8 + test/SemaTemplate/elaborated-type-specifier.cpp | 36 ++ .../explicit-specialization-member.cpp | 2 +- test/SemaTemplate/friend-template.cpp | 80 +++ test/SemaTemplate/friend.cpp | 19 + test/SemaTemplate/fun-template-def.cpp | 2 +- test/SemaTemplate/injected-class-name.cpp | 12 + test/SemaTemplate/instantiate-complete.cpp | 20 +- .../instantiate-default-assignment-operator.cpp | 8 +- test/SemaTemplate/instantiate-expr-2.cpp | 19 + test/SemaTemplate/instantiate-expr-5.cpp | 36 +- test/SemaTemplate/instantiate-function-1.cpp | 5 + test/SemaTemplate/instantiate-function-params.cpp | 41 +- test/SemaTemplate/instantiate-local-class.cpp | 4 +- test/SemaTemplate/instantiate-member-class.cpp | 9 +- test/SemaTemplate/instantiate-member-expr.cpp | 2 +- .../instantiate-member-initializers.cpp | 5 +- test/SemaTemplate/instantiate-member-template.cpp | 2 +- test/SemaTemplate/instantiate-method.cpp | 60 +- .../instantiate-non-type-template-parameter.cpp | 24 +- test/SemaTemplate/instantiate-typedef.cpp | 3 +- test/SemaTemplate/instantiate-using-decl.cpp | 2 +- test/SemaTemplate/instantiation-depth.cpp | 10 +- test/SemaTemplate/nested-name-spec-template.cpp | 13 + test/SemaTemplate/qualified-id.cpp | 1 + test/SemaTemplate/temp_arg.cpp | 3 +- test/SemaTemplate/temp_arg_nontype.cpp | 39 +- test/SemaTemplate/temp_arg_type.cpp | 24 +- test/SemaTemplate/template-decl-fail.cpp | 4 +- test/SemaTemplate/typename-specifier-4.cpp | 2 +- test/SemaTemplate/typename-specifier.cpp | 15 +- 426 files changed, 6995 insertions(+), 1662 deletions(-) create mode 100644 test/Analysis/method-call.cpp create mode 100644 test/Analysis/new.cpp create mode 100644 test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp create mode 100644 test/CXX/class.access/class.friend/p2-cxx03.cpp create mode 100644 test/CXX/class.access/class.friend/p3-cxx0x.cpp create mode 100644 test/CXX/class.access/class.protected/p1.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp create mode 100644 test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp create mode 100644 test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp create mode 100644 test/CXX/temp/temp.res/temp.local/p3.cpp create mode 100644 test/CXX/temp/temp.spec/temp.inst/p11.cpp delete mode 100644 test/CodeGen/arm_asm_clobber.c create mode 100644 test/CodeGen/asm-errors.c create mode 100644 test/CodeGen/asm_arm.c create mode 100644 test/CodeGen/bitfield-2.c create mode 100644 test/CodeGen/builtins-ppc-altivec.c create mode 100644 test/CodeGen/catch-undef-behavior.c create mode 100644 test/CodeGen/const-unordered-compare.c create mode 100644 test/CodeGenCXX/PR6747.cpp create mode 100644 test/CodeGenCXX/arm.cpp create mode 100644 test/CodeGenCXX/bitfield-layout.cpp create mode 100644 test/CodeGenCXX/block-destruct.cpp create mode 100644 test/CodeGenCXX/c-linkage.cpp create mode 100644 test/CodeGenCXX/destructor-debug-info.cpp create mode 100644 test/CodeGenCXX/empty-classes.cpp create mode 100644 test/CodeGenCXX/exceptions-no-rtti.cpp create mode 100644 test/CodeGenCXX/field-access-debug-info.cpp create mode 100644 test/CodeGenCXX/implicit-copy-assign-operator.cpp create mode 100644 test/CodeGenCXX/reference-in-blocks.cpp create mode 100644 test/CodeGenCXX/static-local-in-local-class.cpp delete mode 100644 test/CodeGenCXX/virt.cpp create mode 100644 test/CodeGenObjC/atomic-aggregate-property.m create mode 100644 test/CodeGenObjC/encode-cstyle-method.m create mode 100644 test/CodeGenObjC/exceptions.m create mode 100644 test/CodeGenObjC/next-objc-dispatch.m create mode 100644 test/CodeGenObjC/ns-constant-strings.m delete mode 100644 test/CodeGenObjC/objc-gc-aggr-assign.m create mode 100644 test/CodeGenObjCXX/ivar-objects.mm create mode 100644 test/Driver/darwin-objc-defaults.m create mode 100644 test/Driver/darwin-objc-gc.m create mode 100644 test/Driver/darwin-objc-options.m delete mode 100644 test/FixIt/fixit-at.c create mode 100644 test/FixIt/fixit-suffix.c create mode 100644 test/FixIt/fixit-unrecoverable.c create mode 100644 test/FixIt/fixit-unrecoverable.cpp create mode 100644 test/Index/Inputs/complete-pch.h create mode 100644 test/Index/complete-exprs.c create mode 100644 test/Index/complete-method-decls.m create mode 100644 test/Index/complete-objc-message-id.m create mode 100644 test/Index/complete-pch.m create mode 100644 test/Index/invalid-code-rdar_7833619.m create mode 100644 test/Index/local-symbols.m create mode 100644 test/Index/usrs.m create mode 100644 test/Lexer/gnu_keywords.c create mode 100644 test/Lexer/utf-16.c create mode 100644 test/Lexer/utf-16.c.txt create mode 100644 test/Misc/verify.c create mode 100644 test/PCH/objc_stmts.h create mode 100644 test/PCH/objc_stmts.m create mode 100644 test/Preprocessor/line-directive-output.c create mode 100644 test/Sema/x86-builtin-palignr.c create mode 100644 test/SemaCXX/bitfield-layout.cpp create mode 100644 test/SemaCXX/inc-decrement-qualifiers.cpp create mode 100644 test/SemaCXX/libstdcxx_map_base_hack.cpp create mode 100644 test/SemaCXX/missing-header.cpp create mode 100644 test/SemaCXX/no-exceptions.cpp create mode 100644 test/SemaCXX/storage-class.cpp create mode 100644 test/SemaCXX/typeid-ref.cpp create mode 100644 test/SemaCXX/unused-functions.cpp create mode 100644 test/SemaCXX/warn-unused-parameters.cpp create mode 100644 test/SemaObjC/compound-init.m create mode 100644 test/SemaObjC/ibaction.m create mode 100644 test/SemaObjC/objc-cstyle-args-in-methods.m create mode 100644 test/SemaObjC/pedantic-dynamic-test.m create mode 100644 test/SemaObjC/super-class-protocol-conformance.m create mode 100644 test/SemaObjC/transparent-union.m create mode 100644 test/SemaObjC/warn-unused-exception-param.m create mode 100644 test/SemaObjCXX/instantiate-expr.mm create mode 100644 test/SemaObjCXX/instantiate-message.mm create mode 100644 test/SemaObjCXX/instantiate-stmt.mm create mode 100644 test/SemaObjCXX/ivar-lookup.mm create mode 100644 test/SemaObjCXX/ivar-reference-type.mm create mode 100644 test/SemaObjCXX/overload-1.mm create mode 100644 test/SemaObjCXX/parameters.mm create mode 100644 test/SemaTemplate/default-expr-arguments-2.cpp create mode 100644 test/SemaTemplate/elaborated-type-specifier.cpp (limited to 'test') diff --git a/test/ASTMerge/category.m b/test/ASTMerge/category.m index bf0d11b..6ba2292 100644 --- a/test/ASTMerge/category.m +++ b/test/ASTMerge/category.m @@ -6,4 +6,4 @@ // CHECK: category1.m:16:1: note: instance method 'method2' also declared here // CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int') // CHECK: category1.m:24:1: note: instance method 'method3' also declared here -// CHECK: 4 diagnostics generated. +// CHECK: 2 errors generated. diff --git a/test/ASTMerge/enum.c b/test/ASTMerge/enum.c index 9b78fd1..4380d19 100644 --- a/test/ASTMerge/enum.c +++ b/test/ASTMerge/enum.c @@ -22,4 +22,4 @@ // CHECK: enum1.c:30:6: note: no corresponding enumerator here // CHECK: enum2.c:34:3: error: external variable 'x5' declared with incompatible types in different translation units ('enum E5' vs. 'enum E5') // CHECK: enum1.c:34:3: note: declared here with type 'enum E5' -// CHECK: 20 diagnostics generated +// CHECK: 4 warnings and 4 errors generated diff --git a/test/ASTMerge/function.c b/test/ASTMerge/function.c index 581b6ec..f97ecee 100644 --- a/test/ASTMerge/function.c +++ b/test/ASTMerge/function.c @@ -6,4 +6,4 @@ // CHECK: function1.c:2:6: note: declared here with type 'void (int, float)' // CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)') // CHECK: function1.c:4:6: note: declared here with type 'void (void)' -// CHECK: 4 diagnostics generated +// CHECK: 2 errors generated diff --git a/test/ASTMerge/interface.m b/test/ASTMerge/interface.m index 47e4e05..420ae38 100644 --- a/test/ASTMerge/interface.m +++ b/test/ASTMerge/interface.m @@ -15,5 +15,5 @@ // CHECK: interface1.m:46:1: note: class method 'bar:' also declared here // CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float') // CHECK: interface1.m:58:19: note: declared here with type 'float' -// CHECK: 13 diagnostics generated +// CHECK: 6 errors generated diff --git a/test/ASTMerge/property.m b/test/ASTMerge/property.m index 0fd7e48..5f7a730 100644 --- a/test/ASTMerge/property.m +++ b/test/ASTMerge/property.m @@ -6,4 +6,4 @@ // CHECK: property1.m:10:28: note: declared here with type 'float' // CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float') // CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here -// CHECK: 4 diagnostics generated. +// CHECK: 2 errors generated. diff --git a/test/ASTMerge/struct.c b/test/ASTMerge/struct.c index e72b93b..7217222 100644 --- a/test/ASTMerge/struct.c +++ b/test/ASTMerge/struct.c @@ -39,4 +39,4 @@ // CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here // CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError') // CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError' -// CHECK: 37 diagnostics +// CHECK: 8 warnings and 7 errors generated diff --git a/test/ASTMerge/typedef.c b/test/ASTMerge/typedef.c index 4498864..6f91129 100644 --- a/test/ASTMerge/typedef.c +++ b/test/ASTMerge/typedef.c @@ -4,4 +4,4 @@ // CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int')) // CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int') -// CHECK: 2 diagnostics +// CHECK: 1 error diff --git a/test/ASTMerge/var.c b/test/ASTMerge/var.c index fd30794..7f23b9f 100644 --- a/test/ASTMerge/var.c +++ b/test/ASTMerge/var.c @@ -9,4 +9,4 @@ // CHECK: var1.h:1:8: note: declared here with type 'double' // CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]') // CHECK: var1.c:7:5: note: declared here with type 'int [18]' -// CHECK: 6 diagnostics +// CHECK: 3 errors diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 952de73..acaf74d 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f2 -verify %s - +// RUN: false +// XFAIL: * int f1() { int y = 1; y++; diff --git a/test/Analysis/inline2.c b/test/Analysis/inline2.c index e2758c1..ec965a6 100644 --- a/test/Analysis/inline2.c +++ b/test/Analysis/inline2.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f2 -verify %s +// RUN: false +// XFAIL: * // Test parameter 'a' is registered to LiveVariables analysis data although it // is not referenced in the function body. diff --git a/test/Analysis/inline3.c b/test/Analysis/inline3.c index 3661263..8f45858 100644 --- a/test/Analysis/inline3.c +++ b/test/Analysis/inline3.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f2 -verify %s - +// RUN: false +// XFAIL: * // Test when entering f1(), we set the right AnalysisContext to Environment. // Otherwise, block-level expr '1 && a' would not be block-level. diff --git a/test/Analysis/inline4.c b/test/Analysis/inline4.c index dd2379f..b2b3c34 100644 --- a/test/Analysis/inline4.c +++ b/test/Analysis/inline4.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -inline-call -analyzer-store region -analyze-function f -verify %s - +// RUN: false +// XFAIL: * int g(int a) { return a; } diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp new file mode 100644 index 0000000..dd89159 --- /dev/null +++ b/test/Analysis/method-call.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s +struct A { + int x; + A(int a) { x = a; } + int getx() { return x; } +}; + +void f1() { + A x(3); + if (x.getx() == 3) { + int *p = 0; + *p = 3; // expected-warning{{Dereference of null pointer}} + } else { + int *p = 0; + *p = 3; // no-warning + } +} + diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index d10b9fa..4255141 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -955,3 +955,62 @@ void pr6288_b(void) { *(px[0]) = 0; // no-warning } +// - A bug in RemoveDeadBindings was causing instance variable bindings +// to get prematurely pruned from the state. +@interface Rdar7817800 { + char *x; +} +- (void) rdar7817800_baz; +@end + +char *rdar7817800_foobar(); +void rdar7817800_qux(void*); + +@implementation Rdar7817800 +- (void) rdar7817800_baz { + if (x) + rdar7817800_qux(x); + x = rdar7817800_foobar(); + // Previously this triggered a bogus null dereference warning. + x[1] = 'a'; // no-warning +} +@end + +// PR 6036 - This test case triggered a crash inside StoreManager::CastRegion because the size +// of 'unsigned long (*)[0]' is 0. +struct pr6036_a { int pr6036_b; }; +struct pr6036_c; +void u132monitk (struct pr6036_c *pr6036_d) { + (void) ((struct pr6036_a *) (unsigned long (*)[0]) ((char *) pr6036_d - 1))->pr6036_b; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}} +} + +// - ?-expressions used as a base of a member expression should be treated as an lvalue +typedef struct rdar7813989_NestedVal { int w; } rdar7813989_NestedVal; +typedef struct rdar7813989_Val { rdar7813989_NestedVal nv; } rdar7813989_Val; + +int rdar7813989(int x, rdar7813989_Val *a, rdar7813989_Val *b) { + // This previously crashed with an assertion failure. + int z = (x ? a->nv : b->nv).w; + return z + 1; +} + +// PR 6844 - Don't crash on vaarg expression. +typedef __builtin_va_list va_list; +void map(int srcID, ...) { + va_list ap; + int i; + for (i = 0; i < srcID; i++) { + int v = __builtin_va_arg(ap, int); + } +} + +// PR 6854 - crash when casting symbolic memory address to a float +// Handle casting from a symbolic region to a 'float'. This isn't +// really all that intelligent, but previously this caused a crash +// in SimpleSValuator. +void pr6854(void * arg) { + void * a = arg; + *(void**)a = arg; + float f = *(float*) a; +} + diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index fa05f6f..2b21eec 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -933,3 +933,27 @@ void foo_rev95547_b(struct s_rev95547 w) { struct s_rev95547 w2 = w; w2.z1.x += 20.0; // no-warning } + +//===----------------------------------------------------------------------===// +// Test handling statement expressions that don't populate a CFG block that +// is used to represent the computation of the RHS of a logical operator. +// This previously triggered a crash. +//===----------------------------------------------------------------------===// + +void pr6938() { + if (1 && ({ + while (0); + 0; + }) == 0) { + } +} + +void pr6938_b() { + if (1 && *({ // expected-warning{{Dereference of null pointer}} + while (0) {} + ({ + (int *) 0; + }); + }) == 0) { + } +} diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp new file mode 100644 index 0000000..f26eecd --- /dev/null +++ b/test/Analysis/new.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store region -verify %s + +void f1() { + int *n = new int; + if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}} + } +} + +void f2() { + int *n = new int(3); + if (*n) { // no-warning + } +} + diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m index 5722a04..5f51871 100644 --- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m +++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m @@ -72,11 +72,11 @@ int handleVoidInComma() { int marker(void) { // control reaches end of non-void function } +// CHECK-darwin8: control reaches end of non-void function // CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage // CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage // CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage // CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage -// CHECK-darwin8: control reaches end of non-void function -// CHECK-darwin8: 5 diagnostics generated +// CHECK-darwin8: 5 warnings generated // CHECK-darwin9: control reaches end of non-void function -// CHECK-darwin9: 1 diagnostic generated +// CHECK-darwin9: 1 warning generated diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index 5376ca0..5a1049c 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -62,8 +62,8 @@ int f4(int *p) { int f4_b() { short array[2]; - uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion initializing}} - short *p = x; // expected-warning{{incompatible integer to pointer conversion initializing}} + uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}} + short *p = x; // expected-warning{{incompatible integer to pointer conversion}} // The following branch should be infeasible. if (!(p = &array[0])) { diff --git a/test/Analysis/override-werror.c b/test/Analysis/override-werror.c index 522b9dc..f4854bb 100644 --- a/test/Analysis/override-werror.c +++ b/test/Analysis/override-werror.c @@ -6,7 +6,7 @@ // analyzer results. char* f(int *p) { - return p; // expected-warning{{incompatible pointer types returning 'int *', expected 'char *'}} + return p; // expected-warning{{incompatible pointer types}} } void g(int *p) { diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c index 777ad19..9d036ac 100644 --- a/test/Analysis/unix-fns.c +++ b/test/Analysis/unix-fns.c @@ -1,11 +1,24 @@ -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region -// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem %s -analyzer-store=region -fblocks -verify +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic -fblocks -verify + +struct _opaque_pthread_once_t { + long __sig; + char __opaque[8]; +}; +typedef struct _opaque_pthread_once_t __darwin_pthread_once_t; +typedef __darwin_pthread_once_t pthread_once_t; +int pthread_once(pthread_once_t *, void (*)(void)); + +typedef void (^dispatch_block_t)(void); +typedef long dispatch_once_t; +void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block); #ifndef O_CREAT #define O_CREAT 0x0200 #define O_RDONLY 0x0000 #endif int open(const char *, int, ...); +int close(int fildes); void test_open(const char *path) { int fd; @@ -17,3 +30,23 @@ void test_open(const char *path) { if (!fd) close(fd); } + +void test_dispatch_once() { + dispatch_once_t pred = 0; + do { if (__builtin_expect(*(&pred), ~0l) != ~0l) dispatch_once((&pred), (^() {})); } while (0); // expected-warning{{Call to 'dispatch_once' uses the local variable 'pred' for the predicate value}} +} +void test_dispatch_once_neg() { + static dispatch_once_t pred = 0; + do { if (__builtin_expect(*(&pred), ~0l) != ~0l) dispatch_once((&pred), (^() {})); } while (0); // no-warning +} + +void test_pthread_once_aux(); + +void test_pthread_once() { + pthread_once_t pred = {0x30B1BCBA, {0}}; + pthread_once(&pred, test_pthread_once_aux); // expected-warning{{Call to 'pthread_once' uses the local variable 'pred' for the "control" value}} +} +void test_pthread_once_neg() { + static pthread_once_t pred = {0x30B1BCBA, {0}}; + pthread_once(&pred, test_pthread_once_aux); // no-warning +} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp index ee01416..0e262f3 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp @@ -71,3 +71,18 @@ namespace O { } } +extern "C" { + struct L { }; +} + +void h(L); // expected-note{{candidate function}} + +namespace P { + void h(L); // expected-note{{candidate function}} + void test_transparent_context_adl(L l) { + { + h(l); // expected-error {{call to 'h' is ambiguous}} + } + } +} + diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp new file mode 100644 index 0000000..004d1e4 --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp @@ -0,0 +1,60 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace test0 { + struct A { + static int foo; + }; + + namespace i0 { + typedef int A; // expected-note {{declared here}} + + int test() { + struct A a; // expected-error {{elaborated type refers to a typedef}} + return a.foo; + } + } + + namespace i1 { + template class A; // expected-note {{declared here}} + + int test() { + struct A a; // expected-error {{elaborated type refers to a template}} + return a.foo; + } + } + + namespace i2 { + int A; + + int test() { + struct A a; + return a.foo; + } + } + + namespace i3 { + void A(); + + int test() { + struct A a; + return a.foo; + } + } + + namespace i4 { + template void A(); + + int test() { + struct A a; + return a.foo; + } + } + + // This should magically be okay; see comment in SemaDecl.cpp. + // rdar://problem/7898108 + typedef struct A A; + int test() { + struct A a; + return a.foo; + } +} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp index f9bac40..3039396 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp @@ -36,7 +36,7 @@ namespace Numbers { double d; }; Number zero(0.0f); - void g(Number); + void g(Number); // expected-note 2{{passing argument to parameter here}} } void test2() { diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp index e579546..d2afd5d 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp @@ -32,6 +32,6 @@ namespace test1 { // Test that we don't find the injected class name when parsing base // specifiers. namespace test2 { - template struct bar {}; // expected-note {{template parameter is declared here}} - template struct foo : bar {}; // expected-error {{template argument for template type parameter must be a type}} + template struct bar {}; + template struct foo : bar {}; // expected-error {{use of class template foo requires template arguments}} expected-note {{template is declared here}} } diff --git a/test/CXX/class.access/class.access.base/p1.cpp b/test/CXX/class.access/class.access.base/p1.cpp index 1bbcedb..0988431 100644 --- a/test/CXX/class.access/class.access.base/p1.cpp +++ b/test/CXX/class.access/class.access.base/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access.base]p1(a): // If a class is declared to be a base class for another class using diff --git a/test/CXX/class.access/class.access.base/p5.cpp b/test/CXX/class.access/class.access.base/p5.cpp index 96037e7..938d9fb 100644 --- a/test/CXX/class.access/class.access.base/p5.cpp +++ b/test/CXX/class.access/class.access.base/p5.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faccess-control -verify %s +// RUN: %clang_cc1 -verify %s namespace test0 { struct A { diff --git a/test/CXX/class.access/class.access.nest/p1.cpp b/test/CXX/class.access/class.access.nest/p1.cpp index d2644c6..eceffcf 100644 --- a/test/CXX/class.access/class.access.nest/p1.cpp +++ b/test/CXX/class.access/class.access.nest/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // Derived from GNU's std::string namespace test0 { diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 22266cd..991698d 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++'0x [class.friend] p1: // A friend of a class is a function or class that is given permission to use @@ -192,3 +192,98 @@ namespace test4 { return a == b; // expected-note {{requested here}} } } + + +// PR6174 +namespace test5 { + namespace ns { + class A; + } + + class ns::A { + private: int x; + friend class B; + }; + + namespace ns { + class B { + int test(A *p) { return p->x; } + }; + } +} + +// PR6207 +namespace test6 { + struct A {}; + + struct B { + friend A::A(); + friend A::~A(); + friend A &A::operator=(const A&); + }; +} + +namespace test7 { + template struct X { + X(); + ~X(); + void foo(); + void bar(); + }; + + class A { + friend void X::foo(); + friend X::X(); + friend X::X(const X&); + + private: + A(); // expected-note 2 {{declared private here}} + }; + + template<> void X::foo() { + A a; + } + + template<> void X::bar() { + A a; // expected-error {{calling a private constructor}} + } + + template<> X::X() { + A a; + } + + template<> X::~X() { + A a; // expected-error {{calling a private constructor}} + } +} + +// Return types, parameters and default arguments to friend functions. +namespace test8 { + class A { + typedef int I; // expected-note 4 {{declared private here}} + static const I x = 0; + friend I f(I i); + template friend I g(I i); + }; + + // FIXME: This should be on line 264. + const A::I A::x; // expected-note {{declared private here}} + A::I f(A::I i = A::x) {} + template A::I g(A::I i) { + T t; + } + template A::I g(A::I i); + + A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}} + template A::I g2(A::I i) { // expected-error 2 {{is a private member of}} + T t; + } + template A::I g2(A::I i); +} + +// PR6885 +namespace test9 { + class B { + friend class test9; + }; +} diff --git a/test/CXX/class.access/class.friend/p2-cxx03.cpp b/test/CXX/class.access/class.friend/p2-cxx03.cpp new file mode 100644 index 0000000..0391c4b --- /dev/null +++ b/test/CXX/class.access/class.friend/p2-cxx03.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +template +class X0 { + friend T; // expected-warning{{non-class type 'T' cannot be a friend}} +}; + +class X1 { }; +enum E1 { }; +X0 x0a; +X0 x0b; +X0 x0c; +X0 x0d; + diff --git a/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/test/CXX/class.access/class.friend/p3-cxx0x.cpp new file mode 100644 index 0000000..4f55e53 --- /dev/null +++ b/test/CXX/class.access/class.friend/p3-cxx0x.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s +template +class X0 { + friend T; +}; + +class Y1 { }; +enum E1 { }; +X0 x0a; +X0 x0b; +X0 x0c; +X0 x0d; + +template +class X1 { + friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}} +}; + +struct Y2 { + struct type { }; +}; + +struct Y3 { + typedef int type; +}; + +X1 x1a; +X1 x1b; +X1 x1c; // expected-note{{in instantiation of template class 'X1' requested here}} diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp new file mode 100644 index 0000000..6ff630c --- /dev/null +++ b/test/CXX/class.access/class.protected/p1.cpp @@ -0,0 +1,387 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace test0 { + class A { + protected: int x; // expected-note 3 {{declared}} + static int sx; // expected-note 3 {{declared}} + }; + class B : public A { + }; + class C : protected A { // expected-note {{declared}} + }; + class D : private B { // expected-note 3 {{constrained}} + }; + + void test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; // expected-error {{'sx' is a protected member}} + } + void test(B &b) { + (void) b.x; // expected-error {{'x' is a protected member}} + (void) b.sx; // expected-error {{'sx' is a protected member}} + } + void test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} expected-error {{private base class}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } +} + +namespace test1 { + class A { + protected: int x; + static int sx; + static void test(A&); + }; + class B : public A { + static void test(B&); + }; + class C : protected A { + static void test(C&); + }; + class D : private B { + static void test(D&); + }; + + void A::test(A &a) { + (void) a.x; + (void) a.sx; + } + void B::test(B &b) { + (void) b.x; + (void) b.sx; + } + void C::test(C &c) { + (void) c.x; + (void) c.sx; + } + void D::test(D &d) { + (void) d.x; + (void) d.sx; + } +} + +namespace test2 { + class A { + protected: int x; // expected-note 3 {{declared}} + static int sx; + static void test(A&); + }; + class B : public A { + static void test(A&); + }; + class C : protected A { + static void test(A&); + }; + class D : private B { + static void test(A&); + }; + + void A::test(A &a) { + (void) a.x; + (void) a.sx; + } + void B::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } + void C::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } + void D::test(A &a) { + (void) a.x; // expected-error {{'x' is a protected member}} + (void) a.sx; + } +} + +namespace test3 { + class B; + class A { + protected: int x; // expected-note {{declared}} + static int sx; + static void test(B&); + }; + class B : public A { + static void test(B&); + }; + class C : protected A { + static void test(B&); + }; + class D : private B { + static void test(B&); + }; + + void A::test(B &b) { + (void) b.x; + (void) b.sx; + } + void B::test(B &b) { + (void) b.x; + (void) b.sx; + } + void C::test(B &b) { + (void) b.x; // expected-error {{'x' is a protected member}} + (void) b.sx; + } + void D::test(B &b) { + (void) b.x; + (void) b.sx; + } +} + +namespace test4 { + class C; + class A { + protected: int x; // expected-note 2 {{declared}} + static int sx; + static void test(C&); + }; + class B : public A { + static void test(C&); + }; + class C : protected A { // expected-note 4 {{constrained}} expected-note 3 {{declared}} + static void test(C&); + }; + class D : private B { + static void test(C&); + }; + + void A::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void B::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } + void C::test(C &c) { + (void) c.x; + (void) c.sx; + } + void D::test(C &c) { + (void) c.x; // expected-error {{'x' is a protected member}} \ + // expected-error {{protected base class}} + (void) c.sx; // expected-error {{'sx' is a protected member}} + } +} + +namespace test5 { + class D; + class A { + protected: int x; + static int sx; + static void test(D&); + }; + class B : public A { + static void test(D&); + }; + class C : protected A { + static void test(D&); + }; + class D : private B { // expected-note 9 {{constrained}} + static void test(D&); + }; + + void A::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void B::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void C::test(D &d) { + (void) d.x; // expected-error {{'x' is a private member}} \ + // expected-error {{cannot cast}} + (void) d.sx; // expected-error {{'sx' is a private member}} + } + void D::test(D &d) { + (void) d.x; + (void) d.sx; + } +} + +namespace test6 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(A&); + }; + class B : public A { + static void test(A&); + }; + class C : protected A { + static void test(A&); + }; + class D : private B { + static void test(A&); + }; + + void A::test(A &a) { + a.foo(10); + a.foo(Static()); + } + void B::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } + void C::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } + void D::test(A &a) { + a.foo(10); // expected-error {{'foo' is a protected member}} + a.foo(Static()); + } +} + +namespace test7 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(); + }; + class B : public A { + static void test(); + }; + class C : protected A { + static void test(); + }; + class D : private B { + static void test(); + }; + + void A::test() { + void (A::*x)(int) = &A::foo; + void (*sx)(Static) = &A::foo; + } + void B::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } + void C::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } + void D::test() { + void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} + void (*sx)(Static) = &A::foo; + } +} + +namespace test8 { + class Static {}; + class A { + protected: + void foo(int); // expected-note 3 {{declared}} + void foo(long); + static void foo(Static); + + static void test(); + }; + class B : public A { + static void test(); + }; + class C : protected A { + static void test(); + }; + class D : private B { + static void test(); + }; + void call(void (A::*)(int)); + void calls(void (*)(Static)); + + void A::test() { + call(&A::foo); + calls(&A::foo); + } + void B::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } + void C::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } + void D::test() { + call(&A::foo); // expected-error {{'foo' is a protected member}} + calls(&A::foo); + } +} + +namespace test9 { + class A { + protected: int foo(); // expected-note 8 {{declared}} + }; + + class B : public A { + friend class D; + }; + + class C : protected B { // expected-note {{declared}} \ + // expected-note 6 {{constrained}} + }; + + class D : public A { + static void test(A &a) { + a.foo(); // expected-error {{'foo' is a protected member}} + a.A::foo(); // expected-error {{'foo' is a protected member}} + a.B::foo(); + a.C::foo(); // expected-error {{'foo' is a protected member}} + } + + static void test(B &b) { + b.foo(); + b.A::foo(); // expected-error {{'foo' is a protected member}} + b.B::foo(); + b.C::foo(); // expected-error {{'foo' is a protected member}} + } + + static void test(C &c) { + c.foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{cannot cast}} + c.A::foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{'A' is a protected member}} \ + // expected-error {{cannot cast}} + c.B::foo(); // expected-error {{'B' is a protected member}} \ + // expected-error {{cannot cast}} + c.C::foo(); // expected-error {{'foo' is a protected member}} \ + // expected-error {{cannot cast}} + } + + static void test(D &d) { + d.foo(); + d.A::foo(); + d.B::foo(); + d.C::foo(); // expected-error {{'foo' is a protected member}} + } + }; +} + +namespace test10 { + template class A { + protected: + int foo(); + int foo() const; + + ~A() { foo(); } + }; + + template class A; +} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp index 3bbdbab8..1cd8966 100644 --- a/test/CXX/class.access/p4.cpp +++ b/test/CXX/class.access/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access]p4: @@ -88,13 +88,24 @@ namespace test1 { namespace test2 { class A { private: - A(); // expected-note {{declared private here}} + A(); // expected-note 3 {{declared private here}} static A foo; }; A a; // expected-error {{calling a private constructor}} A A::foo; // okay + + class B : A { }; // expected-error {{base class 'test2::A' has private constructor}} + B b; + + class C : virtual A { + public: + C(); + }; + + class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private constructor}} + D d; } // Implicit destructor calls. @@ -191,13 +202,13 @@ namespace test5 { void operator=(const A &); // expected-note 2 {{declared private here}} }; - class Test1 { A a; }; // expected-error {{field of type 'test5::A' has private copy assignment operator}} + class Test1 { A a; }; // expected-error {{private member}} void test1() { Test1 a; a = Test1(); } - class Test2 : A {}; // expected-error {{base class 'test5::A' has private copy assignment operator}} + class Test2 : A {}; // expected-error {{private member}} void test2() { Test2 a; a = Test2(); @@ -327,3 +338,83 @@ namespace test13 { (void) d->x; } } + +// Destructors for temporaries. +namespace test14 { + class A { + private: ~A(); // expected-note {{declared private here}} + }; + A foo(); + + void test() { + foo(); // expected-error {{temporary of type 'test14::A' has private destructor}} + } + + class X { + ~X(); // expected-note {{declared private here}} + }; + + struct Y1 { + operator X(); + }; + + void g() { + const X &xr = Y1(); // expected-error{{temporary of type 'test14::X' has private destructor}} + } +} + +// PR 7024 +namespace test15 { + template class A { + private: + int private_foo; // expected-note {{declared private here}} + static int private_sfoo; // expected-note {{declared private here}} + protected: + int protected_foo; // expected-note 4 {{declared protected here}} + static int protected_sfoo; // expected-note 3 {{declared protected here}} + + int test1(A &a) { + return a.private_foo; // expected-error {{private member}} + } + + int test2(A &a) { + return a.private_sfoo; // expected-error {{private member}} + } + + int test3(A &a) { + return a.protected_foo; // expected-error {{protected member}} + } + + int test4(A &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class A; + template class A; // expected-note 4 {{in instantiation}} + + template class B : public A { + // TODO: These first two accesses can be detected as ill-formed at + // definition time because they're member accesses and A can't + // be a subclass of B for any T. + + int test1(A &a) { + return a.protected_foo; // expected-error 2 {{protected member}} + } + + int test2(A &a) { + return a.protected_sfoo; // expected-error {{protected member}} + } + + int test3(B &b) { + return b.protected_foo; // expected-error {{protected member}} + } + + int test4(B &b) { + return b.protected_sfoo; // expected-error {{protected member}} + } + }; + + template class B; // expected-note {{in instantiation}} + template class B; // expected-note 4 {{in instantiation}} +} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp index aaf510a..734a4d8 100644 --- a/test/CXX/class.access/p6.cpp +++ b/test/CXX/class.access/p6.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // C++0x [class.access]p6: // All access controls in [class.access] affect the ability to @@ -52,3 +52,70 @@ namespace test1 { A apriv = priv; // expected-error {{private constructor}} } } + +// PR6967 +namespace test2 { + class A { + public: + template static void set(T &t, typename T::type v) { + t.value = v; + } + template static typename T::type get(const T &t) { + return t.value; + } + }; + + class B { + friend class A; + + private: + typedef int type; + type value; + }; + + int test() { + B b; + A::set(b, 0); + return A::get(b); + } +} + +namespace test3 { + class Green {}; class Blue {}; + + // We have to wrap this in a class because a partial specialization + // isn't actually in the context of the template. + struct Outer { + template class A { + }; + }; + + template class Outer::A { + public: + static void foo(); + }; + + class B { + private: typedef Green nature; + friend class Outer; + }; + + void test() { + Outer::A::foo(); + Outer::A::foo(); // expected-error {{no member named 'foo'}} + } +} + +namespace test4 { + template class A { + private: typedef int type; + template friend void foo(U &, typename U::type); + }; + + template void foo(U &, typename U::type) {} + + void test() { + A a; + foo(a, 0); + } +} diff --git a/test/CXX/class/class.friend/p2.cpp b/test/CXX/class/class.friend/p2.cpp index 9fe2b17..eb5036f 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-error {{friends can only be classes or functions}} - friend B0; // expected-error {{must specify 'struct' to befriend}} + friend int; // expected-warning {{non-class type 'int' cannot be a friend}} + friend B0; // expected-warning {{must specify 'struct' to befriend}} friend class C; // okay }; diff --git a/test/CXX/class/class.local/p2.cpp b/test/CXX/class/class.local/p2.cpp index 2b1359c..db4c90f 100644 --- a/test/CXX/class/class.local/p2.cpp +++ b/test/CXX/class/class.local/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -faccess-control +// RUN: %clang_cc1 -fsyntax-only -verify %s struct A { }; diff --git a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp index f5fbf7a..c81e4ef 100644 --- a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp +++ b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp @@ -50,7 +50,7 @@ namespace test1 { } namespace test2 { - class Unrelated { + struct Unrelated { void foo(); }; diff --git a/test/CXX/conv/conv.mem/p4.cpp b/test/CXX/conv/conv.mem/p4.cpp index 42f6343..e0748d8 100644 --- a/test/CXX/conv/conv.mem/p4.cpp +++ b/test/CXX/conv/conv.mem/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s struct Base { int data; diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp index a5f314d..ddcbe78 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp @@ -53,4 +53,16 @@ struct Y { friend union X1; }; +namespace N { + namespace M { + template class X; + } +} + +namespace N3 { + class Y { + template friend class N::M::X; + }; +} + // FIXME: Woefully inadequate for testing diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp index 89e9c89..bb1d67f 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // We have to avoid ADL for this test. @@ -12,7 +12,8 @@ namespace Test0 { test<1> foo(class foo); namespace A { - test<2> foo(class ::foo); // expected-note {{candidate}} + test<2> foo(class ::foo); // expected-note {{candidate}} \ + // expected-note{{passing argument to parameter here}} void test0() { using ::foo; @@ -38,7 +39,7 @@ namespace Test0 { test<2> _1 = (foo)(a); class Test0::foo b; - test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class foo' is possible}} + test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo' is possible}} } } } diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp index 23da98c..a43d9e0 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp @@ -166,7 +166,7 @@ namespace test3 { template struct C : A { using typename A::type; - using typename A::hiding; // expected-note {{declared at}} \ + using typename A::hiding; // expected-note {{declared here}} \ // expected-error {{'typename' keyword used on a non-type}} using typename A::union_member; // expected-error {{'typename' keyword used on a non-type}} using typename A::enumerator; // expected-error {{'typename' keyword used on a non-type}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp index c530311..b04e869 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp @@ -13,7 +13,7 @@ class A1 { friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} friend enum A; // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ - // expected-error {{enum types cannot be friends}} + // expected-warning {{cannot be a friend}} }; template struct B { // expected-note {{previous use is here}} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp new file mode 100644 index 0000000..5a342d4 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p16-cxx0x-no-extra-copy.cpp @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// C++03 requires that we check for a copy constructor when binding a +// reference to a reference-compatible rvalue, since we are allowed to +// make a copy. C++0x does not permit the copy, so ensure that we +// don't diagnose cases where the copy constructor is unavailable. + +struct X1 { + X1(); + explicit X1(const X1&); +}; + +struct X2 { + X2(); + +private: + X2(const X2&); +}; + +struct X3 { + X3(); + +private: + X3(X3&); +}; + +template +T get_value_badly() { + double *dp = 0; + T *tp = dp; + return T(); +} + +template +struct X4 { + X4(); + X4(const X4&, T = get_value_badly()); +}; + +void g1(const X1&); +void g2(const X2&); +void g3(const X3&); +void g4(const X4&); + +void test() { + g1(X1()); + g2(X2()); + g3(X3()); + g4(X4()); +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp new file mode 100644 index 0000000..1639411 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// C++03 requires that we check for a copy constructor when binding a +// reference to a temporary, since we are allowed to make a copy, Even +// though we don't actually make that copy, make sure that we diagnose +// cases where that copy constructor is somehow unavailable. + +struct X1 { + X1(); + explicit X1(const X1&); +}; + +struct X2 { + X2(); + +private: + X2(const X2&); // expected-note{{declared private here}} +}; + +struct X3 { + X3(); + +private: + X3(X3&); // expected-note{{candidate constructor not viable: no known conversion from 'X3' to 'X3 &' for 1st argument}} +}; + +// Check for instantiation of default arguments +template +T get_value_badly() { + double *dp = 0; + T *tp = dp; // expected-error{{ cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}} + return T(); +} + +template +struct X4 { + X4(); + X4(const X4&, T = get_value_badly()); // expected-note{{in instantiation of}} +}; + +// Check for "dangerous" default arguments that could cause recursion. +struct X5 { + X5(); + X5(const X5&, const X5& = X5()); // expected-error{{no viable constructor copying parameter of type 'X5'}} +}; + +void g1(const X1&); +void g2(const X2&); +void g3(const X3&); +void g4(const X4&); +void g5(const X5&); + +void test() { + g1(X1()); // expected-error{{no viable constructor copying parameter of type 'X1'}} + g2(X2()); // expected-error{{calling a private constructor of class 'X2'}} + g3(X3()); // expected-error{{no viable constructor copying parameter of type 'X3'}} + g4(X4()); + g5(X5()); // expected-error{{no viable constructor copying parameter of type 'X5'}} +} + +// Check for dangerous recursion in default arguments. diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp index d757adf..9b39259 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp @@ -17,11 +17,11 @@ struct B : A { } b; // CHECK: example1 void example1() { // CHECK: A &ra = - // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue + // CHECK: ImplicitCastExpr{{.*}}'struct A' lvalue A &ra = b; // CHECK: A const &rca = // CHECK: ImplicitCastExpr{{.*}}'struct A const' - // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: ImplicitCastExpr{{.*}}'struct A' const A& rca = b; } @@ -35,12 +35,12 @@ struct X { void example2() { // CHECK: A const &rca = // CHECK: ImplicitCastExpr{{.*}}'struct A const' - // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: ImplicitCastExpr{{.*}}'struct A' // CHECK: CallExpr{{.*}}B const A &rca = f(); // CHECK: A const &r = // CHECK: ImplicitCastExpr{{.*}}'struct A const' - // CHECK: ImplicitCastExpr{{.*}}'struct A' + // CHECK: ImplicitCastExpr{{.*}}'struct A' // CHECK: CXXMemberCallExpr{{.*}}'struct B' const A& r = x; } diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp index 4c7ee94..51d61a5 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp @@ -22,3 +22,19 @@ namespace PR6264 { T bar = S(); } } + +namespace PR6066 { + struct B { }; + struct A : B { + operator B*(); + operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}} + }; + + void f(B&); // no rvalues accepted + void f(B*); + + int g() { + f(A()); // calls f(B*) + return 0; + } +} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp index 7ee052c..3100e56 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp @@ -2,7 +2,8 @@ float global_f; -void f0(int *ip = &global_f); // expected-error{{cannot initialize}} +void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \ +// expected-note{{passing argument to parameter 'ip' here}} // Example from C++03 standard int a = 1; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp index 00234ac..9ab0b48 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s class C { +public: void f(int i = 3); // expected-note{{here}} void g(int i, int j = 99); }; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp index 17fd712..aaf7451 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp @@ -9,10 +9,10 @@ typedef int &intref; typedef intref &intrefref; -template class RefMem { +template class RefMem { // expected-warning{{class 'RefMem' does not declare any constructor to initialize its non-modifiable members}} T & - member; + member; // expected-note{{ reference member 'member' will never be initialized}} }; struct RefRef { @@ -34,7 +34,7 @@ struct RefRef { int & > - refref3; // collapses + refref3; // collapses expected-note{{in instantiation of template class 'RefMem' requested here}} }; diff --git a/test/CXX/except/except.handle/p16.cpp b/test/CXX/except/except.handle/p16.cpp index 87972f5..4950a2f 100644 --- a/test/CXX/except/except.handle/p16.cpp +++ b/test/CXX/except/except.handle/p16.cpp @@ -11,12 +11,12 @@ class X { public: X(const X &) { int *ip = 0; - ptr = ip; // expected-error{{incompatible type assigning 'int *', expected 'float *'}} + ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}} } ~X() { float *fp = 0; - ptr = fp; // expected-error{{incompatible type assigning 'float *', expected 'int *'}} + ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}} } }; diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp index 4b2b5ae..2fa30e5 100644 --- a/test/CXX/expr/expr.unary/expr.delete/p5.cpp +++ b/test/CXX/expr/expr.unary/expr.delete/p5.cpp @@ -11,7 +11,7 @@ class T0 { ~T0(); }; // The trivial case, inside a template instantiation. template -class T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} +struct T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} class T1_B; // expected-note {{forward declaration}} void f0() { T1_A x; } // expected-note {{in instantiation of member function}} diff --git a/test/CXX/expr/expr.unary/expr.new/p19.cpp b/test/CXX/expr/expr.unary/expr.new/p19.cpp index 6134779..bb69fd5 100644 --- a/test/CXX/expr/expr.unary/expr.new/p19.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p19.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Operator delete template for placement new with global lookup diff --git a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp index c188e1e..4c924b1 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fexceptions %s typedef __SIZE_TYPE__ size_t; struct S { diff --git a/test/CXX/expr/expr.unary/expr.new/p20.cpp b/test/CXX/expr/expr.unary/expr.new/p20.cpp index 71e584e..8cbe2b9 100644 --- a/test/CXX/expr/expr.unary/expr.new/p20.cpp +++ b/test/CXX/expr/expr.unary/expr.new/p20.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s typedef __SIZE_TYPE__ size_t; // Overloaded operator delete with two arguments diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp new file mode 100644 index 0000000..d9e0ff8 --- /dev/null +++ b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s + +namespace PR6285 { + template struct identity + { typedef T type; }; + + struct D { + template + operator typename identity::type(); // expected-note{{candidate}} + }; + + int f() { return D(); } // expected-error{{no viable conversion}} +} + diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp index e674f97..31de685 100644 --- a/test/CXX/stmt.stmt/stmt.select/p3.cpp +++ b/test/CXX/stmt.stmt/stmt.select/p3.cpp @@ -9,3 +9,11 @@ void g() { int x; // expected-error{{redefinition of 'x'}} } } + + +void h() { + if (int x = f()) // expected-note 2{{previous definition}} + int x; // expected-error{{redefinition of 'x'}} + else + int x; // expected-error{{redefinition of 'x'}} +} \ No newline at end of file diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp index cfa14f9..97457ea 100644 --- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp +++ b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp @@ -1,16 +1,48 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -template class X { +template struct X { static const int value = 0; }; -template class X { +template struct X { static const int value = 1; }; -template class X { +template struct X { static const int value = 2; }; int array0[X<0, 0, float>::value == 0? 1 : -1]; int array1[X<0, 1, int>::value == 1? 1 : -1]; int array2[X<0, 0, int>::value == 2? 1 : -1]; + +namespace DependentSubstPartialOrdering { + template + struct X { + static const unsigned value = 1; + }; + + template + struct X { + static const unsigned value = 2; + }; + + template + struct X { + static const unsigned value = 3; + }; + + struct X1 { }; + + struct X2 { + typedef void is_b; + }; + + struct X3 { + typedef void is_a; + typedef void is_b; + }; + + int check_X1[X::value == 1? 1 : -1]; + int check_X2[X::value == 2? 1 : -1]; + int check_X3[X::value == 3? 1 : -1]; +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp index c9dc546..073b2a1 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faccess-control -verify -emit-llvm-only %s +// RUN: %clang_cc1 -verify -emit-llvm-only %s namespace test0 { template struct Num { @@ -155,7 +155,7 @@ namespace Dependent { } namespace test7 { - template class A { // expected-note {{previous definition is here}} + template class A { // expected-note {{declared here}} friend class B; int x; // expected-note {{declared private here}} }; @@ -174,7 +174,7 @@ namespace test7 { // This shouldn't crash. template class D { - friend class A; // expected-error {{redefinition of 'A' as different kind of symbol}} + friend class A; // expected-error {{elaborated type refers to a template}} }; template class D; } @@ -216,3 +216,80 @@ namespace test9 { template class A; // expected-note {{in instantiation}} } + +namespace test10 { + template class A; + template A bar(const T*, const A&); + template class A { + private: + void foo(); // expected-note {{declared private here}} + friend A bar<>(const T*, const A&); + }; + + template A bar(const T *l, const A &r) { + A l1; + l1.foo(); + + A l2; + l2.foo(); // expected-error {{'foo' is a private member of 'test10::A'}} + + return l1; + } + + template A bar(const int *, const A &); // expected-note {{in instantiation}} +} + +// PR6752: this shouldn't crash. +namespace test11 { + struct Foo { + template + struct IteratorImpl { + template friend class IteratorImpl; + }; + }; + + template struct Foo::IteratorImpl; + template struct Foo::IteratorImpl; +} + +// PR6827 +namespace test12 { + template class Foo; + template Foo foo(T* t){ return Foo(t, true); } + + template class Foo { + public: + Foo(T*); + friend Foo foo(T*); + private: + Foo(T*, bool); // expected-note {{declared private here}} + }; + + // Should work. + int globalInt; + Foo f = foo(&globalInt); + + // Shouldn't work. + long globalLong; + template <> Foo foo(long *t) { + Foo s(&globalInt, false); // expected-error {{calling a private constructor}} + return Foo(t, true); + } +} + +// PR6514 +namespace test13 { + template class Temp> + class Role : public Temp { + friend class Temp; + int x; + }; + + template class Foo { + void foo(Role &role) { + (void) role.x; + } + }; + + template class Foo<0>; +} diff --git a/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/test/CXX/temp/temp.decls/temp.friend/p3.cpp index 17d8c85..d116e01 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p3.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p3.cpp @@ -8,6 +8,5 @@ class B { template friend class A; template friend class Undeclared; - // FIXME: Diagnostic below could be (and was) better. - template friend typename A::Member; // expected-error {{classes or functions}} + template friend typename A::Member; // expected-warning {{non-class type 'typename A::Member' cannot be a friend}} }; diff --git a/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/test/CXX/temp/temp.decls/temp.mem/p1.cpp index b057eed..f5f1205 100644 --- a/test/CXX/temp/temp.decls/temp.mem/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.mem/p1.cpp @@ -19,17 +19,17 @@ namespace PR6376 { template struct X { template - struct Y { }; + struct Y1 { }; // }; template<> struct X { template - struct Y { }; + struct Y1 { }; }; template - struct Z : public X::template Y { }; + struct Z : public X::template Y1 { }; Z z0; } diff --git a/test/CXX/temp/temp.param/p3.cpp b/test/CXX/temp/temp.param/p3.cpp index 8fcc2dc..dc40c4b 100644 --- a/test/CXX/temp/temp.param/p3.cpp +++ b/test/CXX/temp/temp.param/p3.cpp @@ -26,3 +26,15 @@ template struct X2 { // expected-error{{no viable conversion}} } }; + +namespace PR6831 { + namespace NA { struct S; } + namespace NB { struct S; } + + using namespace NA; + using namespace NB; + + template void foo(); + template void bar(); + template class S> void baz(); +} diff --git a/test/CXX/temp/temp.res/temp.local/p3.cpp b/test/CXX/temp/temp.res/temp.local/p3.cpp new file mode 100644 index 0000000..88f8963 --- /dev/null +++ b/test/CXX/temp/temp.res/temp.local/p3.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -verify %s + +template struct Base { // expected-note 4 {{member found by ambiguous name lookup}} + static void f(); +}; + +struct X0 { }; + +template struct Derived: Base, Base { + typename Derived::Base b; // expected-error{{member 'Base' found in multiple base classes of different types}} + typename Derived::Base d; // OK + + void g(X0 *t) { + t->Derived::Base::f(); + t->Base::f(); + t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \ + // expected-error{{no member named 'f' in 'X0'}} \ + // expected-error{{expected a class or namespace}} + } +}; + +namespace PR6717 { + template + class WebVector { + } + + WebVector(const WebVector& other) { } + + template + WebVector& operator=(const C& other) { } // expected-error{{unknown type name 'WebVector'}} \ + // expected-error{{unqualified-id}} +} diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp index c37817c..ba99dd7 100644 --- a/test/CXX/temp/temp.spec/p5.cpp +++ b/test/CXX/temp/temp.spec/p5.cpp @@ -27,3 +27,20 @@ template union X0::Inner; // expected-error{{duplicate explicit instantia template float X0::value; // expected-note{{previous explicit instantiation}} template float X0::value; // expected-error{{duplicate explicit instantiation}} + +// Make sure that we don't get tricked by redeclarations of nested classes. +namespace NestedClassRedecls { + template + struct X { + struct Nested; + friend struct Nested; + + struct Nested { + Nested() {} + } nested; + }; + + X xi; + + template struct X; +} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp index e30f046..e9758bc 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp @@ -8,12 +8,11 @@ template void f0(int); // okay // A definition of the class or class template containing a member function // template shall be in scope at the point of the explicit instantiation of // the member function template. -struct X0; // expected-note 3{{forward declaration}} -template struct X1; // expected-note 8{{declared here}} +struct X0; // expected-note {{forward declaration}} +template struct X1; // expected-note 5{{declared here}} -// FIXME: Repeated diagnostics here! -template void X0::f0(int); // expected-error 3{{incomplete type}} // expected-error{{invalid token after top level declarator}} -template void X1::f0(int); // expected-error 3{{implicit instantiation of undefined template}} // expected-error{{invalid token after top level declarator}} +template void X0::f0(int); // expected-error {{incomplete type}} +template void X1::f0(int); // expected-error {{implicit instantiation of undefined template}} // A definition of a class template or class member template shall be in scope // at the point of the explicit instantiation of the class template or class @@ -33,11 +32,10 @@ template struct X2::Inner; // expected-error{{explicit instantiation // A definition of a class template shall be in scope at the point of an // explicit instantiation of a member function or a static data member of the // class template. -template void X1::f1(int); // expected-error 2{{undefined template}} \ - // expected-error{{does not refer}} +template void X1::f1(int); // expected-error {{undefined template}} +template void X1::f1(int); // expected-error {{undefined template}} -template int X1::member; // expected-error 2{{undefined template}} \ - // expected-error{{does not refer}} +template int X1::member; // expected-error {{undefined template}} // A definition of a member class of a class template shall be in scope at the // point of an explicit instantiation of the member class. diff --git a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp index 2b85213..d304374 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s template void f0(T); // expected-note{{here}} template void f0(int); // expected-error{{explicit instantiation of undefined function template}} @@ -16,20 +16,20 @@ template void X0::f1(); // expected-error{{explicit instantiation of undefi template int X0::value; // expected-error{{explicit instantiation of undefined static data member}} -template<> void f0(long); -template void f0(long); // okay +template<> void f0(long); // expected-note{{previous template specialization is here}} +template void f0(long); // expected-warning{{explicit instantiation of 'f0' that occurs after an explicit specialization will be ignored}} -template<> void X0::f1(); -template void X0::f1(); +template<> void X0::f1(); // expected-note{{previous template specialization is here}} +template void X0::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}} -template<> struct X0::Inner; -template struct X0::Inner; +template<> struct X0::Inner; // expected-note{{previous template specialization is here}} +template struct X0::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}} -template<> long X0::value; -template long X0::value; +template<> long X0::value; // expected-note{{previous template specialization is here}} +template long X0::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}} -template<> struct X0; -template struct X0; +template<> struct X0; // expected-note{{previous template specialization is here}} +template struct X0; // expected-warning{{explicit instantiation of 'X0' that occurs after an explicit specialization will be ignored}} // PR 6458 namespace test0 { diff --git a/test/CXX/temp/temp.spec/temp.inst/p11.cpp b/test/CXX/temp/temp.spec/temp.inst/p11.cpp new file mode 100644 index 0000000..8184071 --- /dev/null +++ b/test/CXX/temp/temp.spec/temp.inst/p11.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -verify -emit-llvm-only %s + +// rdar://problem/7838962 +namespace test0 { + template unsigned f0() { + return T::MaxSize; // expected-error {{'int' cannot be used prior to '::'}} + }; + template struct A { + void Allocate(unsigned Alignment + = f0()) // expected-note {{in instantiation}} + {} + }; + void f1(A x) { x.Allocate(); } + +} diff --git a/test/CodeCompletion/call.cpp b/test/CodeCompletion/call.cpp index 04d2a2f..1df958e 100644 --- a/test/CodeCompletion/call.cpp +++ b/test/CodeCompletion/call.cpp @@ -18,6 +18,7 @@ void f(); void test() { f(Y(), 0, 0); // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s + // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type-id#>>(<#expression#>) // CHECK-CC1: f(N::Y y, <#int ZZ#>) // CHECK-CC1-NEXT: f(int i, <#int j#>, int k) // CHECK-CC1-NEXT: f(float x, <#float y#>) diff --git a/test/CodeCompletion/macros.c b/test/CodeCompletion/macros.c index 6330d25..0758bbf 100644 --- a/test/CodeCompletion/macros.c +++ b/test/CodeCompletion/macros.c @@ -19,11 +19,7 @@ void test(struct Point *p) { // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CC1 %s // RUN: %clang_cc1 -include-pch %t -fsyntax-only -code-completion-macros -code-completion-at=%s:14:9 %s -o - | FileCheck -check-prefix=CC2 %s - // CC1: BAR(<#X#>, <#Y#>) // CC1: color - // CC1: FOO - // CC1: IDENTITY(<#X#>) - // CC1: WIBBLE // CC1: x // CC1: y // CC1: z diff --git a/test/CodeCompletion/ordinary-name.cpp b/test/CodeCompletion/ordinary-name.cpp index d938c79..699b01d 100644 --- a/test/CodeCompletion/ordinary-name.cpp +++ b/test/CodeCompletion/ordinary-name.cpp @@ -21,7 +21,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: float // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo() // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){<#statements#> - // CHECK-CC1: COMPLETION: Pattern : goto <#identifier#>; + // CHECK-CC1: COMPLETION: Pattern : goto <#identifier#> // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#> // CHECK-CC1: COMPLETION: int // CHECK-CC1-NEXT: COMPLETION: long @@ -29,7 +29,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type-id#>[<#size#>](<#expressions#>) // CHECK-CC1-NEXT: COMPLETION: operator // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type-id#>>(<#expression#>) - // CHECK-CC1-NEXT: COMPLETION: Pattern : return; + // CHECK-CC1-NEXT: COMPLETION: Pattern : return // CHECK-CC1-NEXT: COMPLETION: short // CHECK-CC1-NEXT: COMPLETION: signed // CHECK-CC1-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>) @@ -48,7 +48,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC1-NEXT: COMPLETION: union // CHECK-CC1-NEXT: COMPLETION: unsigned - // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; + // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#> // CHECK-CC1-NEXT: COMPLETION: void // CHECK-CC1-NEXT: COMPLETION: volatile // CHECK-CC1-NEXT: COMPLETION: wchar_t @@ -58,7 +58,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: z : [#void#]z(<#int#>) // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s - // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>); + // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>) // CHECK-CC2-NEXT: COMPLETION: bool // CHECK-CC2-NEXT: COMPLETION: char // CHECK-CC2-NEXT: COMPLETION: class @@ -71,14 +71,14 @@ void foo() { // CHECK-CC2-NEXT: COMPLETION: int // CHECK-CC2-NEXT: COMPLETION: long // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#> - // CHECK-CC2: COMPLETION: Pattern : namespace <#identifier#> = <#identifier#>; + // CHECK-CC2: COMPLETION: Pattern : namespace <#identifier#> = <#identifier#> // CHECK-CC2-NEXT: COMPLETION: operator // CHECK-CC2-NEXT: COMPLETION: short // CHECK-CC2-NEXT: COMPLETION: signed // CHECK-CC2-NEXT: COMPLETION: static // CHECK-CC2-NEXT: COMPLETION: struct // CHECK-CC2-NEXT: COMPLETION: t : t - // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#>; + // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#> // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>> // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF // CHECK-CC2-NEXT: COMPLETION: typedef @@ -86,8 +86,8 @@ void foo() { // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC2-NEXT: COMPLETION: union // CHECK-CC2-NEXT: COMPLETION: unsigned - // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; - // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualified-id#>; + // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualified-id#> // CHECK-CC2-NEXT: COMPLETION: void // CHECK-CC2-NEXT: COMPLETION: volatile // CHECK-CC2-NEXT: COMPLETION: wchar_t @@ -122,7 +122,7 @@ void foo() { // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC3-NEXT: COMPLETION: union // CHECK-CC3-NEXT: COMPLETION: unsigned - // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualified-id#>; + // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualified-id#> // CHECK-CC3-NEXT: COMPLETION: virtual // CHECK-CC3-NEXT: COMPLETION: void // CHECK-CC3-NEXT: COMPLETION: volatile diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c index 99be469..1db37de 100644 --- a/test/CodeGen/2009-10-20-GlobalDebug.c +++ b/test/CodeGen/2009-10-20-GlobalDebug.c @@ -1,4 +1,8 @@ // RUN: %clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s int global; -// CHECK: asciz "global" ## External Name -int main() { return 0;} +// CHECK: asciz "global" ## External Name +// CHECK: asciz "localstatic" ## External Name +int main() { + static int localstatic; + return 0; +} diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c index d313a9b..72fd7c3 100644 --- a/test/CodeGen/arm-arguments.c +++ b/test/CodeGen/arm-arguments.c @@ -28,13 +28,13 @@ struct s4 { struct s4_0 { int f0; } f0; }; struct s4 f4(void) {} // APCS-GNU: define arm_apcscc void @f5( -// APCS-GNU: struct.s5* noalias sret +// APCS-GNU: struct.s5* sret // AAPCS: define arm_aapcscc i32 @f5() struct s5 { struct { } f0; int f1; }; struct s5 f5(void) {} // APCS-GNU: define arm_apcscc void @f6( -// APCS-GNU: struct.s6* noalias sret +// APCS-GNU: struct.s6* sret // AAPCS: define arm_aapcscc i32 @f6() struct s6 { int f0[1]; }; struct s6 f6(void) {} @@ -45,7 +45,7 @@ struct s7 { struct { int : 0; } f0; }; struct s7 f7(void) {} // APCS-GNU: define arm_apcscc void @f8( -// APCS-GNU: struct.s8* noalias sret +// APCS-GNU: struct.s8* sret // AAPCS: define arm_aapcscc void @f8() struct s8 { struct { int : 0; } f0[1]; }; struct s8 f8(void) {} @@ -61,7 +61,7 @@ struct s10 { int f0; int : 0; int : 0; }; struct s10 f10(void) {} // APCS-GNU: define arm_apcscc void @f11( -// APCS-GNU: struct.s10* noalias sret +// APCS-GNU: struct.s10* sret // AAPCS: define arm_aapcscc i32 @f11() struct s11 { int : 0; int f0; }; struct s11 f11(void) {} @@ -72,7 +72,7 @@ union u12 { char f0; short f1; int f2; }; union u12 f12(void) {} // APCS-GNU: define arm_apcscc void @f13( -// APCS-GNU: struct.s13* noalias sret +// APCS-GNU: struct.s13* sret // FIXME: This should return a float. // AAPCS-FIXME: define arm_aapcscc float @f13() @@ -80,7 +80,7 @@ struct s13 { float f0; }; struct s13 f13(void) {} // APCS-GNU: define arm_apcscc void @f14( -// APCS-GNU: struct.s13* noalias sret +// APCS-GNU: struct.s13* sret // AAPCS: define arm_aapcscc i32 @f14() union u14 { float f0; }; union u14 f14(void) {} @@ -104,18 +104,18 @@ struct s18 { short f0; char f1 : 4; }; struct s18 f18(void) {} // APCS-GNU: define arm_apcscc void @f19( -// APCS-GNU: struct.s19* noalias sret +// APCS-GNU: struct.s19* sret // AAPCS: define arm_aapcscc i32 @f19() struct s19 { int f0; struct s8 f1; }; struct s19 f19(void) {} // APCS-GNU: define arm_apcscc void @f20( -// APCS-GNU: struct.s20* noalias sret +// APCS-GNU: struct.s20* sret // AAPCS: define arm_aapcscc i32 @f20() struct s20 { struct s8 f1; int f0; }; struct s20 f20(void) {} -// APCS-GNU: define arm_apcscc i32 @f21() +// APCS-GNU: define arm_apcscc i8 @f21() // AAPCS: define arm_aapcscc i32 @f21() struct s21 { struct {} f1; int f0 : 4; }; struct s21 f21(void) {} @@ -128,10 +128,10 @@ struct s21 f21(void) {} // APCS-GNU: define arm_apcscc i128 @f27() // AAPCS: define arm_aapcscc i16 @f22() // AAPCS: define arm_aapcscc i32 @f23() -// AAPCS: define arm_aapcscc void @f24({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f25({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f26({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f27({{.*}} noalias sret +// AAPCS: define arm_aapcscc void @f24({{.*}} sret +// AAPCS: define arm_aapcscc void @f25({{.*}} sret +// AAPCS: define arm_aapcscc void @f26({{.*}} sret +// AAPCS: define arm_aapcscc void @f27({{.*}} sret _Complex char f22(void) {} _Complex short f23(void) {} _Complex int f24(void) {} @@ -149,7 +149,7 @@ struct s28 f28() {} struct s29 { _Complex short f0; }; struct s29 f29() {} -// APCS-GNU: define arm_apcscc void @f30({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret +// APCS-GNU: define arm_apcscc void @f30({{.*}} sret +// AAPCS: define arm_aapcscc void @f30({{.*}} sret struct s30 { _Complex int f0; }; struct s30 f30() {} diff --git a/test/CodeGen/arm_asm_clobber.c b/test/CodeGen/arm_asm_clobber.c deleted file mode 100644 index a7ca0b5..0000000 --- a/test/CodeGen/arm_asm_clobber.c +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o %t %s - -void test0(void) { - asm volatile("mov r0, r0" :: ); -} -void test1(void) { - asm volatile("mov r0, r0" ::: - "cc", "memory" ); -} -void test2(void) { - asm volatile("mov r0, r0" ::: - "r0", "r1", "r2", "r3"); - asm volatile("mov r0, r0" ::: - "r4", "r5", "r6", "r8"); -} -void test3(void) { - asm volatile("mov r0, r0" ::: - "a1", "a2", "a3", "a4"); - asm volatile("mov r0, r0" ::: - "v1", "v2", "v3", "v5"); -} diff --git a/test/CodeGen/asm-errors.c b/test/CodeGen/asm-errors.c new file mode 100644 index 0000000..7323e61 --- /dev/null +++ b/test/CodeGen/asm-errors.c @@ -0,0 +1,8 @@ +// RUN: not %clang_cc1 -triple i386-apple-darwin10 -emit-obj %s > %t 2>&1 +// RUN: FileCheck %s < %t + +int test1(int X) { +// CHECK: error: unrecognized instruction + __asm__ ("abc incl %0" : "+r" (X)); + return X; +} diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index ace0db9..5077028 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -147,3 +147,24 @@ int t19(unsigned data) { // CHECK: = call {{.*}}asm "x$(abc$|def$|ghi$)z" } + +// PR6845 - Mismatching source/dest fp types. +double t20(double x) { + register long double result; + __asm __volatile ("frndint" : "=t" (result) : "0" (x)); + return result; + + // CHECK: @t20 + // CHECK: fpext double {{.*}} to x86_fp80 + // CHECK-NEXT: call x86_fp80 asm sideeffect "frndint" + // CHECK: fptrunc x86_fp80 {{.*}} to double +} + +float t21(long double x) { + register float result; + __asm __volatile ("frndint" : "=t" (result) : "0" (x)); + return result; + // CHECK: @t21 + // CHECK: call x86_fp80 asm sideeffect "frndint" + // CHECK-NEXT: fptrunc x86_fp80 {{.*}} to float +} diff --git a/test/CodeGen/asm_arm.c b/test/CodeGen/asm_arm.c new file mode 100644 index 0000000..aac47d5 --- /dev/null +++ b/test/CodeGen/asm_arm.c @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +void test0(void) { + asm volatile("mov r0, r0" :: ); +} +void test1(void) { + asm volatile("mov r0, r0" ::: + "cc", "memory" ); +} +void test2(void) { + asm volatile("mov r0, r0" ::: + "r0", "r1", "r2", "r3"); + asm volatile("mov r0, r0" ::: + "r4", "r5", "r6", "r8"); +} +void test3(void) { + asm volatile("mov r0, r0" ::: + "a1", "a2", "a3", "a4"); + asm volatile("mov r0, r0" ::: + "v1", "v2", "v3", "v5"); +} + + +// {} should not be treated as asm variants. +void test4(float *a, float *b) { + // CHECK: @test4 + // CHECK: call void asm sideeffect "vld1.32 {d8[],d9[]}, + __asm__ volatile ( + "vld1.32 {d8[],d9[]}, [%1,:32] \n\t" + "vst1.32 {q4}, [%0,:128] \n\t" + :: "r"(a), "r"(b)); +} diff --git a/test/CodeGen/bitfield-2.c b/test/CodeGen/bitfield-2.c new file mode 100644 index 0000000..e91859f --- /dev/null +++ b/test/CodeGen/bitfield-2.c @@ -0,0 +1,368 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64 -O3 -o %t.opt.ll %s \ +// RUN: -fdump-record-layouts 2> %t.dump.txt +// RUN: FileCheck -check-prefix=CHECK-RECORD < %t.dump.txt %s +// RUN: FileCheck -check-prefix=CHECK-OPT < %t.opt.ll %s + +/****/ + +// Check that we don't read off the end a packed 24-bit structure. +// PR6176 + +// CHECK-RECORD: *** Dumping IRgen Record Layout +// CHECK-RECORD: Record: struct s0 +// CHECK-RECORD: Layout: +// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: BitFields:[ +// CHECK-RECORD: +// CHECK-RECORD: +struct __attribute((packed)) s0 { + int f0 : 24; +}; + +struct s0 g0 = { 0xdeadbeef }; + +int f0_load(struct s0 *a0) { + int size_check[sizeof(struct s0) == 3 ? 1 : -1]; + return a0->f0; +} +int f0_store(struct s0 *a0) { + return (a0->f0 = 1); +} +int f0_reload(struct s0 *a0) { + return (a0->f0 += 1); +} + +// CHECK-OPT: define i64 @test_0() +// CHECK-OPT: ret i64 1 +// CHECK-OPT: } +unsigned long long test_0() { + struct s0 g0 = { 0xdeadbeef }; + unsigned long long res = 0; + res ^= g0.f0; + res ^= f0_load(&g0) ^ f0_store(&g0) ^ f0_reload(&g0); + res ^= g0.f0; + return res; +} + +/****/ + +// PR5591 + +// CHECK-RECORD: *** Dumping IRgen Record Layout +// CHECK-RECORD: Record: struct s1 +// CHECK-RECORD: Layout: +// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: BitFields:[ +// CHECK-RECORD: +// CHECK-RECORD: ]> +// CHECK-RECORD: +// CHECK-RECORD: + +#pragma pack(push) +#pragma pack(1) +struct __attribute((packed)) s1 { + signed f0 : 10; + signed f1 : 10; +}; +#pragma pack(pop) + +struct s1 g1 = { 0xdeadbeef, 0xdeadbeef }; + +int f1_load(struct s1 *a0) { + int size_check[sizeof(struct s1) == 3 ? 1 : -1]; + return a0->f1; +} +int f1_store(struct s1 *a0) { + return (a0->f1 = 1234); +} +int f1_reload(struct s1 *a0) { + return (a0->f1 += 1234); +} + +// CHECK-OPT: define i64 @test_1() +// CHECK-OPT: ret i64 210 +// CHECK-OPT: } +unsigned long long test_1() { + struct s1 g1 = { 0xdeadbeef, 0xdeadbeef }; + unsigned long long res = 0; + res ^= g1.f0 ^ g1.f1; + res ^= f1_load(&g1) ^ f1_store(&g1) ^ f1_reload(&g1); + res ^= g1.f0 ^ g1.f1; + return res; +} + +/****/ + +// Check that we don't access beyond the bounds of a union. +// +// PR5567 + +// CHECK-RECORD: *** Dumping IRgen Record Layout +// CHECK-RECORD: Record: union u2 +// CHECK-RECORD: Layout: +// CHECK-RECORD: ContainsPointerToDataMember:0 +// CHECK-RECORD: BitFields:[ +// CHECK-RECORD: + +union __attribute__((packed)) u2 { + unsigned long long f0 : 3; +}; + +union u2 g2 = { 0xdeadbeef }; + +int f2_load(union u2 *a0) { + return a0->f0; +} +int f2_store(union u2 *a0) { + return (a0->f0 = 1234); +} +int f2_reload(union u2 *a0) { + return (a0->f0 += 1234); +} + +// CHECK-OPT: define i64 @test_2() +// CHECK-OPT: ret i64 2 +// CHECK-OPT: } +unsigned long long test_2() { + union u2 g2 = { 0xdeadbeef }; + unsigned long long res = 0; + res ^= g2.f0; + res ^= f2_load(&g2) ^ f2_store(&g2) ^ f2_reload(&g2); + res ^= g2.f0; + return res; +} + +/***/ + +// PR5039 + +struct s3 { + long long f0 : 32; + long long f1 : 32; +}; + +struct s3 g3 = { 0xdeadbeef, 0xdeadbeef }; + +int f3_load(struct s3 *a0) { + a0->f0 = 1; + return a0->f0; +} +int f3_store(struct s3 *a0) { + a0->f0 = 1; + return (a0->f0 = 1234); +} +int f3_reload(struct s3 *a0) { + a0->f0 = 1; + return (a0->f0 += 1234); +} + +// CHECK-OPT: define i64 @test_3() +// CHECK-OPT: ret i64 -559039940 +// CHECK-OPT: } +unsigned long long test_3() { + struct s3 g3 = { 0xdeadbeef, 0xdeadbeef }; + unsigned long long res = 0; + res ^= g3.f0 ^ g3.f1; + res ^= f3_load(&g3) ^ f3_store(&g3) ^ f3_reload(&g3); + res ^= g3.f0 ^ g3.f1; + return res; +} + +/***/ + +// This is a case where the bitfield access will straddle an alignment boundary +// of its underlying type. + +struct s4 { + unsigned f0 : 16; + unsigned f1 : 28 __attribute__ ((packed)); +}; + +struct s4 g4 = { 0xdeadbeef, 0xdeadbeef }; + +int f4_load(struct s4 *a0) { + return a0->f0 ^ a0->f1; +} +int f4_store(struct s4 *a0) { + return (a0->f0 = 1234) ^ (a0->f1 = 5678); +} +int f4_reload(struct s4 *a0) { + return (a0->f0 += 1234) ^ (a0->f1 += 5678); +} + +// CHECK-OPT: define i64 @test_4() +// CHECK-OPT: ret i64 4860 +// CHECK-OPT: } +unsigned long long test_4() { + struct s4 g4 = { 0xdeadbeef, 0xdeadbeef }; + unsigned long long res = 0; + res ^= g4.f0 ^ g4.f1; + res ^= f4_load(&g4) ^ f4_store(&g4) ^ f4_reload(&g4); + res ^= g4.f0 ^ g4.f1; + return res; +} + +/***/ + +struct s5 { + unsigned f0 : 2; + _Bool f1 : 1; + _Bool f2 : 1; +}; + +struct s5 g5 = { 0xdeadbeef, 0xdeadbeef }; + +int f5_load(struct s5 *a0) { + return a0->f0 ^ a0->f1; +} +int f5_store(struct s5 *a0) { + return (a0->f0 = 0xF) ^ (a0->f1 = 0xF) ^ (a0->f2 = 0xF); +} +int f5_reload(struct s5 *a0) { + return (a0->f0 += 0xF) ^ (a0->f1 += 0xF) ^ (a0->f2 += 0xF); +} + +// CHECK-OPT: define i64 @test_5() +// CHECK-OPT: ret i64 2 +// CHECK-OPT: } +unsigned long long test_5() { + struct s5 g5 = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }; + unsigned long long res = 0; + res ^= g5.f0 ^ g5.f1 ^ g5.f2; + res ^= f5_load(&g5) ^ f5_store(&g5) ^ f5_reload(&g5); + res ^= g5.f0 ^ g5.f1 ^ g5.f2; + return res; +} + +/***/ + +struct s6 { + _Bool f0 : 2; +}; + +struct s6 g6 = { 0xF }; + +int f6_load(struct s6 *a0) { + return a0->f0; +} +int f6_store(struct s6 *a0) { + return a0->f0 = 0x0; +} +int f6_reload(struct s6 *a0) { + return (a0->f0 += 0xF); +} + +// CHECK-OPT: define zeroext i1 @test_6() +// CHECK-OPT: ret i1 true +// CHECK-OPT: } +_Bool test_6() { + struct s6 g6 = { 0xF }; + unsigned long long res = 0; + res ^= g6.f0; + res ^= f6_load(&g6); + res ^= g6.f0; + return res; +} + +/***/ + +// Check that we compute the best alignment possible for each access. +// +// CHECK-RECORD: *** Dumping IRgen Record Layout +// CHECK-RECORD: Record: struct s7 +// CHECK-RECORD: Layout: +// CHECK-RECORD: ]> +// CHECK-RECORD: + +struct __attribute__((aligned(16))) s7 { + int a, b, c; + int f0 : 5; + int f1 : 29; +}; + +int f7_load(struct s7 *a0) { + return a0->f0; +} + +/***/ + +// This is a case where we narrow the access width immediately. + +struct __attribute__((packed)) s8 { + char f0 : 4; + char f1; + int f2 : 4; + char f3 : 4; +}; + +struct s8 g8 = { 0xF }; + +int f8_load(struct s8 *a0) { + return a0->f0 ^ a0 ->f2 ^ a0->f3; +} +int f8_store(struct s8 *a0) { + return (a0->f0 = 0xFD) ^ (a0->f2 = 0xFD) ^ (a0->f3 = 0xFD); +} +int f8_reload(struct s8 *a0) { + return (a0->f0 += 0xFD) ^ (a0->f2 += 0xFD) ^ (a0->f3 += 0xFD); +} + +// CHECK-OPT: define i32 @test_8() +// CHECK-OPT: ret i32 -3 +// CHECK-OPT: } +unsigned test_8() { + struct s8 g8 = { 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }; + unsigned long long res = 0; + res ^= g8.f0 ^ g8.f2 ^ g8.f3; + res ^= f8_load(&g8) ^ f8_store(&g8) ^ f8_reload(&g8); + res ^= g8.f0 ^ g8.f2 ^ g8.f3; + return res; +} + +/***/ + +// This is another case where we narrow the access width immediately. +// +// + +struct __attribute__((packed)) s9 { + unsigned f0 : 7; + unsigned f1 : 7; + unsigned f2 : 7; + unsigned f3 : 7; + unsigned f4 : 7; + unsigned f5 : 7; + unsigned f6 : 7; + unsigned f7 : 7; +}; + +int f9_load(struct s9 *a0) { + return a0->f7; +} diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index 0ef10c1..e7625b1 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -12,7 +12,7 @@ struct s0 { int a[64]; }; -// RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* noalias sret .*, .*, .* byval .*)' %t +// RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* sret .*, .*, .* byval .*)' %t struct s0 f2(struct s0 a0) { return ^(struct s0 a1){ return a1; }(a0); } diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c new file mode 100644 index 0000000..04249cc --- /dev/null +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -0,0 +1,332 @@ +// RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +#include "altivec.h" + +int main () +{ + vector signed char vsc = { 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16 }; + vector unsigned char vuc = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; + vector short vs = { -1, 2, -3, 4, -5, 6, -7, 8 }; + vector unsigned short vus = { 1, 2, 3, 4, 5, 6, 7, 8 }; + vector int vi = { -1, 2, -3, 4 }; + vector unsigned int vui = { 1, 2, 3, 4 }; + vector float vf = { -1.5, 2.5, -3.5, 4.5 }; + + vector signed char res_vsc; + vector unsigned char res_vuc; + vector short res_vs; + vector unsigned short res_vus; + vector int res_vi; + vector unsigned int res_vui; + vector float res_vf; + + int param_i; + int res_i; + + /* vec_abs */ + vsc = vec_abs(vsc); // CHECK: sub <16 x i8> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsb + + vs = __builtin_vec_abs(vs); // CHECK: sub <8 x i16> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsh + + vi = vec_abs(vi); // CHECK: sub <4 x i32> zeroinitializer + // CHECK: @llvm.ppc.altivec.vmaxsw + + vf = vec_abs(vf); // CHECK: store <4 x i32> + // CHECK: and <4 x i32> + + /* vec_abs */ + vsc = vec_abss(vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + // CHECK: @llvm.ppc.altivec.vmaxsb + + vs = __builtin_vec_abss(vs); // CHECK: @llvm.ppc.altivec.vsubshs + // CHECK: @llvm.ppc.altivec.vmaxsh + + vi = vec_abss(vi); // CHECK: @llvm.ppc.altivec.vsubsws + // CHECK: @llvm.ppc.altivec.vmaxsw + + /* vec_add */ + res_vsc = vec_add(vsc, vsc); // CHECK: add nsw <16 x i8> + res_vuc = vec_vaddubm(vuc, vuc); // CHECK: add <16 x i8> + res_vs = __builtin_altivec_vadduhm(vs, vs); // CHECK: add nsw <8 x i16> + res_vus = vec_vadduhm(vus, vus); // CHECK: add <8 x i16> + res_vi = __builtin_vec_vadduwm(vi, vi); // CHECK: add nsw <4 x i32> + res_vui = vec_vadduwm(vui, vui); // CHECK: add <4 x i32> + res_vf = __builtin_vec_vaddfp(vf, vf); // CHECK: fadd <4 x float> + + /* vec_addc */ + res_vui = vec_vaddcuw(vui, vui); // HECK: @llvm.ppc.altivec.vaddcuw + + /* vec_adds */ + res_vsc = vec_adds(vsc, vsc); // CHECK: @llvm.ppc.altivec.vaddsbs + res_vuc = vec_vaddubs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vaddubs + res_vs = __builtin_vec_vaddshs(vs, vs); // CHECK: @llvm.ppc.altivec.vaddshs + res_vus = vec_vadduhs(vus, vus); // CHECK: @llvm.ppc.altivec.vadduhs + res_vi = __builtin_vec_vaddsws(vi, vi); // CHECK: @llvm.ppc.altivec.vaddsws + res_vui = vec_vadduws(vui, vui); // CHECK: @llvm.ppc.altivec.vadduws + + /* vec_sub */ + res_vsc = vec_sub(vsc, vsc); // CHECK: sub nsw <16 x i8> + res_vuc = vec_vsububm(vuc, vuc); // CHECK: sub <16 x i8> + res_vs = __builtin_altivec_vsubuhm(vs, vs); // CHECK: sub nsw <8 x i16> + res_vus = vec_vsubuhm(vus, vus); // CHECK: sub <8 x i16> + res_vi = __builtin_vec_vsubuwm(vi, vi); // CHECK: sub nsw <4 x i32> + res_vui = vec_vsubuwm(vui, vui); // CHECK: sub <4 x i32> + res_vf = __builtin_vec_vsubfp(vf, vf); // CHECK: fsub <4 x float> + + /* vec_subs */ + res_vsc = vec_subs(vsc, vsc); // CHECK: @llvm.ppc.altivec.vsubsbs + res_vuc = vec_vsububs(vuc, vuc); // CHECK: @llvm.ppc.altivec.vsububs + res_vs = __builtin_vec_vsubshs(vs, vs); // CHECK: @llvm.ppc.altivec.vsubshs + res_vus = vec_vsubuhs(vus, vus); // CHECK: @llvm.ppc.altivec.vsubuhs + res_vi = __builtin_vec_vsubsws(vi, vi); // CHECK: @llvm.ppc.altivec.vsubsws + res_vui = vec_vsubuws(vui, vui); // CHECK: @llvm.ppc.altivec.vsubuws + + /* vec_avg */ + res_vsc = vec_avg(vsc, vsc); // CHECK: @llvm.ppc.altivec.vavgsb + res_vuc = __builtin_vec_vavgub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vavgub + res_vs = vec_vavgsh(vs, vs); // CHECK: @llvm.ppc.altivec.vavgsh + res_vus = __builtin_vec_vavguh(vus, vus); // CHECK: @llvm.ppc.altivec.vavguh + res_vi = vec_vavgsw(vi, vi); // CHECK: @llvm.ppc.altivec.vavgsw + res_vui = __builtin_vec_vavguw(vui, vui); // CHECK: @llvm.ppc.altivec.vavguw + + /* vec_st */ + param_i = 5; + vec_st(vsc, 0, &res_vsc); // CHECK: @llvm.ppc.altivec.stvx + __builtin_vec_st(vuc, param_i, &res_vuc); // CHECK: @llvm.ppc.altivec.stvx + vec_stvx(vs, 1, &res_vs); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vus, 1000, &res_vus); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvx + vec_st(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvx + + /* vec_stl */ + param_i = 10000; + vec_stl(vsc, param_i, &res_vsc); // CHECK: @llvm.ppc.altivec.stvxl + __builtin_vec_stl(vuc, 1, &res_vuc); // CHECK: @llvm.ppc.altivec.stvxl + vec_stvxl(vs, 0, &res_vs); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vus, 0, &res_vus); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvxl + vec_stl(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvxl + + /* vec_ste */ + param_i = 10000; + vec_ste(vsc, param_i, &res_vsc); // CHECK: @llvm.ppc.altivec.stvebx + vec_stvebx(vuc, 1, &res_vuc); // CHECK: @llvm.ppc.altivec.stvebx + __builtin_vec_stvehx(vs, 0, &res_vs); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvehx(vus, 0, &res_vus); // CHECK: @llvm.ppc.altivec.stvehx + vec_stvewx(vi, 0, &res_vi); // CHECK: @llvm.ppc.altivec.stvewx + __builtin_vec_stvewx(vui, 0, &res_vui); // CHECK: @llvm.ppc.altivec.stvewx + vec_stvewx(vf, 0, &res_vf); // CHECK: @llvm.ppc.altivec.stvewx + + /* vec_cmpb */ + res_vi = vec_vcmpbfp(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp + + /* vec_cmpeq */ + res_vi = vec_cmpeq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vi = __builtin_vec_cmpeq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb + res_vi = vec_cmpeq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vi = vec_cmpeq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh + res_vi = vec_cmpeq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vi = vec_cmpeq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw + res_vi = vec_cmpeq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp + + /* vec_cmpge */ + res_vi = __builtin_vec_cmpge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp + + /* vec_cmpgt */ + res_vi = vec_cmpgt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vi = vec_vcmpgtub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vi = __builtin_vec_vcmpgtsh(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vi = vec_cmpgt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vi = vec_cmpgt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vi = vec_cmpgt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vi = vec_cmpgt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + + /* vec_cmple */ + res_vi = __builtin_vec_cmple(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp + + /* vec_cmplt */ + res_vi = vec_cmplt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb + res_vi = __builtin_vec_cmplt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub + res_vi = vec_cmplt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh + res_vi = vec_cmplt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh + res_vi = vec_cmplt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw + res_vi = vec_cmplt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw + res_vi = vec_cmplt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp + + /* vec_max */ + res_vsc = vec_max(vsc, vsc); // CHECK: @llvm.ppc.altivec.vmaxsb + res_vuc = __builtin_vec_vmaxub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vmaxub + res_vs = vec_vmaxsh(vs, vs); // CHECK: @llvm.ppc.altivec.vmaxsh + res_vus = vec_max(vus, vus); // CHECK: @llvm.ppc.altivec.vmaxuh + res_vi = __builtin_vec_vmaxsw(vi, vi); // CHECK: @llvm.ppc.altivec.vmaxsw + res_vui = vec_vmaxuw(vui, vui); // CHECK: @llvm.ppc.altivec.vmaxuw + res_vf = __builtin_vec_max(vf, vf); // CHECK: @llvm.ppc.altivec.vmaxfp + + /* vec_mfvscr */ + vf = vec_mfvscr(); // CHECK: @llvm.ppc.altivec.mfvscr + + /* vec_min */ + res_vsc = vec_min(vsc, vsc); // CHECK: @llvm.ppc.altivec.vminsb + res_vuc = __builtin_vec_vminub(vuc, vuc); // CHECK: @llvm.ppc.altivec.vminub + res_vs = vec_vminsh(vs, vs); // CHECK: @llvm.ppc.altivec.vminsh + res_vus = vec_min(vus, vus); // CHECK: @llvm.ppc.altivec.vminuh + res_vi = __builtin_vec_vminsw(vi, vi); // CHECK: @llvm.ppc.altivec.vminsw + res_vui = vec_vminuw(vui, vui); // CHECK: @llvm.ppc.altivec.vminuw + res_vf = __builtin_vec_min(vf, vf); // CHECK: @llvm.ppc.altivec.vminfp + + /* vec_mtvscr */ + vec_mtvscr(vsc); // CHECK: @llvm.ppc.altivec.mtvscr + + /* ------------------------------ predicates -------------------------------------- */ + + res_i = __builtin_vec_vcmpeq_p(__CR6_EQ, vsc, vui); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + res_i = __builtin_vec_vcmpge_p(__CR6_EQ, vs, vi); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + res_i = __builtin_vec_vcmpgt_p(__CR6_EQ, vuc, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_eq */ + res_i = vec_all_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_ge */ + res_i = vec_all_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_gt */ + res_i = vec_all_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_in */ + res_i = vec_all_in(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p + + /* vec_all_le */ + res_i = vec_all_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_all_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_all_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_all_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_all_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_all_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_all_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_nan */ + res_i = vec_all_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_ne */ + res_i = vec_all_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_all_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_all_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_all_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_all_nge */ + res_i = vec_all_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_all_ngt */ + res_i = vec_all_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_nle */ + res_i = vec_all_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_all_nlt */ + res_i = vec_all_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_all_numeric */ + res_i = vec_all_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_eq */ + res_i = vec_any_eq(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_eq(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_eq(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_eq(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_ge */ + res_i = vec_any_ge(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_ge(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_ge(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_ge(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_ge(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_ge(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_ge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_gt */ + res_i = vec_any_gt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_gt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_gt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_gt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_gt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_gt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_gt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_le */ + res_i = vec_any_le(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_le(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_le(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_le(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_le(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_le(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_le(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_lt */ + res_i = vec_any_lt(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpgtsb.p + res_i = vec_any_lt(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpgtub.p + res_i = vec_any_lt(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpgtsh.p + res_i = vec_any_lt(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpgtuh.p + res_i = vec_any_lt(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpgtsw.p + res_i = vec_any_lt(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpgtuw.p + res_i = vec_any_lt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_nan */ + res_i = vec_any_nan(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_ne */ + res_i = vec_any_ne(vsc, vsc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vuc, vuc); // CHECK: @llvm.ppc.altivec.vcmpequb.p + res_i = vec_any_ne(vs, vs); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vus, vus); // CHECK: @llvm.ppc.altivec.vcmpequh.p + res_i = vec_any_ne(vi, vi); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vui, vui); // CHECK: @llvm.ppc.altivec.vcmpequw.p + res_i = vec_any_ne(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_nge */ + res_i = vec_any_nge(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_any_ngt */ + res_i = vec_any_ngt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_nle */ + res_i = vec_any_nle(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgefp.p + + /* vec_any_nlt */ + res_i = vec_any_nlt(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpgtfp.p + + /* vec_any_numeric */ + res_i = vec_any_numeric(vf); // CHECK: @llvm.ppc.altivec.vcmpeqfp.p + + /* vec_any_out */ + res_i = vec_any_out(vf, vf); // CHECK: @llvm.ppc.altivec.vcmpbfp.p + + return 0; +} diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c new file mode 100644 index 0000000..fef1587 --- /dev/null +++ b/test/CodeGen/catch-undef-behavior.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm-only %s + +// PR6805 +void foo() { + union { int i; } u; + u.i=1; +} diff --git a/test/CodeGen/const-unordered-compare.c b/test/CodeGen/const-unordered-compare.c new file mode 100644 index 0000000..ac7d35b --- /dev/null +++ b/test/CodeGen/const-unordered-compare.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +// Checks folding of an unordered comparison +int nan_ne_check() { + // CHECK: store i32 1 + return (__builtin_nanf("") != __builtin_nanf("")) ? 1 : 0; +} diff --git a/test/CodeGen/decl.c b/test/CodeGen/decl.c index 6d06813..7ffb700 100644 --- a/test/CodeGen/decl.c +++ b/test/CodeGen/decl.c @@ -1,10 +1,14 @@ -// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s +// 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: @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: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }] + void test1() { // This should codegen as a "@test1.x" global. const int x[] = { 1, 2, 3, 4, 6, 8, 9, 10, 123, 231, 123,23 }; @@ -59,3 +63,29 @@ void test5() { union test5u test5w = (union test5u)2; union test5u test5y = (union test5u)73.0; + + +// PR6660 - sqlite miscompile +struct SelectDest { + unsigned char eDest; + unsigned char affinity; + int iParm; + int iMem; +}; + +void test6() { + struct SelectDest x = {1, 2, 3}; + test6f(&x); +} + +// rdar://7657600 +struct test7s { int a; int b; } test7[] = { + {1, 2}, + {4}, +}; + +// rdar://7872531 +#pragma pack(push, 2) +struct test8s { int f0; char f1; } test8g = {}; + + diff --git a/test/CodeGen/designated-initializers.c b/test/CodeGen/designated-initializers.c index 652238f..49f57ad 100644 --- a/test/CodeGen/designated-initializers.c +++ b/test/CodeGen/designated-initializers.c @@ -1,22 +1,37 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o %t -// RUN: grep "{ i8\* null, i32 1024 }" %t -// RUN: grep "i32 0, i32 22" %t +// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s struct foo { void *a; int b; }; +// CHECK: @u = global %union.anon zeroinitializer union { int i; float f; } u = { }; -int main(int argc, char **argv) -{ - union { int i; float f; } u2 = { }; - static struct foo foo = { - .b = 1024, - }; -} +// CHECK: @u2 = global %0 { i32 0, [4 x i8] undef } +union { int i; double f; } u2 = { }; +// CHECK: @u3 = global %1 zeroinitializer +union { double f; int i; } u3 = { }; + +// CHECK: @b = global [2 x i32] [i32 0, i32 22] int b[2] = { - [1] 22 + [1] = 22 }; + +int main(int argc, char **argv) +{ + // CHECK: internal global %struct.foo { i8* null, i32 1024 } + static struct foo foo = { + .b = 1024, + }; + + // CHECK: bitcast %union.anon* %u2 + // CHECK: call void @llvm.memset + union { int i; float f; } u2 = { }; + + // CHECK-NOT: call void @llvm.memset + union { int i; float f; } u3; + + // CHECK: ret i32 +} diff --git a/test/CodeGen/functions.c b/test/CodeGen/functions.c index 5629ef5..a2c692d 100644 --- a/test/CodeGen/functions.c +++ b/test/CodeGen/functions.c @@ -47,3 +47,15 @@ void f7(float f, float g) { // CHECK: define void @f7(float{{.*}}, float{{.*}}) // CHECK: call void @f6(float{{.*}}, float{{.*}}) } + +// PR6911 - incomplete function types +struct Incomplete; +void f8_callback(struct Incomplete); +void f8_user(void (*callback)(struct Incomplete)); +void f8_test() { + f8_user(&f8_callback); +// CHECK: define void @f8_test() +// CHECK: call void @f8_user({{.*}}* bitcast (void ()* @f8_callback to {{.*}}*)) +// CHECK: declare void @f8_user({{.*}}*) +// CHECK: declare void @f8_callback() +} diff --git a/test/CodeGen/global-init.c b/test/CodeGen/global-init.c index e166fb4..351ca9e 100644 --- a/test/CodeGen/global-init.c +++ b/test/CodeGen/global-init.c @@ -12,19 +12,41 @@ int c __attribute__((weak))= 0; // CHECK: @c = weak global i32 0 - // Since this is marked const, it should get weak_odr linkage, since all // definitions have to be the same. // CHECK: @d = weak_odr constant i32 0 const int d __attribute__((weak))= 0; +// PR6168 "too many undefs" +struct ManyFields { + int a; + int b; + int c; + char d; + int e; + int f; +}; + +// CHECK: global %0 { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 } +struct ManyFields FewInits = {1, 2}; + + +// PR6766 +// CHECK: @l = global %1 { [24 x i8] c"f\00\00\00o\00\00\00o\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i32 1 } +typedef __WCHAR_TYPE__ wchar_t; +struct K { + wchar_t L[6]; + int M; +} l = { { L"foo" }, 1 }; + + +// CHECK: @yuv_types = global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"] +char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"}; // NOTE: tentative definitions are processed at the end of the translation unit. // This shouldn't be emitted as common because it has an explicit section. // rdar://7119244 -int b __attribute__((section("foo"))); - // CHECK: @b = global i32 0, section "foo" - +int b __attribute__((section("foo"))); diff --git a/test/CodeGen/init.c b/test/CodeGen/init.c index 13ffad1..d48e723 100644 --- a/test/CodeGen/init.c +++ b/test/CodeGen/init.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s void f1() { // Scalars in braces. @@ -22,8 +22,8 @@ void f3() { } // Constants -// RUN: grep '@g3 = constant i32 10' %t -// RUN: grep '@f4.g4 = internal constant i32 12' %t +// CHECK: @g3 = constant i32 10 +// CHECK: @f4.g4 = internal constant i32 12 const int g3 = 10; int f4() { static const int g4 = 12; diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c index a96176a..828d7de 100644 --- a/test/CodeGen/libcalls.c +++ b/test/CodeGen/libcalls.c @@ -1,22 +1,52 @@ -// RUN: %clang_cc1 -fmath-errno -emit-llvm -o %t %s -triple i386-unknown-unknown -// RUN: grep "declare " %t | count 6 -// RUN: grep "declare " %t | grep "@llvm." | count 1 -// RUN: %clang_cc1 -emit-llvm -o %t %s -triple i386-unknown-unknown -// RUN: grep "declare " %t | count 6 -// RUN: grep "declare " %t | grep -v "@llvm." | count 0 - -// IRgen only pays attention to const; it should always call llvm for -// this. -float sqrtf(float) __attribute__((const)); +// RUN: %clang_cc1 -fmath-errno -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix YES %s +// RUN: %clang_cc1 -emit-llvm -o - %s -triple i386-unknown-unknown | FileCheck -check-prefix NO %s +// CHECK-YES: define void @test_sqrt +// CHECK-NO: define void @test_sqrt void test_sqrt(float a0, double a1, long double a2) { + // Following llvm-gcc's lead, we never emit these as intrinsics; + // no-math-errno isn't good enough. We could probably use intrinsics + // with appropriate guards if it proves worthwhile. + + // CHECK-YES: call float @sqrtf + // CHECK-NO: call float @sqrtf float l0 = sqrtf(a0); + + // CHECK-YES: call double @sqrt + // CHECK-NO: call double @sqrt double l1 = sqrt(a1); + + // CHECK-YES: call x86_fp80 @sqrtl + // CHECK-NO: call x86_fp80 @sqrtl long double l2 = sqrtl(a2); } +// CHECK-YES: declare float @sqrtf(float) +// CHECK-YES: declare double @sqrt(double) +// CHECK-YES: declare x86_fp80 @sqrtl(x86_fp80) +// CHECK-NO: declare float @sqrtf(float) readnone +// CHECK-NO: declare double @sqrt(double) readnone +// CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) readnone + +// CHECK-YES: define void @test_pow +// CHECK-NO: define void @test_pow void test_pow(float a0, double a1, long double a2) { + // CHECK-YES: call float @powf + // CHECK-NO: call float @llvm.pow.f32 float l0 = powf(a0, a0); + + // CHECK-YES: call double @pow + // CHECK-NO: call double @llvm.pow.f64 double l1 = pow(a1, a1); + + // CHECK-YES: call x86_fp80 @powl + // CHECK-NO: call x86_fp80 @llvm.pow.f80 long double l2 = powl(a2, a2); } + +// CHECK-YES: declare float @powf(float, float) +// CHECK-YES: declare double @pow(double, double) +// CHECK-YES: declare x86_fp80 @powl(x86_fp80, x86_fp80) +// CHECK-NO: declare float @llvm.pow.f32(float, float) nounwind readonly +// CHECK-NO: declare double @llvm.pow.f64(double, double) nounwind readonly +// CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) nounwind readonly diff --git a/test/CodeGen/palignr.c b/test/CodeGen/palignr.c index 627e309..6297b2e 100644 --- a/test/CodeGen/palignr.c +++ b/test/CodeGen/palignr.c @@ -1,13 +1,9 @@ // 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))) -#define _mm_alignr_pi8(a, b, n) (__builtin_ia32_palignr((a), (b), (n*8))) -typedef __attribute__((vector_size(8))) int int2; typedef __attribute__((vector_size(16))) int int4; // CHECK: palignr -int2 mmx_align1(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 7); } -// CHECK: palignr int4 align1(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 15); } // CHECK: ret // CHECK: ret @@ -17,3 +13,18 @@ int4 align2(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 16); } int4 align3(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 17); } // CHECK: xor int4 align4(int4 a, int4 b) { return _mm_alignr_epi8(a, b, 32); } + +#define _mm_alignr_pi8(a, b, n) (__builtin_ia32_palignr((a), (b), (n))) +typedef __attribute__((vector_size(8))) int int2; + +// CHECK-NOT: palignr +int2 align5(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 8); } + +// CHECK: psrlq +int2 align6(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 9); } + +// CHECK: xor +int2 align7(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 16); } + +// CHECK: palignr +int2 align8(int2 a, int2 b) { return _mm_alignr_pi8(a, b, 7); } \ No newline at end of file diff --git a/test/CodeGen/struct-passing.c b/test/CodeGen/struct-passing.c index b351d81..409d14e 100644 --- a/test/CodeGen/struct-passing.c +++ b/test/CodeGen/struct-passing.c @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s // RUN: grep 'declare i32 @f0() readnone$' %t // RUN: grep 'declare i32 @f1() readonly$' %t -// RUN: grep 'declare void @f2(.* noalias sret)$' %t -// RUN: grep 'declare void @f3(.* noalias sret)$' %t +// RUN: grep 'declare void @f2(.* sret)$' %t +// RUN: grep 'declare void @f3(.* sret)$' %t // RUN: grep 'declare void @f4(.* byval)$' %t // RUN: grep 'declare void @f5(.* byval)$' %t // PR3835 diff --git a/test/CodeGen/union-init2.c b/test/CodeGen/union-init2.c index ac469cd..1386c27 100644 --- a/test/CodeGen/union-init2.c +++ b/test/CodeGen/union-init2.c @@ -1,4 +1,13 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | grep "bitcast (%0\* @r to %union.x\*), \[4 x i8\] undef" +// RUN: %clang_cc1 -emit-llvm %s -o - -triple i686-pc-linux-gnu | FileCheck %s // Make sure we generate something sane instead of a ptrtoint +// CHECK: bitcast (%0* @r to %union.x*), [4 x i8] undef union x {long long b;union x* a;} r = {.a = &r}; + + +// CHECK: global %1 { [3 x i8] zeroinitializer, [5 x i8] undef } +union z { + char a[3]; + long long b; +}; +union z y = {}; diff --git a/test/CodeGen/x86_32-arguments.c b/test/CodeGen/x86_32-arguments.c index eb98e1a..01c3e23 100644 --- a/test/CodeGen/x86_32-arguments.c +++ b/test/CodeGen/x86_32-arguments.c @@ -1,45 +1,45 @@ // RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s -// RUN: grep 'define signext i8 @f0()' %t -// RUN: grep 'define signext i16 @f1()' %t -// RUN: grep 'define i32 @f2()' %t -// RUN: grep 'define float @f3()' %t -// RUN: grep 'define double @f4()' %t -// RUN: grep 'define x86_fp80 @f5()' %t -// RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t -// RUN: grep 'define void @f7(i32 %a0)' %t -// RUN: grep 'define i64 @f8_1()' %t -// RUN: grep 'define void @f8_2(i32 %a0.0, i32 %a0.1)' %t +// RUN: FileCheck < %t %s +// CHECK: define signext i8 @f0() char f0(void) { return 0; } +// CHECK: define signext i16 @f1() short f1(void) { return 0; } +// CHECK: define i32 @f2() int f2(void) { return 0; } +// CHECK: define float @f3() float f3(void) { return 0; } +// CHECK: define double @f4() double f4(void) { return 0; } +// CHECK: define x86_fp80 @f5() long double f5(void) { return 0; } +// CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4) void f6(char a0, short a1, int a2, long long a3, void *a4) {} -typedef enum { A, B, C } E; - -void f7(E a0) {} +// CHECK: define void @f7(i32 %a0) +typedef enum { A, B, C } e7; +void f7(e7 a0) {} +// CHECK: define i64 @f8_1() +// CHECK: define void @f8_2(i32 %a0.0, i32 %a0.1) struct s8 { int a; int b; @@ -49,11 +49,11 @@ void f8_2(struct s8 a0) {} // This should be passed just as s8. -// RUN: grep 'define i64 @f9_1()' %t +// CHECK: define i64 @f9_1() // FIXME: llvm-gcc expands this, this may have some value for the // backend in terms of optimization but doesn't change the ABI. -// RUN: grep 'define void @f9_2(%.truct.s9\* byval %a0)' %t +// CHECK: define void @f9_2(%struct.s9* byval %a0) struct s9 { int a : 17; int b; @@ -63,7 +63,7 @@ void f9_2(struct s9 a0) {} // Return of small structures and unions -// RUN: grep 'float @f10()' %t +// CHECK: float @f10() struct s10 { union { }; float f; @@ -71,12 +71,12 @@ struct s10 { // Small vectors and 1 x {i64,double} are returned in registers -// RUN: grep 'i32 @f11()' %t -// RUN: grep -F 'void @f12(<2 x i32>* noalias sret %agg.result)' %t -// RUN: grep 'i64 @f13()' %t -// RUN: grep 'i64 @f14()' %t -// RUN: grep '<2 x i64> @f15()' %t -// RUN: grep '<2 x i64> @f16()' %t +// CHECK: i32 @f11() +// CHECK: void @f12(<2 x i32>* sret %agg.result) +// CHECK: i64 @f13() +// CHECK: i64 @f14() +// CHECK: <2 x i64> @f15() +// CHECK: <2 x i64> @f16() typedef short T11 __attribute__ ((vector_size (4))); T11 f11(void) { while (1) {} } typedef int T12 __attribute__ ((vector_size (8))); @@ -93,12 +93,12 @@ T16 f16(void) { while (1) {} } // And when the single element in a struct (but not for 64 and // 128-bits). -// RUN: grep 'i32 @f17()' %t -// RUN: grep -F 'void @f18(%2* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f19(%3* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f20(%4* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f21(%5* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f22(%6* noalias sret %agg.result)' %t +// CHECK: i32 @f17() +// CHECK: void @f18(%2* sret %agg.result) +// CHECK: void @f19(%3* sret %agg.result) +// CHECK: void @f20(%4* sret %agg.result) +// CHECK: void @f21(%5* sret %agg.result) +// CHECK: void @f22(%6* sret %agg.result) struct { T11 a; } f17(void) { while (1) {} } struct { T12 a; } f18(void) { while (1) {} } struct { T13 a; } f19(void) { while (1) {} } @@ -108,97 +108,109 @@ struct { T16 a; } f22(void) { while (1) {} } // Single element structures are handled specially -// RUN: grep -F 'float @f23()' %t -// RUN: grep -F 'float @f24()' %t -// RUN: grep -F 'float @f25()' %t +// CHECK: float @f23() +// CHECK: float @f24() +// CHECK: float @f25() struct { float a; } f23(void) { while (1) {} } struct { float a[1]; } f24(void) { while (1) {} } struct { struct {} a; struct { float a[1]; } b; } f25(void) { while (1) {} } // Small structures are handled recursively -// RUN: grep -F 'i32 @f26()' %t -// RUN: grep 'void @f27(%.truct.s27\* noalias sret %agg.result)' %t +// CHECK: i32 @f26() +// CHECK: void @f27(%struct.s27* sret %agg.result) struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) { while (1) {} } struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) { while (1) {} } -// RUN: grep 'void @f28(%.truct.s28\* noalias sret %agg.result)' %t +// CHECK: void @f28(%struct.s28* sret %agg.result) struct s28 { int a; int b[]; } f28(void) { while (1) {} } -// RUN: grep 'define i16 @f29()' %t +// CHECK: define i16 @f29() struct s29 { struct { } a[1]; char b; char c; } f29(void) { while (1) {} } -// RUN: grep 'define i16 @f30()' %t +// CHECK: define i16 @f30() struct s30 { char a; char b : 4; } f30(void) { while (1) {} } -// RUN: grep 'define float @f31()' %t +// CHECK: define float @f31() struct s31 { char : 0; float b; char : 0; } f31(void) { while (1) {} } -// RUN: grep 'define i32 @f32()' %t +// CHECK: define i32 @f32() struct s32 { char a; unsigned : 0; } f32(void) { while (1) {} } -// RUN: grep 'define float @f33()' %t +// CHECK: define float @f33() struct s33 { float a; long long : 0; } f33(void) { while (1) {} } -// RUN: grep 'define float @f34()' %t +// CHECK: define float @f34() struct s34 { struct { int : 0; } a; float b; } f34(void) { while (1) {} } -// RUN: grep 'define i16 @f35()' %t +// CHECK: define i16 @f35() struct s35 { struct { int : 0; } a; char b; char c; } f35(void) { while (1) {} } -// RUN: grep 'define i16 @f36()' %t +// CHECK: define i16 @f36() struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) { while (1) {} } -// RUN: grep 'define float @f37()' %t +// CHECK: define float @f37() struct s37 { float c[1][1]; } f37(void) { while (1) {} } -// RUN: grep 'define void @f38(.struct.s38. noalias sret .agg.result)' %t +// CHECK: define void @f38(%struct.s38* sret %agg.result) struct s38 { char a[3]; short b; } f38(void) { while (1) {} } -// RUN: grep 'define void @f39(.struct.s39. byval align 16 .x)' %t +// CHECK: define void @f39(%struct.s39* byval align 16 %x) typedef int v39 __attribute((vector_size(16))); struct s39 { v39 x; }; void f39(struct s39 x) {} // -// RUN: grep 'define i32 @f40()' %t +// CHECK: define i32 @f40() enum e40 { ec0 = 0 }; enum e40 f40(void) { } -// RUN: grep 'define void ()\* @f41()' %t +// CHECK: define void ()* @f41() typedef void (^vvbp)(void); vvbp f41(void) { } -// RUN: grep 'define i32 @f42()' %t +// CHECK: define i32 @f42() struct s42 { enum e40 f0; } f42(void) { } -// RUN: grep 'define i64 @f43()' %t +// CHECK: define i64 @f43() struct s43 { enum e40 f0; int f1; } f43(void) { } -// RUN: grep 'define i32 @f44()' %t +// CHECK: define i32 @f44() struct s44 { vvbp f0; } f44(void) { } -// RUN: grep 'define i64 @f45()' %t +// CHECK: define i64 @f45() struct s45 { vvbp f0; int f1; } f45(void) { } -// RUN: grep 'define void @f46(i32 %a0)' %t +// CHECK: define void @f46(i32 %a0) void f46(enum e40 a0) { } -// RUN: grep 'define void @f47(void ()\* %a1)' %t +// CHECK: define void @f47(void ()* %a1) void f47(vvbp a1) { } -// RUN: grep 'define void @f48(i32 %a0.0)' %t +// CHECK: define void @f48(i32 %a0.0) struct s48 { enum e40 f0; }; void f48(struct s48 a0) { } -// RUN: grep 'define void @f49(i32 %a0.0, i32 %a0.1)' %t +// CHECK: define void @f49(i32 %a0.0, i32 %a0.1) struct s49 { enum e40 f0; int f1; }; void f49(struct s49 a0) { } -// RUN: grep 'define void @f50(void ()\* %a0.0)' %t +// CHECK: define void @f50(void ()* %a0.0) struct s50 { vvbp f0; }; void f50(struct s50 a0) { } -// RUN: grep 'define void @f51(void ()\* %a0.0, i32 %a0.1)' %t +// CHECK: define void @f51(void ()* %a0.0, i32 %a0.1) struct s51 { vvbp f0; int f1; }; void f51(struct s51 a0) { } +// CHECK: define void @f52(%struct.s52* byval align 16 %x) +struct s52 { + long double a; +}; +void f52(struct s52 x) {} + +// CHECK: define void @f53(%struct.s53* byval align 32 %x) +struct __attribute__((aligned(32))) s53 { + int x; + int y; +}; +void f53(struct s53 x) {} diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index d6b9b29..47b2eb1 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -1,49 +1,51 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o %t %s -// RUN: grep 'define signext i8 @f0()' %t -// RUN: grep 'define signext i16 @f1()' %t -// RUN: grep 'define i32 @f2()' %t -// RUN: grep 'define float @f3()' %t -// RUN: grep 'define double @f4()' %t -// RUN: grep 'define x86_fp80 @f5()' %t -// RUN: grep 'define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8\* %a4)' %t -// RUN: grep 'define void @f7(i32 %a0)' %t -// RUN: grep '.0 = type { i64, double }' %t -// RUN: grep 'define .0 @f8_1()' %t -// RUN: grep 'define void @f8_2(.0)' %t +// RUN: FileCheck < %t %s +// CHECK: %0 = type { i64, double } + +// CHECK: define signext i8 @f0() char f0(void) { return 0; } +// CHECK: define signext i16 @f1() short f1(void) { return 0; } +// CHECK: define i32 @f2() int f2(void) { return 0; } +// CHECK: define float @f3() float f3(void) { return 0; } +// CHECK: define double @f4() double f4(void) { return 0; } +// CHECK: define x86_fp80 @f5() long double f5(void) { return 0; } +// CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4) void f6(char a0, short a1, int a2, long long a3, void *a4) { } -typedef enum { A, B, C } E; - -void f7(E a0) { +// CHECK: define void @f7(i32 %a0) +typedef enum { A, B, C } e7; +void f7(e7 a0) { } // Test merging/passing of upper eightbyte with X87 class. +// +// CHECK: define %0 @f8_1() +// CHECK: define void @f8_2(%0) union u8 { long double a; int b; @@ -51,48 +53,63 @@ union u8 { union u8 f8_1() { while (1) {} } void f8_2(union u8 a0) {} -// RUN: grep 'define i64 @f9()' %t +// CHECK: define i64 @f9() struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} } -// RUN: grep 'define void @f10(i64)' %t +// CHECK: define void @f10(i64) struct s10 { int a; int b; int : 0; }; void f10(struct s10 a0) {} -// RUN: grep 'define void @f11(.union.anon. noalias sret .agg.result)' %t +// CHECK: define void @f11(%struct.s19* sret %agg.result) union { long double a; float b; } f11() { while (1) {} } -// RUN: grep 'define i64 @f12_0()' %t -// RUN: grep 'define void @f12_1(i64)' %t +// CHECK: define i64 @f12_0() +// CHECK: define void @f12_1(i64) struct s12 { int a __attribute__((aligned(16))); }; struct s12 f12_0(void) { while (1) {} } void f12_1(struct s12 a0) {} // Check that sret parameter is accounted for when checking available integer // registers. -// RUN: grep 'define void @f13(.struct.s13_0. noalias sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t +// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, %struct.s13_1* byval %e, i32 %f) struct s13_0 { long long f0[3]; }; struct s13_1 { long long f0[2]; }; -struct s13_0 f13(int a, int b, int c, int d, +struct s13_0 f13(int a, int b, int c, int d, struct s13_1 e, int f) { while (1) {} } -// RUN: grep 'define void @f14(.*, i8 signext .X)' %t -void f14(int a, int b, int c, int d, int e, int f, - char X) {} -// RUN: grep 'define void @f15(.*, i8\* .X)' %t -void f15(int a, int b, int c, int d, int e, int f, - void *X) {} -// RUN: grep 'define void @f16(.*, float .X)' %t +// CHECK: define void @f14({{.*}}, i8 signext %X) +void f14(int a, int b, int c, int d, int e, int f, char X) {} + +// CHECK: define void @f15({{.*}}, i8* %X) +void f15(int a, int b, int c, int d, int e, int f, void *X) {} + +// CHECK: define void @f16({{.*}}, float %X) void f16(float a, float b, float c, float d, float e, float f, float g, float h, float X) {} -// RUN: grep 'define void @f17(.*, x86_fp80 .X)' %t + +// CHECK: define void @f17({{.*}}, x86_fp80 %X) void f17(float a, float b, float c, float d, float e, float f, float g, float h, long double X) {} // Check for valid coercion. -// RUN: grep '.. = bitcast i64. .* to .struct.f18_s0.' %t -// RUN: grep '.. = load .struct.f18_s0. .., align 1' %t -// RUN: grep 'store .struct.f18_s0 .., .struct.f18_s0. .f18_arg1' %t +// CHECK: [[f18_t0:%.*]] = bitcast i64* {{.*}} to %struct.f18_s0* +// CHECK: [[f18_t1:%.*]] = load %struct.f18_s0* [[f18_t0]], align 1 +// CHECK: store %struct.f18_s0 [[f18_t1]], %struct.f18_s0* %f18_arg1 struct f18_s0 { int f0; }; void f18(int a, struct f18_s0 f18_arg1) { while (1) {} } +// Check byval alignment. + +// CHECK: define void @f19(%struct.s19* byval align 16 %x) +struct s19 { + long double a; +}; +void f19(struct s19 x) {} + +// CHECK: define void @f20(%struct.s20* byval align 32 %x) +struct __attribute__((aligned(32))) s20 { + int x; + int y; +}; +void f20(struct s20 x) {} diff --git a/test/CodeGenCXX/PR6747.cpp b/test/CodeGenCXX/PR6747.cpp new file mode 100644 index 0000000..5a07ce6 --- /dev/null +++ b/test/CodeGenCXX/PR6747.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s + +struct foo { + virtual void bar(); +// CHECK: define available_externally void @_ZN3foo3bazEv + virtual void baz() {} +}; +void zed() { + foo b; + b.baz(); +} diff --git a/test/CodeGenCXX/address-of-fntemplate.cpp b/test/CodeGenCXX/address-of-fntemplate.cpp index c5fa89d..162c6e5 100644 --- a/test/CodeGenCXX/address-of-fntemplate.cpp +++ b/test/CodeGenCXX/address-of-fntemplate.cpp @@ -11,3 +11,17 @@ void test() { } // CHECK: define linkonce_odr void @_Z1fIiEvT_ // CHECK: define linkonce_odr void @_Z1fIiEvv + +namespace PR6973 { + template + struct X { + void f(const T&); + }; + + template + int g(); + + void h(X xf) { + xf.f(&g); + } +} diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index ea3eafc..adb3950 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s struct A { union { @@ -10,3 +10,27 @@ struct A { }; A a; + +namespace PR7021 { + struct X + { + union { long l; }; + }; + + // CHECK: define void @_ZN6PR70211fENS_1XES0_ + void f(X x, X z) { + X x1; + + // CHECK: store i64 1, i64 + x1.l = 1; + + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + X x2(x1); + + X x3; + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 + x3 = x1; + + // CHECK: ret void + } +} diff --git a/test/CodeGenCXX/arm.cpp b/test/CodeGenCXX/arm.cpp new file mode 100644 index 0000000..5cca788 --- /dev/null +++ b/test/CodeGenCXX/arm.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - | FileCheck %s + +class foo { +public: + foo(); + virtual ~foo(); +}; + +class bar : public foo { +public: + bar(); +}; + +// The global dtor needs the right calling conv with -fno-use-cxa-atexit +// rdar://7817590 +bar baz; + +// CHECK: @_GLOBAL__D_a() +// CHECK: call arm_apcscc void @_ZN3barD1Ev(%class.bar* @baz) + diff --git a/test/CodeGenCXX/assign-operator.cpp b/test/CodeGenCXX/assign-operator.cpp index cb8867f..c4b64e6 100644 --- a/test/CodeGenCXX/assign-operator.cpp +++ b/test/CodeGenCXX/assign-operator.cpp @@ -1,9 +1,19 @@ -// RUN: %clang_cc1 %s -emit-llvm-only -verify +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -verify -o - |FileCheck %s class x { -int operator=(int); +public: int operator=(int); }; void a() { x a; a = 1u; } + +void f(int i, int j) { + // CHECK: load i32 + // CHECK: load i32 + // CHECK: add nsw i32 + // CHECK: store i32 + // CHECK: store i32 17, i32 + // CHECK: ret + (i += j) = 17; +} diff --git a/test/CodeGenCXX/bitfield-layout.cpp b/test/CodeGenCXX/bitfield-layout.cpp new file mode 100644 index 0000000..15f33d2 --- /dev/null +++ b/test/CodeGenCXX/bitfield-layout.cpp @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck -check-prefix LP32 %s + +// CHECK-LP64: %union.Test1 = type { i32, [4 x i8] } +union Test1 { + int a; + int b: 39; +} t1; + +// CHECK-LP64: %union.Test2 = type { i8 } +union Test2 { + int : 6; +} t2; + +// CHECK-LP64: %union.Test3 = type { [2 x i8] } +union Test3 { + int : 9; +} t3; + + +#define CHECK(x) if (!(x)) return __LINE__ + +int f() { + struct { + int a; + + unsigned long long b : 65; + + int c; + } c; + + c.a = 0; + c.b = (unsigned long long)-1; + c.c = 0; + + CHECK(c.a == 0); + CHECK(c.b == (unsigned long long)-1); + CHECK(c.c == 0); + +// CHECK-LP64: ret i32 0 +// CHECK-LP32: ret i32 0 + return 0; +} diff --git a/test/CodeGenCXX/block-destruct.cpp b/test/CodeGenCXX/block-destruct.cpp new file mode 100644 index 0000000..f809ca2 --- /dev/null +++ b/test/CodeGenCXX/block-destruct.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -emit-llvm -o - | FileCheck %s + +struct A { ~A(); }; + +void f() { + __block A a; +} + +// CHECK: call void @_ZN1AD1Ev diff --git a/test/CodeGenCXX/c-linkage.cpp b/test/CodeGenCXX/c-linkage.cpp new file mode 100644 index 0000000..b1f07b7 --- /dev/null +++ b/test/CodeGenCXX/c-linkage.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// pr6644 + +extern "C" { + namespace N { + struct X { + virtual void f(); + }; + void X::f() { } + } +} + +// CHECK: define void @_ZN1N1X1fEv diff --git a/test/CodeGenCXX/constructor-init-reference.cpp b/test/CodeGenCXX/constructor-init-reference.cpp index c2f41e1..5e75159 100644 --- a/test/CodeGenCXX/constructor-init-reference.cpp +++ b/test/CodeGenCXX/constructor-init-reference.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-llvm -o - %s | grep "store i32\* @x, i32\*\*" int x; -class A { +struct A { int& y; A() : y(x) {} }; diff --git a/test/CodeGenCXX/constructors.cpp b/test/CodeGenCXX/constructors.cpp index 2c95c91..a8dc7fc 100644 --- a/test/CodeGenCXX/constructors.cpp +++ b/test/CodeGenCXX/constructors.cpp @@ -12,7 +12,7 @@ struct ValueClass { /* Test basic functionality. */ -class A { +struct A { A(struct Undeclared &); A(ValueClass); Member mem; @@ -92,3 +92,15 @@ D::D(int x, ...) : A(ValueClass(x, x+1)), mem(x*x) {} // CHECK: call void @_ZN10ValueClassC1Eii( // CHECK: call void @_ZN1AC2E10ValueClass( // CHECK: call void @_ZN6MemberC1Ei( + + +// PR6622: this shouldn't crash +namespace test0 { + struct A {}; + struct B : virtual A { int x; }; + struct C : B {}; + + void test(C &in) { + C tmp = in; + } +} diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp index e523eb0..e4a0677 100644 --- a/test/CodeGenCXX/default-arg-temps.cpp +++ b/test/CodeGenCXX/default-arg-temps.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s struct T { T(); @@ -13,20 +13,62 @@ public: X(const X&, const T& t = T()); }; +// CHECK: define void @_Z1gv() void g() { - // RUN: grep "call void @_ZN1TC1Ev" %t | count 4 - // RUN: grep "call void @_ZN1TD1Ev" %t | count 4 + // CHECK: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG1:%.*]]) + // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG1]]) + // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG1]]) f(); + + // CHECK-NEXT: call void @_ZN1TC1Ev([[T:%.*]]* [[AGG2:%.*]]) + // CHECK-NEXT: call void @_Z1fRK1T([[T]]* [[AGG2]]) + // CHECK-NEXT: call void @_ZN1TD1Ev([[T]]* [[AGG2]]) f(); + // CHECK-NEXT: call void @_ZN1XC1Ev( X a; + + // CHECK-NEXT: call void @_ZN1TC1Ev( + // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T( + // CHECK-NEXT: call void @_ZN1TD1Ev( X b(a); + + // CHECK-NEXT: call void @_ZN1TC1Ev( + // CHECK-NEXT: call void @_ZN1XC1ERKS_RK1T( + // CHECK-NEXT: call void @_ZN1TD1Ev( X c = a; } -// RUN: grep memset %t class obj{ int a; float b; double d; }; +// CHECK: define void @_Z1hv() void h() { + // CHECK: call void @llvm.memset.p0i8.i64( + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64( obj o = obj(); } + +// PR7028 - mostly this shouldn't crash +namespace test1 { + struct A { A(); }; + struct B { B(); ~B(); }; + + struct C { + C(const B &file = B()); + }; + C::C(const B &file) {} + + struct D { + C c; + A a; + + // CHECK: define linkonce_odr void @_ZN5test11DC2Ev( + // CHECK: call void @_ZN5test11BC1Ev( + // CHECK-NEXT: call void @_ZN5test11CC1ERKNS_1BE( + // CHECK-NEXT: call void @_ZN5test11BD1Ev( + // CHECK: call void @_ZN5test11AC1Ev( + D() : c(), a() {} + }; + + D d; +} diff --git a/test/CodeGenCXX/default-destructor-nested.cpp b/test/CodeGenCXX/default-destructor-nested.cpp index 8694274..565a727 100644 --- a/test/CodeGenCXX/default-destructor-nested.cpp +++ b/test/CodeGenCXX/default-destructor-nested.cpp @@ -2,7 +2,7 @@ // PR6294 class A { - virtual ~A(); +public: virtual ~A(); }; class B { class C; diff --git a/test/CodeGenCXX/delete.cpp b/test/CodeGenCXX/delete.cpp index 7cc264f..87f8698 100644 --- a/test/CodeGenCXX/delete.cpp +++ b/test/CodeGenCXX/delete.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o %t +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s void t1(int *a) { delete a; @@ -19,8 +19,11 @@ struct T { int a; }; +// CHECK: define void @_Z2t4P1T void t4(T *t) { - // RUN: grep "call void @_ZN1TD1Ev" %t | count 1 + // CHECK: call void @_ZN1TD1Ev + // CHECK-NEXT: bitcast + // CHECK-NEXT: call void @_ZdlPv delete t; } @@ -35,3 +38,22 @@ void f() { delete a; } + +namespace test0 { + struct A { + void *operator new(__SIZE_TYPE__ sz); + void operator delete(void *p) { ::operator delete(p); } + ~A() {} + }; + + // CHECK: define void @_ZN5test04testEPNS_1AE( + void test(A *a) { + // CHECK: call void @_ZN5test01AD1Ev + // CHECK-NEXT: bitcast + // CHECK-NEXT: call void @_ZN5test01AdlEPv + delete a; + } + + // CHECK: define linkonce_odr void @_ZN5test01AD1Ev + // CHECK: define linkonce_odr void @_ZN5test01AdlEPv +} diff --git a/test/CodeGenCXX/destructor-debug-info.cpp b/test/CodeGenCXX/destructor-debug-info.cpp new file mode 100644 index 0000000..9e32275 --- /dev/null +++ b/test/CodeGenCXX/destructor-debug-info.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -g -S -emit-llvm -o %t %s +// RUN: grep "i32 20, i32 3, metadata" %t | count 1 +// Check there is a line number entry for line 20 where b1 is destructed. +class A { int a; }; +class B { +public: + B() { a = new A; } + ~B() { delete a; } +private: + A *a; +}; + +void fn(B b); + +int i; +void foo() { + if (i) { + B b1; + fn (b1); + } +} diff --git a/test/CodeGenCXX/eh.cpp b/test/CodeGenCXX/eh.cpp index afd9da6..f2629d1 100644 --- a/test/CodeGenCXX/eh.cpp +++ b/test/CodeGenCXX/eh.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll +// RUN: %clang_cc1 -fexceptions -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t.ll // RUN: FileCheck --input-file=%t.ll %s struct test1_D { @@ -9,14 +9,18 @@ void test1() { throw d1; } -// CHECK: define void @_Z5test1v() nounwind { -// CHECK: %{{exception.ptr|1}} = alloca i8* -// CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 8) -// CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{exception.ptr|1}} -// CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test1_D* -// CHECK-NEXT: %{{tmp|4}} = bitcast %struct.test1_D* %{{0|3}} to i8* -// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{tmp|4}}, i8* bitcast (%struct.test1_D* @d1 to i8*), i64 8, i32 8, i1 false) -// CHECK-NEXT: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn +// CHECK: define void @_Z5test1v() +// CHECK: [[FREEVAR:%.*]] = alloca i1 +// CHECK-NEXT: [[EXNOBJVAR:%.*]] = alloca i8* +// CHECK-NEXT: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8) +// CHECK-NEXT: store i8* [[EXNOBJ]], i8** [[EXNOBJVAR]] +// CHECK-NEXT: store i1 true, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]] +// CHECK-NEXT: [[EXN2:%.*]] = bitcast [[DSTAR]] [[EXN]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[EXN2]], i8* bitcast ([[DSTAR]] @d1 to i8*), i64 8, i32 8, i1 false) +// CHECK-NEXT: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast (%0* @_ZTI7test1_D to i8*), i8* null) noreturn // CHECK-NEXT: unreachable @@ -31,14 +35,19 @@ void test2() { throw d2; } -// CHECK: define void @_Z5test2v() nounwind { -// CHECK: %{{exception.ptr|1}} = alloca i8* -// CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 16) -// CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{\1}} -// CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test2_D* -// CHECK: invoke void @_ZN7test2_DC1ERKS_(%struct.test2_D* %{{0|3}}, %struct.test2_D* @d2) -// CHECK-NEXT: to label %{{invoke.cont|8}} unwind label %{{terminate.handler|4}} -// CHECK: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%{{0|3}}* @_ZTI7test2_D to i8*), i8* null) noreturn +// CHECK: define void @_Z5test2v() +// CHECK: [[FREEVAR:%.*]] = alloca i1 +// CHECK-NEXT: [[EXNOBJVAR:%.*]] = alloca i8* +// CHECK-NEXT: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 16) +// CHECK-NEXT: store i8* [[EXNOBJ]], i8** [[EXNOBJVAR]] +// CHECK-NEXT: store i1 true, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]] +// CHECK-NEXT: invoke void @_ZN7test2_DC1ERKS_([[DSTAR]] [[EXN]], [[DSTAR]] @d2) +// CHECK-NEXT: to label %[[CONT:.*]] unwind label %{{.*}} +// : [[CONT]]: (can't check this in Release-Asserts builds) +// CHECK: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast (%{{.*}}* @_ZTI7test2_D to i8*), i8* null) noreturn // CHECK-NEXT: unreachable @@ -52,20 +61,46 @@ void test3() { throw (volatile test3_D *)0; } -// CHECK: define void @_Z5test3v() nounwind { -// CHECK: %{{exception.ptr|1}} = alloca i8* -// CHECK-NEXT: %{{exception|2}} = call i8* @__cxa_allocate_exception(i64 8) -// CHECK-NEXT: store i8* %{{exception|2}}, i8** %{{exception.ptr|1}} -// CHECK-NEXT: %{{0|3}} = bitcast i8* %{{exception|2}} to %struct.test3_D** -// CHECK-NEXT: store %struct.test3_D* null, %struct.test3_D** -// CHECK-NEXT: call void @__cxa_throw(i8* %{{exception|2}}, i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn -// CHECK-NEXT: unreachable +// CHECK: define void @_Z5test3v() +// CHECK: [[FREEVAR:%.*]] = alloca i1 +// CHECK-NEXT: [[EXNOBJVAR:%.*]] = alloca i8* +// CHECK-NEXT: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8) +// CHECK-NEXT: store i8* [[EXNOBJ]], i8** [[EXNOBJVAR]] +// CHECK-NEXT: store i1 true, i1* [[FREEVAR]] +// CHECK-NEXT: [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSS:%[^*]*\*]]* +// CHECK-NEXT: store [[DSS]] null, [[DSS]]* [[EXN]] +// CHECK-NEXT: store i1 false, i1* [[FREEVAR]] +// CHECK-NEXT: call void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast (%1* @_ZTIPV7test3_D to i8*), i8* null) noreturn +// CHECK-NEXT: unreachable void test4() { throw; } -// CHECK: define void @_Z5test4v() nounwind { +// CHECK: define void @_Z5test4v() // CHECK: call void @__cxa_rethrow() noreturn // CHECK-NEXT: unreachable + + +// rdar://problem/7696549 +namespace test5 { + struct A { + A(); + A(const A&); + ~A(); + }; + + void test() { + try { throw A(); } catch (A &x) {} + } +// CHECK: define void @_ZN5test54testEv() +// CHECK: [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 1) +// CHECK: [[EXNCAST:%.*]] = bitcast i8* [[EXNOBJ]] to [[A:%[^*]*]]* +// CHECK-NEXT: invoke void @_ZN5test51AC1Ev([[A]]* [[EXNCAST]]) +// CHECK: invoke void @__cxa_throw(i8* [[EXNOBJ]], i8* bitcast ({{%.*}}* @_ZTIN5test51AE to i8*), i8* bitcast (void ([[A]]*)* @_ZN5test51AD1Ev to i8*)) noreturn +// CHECK-NEXT: to label {{%.*}} unwind label %[[HANDLER:[^ ]*]] +// : [[HANDLER]]: (can't check this in Release-Asserts builds) +// CHECK: {{%.*}} = call i32 @llvm.eh.typeid.for(i8* bitcast ({{%.*}}* @_ZTIN5test51AE to i8*)) +} diff --git a/test/CodeGenCXX/empty-classes.cpp b/test/CodeGenCXX/empty-classes.cpp new file mode 100644 index 0000000..59124e3 --- /dev/null +++ b/test/CodeGenCXX/empty-classes.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s + +struct Empty { }; + +struct A { + explicit A(unsigned a = 0xffffffff) : a(a) { } + + unsigned a; +}; + +struct B : A, Empty { + B() : A(), Empty() { } +}; + +struct C : A, Empty { + C() : A(), Empty() { } + C(const C& other) : A(0x12345678), Empty(other) { } +}; + +struct D : A, Empty { + D& operator=(const D& other) { + a = 0x87654321; + Empty::operator=(other); + + return *this; + } +}; + +#define CHECK(x) if (!(x)) return __LINE__ + +// PR7012 +// CHECK: define i32 @_Z1fv() +int f() { + B b1; + + // Check that A::a is not overwritten by the Empty default constructor. + CHECK(b1.a == 0xffffffff); + + C c1; + C c2(c1); + + // Check that A::a has the value set in the C::C copy constructor. + CHECK(c2.a == 0x12345678); + + D d1, d2; + d2 = d1; + + // Check that A::as has the value set in the D copy assignment operator. + CHECK(d2.a == 0x87654321); + + // Success! + // CHECK: ret i32 0 + return 0; +} + +#ifdef HARNESS +extern "C" void printf(const char *, ...); + +int main() { + int result = f(); + + if (result == 0) + printf("success!\n"); + else + printf("test on line %d failed!\n", result); + + return result; +} +#endif diff --git a/test/CodeGenCXX/exceptions-no-rtti.cpp b/test/CodeGenCXX/exceptions-no-rtti.cpp new file mode 100644 index 0000000..c26abb2 --- /dev/null +++ b/test/CodeGenCXX/exceptions-no-rtti.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -fno-rtti -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// CHECK: @_ZTIN5test11AE = weak_odr constant +// CHECK: @_ZTIN5test11BE = weak_odr constant +// CHECK: @_ZTIN5test11CE = weak_odr constant +// CHECK: @_ZTIN5test11DE = weak_odr constant +// CHECK: @_ZTIPN5test11DE = weak_odr constant {{.*}} @_ZTIN5test11DE + +// PR6974: this shouldn't crash +namespace test0 { + class err {}; + + void f(void) { + try { + } catch (err &) { + } + } +} + +namespace test1 { + // These classes have key functions defined out-of-line. + // Under normal circumstances, we wouldn't generate RTTI for them; + // under -fno-rtti, we generate RTTI only when required by EH. + class A { virtual void foo(); }; + class B { virtual void foo(); }; + class C { virtual void foo(); }; + class D { virtual void foo(); }; + + void opaque(); + + void test0() { + throw A(); + } + + void test1() throw(B) { + opaque(); + } + + void test2() { + try { + opaque(); + } catch (C&) {} + } + + void test3(D *ptr) { + throw ptr; + }; +} diff --git a/test/CodeGenCXX/field-access-debug-info.cpp b/test/CodeGenCXX/field-access-debug-info.cpp new file mode 100644 index 0000000..907fe04 --- /dev/null +++ b/test/CodeGenCXX/field-access-debug-info.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -g -S -masm-verbose -o %t %s +// RUN: grep DW_AT_accessibility %t + +class A { +public: + int p; +private: + int pr; +}; + +A a; diff --git a/test/CodeGenCXX/implicit-copy-assign-operator.cpp b/test/CodeGenCXX/implicit-copy-assign-operator.cpp new file mode 100644 index 0000000..0ec89fc --- /dev/null +++ b/test/CodeGenCXX/implicit-copy-assign-operator.cpp @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10.0.0 -o - %s | FileCheck %s +struct A { + A &operator=(const A&); + A &operator=(A&); +}; + +struct B { + B &operator=(B&); +}; + +struct C { + virtual C& operator=(const C&); +}; + +struct POD { + int array[3][4]; +}; + +struct CopyByValue { + CopyByValue(const CopyByValue&); + CopyByValue &operator=(CopyByValue); +}; + +struct D : A, B, virtual C { + int scalar; + int scalar_array[2][3]; + B class_member; + C class_member_array[2][3]; + POD pod_array[2][3]; + + union { + int x; + float f[3]; + }; + + CopyByValue by_value; +}; + +void test_D(D d1, D d2) { + d1 = d2; +} + +// CHECK: define linkonce_odr %struct.D* @_ZN1DaSERS_ +// CHECK: {{call.*_ZN1AaSERS_}} +// CHECK: {{call.*_ZN1BaSERS_}} +// CHECK: {{call.*_ZN1CaSERKS_}} +// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 24}} +// CHECK: {{call.*_ZN1BaSERS_}} +// CHECK: br +// CHECK: {{call.*_ZN1CaSERKS_}} +// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 288}} +// CHECK: {{call void @llvm.memcpy.p0i8.p0i8.i64.*i64 12}} +// CHECK: call void @_ZN11CopyByValueC1ERKS_ +// CHECK: {{call.*_ZN11CopyByValueaSES_}} +// CHECK: ret + diff --git a/test/CodeGenCXX/instantiate-init-list.cpp b/test/CodeGenCXX/instantiate-init-list.cpp index 676d299..49c6f51 100644 --- a/test/CodeGenCXX/instantiate-init-list.cpp +++ b/test/CodeGenCXX/instantiate-init-list.cpp @@ -5,7 +5,7 @@ struct F { }; void G(); template class A { - A(); +public: A(); }; template A::A() { static F f = { G }; diff --git a/test/CodeGenCXX/mangle-template.cpp b/test/CodeGenCXX/mangle-template.cpp index 22949da..6a29944 100644 --- a/test/CodeGenCXX/mangle-template.cpp +++ b/test/CodeGenCXX/mangle-template.cpp @@ -104,3 +104,43 @@ namespace test8 { // CHECK: define weak_odr void @_ZN5test81fIiEEvNS_5int_cIXsrNS_4metaIT_E4typeE5valueEEE template void f(int_c); } + +namespace test9 { + template + struct supermeta { + template + struct apply { + typedef T U::*type; + }; + }; + + struct X { }; + + template + typename supermeta::template apply::type f(); + + void test_f() { + // CHECK: @_ZN5test91fIiNS_1XEEENS_9supermetaIT_E5applyIT0_E4typeEv() + // Note: GCC incorrectly mangles this as + // _ZN5test91fIiNS_1XEEENS_9supermetaIT_E5apply4typeEv, while EDG + // gets it right. + f(); + } +} + +namespace test10 { + template + struct X { + template + struct definition { + }; + }; + + // CHECK: _ZN6test101fIidEENS_1XIT_E10definitionIT0_EES2_S5_ + template + typename X::template definition f(T, U) { } + + void g(int i, double d) { + f(i, d); + } +} diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index ec9c08c..8f3d356 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -450,7 +450,7 @@ namespace test7 { // CHECK: define weak_odr void @_ZN5test81AILZNS_1B5valueEEE3incEv namespace test8 { template class A { void inc() { counter++; } }; - class B { static int value; }; + class B { public: static int value; }; template class A; } // CHECK: declare void @_ZN5test91fIiNS_3barEEEvRKNT0_3baz1XE @@ -468,3 +468,12 @@ namespace test9 { f( 0); } } + +// +namespace test10 { + template struct S {}; + template void f(struct S ) {} + + // CHECK: define weak_odr void @_ZN6test101fILc3EEEvNS_1SIXquLb0ELc97ET_EEE( + template void f<(char) 3>(struct S<3>); +} diff --git a/test/CodeGenCXX/member-function-pointer-calls.cpp b/test/CodeGenCXX/member-function-pointer-calls.cpp index e1f2eb7..6f0ef81 100644 --- a/test/CodeGenCXX/member-function-pointer-calls.cpp +++ b/test/CodeGenCXX/member-function-pointer-calls.cpp @@ -9,18 +9,17 @@ int f(A* a, int (A::*fp)()) { } // CHECK: define i32 @_Z2g1v() +// CHECK-NEXT: {{.*}}: +// CHECK-NEXT: ret i32 1 int g1() { A a; - - // CHECK: call i32 @_ZN1A3vf1Ev - // CHECK-NEXT: ret i32 return f(&a, &A::vf1); } +// CHECK: define i32 @_Z2g2v() +// CHECK-NEXT: {{.*}}: +// CHECK-NEXT: ret i32 2 int g2() { A a; - - // CHECK: call i32 @_ZN1A3vf2Ev - // CHECK-NEXT: ret i32 return f(&a, &A::vf2); } diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index f7c445b..e4beee1 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s struct A { int a; void f(); virtual void vf1(); virtual void vf2(); }; struct B { int b; virtual void g(); }; @@ -12,10 +13,12 @@ void (C::*pc)(); // CHECK: @pa2 = global %0 { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8 void (A::*pa2)() = &A::f; -// CHECK: @pa3 = global %0 { i64 1, i64 0 }, align 8 +// CHECK: @pa3 = global %0 { i64 1, i64 0 }, align 8 +// CHECK-LP32: @pa3 = global %0 { i32 1, i32 0 }, align 4 void (A::*pa3)() = &A::vf1; -// CHECK: @pa4 = global %0 { i64 9, i64 0 }, align 8 +// CHECK: @pa4 = global %0 { i64 9, i64 0 }, align 8 +// CHECK-LP32: @pa4 = global %0 { i32 5, i32 0 }, align 4 void (A::*pa4)() = &A::vf2; // CHECK: @pc2 = global %0 { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8 @@ -51,16 +54,24 @@ void f2() { // CHECK: store i64 0, i64* [[pa2adj]] void (A::*pa2)() = &A::f; - // CHECK: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 - // CHECK: store i64 1, i64* [[pa3ptr]] - // CHECK: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa3adj]] + // CHECK: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 + // CHECK: store i64 1, i64* [[pa3ptr]] + // CHECK: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 + // CHECK: store i64 0, i64* [[pa3adj]] + // CHECK-LP32: [[pa3ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 0 + // CHECK-LP32: store i32 1, i32* [[pa3ptr]] + // CHECK-LP32: [[pa3adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa3, i32 0, i32 1 + // CHECK-LP32: store i32 0, i32* [[pa3adj]] void (A::*pa3)() = &A::vf1; - // CHECK: [[pa4ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 0 - // CHECK: store i64 9, i64* [[pa4ptr]] - // CHECK: [[pa4adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 1 - // CHECK: store i64 0, i64* [[pa4adj]] + // CHECK: [[pa4ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 0 + // CHECK: store i64 9, i64* [[pa4ptr]] + // CHECK: [[pa4adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 1 + // CHECK: store i64 0, i64* [[pa4adj]] + // CHECK-LP32: [[pa4ptr:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 0 + // CHECK-LP32: store i32 5, i32* [[pa4ptr]] + // CHECK-LP32: [[pa4adj:%[a-zA-Z0-9\.]+]] = getelementptr inbounds %0* %pa4, i32 0, i32 1 + // CHECK-LP32: store i32 0, i32* [[pa4adj]] void (A::*pa4)() = &A::vf2; } @@ -173,3 +184,9 @@ namespace PR6258 { void (A::*pf)(bool) = &A::f; } } + +// PR7027 +namespace PR7027 { + struct X { void test( ); }; + void testX() { &X::test; } +} diff --git a/test/CodeGenCXX/member-initializers.cpp b/test/CodeGenCXX/member-initializers.cpp index 81dcee7..244a164 100644 --- a/test/CodeGenCXX/member-initializers.cpp +++ b/test/CodeGenCXX/member-initializers.cpp @@ -16,7 +16,7 @@ struct B : A { int f() { B b; - // CHECK: call i32 @_ZN1B1fEv + // CHECK: ret i32 2 return b.i; } diff --git a/test/CodeGenCXX/namespace-aliases.cpp b/test/CodeGenCXX/namespace-aliases.cpp index 74b8eba..8624eb7 100644 --- a/test/CodeGenCXX/namespace-aliases.cpp +++ b/test/CodeGenCXX/namespace-aliases.cpp @@ -1,3 +1,9 @@ // RUN: %clang_cc1 -emit-llvm-only %s namespace A { } namespace B = A; + +namespace b {} + +void foo() { + namespace a = b; +} diff --git a/test/CodeGenCXX/new-operator-phi.cpp b/test/CodeGenCXX/new-operator-phi.cpp index 38467ad..49859ac 100644 --- a/test/CodeGenCXX/new-operator-phi.cpp +++ b/test/CodeGenCXX/new-operator-phi.cpp @@ -2,7 +2,7 @@ // PR5454 #include -class X {static void * operator new(size_t size) throw(); X(int); }; +struct X {static void * operator new(size_t size) throw(); X(int); }; int a(), b(); void b(int x) { diff --git a/test/CodeGenCXX/new.cpp b/test/CodeGenCXX/new.cpp index ca7c52f..885158f 100644 --- a/test/CodeGenCXX/new.cpp +++ b/test/CodeGenCXX/new.cpp @@ -90,9 +90,19 @@ A* t10() { return new(1, 2, 3.45, 100) A; } -struct B { }; +struct B { int a; }; void t11() { // CHECK: call noalias i8* @_Znwm // CHECK: call void @llvm.memset.p0i8.i64( B* b = new B(); } + +struct Empty { }; + +// We don't need to initialize an empty class. +void t12() { + // CHECK: define void @_Z3t12v + // CHECK-NOT: br label + // CHECK: ret void + (void)new Empty[10]; +} diff --git a/test/CodeGenCXX/operator-new.cpp b/test/CodeGenCXX/operator-new.cpp index da64fc1..f718fae 100644 --- a/test/CodeGenCXX/operator-new.cpp +++ b/test/CodeGenCXX/operator-new.cpp @@ -6,6 +6,7 @@ class teste { int A; +public: teste() : A(2) {} }; diff --git a/test/CodeGenCXX/reference-in-blocks.cpp b/test/CodeGenCXX/reference-in-blocks.cpp new file mode 100644 index 0000000..c020bab --- /dev/null +++ b/test/CodeGenCXX/reference-in-blocks.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fblocks %s -emit-llvm -o %t + +extern "C" int printf(const char*, ...); + +template class range { +public: +T _i; + range(T i) {_i = i;}; + T get() {return _i;}; +}; + +int main() { + + // works + void (^bl)(range ) = ^(range i){printf("Hello Blocks %d\n", i.get()); }; + + //crashes in godegen? + void (^bl2)(range& ) = ^(range& i){printf("Hello Blocks %d\n", i.get()); }; + return 0; +} + diff --git a/test/CodeGenCXX/rtti-fundamental.cpp b/test/CodeGenCXX/rtti-fundamental.cpp index 473f48d..6826321 100644 --- a/test/CodeGenCXX/rtti-fundamental.cpp +++ b/test/CodeGenCXX/rtti-fundamental.cpp @@ -8,8 +8,10 @@ std::type_info foo() { namespace __cxxabiv1 { struct __fundamental_type_info { - virtual ~__fundamental_type_info() {} + virtual ~__fundamental_type_info(); }; + + __fundamental_type_info::~__fundamental_type_info() { } } // CHECK: @_ZTIv = weak_odr constant diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp index a67d137..750da02 100644 --- a/test/CodeGenCXX/static-init.cpp +++ b/test/CodeGenCXX/static-init.cpp @@ -34,3 +34,14 @@ inline void h2() { void h3() { h2(); } + +// PR6980: this shouldn't crash +namespace test0 { + struct A { A(); }; + __attribute__((noreturn)) int throw_exception(); + + void test() { + throw_exception(); + static A r; + } +} diff --git a/test/CodeGenCXX/static-local-in-local-class.cpp b/test/CodeGenCXX/static-local-in-local-class.cpp new file mode 100644 index 0000000..d9e044c --- /dev/null +++ b/test/CodeGenCXX/static-local-in-local-class.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -emit-llvm -o %t %s +// PR6769 + +struct X { + static void f(); +}; + +void X::f() { + static int *i; + { + struct Y { + static void g() { + i = new int(); + *i = 100; + (*i) = (*i) +1; + } + }; + (void)Y::g(); + } + (void)i; +} diff --git a/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp b/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp index 921113a..41ae084 100644 --- a/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/template-anonymous-union-member-initializer.cpp @@ -4,6 +4,7 @@ class A { union { void *d; }; +public: A() : d(0) { } }; diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp index 416c0a1..4a38575 100644 --- a/test/CodeGenCXX/template-instantiation.cpp +++ b/test/CodeGenCXX/template-instantiation.cpp @@ -40,6 +40,7 @@ namespace test1 { namespace test2 { template class C { + public: virtual ~C(); void zedbar(double) { } diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp index 4aad3c0..eb543cb 100644 --- a/test/CodeGenCXX/temporaries.cpp +++ b/test/CodeGenCXX/temporaries.cpp @@ -301,3 +301,22 @@ namespace PR6648 { zed(foo); } } + +namespace UserConvertToValue { + struct X { + X(int); + X(const X&); + ~X(); + }; + + void f(X); + + // CHECK: void @_ZN18UserConvertToValue1gEv() + void g() { + // CHECK: call void @_ZN18UserConvertToValue1XC1Ei + // CHECK: call void @_ZN18UserConvertToValue1fENS_1XE + // CHECK: call void @_ZN18UserConvertToValue1XD1Ev + // CHECK: ret void + f(1); + } +} diff --git a/test/CodeGenCXX/value-init.cpp b/test/CodeGenCXX/value-init.cpp index 37891bd..35be159 100644 --- a/test/CodeGenCXX/value-init.cpp +++ b/test/CodeGenCXX/value-init.cpp @@ -23,3 +23,29 @@ void test_value_init() { C c = { 17 } ; // CHECK: call void @_ZN1CD1Ev } + +enum enum_type { negative_number = -1, magic_number = 42 }; + +class enum_holder +{ + enum_type m_enum; + +public: + enum_holder() : m_enum(magic_number) { } +}; + +struct enum_holder_and_int +{ + enum_holder e; + int i; +}; + +// CHECK: _Z24test_enum_holder_and_intv() +void test_enum_holder_and_int() { + // CHECK: alloca + // CHECK-NEXT: bitcast + // CHECK-NEXT: call void @llvm.memset + // CHECK-NEXT: call void @_ZN19enum_holder_and_intC1Ev + enum_holder_and_int(); + // CHECK-NEXT: ret void +} diff --git a/test/CodeGenCXX/virt-template-vtable.cpp b/test/CodeGenCXX/virt-template-vtable.cpp index 76a1240..b968f38 100644 --- a/test/CodeGenCXX/virt-template-vtable.cpp +++ b/test/CodeGenCXX/virt-template-vtable.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s template class A { +public: A() {} virtual void a() {} }; diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp deleted file mode 100644 index 874ffb1..0000000 --- a/test/CodeGenCXX/virt.cpp +++ /dev/null @@ -1,696 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -O0 -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s - -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll -// RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s - - -// CHECK-LP64: main: -// CHECK-LP64: movl $1, 12(%rax) -// CHECK-LP64: movl $2, 8(%rax) - -struct B { - virtual void bar1(); - virtual void bar2(); - int b; -}; -void B::bar1() { } -void B::bar2() { } - -// CHECK-LPLL64:@_ZTV1B = constant [4 x i8*] [i8* null, i8* bitcast (%0* @_ZTI1B to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar1Ev to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar2Ev to i8*)] - -struct C { - virtual void bee1(); - virtual void bee2(); -}; -void C::bee1() { } -void C::bee2() { } - -struct D { - virtual void boo(); -}; -void D::boo() { } - -struct D1 { - virtual void bar(); - virtual void bar2(); - virtual void bar3(); - virtual void bar4(); - virtual void bar5(); - void *d1; -}; -void D1::bar() { } - -class F : virtual public D1, virtual public D { -public: - virtual void foo(); - void *f; -}; -void F::foo() { } - -// CHECK-LPLL64:@_ZTV1F = constant [19 x i8*] [i8* null, i8* inttoptr (i64 16 to i8*), i8* null, i8* null, i8* bitcast (%1* @_ZTI1F to i8*), i8* bitcast (void (%class.test14*)* @_ZN1D3booEv to i8*), i8* bitcast (void (%class.F*)* @_ZN1F3fooEv to i8*), i8* null, i8* null, i8* null, i8* null, i8* null, i8* inttoptr (i64 -16 to i8*), i8* bitcast (%1* @_ZTI1F to i8*), i8* bitcast (void (%struct.D1*)* @_ZN2D13barEv to i8*), i8* bitcast (void (%struct.D1*)* @_ZN2D14bar2Ev to i8*), i8* bitcast (void (%struct.D1*)* @_ZN2D14bar3Ev to i8*), i8* bitcast (void (%struct.D1*)* @_ZN2D14bar4Ev to i8*), i8* bitcast (void (%struct.D1*)* @_ZN2D14bar5Ev to i8*)] - - -struct E { - int e; -}; - -static_assert (sizeof (C) == (sizeof(void *)), "vtable pointer layout"); - -class A : public E, public B, public C { -public: - virtual void foo1(); - virtual void foo2(); - A() { } - int a; -} *ap; -void A::foo1() { } -void A::foo2() { } - -// CHECK-LPLL64:@_ZTV1A = constant [10 x i8*] [i8* null, i8* bitcast (%2* @_ZTI1A to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar1Ev to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar2Ev to i8*), i8* bitcast (void (%class.A*)* @_ZN1A4foo1Ev to i8*), i8* bitcast (void (%class.A*)* @_ZN1A4foo2Ev to i8*), i8* inttoptr (i64 -16 to i8*), i8* bitcast (%2* @_ZTI1A to i8*), i8* bitcast (void (%class.test14*)* @_ZN1C4bee1Ev to i8*), i8* bitcast (void (%class.test14*)* @_ZN1C4bee2Ev to i8*)] - -int main() { - A a; - B b; - ap->e = 1; - ap->b = 2; -} - - -struct test12_A { - virtual void foo0() { } - virtual void foo(); -} *test12_pa; - -struct test12_B : public test12_A { - virtual void foo() { } -} *test12_pb; - -struct test12_D : public test12_B { -} *test12_pd; - - -struct test6_B2 { virtual void funcB2(); char b[1000]; }; -struct test6_B1 : virtual test6_B2 { virtual void funcB1(); }; - -struct test6_D : test6_B2, virtual test6_B1 { -}; - -// CHECK-LP64: .zerofill __DATA,__common,_d6,2024,4 - -struct test7_B2 { virtual void funcB2(); }; -struct test7_B1 : virtual test7_B2 { virtual void funcB1(); }; - -struct test7_D : test7_B2, virtual test7_B1 { -}; - -// FIXME: we were checking for an alignment of 3 (?) -// CHECK-LP64: .zerofill __DATA,__common,_d7,16, - - -struct test3_B3 { virtual void funcB3(); }; -struct test3_B2 : virtual test3_B3 { virtual void funcB2(); }; -struct test3_B1 : virtual test3_B2 { virtual void funcB1(); }; - -struct test3_D : virtual test3_B1 { - virtual void funcD() { } -}; - -// CHECK-LPLL64:@_ZTV7test3_D = weak_odr constant [12 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI7test3_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test3_B36funcB3Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test3_B26funcB2Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test3_B16funcB1Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN7test3_D5funcDEv to i8*)] - - -struct test4_D : virtual B, virtual C { -}; - -// CHECK-LPLL64:@_ZTV7test4_D = weak_odr constant [14 x i8*] [i8* null, i8* inttoptr (i64 8 to i8*), i8* null, i8* null, i8* null, i8* bitcast (%1* @_ZTI7test4_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN1C4bee1Ev to i8*), i8* bitcast (void (%class.test14*)* @_ZN1C4bee2Ev to i8*), i8* null, i8* null, i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI7test4_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar1Ev to i8*), i8* bitcast (void (%struct.B*)* @_ZN1B4bar2Ev to i8*)] - - -struct test5_B3 { virtual void funcB3(); }; -struct test5_B2 : virtual test5_B3 { virtual void funcB2(); }; -struct test5_B1 : virtual test5_B2 { virtual void funcB1(); }; - -struct test5_B23 { virtual void funcB23(); }; -struct test5_B22 : virtual test5_B23 { virtual void funcB22(); }; -struct test5_B21 : virtual test5_B22 { virtual void funcB21(); }; - - -struct B232 { virtual void funcB232(); }; -struct B231 { virtual void funcB231(); }; - -struct test5_B33 { virtual void funcB33(); }; -struct test5_B32 : virtual test5_B33, virtual B232 { virtual void funcB32(); }; -struct test5_B31 : virtual test5_B32, virtual B231 { virtual void funcB31(); }; - -struct test5_D : virtual test5_B1, virtual test5_B21, virtual test5_B31 { - virtual void funcD() { } -}; - -// CHECK-LPLL64:@_ZTV7test5_D = weak_odr constant [50 x i8*] [i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 24 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 8 to i8*), i8* inttoptr (i64 8 to i8*), i8* inttoptr (i64 8 to i8*), i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* bitcast (%2* @_ZTI7test5_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test5_B36funcB3Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test5_B26funcB2Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test5_B16funcB1Ev to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN7test5_D5funcDEv to i8*), i8* null, i8* null, i8* null, i8* null, i8* null, i8* inttoptr (i64 -8 to i8*), i8* bitcast (%2* @_ZTI7test5_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test5_B237funcB23Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test5_B227funcB22Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test5_B217funcB21Ev to i8*), i8* null, i8* inttoptr (i64 16 to i8*), i8* null, i8* null, i8* inttoptr (i64 8 to i8*), i8* null, i8* null, i8* inttoptr (i64 -16 to i8*), i8* bitcast (%2* @_ZTI7test5_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test5_B337funcB33Ev to i8*), i8* bitcast (void (%class.test20_D*)* @_ZN9test5_B327funcB32Ev to i8*), i8* bitcast (void (%class.test23_D*)* @_ZN9test5_B317funcB31Ev to i8*), i8* null, i8* inttoptr (i64 -24 to i8*), i8* bitcast (%2* @_ZTI7test5_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN4B2328funcB232Ev to i8*), i8* null, i8* inttoptr (i64 -32 to i8*), i8* bitcast (%2* @_ZTI7test5_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN4B2318funcB231Ev to i8*)] - -struct test8_B1 { - virtual void ftest8_B1() { } -}; -struct test8_B2aa { - virtual void ftest8_B2aa() { } - int i; -}; -struct test8_B2ab { - virtual void ftest8_B2ab() { } - int i; -}; -struct test8_B2a : virtual test8_B2aa, virtual test8_B2ab { - virtual void ftest8_B2a() { } -}; -struct test8_B2b { - virtual void ftest8_B2b() { } -}; -struct test8_B2 : test8_B2a, test8_B2b { - virtual void ftest8_B2() { } -}; -struct test8_B3 { - virtual void ftest8_B3() { } -}; -class test8_D : test8_B1, test8_B2, test8_B3 { -}; - -// CHECK-LPLL64:@_ZTV7test8_D = weak_odr constant [25 x i8*] [i8* inttoptr (i64 48 to i8*), i8* inttoptr (i64 32 to i8*), i8* null, i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test8_B19ftest8_B1Ev to i8*), i8* inttoptr (i64 40 to i8*), i8* inttoptr (i64 24 to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%struct.test10_B2a*)* @_ZN9test8_B2a10ftest8_B2aEv to i8*), i8* bitcast (void (%struct.test15_D*)* @_ZN8test8_B29ftest8_B2Ev to i8*), i8* inttoptr (i64 -16 to i8*), i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test8_B2b10ftest8_B2bEv to i8*), i8* inttoptr (i64 -24 to i8*), i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test8_B39ftest8_B3Ev to i8*), i8* null, i8* inttoptr (i64 -32 to i8*), i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2aa11ftest8_B2aaEv to i8*), i8* null, i8* inttoptr (i64 -48 to i8*), i8* bitcast (%2* @_ZTI7test8_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2ab11ftest8_B2abEv to i8*)] - -// CHECK-LPLL64:@_ZTC7test8_D8_8test8_B2 = internal constant [14 x i8*] [i8* inttoptr (i64 40 to i8*), i8* inttoptr (i64 24 to i8*), i8* null, i8* bitcast (%1* @_ZTI8test8_B2 to i8*), i8* bitcast (void (%struct.test10_B2a*)* @_ZN9test8_B2a10ftest8_B2aEv to i8*), i8* bitcast (void (%struct.test15_D*)* @_ZN8test8_B29ftest8_B2Ev to i8*), i8* null, i8* inttoptr (i64 -24 to i8*), i8* bitcast (%1* @_ZTI8test8_B2 to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2aa11ftest8_B2aaEv to i8*), i8* null, i8* inttoptr (i64 -40 to i8*), i8* bitcast (%1* @_ZTI8test8_B2 to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2ab11ftest8_B2abEv to i8*)] ; <[14 x i8*]*> [#uses=3] - -// CHECK-LPLL64:@_ZTC7test8_D8_9test8_B2a = internal constant [13 x i8*] [i8* inttoptr (i64 40 to i8*), i8* inttoptr (i64 24 to i8*), i8* null, i8* bitcast (%1* @_ZTI9test8_B2a to i8*), i8* bitcast (void (%struct.test10_B2a*)* @_ZN9test8_B2a10ftest8_B2aEv to i8*), i8* null, i8* inttoptr (i64 -24 to i8*), i8* bitcast (%1* @_ZTI9test8_B2a to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2aa11ftest8_B2aaEv to i8*), i8* null, i8* inttoptr (i64 -40 to i8*), i8* bitcast (%1* @_ZTI9test8_B2a to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test8_B2ab11ftest8_B2abEv to i8*)] ; <[13 x i8*]*> [#uses=3] - -// CHECK-LPLL64:@_ZTT7test8_D = weak_odr constant [10 x i8*] [i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTV7test8_D, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTC7test8_D8_8test8_B2, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([13 x i8*]* @_ZTC7test8_D8_9test8_B2a, i64 0, i64 4) to i8*), i8* bitcast (i8** getelementptr inbounds ([13 x i8*]* @_ZTC7test8_D8_9test8_B2a, i64 0, i64 8) to i8*), i8* bitcast (i8** getelementptr inbounds ([13 x i8*]* @_ZTC7test8_D8_9test8_B2a, i64 0, i64 12) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTC7test8_D8_8test8_B2, i64 0, i64 9) to i8*), i8* bitcast (i8** getelementptr inbounds ([14 x i8*]* @_ZTC7test8_D8_8test8_B2, i64 0, i64 13) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTV7test8_D, i64 0, i64 9) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTV7test8_D, i64 0, i64 20) to i8*), i8* bitcast (i8** getelementptr inbounds ([25 x i8*]* @_ZTV7test8_D, i64 0, i64 24) to i8*)] - - -struct test9_B3 { virtual void funcB3(); int i; }; -struct test9_B2 : virtual test9_B3 { virtual void funcB2(); int i; }; -struct test9_B1 : virtual test9_B2 { virtual void funcB1(); int i; }; - -struct test9_B23 { virtual void funcB23(); int i; }; -struct test9_B22 : virtual test9_B23 { virtual void funcB22(); int i; }; -struct test9_B21 : virtual test9_B22 { virtual void funcB21(); int i; }; - - -struct test9_B232 { virtual void funcB232(); int i; }; -struct test9_B231 { virtual void funcB231(); int i; }; - -struct test9_B33 { virtual void funcB33(); int i; }; -struct test9_B32 : virtual test9_B33, virtual test9_B232 { virtual void funcB32(); int i; }; -struct test9_B31 : virtual test9_B32, virtual test9_B231 { virtual void funcB31(); int i; }; - -struct test9_D : virtual test9_B1, virtual test9_B21, virtual test9_B31 { - virtual void funcD() { } -}; - -// CHECK-LPLL64:@_ZTV7test9_D = weak_odr constant [70 x i8*] [i8* inttoptr (i64 168 to i8*), i8* inttoptr (i64 152 to i8*), i8* inttoptr (i64 136 to i8*), i8* inttoptr (i64 120 to i8*), i8* inttoptr (i64 104 to i8*), i8* inttoptr (i64 88 to i8*), i8* inttoptr (i64 72 to i8*), i8* inttoptr (i64 56 to i8*), i8* inttoptr (i64 40 to i8*), i8* inttoptr (i64 24 to i8*), i8* inttoptr (i64 8 to i8*), i8* null, i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test9_D*)* @_ZN7test9_D5funcDEv to i8*), i8* null, i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test9_B1*)* @_ZN8test9_B16funcB1Ev to i8*), i8* null, i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -24 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN8test9_B26funcB2Ev to i8*), i8* null, i8* inttoptr (i64 -40 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN8test9_B36funcB3Ev to i8*), i8* null, i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -56 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test9_B1*)* @_ZN9test9_B217funcB21Ev to i8*), i8* null, i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -72 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN9test9_B227funcB22Ev to i8*), i8* null, i8* inttoptr (i64 -88 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN9test9_B237funcB23Ev to i8*), i8* null, i8* inttoptr (i64 64 to i8*), i8* inttoptr (i64 48 to i8*), i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -104 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test9_B31*)* @_ZN9test9_B317funcB31Ev to i8*), i8* null, i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -120 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.test9_B1*)* @_ZN9test9_B327funcB32Ev to i8*), i8* null, i8* inttoptr (i64 -136 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN9test9_B337funcB33Ev to i8*), i8* null, i8* inttoptr (i64 -152 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test9_B2328funcB232Ev to i8*), i8* null, i8* inttoptr (i64 -168 to i8*), i8* bitcast (%2* @_ZTI7test9_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test9_B2318funcB231Ev to i8*)] ; <[70 x i8*]*> [#uses=12] - - -struct test10_O { int i; }; - -struct test10_B1 : virtual test10_O { - virtual void ftest10_B1() { } -}; - -struct test10_B2aa : virtual test10_O { - int i; -}; -struct test10_B2ab : virtual test10_O { - int i; -}; -struct test10_B2a : virtual test10_B2aa, virtual test10_B2ab,virtual test10_O { - virtual void ftest10_B2a() { } -}; -struct test10_B2b : virtual test10_O { - virtual void ftest10_B2b() { } -}; -struct test10_B2 : test10_B2a { - virtual void ftest10_B2() { } -}; -class test10_D : test10_B1, test10_B2 { - - void ftest10_B2aa() { } -}; - -// CHECK-LPLL64:@_ZTV8test10_D = weak_odr constant [19 x i8*] [i8* inttoptr (i64 40 to i8*), i8* inttoptr (i64 24 to i8*), i8* inttoptr (i64 16 to i8*), i8* null, i8* bitcast (%1* @_ZTI8test10_D to i8*), i8* bitcast (void (%struct.test10_B1*)* @_ZN9test10_B110ftest10_B1Ev to i8*), i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 8 to i8*), i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI8test10_D to i8*), i8* bitcast (void (%struct.test10_B2a*)* @_ZN10test10_B2a11ftest10_B2aEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN9test10_B210ftest10_B2Ev to i8*), i8* inttoptr (i64 -8 to i8*), i8* inttoptr (i64 -24 to i8*), i8* bitcast (%1* @_ZTI8test10_D to i8*), i8* inttoptr (i64 -24 to i8*), i8* inttoptr (i64 -40 to i8*), i8* bitcast (%1* @_ZTI8test10_D to i8*)] ; <[19 x i8*]*> [#uses=4] - - -struct test11_B { - virtual void B1() { } - virtual void D() { } - virtual void B2() { } -}; - -struct test11_D : test11_B { - virtual void D1() { } - virtual void D() { } - virtual void D2() { } -}; - -// CHECK-LPLL64:@_ZTV8test11_D = weak_odr constant [7 x i8*] [i8* null, i8* bitcast (%4* @_ZTI8test11_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test11_B2B1Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test11_D1DEv to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test11_B2B2Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test11_D2D1Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test11_D2D2Ev to i8*)] - - -struct test13_B { - virtual void B1() { } - virtual void D() { } - virtual void Da(); - virtual void Db() { } - virtual void Dc() { } - virtual void B2() { } - int i; -}; - - -struct test13_NV1 { - virtual void fooNV1() { } - virtual void D() { } -}; - - -struct test13_B2 : /* test13_NV1, */ virtual test13_B { - virtual void B2a() { } - virtual void B2() { } - virtual void D() { } - virtual void Da(); - virtual void Dd() { } - virtual void B2b() { } - int i; -}; - - -struct test13_D : test13_NV1, virtual test13_B2 { - virtual void D1() { } - virtual void D() { } - virtual void Db() { } - virtual void Dd() { } - virtual void D2() { } - virtual void fooNV1() { } -}; - -// CHECK-LPLL64:@_ZTV8test13_D = weak_odr constant [39 x i8*] [i8* inttoptr (i64 24 to i8*), i8* inttoptr (i64 8 to i8*), i8* null, i8* bitcast (%1* @_ZTI8test13_D to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D6fooNV1Ev to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D1DEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D2D1Ev to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D2DbEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D2DdEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZN8test13_D2D2Ev to i8*), i8* null, i8* inttoptr (i64 -8 to i8*), i8* null, i8* inttoptr (i64 -8 to i8*), i8* null, i8* null, i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI8test13_D to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN9test13_B23B2aEv to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN9test13_B22B2Ev to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZTv0_n48_N8test13_D1DEv to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN9test13_B22DaEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZTv0_n64_N8test13_D2DdEv to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZN9test13_B23B2bEv to i8*), i8* inttoptr (i64 -16 to i8*), i8* null, i8* inttoptr (i64 -24 to i8*), i8* inttoptr (i64 -16 to i8*), i8* inttoptr (i64 -24 to i8*), i8* null, i8* inttoptr (i64 -24 to i8*), i8* bitcast (%1* @_ZTI8test13_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN8test13_B2B1Ev to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZTv0_n32_N8test13_D1DEv to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZTv0_n40_N9test13_B22DaEv to i8*), i8* bitcast (void (%struct.test10_B2*)* @_ZTv0_n48_N8test13_D2DbEv to i8*), i8* bitcast (void (%struct.B*)* @_ZN8test13_B2DcEv to i8*), i8* bitcast (void (%struct.test13_B2*)* @_ZTv0_n64_N9test13_B22B2Ev to i8*)] - - -class test14 { -public: - virtual void initWithInt(int a); - static test14 *withInt(int a); -}; - -void test14::initWithInt(int a) { } - -test14 *test14::withInt(int a) { - test14 *me = new test14; - me->initWithInt(a); - return me; -} - - -struct test15_B { - virtual test15_B *foo1() { return 0; } - virtual test15_B *foo2() { return 0; } - virtual test15_B *foo3() { return 0; } - int i; -}; - -struct test15_NV1 { - virtual void fooNV1() { } - int i; -}; - -struct test15_B2 : test15_NV1, virtual test15_B { - virtual test15_B2 *foo1() { return 0; } - virtual test15_B2 *foo2() { return 0; } - int i; -}; - -struct test15_D : test15_NV1, virtual test15_B2 { - virtual test15_D *foo1() { return 0; } -}; - -// CHECK-LPLL64:@_ZTV8test15_D = weak_odr constant [23 x i8*] [i8* inttoptr (i64 32 to i8*), i8* inttoptr (i64 16 to i8*), i8* null, i8* bitcast (%1* @_ZTI8test15_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test15_NV16fooNV1Ev to i8*), i8* bitcast (%struct.test15_D* (%struct.test15_D*)* @_ZN8test15_D4foo1Ev to i8*), i8* null, i8* inttoptr (i64 -16 to i8*), i8* null, i8* inttoptr (i64 16 to i8*), i8* inttoptr (i64 -16 to i8*), i8* bitcast (%1* @_ZTI8test15_D to i8*), i8* bitcast (void (%struct.B*)* @_ZN10test15_NV16fooNV1Ev to i8*), i8* bitcast (%struct.test15_D* (%struct.test15_D*)* @_ZTcv0_n40_v0_n24_N8test15_D4foo1Ev to i8*), i8* bitcast (%struct.test15_B2* (%struct.test15_B2*)* @_ZN9test15_B24foo2Ev to i8*), i8* null, i8* inttoptr (i64 -16 to i8*), i8* inttoptr (i64 -32 to i8*), i8* inttoptr (i64 -32 to i8*), i8* bitcast (%1* @_ZTI8test15_D to i8*), i8* bitcast (%struct.test15_D* (%struct.test15_D*)* @_ZTcv0_n24_v0_n32_N8test15_D4foo1Ev to i8*), i8* bitcast (%struct.test15_B2* (%struct.test15_B2*)* @_ZTcv0_n32_v0_n24_N9test15_B24foo2Ev to i8*), i8* bitcast (%struct.B* (%struct.B*)* @_ZN8test15_B4foo3Ev to i8*)] - - -struct test16_NV1 { - virtual void fooNV1() { } -virtual void foo_NV1() { } - int i; -}; - -struct test16_NV2 { - virtual test16_NV2* foo1() { return 0; } -virtual void foo_NV2() { } -virtual void foo_NV2b() { } - int i; -}; - -struct test16_B : public test16_NV1, test16_NV2 { - virtual test16_B *foo1() { return 0; } - virtual test16_B *foo2() { return 0; } - virtual test16_B *foo3() { return 0; } -virtual void foo_B() { } - int i; -}; - -struct test16_B2 : test16_NV1, virtual test16_B { - virtual test16_B2 *foo1() { return 0; } - virtual test16_B2 *foo2() { return 0; } -virtual void foo_B2() { } - int i; -}; - -struct test16_D : test16_NV1, virtual test16_B2 { - virtual void bar() { } - virtual test16_D *foo1() { return 0; } -}; - -// FIXME: -// CHECK-LP64: __ZTV8test16_D: -// CHECK-LP64-NEXT: .quad 32 -// CHECK-LP64-NEXT: .quad 16 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad __ZTI8test16_D -// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev -// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev -// CHECK-LP64-NEXT: .quad __ZN8test16_D3barEv -// CHECK-LP64-NEXT: .quad __ZN8test16_D4foo1Ev -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad -16 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 16 -// CHECK-LP64-NEXT: .quad -16 -// CHECK-LP64-NEXT: .quad __ZTI8test16_D -// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev -// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev -// CHECK-LP64-NEXT: .quad __ZTcv0_n48_v0_n24_N8test16_D4foo1Ev -// CHECK-LP64-NEXT: .quad __ZN9test16_B24foo2Ev -// CHECK-LP64-NEXT: .quad __ZN9test16_B26foo_B2Ev -// CHECK-LP64-NEXT: .quad 16 -// CHECK-LP64-NEXT: .quad 16 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad -16 -// CHECK-LP64-NEXT: .quad -32 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad -32 -// CHECK-LP64-NEXT: .quad __ZTI8test16_D -// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev -// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev -// CHECK-LP64-NEXT: .quad __ZTcv0_n40_v0_n32_N8test16_D4foo1Ev -// CHECK-LP64-NEXT: .quad __ZTcv0_n48_v0_n24_N9test16_B24foo2Ev -// CHECK-LP64-NEXT: .quad __ZN8test16_B4foo3Ev -// CHECK-LP64-NEXT: .quad __ZN8test16_B5foo_BEv -// CHECK-LP64-NEXT: .quad -48 -// CHECK-LP64-NEXT: .quad __ZTI8test16_D -// CHECK-LP64-NEXT: .quad __ZTcvn16_n40_v16_n32_N8test16_D4foo1Ev -// CHECK-LP64-NEXT: .quad __ZN10test16_NV27foo_NV2Ev -// CHECK-LP64-NEXT: .quad __ZN10test16_NV28foo_NV2bEv - - - - -class test17_B1 { - virtual void foo() = 0; - virtual void bar() { } -}; - -class test17_B2 : public test17_B1 { - void foo() { } - virtual void bar() = 0; -}; - -class test17_D : public test17_B2 { - void bar() { } -}; - - -// CHECK-LPLL64:@_ZTV8test17_D = weak_odr constant [4 x i8*] [i8* null, i8* bitcast (%4* @_ZTI8test17_D to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test17_B23fooEv to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN8test17_D3barEv to i8*)] - -// CHECK-LPLL64:@_ZTV9test17_B2 = weak_odr constant [4 x i8*] [i8* null, i8* bitcast (%4* @_ZTI9test17_B2 to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test17_B23fooEv to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*)] - -// CHECK-LPLL64:@_ZTV9test17_B1 = weak_odr constant [4 x i8*] [i8* null, i8* bitcast (%0* @_ZTI9test17_B1 to i8*), i8* bitcast (void ()* @__cxa_pure_virtual to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test17_B13barEv to i8*)] - - -struct test18_NV1 { - virtual void fooNV1() { } -virtual void foo_NV1() { } - int i; -}; - -struct test18_NV2 { - virtual test18_NV2& foo1() { return *this; } -virtual void foo_NV2() { } -virtual void foo_NV2b() { } - int i; -}; - -struct test18_B : public test18_NV1, test18_NV2 { - virtual test18_B& foo1() { return *this; } - virtual test18_B *foo2() { return 0; } - virtual test18_B *foo3() { return 0; } -virtual void foo_B() { } - int i; -}; - -struct test18_B2 : test18_NV1, virtual test18_B { - virtual test18_B2& foo1() { return *this; } - virtual test18_B2 *foo2() { return 0; } -virtual void foo_B2() { } - int i; -}; - -struct test18_D : test18_NV1, virtual test18_B2 { - virtual test18_D& foo1() { return *this; } -}; - - -struct test19_VB1 { }; -struct test19_B1 : public virtual test19_VB1 { - virtual void fB1() { } - virtual void foB1B2() { } - virtual void foB1B3() { } - virtual void foB1B4() { } -}; - -struct test19_VB2 { }; -struct test19_B2: public test19_B1, public virtual test19_VB2 { - virtual void foB1B2() { } - virtual void foB1B3() { } - virtual void foB1B4() { } - - virtual void fB2() { } - virtual void foB2B3() { } - virtual void foB2B4() { } -}; - -struct test19_VB3 { }; -struct test19_B3: virtual public test19_B2, public virtual test19_VB3 { - virtual void foB1B3() { } - virtual void foB1B4() { } - - virtual void foB2B3() { } - virtual void foB2B4() { } - - virtual void fB3() { } - virtual void foB3B4() { } -}; - -struct test19_VB4 { }; -struct test19_B4: public test19_B3, public virtual test19_VB4 { - virtual void foB1B4() { } - - virtual void foB2B4() { } - - virtual void foB3B4() { } - - virtual void fB4() { } -}; - -struct test19_D : virtual test19_B4 { -}; - - -// CHECK-LPLL64:@_ZTV8test19_D = weak_odr constant [28 x i8*] [i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI8test19_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test19_B13fB1Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B26foB1B2Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B36foB1B3Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B46foB1B4Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B23fB2Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B36foB2B3Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B46foB2B4Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B33fB3Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B46foB3B4Ev to i8*), i8* bitcast (void (%class.test17_B2*)* @_ZN9test19_B43fB4Ev to i8*)] - -// FIXME: -// CHECK-LP64: __ZTT8test19_D: -// CHECK-LP64-NEXT: .quad __ZTV8test19_D+144 -// CHECK-LP64-NEXT: .quad __ZTV8test19_D+144 -// CHECK-LP64-NEXT .quad __ZTV8test19_D+144 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B4+136 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B3+104 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B3+104 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B4+136 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B2+88 -// CHECK-LP64-NEXT .quad __ZTC8test19_D0_9test19_B1+24 - -class test20_V { - virtual void foo1(); -}; -class test20_V1 { - virtual void foo2(); -}; -class test20_B : virtual test20_V { -} b; -class test20_B1 : virtual test20_V1 { -}; -class test20_D : public test20_B, public test20_B1 { -}; - -// CHECK-LPLL64:@_ZTV8test20_D = weak_odr constant [11 x i8*] [i8* inttoptr (i64 8 to i8*), i8* null, i8* null, i8* null, i8* bitcast (%1* @_ZTI8test20_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test20_V4foo1Ev to i8*), i8* null, i8* null, i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI8test20_D to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test20_V14foo2Ev to i8*)] - -// CHECK-LPLL64:@_ZTC8test20_D0_8test20_B = internal constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI8test20_B to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test20_V4foo1Ev to i8*)] - -// CHECK-LPLL64:@_ZTC8test20_D8_9test20_B1 = internal constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI9test20_B1 to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test20_V14foo2Ev to i8*)] ; <[5 x i8*]*> [#uses=1] - -// FIXME: -// CHECK-LP64: __ZTT8test20_D: -// CHECK-LP64-NEXT: .quad __ZTV8test20_D+40 -// CHECK-LP64-NEXT: .quad __ZTC8test20_D0_8test20_B+32 -// CHECK-LP64-NEXT: .quad __ZTC8test20_D0_8test20_B+32 -// CHECK-LP64-NEXT: .quad __ZTC8test20_D8_9test20_B1+32 -// CHECK-LP64-NEXT: .quad __ZTC8test20_D8_9test20_B1+32 -// CHECK-LP64-NEXT .quad __ZTV8test20_D+40 -// CHECK-LP64-NEXT .quad __ZTV8test20_D+80 -// CHECK-LP64-NEXT .quad __ZTV8test20_D+80 - - -class test21_V { - virtual void foo() { } -}; -class test21_V1 { - virtual void foo() { } -}; -class test21_B : virtual test21_V { -}; -class test21_B1 : virtual test21_V1 { -}; -class test21_D : public test21_B, public test21_B1 { - void foo() { } -}; - -// CHECK-LPLL64:@_ZTV8test21_D = weak_odr constant [11 x i8*] [i8* inttoptr (i64 8 to i8*), i8* null, i8* null, i8* null, i8* bitcast (%1* @_ZTI8test21_D to i8*), i8* bitcast (void (%class.test20_D*)* @_ZN8test21_D3fooEv to i8*), i8* null, i8* inttoptr (i64 -8 to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%1* @_ZTI8test21_D to i8*), i8* bitcast (void (%class.test20_D*)* @_ZTv0_n24_N8test21_D3fooEv to i8*)] - -// CHECK-LPLL64:@_ZTC8test21_D0_8test21_B = internal constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI8test21_B to i8*), i8* bitcast (void (%class.test14*)* @_ZN8test21_V3fooEv to i8*)] - -// CHECK-LPLL64:@_ZTC8test21_D8_9test21_B1 = internal constant [5 x i8*] [i8* null, i8* null, i8* null, i8* bitcast (%3* @_ZTI9test21_B1 to i8*), i8* bitcast (void (%class.test14*)* @_ZN9test21_V13fooEv to i8*)] ; <[5 x i8*]*> [#uses=1] - -// FIXME: -// CHECK-LP64: __ZTT8test21_D: -// CHECK-LP64-NEXT: .quad __ZTV8test21_D+40 -// CHECK-LP64-NEXT: .quad __ZTC8test21_D0_8test21_B+32 -// CHECK-LP64-NEXT: .quad __ZTC8test21_D0_8test21_B+32 -// CHECK-LP64-NEXT: .quad __ZTC8test21_D8_9test21_B1+32 -// CHECK-LP64-NEXT: .quad __ZTC8test21_D8_9test21_B1+32 -// CHECK-LP64-NEXT .quad __ZTV8test21_D+40 -// CHECK-LP64-NEXT .quad __ZTV8test21_D+80 -// CHECK-LP64-NEXT .quad __ZTV8test21_D+80 - - -struct test22_s1 { virtual void dtor() { } }; -struct test22_s2 { virtual void dtor() { } }; -struct test22_s3 : test22_s1, test22_s2 { virtual void dtor() { } }; -struct test22_D : test22_s3 { virtual void dtor() { } }; - -// CHECK-LPLL64:@_ZTV8test22_D = weak_odr constant [6 x i8*] [i8* null, i8* bitcast (%4* @_ZTI8test22_D to i8*), i8* bitcast (void (%class.test20_D*)* @_ZN8test22_D4dtorEv to i8*), i8* inttoptr (i64 -8 to i8*), i8* bitcast (%4* @_ZTI8test22_D to i8*), i8* bitcast (void (%class.test20_D*)* @_ZThn8_N8test22_D4dtorEv to i8*)] - - -class test23_s1 { - virtual void fun1(char *t) { } -}; -class test23_s2 { - virtual void fun2(char *t) { } -}; -class test23_s3 { - virtual void fun3(char *t) { } -}; -class test23_s4: virtual test23_s1, test23_s2, test23_s3 { - virtual void fun4(char *t) { } -}; -class test23_D: virtual test23_s4 { - virtual void fun5(char *t) { } -}; - - -// FIXME: -// CHECK-LP64: __ZTV8test23_D: -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 8 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64-NEXT: .quad __ZTI8test23_D -// CHECK-LP64-NEXT: .quad __ZN9test23_s14fun1EPc -// CHECK-LP64-NEXT: .quad __ZN8test23_D4fun5EPc -// CHECK-LP64-NEXT .quad 8 -// CHECK-LP64: .quad 0 -// CHECK-LP64-NEXT: .quad 0 -// CHECK-LP64: .quad -8 -// CHECK-LP64-NEXT: .quad -8 -// CHECK-LP64-NEXT: .quad __ZTI8test23_D -// CHECK-LP64-NEXT: .quad __ZN9test23_s24fun2EPc -// CHECK-LP64-NEXT: .quad __ZN9test23_s44fun4EPc -// CHECK-LP64-NEXT: .quad -16 -// CHECK-LP64-NEXT: .quad __ZTI8test23_D -// CHECK-LP64-NEXT: .quad __ZN9test23_s34fun3EPc - - -test23_D d23; -test22_D d22; -test21_D d21; -test20_D d20; -test19_D d19; -test18_D d18; -test17_D d17; -test16_D d16; -test15_D d15; -test13_D d13; -test11_D d11; -test10_D d10; -test9_D d9; -test8_D d8; - -test5_D d5; -test4_D d4; -test3_D d3; - -test6_D d6; -test7_D d7; - - -int j; -void *vp; -void test2() { - F f; - static int sz = (char *)(&f.f) - (char *)(&f); - vp = &sz; - j = sz; - // FIXME: These should result in a frontend constant a la fold, no run time - // initializer - // CHECK-LPLL64: define void @_Z5test2v() - // CHECK-LPLL64: = getelementptr inbounds %class.F* %f, i32 0, i32 1 -} - -static_assert(sizeof(F) == sizeof(void*)*4, "invalid vbase size"); - - -void test12_foo() { - test12_pa->foo0(); - test12_pb->foo0(); - test12_pd->foo0(); - test12_pa->foo(); - test12_pb->foo(); - test12_pd->foo(); - test12_pa->test12_A::foo(); -} - - -// CHECK-LPLL64:define void @_Z10test12_foov() nounwind { -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void % -// CHECK-LPLL64: call void @_ZN8test12_A3fooEv(%class.test14* %{{.*}}) - diff --git a/test/CodeGenCXX/vtable-layout.cpp b/test/CodeGenCXX/vtable-layout.cpp index 3a0dae4..f2f5179 100644 --- a/test/CodeGenCXX/vtable-layout.cpp +++ b/test/CodeGenCXX/vtable-layout.cpp @@ -1303,3 +1303,337 @@ struct B : virtual A { V2 *B::f() { return 0; } } + +namespace Test30 { + +// Test that we don't assert when generating a vtable for F. +struct A { }; + +struct B : virtual A { + int i; +}; + +struct C { + virtual void f(); +}; + +struct D : virtual C, B { }; +struct E : virtual D { }; + +struct F : E { + virtual void f(); +}; +void F::f() { } + +} + +namespace Test31 { + +// Test that we don't add D::f twice to the primary vtable. +struct A { + int a; +}; + +struct B { + virtual void f(); +}; + +struct C : A, virtual B { + virtual void f(); +}; + +// CHECK: Vtable for 'Test31::D' (11 entries). +// CHECK-NEXT: 0 | vbase_offset (0) +// CHECK-NEXT: 1 | vbase_offset (8) +// CHECK-NEXT: 2 | vcall_offset (0) +// CHECK-NEXT: 3 | offset_to_top (0) +// CHECK-NEXT: 4 | Test31::D RTTI +// CHECK-NEXT: -- (Test31::B, 0) vtable address -- +// CHECK-NEXT: -- (Test31::D, 0) vtable address -- +// CHECK-NEXT: 5 | void Test31::D::f() +// CHECK-NEXT: 6 | vbase_offset (-8) +// CHECK-NEXT: 7 | vcall_offset (-8) +// CHECK-NEXT: 8 | offset_to_top (-8) +// CHECK-NEXT: 9 | Test31::D RTTI +// CHECK-NEXT: -- (Test31::C, 8) vtable address -- +// CHECK-NEXT: 10 | void Test31::D::f() +// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset] +struct D : virtual C { + virtual void f(); +}; +void D::f() { } + +} + +namespace Test32 { + +// Check that we correctly lay out the virtual bases of 'Test32::D'. + +struct A { + virtual void f(); +}; + +struct B : virtual A { }; +struct C : A, virtual B { }; +struct D : virtual B { }; + +// CHECK: Virtual base offset offsets for 'Test32::E' (3 entries). +// CHECK-NEXT: Test32::A | -32 +// CHECK-NEXT: Test32::B | -24 +// CHECK-NEXT: Test32::D | -40 +struct E : C, virtual D { + virtual void f(); +}; +void E::f() { } + +} + +namespace Test33 { + +// Test that we don't emit too many vcall offsets in 'Test32::F'. + +struct A { + virtual void a(); +}; + +struct B { + virtual void b(); +}; + +struct C : virtual A, virtual B { + virtual void c(); +}; + +struct D : virtual C { }; + +struct E : A, D { + virtual void e(); +}; + +// CHECK: Vtable for 'Test33::F' (30 entries). +// CHECK-NEXT: 0 | vbase_offset (24) +// CHECK-NEXT: 1 | vbase_offset (16) +// CHECK-NEXT: 2 | vbase_offset (16) +// CHECK-NEXT: 3 | vbase_offset (8) +// CHECK-NEXT: 4 | offset_to_top (0) +// CHECK-NEXT: 5 | Test33::F RTTI +// CHECK-NEXT: -- (Test33::A, 0) vtable address -- +// CHECK-NEXT: -- (Test33::F, 0) vtable address -- +// CHECK-NEXT: 6 | void Test33::A::a() +// CHECK-NEXT: 7 | void Test33::F::f() +// CHECK-NEXT: 8 | vcall_offset (0) +// CHECK-NEXT: 9 | vcall_offset (0) +// CHECK-NEXT: 10 | vbase_offset (16) +// CHECK-NEXT: 11 | vbase_offset (8) +// CHECK-NEXT: 12 | vbase_offset (8) +// CHECK-NEXT: 13 | offset_to_top (-8) +// CHECK-NEXT: 14 | Test33::F RTTI +// CHECK-NEXT: -- (Test33::A, 8) vtable address -- +// CHECK-NEXT: -- (Test33::E, 8) vtable address -- +// CHECK-NEXT: 15 | void Test33::A::a() +// CHECK-NEXT: 16 | void Test33::E::e() +// CHECK-NEXT: 17 | vbase_offset (0) +// CHECK-NEXT: 18 | vcall_offset (0) +// CHECK-NEXT: 19 | vbase_offset (8) +// CHECK-NEXT: 20 | vbase_offset (0) +// CHECK-NEXT: 21 | vcall_offset (0) +// CHECK-NEXT: 22 | offset_to_top (-16) +// CHECK-NEXT: 23 | Test33::F RTTI +// CHECK-NEXT: -- (Test33::A, 16) vtable address -- +// CHECK-NEXT: -- (Test33::C, 16) vtable address -- +// CHECK-NEXT: -- (Test33::D, 16) vtable address -- +// CHECK-NEXT: 24 | void Test33::A::a() +// CHECK-NEXT: 25 | void Test33::C::c() +// CHECK-NEXT: 26 | vcall_offset (0) +// CHECK-NEXT: 27 | offset_to_top (-24) +// CHECK-NEXT: 28 | Test33::F RTTI +// CHECK-NEXT: -- (Test33::B, 24) vtable address -- +// CHECK-NEXT: 29 | void Test33::B::b() +struct F : virtual E, A { + virtual void f(); +}; +void F::f() { } + +} + +namespace Test34 { + +// Test that we lay out the construction vtable for 'Test34::E' in 'Test34::F' correctly. + +struct A { + virtual void a(); +}; +struct B : virtual A { }; + +struct C : B, A { + virtual void c(); +}; + +struct D : A, C { }; + +struct E : virtual D { + virtual void e(); +}; + +// CHECK: Construction vtable for ('Test34::E', 0) in 'Test34::F' (22 entries). +// CHECK-NEXT: 0 | vbase_offset (0) +// CHECK-NEXT: 1 | vbase_offset (8) +// CHECK-NEXT: 2 | vcall_offset (0) +// CHECK-NEXT: 3 | offset_to_top (0) +// CHECK-NEXT: 4 | Test34::E RTTI +// CHECK-NEXT: -- (Test34::A, 0) vtable address -- +// CHECK-NEXT: -- (Test34::E, 0) vtable address -- +// CHECK-NEXT: 5 | void Test34::A::a() +// CHECK-NEXT: 6 | void Test34::E::e() +// CHECK-NEXT: 7 | vcall_offset (8) +// CHECK-NEXT: 8 | vcall_offset (0) +// CHECK-NEXT: 9 | vbase_offset (-8) +// CHECK-NEXT: 10 | offset_to_top (-8) +// CHECK-NEXT: 11 | Test34::E RTTI +// CHECK-NEXT: -- (Test34::A, 8) vtable address -- +// CHECK-NEXT: -- (Test34::D, 8) vtable address -- +// CHECK-NEXT: 12 | void Test34::A::a() +// CHECK-NEXT: 13 | vbase_offset (-16) +// CHECK-NEXT: 14 | vcall_offset (-16) +// CHECK-NEXT: 15 | offset_to_top (-16) +// CHECK-NEXT: 16 | Test34::E RTTI +// CHECK-NEXT: -- (Test34::B, 16) vtable address -- +// CHECK-NEXT: -- (Test34::C, 16) vtable address -- +// CHECK-NEXT: 17 | [unused] void Test34::A::a() +// CHECK-NEXT: 18 | void Test34::C::c() +// CHECK-NEXT: 19 | offset_to_top (-24) +// CHECK-NEXT: 20 | Test34::E RTTI +// CHECK-NEXT: -- (Test34::A, 24) vtable address -- +// CHECK-NEXT: 21 | void Test34::A::a() +struct F : E { + virtual void f(); +}; +void F::f() { } + +} + +namespace Test35 { + +// Test that we lay out the virtual bases of 'Test35::H' in the correct order. + +struct A { + virtual void a(); + + int i; +}; + +struct B : virtual A { + virtual void b(); +}; + +struct C { + virtual void c(); +}; + +struct D : C, virtual B { + virtual void d(); +}; + +struct E : D { + virtual void e(); + + bool b; +}; + +struct F : virtual D { }; +struct G : virtual E { }; + +// CHECK: Vtable for 'Test35::H' (32 entries). +// CHECK-NEXT: 0 | vbase_offset (32) +// CHECK-NEXT: 1 | vbase_offset (0) +// CHECK-NEXT: 2 | vcall_offset (0) +// CHECK-NEXT: 3 | vcall_offset (0) +// CHECK-NEXT: 4 | vbase_offset (16) +// CHECK-NEXT: 5 | vbase_offset (8) +// CHECK-NEXT: 6 | offset_to_top (0) +// CHECK-NEXT: 7 | Test35::H RTTI +// CHECK-NEXT: -- (Test35::C, 0) vtable address -- +// CHECK-NEXT: -- (Test35::D, 0) vtable address -- +// CHECK-NEXT: -- (Test35::F, 0) vtable address -- +// CHECK-NEXT: -- (Test35::H, 0) vtable address -- +// CHECK-NEXT: 8 | void Test35::C::c() +// CHECK-NEXT: 9 | void Test35::D::d() +// CHECK-NEXT: 10 | void Test35::H::h() +// CHECK-NEXT: 11 | vbase_offset (0) +// CHECK-NEXT: 12 | vbase_offset (24) +// CHECK-NEXT: 13 | vcall_offset (0) +// CHECK-NEXT: 14 | vbase_offset (8) +// CHECK-NEXT: 15 | offset_to_top (-8) +// CHECK-NEXT: 16 | Test35::H RTTI +// CHECK-NEXT: -- (Test35::B, 8) vtable address -- +// CHECK-NEXT: -- (Test35::G, 8) vtable address -- +// CHECK-NEXT: 17 | void Test35::B::b() +// CHECK-NEXT: 18 | vcall_offset (0) +// CHECK-NEXT: 19 | offset_to_top (-16) +// CHECK-NEXT: 20 | Test35::H RTTI +// CHECK-NEXT: -- (Test35::A, 16) vtable address -- +// CHECK-NEXT: 21 | void Test35::A::a() +// CHECK-NEXT: 22 | vcall_offset (0) +// CHECK-NEXT: 23 | vcall_offset (0) +// CHECK-NEXT: 24 | vcall_offset (0) +// CHECK-NEXT: 25 | vbase_offset (-16) +// CHECK-NEXT: 26 | vbase_offset (-24) +// CHECK-NEXT: 27 | offset_to_top (-32) +// CHECK-NEXT: 28 | Test35::H RTTI +// CHECK-NEXT: -- (Test35::C, 32) vtable address -- +// CHECK-NEXT: -- (Test35::D, 32) vtable address -- +// CHECK-NEXT: -- (Test35::E, 32) vtable address -- +// CHECK-NEXT: 29 | void Test35::C::c() +// CHECK-NEXT: 30 | void Test35::D::d() +// CHECK-NEXT: 31 | void Test35::E::e() + +// CHECK: Virtual base offset offsets for 'Test35::H' (4 entries). +// CHECK-NEXT: Test35::A | -32 +// CHECK-NEXT: Test35::B | -24 +// CHECK-NEXT: Test35::D | -56 +// CHECK-NEXT: Test35::E | -64 +struct H : F, G { + virtual void h(); +}; +void H::h() { } + +} + +namespace Test36 { + +// Test that we don't mark B::f as unused in the vtable for D. + +struct A { + virtual void f(); +}; + +struct B : virtual A { }; + +struct C : virtual A { + virtual void f(); +}; + +// CHECK: Vtable for 'Test36::D' (12 entries). +// CHECK-NEXT: 0 | vbase_offset (8) +// CHECK-NEXT: 1 | vbase_offset (8) +// CHECK-NEXT: 2 | vcall_offset (0) +// CHECK-NEXT: 3 | offset_to_top (0) +// CHECK-NEXT: 4 | Test36::D RTTI +// CHECK-NEXT: -- (Test36::C, 0) vtable address -- +// CHECK-NEXT: -- (Test36::D, 0) vtable address -- +// CHECK-NEXT: 5 | void Test36::C::f() +// CHECK-NEXT: 6 | void Test36::D::g() +// CHECK-NEXT: 7 | vbase_offset (0) +// CHECK-NEXT: 8 | vcall_offset (-8) +// CHECK-NEXT: 9 | offset_to_top (-8) +// CHECK-NEXT: 10 | Test36::D RTTI +// CHECK-NEXT: -- (Test36::A, 8) vtable address -- +// CHECK-NEXT: -- (Test36::B, 8) vtable address -- +// CHECK-NEXT: 11 | void Test36::C::f() +// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset] +struct D : virtual B, C { + virtual void g(); +}; +void D::g() { } + +} diff --git a/test/CodeGenCXX/x86_32-arguments.cpp b/test/CodeGenCXX/x86_32-arguments.cpp index d13c0e4..f8d6551 100644 --- a/test/CodeGenCXX/x86_32-arguments.cpp +++ b/test/CodeGenCXX/x86_32-arguments.cpp @@ -6,7 +6,7 @@ struct S { int s; }; -// CHECK: define void @_Z1fv(%struct.S* noalias sret % +// CHECK: define void @_Z1fv(%struct.S* sret % S f() { return S(); } // CHECK: define void @_Z1f1S(%struct.S*) void f(S) { } @@ -17,7 +17,7 @@ class C { double c; }; -// CHECK: define void @_Z1gv(%class.C* noalias sret % +// CHECK: define void @_Z1gv(%class.C* sret % C g() { return C(); } // CHECK: define void @_Z1f1C(%class.C*) diff --git a/test/CodeGenObjC/atomic-aggregate-property.m b/test/CodeGenObjC/atomic-aggregate-property.m new file mode 100644 index 0000000..2896d37 --- /dev/null +++ b/test/CodeGenObjC/atomic-aggregate-property.m @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// rdar: // 7849824 + +struct s { + double a, b, c, d; +}; + +struct s1 { + int i; + id j; + id k; +}; + +@interface A +@property (readwrite) double x; +@property (readwrite) struct s y; +@property (nonatomic, readwrite) struct s1 z; +@end + +@implementation A +@synthesize x; +@synthesize y; +@synthesize z; +@end + +// CHECK-LP64: call void @objc_copyStruct +// CHECK-LP64: call void @objc_copyStruct +// CHECK-LP64: call void @objc_copyStruct diff --git a/test/CodeGenObjC/blocks.m b/test/CodeGenObjC/blocks.m index 6dc1410..8ba319e 100644 --- a/test/CodeGenObjC/blocks.m +++ b/test/CodeGenObjC/blocks.m @@ -29,7 +29,7 @@ void foo(T *P) { @interface B : A @end @implementation B -(void) im1 { - ^(void) { [super im0]; }(); + ^(void) { [self im0]; }(); } @end diff --git a/test/CodeGenObjC/encode-cstyle-method.m b/test/CodeGenObjC/encode-cstyle-method.m new file mode 100644 index 0000000..187c9bf --- /dev/null +++ b/test/CodeGenObjC/encode-cstyle-method.m @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// rdar: // 7445205 + +@interface Foo +- (id)test:(id)one, id two; +@end + +@implementation Foo +- (id)test:(id )one, id two {return two; } @end + +// CHECK-LP64: internal global [11 x i8] c"@24@0:8@16 diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m new file mode 100644 index 0000000..a74dee9 --- /dev/null +++ b/test/CodeGenObjC/exceptions.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s +// +// [irgen] [eh] Exception code built with clang (x86_64) crashes + +// Just check that we don't emit any dead blocks. +// +// RUN: grep 'No predecessors' %t | count 0 + +@interface NSArray @end +void f0() { + @try { + @try { + @throw @"a"; + } @catch(NSArray *e) { + } + } @catch (id e) { + } +} diff --git a/test/CodeGenObjC/image-info.m b/test/CodeGenObjC/image-info.m index 8916d00..2777723 100644 --- a/test/CodeGenObjC/image-info.m +++ b/test/CodeGenObjC/image-info.m @@ -1,2 +1,8 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s -// RUN: grep -F '@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__OBJC, __image_info,regular"' %t +// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o %t %s +// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s + +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s + +// CHECK-FRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__OBJC, __image_info,regular" +// CHECK-NONFRAGILE: @"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip" diff --git a/test/CodeGenObjC/metadata-symbols-64.m b/test/CodeGenObjC/metadata-symbols-64.m index 886d53a..dbc06d7 100644 --- a/test/CodeGenObjC/metadata-symbols-64.m +++ b/test/CodeGenObjC/metadata-symbols-64.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-dispatch-method=mixed -emit-llvm -o %t %s // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && // RUN: grep '@"OBJC_CLASS_$_A" = global' %t diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m index dc65382..921168c 100644 --- a/test/CodeGenObjC/metadata_symbols.m +++ b/test/CodeGenObjC/metadata_symbols.m @@ -1,25 +1,40 @@ -// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -o %t %s - -// RUN: grep '@"OBJC_METACLASS_$_A" = global .*section "__DATA, __objc_data", align 8' %t -// RUN: grep '@"OBJC_CLASS_$_A" = global .*section "__DATA, __objc_data", align 8' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH1" = weak global .*section "__DATA,__datacoal_nt,coalesced", align 8' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH2" = external global' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH3" = global .*section "__DATA,__objc_const", align 8' %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s // RUN: grep '@"OBJC_EHTYPE_$_EH3"' %t | count 3 -// RUN: grep '@"\\01L_OBJC_CLASS_NAME_" =.*section "__TEXT,__cstring,cstring_literals", align 1' %t | count 1 -// RUN: grep -F 'define internal void @"\01-[A im0]"' %t -// RUN: grep -F 'define internal void @"\01-[A(Cat) im1]"' %t -// RUN: %clang_cc1 -fobjc-nonfragile-abi -fvisibility hidden -emit-llvm -o %t %s +// CHECK-X86_64: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8 +// CHECK-X86_64: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 8 +// CHECK-X86_64: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__cstring,cstring_literals", align 1 +// CHECK-X86_64: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 8 +// CHECK-X86_64: @"OBJC_EHTYPE_$_EH2" = external global +// CHECK-X86_64: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 8 +// CHECK-X86_64: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 8 +// CHECK-X86_64: define internal void @"\01-[A im0]" +// CHECK-X86_64: define internal void @"\01-[A(Cat) im1]" + +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fvisibility hidden -emit-llvm -o %t %s +// RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s + +// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8 +// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8 +// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH1" = weak hidden global {{.*}}, section "__DATA,__datacoal_nt,coalesced" +// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH2" = external global +// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8 +// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]" +// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]" -// RUN: grep '@"OBJC_METACLASS_$_A" = hidden global .*section "__DATA, __objc_data", align 8' %t -// RUN: grep '@"OBJC_CLASS_$_A" = hidden global .*section "__DATA, __objc_data", align 8' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH1" = weak hidden global .*section "__DATA,__datacoal_nt,coalesced"' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH2" = external global' %t -// RUN: grep '@"OBJC_EHTYPE_$_EH3" = hidden global .*section "__DATA,__objc_const", align 8' %t -// RUN: grep -F 'define internal void @"\01-[A im0]"' %t -// RUN: grep -F 'define internal void @"\01-[A(Cat) im1]"' %t +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s +// CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4 +// CHECK-ARMV6: @"OBJC_METACLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4 +// CHECK-ARMV6: @"\01L_OBJC_CLASS_NAME_" = {{.*}}, section "__TEXT,__cstring,cstring_literals", align 1 +// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, section "__DATA,__datacoal_nt,coalesced", align 4 +// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global +// CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4 +// CHECK-ARMV6: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4 +// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A im0]" +// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A(Cat) im1]" @interface A @end diff --git a/test/CodeGenObjC/next-objc-dispatch.m b/test/CodeGenObjC/next-objc-dispatch.m new file mode 100644 index 0000000..a3e8e19 --- /dev/null +++ b/test/CodeGenObjC/next-objc-dispatch.m @@ -0,0 +1,73 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \ +// RUN: -fobjc-dispatch-method=legacy | \ +// RUN: FileCheck -check-prefix CHECK-FRAGILE_LEGACY %s +// +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \ +// RUN: -fobjc-nonfragile-abi -fobjc-dispatch-method=legacy | \ +// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_LEGACY %s +// +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \ +// RUN: -fobjc-nonfragile-abi -fobjc-dispatch-method=non-legacy | \ +// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_NONLEGACY %s +// +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o - %s \ +// RUN: -fobjc-nonfragile-abi -fobjc-dispatch-method=mixed | \ +// RUN: FileCheck -check-prefix CHECK-NONFRAGILE_MIXED %s +// +// + +// There are basically four ways that we end up doing message dispatch for the +// NeXT runtime. They are: +// (1) fragile ABI, legacy dispatch +// (2) non-fragile ABI, legacy dispatch +// (2) non-fragile ABI, non-legacy dispatch +// (2) non-fragile ABI, mixed dispatch +// +// Note that fragile ABI and non-fragile ABI legacy dispatch are not the same, +// they use some different API calls (objc_msgSendSuper vs objc_msgSendSuper2). + +// CHECK-FRAGILE_LEGACY: ModuleID +// CHECK-FRAGILE_LEGACY-NOT: declare i8* @objc_msgSendSuper2_fixup( +// CHECK-FRAGILE_LEGACY-NOT: declare i8* @objc_msgSend_fixup( +// CHECK-FRAGILE_LEGACY: declare i8* @objc_msgSendSuper( +// CHECK-FRAGILE_LEGACY: declare i8* @objc_msgSend( + +// CHECK-NONFRAGILE_LEGACY: ModuleID +// CHECK-NONFRAGILE_LEGACY-NOT: declare i8* @objc_msgSendSuper2_fixup( +// CHECK-NONFRAGILE_LEGACY-NOT: declare i8* @objc_msgSend_fixup( +// CHECK-NONFRAGILE_LEGACY: declare i8* @objc_msgSendSuper2( +// CHECK-NONFRAGILE_LEGACY: declare i8* @objc_msgSend( + +// CHECK-NONFRAGILE_NONLEGACY: ModuleID +// CHECK-NONFRAGILE_NONLEGACY: declare i8* @objc_msgSendSuper2_fixup( +// CHECK-NONFRAGILE_NONLEGACY: declare i8* @objc_msgSend_fixup( + +// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSendSuper2_fixup( +// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSendSuper2( +// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSend_fixup( +// CHECK-NONFRAGILE_MIXED: declare i8* @objc_msgSend( + +@interface NSObject ++ (id)alloc; +- (id)init; +@end + +@interface I0 : NSObject +-(void) im0; +@end + +@implementation I0 ++(id) alloc { + return [super alloc]; +} +-(id) init { + [super init]; + return self; +} +-(void) im0 {} +@end + +void f0(I0 *a) { + [I0 alloc]; + [a im0]; +} diff --git a/test/CodeGenObjC/non-lazy-classes.m b/test/CodeGenObjC/non-lazy-classes.m index 021db97..512ad89 100644 --- a/test/CodeGenObjC/non-lazy-classes.m +++ b/test/CodeGenObjC/non-lazy-classes.m @@ -1,5 +1,5 @@ // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && -// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o %t %s // RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CLASS_$" = internal global \[1 x .*\] .*@"OBJC_CLASS_$_A".*, section "__DATA, __objc_nlclslist, regular, no_dead_strip", align 8' %t // RUN: grep '@".01L_OBJC_LABEL_NONLAZY_CATEGORY_$" = internal global \[1 x .*\] .*@".01l_OBJC_$_CATEGORY_A_$_Cat".*, section "__DATA, __objc_nlcatlist, regular, no_dead_strip", align 8' %t diff --git a/test/CodeGenObjC/ns-constant-strings.m b/test/CodeGenObjC/ns-constant-strings.m new file mode 100644 index 0000000..3ef5f55 --- /dev/null +++ b/test/CodeGenObjC/ns-constant-strings.m @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fno-constant-cfstrings -emit-llvm -o %t %s +// RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s + +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fno-constant-cfstrings -emit-llvm -o %t %s +// RUN: FileCheck --check-prefix CHECK-NONFRAGILE < %t %s + +@interface NSString @end + +@interface NSSimpleCString : NSString { +@protected + char *bytes; + unsigned int numBytes; +} +@end + +@interface NSConstantString : NSSimpleCString +@end + +#if OBJC_API_VERSION >= 2 +extern Class _NSConstantStringClassReference; +#else +extern struct objc_class _NSConstantStringClassReference; +#endif + +const NSConstantString *appKey = @"MyApp"; + +int main() { + const NSConstantString *appKey = @"MyApp"; + const NSConstantString *appKey1 = @"MyApp1"; +} + +// CHECK-FRAGILE: @_NSConstantStringClassReference = external global +// CHECK-NONFRAGILE: @"OBJC_CLASS_$_NSConstantString" = external global diff --git a/test/CodeGenObjC/objc-gc-aggr-assign.m b/test/CodeGenObjC/objc-gc-aggr-assign.m deleted file mode 100644 index e127242..0000000 --- a/test/CodeGenObjC/objc-gc-aggr-assign.m +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fobjc-gc -emit-llvm -o %t %s -// RUN: grep objc_memmove_collectable %t | grep call | count 3 - -static int count; - -typedef struct S { - int ii; -} SS; - -struct type_s { - SS may_recurse; - id id_val; -}; - -@interface NamedObject -{ - struct type_s type_s_ivar; -} -- (void) setSome : (struct type_s) arg; -- (struct type_s) getSome; -@property(assign) struct type_s aggre_prop; -@end - -@implementation NamedObject -- (void) setSome : (struct type_s) arg - { - type_s_ivar = arg; - } -- (struct type_s) getSome - { - return type_s_ivar; - } -@synthesize aggre_prop = type_s_ivar; -@end - -struct type_s some = {{1234}, (id)0}; - -struct type_s get(void) -{ - return some; -} - -void f(const struct type_s *in, struct type_s *out) { - *out = *in; -} - diff --git a/test/CodeGenObjC/objc2-legacy-dispatch.m b/test/CodeGenObjC/objc2-legacy-dispatch.m index 4c37573..7a99d15 100644 --- a/test/CodeGenObjC/objc2-legacy-dispatch.m +++ b/test/CodeGenObjC/objc2-legacy-dispatch.m @@ -1,11 +1,11 @@ -// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_NEW_DISPATCH %s +// RUN: %clang_cc1 -fobjc-nonfragile-abi -fobjc-dispatch-method=mixed -triple i386-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_NEW_DISPATCH %s // // CHECK_NEW_DISPATCH: define void @f0 // CHECK_NEW_DISPATCH: bitcast {{.*}}objc_msgSend_fixup_alloc // CHECK_NEW_DISPATCH: define void @f1 // CHECK_NEW_DISPATCH: load {{.*}}OBJC_SELECTOR_REFERENCES // -// RUN: %clang_cc1 -fobjc-nonfragile-abi -fobjc-legacy-dispatch -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_OLD_DISPATCH %s +// RUN: %clang_cc1 -fobjc-nonfragile-abi -fobjc-dispatch-method=legacy -emit-llvm -o - %s | FileCheck -check-prefix=CHECK_OLD_DISPATCH %s // // CHECK_OLD_DISPATCH: define void @f0 // CHECK_OLD_DISPATCH: load {{.*}}OBJC_SELECTOR_REFERENCES diff --git a/test/CodeGenObjC/x86_64-struct-return-gc.m b/test/CodeGenObjC/x86_64-struct-return-gc.m index 32a321c..c62a33f 100644 --- a/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -25,7 +25,7 @@ struct Indirect indirect_func(void); void Indirect_test(void) { struct Indirect i; - // CHECK: call void @indirect_func(%struct.Indirect* noalias sret + // CHECK: call void @indirect_func(%struct.Indirect* sret // CHECK: call i8* @objc_memmove_collectable( i = indirect_func(); } diff --git a/test/CodeGenObjCXX/ivar-objects.mm b/test/CodeGenObjCXX/ivar-objects.mm new file mode 100644 index 0000000..79c1a39 --- /dev/null +++ b/test/CodeGenObjCXX/ivar-objects.mm @@ -0,0 +1,71 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// CHECK: -[A .cxx_construct] +// CHECK: -[A .cxx_destruct] + +@interface NSObject +- alloc; +- init; +- (void) release; +@end + +extern "C" int printf(const char *, ...); + +int count = 17; +struct X { + X() : value(count++) { printf( "X::X()\n"); } + ~X() { printf( "X::~X()\n"); } + int value; +}; + +struct Y { + Y() : value(count++) { printf( "Y::Y()\n"); } + ~Y() { printf( "Y::~Y()\n"); } + int value; +}; + +@interface Super : NSObject { + Y yvar; + Y yvar1; + Y ya[3]; +} +- (void)finalize; +@end + +@interface A : Super { + X xvar; + X xvar1; + X xvar2; + X xa[2][2]; +} + +- (void)print; +- (void)finalize; +@end + +@implementation Super +- (void)print { + printf( "yvar.value = %d\n", yvar.value); + printf( "yvar1.value = %d\n", yvar1.value); + printf( "ya[0..2] = %d %d %d\n", ya[0].value, ya[1].value, ya[2].value); +} +- (void)finalize {} +@end + +@implementation A +- (void)print { + printf( "xvar.value = %d\n", xvar.value); + printf( "xvar1.value = %d\n", xvar1.value); + printf( "xvar2.value = %d\n", xvar2.value); + printf( "xa[0..1][0..1] = %d %d %d %d\n", + xa[0][0].value, xa[0][1].value, xa[1][0].value, xa[1][1].value); + [super print]; +} +- (void)finalize { [super finalize]; } +@end + +int main() { + A *a = [[A alloc] init]; + [a print]; + [a release]; +} + diff --git a/test/CodeGenObjCXX/mangle.mm b/test/CodeGenObjCXX/mangle.mm index d277c4e..7a75a5b 100644 --- a/test/CodeGenObjCXX/mangle.mm +++ b/test/CodeGenObjCXX/mangle.mm @@ -2,6 +2,7 @@ // CHECK: @"_ZZ11+[A shared]E1a" = internal global // CHECK: @"_ZZ11-[A(Foo) f]E1a" = internal global +// CHECK: v56@0:8i16i20i24i28i32i36i40i44^i48 @interface A @end @@ -30,3 +31,14 @@ return 0; } @end + +// PR6468 +@interface Test +- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i; +@end + +@implementation Test +- (void) process: (int)r3 :(int)r4 :(int)r5 :(int)r6 :(int)r7 :(int)r8 :(int)r9 :(int)r10 :(int &)i { +} +@end + diff --git a/test/Coverage/ast-printing.cpp b/test/Coverage/ast-printing.cpp index ce0a569..1a75fb4 100644 --- a/test/Coverage/ast-printing.cpp +++ b/test/Coverage/ast-printing.cpp @@ -3,6 +3,6 @@ // RUN: %clang_cc1 -ast-dump %s // FIXME: %clang_cc1 -ast-print-xml -o %t %s // RUN: %clang_cc1 -print-decl-contexts %s -// RUN: %clang_cc1 -dump-record-layouts %s +// RUN: %clang_cc1 -fdump-record-layouts %s #include "cxx-language-features.inc" diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 9ae81f1..76ddaa8 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -33,7 +33,7 @@ // Note that at conception, this exactly matches gcc. // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO -l FOO 2> %t.log -// RUN: grep '".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1/../../../i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1/../../.." "-filelist" "FOO" "-lFOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log +// RUN: grep '".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp".* "-filelist" "FOO" "-lFOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log // Don't run dsymutil on a fat build of an executable. // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log diff --git a/test/Driver/darwin-objc-defaults.m b/test/Driver/darwin-objc-defaults.m new file mode 100644 index 0000000..4cf83a1 --- /dev/null +++ b/test/Driver/darwin-objc-defaults.m @@ -0,0 +1,88 @@ +// Check non-fragile ABI and dispatch method defaults. + +// i386 + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -mmacosx-version-min=10.5 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_OSX10_5 < %t %s + +// CHECK-CHECK-I386_OSX10_5: "-cc1" +// CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-nonfragile-abi +// CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_OSX10_5: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -mmacosx-version-min=10.6 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_OSX10_6 < %t %s + +// CHECK-CHECK-I386_OSX10_6: "-cc1" +// CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-nonfragile-abi +// CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_OSX10_6: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -miphoneos-version-min=3.0 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_IPHONE3_0 < %t %s + +// CHECK-CHECK-I386_IPHONE3_0: "-cc1" +// CHECK-CHECK-I386_IPHONE3_0-NOT: -fobjc-nonfragile-abi +// CHECK-CHECK-I386_IPHONE3_0-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_IPHONE3_0: darwin-objc-defaults + +// x86_64 + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch x86_64 -mmacosx-version-min=10.5 2> %t +// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_5 < %t %s + +// CHECK-CHECK-X86_64_OSX10_5: "-cc1" +// CHECK-CHECK-X86_64_OSX10_5: -fobjc-nonfragile-abi +// CHECK-CHECK-X86_64_OSX10_5: -fobjc-dispatch-method=non-legacy +// CHECK-CHECK-X86_64_OSX10_5: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch x86_64 -mmacosx-version-min=10.6 2> %t +// RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_6 < %t %s + +// CHECK-CHECK-X86_64_OSX10_6: "-cc1" +// CHECK-CHECK-X86_64_OSX10_6: -fobjc-nonfragile-abi +// CHECK-CHECK-X86_64_OSX10_6: -fobjc-dispatch-method=mixed +// CHECK-CHECK-X86_64_OSX10_6: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch x86_64 -miphoneos-version-min=3.0 2> %t +// RUN: FileCheck --check-prefix CHECK-X86_64_IPHONE3_0 < %t %s + +// CHECK-CHECK-X86_64_IPHONE3_0: "-cc1" +// CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-nonfragile-abi +// CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-dispatch-method=mixed +// CHECK-CHECK-X86_64_IPHONE3_0: darwin-objc-defaults + +// armv7 + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch armv7 -mmacosx-version-min=10.5 2> %t +// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_5 < %t %s + +// CHECK-CHECK-ARMV7_OSX10_5: "-cc1" +// CHECK-CHECK-ARMV7_OSX10_5: -fobjc-nonfragile-abi +// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-dispatch-method +// CHECK-CHECK-ARMV7_OSX10_5: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch armv7 -mmacosx-version-min=10.6 2> %t +// RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_6 < %t %s + +// CHECK-CHECK-ARMV7_OSX10_6: "-cc1" +// CHECK-CHECK-ARMV7_OSX10_6: -fobjc-nonfragile-abi +// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-dispatch-method +// CHECK-CHECK-ARMV7_OSX10_6: darwin-objc-defaults + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch armv7 -miphoneos-version-min=3.0 2> %t +// RUN: FileCheck --check-prefix CHECK-ARMV7_IPHONE3_0 < %t %s + +// CHECK-CHECK-ARMV7_IPHONE3_0: "-cc1" +// CHECK-CHECK-ARMV7_IPHONE3_0: -fobjc-nonfragile-abi +// CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-dispatch-method +// CHECK-CHECK-ARMV7_IPHONE3_0: darwin-objc-defaults diff --git a/test/Driver/darwin-objc-gc.m b/test/Driver/darwin-objc-gc.m new file mode 100644 index 0000000..aecb9a6 --- /dev/null +++ b/test/Driver/darwin-objc-gc.m @@ -0,0 +1,19 @@ +// Check that we warn, but accept, -fobjc-gc for iPhone OS. + +// RUN: %clang -ccc-host-triple i386-apple-darwin9 -miphoneos-version-min=3.0 -fobjc-gc -flto -S -o %t %s 2> %t.err +// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_LL %s < %t +// RUN: FileCheck --check-prefix=IPHONE_OBJC_GC_STDERR %s < %t.err + +// IPHONE_OBJC_GC_LL: define void @f0 +// IPHONE_OBJC_GC_LL-NOT: objc_assign_ivar +// IPHONE_OBJC_GC_LL: } + +// IPHONE_OBJC_GC_STDERR: warning: Objective-C garbage collection is not supported on this platform, ignoring '-fobjc-gc' + +@interface A { +@public + id x; +} +@end + +void f0(A *a, id x) { a->x = x; } diff --git a/test/Driver/darwin-objc-options.m b/test/Driver/darwin-objc-options.m new file mode 100644 index 0000000..bc0b12c --- /dev/null +++ b/test/Driver/darwin-objc-options.m @@ -0,0 +1,19 @@ +// Check miscellaneous Objective-C options. + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch x86_64 -fobjc-abi-version=1 2> %t +// RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s + +// CHECK-CHECK-X86_64_ABI1: "-cc1" +// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-nonfragile-abi +// CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method +// CHECK-CHECK-X86_64_ABI1: darwin-objc-options + +// RUN: %clang -ccc-host-triple x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -fobjc-abi-version=2 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s + +// CHECK-CHECK-I386_ABI2: "-cc1" +// CHECK-CHECK-I386_ABI2: -fobjc-nonfragile-abi +// CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_ABI2: darwin-objc-options diff --git a/test/FixIt/fixit-at.c b/test/FixIt/fixit-at.c deleted file mode 100644 index c32aee9..0000000 --- a/test/FixIt/fixit-at.c +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %clang_cc1 -fixit-at=fixit-at.c:3:1 %s -o - | %clang_cc1 -verify -x c - - -_Complex cd; - -int i0[1] = { { 17 } }; // expected-warning{{braces}} diff --git a/test/FixIt/fixit-c90.c b/test/FixIt/fixit-c90.c index e84733f..0bc1fad 100644 --- a/test/FixIt/fixit-c90.c +++ b/test/FixIt/fixit-c90.c @@ -1,4 +1,10 @@ -/* RUN: %clang_cc1 -std=c90 -pedantic -fixit %s -o - | %clang_cc1 -pedantic -x c -std=c90 -Werror - +/* RUN: cp %s %t + RUN: %clang_cc1 -std=c90 -pedantic -fixit %t + RUN: %clang_cc1 -pedantic -x c -std=c90 -Werror %t + */ +/* XPASS: * + This test passes because clang merely warns for this syntax error even with + -pedantic -Werror -std=c90. */ /* This is a test of the various code modification hints that are diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index 3694b9d..d8a858d 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -1,13 +1,15 @@ -/* RUN: %clang_cc1 -std=c++0x -fixit %s -o - | %clang_cc1 -x c++ -std=c++0x - - */ +// RUN: %clang_cc1 -verify -std=c++0x %s +// RUN: cp %s %t +// RUN: %clang_cc1 -std=c++0x -fixit %t || true +// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++0x %t /* This is a test of the various code modification hints that only apply in C++0x. */ -struct A { +struct A { explicit operator int(); // expected-note{{conversion to integral type}} }; -void x() { +void x() { switch(A()) { // expected-error{{explicit conversion to}} } } diff --git a/test/FixIt/fixit-errors-1.c b/test/FixIt/fixit-errors-1.c index ecad53c..96f27eb 100644 --- a/test/FixIt/fixit-errors-1.c +++ b/test/FixIt/fixit-errors-1.c @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -pedantic -fixit %s -o - | %clang_cc1 -pedantic -Werror -x c - +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -fixit %t +// RUN: echo %clang_cc1 -pedantic -Werror -x c %t +/* XPASS: * */ /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the diff --git a/test/FixIt/fixit-errors.c b/test/FixIt/fixit-errors.c index 7bf9a58..ff06363 100644 --- a/test/FixIt/fixit-errors.c +++ b/test/FixIt/fixit-errors.c @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -pedantic -fixit %s -o - | %clang_cc1 -pedantic -Werror -x c - +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -verify -fixit -x c %t || true +// RUN: %clang_cc1 -pedantic -Werror -x c %t +// XFAIL: * /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the diff --git a/test/FixIt/fixit-objc.m b/test/FixIt/fixit-objc.m index 665ac74..03f28a1 100644 --- a/test/FixIt/fixit-objc.m +++ b/test/FixIt/fixit-objc.m @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -pedantic -fixit %s -o %t -// RUN: %clang_cc1 -pedantic -x objective-c %t -verify +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -fixit -x objective-c %t +// RUN: %clang_cc1 -pedantic -verify -x objective-c %t /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the @@ -27,7 +28,7 @@ void h(id a); void f(Test *t) { NSString *a = "Foo"; id b = "Foo"; - A* c = "Foo"; // expected-warning {{incompatible pointer types initializing 'char [4]', expected 'A *'}} + A* c = "Foo"; // expected-warning {{incompatible pointer types initializing 'A *' with an expression of type 'char [4]'}} g("Foo"); h("Foo"); h(("Foo")); diff --git a/test/FixIt/fixit-pmem.cpp b/test/FixIt/fixit-pmem.cpp index 0926309..b69eadf 100644 --- a/test/FixIt/fixit-pmem.cpp +++ b/test/FixIt/fixit-pmem.cpp @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -pedantic -fixit %s -o - | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ - +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -fixit -x c++ %t +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t +// XFAIL: * /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the diff --git a/test/FixIt/fixit-suffix.c b/test/FixIt/fixit-suffix.c new file mode 100644 index 0000000..a1a747a --- /dev/null +++ b/test/FixIt/fixit-suffix.c @@ -0,0 +1,5 @@ +// RUN: cp %s %t.extrasuffix +// RUN: %clang_cc1 -fixit=fixed -x c %t.extrasuffix +// RUN: %clang_cc1 -Werror -pedantic -x c %t.fixed.extrasuffix + +_Complex cd; diff --git a/test/FixIt/fixit-unrecoverable.c b/test/FixIt/fixit-unrecoverable.c new file mode 100644 index 0000000..8052beb --- /dev/null +++ b/test/FixIt/fixit-unrecoverable.c @@ -0,0 +1,10 @@ +/* FIXME: This is a file containing various typos for which we can + suggest corrections but are unable to actually recover from + them. Ideally, we would eliminate all such cases and move these + tests elsewhere. */ + +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// FIXME: Sadly, the following doesn't work within a function. + +unsinged x = 17; // expected-error{{unknown type name 'unsinged'; did you mean 'unsigned'?}} diff --git a/test/FixIt/fixit-unrecoverable.cpp b/test/FixIt/fixit-unrecoverable.cpp new file mode 100644 index 0000000..00ed897 --- /dev/null +++ b/test/FixIt/fixit-unrecoverable.cpp @@ -0,0 +1,11 @@ +/* FIXME: This is a file containing various typos for which we can + suggest corrections but are unable to actually recover from + them. Ideally, we would eliminate all such cases and move these + tests elsewhere. */ + +// RUN: %clang_cc1 -fsyntax-only -verify %s + +float f(int y) { + return static_cst(y); // expected-error{{use of undeclared identifier 'static_cst'; did you mean 'static_cast'?}} +} + diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 83d724d..b799fa3 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -pedantic -fixit %s -o - | grep -v 'CHECK' > %t -// RUN: %clang_cc1 -pedantic -Werror -x c - -// RUN: FileCheck -input-file=%t %s +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -fixit -x c %t || true +// RUN: grep -v CHECK %t > %t2 +// RUN: %clang_cc1 -pedantic -Werror -x c %t +// RUN: FileCheck -input-file=%t2 %t /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the @@ -25,15 +27,14 @@ struct s s0 = { y: 5 }; // CHECK: int array0[5] = { [3] = 3 }; int array0[5] = { [3] 3 }; -void f1(x, y) +void f1(x, y) { } int i0 = { 17 }; -int f2(const char *my_string) { - // FIXME: terminal output isn't so good when "my_string" is shorter -// CHECK: return strcmp(my_string , "foo") == 0; - return my_string == "foo"; +int test_cond(int y, int fooBar) { +// CHECK: int x = y ? 1 : 4+fooBar; + int x = y ? 1 4+foobar; + return x; } - diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index 79c294b..b9282c4 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -1,11 +1,13 @@ -// RUN: %clang_cc1 -pedantic -Wall -fixit %s -o - | %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ - +// RUN: cp %s %t +// RUN: %clang_cc1 -pedantic -Wall -fixit -x c++ %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror -x c++ %t /* This is a test of the various code modification hints that are provided as part of warning or extension diagnostics. All of the warnings will be fixed by -fixit, and the resulting file should compile cleanly with -Werror -pedantic. */ -struct C1 { +struct C1 { virtual void f(); static void g(); }; @@ -40,3 +42,12 @@ class B : public A { void f() throw(); void f(); // expected-warning{{missing exception specification}} + +namespace rdar7853795 { + struct A { + bool getNumComponents() const; // expected-note{{declared here}} + void dump() const { + getNumComponenets(); // expected-error{{use of undeclared identifier 'getNumComponenets'; did you mean 'getNumComponents'?}} + } + }; +} diff --git a/test/FixIt/typo.c b/test/FixIt/typo.c index 72e3d65..01ff3a0 100644 --- a/test/FixIt/typo.c +++ b/test/FixIt/typo.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c - +// RUN: cp %s %t +// RUN: %clang_cc1 -fsyntax-only -fixit -x c %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c %t struct Point { float x, y; }; diff --git a/test/FixIt/typo.cpp b/test/FixIt/typo.cpp index efc9ba8..5b9e68b 100644 --- a/test/FixIt/typo.cpp +++ b/test/FixIt/typo.cpp @@ -1,7 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ - +// RUN: cp %s %t +// RUN: %clang_cc1 -fsyntax-only -fixit -x c++ %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x c++ %t namespace std { template class basic_string { // expected-note 2{{'basic_string' declared here}} + public: int find(const char *substr); // expected-note{{'find' declared here}} static const int npos = -1; // expected-note{{'npos' declared here}} }; diff --git a/test/FixIt/typo.m b/test/FixIt/typo.m index 86dd383..f161bb8 100644 --- a/test/FixIt/typo.m +++ b/test/FixIt/typo.m @@ -1,8 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// FIXME: the test below isn't testing quite what we want... -// RUN: %clang_cc1 -fsyntax-only -fixit -o - %s | %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c - +// RUN: cp %s %t +// RUN: %clang_cc1 -fsyntax-only -fixit %t || true +// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t +// XFAIL: * -@interface NSString +@interface NSString // expected-note{{'NSString' declared here}} + (int)method:(int)x; @end @@ -57,8 +59,7 @@ void test() { @end void test_message_send(B* b) { - // FIXME: Not providing fix-its - [NSstring method:17]; // expected-error{{use of undeclared identifier 'NSstring'; did you mean 'NSString'?}} + [NSstring method:17]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}} } @interface Collide // expected-note{{'Collide' declared here}} @@ -88,3 +89,52 @@ void test2(Collide *a) { @interface IPv6 // expected-error{{cannot find protocol declaration for 'Network_Socket'; did you mean 'NetworkSocket'?}} @end + +@interface Super +- (int)method; +@end + +@interface Sub : Super +- (int)method; +@end + +@implementation Sub +- (int)method { + return [supper method]; // expected-error{{unknown receiver 'supper'; did you mean 'super'?}} +} + +@end + +@interface Ivar +@end + +@protocol Proto +@property (retain) id ivar; +@end + +@interface User +- (void)method; +@end + +@implementation User +@synthesize ivar; + +- (void)method { + [ivar method]; // Test that we don't correct 'ivar' to 'Ivar' +} +@end + +@interface User2 +@end + +@interface User2 (Cat) < Proto> +- (void)method; +@end + +@implementation User2 (Cat) +@synthesize ivar; + +- (void)method { + [ivar method]; // Test that we don't correct 'ivar' to 'Ivar' +} +@end diff --git a/test/Index/Inputs/complete-pch.h b/test/Index/Inputs/complete-pch.h new file mode 100644 index 0000000..ddf5253 --- /dev/null +++ b/test/Index/Inputs/complete-pch.h @@ -0,0 +1,10 @@ +@interface A +- (int)instanceMethod1:(int)x; ++ (int)classMethod1:(double)d; +@end + +@interface B +- (int)instanceMethod2:(int)x; ++ (int)classMethod2:(float)f; +@end + diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m index 1badeb2..ce399d3 100644 --- a/test/Index/annotate-tokens.m +++ b/test/Index/annotate-tokens.m @@ -5,10 +5,11 @@ @implementation Foo - (int)compare:(Foo*)other { return 0; + (void)@encode(Foo); } @end -// RUN: c-index-test -test-annotate-tokens=%s:1:1:9:5 %s | FileCheck %s +// RUN: c-index-test -test-annotate-tokens=%s:1:1:10:5 %s | FileCheck %s // CHECK: Punctuation: "@" [1:1 - 1:2] // CHECK: Identifier: "interface" [1:2 - 1:11] // CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12 @@ -44,6 +45,15 @@ // CHECK: Keyword: "return" [7:3 - 7:9] // CHECK: Literal: "0" [7:10 - 7:11] // CHECK: Punctuation: ";" [7:11 - 7:12] -// CHECK: Punctuation: "}" [8:1 - 8:2] -// CHECK: Punctuation: "@" [9:1 - 9:2] -// CHECK: Identifier: "end" [9:2 - 9:5] +// CHECK: Punctuation: "(" [8:3 - 8:4] +// CHECK: Keyword: "void" [8:4 - 8:8] +// CHECK: Punctuation: ")" [8:8 - 8:9] +// CHECK: Punctuation: "@" [8:9 - 8:10] +// CHECK: Identifier: "encode" [8:10 - 8:16] +// CHECK: Punctuation: "(" [8:16 - 8:17] +// CHECK: Identifier: "Foo" [8:17 - 8:20] ObjCClassRef=Foo:1:12 +// CHECK: Punctuation: ")" [8:20 - 8:21] +// CHECK: Punctuation: ";" [8:21 - 8:22] +// CHECK: Punctuation: "}" [9:1 - 9:2] +// CHECK: Punctuation: "@" [10:1 - 10:2] +// CHECK: Identifier: "end" [10:2 - 10:5] diff --git a/test/Index/complete-at-directives.m b/test/Index/complete-at-directives.m index 1d0a471..811bca0 100644 --- a/test/Index/complete-at-directives.m +++ b/test/Index/complete-at-directives.m @@ -6,7 +6,7 @@ @end // RUN: c-index-test -code-completion-at=%s:2:2 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: {TypedText class}{HorizontalSpace }{Placeholder identifier}{SemiColon ;} +// CHECK-CC1: {TypedText class}{HorizontalSpace }{Placeholder identifier} // CHECK-CC1: {TypedText compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class} // CHECK-CC1: {TypedText implementation}{HorizontalSpace }{Placeholder class} // CHECK-CC1: {TypedText interface}{HorizontalSpace }{Placeholder class} @@ -24,7 +24,7 @@ // CHECK-CC3: {TypedText synthesize}{HorizontalSpace }{Placeholder property} // RUN: c-index-test -code-completion-at=%s:2:1 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{TypedText @class}{HorizontalSpace }{Placeholder identifier}{SemiColon ;} +// CHECK-CC4: NotImplemented:{TypedText @class}{HorizontalSpace }{Placeholder identifier} // CHECK-CC4: NotImplemented:{TypedText @compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class} // CHECK-CC4: NotImplemented:{TypedText @implementation}{HorizontalSpace }{Placeholder class} // CHECK-CC4: NotImplemented:{TypedText @interface}{HorizontalSpace }{Placeholder class} diff --git a/test/Index/complete-at-exprstmt.m b/test/Index/complete-at-exprstmt.m index e8efc3c..87e554f 100644 --- a/test/Index/complete-at-exprstmt.m +++ b/test/Index/complete-at-exprstmt.m @@ -14,7 +14,7 @@ // CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} // CHECK-CC1: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )} // CHECK-CC1: {TypedText synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }} -// CHECK-CC1: {TypedText throw}{HorizontalSpace }{Placeholder expression}{SemiColon ;} +// CHECK-CC1: {TypedText throw}{HorizontalSpace }{Placeholder expression} // CHECK-CC1: {TypedText try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }} // RUN: c-index-test -code-completion-at=%s:9:19 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )} @@ -25,7 +25,7 @@ // CHECK-CC3: NotImplemented:{TypedText @protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} // CHECK-CC3: NotImplemented:{TypedText @selector}{LeftParen (}{Placeholder selector}{RightParen )} // CHECK-CC3: NotImplemented:{TypedText @synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }} -// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression}{SemiColon ;} +// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression} // CHECK-CC3: NotImplemented:{TypedText @try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }} // CHECK-CC3: NotImplemented:{ResultType SEL}{TypedText _cmd} // CHECK-CC3: ParmDecl:{ResultType int}{TypedText arg} diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c new file mode 100644 index 0000000..efc82f9 --- /dev/null +++ b/test/Index/complete-exprs.c @@ -0,0 +1,15 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +int f(int); + +int test(int i, int j, int k, int l) { + return i | j | k & l; +} + +// RUN: c-index-test -code-completion-at=%s:7:9 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} +// CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} +// RUN: c-index-test -code-completion-at=%s:7:14 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: c-index-test -code-completion-at=%s:7:18 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: c-index-test -code-completion-at=%s:7:22 %s | FileCheck -check-prefix=CHECK-CC1 %s diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m new file mode 100644 index 0000000..c18994e --- /dev/null +++ b/test/Index/complete-method-decls.m @@ -0,0 +1,82 @@ +/* Note: the RUN lines are near the end of the file, since line/column + matter for this test. */ + +@protocol P1 +- (id)abc; +- (id)initWithInt:(int)x; +- (id)initWithTwoInts:(int)x second:(int)y; +- (int)getInt; +- (id)getSelf; +@end + +@protocol P2 ++ (id)alloc; +@end + +@interface A +- (id)init; +- (int)getValue; +@end + +@interface B : A +- (id)initWithInt:(int)x; +- (int)getSecondValue; +- (id)getSelf; +- (int)setValue:(int)x; +@end + +@interface B (FooBar) +- (id)categoryFunction:(int)x; +@end + +@implementation B +- (int)getSecondValue { return 0; } +- (id)init { return self; } +- (id)getSelf { return self; } +- (void)setValue:(int)x { } +- (id)initWithTwoInts:(int)x second:(int)y { return self; } ++ (id)alloc { return 0; } +@end + +@implementation B (FooBar) +- (id)categoryFunction:(int)x { return self; } +@end + +// RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc} +// CHECK-CC1: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} +// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} +// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText abc} +// CHECK-CC2-NEXT: NotImplemented:{TypedText getSelf} +// CHECK-CC2: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC2: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText abc} +// CHECK-CC3-NEXT: NotImplemented:{TypedText getSelf} +// CHECK-CC3: NotImplemented:{TypedText init} +// CHECK-CC3: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC3: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// RUN: c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// RUN: c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: NotImplemented:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: NotImplemented:{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// RUN: c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s +// CHECK-CC6: NotImplemented:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6-NOT: getSelf +// CHECK-CC6: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// RUN: c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s +// CHECK-CC7: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace + diff --git a/test/Index/complete-objc-message-id.m b/test/Index/complete-objc-message-id.m new file mode 100644 index 0000000..a75ee4a --- /dev/null +++ b/test/Index/complete-objc-message-id.m @@ -0,0 +1,42 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@interface A ++ (id)alloc; ++ (id)init; ++ (id)new; ++ (Class)class; ++ (Class)superclass; +- (id)retain; +- (id)autorelease; +- (id)superclass; +@end + +@interface B : A +- (int)B_method; +@end + +@interface Unrelated ++ (id)icky; +@end + +void message_id(B *b) { + [[A alloc] init]; + [[b retain] B_method]; + [[b superclass] B_method]; +} + +// RUN: c-index-test -code-completion-at=%s:24:14 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease} +// CHECK-CC1-NOT: B_method +// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain} +// RUN: c-index-test -code-completion-at=%s:25:15 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText B_method} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain} +// RUN: c-index-test -code-completion-at=%s:26:19 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease} +// CHECK-CC3-NOT: B_method +// CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain} + + diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m index 096ed24..e65a056 100644 --- a/test/Index/complete-objc-message.m +++ b/test/Index/complete-objc-message.m @@ -103,6 +103,25 @@ void f(Ellipsis *e) { [e Method:1, 2, 3]; } +@interface Overload2 ++ (int)Method:(int)i; ++ (int)Method; ++ (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2; ++ (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj; ++ (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj; ++ (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2; +@end + +void test_overload2(void) { + [Overload2 Method:1 Arg1:1 OtherArg:ovl]; +} + +void msg_id(id x) { + [x Method:1 Arg1:1 OtherArg:ovl]; + [[x blarg] Method:1 Arg1:1 OtherArg:ovl]; + [id Method:1 Arg1:1 OtherArg:ovl]; +} + // RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: {TypedText categoryClassMethod} // CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} @@ -153,3 +172,62 @@ void f(Ellipsis *e) { // CHECK-CCA: {TypedText super} // RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s // CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}{Placeholder , ...} +// RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText } +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} +// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s +// CHECK-CCF: {ResultType SEL}{TypedText _cmd} +// CHECK-CCF: TypedefDecl:{TypedText Class} +// CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo} +// CHECK-CCF: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )} +// CHECK-CCF: TypedefDecl:{TypedText id} +// CHECK-CCF: ObjCInterfaceDecl:{TypedText MyClass} +// CHECK-CCF: ObjCInterfaceDecl:{TypedText MySubClass} +// CHECK-CCF: TypedefDecl:{TypedText SEL} +// CHECK-CCF: {ResultType Class}{TypedText self} +// CHECK-CCF: {TypedText super} +// RUN: c-index-test -code-completion-at=%s:120:6 %s | FileCheck -check-prefix=CHECK-CCG %s +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod:}{Placeholder (id)obj} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} +// RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s +// RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s +// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod} + diff --git a/test/Index/complete-pch.m b/test/Index/complete-pch.m new file mode 100644 index 0000000..09192ae --- /dev/null +++ b/test/Index/complete-pch.m @@ -0,0 +1,26 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +@interface C +- (int)instanceMethod3:(int)x; ++ (int)classMethod3:(float)f; +@end + +void msg_id(id x) { + [id classMethod1:1.0]; + [x instanceMethod1:5]; +} + +// Build the precompiled header +// RUN: %clang -x objective-c-header -o %t.h.pch %S/Inputs/complete-pch.h + +// Run the actual tests +// RUN: c-index-test -code-completion-at=%s:10:7 -include %t.h %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)d} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)f} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)f} + +// RUN: c-index-test -code-completion-at=%s:11:6 -include %t.h %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)x} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)x} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)x} diff --git a/test/Index/invalid-code-rdar_7833619.m b/test/Index/invalid-code-rdar_7833619.m new file mode 100644 index 0000000..0034539 --- /dev/null +++ b/test/Index/invalid-code-rdar_7833619.m @@ -0,0 +1,4 @@ +// RUN: c-index-test -test-load-source all %s +// All we care about in this test is that it doesn't crash. +typedef r7833619_a (*r7833619_b)(r7833619_c *r7833619_d, r7833619_c *r7833619_e); + diff --git a/test/Index/load-exprs.c b/test/Index/load-exprs.c index f72f104..248bc6e 100644 --- a/test/Index/load-exprs.c +++ b/test/Index/load-exprs.c @@ -7,12 +7,49 @@ void f(void *ptr) { void *xx = ptr ? : &x; } -// RUN: c-index-test -test-load-source all %s | FileCheck %s +int test_blocks(int x) { + __block int y = x; + ^{ + static int z = 0; + y = (++z) + x; + ^{ + ++z; + ++y; + }(); + }(); + return y; +} + +// RUN: c-index-test -test-load-source all %s -fblocks | FileCheck %s +// CHECK: load-exprs.c:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14] +// CHECK: load-exprs.c:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23] +// CHECK: load-exprs.c:2:16: FieldDecl=a:2:16 (Definition) Extent=[2:16 - 2:17] +// CHECK: load-exprs.c:2:19: FieldDecl=b:2:19 (Definition) Extent=[2:19 - 2:20] +// CHECK: load-exprs.c:3:6: FunctionDecl=f:3:6 (Definition) Extent=[3:6 - 8:2] +// CHECK: load-exprs.c:3:14: ParmDecl=ptr:3:14 (Definition) Extent=[3:8 - 3:17] +// CHECK: load-exprs.c:4:6: VarDecl=t_ptr:4:6 (Definition) Extent=[4:3 - 4:22] +// CHECK: load-exprs.c:4:3: TypeRef=T:1:13 Extent=[4:3 - 4:4] // CHECK: load-exprs.c:4:15: TypeRef=T:1:13 Extent=[4:15 - 4:16] +// CHECK: load-exprs.c:4:19: DeclRefExpr=ptr:3:14 Extent=[4:19 - 4:22] // CHECK: load-exprs.c:5:16: TypeRef=T:1:13 Extent=[5:16 - 5:17] +// CHECK: load-exprs.c:6:12: VarDecl=x:6:12 (Definition) Extent=[6:10 - 6:32] // CHECK: load-exprs.c:6:10: TypeRef=struct X:2:8 Extent=[6:10 - 6:11] // CHECK: load-exprs.c:6:24: TypeRef=struct X:2:8 Extent=[6:24 - 6:25] // CHECK: load-exprs.c:7:9: VarDecl=xx:7:9 (Definition) Extent=[7:3 - 7:24] // CHECK: load-exprs.c:7:14: DeclRefExpr=ptr:3:14 Extent=[7:14 - 7:17] // CHECK: load-exprs.c:7:23: DeclRefExpr=x:6:12 Extent=[7:23 - 7:24] +// CHECK: load-exprs.c:10:5: FunctionDecl=test_blocks:10:5 (Definition) Extent=[10:5 - 21:2] +// CHECK: load-exprs.c:10:21: ParmDecl=x:10:21 (Definition) Extent=[10:17 - 10:22] +// CHECK: load-exprs.c:11:15: VarDecl=y:11:15 (Definition) Extent=[11:11 - 11:20] +// CHECK: load-exprs.c:11:19: DeclRefExpr=x:10:21 Extent=[11:19 - 11:20] +// CHECK: load-exprs.c:12:3: CallExpr= Extent=[12:3 - 19:7] +// CHECK: load-exprs.c:13:17: VarDecl=z:13:17 (Definition) Extent=[13:13 - 13:22] +// CHECK: load-exprs.c:14:6: DeclRefExpr= Extent=[14:6 - 14:7] +// CHECK: load-exprs.c:14:13: DeclRefExpr=z:13:17 Extent=[14:13 - 14:14] +// CHECK: load-exprs.c:14:18: DeclRefExpr= Extent=[14:18 - 14:19] +// CHECK: load-exprs.c:15:6: CallExpr= Extent=[15:6 - 18:9] +// CHECK: load-exprs.c:16:10: DeclRefExpr=z:13:17 Extent=[16:10 - 16:11] +// CHECK: load-exprs.c:17:10: DeclRefExpr= Extent=[17:10 - 17:11] +// CHECK: load-exprs.c:20:10: DeclRefExpr=y:11:15 Extent=[20:10 - 20:11] + diff --git a/test/Index/local-symbols.m b/test/Index/local-symbols.m new file mode 100644 index 0000000..8557e7f --- /dev/null +++ b/test/Index/local-symbols.m @@ -0,0 +1,26 @@ +// RUN: c-index-test -test-load-source local %s | FileCheck %s + +// From: +// The method 'bar' was also being reported outside the @implementation + +@interface Foo { + id x; +} +- (id) bar; +@end + +@implementation Foo +- (id) bar { + return 0; +} +@end + +// CHECK: local-symbols.m:6:12: ObjCInterfaceDecl=Foo:6:12 Extent=[6:1 - 10:5] +// CHECK: local-symbols.m:7:6: ObjCIvarDecl=x:7:6 (Definition) Extent=[7:6 - 7:7] +// CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5] +// CHECK: local-symbols.m:9:1: ObjCInstanceMethodDecl=bar:9:1 Extent=[9:1 - 9:12] +// CHECK: local-symbols.m:9:4: TypeRef=id:0:0 Extent=[9:4 - 9:6] +// CHECK: local-symbols.m:12:1: ObjCImplementationDecl=Foo:12:1 (Definition) Extent=[12:1 - 16:2] +// CHECK: local-symbols.m:13:1: ObjCInstanceMethodDecl=bar:13:1 (Definition) Extent=[13:1 - 15:2] +// CHECK: local-symbols.m:13:4: TypeRef=id:0:0 Extent=[13:4 - 13:6] + diff --git a/test/Index/print-usrs.c b/test/Index/print-usrs.c index 9cd64f7..898778b 100644 --- a/test/Index/print-usrs.c +++ b/test/Index/print-usrs.c @@ -8,8 +8,8 @@ ObjCMethod baz:with 1 c:objc(cs)NSObject ObjCProperty gimme c:objc(cs)NSObject ObjCProtocol blah // CHECK: c:objc(cs)NSObject -// CHECK: c:objc(cy)NSObject^foo -// CHECK: c:objc(cs)NSObject@^x +// CHECK: c:objc(cy)NSObject@foo +// CHECK: c:objc(cs)NSObject@x // CHECK: c:objc(cs)NSObject(cm)foo: // CHECK: c:objc(cs)NSObject(im)baz:with // CHECK: c:objc(cs)NSObject(py)gimme diff --git a/test/Index/usrs.m b/test/Index/usrs.m new file mode 100644 index 0000000..eb0817c --- /dev/null +++ b/test/Index/usrs.m @@ -0,0 +1,87 @@ +// RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s + +static inline int my_helper(int x, int y) { return x + y; } + +enum { + ABA, + CADABA +}; + +enum { + FOO, + BAR +}; + +typedef struct { + int wa; + int moo; +} MyStruct; + +enum Pizza { + CHEESE, + MUSHROOMS +}; + +@interface Foo { + id x; + id y; +} +- (id) godzilla; ++ (id) kingkong; +@property int d1; +@end + +@implementation Foo +- (id) godzilla { + static int a = 0; + extern int z; + return 0; +} ++ (id) kingkong { + int local_var; + return 0; +} +@synthesize d1; +@end + +int z; + +static int local_func(int x) { return x; } + +// CHECK: usrs.m c:usrs.m@3:19@F@my_helper Extent=[3:19 - 3:60] +// CHECK: usrs.m c:usrs.m@3:29@x Extent=[3:29 - 3:34] +// CHECK: usrs.m c:usrs.m@3:36@y Extent=[3:36 - 3:41] +// CHECK: usrs.m c:@Ea@usrs.m@5:1 Extent=[5:1 - 8:2] +// CHECK: usrs.m c:@Ea@usrs.m@5:1@ABA Extent=[6:3 - 6:6] +// CHECK: usrs.m c:@Ea@usrs.m@5:1@CADABA Extent=[7:3 - 7:9] +// CHECK: usrs.m c:@Ea@usrs.m@10:1 Extent=[10:1 - 13:2] +// CHECK: usrs.m c:@Ea@usrs.m@10:1@FOO Extent=[11:3 - 11:6] +// CHECK: usrs.m c:@Ea@usrs.m@10:1@BAR Extent=[12:3 - 12:6] +// CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2] +// CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:7 - 16:9] +// CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:7 - 17:10] +// CHECK: usrs.m c:@T@usrs.m@18:3@MyStruct Extent=[18:3 - 18:11] +// CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2] +// CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9] +// CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12] +// CHECK: usrs.m c:objc(cs)Foo Extent=[25:1 - 32:5] +// CHECK: usrs.m c:objc(cs)Foo@x Extent=[26:6 - 26:7] +// CHECK: usrs.m c:objc(cs)Foo@y Extent=[27:6 - 27:7] +// CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[31:15 - 31:17] +// CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[29:1 - 29:17] +// CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[30:1 - 30:17] +// CHECK: usrs.m c:objc(cs)Foo(im)d1 Extent=[31:15 - 31:17] +// CHECK: usrs.m c:objc(cs)Foo(im)setD1: Extent=[31:15 - 31:17] +// CHECK: usrs.m c:usrs.m@31:15@d1 Extent=[31:15 - 31:17] +// CHECK: usrs.m c:objc(cs)Foo Extent=[34:1 - 45:2] +// CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[35:1 - 39:2] +// CHECK: usrs.m c:usrs.m@36:10@a Extent=[36:10 - 36:19] +// CHECK: usrs.m c:@z Extent=[37:10 - 37:15] +// CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[40:1 - 43:2] +// CHECK: usrs.m c:usrs.m@41:3@local_var Extent=[41:3 - 41:16] +// CHECK: usrs.m c:objc(cs)Foo@d1 Extent=[44:13 - 44:15] +// CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[44:1 - 44:15] +// CHECK: usrs.m c:@z Extent=[47:1 - 47:6] +// CHECK: usrs.m c:usrs.m@49:12@F@local_func Extent=[49:12 - 49:43] +// CHECK: usrs.m c:usrs.m@49:23@x Extent=[49:23 - 49:28] + diff --git a/test/Lexer/gnu_keywords.c b/test/Lexer/gnu_keywords.c new file mode 100644 index 0000000..3234f58 --- /dev/null +++ b/test/Lexer/gnu_keywords.c @@ -0,0 +1,12 @@ +// RUN: %clang -DGNU_KEYWORDS -std=gnu89 -fsyntax-only -verify %s +// RUN: %clang -DGNU_KEYWORDS -std=c99 -fgnu-keywords -fsyntax-only -verify %s +// RUN: %clang -std=c99 -fsyntax-only -verify %s +// RUN: %clang -std=gnu89 -fno-gnu-keywords -fsyntax-only -verify %s + +void f() { +#ifdef GNU_KEYWORDS + asm ("ret" : :); +#else + int asm; +#endif +} diff --git a/test/Lexer/utf-16.c b/test/Lexer/utf-16.c new file mode 100644 index 0000000..2b313e4 --- /dev/null +++ b/test/Lexer/utf-16.c @@ -0,0 +1,6 @@ +// RUN: not %clang %s -fsyntax-only -verify +// rdar://7876588 + +// This test verifies that clang gives a decent error for UTF-16 source files. + +#include "utf-16.c.txt" // expected-error {{UTF-16 (LE) byte order mark detected}} diff --git a/test/Lexer/utf-16.c.txt b/test/Lexer/utf-16.c.txt new file mode 100644 index 0000000..4f3d169 Binary files /dev/null and b/test/Lexer/utf-16.c.txt differ diff --git a/test/Misc/message-length.c b/test/Misc/message-length.c index 3c74605..3e69b6a 100644 --- a/test/Misc/message-length.c +++ b/test/Misc/message-length.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s -// RUN: %clang_cc1 -fmessage-length 1 %s - +// RUN: not %clang_cc1 -fmessage-length 72 %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: not %clang_cc1 -fmessage-length 1 %s +// RUN: not %clang_cc1 -fmessage-length 8 %s 2>&1 | FileCheck -check-prefix=CHECK-DOT %s // Hack so we can check things better, force the file name and line. # 1 "FILE" 1 @@ -30,3 +30,13 @@ void a_very_long_line(int *ip, float *FloatPointer) { // CHECK: FILE:23:78 // CHECK: {{^ ...// some long comment text and a brace, eh {} }} + +struct A { int x; }; +void h(struct A *a) { + // CHECK-DOT: member + // CHECK-DOT: reference + // CHECK-DOT: type + (void)a + . + x; +} diff --git a/test/Misc/tabstop.c b/test/Misc/tabstop.c index 66685c6..49c4d7b 100644 --- a/test/Misc/tabstop.c +++ b/test/Misc/tabstop.c @@ -39,12 +39,9 @@ void f(void) // CHECK-3: {{^ }}if (0 & 1 == 1) // CHECK-3: {{^ }} ( ) -// CHECK-3: {{^ }} ( ) // CHECK-4: {{^ }}if (0 & 1 == 1) // CHECK-4: {{^ }} ( ) -// CHECK-4: {{^ }} ( ) // CHECK-5: {{^ }}if (0 & 1 == 1) // CHECK-5: {{^ }} ( ) -// CHECK-5: {{^ }} ( ) diff --git a/test/Misc/verify.c b/test/Misc/verify.c new file mode 100644 index 0000000..85b034e --- /dev/null +++ b/test/Misc/verify.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +struct s; // expected-note 7 {{forward declaration of 'struct s'}} + +// standard string matching +struct s s1; // expected-error {{tentative definition has type 'struct s' that is never completed}} +struct s s2; // expected-error {{tentative definition has type}} + +// regex matching +struct s r1; // expected-error-re {{tentative definition has type 'struct s' that is never completed}} +struct s r2; // expected-error-re {{tentative definition has type '.*[[:space:]]*.*' that is never completed}} +struct s r3; // expected-error-re {{tentative definition has type '(.*)[[:space:]]*(.*)' that is never completed}} +struct s r4; // expected-error-re {{^tentative}} +struct s r5; // expected-error-re {{completed$}} diff --git a/test/PCH/exprs.c b/test/PCH/exprs.c index 2b588a2..038a18b 100644 --- a/test/PCH/exprs.c +++ b/test/PCH/exprs.c @@ -5,6 +5,7 @@ // RUN: %clang_cc1 -emit-pch -fblocks -o %t %S/exprs.h // RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s +__SIZE_TYPE__ size_type_value; int integer; long long_integer; double floating; @@ -35,6 +36,9 @@ char_literal *int_ptr3 = &integer; // UnaryOperator negate_enum *int_ptr4 = &integer; +// OffsetOfExpr +offsetof_type *offsetof_ptr = &size_type_value; + // SizeOfAlignOfExpr typeof(sizeof(float)) size_t_value; typeof_sizeof *size_t_ptr = &size_t_value; diff --git a/test/PCH/exprs.h b/test/PCH/exprs.h index 7012422..5af8c7c 100644 --- a/test/PCH/exprs.h +++ b/test/PCH/exprs.h @@ -25,6 +25,19 @@ typedef typeof('a') char_literal; // UnaryOperator typedef typeof(-Enumerator) negate_enum; +// OffsetOfExpr +struct X { + int member; +}; +struct Y { + struct X array[5]; +}; +struct Z { + struct Y y; +}; +typedef typeof(__builtin_offsetof(struct Z, y.array[1 + 2].member)) + offsetof_type; + // SizeOfAlignOfExpr typedef typeof(sizeof(int)) typeof_sizeof; typedef typeof(sizeof(Enumerator)) typeof_sizeof2; diff --git a/test/PCH/functions.c b/test/PCH/functions.c index eb8579a..23becb6 100644 --- a/test/PCH/functions.c +++ b/test/PCH/functions.c @@ -6,7 +6,7 @@ // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s int f0(int x0, int y0, ...) { return x0 + y0; } - +// expected-note{{passing argument to parameter here}} float *test_f1(int val, double x, double y) { if (val > 5) return f1(x, y); @@ -15,7 +15,7 @@ float *test_f1(int val, double x, double y) { } void test_g0(int *x, float * y) { - g0(y); // expected-warning{{incompatible pointer types passing 'float *', expected 'int *'}} + g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}} g0(x); } diff --git a/test/PCH/functions.h b/test/PCH/functions.h index 3972430..f57400f 100644 --- a/test/PCH/functions.h +++ b/test/PCH/functions.h @@ -1,6 +1,9 @@ /* For use with the functions.c test */ -int f0(int x, int y, ...); + + + +int f0(int x, int y, ...); float *f1(float x, float y); void g0(int *); diff --git a/test/PCH/objc_stmts.h b/test/PCH/objc_stmts.h new file mode 100644 index 0000000..5f705df --- /dev/null +++ b/test/PCH/objc_stmts.h @@ -0,0 +1,22 @@ +/* For use with the methods.m test */ + +@interface A +@end + +@interface B +@end + +@interface TestPCH +- (void)instMethod; +@end + +@implementation TestPCH +- (void)instMethod { + @try { + } @catch(A *a) { + } @catch(B *b) { + } @catch(...) { + } @finally { + } +} +@end diff --git a/test/PCH/objc_stmts.m b/test/PCH/objc_stmts.m new file mode 100644 index 0000000..ed7466a --- /dev/null +++ b/test/PCH/objc_stmts.m @@ -0,0 +1,12 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -o - %s +// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -o - %s 2>&1 | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_stmts.h +// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s +// RUN: %clang_cc1 -include-pch %t -ast-dump -o - %s 2>&1 | FileCheck %s + +// CHECK: catch parm = "A *a" +// CHECK: catch parm = "B *b" +// CHECK: catch all diff --git a/test/PCH/pr4489.c b/test/PCH/pr4489.c index 1d8be2d..033e55b 100644 --- a/test/PCH/pr4489.c +++ b/test/PCH/pr4489.c @@ -1,6 +1,13 @@ // RUN: %clang -x c-header -o %t.pch %s // RUN: echo > %t.empty.c // RUN: %clang -include %t -x c %t.empty.c -emit-llvm -S -o - + +// FIXME: This test is forcibly disabled, it is flaky on the clang-i686-xp-msvc9 +// buildbot. +// +// RUN: false +// XFAIL: * + // PR 4489: Crash with PCH // PR 4492: Crash with PCH (round two) // PR 4509: Crash with PCH (round three) diff --git a/test/PCH/types.c b/test/PCH/types.c index 1ebc01b..c21b33a 100644 --- a/test/PCH/types.c +++ b/test/PCH/types.c @@ -66,7 +66,7 @@ int_ptr_ptr ipp = &int_value_ptr; // TYPE_TYPEOF_EXPR typeof_17 *t17 = &int_value; struct S { int x, y; }; -typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{incompatible type initializing}} +typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{initializing 'typeof_17' (aka 'int') with an expression of incompatible type 'struct S'}} // TYPE_TYPEOF int_ptr_ptr2 ipp2 = &int_value_ptr; diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index c2a32cf..ed14457 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faltivec -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s __vector char vv_c; __vector signed char vv_sc; @@ -40,6 +40,8 @@ vector int f__r(); void f_a(vector int a); void f_a2(int b, vector int a); +vector int v = (vector int)(-1); + // These should have warnings. __vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}} __vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}} @@ -81,8 +83,8 @@ void f() { gccvector unsigned int gv = v; gccvector int gvi = (gccvector int)v; __attribute__((vector_size(8))) unsigned int gv8; - gv8 = gccv; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int', expected '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} - av = gv8; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int', expected '__vector unsigned int'}} + gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}} + av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} v = gccv; __vector unsigned int tv = gccv; diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c index ca606f5..b287363 100644 --- a/test/Parser/attributes.c +++ b/test/Parser/attributes.c @@ -52,3 +52,7 @@ int foo42(void) { void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void); void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn)); + + +// PR6287 +void __attribute__((returns_twice)) returns_twice_test(); diff --git a/test/Parser/builtin_types_compatible.c b/test/Parser/builtin_types_compatible.c index 325615c..ac81e7b 100644 --- a/test/Parser/builtin_types_compatible.c +++ b/test/Parser/builtin_types_compatible.c @@ -35,7 +35,7 @@ static void test() struct xx { int a; } x, y; c = __builtin_choose_expr(a+3-7, b, x); // expected-error{{'__builtin_choose_expr' requires a constant expression}} - c = __builtin_choose_expr(0, b, x); // expected-error{{incompatible type assigning 'struct xx', expected 'int'}} + c = __builtin_choose_expr(0, b, x); // expected-error{{assigning to 'int' from incompatible type 'struct xx'}} c = __builtin_choose_expr(5+3-7, b, x); y = __builtin_choose_expr(4+3-7, b, x); diff --git a/test/Parser/check-syntax-1.m b/test/Parser/check-syntax-1.m index 085ff4c..db37793 100644 --- a/test/Parser/check-syntax-1.m +++ b/test/Parser/check-syntax-1.m @@ -11,9 +11,7 @@ typedef float CGFloat; // rdar: // 7822196 @interface A -(void) x; // expected-error {{method type specifier must start with '-' or '+'}} \ - // expected-warning {{type specifier missing, defaults to 'int' [-Wimplicit-int]}} \ - // expected-error {{cannot declare variable inside @interface or @protocol}} +(void) x; // expected-error {{method type specifier must start with '-' or '+'}} (int)im; // expected-error {{method type specifier must start with '-' or '+'}} \ - ok; @end diff --git a/test/Parser/cxx-altivec.cpp b/test/Parser/cxx-altivec.cpp index 3610c0e..66d4f32 100644 --- a/test/Parser/cxx-altivec.cpp +++ b/test/Parser/cxx-altivec.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -faltivec -fsyntax-only -verify %s - +// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s // This is the same as the C version: __vector char vv_c; @@ -42,6 +41,8 @@ vector int f__r(); void f_a(vector int a); void f_a2(int b, vector int a); +vector int v = (vector int)(-1); + // These should have warnings. __vector long vv_l; // expected-warning {{Use of 'long' with '__vector' is deprecated}} __vector signed long vv_sl; // expected-warning {{Use of 'long' with '__vector' is deprecated}} @@ -81,8 +82,8 @@ void f() { gccvector unsigned int gv = v; gccvector int gvi = (gccvector int)v; __attribute__((vector_size(8))) unsigned int gv8; - gv8 = gccv; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int', expected '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} - av = gv8; // expected-error {{incompatible type assigning '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int', expected '__vector unsigned int'}} + gv8 = gccv; // expected-error {{assigning to '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int' from incompatible type '__attribute__((__vector_size__(4 * sizeof(unsigned int)))) unsigned int'}} + av = gv8; // expected-error {{assigning to '__vector unsigned int' from incompatible type '__attribute__((__vector_size__(2 * sizeof(unsigned int)))) unsigned int'}} v = gccv; __vector unsigned int tv = gccv; diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp index c8b4716..98d962a 100644 --- a/test/Parser/cxx-casting.cpp +++ b/test/Parser/cxx-casting.cpp @@ -5,8 +5,6 @@ char *const_cast_test(const char *var) return const_cast(var); } -#if 0 -// FIXME: Uncomment when C++ is supported more. struct A { virtual ~A() {} }; @@ -18,7 +16,6 @@ struct B *dynamic_cast_test(struct A *a) { return dynamic_cast(a); } -#endif char *reinterpret_cast_test() { @@ -34,3 +31,9 @@ char postfix_expr_test() { return reinterpret_cast(0xdeadbeef)[0]; } + +// This was being incorrectly tentatively parsed. +namespace test1 { + template class A {}; + void foo() { A(*(A*)0); } +} diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 576e57d..4abbbc5 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -8,7 +8,7 @@ protected: struct S {}; enum {}; - int; // expected-error {{declaration does not declare anything}} + int; // expected-warning {{declaration does not declare anything}} int : 1, : 2; public: diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp index 2fe30cd..59350b5 100644 --- a/test/Parser/cxx-friend.cpp +++ b/test/Parser/cxx-friend.cpp @@ -21,9 +21,9 @@ class B { // 'A' here should refer to the declaration above. friend class A; - friend C; // expected-error {{must specify 'class' to befriend}} - friend U; // expected-error {{must specify 'union' to befriend}} - friend int; // expected-error {{friends can only be classes or functions}} + friend C; // expected-warning {{must specify 'class' to befriend}} + friend U; // expected-warning {{must specify 'union' to befriend}} + friend int; // expected-warning {{non-class type 'int' cannot be a friend}} friend void myfunc(); diff --git a/test/Parser/cxx-template-decl.cpp b/test/Parser/cxx-template-decl.cpp index 3f8f1ec..3a97efa 100644 --- a/test/Parser/cxx-template-decl.cpp +++ b/test/Parser/cxx-template-decl.cpp @@ -6,7 +6,7 @@ template x; // expected-error {{C++ requires a type specifier for al // expected-error {{does not refer}} export template x; // expected-error {{expected '<' after 'template'}} export template class x0; // expected-warning {{exported templates are unsupported}} -template < ; // expected-error {{parse error}} expected-error {{declaration does not declare anything}} +template < ; // expected-error {{parse error}} expected-warning {{declaration does not declare anything}} template