pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/25729: Semantic errors in code prevent devel/astyle from compiling with gcc 3.4.0



>Number:         25729
>Category:       pkg
>Synopsis:       Semantic errors in code prevent devel/astyle from compiling 
>with gcc 3.4.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 27 16:41:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     John  R. Shannon
>Release:        NetBSD 2.0_BETA
>Organization:
        netbsd.org
>Environment:
System: NetBSD colleen.internal.johnrshannon.com 2.0_BETA NetBSD 2.0_BETA 
(KERNEL) #0: Mon May 24 05:31:10 MDT 2004 
root%colleen.internal.johnrshannon.com@localhost:/usr/obj/usr/src/sys/arch/i386/compile/KERNEL
 i386
Architecture: i386
Machine: i386
>Description:
        g++ -Wall -Wno-sign-compare -O2 -O2 -c astyle_main.cpp
        astyle_main.cpp: In function `bool parseOptions(astyle::ASFormatter&, 
const ITER&, const ITER&, const std::string&)':
        astyle_main.cpp:178: error: there are no arguments to `parseOption' 
that depend on a template parameter, so a declaration of `parseOption' must be 
available
        astyle_main.cpp:178: error: (if you use `-fpermissive', G++ will accept 
your code, but allowing the use of an undeclared name is deprecated)
        astyle_main.cpp:183: error: there are no arguments to `parseOption' 
that depend on a template parameter, so a declaration of `parseOption' must be 
available
        astyle_main.cpp:188: error: there are no arguments to `parseOption' 
that depend on a template parameter, so a declaration of `parseOption' must be 
available
        astyle_main.cpp: At global scope:
        astyle_main.cpp:654: warning: ISO C++ forbids declaration of `main' 
with no type

        The error comes from parseOptions being a function template rather than 
a function. parseOptions
        also has problems in that it contains a forward referece to 
parseOption().

>How-To-Repeat:
        
>Fix:

        The following fix changes parseOptions from a function template to a 
function. This
        is possible because parseOptions is only used with vector<string> for 
the template
        parameter.

$NetBSD$

--- astyle_main.cpp.orig        2001-01-20 17:02:14.000000000 -0700
+++ astyle_main.cpp
@@ -150,49 +150,6 @@ void error(const char *why, const char* 
 }
 
 
-
-template<class ITER>
-bool parseOptions(ASFormatter &formatter,
-                  const ITER &optionsBegin,
-                  const ITER &optionsEnd,
-                  const string &errorInfo)
-{
-    ITER option;
-    bool ok = true;
-    string arg, subArg;
-
-    for (option = optionsBegin; option != optionsEnd; ++option)
-    {
-        arg = *option; //string(*option);
-
-        if (arg.COMPARE(0, 2, string("--")) == 0)
-            ok &= parseOption(formatter, arg.substr(2), errorInfo);
-        else if (arg[0] == '-')
-        {
-            int i;
-
-            for (i=1; i < arg.length(); ++i)
-            {
-                if (isalpha(arg[i]) && i > 1)
-                {
-                    ok &= parseOption(formatter, subArg, errorInfo);
-                    subArg = "";
-                }
-                subArg.append(1, arg[i]);
-            }
-            ok &= parseOption(formatter, subArg, errorInfo);
-            subArg = "";
-        }
-        else
-        {
-            ok &= parseOption(formatter, arg, errorInfo);
-            subArg = "";
-        }
-    }
-
-    return ok;
-}
-
 void manuallySetJavaStyle(ASFormatter &formatter)
 {
     formatter.setJavaStyle();
@@ -417,9 +374,50 @@ bool parseOption(ASFormatter &formatter,
     return true; //o.k.
 }
 
+typedef vector<string> string_vector;
+
+bool parseOptions(ASFormatter &formatter,
+                  const string_vector::iterator optionsBegin,
+                  const string_vector::iterator optionsEnd,
+                  const string &errorInfo)
+{
+    string_vector::iterator option;
+    bool ok = true;
+    string arg, subArg;
+
+    for (option = optionsBegin; option != optionsEnd; ++option)
+    {
+        arg = *option; //string(*option);
+
+        if (arg.COMPARE(0, 2, string("--")) == 0)
+            ok &= parseOption(formatter, arg.substr(2), errorInfo);
+        else if (arg[0] == '-')
+        {
+            int i;
+
+            for (i=1; i < arg.length(); ++i)
+            {
+                if (isalpha(arg[i]) && i > 1)
+                {
+                    ok &= parseOption(formatter, subArg, errorInfo);
+                    subArg = "";
+                }
+                subArg.append(1, arg[i]);
+            }
+            ok &= parseOption(formatter, subArg, errorInfo);
+            subArg = "";
+        }
+        else
+        {
+            ok &= parseOption(formatter, arg, errorInfo);
+            subArg = "";
+        }
+    }
 
+    return ok;
+}
 
-void importOptions(istream &in, vector<string> &optionsVector)
+void importOptions(istream &in, string_vector &optionsVector)
 {
     char ch;
     string currentToken;
@@ -653,8 +651,8 @@ void printHelpAndExit()
 main(int argc, char *argv[])
 {
     ASFormatter formatter;
-    vector<string> fileNameVector;
-    vector<string> optionsVector;
+    string_vector fileNameVector;
+    string_vector optionsVector;
     string optionsFileName = "";
     string arg;
     bool ok = true;
@@ -721,7 +719,7 @@ main(int argc, char *argv[])
             ifstream optionsIn(optionsFileName.c_str());
             if (optionsIn)
             {
-                vector<string> fileOptionsVector;
+                string_vector fileOptionsVector;
                 importOptions(optionsIn, fileOptionsVector);
                 ok = parseOptions(formatter,
                                   fileOptionsVector.begin(),
>Release-Note:
>Audit-Trail:
>Unformatted:



Home | Main Index | Thread Index | Old Index