public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: call complete_type after performing auto deduction [PR80351]
@ 2022-03-24  1:01 Pokechu22
  2022-03-24 20:53 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Pokechu22 @ 2022-03-24  1:01 UTC (permalink / raw)
  To: gcc-patches

When cp_finish_decl calls cp_apply_type_quals_to_decl on a const auto or
constexpr auto variable, the type might not be complete the first time
(this happened when auto deduces to an initializer_list).
cp_apply_type_quals_to_decl removes the const qualifier if the type is
not complete, which is appropriate for grokdeclarator, on the assumption
that the type will be complete when called by cp_finish_decl.

Tested on x86_64 Ubuntu under WSL1 by bootstrapping and comparing results
from 24d51e749570dcb85bd43d3b528f58ad6141de26 with results from this
change.  As far as I can tell, this fixes Wunused-var-38.C and
Wunused-var-39.C without regressions.
(Wunused-var-37.C passed before this change.)

gcc/cp/ChangeLog:

    PR c++/80351
    * decl.cc (cp_finish_decl): Call complete_type after performing
    auto deduction.

gcc/testsuite/ChangeLog:

    PR c++/80351
    * g++.dg/warn/Wunused-var-37.C: New test.
    * g++.dg/warn/Wunused-var-38.C: New test.
    * g++.dg/warn/Wunused-var-39.C: New test.
---
 gcc/cp/decl.cc                             |  2 +-
 gcc/testsuite/g++.dg/warn/Wunused-var-37.C | 64 ++++++++++++++++++++++
 gcc/testsuite/g++.dg/warn/Wunused-var-38.C | 16 ++++++
 gcc/testsuite/g++.dg/warn/Wunused-var-39.C | 16 ++++++
 4 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-37.C
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-38.C
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-39.C

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 34d9dad9fb0..e382b8ad218 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8098,7 +8098,7 @@ cp_finish_decl (tree decl, tree init, bool
init_const_expr_p,
       TREE_TYPE (decl) = error_mark_node;
       return;
     }
