aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/Make-lang.in2
-rw-r--r--gcc/cp/mangle.c33
-rw-r--r--gcc/cp/method.c1
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle40.C25
-rw-r--r--gcc/testsuite/g++.dg/abi/mangle41.C7
7 files changed, 82 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 556c4ac..1b0b72b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2010-03-03 Jason Merrill <jason@redhat.com>
+
+ PR c++/12909
+ * mangle.c: Include cgraph.h.
+ (mangle_decl): If the mangled name will change in a later
+ ABI version, make the later mangled name an alias.
+ * method.c (make_alias_for): Copy DECL_ARGUMENTS.
+ * Make-lang.in (mangle.o): Depend on cgraph.h.
+
2010-03-01 Marco Poletti <poletti.marco@gmail.com>
* pt.c (redeclare_class_template): Use error_n and inform_n.
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index f6cb70f..1484063 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -308,7 +308,7 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h $(INTEGRATE_H) \
insn-config.h input.h $(PARAMS_H) debug.h $(TREE_INLINE_H) $(GIMPLE_H) \
$(TARGET_H) tree-iterator.h $(CGRAPH_H)
cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h $(REAL_H) \
- gt-cp-mangle.h $(TARGET_H) $(TM_P_H)
+ gt-cp-mangle.h $(TARGET_H) $(TM_P_H) $(CGRAPH_H)
cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_H) gt-cp-parser.h \
output.h $(TARGET_H) $(PLUGIN_H) intl.h
cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) toplev.h $(C_COMMON_H) \
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 6196ae2..9478092 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see
#include "varray.h"
#include "flags.h"
#include "target.h"
+#include "cgraph.h"
/* Debugging support. */
@@ -3055,6 +3056,38 @@ mangle_decl (const tree decl)
tree id = mangle_decl_string (decl);
id = targetm.mangle_decl_assembler_name (decl, id);
SET_DECL_ASSEMBLER_NAME (decl, id);
+
+#ifdef ASM_OUTPUT_DEF
+ if (G.need_abi_warning)
+ {
+ /* If the mangling will change in the future, emit an alias with the
+ future mangled name for forward-compatibility. */
+ int save_ver;
+ tree id2, alias;
+
+ SET_IDENTIFIER_GLOBAL_VALUE (id, decl);
+ if (IDENTIFIER_GLOBAL_VALUE (id) != decl)
+ inform (DECL_SOURCE_LOCATION (decl), "-fabi-version=4 (or =0) "
+ "avoids this error with a change in vector mangling");
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ return;
+
+ save_ver = flag_abi_version;
+ flag_abi_version = 0;
+ id2 = mangle_decl_string (decl);
+ id2 = targetm.mangle_decl_assembler_name (decl, id2);
+ flag_abi_version = save_ver;
+
+ alias = make_alias_for (decl, id2);
+ DECL_IGNORED_P (alias) = 1;
+ TREE_PUBLIC (alias) = TREE_PUBLIC (decl);
+ DECL_VISIBILITY (alias) = DECL_VISIBILITY (decl);
+ if (vague_linkage_fn_p (decl))
+ DECL_WEAK (alias) = 1;
+ cgraph_same_body_alias (alias, decl);
+ }
+#endif
}
/* Generate the mangled representation of TYPE. */
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index ccc977d..c25cedb 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -234,6 +234,7 @@ make_alias_for (tree function, tree newid)
DECL_TEMPLATE_INSTANTIATED (alias) = 0;
DECL_TEMPLATE_INFO (alias) = NULL;
DECL_INITIAL (alias) = error_mark_node;
+ DECL_ARGUMENTS (alias) = copy_list (DECL_ARGUMENTS (target));
TREE_ADDRESSABLE (alias) = 1;
TREE_USED (alias) = 1;
SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ba742fd..77aaf9c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-03 Jason Merrill <jason@redhat.com>
+
+ PR c++/12909
+ * g++.dg/abi/mangle40.C: New.
+ * g++.dg/abi/mangle41.C: New.
+
2010-03-03 Paul Thomas <pault@gcc.gnu.org>
PR fortran/43243
diff --git a/gcc/testsuite/g++.dg/abi/mangle40.C b/gcc/testsuite/g++.dg/abi/mangle40.C
new file mode 100644
index 0000000..1d604ef
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle40.C
@@ -0,0 +1,25 @@
+// PR c++/12909
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options "-mavx -Wabi -fabi-version=2" }
+// { dg-final { scan-assembler "weak\[^\n\]*_Z1fIDv4_fEvT_" } }
+// { dg-final { scan-assembler "weak\[^\n\]*_Z1fIU8__vectorfEvT_" } }
+// { dg-final { scan-assembler "weak\[^\n\]*_ZN1AIU8__vectorfE1tE" } }
+
+#include <x86intrin.h>
+
+template <class T>
+struct A
+{
+ static T t;
+};
+
+template <class T>
+T A<T>::t; // { dg-warning "mangled name" }
+
+template <class T>
+void f (T t) { } // { dg-warning "mangled name" }
+
+int main()
+{
+ f (A<__m128>::t);
+}
diff --git a/gcc/testsuite/g++.dg/abi/mangle41.C b/gcc/testsuite/g++.dg/abi/mangle41.C
new file mode 100644
index 0000000..3a9c04f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/mangle41.C
@@ -0,0 +1,7 @@
+// PR c++/41959
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options "-mavx -fabi-version=2" }
+
+#include <x86intrin.h>
+void f(__m128) { } // { dg-error "previous" }
+void f(__m256) { } // { dg-message "declaration|mangling" }