diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-03-20 08:06:45 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-03-20 08:06:45 +0000 |
commit | 148f1f7936afd718bac7be95089e77673e43f16f (patch) | |
tree | 22f5d2c0957ba688ddebf3dc105e56ca0609e662 /test/SemaCXX/cxx0x-constexpr-const.cpp | |
parent | eedd4670b2eb7e4d67d11b2f26ed1ad304b70596 (diff) |
Only objects are declared const by a constexpr specifier, per C++0x [dcl.constexpr]p9
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx0x-constexpr-const.cpp')
-rw-r--r-- | test/SemaCXX/cxx0x-constexpr-const.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-constexpr-const.cpp b/test/SemaCXX/cxx0x-constexpr-const.cpp new file mode 100644 index 0000000000..79e6dda3e1 --- /dev/null +++ b/test/SemaCXX/cxx0x-constexpr-const.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +constexpr int x = 1; +constexpr int id(int x) { return x; } + +void foo(void) { + x = 2; // expected-error {{read-only variable is not assignable}} + int (*idp)(int) = id; +} + |