summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-01-15 02:48:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-01-15 02:48:13 +0000
commit0faa2b1ae45d20c8287a329d505373ae062153ca (patch)
tree41662c41ca0bbac588448dd45c8ab1516fc0d6c4 /clang/lib/Sema
parent184e981111d74fe650b7ea4506adc9bc356273ee (diff)
downloadbcm5719-llvm-0faa2b1ae45d20c8287a329d505373ae062153ca.tar.gz
bcm5719-llvm-0faa2b1ae45d20c8287a329d505373ae062153ca.zip
Fix behavior of [[gnu::]] function attributes. Per g++'s behavior, these
attributes appertain to a declaration, even though they would be much more naturally modelled as appertaining to a function type. Previously, we would try to distribute them from the declarator to the function type, then reject them for being at an incorrect location. Now, we just distribute them as far as the declarator; the existing attribute handling code can actually apply them there just fine. llvm-svn: 172504
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaType.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 3b1dac348e8..e849e05c7b4 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -463,6 +463,15 @@ distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state,
QualType &declSpecType) {
state.saveDeclSpecAttrs();
+ // C++11 attributes before the decl specifiers actually appertain to
+ // the declarators. Move them straight there. We don't support the
+ // 'put them wherever you like' semantics we allow for GNU attributes.
+ if (attr.isCXX11Attribute()) {
+ moveAttrFromListToList(attr, state.getCurrentAttrListRef(),
+ state.getDeclarator().getAttrListRef());
+ return;
+ }
+
// Try to distribute to the innermost.
if (distributeFunctionTypeAttrToInnermost(state, attr,
state.getCurrentAttrListRef(),
@@ -512,6 +521,11 @@ static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state,
do {
next = attr->getNext();
+ // Do not distribute C++11 attributes. They have strict rules for what
+ // they appertain to.
+ if (attr->isCXX11Attribute())
+ continue;
+
switch (attr->getKind()) {
OBJC_POINTER_TYPE_ATTRS_CASELIST:
distributeObjCPointerTypeAttrFromDeclarator(state, *attr, declSpecType);
OpenPOWER on IntegriCloud