-      cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
+      cp_apply_type_quals_to_decl (cp_type_quals (complete_type (type)), decl);
     }

   if (ensure_literal_type_for_constexpr_object (decl) == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-37.C
b/gcc/testsuite/g++.dg/warn/Wunused-var-37.C
new file mode 100644
index 00000000000..54e76ac4e11
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-37.C
@@ -0,0 +1,64 @@
+// Tangentially to PR c++/80351
+// { dg-do compile { target c++17 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+// Warnings:
+static int           int_s1  = 0; // { dg-warning "defined but not used" }
+static int           int_s2  = 0; // { dg-warning "defined but not used" }
+inline static int    int_is1 = 0; // { dg-warning "defined but not used" }
+inline static int    int_is2 = 0; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static int int_cs1 = 0; // { dg-bogus "defined but not used" }
+constexpr static int int_cs2 = 0; // { dg-bogus "defined but not used" }
+int                  int_1   = 0; // { dg-bogus "defined but not used" }
+int                  int_2   = 0; // { dg-bogus "defined but not used" }
+inline int           int_i1  = 0; // { dg-bogus "defined but not used" }
+inline int           int_i2  = 0; // { dg-bogus "defined but not used" }
+constexpr int        int_c1  = 0; // { dg-bogus "defined but not used" }
+constexpr int        int_c2  = 0; // { dg-bogus "defined but not used" }
+
+// Warnings:
+static auto           int_as1  = 0; // { dg-warning "defined but not used" }
+static auto           int_as2  = 0; // { dg-warning "defined but not used" }
+inline static auto    int_ais1 = 0; // { dg-warning "defined but not used" }
+inline static auto    int_ais2 = 0; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static auto int_acs1 = 0; // { dg-bogus "defined but not used" }
+constexpr static auto int_acs2 = 0; // { dg-bogus "defined but not used" }
+auto                  int_a1   = 0; // { dg-bogus "defined but not used" }
+auto                  int_a2   = 0; // { dg-bogus "defined but not used" }
+inline auto           int_ai1  = 0; // { dg-bogus "defined but not used" }
+inline auto           int_ai2  = 0; // { dg-bogus "defined but not used" }
+constexpr auto        int_ac1  = 0; // { dg-bogus "defined but not used" }
+constexpr auto        int_ac2  = 0; // { dg-bogus "defined but not used" }
+
+// Warnings:
+static std::initializer_list<int>           il_s1  = {0, 1}; // {
dg-warning "defined but not used" }
+static std::initializer_list<int>           il_s2  = {0, 1}; // {
dg-warning "defined but not used" }
+inline static std::initializer_list<int>    il_is1 = {0, 1}; // {
dg-warning "defined but not used" }
+inline static std::initializer_list<int>    il_is2 = {0, 1}; // {
dg-warning "defined but not used" }
+// No warnings:
+constexpr static std::initializer_list<int> il_cs1 = {0, 1}; // {
dg-bogus "defined but not used" }
+constexpr static std::initializer_list<int> il_cs2 = {0, 1}; // {
dg-bogus "defined but not used" }
+std::initializer_list<int>                  il_1   = {0, 1}; // {
dg-bogus "defined but not used" }
+std::initializer_list<int>                  il_2   = {0, 1}; // {
dg-bogus "defined but not used" }
+inline std::initializer_list<int>           il_i1  = {0, 1}; // {
dg-bogus "defined but not used" }
+inline std::initializer_list<int>           il_i2  = {0, 1}; // {
dg-bogus "defined but not used" }
+constexpr std::initializer_list<int>        il_c1  = {0, 1}; // {
dg-bogus "defined but not used" }
+constexpr std::initializer_list<int>        il_c2  = {0, 1}; // {
dg-bogus "defined but not used" }
+
+// Warnings:
+static auto           il_as1  = {0, 1}; // { dg-warning "defined but
not used" }
+static auto           il_as2  = {0, 1}; // { dg-warning "defined but
not used" }
+inline static auto    il_ais1 = {0, 1}; // { dg-warning "defined but
not used" }
+inline static auto    il_ais2 = {0, 1}; // { dg-warning "defined but
not used" }
+// No warnings:
+constexpr static auto il_acs1 = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr static auto il_acs2 = {0, 1}; // { dg-bogus "defined but not used" }
+auto                  il_a1   = {0, 1}; // { dg-bogus "defined but not used" }
+auto                  il_a2   = {0, 1}; // { dg-bogus "defined but not used" }
+inline auto           il_ai1  = {0, 1}; // { dg-bogus "defined but not used" }
+inline auto           il_ai2  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr auto        il_ac1  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr auto        il_ac2  = {0, 1}; // { dg-bogus "defined but not used" }
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-38.C
b/gcc/testsuite/g++.dg/warn/Wunused-var-38.C
new file mode 100644
index 00000000000..3d34bc8e8c1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-38.C
@@ -0,0 +1,16 @@
+// PR c++/80351
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+constexpr auto int_1 = 1; // { dg-bogus "defined but not used" }
+constexpr auto int_2 = 2; // { dg-bogus "defined but not used" }
+
+constexpr auto il_int_1 = {3, 3}; // { dg-bogus "defined but not
used" "Triggered by PR80351" }
+constexpr auto il_int_2 = {4, 4}; // { dg-bogus "defined but not
used" "Not triggered by PR80351" }
+
+constexpr auto il_uint_1 = {5u, 5u}; // { dg-bogus "defined but not
used" "Triggered by PR80351" }
+constexpr auto il_uint_2 = {6u, 6u}; // { dg-bogus "defined but not
used" "Not triggered by PR80351" }
+
+constexpr auto uint_1 = 7u; // { dg-bogus "defined but not used" }
+constexpr auto uint_2 = 8u; // { dg-bogus "defined but not used" }
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-39.C
b/gcc/testsuite/g++.dg/warn/Wunused-var-39.C
new file mode 100644
index 00000000000..d25a74c43c2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-39.C
@@ -0,0 +1,16 @@
+// PR c++/80351
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+const auto int_1 = 1; // { dg-bogus "defined but not used" }
+const auto int_2 = 2; // { dg-bogus "defined but not used" }
+
+const auto il_int_1 = {3, 3}; // { dg-bogus "defined but not used"
"Triggered by PR80351" }
+const auto il_int_2 = {4, 4}; // { dg-bogus "defined but not used"
"Not triggered by PR80351" }
+
+const auto il_uint_1 = {5u, 5u}; // { dg-bogus "defined but not used"
"Triggered by PR80351" }
+const auto il_uint_2 = {6u, 6u}; // { dg-bogus "defined but not used"
"Not triggered by PR80351" }
+
+const auto uint_1 = 7u; // { dg-bogus "defined but not used" }
+const auto uint_2 = 8u; // { dg-bogus "defined but not used" }
-- 
2.25.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: call complete_type after performing auto deduction [PR80351]
  2022-03-24  1:01 [PATCH] c++: call complete_type after performing auto deduction [PR80351] Pokechu22
