|
| 1 | +// RUN: %clang_cc1 -verify -std=c++17 -pedantic-errors %s |
| 2 | +// RUN: cp %s %t |
| 3 | +// RUN: not %clang_cc1 -x c++ -std=c++17 -fixit %t |
| 4 | +// RUN: %clang_cc1 -Wall -pedantic-errors -x c++ -std=c++17 %t |
| 5 | + |
| 6 | +/* This is a test of the various code modification hints that only |
| 7 | + apply in C++17. */ |
| 8 | +template<int... args> |
| 9 | +int foo() { |
| 10 | + int a = (args + 1 + ...); // expected-error {{expression not permitted as operand of fold expression}} |
| 11 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"(" |
| 12 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:22-[[@LINE-2]]:22}:")" |
| 13 | + int b = (args + 123 + ...); // expected-error {{expression not permitted as operand of fold expression}} |
| 14 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"(" |
| 15 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:24-[[@LINE-2]]:24}:")" |
| 16 | + int c = (args + 1 + 2 + ...); // expected-error {{expression not permitted as operand of fold expression}} |
| 17 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"(" |
| 18 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:26-[[@LINE-2]]:26}:")" |
| 19 | + int e = (... + 1 + args); // expected-error {{expression not permitted as operand of fold expression}} |
| 20 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:20-[[@LINE-1]]:20}:"(" |
| 21 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:28-[[@LINE-2]]:28}:")" |
| 22 | + int f = (1 + ... + args + 1); // expected-error {{expression not permitted as operand of fold expression}} |
| 23 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:24-[[@LINE-1]]:24}:"(" |
| 24 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:32-[[@LINE-2]]:32}:")" |
| 25 | + int g = (args + 1 + ... + 1); // expected-error {{expression not permitted as operand of fold expression}} |
| 26 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:14-[[@LINE-1]]:14}:"(" |
| 27 | + // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:22-[[@LINE-2]]:22}:")" |
| 28 | + return a + b + c + e + f + g; |
| 29 | +} |
0 commit comments