This fixes PR22492, which is in response to CWG issue #1204.
Per the CWG issue 'contexpr' variables are now allowed in
for range loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229716
91177308-0d34-0410-b5e6-
96231b3b80d8
case SC_OpenCLWorkGroupLocal:
llvm_unreachable("Unexpected storage class");
}
- if (VD->isConstexpr())
- Error = 5;
if (Error != -1) {
Diag(VD->getOuterLocStart(), diag::err_for_range_storage_class)
<< VD->getDeclName() << Error;
struct NoEndADL {
null_t alt_begin();
};
+
+ struct C {
+ C();
+ struct It {
+ int val;
+ operator int &() { return val; }
+ };
+ It begin();
+ It end();
+ };
+
+ constexpr int operator*(const C::It &) { return 0; }
}
using X::A;
for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}}
for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}}
for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}} expected-warning {{deprecated}}
- for (constexpr int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'constexpr'}}
+ for (constexpr int a : X::C()) {} // OK per CWG issue #1204.
for (auto u : X::NoBeginADL()) { // expected-error {{invalid range expression of type 'X::NoBeginADL'; no viable 'begin' function available}}
}