diff options
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/hog1.C | 77 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/consteval36.C | 22 |
2 files changed, 99 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/hog1.C b/gcc/testsuite/g++.dg/cpp0x/hog1.C new file mode 100644 index 0000000..105a2e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/hog1.C @@ -0,0 +1,77 @@ +// PR c++/111660 +// { dg-do compile { target c++11 } } + +enum Value { + LPAREN, + RPAREN, + LBRACE, + RBRACE, + LBRACK, + RBRACK, + CONDITIONAL, + COLON, + SEMICOLON, + COMMA, + PERIOD, + BIT_OR, + BIT_AND, + BIT_XOR, + BIT_NOT, + NOT, + LT, + GT, + MOD, + ASSIGN, + ADD, + SUB, + MUL, + DIV, + PRIVATE_NAME, + STRING, + TEMPLATE_SPAN, + IDENTIFIER, + WHITESPACE, + ILLEGAL, +}; + +constexpr Value GetOneCharToken(char c) { + return + c == '(' ? LPAREN : + c == ')' ? RPAREN : + c == '{' ? LBRACE : + c == '}' ? RBRACE : + c == '[' ? LBRACK : + c == ']' ? RBRACK : + c == '?' ? CONDITIONAL : + c == ':' ? COLON : + c == ';' ? SEMICOLON : + c == ',' ? COMMA : + c == '.' ? PERIOD : + c == '|' ? BIT_OR : + c == '&' ? BIT_AND : + c == '^' ? BIT_XOR : + c == '~' ? BIT_NOT : + c == '!' ? NOT : + c == '<' ? LT : + c == '>' ? GT : + c == '%' ? MOD : + c == '=' ? ASSIGN : + c == '+' ? ADD : + c == '-' ? SUB : + c == '*' ? MUL : + c == '/' ? DIV : + c == '#' ? PRIVATE_NAME : + c == '"' ? STRING : + c == '\'' ? STRING : + c == '`' ? TEMPLATE_SPAN : + c == '\\' ? IDENTIFIER : + c == ' ' ? WHITESPACE : + c == '\t' ? WHITESPACE : + c == '\v' ? WHITESPACE : + c == '\f' ? WHITESPACE : + c == '\r' ? WHITESPACE : + c == '\n' ? WHITESPACE : + ILLEGAL; +} + +int main() {} diff --git a/gcc/testsuite/g++.dg/cpp2a/consteval36.C b/gcc/testsuite/g++.dg/cpp2a/consteval36.C new file mode 100644 index 0000000..9c470e4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/consteval36.C @@ -0,0 +1,22 @@ +// PR c++/111660 +// { dg-do compile { target c++20 } } + +consteval int id (int i) { return i; } + +void +g (int i) +{ + 1 ? 1 : ((1 ? 1 : 1), id (i)); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : 1), id (i), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((i ? 1 : 1), id (i), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? i : 1), id (i), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : i), id (i), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((i ? -i : i), id (i), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : id (i)), id (42), 1); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : id (42)), id (i)); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : id (42)), id (i), 1); // { dg-error "'i' is not a constant expression" } + id (i) ? 1 : ((1 ? 1 : 1), id (i)); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((1 ? 1 : id (i)), id (i)); // { dg-error "'i' is not a constant expression" } + 1 ? id (i) : ((1 ? 1 : id (i)), id (i)); // { dg-error "'i' is not a constant expression" } + 1 ? 1 : ((id (i) ? 1 : 1), id (i)); // { dg-error "'i' is not a constant expression" } +} |