0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-12166: Promote struct/class mismatch warning to error with GCC/Clang

This commit is contained in:
Mark Benvenuto 2013-12-31 15:15:59 -05:00
parent 6486c53c2d
commit 7964cab85a
7 changed files with 63 additions and 12 deletions

View File

@ -80,6 +80,7 @@ else:
nix = not windows
# --- options ----
use_clang = False
options = {}
@ -1049,6 +1050,9 @@ def doConfigure(myenv):
myenv = conf.Finish()
global use_clang
use_clang = using_clang()
# Figure out what our minimum windows version is. If the user has specified, then use
# that. Otherwise, if they have explicitly selected between 32 bit or 64 bit, choose XP or
# Vista respectively. Finally, if they haven't done either of these, try invoking the
@ -1125,7 +1129,7 @@ def doConfigure(myenv):
test_mutation = mutation
if using_gcc():
test_mutation = copy.deepcopy(mutation)
# GCC helpfully doesn't issue a diagnostic on unkown flags of the form -Wno-xxx
# GCC helpfully doesn't issue a diagnostic on unknown flags of the form -Wno-xxx
# unless other diagnostics are triggered. That makes it tough to check for support
# for -Wno-xxx. To work around, if we see that we are testing for a flag of the
# form -Wno-xxx (but not -Wno-error=xxx), we also add -Wxxx to the flags. GCC does
@ -1180,12 +1184,6 @@ def doConfigure(myenv):
# libraries have such things.
AddToCCFLAGSIfSupported(myenv, '-Wno-unused-private-field')
# Clang warns about struct/class tag mismatch, but most people think that that is not
# really an issue, see
# http://stackoverflow.com/questions/4866425/mixing-class-and-struct. We disable the
# warning so it doesn't become an error.
AddToCCFLAGSIfSupported(myenv, '-Wno-mismatched-tags')
# Prevents warning about using deprecated features (such as auto_ptr in c++11)
# Using -Wno-error=deprecated-declarations does not seem to work on some compilers,
# including at least g++-4.6.
@ -1691,6 +1689,7 @@ Export('module_sconscripts')
Export("debugBuild optBuild")
Export("enforce_glibc")
Export("s3push")
Export("use_clang")
env.SConscript('src/SConscript', variant_dir='$BUILD_DIR', duplicate=False)
env.SConscript('src/SConscript.client', variant_dir='$BUILD_DIR/client_build', duplicate=False)

45
src/mongo/db/geo/s2.h Normal file
View File

@ -0,0 +1,45 @@
/**
* Copyright (C) 2008-2012 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the GNU Affero General Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#pragma once
/*
* This file's purpose is to confine the suppression of the Clang warning for mismatched-tags (struct vs class)
* in only the s2.h file
*/
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wmismatched-tags"
#endif
#include "third_party/s2/s2.h"
#ifdef __clang__
#pragma GCC diagnostic pop
#endif

View File

@ -31,7 +31,7 @@
#include "mongo/db/geo/geoconstants.h"
#include "mongo/db/geo/geoparser.h"
#include "mongo/db/geo/geoquery.h"
#include "third_party/s2/s2.h"
#include "mongo/db/geo/s2.h"
#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2regioncoverer.h"

View File

@ -28,7 +28,7 @@
#include "mongo/db/geo/geoparser.h"
#include "mongo/db/geo/geoconstants.h"
#include "third_party/s2/s2.h"
#include "mongo/db/geo/s2.h"
#include "third_party/s2/s2regioncoverer.h"
#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2polyline.h"

View File

@ -33,7 +33,7 @@
#include "mongo/base/owned_pointer_vector.h"
#include "mongo/db/jsobj.h"
#include "third_party/s2/s2.h"
#include "mongo/db/geo/s2.h"
#include "third_party/s2/s2cap.h"
#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2latlng.h"

View File

@ -36,7 +36,7 @@
#include "mongo/db/query/indexability.h"
#include "mongo/db/query/qlog.h"
#include "mongo/util/mongoutils/str.h"
#include "third_party/s2/s2.h"
#include "mongo/db/geo/s2.h"
#include "third_party/s2/s2cell.h"
#include "third_party/s2/s2regioncoverer.h"

View File

@ -1,6 +1,6 @@
# -*- mode: python -*-
Import("env windows linux darwin solaris")
Import("env windows linux darwin solaris use_clang")
env = env.Clone()
@ -14,6 +14,13 @@ env.SConscript( [
env.Append(CCFLAGS=['-Isrc/third_party/s2'])
env.Append(CCFLAGS=['-DDEBUG_MODE=false'])
# Clang warns about struct/class tag mismatch, but as long as this is
# not a problem on Windows, these mismatches can be ignored
# http://stackoverflow.com/questions/4866425/mixing-class-and-struct. W
# warning so it doesn't become an error.
if use_clang:
env.Append(CCFLAGS=['-Wno-mismatched-tags'])
env.StaticLibrary( "s2",
[
"s1angle.cc",