teak-llvm/clang/test/SemaCXX/cxx0x-constexpr-const.cpp
Richard Trieu af7d76c720 Improve the error message for assigning to read-only variables.
Previously, many error messages would simply be "read-only variable is not
assignable"  This change provides more information about why the variable is
not assignable, as well as note to where the const is located.

Differential Revision: http://reviews.llvm.org/D4479

llvm-svn: 234677
2015-04-11 01:53:13 +00:00

11 lines
314 B
C++

// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
constexpr int x = 1; // expected-note {{variable 'x' declared const here}}
constexpr int id(int x) { return x; }
void foo(void) {
x = 2; // expected-error {{cannot assign to variable 'x' with const-qualified type 'const int'}}
int (*idp)(int) = id;
}