@ 2022-03-24 20:53 ` Jason Merrill
  2022-03-29  6:02   ` Pokechu22
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2022-03-24 20:53 UTC (permalink / raw)
  To: Pokechu22, gcc-patches

On 3/23/22 21:01, Pokechu22 via Gcc-patches wrote:
> When cp_finish_decl calls cp_apply_type_quals_to_decl on a const auto or
> constexpr auto variable, the type might not be complete the first time
> (this happened when auto deduces to an initializer_list).
> cp_apply_type_quals_to_decl removes the const qualifier if the type is
> not complete, which is appropriate for grokdeclarator, on the assumption
> that the type will be complete when called by cp_finish_decl.
> 
> Tested on x86_64 Ubuntu under WSL1 by bootstrapping and comparing results
> from 24d51e749570dcb85bd43d3b528f58ad6141de26 with results from this
> change.  As far as I can tell, this fixes Wunused-var-38.C and
> Wunused-var-39.C without regressions.
> (Wunused-var-37.C passed before this change.)

Thanks!  For future reference, the patch doesn't apply easily because 
gmail wrapped lines; for sending patches via gmail you'll need to use 
attachments.  Or you can use another MUA, or git send-email.  This time 
I fixed the wrapping by hand, but that's a pain (especially since 
there's no "try again" flag to git am).

Also, like other DCO projects, we can't normally accept pseudonymous 
contributions.  But as you say in the PR, this patch is trivial enough 
that I'm content to apply it myself; I want to make some adjustments anyway.

Currently GCC 12 development is in the regression fixes only stage, so 
I'll queue this for GCC 13.

Thanks again,
Jason


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: call complete_type after performing auto deduction [PR80351]
  2022-03-24 20:53 ` Jason Merrill
@ 2022-03-29  6:02   ` Pokechu22
  2022-03-30  3:56     ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Pokechu22 @ 2022-03-29  6:02 UTC (permalink / raw)
  To: Jason Merrill, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

On Thu, Mar 24, 2022 at 1:53 PM Jason Merrill <jason@redhat.com> wrote:
> Thanks!  For future reference, the patch doesn't apply easily because
> gmail wrapped lines; for sending patches via gmail you'll need to use
> attachments.  Or you can use another MUA, or git send-email.  This time
> I fixed the wrapping by hand, but that's a pain (especially since
> there's no "try again" flag to git am).

Thanks.  I was vaguely aware that gmail did something wrong, but I
thought that enabling plain-text mode was enough to work around it.
It might be useful to add that information to the contributing
webpage.  I've attached a copy of the patch here in case anyone else
wants to test it without dealing with the mangling.

Out of curiosity, do you know if this issue could have impacted
anything beyond the false warning?  I had previously determined that
ensure_literal_type_for_constexpr_object completes the type, so for
constexpr variables it wouldn't have caused any further issues, but I
discovered that regular const variables were also affected later on
(and possibly other unused variables could be affected, but non-const
ones would trigger the warning normally).

