1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 510010 - Uniform initialization in template argument

Change-Id: I55853735e44fdf6240bebb53f2e7ab1a6885b273
This commit is contained in:
Nathan Ridge 2017-01-08 14:23:44 -05:00
parent 68e19daf1e
commit ccb64b8b63
2 changed files with 46 additions and 1 deletions

View file

@ -7807,6 +7807,28 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
// struct IntConvertible {
// constexpr operator int() const { return 42; }
// };
//
// template <int>
// struct Waldo {};
//
// Waldo<IntConvertible{}> w; // Syntax error
public void testUniformInitializationInTemplateArgument_510010() throws Exception {
parseAndCheckBindings();
}
// int f() {
// int i = 0;
// if(i < 1){
// ++i;
// }
// }
public void testRegression_510010() throws Exception {
parseAndCheckBindings();
}
// template<bool, typename T = void>
// struct C {};
//

View file

@ -572,9 +572,32 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
}
}
break;
case IToken.tSEMI:
// In C++11, braces can occur at the top level in a template-argument,
// if an object of class type is being created via uniform initialization,
// and that class type has a constexpr conversion operator to a type
// that's valid as the type of a non-type template parameter.
case IToken.tLBRACE:
if (nk == 0) {
nk = IToken.tLBRACE;
depth = 0;
} else if (nk == IToken.tLBRACE) {
depth++;
}
break;
case IToken.tRBRACE:
if (nk == 0) {
return NO_TEMPLATE_ID;
}
else if (nk == IToken.tLBRACE) {
if (--depth < 0) {
nk = 0;
}
}
break;
case IToken.tSEMI:
if (nk == 0) {
return NO_TEMPLATE_ID;
}