mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 510010 - Uniform initialization in template argument
Change-Id: I55853735e44fdf6240bebb53f2e7ab1a6885b273
This commit is contained in:
parent
68e19daf1e
commit
ccb64b8b63
2 changed files with 46 additions and 1 deletions
|
@ -7807,6 +7807,28 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
parseAndCheckBindings();
|
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>
|
// template<bool, typename T = void>
|
||||||
// struct C {};
|
// struct C {};
|
||||||
//
|
//
|
||||||
|
|
|
@ -572,9 +572,32 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case IToken.tLBRACE:
|
||||||
|
if (nk == 0) {
|
||||||
|
nk = IToken.tLBRACE;
|
||||||
|
depth = 0;
|
||||||
|
} else if (nk == IToken.tLBRACE) {
|
||||||
|
depth++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case IToken.tRBRACE:
|
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) {
|
if (nk == 0) {
|
||||||
return NO_TEMPLATE_ID;
|
return NO_TEMPLATE_ID;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue