gxxint.texi: G++ now implements namespaces.
authorMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 19 Sep 1999 00:33:09 +0000 (00:33 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 19 Sep 1999 00:33:09 +0000 (00:33 +0000)
* gxxint.texi: G++ now implements namespaces.

* decl.c (pop_label): Don't warn about unused labels more than
once.
* semantics.c (finish_goto_stmt): Always marked used labels as
used.

From-SVN: r29505

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/gxxint.texi
gcc/cp/semantics.c
gcc/testsuite/g++.old-deja/g++.pt/warn2.C [new file with mode: 0644]

index 599c7ff254c545cf550d2d75db65133e9694f00a..51185fa5522213c2c822d627a3fb1fb86ad5ad16 100644 (file)
@@ -1,5 +1,14 @@
+1999-09-18  Paul Burchard <burchard@pobox.com>
+
+       * gxxint.texi: G++ now implements namespaces.
+       
 1999-09-18  Mark Mitchell  <mark@codesourcery.com>
 
+       * decl.c (pop_label): Don't warn about unused labels more than
+       once.
+       * semantics.c (finish_goto_stmt): Always marked used labels as
+       used.
+
        * decl.c (layout_var_decl): Change prototype.  Call layout_decl
        even when the declaration is external.
        (cp_finish_decl): Adjust call to layout_var_decl.
index ed3e11e921d06bac2584ecacd550f80457e9f679..c1a07c1eb276b4e552ce3ea01ca4786fc9e88c36 100644 (file)
@@ -1125,14 +1125,17 @@ pop_label (link)
 {
   tree label = TREE_VALUE (link);
 
-  if (DECL_INITIAL (label) == NULL_TREE)
+  if (!processing_template_decl && doing_semantic_analysis_p ())
     {
-      cp_error_at ("label `%D' used but not defined", label);
-      /* Avoid crashing later.  */
-      define_label (input_filename, 1, DECL_NAME (label));
+      if (DECL_INITIAL (label) == NULL_TREE)
+       {
+         cp_error_at ("label `%D' used but not defined", label);
+         /* Avoid crashing later.  */
+         define_label (input_filename, 1, DECL_NAME (label));
+       }
+      else if (warn_unused && !TREE_USED (label))
+       cp_warning_at ("label `%D' defined but not used", label);
     }
-  else if (warn_unused && !TREE_USED (label))
-    cp_warning_at ("label `%D' defined but not used", label);
 
   SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (label), TREE_PURPOSE (link));
 }
index 05f1373b2525c72d9898fefae4ce5df8959a66a9..df9d100c3c31a2165dfb7b65d4e7f78d3c8310f6 100644 (file)
@@ -1602,7 +1602,7 @@ The int parameter is a basic type, and does not receive a B encoding...
 @subsection Qualified names
 
 Both C++ and Java allow a class to be lexically nested inside another
-class.  C++ also supports namespaces (not yet implemented by G++).
+class.  C++ also supports namespaces.
 Java also supports packages.
 
 These are all mangled the same way:  First the letter @samp{Q}
index 383e981402ec287f46bf56b0c4bba0e6b61a9426..6943b966efc33b5f69ec0ff67a235931bbde16cd 100644 (file)
@@ -642,6 +642,11 @@ finish_goto_stmt (destination)
   if (TREE_CODE (destination) == IDENTIFIER_NODE)
     destination = lookup_label (destination);
 
+  /* We warn about unused labels with -Wunused.  That means we have to
+     mark the used labels as used.  */
+  if (TREE_CODE (destination) == LABEL_DECL)
+    TREE_USED (destination) = 1;
+    
   if (building_stmt_tree ())
     add_tree (build_min_nt (GOTO_STMT, destination));
   else
@@ -650,7 +655,6 @@ finish_goto_stmt (destination)
 
       if (TREE_CODE (destination) == LABEL_DECL)
        {
-         TREE_USED (destination) = 1;
          label_rtx (destination);
          expand_goto (destination); 
        }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/warn2.C b/gcc/testsuite/g++.old-deja/g++.pt/warn2.C
new file mode 100644 (file)
index 0000000..a45e518
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// Special g++ Options: -Wall
+// Origin: Jeroen@MMR.be
+
+template <typename T>
+void f()
+{
+  for(;;)
+    for(;;)
+      goto a;
+
+ a:
+  ;
+}
+
+void g()
+{
+  f<long>();
+}