aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-10-15 19:43:51 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-10-15 15:43:51 -0400
commit0f8766b8af0eb7c2ea063d5442f2b73fc6ebb506 (patch)
treeff389523064167bec47d1d00530d97b280e24d9b /gcc
parentd46965b9674d7006bbe525cea86da936cfc2e3c1 (diff)
downloadgcc-0f8766b8af0eb7c2ea063d5442f2b73fc6ebb506.zip
gcc-0f8766b8af0eb7c2ea063d5442f2b73fc6ebb506.tar.gz
gcc-0f8766b8af0eb7c2ea063d5442f2b73fc6ebb506.tar.bz2
decl.c (grokfndecl): ::main and __builtin_* get C linkage.
* decl.c (grokfndecl): ::main and __builtin_* get C linkage. Do mangling here. (grokdeclarator): Instead of here. * friend.c (do_friend): Lose special handling of ::main and __builtin_*. * cp-tree.h (DECL_MAIN_P): Check for C linkage. * spew.c (yylex): Clear looking_for_typename if we got 'enum { ... };'. From-SVN: r23117
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/decl.c38
-rw-r--r--gcc/cp/friend.c14
-rw-r--r--gcc/cp/spew.c5
5 files changed, 38 insertions, 33 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6b6ed2c..0958c3b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+1998-10-15 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (grokfndecl): ::main and __builtin_* get C linkage.
+ Do mangling here.
+ (grokdeclarator): Instead of here.
+ * friend.c (do_friend): Lose special handling of ::main and
+ __builtin_*.
+ * cp-tree.h (DECL_MAIN_P): Check for C linkage.
+
+ * spew.c (yylex): Clear looking_for_typename if we got
+ 'enum { ... };'.
+
1998-10-15 Mark Mitchell <mark@markmitchell.com>
* class.c (maybe_warn_about_overly_private_class): Improve error
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6a74d26..76ba93e 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -2203,7 +2203,7 @@ extern int current_function_parms_stored;
`main'. */
#define DECL_MAIN_P(NODE) \
(TREE_CODE (NODE) == FUNCTION_DECL \
- && DECL_CONTEXT (NODE) == NULL_TREE \
+ && DECL_LANGUAGE (NODE) == lang_c \
&& DECL_NAME (NODE) != NULL_TREE \
&& MAIN_NAME_P (DECL_NAME (NODE)))
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8facd96..29605a7 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8016,6 +8016,19 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
if (in_namespace)
set_decl_namespace (decl, in_namespace);
+ /* `main' and builtins have implicit 'C' linkage. */
+ if ((MAIN_NAME_P (declarator)
+ || (IDENTIFIER_LENGTH (declarator) > 10
+ && IDENTIFIER_POINTER (declarator)[0] == '_'
+ && IDENTIFIER_POINTER (declarator)[1] == '_'
+ && strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0))
+ && current_lang_name == lang_name_cplusplus
+ /* context == 0 could mean global scope or not set yet; either is fine
+ for us here, as we check current_namespace. */
+ && DECL_CONTEXT (decl) == NULL_TREE
+ && current_namespace == global_namespace)
+ DECL_LANGUAGE (decl) = lang_c;
+
/* Should probably propagate const out from type to decl I bet (mrs). */
if (staticp)
{
@@ -8026,7 +8039,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
if (ctype)
DECL_CLASS_CONTEXT (decl) = ctype;
- if (ctype == NULL_TREE && MAIN_NAME_P (declarator))
+ if (ctype == NULL_TREE && DECL_MAIN_P (decl))
{
if (inlinep)
error ("cannot declare `main' to be inline");
@@ -8123,6 +8136,12 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
}
}
+ /* Plain overloading: will not be grok'd by grokclassfn. */
+ if (! ctype && ! processing_template_decl
+ && DECL_LANGUAGE (decl) != lang_c
+ && (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1))
+ set_mangled_name_for_decl (decl);
+
/* Caller will do the rest of this. */
if (check < 0)
return decl;
@@ -10625,18 +10644,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
error ("virtual non-class function `%s'", name);
virtualp = 0;
}
-
- if (current_lang_name == lang_name_cplusplus
- && ! processing_template_decl
- && ! MAIN_NAME_P (original_name)
- && ! (IDENTIFIER_LENGTH (original_name) > 10
- && IDENTIFIER_POINTER (original_name)[0] == '_'
- && IDENTIFIER_POINTER (original_name)[1] == '_'
- && strncmp (IDENTIFIER_POINTER (original_name)+2, "builtin_", 8) == 0))
- /* Plain overloading: will not be grok'd by grokclassfn. */
- if (name_mangling_version < 1
- || TREE_CODE (declarator) != TEMPLATE_ID_EXPR)
- declarator = build_decl_overload (dname, TYPE_ARG_TYPES (type), 0);
}
else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2)
type = build_cplus_method_type (ctype, TREE_TYPE (type),
@@ -10660,11 +10667,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (decl == error_mark_node)
return error_mark_node;
- if (ctype == NULL_TREE && DECL_LANGUAGE (decl) != lang_c
- && (! DECL_USE_TEMPLATE (decl) ||
- name_mangling_version < 1))
- DECL_ASSEMBLER_NAME (decl) = declarator;
-
if (staticp == 1)
{
int illegal_static = 0;
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index acb9657..a3d198a 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -405,20 +405,6 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
decl = void_type_node;
}
}
- else if (TREE_CODE (decl) == FUNCTION_DECL
- && (MAIN_NAME_P (declarator)
- || (IDENTIFIER_LENGTH (declarator) > 10
- && IDENTIFIER_POINTER (declarator)[0] == '_'
- && IDENTIFIER_POINTER (declarator)[1] == '_'
- && strncmp (IDENTIFIER_POINTER (declarator)+2,
- "builtin_", 8) == 0)))
- {
- /* raw "main", and builtin functions never gets overloaded,
- but they can become friends. */
- add_friend (current_class_type, decl);
- DECL_FRIEND_P (decl) = 1;
- decl = void_type_node;
- }
/* A global friend.
@@ or possibly a friend from a base class ?!? */
else if (TREE_CODE (decl) == FUNCTION_DECL)
diff --git a/gcc/cp/spew.c b/gcc/cp/spew.c
index ff93ac7..b524cb1 100644
--- a/gcc/cp/spew.c
+++ b/gcc/cp/spew.c
@@ -401,6 +401,11 @@ yylex ()
if (tmp_token.yychar != '~')
got_object = NULL_TREE;
+ /* Clear looking_for_typename if we got 'enum { ... };'. */
+ if (tmp_token.yychar == '{' || tmp_token.yychar == ':'
+ || tmp_token.yychar == ';')
+ looking_for_typename = 0;
+
yylval = tmp_token.yylval;
yychar = tmp_token.yychar;
end_of_file = tmp_token.end_of_file;