From ab73670a29184764111d4cd87d71542ba646bb4d Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 1 Mar 2004 20:38:31 +0000 Subject: [PATCH] re PR c++/14324 (Multiple static definitions are not unique) PR c++/14324 * lex.c (retrofit_lang_decl): Treat entities with no linkage as having C++ linkage for name-mangling purposes. PR c++/14260 * parser.c (cp_parser_direct_declarator): Recognize constructor declarators that use a template-id to name the class being constructed. PR c++/14337 * pt.c (tsubst_qualified_id): Handle dependent qualifying scopes. (tsubst_expr): Do not call tsubst_copy, even when processing_template_decl. PR c++/14324 * g++.dg/abi/mangle21.C: New test. PR c++/14260 * g++.dg/parse/constructor2.C: New test. PR c++/14337 * g++.dg/template/sfinae1.C: New test. From-SVN: r78720 --- gcc/cp/ChangeLog | 16 ++++++++++++++++ gcc/cp/lex.c | 3 ++- gcc/cp/parser.c | 5 ++++- gcc/cp/pt.c | 6 ++---- gcc/testsuite/ChangeLog | 11 +++++++++++ gcc/testsuite/g++.dg/abi/mangle21.C | 13 +++++++++++++ gcc/testsuite/g++.dg/parse/constructor2.C | 11 +++++++++++ gcc/testsuite/g++.dg/template/sfinae1.C | 21 +++++++++++++++++++++ 8 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/abi/mangle21.C create mode 100644 gcc/testsuite/g++.dg/parse/constructor2.C create mode 100644 gcc/testsuite/g++.dg/template/sfinae1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b9ef5933976b..9c7d3d937a4d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,19 @@ +2004-03-01 Mark Mitchell + + PR c++/14324 + * lex.c (retrofit_lang_decl): Treat entities with no linkage as + having C++ linkage for name-mangling purposes. + + PR c++/14260 + * parser.c (cp_parser_direct_declarator): Recognize constructor + declarators that use a template-id to name the class being + constructed. + + PR c++/14337 + * pt.c (tsubst_qualified_id): Handle dependent qualifying scopes. + (tsubst_expr): Do not call tsubst_copy, even when + processing_template_decl. + 2004-03-01 Jeff Law * init.c (build_vec_delete_1): Convert 2nd argument to NE_EXPR to diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index ab248a434b76..2239c76ca873 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -726,7 +726,8 @@ retrofit_lang_decl (tree t) ld->u.f.u3sel = TREE_CODE (t) == FUNCTION_DECL ? 1 : 0; DECL_LANG_SPECIFIC (t) = ld; - if (current_lang_name == lang_name_cplusplus) + if (current_lang_name == lang_name_cplusplus + || decl_linkage (t) == lk_none) SET_DECL_LANGUAGE (t, lang_cplusplus); else if (current_lang_name == lang_name_c) SET_DECL_LANGUAGE (t, lang_c); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bc887f89bf93..77b57957f791 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -10628,7 +10628,10 @@ cp_parser_direct_declarator (cp_parser* parser, /* See if it names ctor, dtor or conv. */ if (TREE_CODE (unqualified_name) == BIT_NOT_EXPR || IDENTIFIER_TYPENAME_P (unqualified_name) - || constructor_name_p (unqualified_name, class_type)) + || constructor_name_p (unqualified_name, class_type) + || (TREE_CODE (unqualified_name) == TYPE_DECL + && same_type_p (TREE_TYPE (unqualified_name), + class_type))) *ctor_dtor_or_conv_p = -1; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3fa25768d945..20056eb8e759 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7325,7 +7325,8 @@ tsubst_qualified_id (tree qualified_id, tree args, else expr = name; - my_friendly_assert (!dependent_type_p (scope), 20030729); + if (dependent_type_p (scope)) + return build_nt (SCOPE_REF, scope, expr); if (!BASELINK_P (name) && !DECL_P (expr)) { @@ -7738,9 +7739,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (t == NULL_TREE || t == error_mark_node) return t; - if (processing_template_decl) - return tsubst_copy (t, args, complain, in_decl); - if (!STATEMENT_CODE_P (TREE_CODE (t))) return tsubst_copy_and_build (t, args, complain, in_decl, /*function_p=*/false); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6dbd88042f0..459ff6600ad4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2004-03-01 Mark Mitchell + + PR c++/14324 + * g++.dg/abi/mangle21.C: New test. + + PR c++/14260 + * g++.dg/parse/constructor2.C: New test. + + PR c++/14337 + * g++.dg/template/sfinae1.C: New test. + 2004-02-29 Mark Mitchell PR c++/14267 diff --git a/gcc/testsuite/g++.dg/abi/mangle21.C b/gcc/testsuite/g++.dg/abi/mangle21.C new file mode 100644 index 000000000000..f457d600cd8e --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/mangle21.C @@ -0,0 +1,13 @@ +// PR c++/14324 +// { dg-do assemble } + +extern "C" { + +void fun1(void) +{ + do { static int xyz __attribute__((unused)) = 1; } while (0); + do { static int xyz __attribute__((unused)) = 2; } while (0); + do { static int xyz __attribute__((unused)) = 3; } while (0); +} + +} diff --git a/gcc/testsuite/g++.dg/parse/constructor2.C b/gcc/testsuite/g++.dg/parse/constructor2.C new file mode 100644 index 000000000000..e514e9397e92 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/constructor2.C @@ -0,0 +1,11 @@ +// PR c++/14260 + +template +class T +{ +public: + T(short,short f=0) {} + T(int f) {} + T(int f=0,const char* b=0) {} +}; + diff --git a/gcc/testsuite/g++.dg/template/sfinae1.C b/gcc/testsuite/g++.dg/template/sfinae1.C new file mode 100644 index 000000000000..47db4115452a --- /dev/null +++ b/gcc/testsuite/g++.dg/template/sfinae1.C @@ -0,0 +1,21 @@ +// PR c++/14337 + +template struct Constraint; +template <> struct Constraint { typedef int Result; }; + +template +struct IsInt { static const bool value = false; }; + +template <> +struct IsInt { static const bool value = true; }; + +template +typename Constraint::value>::Result foo(T); + +template +typename Constraint::value>::Result foo(T); + +template +void bar() { + foo(1); +} -- 2.47.2