This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH for c++/64956 (__GXX_ABI_VERSION)


It doesn't really make sense for __GXX_ABI_VERSION to be 99999 under -fabi-version=0; that tells the user about what flag was given, but not what ABI is actually active. So let's change flag_abi_version to something more specific, which has the effect of making __GXX_ABI_VERSION more useful.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 1024e96fcbb23d67cd5dd1a434cd32d078791e9a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 12 16:37:42 2015 -0500

    	PR c++/64956
    	* c-opts.c (c_common_post_options): Change flag_abi_version from 0
    	to the current highest version.
    	* c-cppbuiltin.c (c_cpp_builtins): Assert that it isn't 0.

diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 1936592..60c2d7f 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -891,14 +891,8 @@ c_cpp_builtins (cpp_reader *pfile)
   /* 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);
+    /* We should have set this to something real in c_common_post_options.  */
+    gcc_unreachable ();
   else if (flag_abi_version == 1)
     /* Due to a historical accident, this version had the value
        "102".  */
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index d10e5bd..1a67b5a 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -886,6 +886,11 @@ c_common_post_options (const char **pfilename)
 	warn_abi = false;
     }
 
+  /* Change flag_abi_version to be the actual current ABI level for the
+     benefit of c_cpp_builtins.  */
+  if (flag_abi_version == 0)
+    flag_abi_version = 8;
+
   if (cxx_dialect >= cxx11)
     {
       /* If we're allowing C++0x constructs, don't warn about C++98
diff --git a/gcc/common.opt b/gcc/common.opt
index 87f2e1f..0c60e84 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -806,7 +806,8 @@ Driver Undocumented
 ;
 ; 1: The version of the ABI first used in G++ 3.2.  No longer selectable.
 ;
-; 2: The version of the ABI first used in G++ 3.4 (and current default).
+; 2: The version of the ABI first used in G++ 3.4, and the default
+;    until GCC 4.9.
 ;
 ; 3: The version of the ABI that fixes the missing underscore
 ;    in template non-type arguments of pointer type.
@@ -831,7 +832,8 @@ Driver Undocumented
 ;
 ; 8: The version of the ABI that corrects the substitution behavior of
 ;    function types with function-cv-qualifiers.
-;    First selectable in G++ 4.9.
+;    First selectable in G++ 4.9 and default in G++ 5
+;    (set in c_common_post_options).
 ;
 ; Additional positive integers will be assigned as new versions of
 ; the ABI become the default version of the ABI.
diff --git a/gcc/testsuite/g++.dg/abi/macro0.C b/gcc/testsuite/g++.dg/abi/macro0.C
index 6c391e6..fbcbb2c 100644
--- a/gcc/testsuite/g++.dg/abi/macro0.C
+++ b/gcc/testsuite/g++.dg/abi/macro0.C
@@ -1,5 +1,6 @@
+// This testcase will need to be kept in sync with c_common_post_options.
 // { dg-options "-fabi-version=0" }
 
-#if __GXX_ABI_VERSION != 999999
+#if __GXX_ABI_VERSION != 1008
 #error "Incorrect value of __GXX_ABI_VERSION"
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]