r335021 - [Sema] Produce diagnostics for attribute 'trivial_abi' that appears
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 18 22:04:45 PDT 2018
Author: ahatanak
Date: Mon Jun 18 22:04:44 2018
New Revision: 335021
URL: http://llvm.org/viewvc/llvm-project?rev=335021&view=rev
Log:
[Sema] Produce diagnostics for attribute 'trivial_abi' that appears
after the closing brace of a class declaration.
Merge the two call sites of checkIllFormedTrivialABIStruct and sink it
into CheckCompletedCXXClass so that it is called after the attribute has
been attached to the CXXRecordDecl.
rdar://problem/40873297
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaObjCXX/attr-trivial-abi.mm
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=335021&r1=335020&r2=335021&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jun 18 22:04:44 2018
@@ -6018,6 +6018,10 @@ void Sema::CheckCompletedCXXClass(CXXRec
}
}
+ // See if trivial_abi has to be dropped.
+ if (Record->hasAttr<TrivialABIAttr>())
+ checkIllFormedTrivialABIStruct(*Record);
+
// Set HasTrivialSpecialMemberForCall if the record has attribute
// "trivial_abi".
bool HasTrivialABI = Record->hasAttr<TrivialABIAttr>();
@@ -7810,17 +7814,12 @@ void Sema::ActOnFinishCXXMemberSpecifica
l->getName();
}
- // See if trivial_abi has to be dropped.
- auto *RD = dyn_cast<CXXRecordDecl>(TagDecl);
- if (RD && RD->hasAttr<TrivialABIAttr>())
- checkIllFormedTrivialABIStruct(*RD);
-
ActOnFields(S, RLoc, TagDecl, llvm::makeArrayRef(
// strict aliasing violation!
reinterpret_cast<Decl**>(FieldCollector->getCurFields()),
FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
- CheckCompletedCXXClass(RD);
+ CheckCompletedCXXClass(dyn_cast_or_null<CXXRecordDecl>(TagDecl));
}
/// AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=335021&r1=335020&r2=335021&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Mon Jun 18 22:04:44 2018
@@ -2123,10 +2123,6 @@ Sema::InstantiateClass(SourceLocation Po
}
}
- // See if trivial_abi has to be dropped.
- if (Instantiation && Instantiation->hasAttr<TrivialABIAttr>())
- checkIllFormedTrivialABIStruct(*Instantiation);
-
// Finish checking fields.
ActOnFields(nullptr, Instantiation->getLocation(), Instantiation, Fields,
SourceLocation(), SourceLocation(), nullptr);
Modified: cfe/trunk/test/SemaObjCXX/attr-trivial-abi.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/attr-trivial-abi.mm?rev=335021&r1=335020&r2=335021&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/attr-trivial-abi.mm (original)
+++ cfe/trunk/test/SemaObjCXX/attr-trivial-abi.mm Mon Jun 18 22:04:44 2018
@@ -18,6 +18,10 @@ struct __attribute__((trivial_abi)) S3 {
virtual void m();
};
+struct S3_2 {
+ virtual void m();
+} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}}
+
struct S4 {
int a;
};
More information about the cfe-commits
mailing list