aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1999-04-09 12:44:53 +0000
committerJason Merrill <jason@gcc.gnu.org>1999-04-09 08:44:53 -0400
commitb17e287057a8d64d65c30fda457085689ea1ef0e (patch)
treede7d86cbb58875066c35ac3be5467ebf7ec1070c /gcc
parent09a076233d68120a839c7c4449dbb2b2b0ce3f7a (diff)
downloadgcc-b17e287057a8d64d65c30fda457085689ea1ef0e.zip
gcc-b17e287057a8d64d65c30fda457085689ea1ef0e.tar.gz
gcc-b17e287057a8d64d65c30fda457085689ea1ef0e.tar.bz2
decl.c (start_decl): Pass attributes to grokdeclarator.
* decl.c (start_decl): Pass attributes to grokdeclarator. (grokdeclarator): Handle attributes on constructor-syntax initializers. From-SVN: r26313
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c105
2 files changed, 71 insertions, 40 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c1c04e7..8a85396 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+1999-04-09 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (start_decl): Pass attributes to grokdeclarator.
+ (grokdeclarator): Handle attributes on constructor-syntax
+ initializers.
+
1999-04-08 Mark Mitchell <mark@codesourcery.com>
* error.c (dump_expr): Don't crash on INDIRECT_REFs whose operands
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0989237..e50c90a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6975,6 +6975,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
tree context;
extern int have_extern_spec;
extern int used_extern_spec;
+ tree attrlist;
#if 0
/* See code below that used this. */
@@ -6989,8 +6990,14 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
used_extern_spec = 1;
}
+ if (attributes || prefix_attributes)
+ attrlist = build_scratch_list (attributes, prefix_attributes);
+ else
+ attrlist = NULL_TREE;
+
decl = grokdeclarator (declarator, declspecs, NORMAL, initialized,
- NULL_TREE);
+ attrlist);
+
if (decl == NULL_TREE || TREE_CODE (decl) == VOID_TYPE)
return NULL_TREE;
@@ -8900,6 +8907,41 @@ build_ptrmemfunc_type (type)
return t;
}
+/* DECL is a VAR_DECL defined in-class, whose TYPE is also given.
+ Check to see that the definition is valid. Issue appropriate error
+ messages. Return 1 if the definition is particularly bad, or 0
+ otherwise. */
+
+int
+check_static_variable_definition (decl, type)
+ tree decl;
+ tree type;
+{
+ /* Motion 10 at San Diego: If a static const integral data member is
+ initialized with an integral constant expression, the initializer
+ may appear either in the declaration (within the class), or in
+ the definition, but not both. If it appears in the class, the
+ member is a member constant. The file-scope definition is always
+ required. */
+ if (CLASS_TYPE_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ cp_error ("in-class initialization of static data member of non-integral type `%T'",
+ type);
+ /* If we just return the declaration, crashes will sometimes
+ occur. We therefore return void_type_node, as if this was a
+ friend declaration, to cause callers to completely ignore
+ this declaration. */
+ return 1;
+ }
+ else if (!CP_TYPE_CONST_P (type))
+ cp_error ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
+ decl);
+ else if (pedantic && !INTEGRAL_TYPE_P (type))
+ cp_pedwarn ("ANSI C++ forbids initialization of member constant `%D' of non-integral type `%T'", decl, type);
+
+ return 0;
+}
+
/* Given declspecs and a declarator,
determine the name and type of the object declared
and construct a ..._DECL node for it.
@@ -8927,6 +8969,9 @@ build_ptrmemfunc_type (type)
BITFIELD for a field with specified width.
INITIALIZED is 1 if the decl has an initializer.
+ ATTRLIST is a TREE_LIST node with prefix attributes in TREE_VALUE and
+ normal attributes in TREE_PURPOSE, or NULL_TREE.
+
In the TYPENAME case, DECLARATOR is really an absolute declarator.
It may also be so in the PARM case, for a prototype where the
argument type is specified but not the name.
@@ -8958,41 +9003,6 @@ build_ptrmemfunc_type (type)
enum return_types { return_normal, return_ctor, return_dtor, return_conversion };
-/* DECL is a VAR_DECL defined in-class, whose TYPE is also given.
- Check to see that the definition is valid. Issue appropriate error
- messages. Return 1 if the definition is particularly bad, or 0
- otherwise. */
-
-int
-check_static_variable_definition (decl, type)
- tree decl;
- tree type;
-{
- /* Motion 10 at San Diego: If a static const integral data member is
- initialized with an integral constant expression, the initializer
- may appear either in the declaration (within the class), or in
- the definition, but not both. If it appears in the class, the
- member is a member constant. The file-scope definition is always
- required. */
- if (CLASS_TYPE_P (type) || TREE_CODE (type) == REFERENCE_TYPE)
- {
- cp_error ("in-class initialization of static data member of non-integral type `%T'",
- type);
- /* If we just return the declaration, crashes will sometimes
- occur. We therefore return void_type_node, as if this was a
- friend declaration, to cause callers to completely ignore
- this declaration. */
- return 1;
- }
- else if (!CP_TYPE_CONST_P (type))
- cp_error ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
- decl);
- else if (pedantic && !INTEGRAL_TYPE_P (type))
- cp_pedwarn ("ANSI C++ forbids initialization of member constant `%D' of non-integral type `%T'", decl, type);
-
- return 0;
-}
-
tree
grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
tree declspecs;
@@ -9129,14 +9139,29 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
case CALL_EXPR:
if (parmlist_is_exprlist (TREE_OPERAND (decl, 1)))
{
- /* This is actually a variable declaration using constructor
- syntax. We need to call start_decl and cp_finish_decl so we
- can get the variable initialized... */
+ /* This is actually a variable declaration using
+ constructor syntax. We need to call start_decl and
+ cp_finish_decl so we can get the variable
+ initialized... */
+
+ tree attributes, prefix_attributes;
*next = TREE_OPERAND (decl, 0);
init = TREE_OPERAND (decl, 1);
- decl = start_decl (declarator, declspecs, 1, NULL_TREE, NULL_TREE);
+ if (attrlist)
+ {
+ attributes = TREE_PURPOSE (attrlist);
+ prefix_attributes = TREE_VALUE (attrlist);
+ }
+ else
+ {
+ attributes = NULL_TREE;
+ prefix_attributes = NULL_TREE;
+ }
+
+ decl = start_decl (declarator, declspecs, 1,
+ attributes, prefix_attributes);
if (decl)
{
/* Look for __unused__ attribute */