mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-19 14:15:50 +02:00
Bug 396663: Throw expressions within conditional expressions.
This commit is contained in:
parent
6dab072dcd
commit
6f89ed8fae
3 changed files with 40 additions and 2 deletions
|
@ -10149,4 +10149,41 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
long BSize = SizeofCalculator.getSizeAndAlignment(B, nameB).size;
|
||||
assertEquals(pointerSize, BSize);
|
||||
}
|
||||
|
||||
// namespace std {
|
||||
// struct string {};
|
||||
// struct exception {};
|
||||
// }
|
||||
// void f(){}
|
||||
//
|
||||
// int problemA(int i) {
|
||||
// return i ? throw 7 : i;
|
||||
// }
|
||||
// int problemB(int i) {
|
||||
// return i ? throw std::string{} : i;
|
||||
// }
|
||||
// void ploblemC(int i) {
|
||||
// return i ? throw std::exception() : throw 3;
|
||||
// }
|
||||
// void ploblemD(int i) {
|
||||
// return i ? throw std::exception() : f();
|
||||
// }
|
||||
// std::string ploblemE(int i) {
|
||||
// return i ? throw 3 : "a";
|
||||
// }
|
||||
// std::string ploblemF(int i) {
|
||||
// return (i<2 ? throw 2 : "x") ? (i>2 ? throw 3 : "d") : (i>22 ? throw 4 : "e");
|
||||
// }
|
||||
// auto ploblemG(int i) ->decltype(i ? throw 3 : "d"){
|
||||
// return i ? throw 3 : "d" ;
|
||||
// }
|
||||
// void fine1(int i) {
|
||||
// return i ? f() : f();
|
||||
// }
|
||||
// std::string fine2(int i) {
|
||||
// return i ? "a" : "b";
|
||||
// }
|
||||
public void testThrowExpressionInConditional_396663() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -942,7 +942,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
lt1= LT(1);
|
||||
if (lt1 != IToken.tCOLON && lt1 != IToken.tCOMMA)
|
||||
stopWithNextOperator= true;
|
||||
break;
|
||||
} else if (allowBraceInitializer && LT(1) == IToken.tLBRACE) {
|
||||
// Brace initializer
|
||||
expr= bracedInitList(true);
|
||||
|
|
|
@ -681,7 +681,9 @@ public class CPPTemplates {
|
|||
IBinding owner = template.getOwner();
|
||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||
IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
|
||||
return new CPPAliasTemplateInstance(id.toCharArray(), aliasTemplate, instantiatedType);
|
||||
StringBuilder buf= new StringBuilder();
|
||||
buf.append(id.getSimpleID()).append(ASTTypeUtil.getArgumentListString(args, false));
|
||||
return new CPPAliasTemplateInstance(buf.toString().toCharArray(), aliasTemplate, instantiatedType);
|
||||
}
|
||||
|
||||
// Class template.
|
||||
|
|
Loading…
Add table
Reference in a new issue