30 lines · cpp
1// RUN: %clang_cc1 -verify -std=c++17 -pedantic-errors %s2// RUN: cp %s %t3// RUN: not %clang_cc1 -x c++ -std=c++17 -fixit %t4// RUN: %clang_cc1 -Wall -pedantic-errors -x c++ -std=c++17 %t5 6/* This is a test of the various code modification hints that only7 apply in C++17. */8template<int... args>9int 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}30