These patches fix several issues I found by switching the C++ dialect
default to C++11.
The first patch fixes obj-c++.dg/encode-10.mm: When
build_non_dependent_expr tries to get a constant value for a
non-dependent expression, we need to know that AT_ENCODE_EXPR can't be a
constant expression.
The second patch fixes the GDB test gdb.cp/anon-struct.cc. In C++11
mode we declare the default constructor before we see the typedef which
gives the anonymous struct a name for linkage purposes, and as a result
the DWARF output for the constructor had no name. The patch causes us
to ignore the constructor if we see it before it has a name, and update
the name of the constructor when the type gets one.
The third patch fixes g++.dg/torture/Wsizeof-memaccess2.C. We shouldn't
emit those warnings when we're in SFINAE mode.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 3e0151efa351acdbb0a294a5d9c36b187c798d19
Author: Jason Merrill <ja...@redhat.com>
Date: Tue May 5 20:55:56 2015 -0500
Fix obj-c++.dg/encode-10.mm with cxx_dialect == cxx11.
* constexpr.c (potential_constant_expression_1) [AT_ENCODE_EXPR]:
Return false.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 9ebb640..f35ec1e 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4159,6 +4159,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
case OBJ_TYPE_REF:
case TRANSACTION_EXPR:
case ASM_EXPR:
+ case AT_ENCODE_EXPR:
fail:
if (flags & tf_error)
error ("expression %qE is not a constant-expression", t);
commit 2d097581fbd5c0e3de866d879f2296d68753caff
Author: Jason Merrill <ja...@redhat.com>
Date: Tue May 5 20:52:13 2015 -0500
Fix gdb.cp/anon-struct.cc with -std=c++11.
gcc/
* dwarf2out.c (gen_member_die): Don't emit anything for an
anonymous class constructor.
gcc/cp/
* decl2.c (reset_type_linkage_2): Update the DECL_NAME of a
maybe-in-charge constructor.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b2251d8..0d47847 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2648,7 +2648,12 @@ reset_type_linkage_2 (tree type)
if (TREE_CODE (m) == VAR_DECL)
reset_decl_linkage (m);
for (tree m = TYPE_METHODS (type); m; m = DECL_CHAIN (m))
- reset_decl_linkage (m);
+ {
+ reset_decl_linkage (m);
+ if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (m))
+ /* Also update its name, for cxx_dwarf_name. */
+ DECL_NAME (m) = TYPE_IDENTIFIER (type);
+ }
binding_table_foreach (CLASSTYPE_NESTED_UTDS (type),
bt_reset_linkage_2, NULL);
}
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ddca2a8..cb2656c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19951,6 +19951,10 @@ gen_member_die (tree type, dw_die_ref context_die)
/* Don't include clones in the member list. */
if (DECL_ABSTRACT_ORIGIN (member))
continue;
+ /* Nor constructors for anonymous classes. */
+ if (DECL_ARTIFICIAL (member)
+ && dwarf2_name (member, 0) == NULL)
+ continue;
child = lookup_decl_die (member);
if (child)
commit 2fe1e2823adecf5b62248f996391b787e4b62926
Author: Jason Merrill <ja...@redhat.com>
Date: Tue May 5 20:55:00 2015 -0500
Fix g++.dg/torture/Wsizeof-pointer-memaccess2.C with -std=c++11
* semantics.c (finish_call_expr): Check complain.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0fc08b5f..701a8eb 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2377,6 +2377,7 @@ finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual,
if (!result)
{
if (warn_sizeof_pointer_memaccess
+ && (complain & tf_warning)
&& !vec_safe_is_empty (*args)
&& !processing_template_decl)
{