}
/// AddAttributes - simply adds the attribute list to the Declarator.
- /// Unlike AddAttributes on DeclSpec, this routine should never have to
- /// concatenate two lists. The following syntax adds 3 attributes to "var":
- ///
- /// short int var __attribute__((aligned(16),common,deprecated));
+ /// These examples both add 3 attributes to "var":
+ /// short int var __attribute__((aligned(16),common,deprecated));
+ /// short int x, __attribute__((aligned(16)) var
+ /// __attribute__((common,deprecated));
///
void AddAttributes(AttributeList *alist) {
if (!alist)
return; // we parsed __attribute__(()) or had a syntax error
- assert((AttrList == 0) && "Declarator already has an attribute list");
+
+ if (AttrList)
+ alist->addAttributeList(AttrList);
AttrList = alist;
}
+
const AttributeList *getAttributes() const { return AttrList; }
AttributeList *getAttributes() { return AttrList; }
// Parse the next declarator.
D.clear();
+
+ // Accept attributes in an init-declarator. In the first declarator in a
+ // declaration, these would be part of the declspec. In subsequent
+ // declarators, they become part of the declarator itself, so that they
+ // don't apply to declarators after *this* one. Examples:
+ // short __attribute__((common)) var; -> declspec
+ // short var __attribute__((common)); -> declarator
+ // short x, __attribute__((common)) var; -> declarator
+ if (Tok.is(tok::kw___attribute))
+ D.AddAttributes(ParseAttributes());
+
ParseDeclarator(D);
}
void (*h3)(void (*f3)(attribute(()) x)); // expected-warning {{defaults to 'int'}}
void (*h4)(void (*f4)(attribute(()))); // expected-error {{expected parameter declarator}}
+
+
+
+// rdar://6131260
+int foo42(void) {
+ int x, attribute((unused)) y, z;
+ return 0;
+}
+
+// rdar://6096491
+void attribute((noreturn)) d0(void), attribute((noreturn)) d1(void);
+