Skip to content

Commit

Permalink
Let COMPILE_ASSERT use static_assert if available.
Browse files Browse the repository at this point in the history
The motivation is that gcc 4.8+ and clang trunk warn on unused local
typedefs, which COMPILE_ASSERT adds. After this change, the warning
will be happy at least in C++11 builds. static_assert also produces a
slighly nicer diagnostic than the typedef method.

While here, merge https://codereview.appspot.com/57500045 and
https://codereview.appspot.com/13112043 so that the steps on
https://code.google.com/p/re2/wiki/Contribute work again.

R=rsc
CC=re2-dev
https://codereview.appspot.com/134590043
  • Loading branch information
nico committed Sep 7, 2014
1 parent 1aef6f5 commit eb93e8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/codereview/codereview.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ def line1(text):
'''

def promptyesno(ui, msg):
return ui.promptchoice(msg, ["&yes", "&no"], 0) == 0
if hgversion >= "2.7":
return ui.promptchoice(msg + " $$ &yes $$ &no", 0) == 0
else:
return ui.promptchoice(msg, ["&yes", "&no"], 0) == 0

def promptremove(ui, repo, f):
if promptyesno(ui, "hg remove %s (y/n)?" % (f,)):
Expand Down Expand Up @@ -2636,7 +2639,7 @@ def RietveldSetup(ui, repo):
rpc = None

global releaseBranch
tags = repo.branchtags().keys()
tags = repo.branchmap().keys()
if 'release-branch.go10' in tags:
# NOTE(rsc): This tags.sort is going to get the wrong
# answer when comparing release-branch.go9 with
Expand Down
4 changes: 4 additions & 0 deletions util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ typedef unsigned int uint;
typedef unsigned short ushort;

// COMPILE_ASSERT causes a compile error about msg if expr is not true.
#if __cplusplus >= 201103L
#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)
#else
template<bool> struct CompileAssert {};
#define COMPILE_ASSERT(expr, msg) \
typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
#endif

// DISALLOW_EVIL_CONSTRUCTORS disallows the copy and operator= functions.
// It goes in the private: declarations in a class.
Expand Down

0 comments on commit eb93e8b

Please sign in to comment.