aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-04-26 17:33:02 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-04-26 17:33:02 +0100
commit57e617640d6ae8f197501345f07a49a376d28a48 (patch)
tree88503845acf8055975cee2c6ce98374afaa7a15a /gcc/cp/decl.c
parent700e6332a7fed75fca4515e24263492ff7a83344 (diff)
downloadgcc-57e617640d6ae8f197501345f07a49a376d28a48.zip
gcc-57e617640d6ae8f197501345f07a49a376d28a48.tar.gz
gcc-57e617640d6ae8f197501345f07a49a376d28a48.tar.bz2
PR c++/90243 - orphaned note in uninstantiated constexpr function
gcc/cp: PR c++/90243 - orphaned note in uninstantiated constexpr function * decl.c (check_for_uninitialized_const_var): Suppress notes if no error was shown. gcc/testsuite: PR c++/90243 * g++.dg/diagnostic/pr90243.C: New test. From-SVN: r270610
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ca21cbb..20a6e2e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5691,13 +5691,15 @@ check_for_uninitialized_const_var (tree decl, bool constexpr_context_p,
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
{
@@ -5706,6 +5708,8 @@ check_for_uninitialized_const_var (tree decl, bool constexpr_context_p,
error_at (DECL_SOURCE_LOCATION (decl),
"uninitialized variable %qD in %<constexpr%> "
"function", decl);
+ else
+ show_notes = false;
cp_function_chain->invalid_constexpr = true;
}
}
@@ -5714,7 +5718,7 @@ check_for_uninitialized_const_var (tree decl, bool constexpr_context_p,
"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;