PR c++/14324
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Mar 2004 20:38:31 +0000 (20:38 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Mar 2004 20:38:31 +0000 (20:38 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78720 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/lex.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/mangle21.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/constructor2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/sfinae1.C [new file with mode: 0644]

index b9ef593..9c7d3d9 100644 (file)
@@ -1,3 +1,19 @@
+2004-03-01  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <law@redhat.com>
 
        * init.c (build_vec_delete_1): Convert 2nd argument to NE_EXPR to
index ab248a4..2239c76 100644 (file)
@@ -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);
index bc887f8..77b5795 100644 (file)
@@ -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;
            }
 
index 3fa2576..20056eb 100644 (file)
@@ -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);
index c6dbd88..459ff66 100644 (file)
@@ -1,3 +1,14 @@
+2004-03-01  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <mark@codesourcery.com>
 
        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 (file)
index 0000000..f457d60
--- /dev/null
@@ -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 (file)
index 0000000..e514e93
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/14260
+
+template <class TClass> 
+class T 
+{ 
+public: 
+  T(short,short f=0) {} 
+  T<TClass>(int f) {} 
+  T<TClass>(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 (file)
index 0000000..47db411
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/14337
+
+template <bool> struct Constraint; 
+template <>     struct Constraint<true> { typedef int Result; }; 
+template <typename T> 
+struct IsInt      { static const bool value = false; }; 
+template <> 
+struct IsInt<int> { static const bool value = true; }; 
+template <typename T> 
+typename Constraint<IsInt<T>::value>::Result foo(T); 
+template <typename T> 
+typename Constraint<!IsInt<T>::value>::Result foo(T); 
+template <typename> 
+void bar() { 
+    foo(1); 
+}