This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ patch] for C++/52369
- From: Fabien Chêne <fabien dot chene at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 27 Mar 2014 22:32:21 +0100
- Subject: Re: [C++ patch] for C++/52369
- Authentication-results: sourceware.org; auth=none
- References: <CAFH4-diup6eH5j3MhZcknAAia+6ZSyzwD5D94WV0NMa+otgjFg at mail dot gmail dot com> <CAFH4-dgpyn56MQN-7bXM9teA9tBWSFYbcsjiAG5TT53YU04XjA at mail dot gmail dot com> <530F8315 dot 5010703 at redhat dot com> <CAFH4-dgj=JNDHuy2gaW0G9VcdwgrLMiGQg1JHuJHdB-Fcb2SQQ at mail dot gmail dot com> <5310FF29 dot 6060102 at redhat dot com> <CAFH4-diMgdJBTGV=fRZaESLhR4aGR_i8zyL1j99-sKD5eJRFQg at mail dot gmail dot com> <CAFH4-djUxkPYoThf-Gxhf-ZxFkPdEphHYprcDDhBtvHt3PC-6w at mail dot gmail dot com> <5313D7EB dot 8080801 at redhat dot com> <CAFH4-djGxznKjqbd96taMQoypJwvrGCTOkcso3aazD8-pz1-xQ at mail dot gmail dot com> <5330698D dot 5010107 at redhat dot com>
Hi,
As a followup, the following patch homogeneise some diagnostics that
relate to uninitialized const or reference members.
Tested x86_64 linux in progress, OK to commit for next stage 1 if that
succeeds ? (or trunk otherwise, I dare to mention it).
2014-03-28 Fabien Chêne <fabien@gcc.gnu.org>
* cp/init.c (perform_member_init): homogeneize uninitialized
diagnostics.
2014-03-28 Fabien Chêne <fabien@gcc.gnu.org>
* g++.dg/init/ctor4.C: Adjust.
* g++.dg/init/ctor4-1.C: New.
2014-03-24 18:21 GMT+01:00 Jason Merrill <jason@redhat.com>:
> OK, thanks.
>
> Jason
--
Fabien
Index: gcc/testsuite/g++.dg/init/ctor4-1.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor4-1.C (rÃvision 0)
+++ gcc/testsuite/g++.dg/init/ctor4-1.C (rÃvision 0)
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+class foo {
+public:
+ foo();
+};
+
+class bar: public foo { // { dg-error "uninitialized" }
+ // { dg-message "implicitly deleted" "" { target c++11 } 8 }
+private:
+ int const a; // { dg-message "should be initialized" }
+};
+
+foo::foo() {
+}
+
+int main(int argc, char **argv)
+{
+ bar x; // { dg-error "deleted" "" { target c++11 } }
+ // { dg-message "synthesized" "" { target { ! c++11 } } 19 }
+}
Index: gcc/testsuite/g++.dg/init/ctor4.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor4.C (rÃvision 208853)
+++ gcc/testsuite/g++.dg/init/ctor4.C (copie de travail)
@@ -6,9 +6,10 @@ public:
foo();
};
-class bar: public foo { // { dg-error "reference|bar::bar" }
+class bar: public foo { // { dg-error "uninitialized" }
+ // { dg-message "implicitly deleted" "" { target c++11 } 9 }
private:
- int &a;
+ int &a; // { dg-message "should be initialized" }
};
foo::foo() {
@@ -16,5 +17,6 @@ foo::foo() {
int main(int argc, char **argv)
{
- bar x; // { dg-message "synthesized|deleted" }
+ bar x; // { dg-error "deleted" "" { target c++11 } }
+ // { dg-message "synthesized" "" { target { ! c++11 } } 20 }
}
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c (rÃvision 208854)
+++ gcc/cp/init.c (copie de travail)
@@ -710,13 +710,19 @@ perform_member_init (tree member, tree i
tree core_type;
/* member traversal: note it leaves init NULL */
if (TREE_CODE (type) == REFERENCE_TYPE)
- permerror (DECL_SOURCE_LOCATION (current_function_decl),
- "uninitialized reference member %qD",
- member);
+ {
+ permerror (DECL_SOURCE_LOCATION (current_function_decl),
+ "uninitialized reference member in %q#T", type);
+ inform (DECL_SOURCE_LOCATION (member),
+ "%q#D should be initialized", member);
+ }
else if (CP_TYPE_CONST_P (type))
- permerror (DECL_SOURCE_LOCATION (current_function_decl),
- "uninitialized member %qD with %<const%> type %qT",
- member, type);
+ {
+ permerror (DECL_SOURCE_LOCATION (current_function_decl),
+ "uninitialized const member in %q#T", type);
+ inform (DECL_SOURCE_LOCATION (member),
+ "%q#D should be initialized", member );
+ }
core_type = strip_array_types (type);