> Also, like other DCO projects, we can't normally accept pseudonymous
> contributions.  But as you say in the PR, this patch is trivial enough
> that I'm content to apply it myself; I want to make some adjustments anyway.

Also out of curiosity, what do you want to adjust with it?  I'd like
to know in case it's relevant for any other patch that I submit
(though there probably won't be a situation where I'm writing another
patch for a while).

Lastly, I'd appreciate my pseudonym being credited (at least as a
co-author) in the final patch, but I get that the patch being trivial
enough that no credit is needed is why it's possible for it to be
submitted pseudonymously in the first place, so if there's a policy
that prohibits doing so that's fine.  The more important thing is that
the bug gets fixed :)

--Poke

> Currently GCC 12 development is in the regression fixes only stage, so
> I'll queue this for GCC 13.
>
> Thanks again,
> Jason
>

[-- Attachment #2: 0001-c-call-complete_type-after-performing-auto-deduction.patch --]
[-- Type: application/octet-stream, Size: 8752 bytes --]

From 07c53a1ec6c517dfe95ee94cf7e1ad965150d578 Mon Sep 17 00:00:00 2001
From: Pokechu22 <Pokechu022@gmail.com>
Date: Mon, 21 Mar 2022 22:00:07 -0700
Subject: [PATCH] c++: call complete_type after performing auto deduction
 [PR80351]

When cp_finish_decl calls cp_apply_type_quals_to_decl on a const auto or
constexpr auto variable, the type might not be complete the first time
(this happened when auto deduces to an initializer_list).
cp_apply_type_quals_to_decl removes the const qualifier if the type is
not complete, which is appropriate for grokdeclarator, on the assumption
that the type will be complete when called by cp_finish_decl.

Tested on x86_64 Ubuntu under WSL1 by bootstrapping and comparing results
from 24d51e749570dcb85bd43d3b528f58ad6141de26 with results from this
change.  As far as I can tell, this fixes Wunused-var-38.C and
Wunused-var-39.C without regressions.
(Wunused-var-37.C passed before this change.)

gcc/cp/ChangeLog:

	PR c++/80351
	* decl.cc (cp_finish_decl): Call complete_type after performing
	auto deduction.

gcc/testsuite/ChangeLog:

	PR c++/80351
	* g++.dg/warn/Wunused-var-37.C: New test.
	* g++.dg/warn/Wunused-var-38.C: New test.
	* g++.dg/warn/Wunused-var-39.C: New test.
---
 gcc/cp/decl.cc                             |  2 +-
 gcc/testsuite/g++.dg/warn/Wunused-var-37.C | 64 ++++++++++++++++++++++
 gcc/testsuite/g++.dg/warn/Wunused-var-38.C | 16 ++++++
 gcc/testsuite/g++.dg/warn/Wunused-var-39.C | 16 ++++++
 4 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-37.C
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-38.C
 create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-var-39.C

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 34d9dad9fb0..e382b8ad218 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -8098,7 +8098,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	  TREE_TYPE (decl) = error_mark_node;
 	  return;
 	}
