This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Change default ABI version to 2
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: bzoz at redhat dot com
- Date: Tue, 23 Dec 2003 08:49:19 -0800
- Subject: C++ PATCH: Change default ABI version to 2
- Reply-to: mark at codesourcery dot com
This patch changes the default C++ ABI version to "2" from "1".
There was no real objection to that change, after some discussion,
about a month ago. Per Benjamin's request, the __GXX_ABI_VERSION
macro now reflects the ABI version. Yes, I know that sounds
tautological -- but until now, it did not.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-12-23 Mark Mitchell <mark@codesourcery.com>
* c-common.c (flag_abi_version): Default to 2.
* c-cppbuiltin.c (c_cpp_builtins): Define __GXX_ABI_VERSION
uniformly for versions above 2.
* doc/invoke.texi: Update documentation for -fabi-version.
2003-12-23 Mark Mitchell <mark@codesourcery.com>
* cp-lang.c (cp_expr_size): Return zero for empty classes.
* cp-tree.h (warn_if_uknown_interface): Remove unused function.
* decl2.c (warn_if_unknown_interface): Likewise.
2003-12-23 Mark Mitchell <mark@codesourcery.com>
* g++.dg/abi/macro0.C: New test.
* g++.dg/abi/macro1.C: Likewise.
* g++.dg/abi/macro2.C: Likewise.
* g++.dg/abi/bitfield5.C: Add explicit -fabi-version=1 option.
* g++.dg/abi/bitfield7.C: Likewise.
* g++.dg/abi/dtor2.C: Likewise.
* g++.dg/abi/mangle11.C: Likewise.
* g++.dg/abi/mangle12.C: Likewise.
* g++.dg/abi/mangle14.C: Likewise.
* g++.dg/abi/mangle17.C: Likewise.
* g++.dg/abi/vbase10.C: Likewise.
* g++.dg/abi/vbase14.C: Likewise.
* g++.dg/template/qualttp17.C: Likewise.
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.470
diff -c -5 -p -r1.470 c-common.c
*** c-common.c 22 Dec 2003 23:57:02 -0000 1.470
--- c-common.c 23 Dec 2003 16:45:05 -0000
*************** int flag_enforce_eh_specs = 1;
*** 607,620 ****
discovered and fixed. Therefore, 0 will not necessarily
indicate the same ABI in different versions of G++.
1: The version of the ABI first used in G++ 3.2.
Additional positive integers will be assigned as new versions of
the ABI become the default version of the ABI. */
! int flag_abi_version = 1;
/* Nonzero means warn about things that will change when compiling
with an ABI-compliant compiler. */
int warn_abi = 0;
--- 607,622 ----
discovered and fixed. Therefore, 0 will not necessarily
indicate the same ABI in different versions of G++.
1: The version of the ABI first used in G++ 3.2.
+ 2: The version of the ABI first used in G++ 3.4.
+
Additional positive integers will be assigned as new versions of
the ABI become the default version of the ABI. */
! int flag_abi_version = 2;
/* Nonzero means warn about things that will change when compiling
with an ABI-compliant compiler. */
int warn_abi = 0;
Index: c-cppbuiltin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-cppbuiltin.c,v
retrieving revision 1.14
diff -c -5 -p -r1.14 c-cppbuiltin.c
*** c-cppbuiltin.c 6 Oct 2003 22:47:17 -0000 1.14
--- c-cppbuiltin.c 23 Dec 2003 16:45:05 -0000
*************** c_cpp_builtins (cpp_reader *pfile)
*** 308,318 ****
if (flag_exceptions)
cpp_define (pfile, "__EXCEPTIONS");
/* represents the C++ ABI version, always defined so it can be used while
preprocessing C and assembler. */
! cpp_define (pfile, "__GXX_ABI_VERSION=102");
/* libgcc needs to know this. */
if (USING_SJLJ_EXCEPTIONS)
cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");
--- 308,334 ----
if (flag_exceptions)
cpp_define (pfile, "__EXCEPTIONS");
/* represents the C++ ABI version, always defined so it can be used while
preprocessing C and assembler. */
! if (flag_abi_version == 0)
! /* Use a very large value so that:
!
! #if __GXX_ABI_VERSION >= <value for version X>
!
! will work whether the user explicitly says "-fabi-version=x" or
! "-fabi-version=0". Do not use INT_MAX because that will be
! different from system to system. */
! builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999);
! else if (flag_abi_version == 1)
! /* Due to an historical accident, this version had the value
! "102". */
! builtin_define_with_int_value ("__GXX_ABI_VERSION", 102);
! else
! /* Newer versions have values 1002, 1003, ... */
! builtin_define_with_int_value ("__GXX_ABI_VERSION",
! 1000 + flag_abi_version);
/* libgcc needs to know this. */
if (USING_SJLJ_EXCEPTIONS)
cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");
Index: cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.69
diff -c -5 -p -r1.69 cp-lang.c
*** cp/cp-lang.c 22 Dec 2003 20:42:57 -0000 1.69
--- cp/cp-lang.c 23 Dec 2003 16:45:06 -0000
*************** cp_expr_size (tree exp)
*** 344,354 ****
/* But storing a CONSTRUCTOR isn't a copy. */
&& TREE_CODE (exp) != CONSTRUCTOR)
abort ();
/* This would be wrong for a type with virtual bases, but they are
caught by the abort above. */
! return CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp));
}
else
/* Use the default code. */
return lhd_expr_size (exp);
}
--- 344,356 ----
/* But storing a CONSTRUCTOR isn't a copy. */
&& TREE_CODE (exp) != CONSTRUCTOR)
abort ();
/* This would be wrong for a type with virtual bases, but they are
caught by the abort above. */
! return (is_empty_class (TREE_TYPE (exp))
! ? size_zero_node
! : CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp)));
}
else
/* Use the default code. */
return lhd_expr_size (exp);
}
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.943
diff -c -5 -p -r1.943 cp-tree.h
*** cp/cp-tree.h 22 Dec 2003 20:42:57 -0000 1.943
--- cp/cp-tree.h 23 Dec 2003 16:45:06 -0000
*************** extern bool have_extern_spec;
*** 3708,3718 ****
extern GTY(()) tree last_function_parms;
/* in decl2.c */
extern bool check_java_method (tree);
extern int grok_method_quals (tree, tree, tree);
- extern void warn_if_unknown_interface (tree);
extern void grok_x_components (tree);
extern void maybe_retrofit_in_chrg (tree);
extern void maybe_make_one_only (tree);
extern void grokclassfn (tree, tree, enum overload_flags, tree);
extern tree grok_array_decl (tree, tree);
--- 3708,3717 ----
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.692
diff -c -5 -p -r1.692 decl2.c
*** cp/decl2.c 22 Dec 2003 23:57:06 -0000 1.692
--- cp/decl2.c 23 Dec 2003 16:45:06 -0000
*************** grok_method_quals (tree ctype, tree func
*** 154,178 ****
TREE_TYPE (function) = fntype;
return this_quals;
}
- /* Warn when -fexternal-templates is used and #pragma
- interface/implementation is not used all the times it should be,
- inform the user. */
-
- void
- warn_if_unknown_interface (tree decl)
- {
- static int already_warned = 0;
- if (already_warned++)
- return;
-
- cp_warning_at ("template `%#D' defined in file without #pragma interface",
- decl);
- }
-
/* A subroutine of the parser, to handle a component list. */
void
grok_x_components (tree specs)
{
--- 154,163 ----
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.371
diff -c -5 -p -r1.371 invoke.texi
*** doc/invoke.texi 23 Dec 2003 00:28:04 -0000 1.371
--- doc/invoke.texi 23 Dec 2003 16:45:07 -0000
*************** Here is a list of options that are @emph
*** 1272,1286 ****
@table @gcctabopt
@item -fabi-version=@var{n}
@opindex fabi-version
! Use version @var{n} of the C++ ABI. Version 1 is the version of the C++
! ABI that first appeared in G++ 3.2. Version 0 will always be the
! version that conforms most closely to the C++ ABI specification.
! Therefore, the ABI obtained using version 0 will change as ABI bugs are
! fixed.
The default is version 1.
@item -fno-access-control
@opindex fno-access-control
--- 1272,1287 ----
@table @gcctabopt
@item -fabi-version=@var{n}
@opindex fabi-version
! Use version @var{n} of the C++ ABI. Version 2 is the version of the
! C++ ABI that first appeared in G++ 3.4. Version 1 is the version of
! the C++ ABI that first appeared in G++ 3.2. Version 0 will always be
! the version that conforms most closely to the C++ ABI specification.
! Therefore, the ABI obtained using version 0 will change as ABI bugs
! are fixed.
The default is version 1.
@item -fno-access-control
@opindex fno-access-control
Index: testsuite/g++.dg/abi/bitfield5.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/bitfield5.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 bitfield5.C
*** testsuite/g++.dg/abi/bitfield5.C 27 Aug 2002 22:14:51 -0000 1.1
--- testsuite/g++.dg/abi/bitfield5.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,7 ****
// { dg-do compile }
! // { dg-options "-Wabi" }
struct A {
virtual void f();
int f1 : 1;
};
--- 1,7 ----
// { dg-do compile }
! // { dg-options "-Wabi -fabi-version=1" }
struct A {
virtual void f();
int f1 : 1;
};
Index: testsuite/g++.dg/abi/bitfield7.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/bitfield7.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 bitfield7.C
*** testsuite/g++.dg/abi/bitfield7.C 23 Sep 2002 09:22:17 -0000 1.1
--- testsuite/g++.dg/abi/bitfield7.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,7 ****
// { dg-do compile }
! // { dg-options "-Wabi" }
union U { // { dg-warning "ABI" }
int i: 4096; // { dg-warning "exceeds" }
};
--- 1,7 ----
// { dg-do compile }
! // { dg-options "-Wabi -fabi-version=1" }
union U { // { dg-warning "ABI" }
int i: 4096; // { dg-warning "exceeds" }
};
Index: testsuite/g++.dg/abi/dtor2.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/dtor2.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 dtor2.C
*** testsuite/g++.dg/abi/dtor2.C 7 Nov 2002 21:33:44 -0000 1.1
--- testsuite/g++.dg/abi/dtor2.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,7 ****
// { dg-do compile }
! // { dg-options "-Wabi" }
struct A {
virtual void a ();
};
--- 1,7 ----
// { dg-do compile }
! // { dg-options "-Wabi -fabi-version=1" }
struct A {
virtual void a ();
};
Index: testsuite/g++.dg/abi/macro0.C
===================================================================
RCS file: testsuite/g++.dg/abi/macro0.C
diff -N testsuite/g++.dg/abi/macro0.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/abi/macro0.C 23 Dec 2003 16:45:07 -0000
***************
*** 0 ****
--- 1,5 ----
+ // { dg-options "-fabi-version=0" }
+
+ #if __GXX_ABI_VERSION != 999999
+ #error "Incorrect value of __GXX_ABI_VERSION"
+ #endif
Index: testsuite/g++.dg/abi/macro1.C
===================================================================
RCS file: testsuite/g++.dg/abi/macro1.C
diff -N testsuite/g++.dg/abi/macro1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/abi/macro1.C 23 Dec 2003 16:45:07 -0000
***************
*** 0 ****
--- 1,5 ----
+ // { dg-options "-fabi-version=1" }
+
+ #if __GXX_ABI_VERSION != 102
+ #error "Incorrect value of __GXX_ABI_VERSION"
+ #endif
Index: testsuite/g++.dg/abi/macro2.C
===================================================================
RCS file: testsuite/g++.dg/abi/macro2.C
diff -N testsuite/g++.dg/abi/macro2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/abi/macro2.C 23 Dec 2003 16:45:07 -0000
***************
*** 0 ****
--- 1,5 ----
+ // { dg-options "-fabi-version=2" }
+
+ #if __GXX_ABI_VERSION != 1002
+ #error "Incorrect value of __GXX_ABI_VERSION"
+ #endif
Index: testsuite/g++.dg/abi/mangle11.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/mangle11.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 mangle11.C
*** testsuite/g++.dg/abi/mangle11.C 4 Oct 2002 04:59:37 -0000 1.1
--- testsuite/g++.dg/abi/mangle11.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,6 ****
! // { dg-options "-Wabi" }
template <typename Q>
void f (typename Q::X) {}
struct S {
--- 1,6 ----
! // { dg-options "-Wabi -fabi-version=1" }
template <typename Q>
void f (typename Q::X) {}
struct S {
Index: testsuite/g++.dg/abi/mangle12.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/mangle12.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 mangle12.C
*** testsuite/g++.dg/abi/mangle12.C 4 Oct 2002 04:59:37 -0000 1.1
--- testsuite/g++.dg/abi/mangle12.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,6 ****
! // { dg-options "-Wabi" }
template <template <typename> class Q>
void f (typename Q<int>::X) {}
template <typename Q>
--- 1,6 ----
! // { dg-options "-Wabi -fabi-version=1" }
template <template <typename> class Q>
void f (typename Q<int>::X) {}
template <typename Q>
Index: testsuite/g++.dg/abi/mangle14.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/mangle14.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 mangle14.C
*** testsuite/g++.dg/abi/mangle14.C 15 Oct 2002 23:59:22 -0000 1.1
--- testsuite/g++.dg/abi/mangle14.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,7 ****
// { dg-do compile }
! // { dg-options "-Wabi" }
struct A {
template <typename T> int f ();
};
--- 1,7 ----
// { dg-do compile }
! // { dg-options "-Wabi -fabi-version=1" }
struct A {
template <typename T> int f ();
};
Index: testsuite/g++.dg/abi/mangle17.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/mangle17.C,v
retrieving revision 1.2
diff -c -5 -p -r1.2 mangle17.C
*** testsuite/g++.dg/abi/mangle17.C 9 Jul 2003 08:48:05 -0000 1.2
--- testsuite/g++.dg/abi/mangle17.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,6 ****
! // { dg-options "-Wabi" }
enum E { e = 3 };
template <int I> struct S {};
--- 1,6 ----
! // { dg-options "-Wabi -fabi-version=1" }
enum E { e = 3 };
template <int I> struct S {};
Index: testsuite/g++.dg/abi/vbase10.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/vbase10.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 vbase10.C
*** testsuite/g++.dg/abi/vbase10.C 27 Aug 2002 22:14:51 -0000 1.1
--- testsuite/g++.dg/abi/vbase10.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,7 ****
// { dg-do compile }
! // { dg-options "-Wabi" }
struct A { virtual void f(); char c1; };
struct B { B(); char c2; };
struct C : public A, public virtual B {}; // { dg-warning "ABI" }
--- 1,7 ----
// { dg-do compile }
! // { dg-options "-Wabi -fabi-version=1" }
struct A { virtual void f(); char c1; };
struct B { B(); char c2; };
struct C : public A, public virtual B {}; // { dg-warning "ABI" }
Index: testsuite/g++.dg/abi/vbase14.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/abi/vbase14.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 vbase14.C
*** testsuite/g++.dg/abi/vbase14.C 22 Oct 2002 05:04:47 -0000 1.1
--- testsuite/g++.dg/abi/vbase14.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,6 ****
! // { dg-options "-Wabi" }
struct E1 {};
struct E2 : public E1 {}; // { dg-warning "layout" }
struct E : public E1, public E2 {}; // { dg-warning "layout|ambiguity" }
struct N : public E { virtual void f () {} }; // { dg-warning "nearly" }
--- 1,6 ----
! // { dg-options "-Wabi -fabi-version=1" }
struct E1 {};
struct E2 : public E1 {}; // { dg-warning "layout" }
struct E : public E1, public E2 {}; // { dg-warning "layout|ambiguity" }
struct N : public E { virtual void f () {} }; // { dg-warning "nearly" }
Index: testsuite/g++.dg/template/qualttp17.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/template/qualttp17.C,v
retrieving revision 1.1
diff -c -5 -p -r1.1 qualttp17.C
*** testsuite/g++.dg/template/qualttp17.C 23 Oct 2001 09:14:15 -0000 1.1
--- testsuite/g++.dg/template/qualttp17.C 23 Dec 2003 16:45:07 -0000
***************
*** 1,9 ****
// Copyright (C) 2001 Free Software Foundation
// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
// { dg-do compile }
! // { dg-options "-fno-inline" }
struct A
{
template <class T> class B {};
};
--- 1,9 ----
// Copyright (C) 2001 Free Software Foundation
// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
// { dg-do compile }
! // { dg-options "-fno-inline -fabi-version=1" }
struct A
{
template <class T> class B {};
};