mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 319107: [c++0x] DeclSpecWriter add support for decltype and typeof
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319107
This commit is contained in:
parent
e911f1d564
commit
3fe0d27e62
2 changed files with 34 additions and 8 deletions
|
@ -170,3 +170,13 @@ auto var = 42;
|
|||
//%CPP
|
||||
long long int i;
|
||||
|
||||
//!C++0x decltype
|
||||
//%CPP
|
||||
int i;
|
||||
decltype(i) j = 3;
|
||||
|
||||
//!C++0x typeof
|
||||
//%CPP
|
||||
int i;
|
||||
typeof i j = 3;
|
||||
|
||||
|
|
|
@ -125,10 +125,18 @@ public class DeclSpecWriter extends NodeWriter {
|
|||
if (isCpp)
|
||||
return Keywords.AUTO;
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_typeof:
|
||||
if (isCpp)
|
||||
return Keywords.TYPEOF;
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_decltype:
|
||||
if (isCpp)
|
||||
return Keywords.DECLTYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
|
||||
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
|
||||
System.err.println("Unknown specifier type: " + type); //$NON-NLS-1$
|
||||
throw new IllegalArgumentException("Unknown specifier type: " + type); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
|
||||
|
@ -280,15 +288,15 @@ public class DeclSpecWriter extends NodeWriter {
|
|||
}
|
||||
|
||||
if(hasFreestandingComments(compDeclSpec)) {
|
||||
writeFreeStandingComments(compDeclSpec);
|
||||
}
|
||||
scribe.decrementIndentationLevel();
|
||||
scribe.print('}');
|
||||
writeFreeStandingComments(compDeclSpec);
|
||||
}
|
||||
scribe.decrementIndentationLevel();
|
||||
scribe.print('}');
|
||||
|
||||
if(hasTrailingComments(compDeclSpec)) {
|
||||
writeTrailingComments(compDeclSpec);
|
||||
}
|
||||
writeTrailingComments(compDeclSpec);
|
||||
}
|
||||
}
|
||||
|
||||
protected IASTDeclaration[] getMembers(IASTCompositeTypeSpecifier compDeclSpec) {
|
||||
return compDeclSpec.getMembers();
|
||||
|
@ -374,6 +382,14 @@ public class DeclSpecWriter extends NodeWriter {
|
|||
private void writeCPPSimpleDeclSpec(ICPPASTSimpleDeclSpecifier simpDeclSpec) {
|
||||
printQualifiers(simpDeclSpec);
|
||||
scribe.print(getCPPSimpleDecSpecifier(simpDeclSpec));
|
||||
if (simpDeclSpec.getType() == IASTSimpleDeclSpecifier.t_typeof) {
|
||||
scribe.printSpace();
|
||||
visitNodeIfNotNull(simpDeclSpec.getDeclTypeExpression());
|
||||
} else if (simpDeclSpec.getType() == IASTSimpleDeclSpecifier.t_decltype) {
|
||||
scribe.print('(');
|
||||
visitNodeIfNotNull(simpDeclSpec.getDeclTypeExpression());
|
||||
scribe.print(')');
|
||||
}
|
||||
}
|
||||
|
||||
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
|
||||
|
|
Loading…
Add table
Reference in a new issue