+2019-04-26 Jonathan Wakely <jwakely@redhat.com>
+
+ PR c++/90243 - orphaned note in uninstantiated constexpr function
+ * decl.c (check_for_uninitialized_const_var): Suppress notes if no
+ error was shown.
+
2019-04-26 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90173
if (!field)
return true;
+ bool show_notes = true;
+
if (!constexpr_context_p)
{
if (CP_TYPE_CONST_P (type))
{
if (complain & tf_error)
- permerror (DECL_SOURCE_LOCATION (decl),
- "uninitialized const %qD", decl);
+ show_notes = permerror (DECL_SOURCE_LOCATION (decl),
+ "uninitialized const %qD", decl);
}
else
{
error_at (DECL_SOURCE_LOCATION (decl),
"uninitialized variable %qD in %<constexpr%> "
"function", decl);
+ else
+ show_notes = false;
cp_function_chain->invalid_constexpr = true;
}
}
"uninitialized variable %qD in %<constexpr%> context",
decl);
- if (CLASS_TYPE_P (type) && (complain & tf_error))
+ if (show_notes && CLASS_TYPE_P (type) && (complain & tf_error))
{
tree defaulted_ctor;
--- /dev/null
+// { dg-do compile { target c++14 } }
+struct Z { // { dg-bogus "default constructor" }
+ int y; // { dg-bogus "initialize" }
+};
+
+template <class T>
+constexpr Z f(const T *data) {
+ Z z;
+ __builtin_memcpy(&z, data, sizeof(z));
+ return z;
+}
+
+constexpr Z g(const char *data) { return f(data); }