1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 396663: Throw expressions within conditional expressions.

This commit is contained in:
Markus Schorn 2012-12-17 14:53:37 +01:00
parent 7c92e3e070
commit c5d08937e2
3 changed files with 42 additions and 2 deletions

View file

@ -261,6 +261,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(defNames.length, j);
}
@Override
protected void assertSameType(IType first, IType second){
assertNotNull(first);
assertNotNull(second);
@ -10079,4 +10080,42 @@ public class AST2CPPTests extends AST2BaseTest {
helper.assertNonProblemOnFirstIdentifier("fint({vbool");
helper.assertNonProblemOnFirstIdentifier("fint({vchar");
}
// 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);
}
}

View file

@ -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);

View file

@ -663,7 +663,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.