mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 534332 - Allow C decl-specifiers to store attributes
The parser already accepted this, but the attributes were not stored in the AST. Change-Id: I7118eaff9dd150f15885f0aabb8a3b5e707394b0
This commit is contained in:
parent
3ad16b909c
commit
d8d04e2731
5 changed files with 8 additions and 7 deletions
|
@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
|
|||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IASTDeclSpecifier extends IASTNode {
|
||||
public interface IASTDeclSpecifier extends IASTAttributeOwner {
|
||||
/**
|
||||
* No storage class specified.
|
||||
*/
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
|||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier, IASTAttributeOwner {
|
||||
public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
|
||||
// A declaration in C++ can be a friend declaration
|
||||
/**
|
||||
* Is this a friend declaration?
|
||||
|
|
|
@ -14,14 +14,14 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public abstract class CASTBaseDeclSpecifier extends ASTNode
|
||||
public abstract class CASTBaseDeclSpecifier extends ASTAttributeOwner
|
||||
implements ICASTDeclSpecifier, IASTAmbiguityParent {
|
||||
|
||||
protected int storageClass;
|
||||
|
|
|
@ -922,6 +922,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
ICASTDeclSpecifier result= null;
|
||||
ICASTDeclSpecifier altResult= null;
|
||||
IASTAlignmentSpecifier[] alignmentSpecifiers = IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
|
||||
List<IASTAttributeSpecifier> attributes = null;
|
||||
try {
|
||||
IASTName identifier= null;
|
||||
IASTExpression typeofExpression= null;
|
||||
|
@ -1151,7 +1152,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec
|
||||
if (!supportAttributeSpecifiers)
|
||||
throwBacktrack(LA(1));
|
||||
__attribute_decl_seq(true, false);
|
||||
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
|
||||
break;
|
||||
case IGCCToken.t__declspec: // __declspec precedes the identifier
|
||||
if (identifier != null || !supportDeclspecSpecifiers)
|
||||
|
@ -1212,6 +1213,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
result= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
|
||||
}
|
||||
result.setAlignmentSpecifiers(ArrayUtil.trim(alignmentSpecifiers));
|
||||
addAttributeSpecifiers(attributes, result);
|
||||
} catch (BacktrackException e) {
|
||||
if (returnToken != null) {
|
||||
backup(returnToken);
|
||||
|
|
|
@ -3065,7 +3065,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
declarator= addInitializer(lie, DeclarationOptions.PARAMETER);
|
||||
}
|
||||
|
||||
addAttributeSpecifiers(attributes, (ICPPASTDeclSpecifier) declSpec);
|
||||
addAttributeSpecifiers(attributes, declSpec);
|
||||
|
||||
final ICPPASTParameterDeclaration parm = getNodeFactory().newParameterDeclaration(declSpec, declarator);
|
||||
final int endOffset = figureEndOffset(declSpec, declarator);
|
||||
|
|
Loading…
Add table
Reference in a new issue