@@ -9652,8 +9652,11 @@ grokdeclarator (const cp_declarator *declarator,
else
{
if (constexpr_p)
- error ("non-static data member %qE declared %<constexpr%>",
- unqualified_id);
+ {
+ error ("non-static data member %qE declared %<constexpr%>",
+ unqualified_id);
+ constexpr_p = false;
+ }
decl = build_decl (input_location,
FIELD_DECL, unqualified_id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
@@ -2698,8 +2698,11 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser,
template <typename T> struct B : public A<T> { X x; };
The user should have said "typename A<T>::X". */
- if (processing_template_decl && current_class_type
- && TYPE_BINFO (current_class_type))
+ if (cxx_dialect < cxx0x && id == ridpointers[(int)RID_CONSTEXPR])
+ inform (location, "C++0x %<constexpr%> only available with "
+ "-std=c++0x or -std=gnu++0x");
+ else if (processing_template_decl && current_class_type
+ && TYPE_BINFO (current_class_type))
{
tree b;
new file mode 100644
@@ -0,0 +1,4 @@
+// { dg-options "-std=c++98" }
+
+constexpr int i = 42; // { dg-message "std=c\\+\\+0x" }
+// { dg-error "constexpr" "" { target *-*-* } 3 }
new file mode 100644
@@ -0,0 +1,6 @@
+// { dg-options -std=c++0x }
+
+struct A
+{
+ constexpr int i; // { dg-error "" }
+};