-      cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
+      cp_apply_type_quals_to_decl (cp_type_quals (complete_type (type)), decl);
     }
 
   if (ensure_literal_type_for_constexpr_object (decl) == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-37.C b/gcc/testsuite/g++.dg/warn/Wunused-var-37.C
new file mode 100644
index 00000000000..54e76ac4e11
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-37.C
@@ -0,0 +1,64 @@
+// Tangentially to PR c++/80351
+// { dg-do compile { target c++17 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+// Warnings:
+static int           int_s1  = 0; // { dg-warning "defined but not used" }
+static int           int_s2  = 0; // { dg-warning "defined but not used" }
+inline static int    int_is1 = 0; // { dg-warning "defined but not used" }
+inline static int    int_is2 = 0; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static int int_cs1 = 0; // { dg-bogus "defined but not used" }
+constexpr static int int_cs2 = 0; // { dg-bogus "defined but not used" }
+int                  int_1   = 0; // { dg-bogus "defined but not used" }
+int                  int_2   = 0; // { dg-bogus "defined but not used" }
+inline int           int_i1  = 0; // { dg-bogus "defined but not used" }
+inline int           int_i2  = 0; // { dg-bogus "defined but not used" }
+constexpr int        int_c1  = 0; // { dg-bogus "defined but not used" }
+constexpr int        int_c2  = 0; // { dg-bogus "defined but not used" }
+
+// Warnings:
+static auto           int_as1  = 0; // { dg-warning "defined but not used" }
+static auto           int_as2  = 0; // { dg-warning "defined but not used" }
+inline static auto    int_ais1 = 0; // { dg-warning "defined but not used" }
+inline static auto    int_ais2 = 0; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static auto int_acs1 = 0; // { dg-bogus "defined but not used" }
+constexpr static auto int_acs2 = 0; // { dg-bogus "defined but not used" }
+auto                  int_a1   = 0; // { dg-bogus "defined but not used" }
+auto                  int_a2   = 0; // { dg-bogus "defined but not used" }
+inline auto           int_ai1  = 0; // { dg-bogus "defined but not used" }
+inline auto           int_ai2  = 0; // { dg-bogus "defined but not used" }
+constexpr auto        int_ac1  = 0; // { dg-bogus "defined but not used" }
+constexpr auto        int_ac2  = 0; // { dg-bogus "defined but not used" }
+
+// Warnings:
+static std::initializer_list<int>           il_s1  = {0, 1}; // { dg-warning "defined but not used" }
+static std::initializer_list<int>           il_s2  = {0, 1}; // { dg-warning "defined but not used" }
+inline static std::initializer_list<int>    il_is1 = {0, 1}; // { dg-warning "defined but not used" }
+inline static std::initializer_list<int>    il_is2 = {0, 1}; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static std::initializer_list<int> il_cs1 = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr static std::initializer_list<int> il_cs2 = {0, 1}; // { dg-bogus "defined but not used" }
+std::initializer_list<int>                  il_1   = {0, 1}; // { dg-bogus "defined but not used" }
+std::initializer_list<int>                  il_2   = {0, 1}; // { dg-bogus "defined but not used" }
+inline std::initializer_list<int>           il_i1  = {0, 1}; // { dg-bogus "defined but not used" }
+inline std::initializer_list<int>           il_i2  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr std::initializer_list<int>        il_c1  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr std::initializer_list<int>        il_c2  = {0, 1}; // { dg-bogus "defined but not used" }
+
+// Warnings:
+static auto           il_as1  = {0, 1}; // { dg-warning "defined but not used" }
+static auto           il_as2  = {0, 1}; // { dg-warning "defined but not used" }
+inline static auto    il_ais1 = {0, 1}; // { dg-warning "defined but not used" }
+inline static auto    il_ais2 = {0, 1}; // { dg-warning "defined but not used" }
+// No warnings:
+constexpr static auto il_acs1 = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr static auto il_acs2 = {0, 1}; // { dg-bogus "defined but not used" }
+auto                  il_a1   = {0, 1}; // { dg-bogus "defined but not used" }
+auto                  il_a2   = {0, 1}; // { dg-bogus "defined but not used" }
+inline auto           il_ai1  = {0, 1}; // { dg-bogus "defined but not used" }
+inline auto           il_ai2  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr auto        il_ac1  = {0, 1}; // { dg-bogus "defined but not used" }
+constexpr auto        il_ac2  = {0, 1}; // { dg-bogus "defined but not used" }
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-38.C b/gcc/testsuite/g++.dg/warn/Wunused-var-38.C
new file mode 100644
index 00000000000..3d34bc8e8c1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-38.C
@@ -0,0 +1,16 @@
+// PR c++/80351
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+constexpr auto int_1 = 1; // { dg-bogus "defined but not used" }
+constexpr auto int_2 = 2; // { dg-bogus "defined but not used" }
+
+constexpr auto il_int_1 = {3, 3}; // { dg-bogus "defined but not used" "Triggered by PR80351" }
+constexpr auto il_int_2 = {4, 4}; // { dg-bogus "defined but not used" "Not triggered by PR80351" }
+
+constexpr auto il_uint_1 = {5u, 5u}; // { dg-bogus "defined but not used" "Triggered by PR80351" }
+constexpr auto il_uint_2 = {6u, 6u}; // { dg-bogus "defined but not used" "Not triggered by PR80351" }
+
+constexpr auto uint_1 = 7u; // { dg-bogus "defined but not used" }
+constexpr auto uint_2 = 8u; // { dg-bogus "defined but not used" }
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-39.C b/gcc/testsuite/g++.dg/warn/Wunused-var-39.C
new file mode 100644
index 00000000000..d25a74c43c2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-var-39.C
@@ -0,0 +1,16 @@
+// PR c++/80351
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+#include <initializer_list>
+
+const auto int_1 = 1; // { dg-bogus "defined but not used" }
+const auto int_2 = 2; // { dg-bogus "defined but not used" }
+
+const auto il_int_1 = {3, 3}; // { dg-bogus "defined but not used" "Triggered by PR80351" }
+const auto il_int_2 = {4, 4}; // { dg-bogus "defined but not used" "Not triggered by PR80351" }
+
+const auto il_uint_1 = {5u, 5u}; // { dg-bogus "defined but not used" "Triggered by PR80351" }
+const auto il_uint_2 = {6u, 6u}; // { dg-bogus "defined but not used" "Not triggered by PR80351" }
+
+const auto uint_1 = 7u; // { dg-bogus "defined but not used" }
+const auto uint_2 = 8u; // { dg-bogus "defined but not used" }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] c++: call complete_type after performing auto deduction [PR80351]
  2022-03-29  6:02   ` Pokechu22
@ 2022-03-30  3:56     ` Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2022-03-30  3:56 UTC (permalink / raw)
  To: Pokechu22, gcc-patches

On 3/29/22 02:02, Pokechu22 wrote:
> On Thu, Mar 24, 2022 at 1:53 PM Jason Merrill <jason@redhat.com> wrote:
>> Thanks!  For future reference, the patch doesn't apply easily because
>> gmail wrapped lines; for sending patches via gmail you'll need to use
>> attachments.  Or you can use another MUA, or git send-email.  This time
>> I fixed the wrapping by hand, but that's a pain (especially since
>> there's no "try again" flag to git am).
> 
> Thanks.  I was vaguely aware that gmail did something wrong, but I
> thought that enabling plain-text mode was enough to work around it.
> It might be useful to add that information to the contributing
> webpage.  I've attached a copy of the patch here in case anyone else
> wants to test it without dealing with the mangling.
> 
> Out of curiosity, do you know if this issue could have impacted
> anything beyond the false warning?  I had previously determined that
> ensure_literal_type_for_constexpr_object completes the type, so for
> constexpr variables it wouldn't have caused any further issues, but I
> discovered that regular const variables were also affected later on
> (and possibly other unused variables could be affected, but non-const
> ones would trigger the warning normally).

It also affects whether the variable goes into .data or .rodata.  For

> #include <initializer_list>
> const auto x = { 1, 2 };

without the change, x goes into .data; after the change it goes in .rodata.

>> Also, like other DCO projects, we can't normally accept pseudonymous
>> contributions.  But as you say in the PR, this patch is trivial enough
>> that I'm content to apply it myself; I want to make some adjustments anyway.
> 
> Also out of curiosity, what do you want to adjust with it?  I'd like
> to know in case it's relevant for any other patch that I submit
> (though there probably won't be a situation where I'm writing another
> patch for a while).

I'm adding a diagnostic if the deduced type remains incomplete, not 
anything more generally relevant.

> Lastly, I'd appreciate my pseudonym being credited (at least as a
> co-author) in the final patch,

Yes, that was my plan.

Jason


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-30  3:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24  1:01 [PATCH] c++: call complete_type after performing auto deduction [PR80351] Pokechu22
2022-03-24 20:53 ` Jason Merrill
2022-03-29  6:02   ` Pokechu22
2022-03-30  3:56     ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).