// Diagnose any ignored type attributes.
if (!T.isNull()) state.diagnoseIgnoredTypeAttrs(T);
- // If there's a constexpr specifier, treat it as a top-level const.
- if (D.getDeclSpec().isConstexprSpecified()) {
+ // C++0x [dcl.constexpr]p9:
+ // A constexpr specifier used in an object declaration declares the object
+ // as const.
+ if (D.getDeclSpec().isConstexprSpecified() && T->isObjectType()) {
T.addConst();
}
--- /dev/null
+// 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;
+}
+