OSDN Git Service

* decl2.c (decl_constant_var_p): Use decl_maybe_constant_var_p.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 11 Jul 2011 18:52:19 +0000 (18:52 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 11 Jul 2011 18:52:19 +0000 (18:52 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@176177 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl2.c

index d95650f..a6df4fb 100644 (file)
@@ -1,5 +1,7 @@
 2011-07-11  Jason Merrill  <jason@redhat.com>
 
+       * decl2.c (decl_constant_var_p): Use decl_maybe_constant_var_p.
+
        PR c++/44609
        * cp-tree.h (struct tinst_level): Add errors field.
        * pt.c (neglectable_inst_p, limit_bad_template_recurson): New.
index d90d4b5..e1f9562 100644 (file)
@@ -3574,26 +3574,16 @@ decl_defined_p (tree decl)
 bool
 decl_constant_var_p (tree decl)
 {
-  bool ret;
-  tree type = TREE_TYPE (decl);
-  if (TREE_CODE (decl) != VAR_DECL)
+  if (!decl_maybe_constant_var_p (decl))
     return false;
-  if (DECL_DECLARED_CONSTEXPR_P (decl)
-      || (CP_TYPE_CONST_NON_VOLATILE_P (type)
-         && INTEGRAL_OR_ENUMERATION_TYPE_P (type)))
-    {
-      /* We don't know if a template static data member is initialized with
-        a constant expression until we instantiate its initializer.  Even
-        in the case of a constexpr variable, we can't treat it as a
-        constant until its initializer is complete in case it's used in
-        its own initializer.  */
-      mark_used (decl);
-      ret = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl);
-    }
-  else
-    ret = false;
 
-  return ret;
+  /* We don't know if a template static data member is initialized with
+     a constant expression until we instantiate its initializer.  Even
+     in the case of a constexpr variable, we can't treat it as a
+     constant until its initializer is complete in case it's used in
+     its own initializer.  */
+  mark_used (decl);
+  return DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl);
 }
 
 /* Returns true if DECL could be a symbolic constant variable, depending on