diff options
author | John McCall <rjmccall@apple.com> | 2010-05-28 08:20:36 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-05-28 08:20:36 +0000 |
commit | 1d0a5856d066f9030efbe3e0d9bbbb50ea597b99 (patch) | |
tree | febfa262414dfd3cdf66ad3cef7bda8860667bf4 /lib/Sema/SemaDeclAttr.cpp | |
parent | 42a4f66ffeb26e69b2f0ec873a5d41b0e39e634c (diff) |
Add a new attribute on records, __attribute__((adl_invisible)), and define
the x86-64 __va_list_tag with this attribute. The attribute causes the
affected type to behave like a fundamental type when considered by ADL.
(x86-64 is the only target we currently provide with a struct-based
__builtin_va_list)
Fixes PR6762.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104941 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index c6dcc3b97b..90d5308168 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -703,7 +703,7 @@ static void HandleObjCExceptionAttr(Decl *D, const AttributeList &Attr, static void HandleObjCNSObject(Decl *D, const AttributeList &Attr, Sema &S) { if (Attr.getNumArgs() != 0) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; return; } if (TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) { @@ -720,7 +720,7 @@ static void HandleObjCNSObject(Decl *D, const AttributeList &Attr, Sema &S) { static void HandleOverloadableAttr(Decl *D, const AttributeList &Attr, Sema &S) { if (Attr.getNumArgs() != 0) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; return; } @@ -732,6 +732,21 @@ HandleOverloadableAttr(Decl *D, const AttributeList &Attr, Sema &S) { D->addAttr(::new (S.Context) OverloadableAttr()); } +static void HandleADLInvisibleAttr(Decl *d, const AttributeList &Attr, Sema &S) { + if (Attr.getNumArgs() != 0) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 0; + return; + } + + if (!isa<RecordDecl>(d)) { + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type) + << "adl_invisible" << 12; + return; + } + + cast<RecordDecl>(d)->setInvisibleToADL(); +} + static void HandleBlocksAttr(Decl *d, const AttributeList &Attr, Sema &S) { if (!Attr.getParameterName()) { S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_not_string) @@ -941,7 +956,7 @@ static void HandleReqdWorkGroupSize(Decl *D, const AttributeList &Attr, Sema &S) { // Attribute has 3 arguments. if (Attr.getNumArgs() != 3) { - S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 1; + S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << 3; return; } @@ -1969,6 +1984,7 @@ static void ProcessDeclAttribute(Scope *scope, Decl *D, HandleObjCExceptionAttr(D, Attr, S); break; case AttributeList::AT_overloadable:HandleOverloadableAttr(D, Attr, S); break; + case AttributeList::AT_adl_invisible: HandleADLInvisibleAttr(D, Attr, S); break; case AttributeList::AT_nsobject: HandleObjCNSObject (D, Attr, S); break; case AttributeList::AT_blocks: HandleBlocksAttr (D, Attr, S); break; case AttributeList::AT_sentinel: HandleSentinelAttr (D, Attr, S); break; |