Richard,

Here is a backport of some of my llvm warning squashing effort already applied to master. I selected only the warnings that can lead to bugs.

OK to apply to branch?

JMarc
>From 6e4460ab4c2c8783b664070cf2d1c693106ed8c2 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Fri, 3 May 2013 14:15:10 +0200
Subject: [PATCH] Some potential bugs spotted by llvm/clang

src/TextClass.h
src/insets/InsetTabular.h

  Overloaded virtual method missing the 'const' qualifier

src/insets/InsetCommandParams.h

  Missing constructor (breaks compilation with llvm/clang)

src/frontends/qt4/GuiWorkArea.cpp

  Missing parenthesis: `+' has priority over `?:' (I do not know
  whether this has a visible effect).

src/mathed/InsetMathFont.cpp

  Use of == instead of = in mathmlize()
---
 src/TextClass.h                   |    2 +-
 src/frontends/qt4/GuiWorkArea.cpp |    2 +-
 src/insets/InsetCommandParams.h   |    2 ++
 src/insets/InsetTabular.h         |    2 +-
 src/mathed/InsetMathFont.cpp      |    4 ++--
 5 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/TextClass.h b/src/TextClass.h
index dc47192..dc30062 100644
--- a/src/TextClass.h
+++ b/src/TextClass.h
@@ -361,7 +361,7 @@ public:
 	/// \return true if there is a Layout with latexname lay
 	bool hasLaTeXLayout(std::string const & lay) const;
 	/// A DocumentClass nevers count as loaded, since it is dynamic
-	virtual bool loaded() { return false; }
+	virtual bool loaded() const { return false; }
 	/// \return the layout object of an inset given by name. If the name
 	/// is not found as such, the part after the ':' is stripped off, and
 	/// searched again. In this way, an error fallback can be provided:
diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp
index df9dfe8..049831d 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -940,7 +940,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
 		buffer_view_->scroll(up ? -step : step);
 		buffer_view_->updateMetrics();
 	} else {
-		buffer_view_->scrollDocView(value + up ? -step : step, false);
+		buffer_view_->scrollDocView(value + (up ? -step : step), false);
 	}
 
 	// In which paragraph do we have to set the cursor ?
diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h
index 7dc59fa..219d79b 100644
--- a/src/insets/InsetCommandParams.h
+++ b/src/insets/InsetCommandParams.h
@@ -31,6 +31,8 @@ class Lexer;
 
 class ParamInfo {
 public:
+	///
+	ParamInfo() {}
 	/// Types of parameters
 	enum ParamType {
 		LATEX_OPTIONAL,    /// normal optional argument
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index bc4542c..2049e54 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -55,7 +55,7 @@ public:
 	///
 	InsetCode lyxCode() const { return CELL_CODE; }
 	///
-	Inset * clone() { return new InsetTableCell(*this); }
+	Inset * clone() const { return new InsetTableCell(*this); }
 	///
 	bool getStatus(Cursor & cur, FuncRequest const & cmd,
 		FuncStatus & status) const;
diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp
index efd43ce..9c02a3c 100644
--- a/src/mathed/InsetMathFont.cpp
+++ b/src/mathed/InsetMathFont.cpp
@@ -140,7 +140,7 @@ void InsetMathFont::htmlize(HtmlStream & os) const
 	         || tag == "textbf")
 		variant = "bold";
 	else if (tag == "mathcal")
-		variant == "script";
+		variant = "script";
 	else if (tag == "mathit" || tag == "textsl"
 	         || tag == "emph" || tag == "textit")
 		variant = "italic";
@@ -180,7 +180,7 @@ void InsetMathFont::mathmlize(MathStream & os) const
 	         || tag == "textbf")
 		variant = "bold";
 	else if (tag == "mathcal")
-		variant == "script";
+		variant = "script";
 	else if (tag == "mathit" || tag == "textsl"
 	         || tag == "emph" || tag == "textit")
 		variant = "italic";
-- 
1.7.0.4

Reply via email to