static int
check_static_variable_definition (tree decl, tree type)
{
+ /* Avoid redundant diagnostics on out-of-class definitions. */
+ if (!current_class_type || !TYPE_BEING_DEFINED (current_class_type))
+ return 0;
/* Can't check yet if we don't know the type. */
if (dependent_type_p (type))
return 0;
else if (cxx_dialect >= cxx11 && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
{
if (!COMPLETE_TYPE_P (type))
- error ("in-class initialization of static data member %q#D of "
- "incomplete type", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "in-class initialization of static data member %q#D of "
+ "incomplete type", decl);
else if (literal_type_p (type))
- permerror (input_location,
+ permerror (DECL_SOURCE_LOCATION (decl),
"%<constexpr%> needed for in-class initialization of "
"static data member %q#D of non-integral type", decl);
else
- error ("in-class initialization of static data member %q#D of "
- "non-literal type", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "in-class initialization of static data member %q#D of "
+ "non-literal type", decl);
return 1;
}
required. */
if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE)
{
- error ("invalid in-class initialization of static data member "
- "of non-integral type %qT",
- type);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "invalid in-class initialization of static data member "
+ "of non-integral type %qT",
+ type);
return 1;
}
else if (!CP_TYPE_CONST_P (type))
- error ("ISO C++ forbids in-class initialization of non-const "
- "static member %qD",
- decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "ISO C++ forbids in-class initialization of non-const "
+ "static member %qD",
+ decl);
else if (!INTEGRAL_OR_ENUMERATION_TYPE_P (type))
- pedwarn (input_location, OPT_Wpedantic, "ISO C++ forbids initialization of member constant "
+ pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wpedantic,
+ "ISO C++ forbids initialization of member constant "
"%qD of non-integral type %qT", decl, type);
return 0;
+2016-05-31 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/71248
+ * g++.dg/cpp0x/pr71248.C: New.
+ * g++.dg/cpp0x/auto7.C: Test column numbers too.
+ * g++.dg/cpp0x/constexpr-static8.C: Likewise.
+ * g++.dg/init/new37.C: Likewise.
+ * g++.dg/template/static1.C: Likewise.
+ * g++.dg/template/static2.C: Likewise.
+
2016-05-31 H.J. Lu <hongjiu.lu@intel.com>
* gcc.target/i386/avx512vl-vbroadcast-3.c: Scan %\[re\]di