===================================================================
@@ -198,8 +198,8 @@ in the following sections.
-fno-default-inline -fvisibility-inlines-hidden @gol
-fvisibility-ms-compat @gol
-Wabi -Wconversion-null -Wctor-dtor-privacy @gol
--Wdelete-non-virtual-dtor -Wliteral-suffix -Wnarrowing @gol
--Wnoexcept -Wnon-virtual-dtor -Wreorder @gol
+-Wdelete-non-virtual-dtor -Wenum-mismatch -Wliteral-suffix @gol
+-Wnarrowing -Wnoexcept -Wnon-virtual-dtor -Wreorder @gol
-Weffc++ -Wstrict-null-sentinel @gol
-Wno-non-template-friend -Wold-style-cast @gol
-Woverloaded-virtual -Wno-pmf-conversions @gol
@@ -3084,6 +3084,7 @@ Options} and @ref{Objective-C and Objective-C++ Di
-Wc++11-compat @gol
-Wchar-subscripts @gol
-Wenum-compare @r{(in C/Objc; this is on by default in C++)} @gol
+-Wenum-mismatch @r{(in C++)} @gol
-Wimplicit-int @r{(C and Objective-C only)} @gol
-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
-Wcomment @gol
@@ -4301,6 +4302,12 @@ Warn about a comparison between values of differen
this warning is enabled by default. In C this warning is enabled by
@option{-Wall}.
+@item -Wenum-mismatch @r{(C++ and Objective-C++ only)}
+@opindex Wenum-mismatch
+@opindex Wno-enum-mismatch
+Warn about values of different enumerated types in conditional
+expressions. This warning is enabled by @option{-Wall}.
+
@item -Wjump-misses-init @r{(C, Objective-C only)}
@opindex Wjump-misses-init
@opindex Wno-jump-misses-init
===================================================================
@@ -360,6 +360,10 @@ Wenum-compare
C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning
Warn about comparison of different enum types
+Wenum-mismatch
+C++ ObjC++ Var(warn_enum_mismatch) Warning LangEnabledBy(C++ ObjC++,Wall)
+Warn about enumeral mismatch in conditional expression
+
Werror
C ObjC C++ ObjC++
; Documented in common.opt
===================================================================
@@ -1,7 +1,7 @@
// { dg-do assemble }
-// { dg-options "-W -pedantic -ansi" }
+// { dg-options "-W -Wenum-mismatch -pedantic -ansi" }
-// Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2000, 2012 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 1 Sep 1999 <nathan@acm.org>
// Derived from bug report from Gabriel Dos Reis
// <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
===================================================================
@@ -0,0 +1,30 @@
+// PR c++/53524
+
+template < typename > struct PointerLikeTypeTraits {
+ enum { NumLowBitsAvailable };
+};
+
+class CodeGenInstruction;
+class CodeGenInstAlias;
+
+template < typename T>
+struct PointerIntPair {
+ enum { IntShift = T::NumLowBitsAvailable };
+};
+
+template < typename PT1, typename PT2 > struct PointerUnionUIntTraits {
+ enum {
+ PT1BitsAv = PointerLikeTypeTraits < PT1 >::NumLowBitsAvailable,
+ PT2BitsAv = PointerLikeTypeTraits < PT2 >::NumLowBitsAvailable,
+ NumLowBitsAvailable = 0 ? PT1BitsAv : PT2BitsAv
+ };
+};
+
+template < typename PT1, typename PT2 > class PointerUnion {
+ typedef PointerIntPair < PointerUnionUIntTraits < PT1, PT2 > > ValTy;
+ ValTy Val;
+};
+
+struct ClassInfo {
+ PointerUnion < CodeGenInstruction *, CodeGenInstAlias * > DefRec;
+};
===================================================================
@@ -0,0 +1,31 @@
+// PR c++/53524
+// { dg-options "-Wenum-mismatch" }
+
+template < typename > struct PointerLikeTypeTraits {
+ enum { NumLowBitsAvailable };
+};
+
+class CodeGenInstruction;
+class CodeGenInstAlias;
+
+template < typename T>
+struct PointerIntPair {
+ enum { IntShift = T::NumLowBitsAvailable };
+};
+
+template < typename PT1, typename PT2 > struct PointerUnionUIntTraits {
+ enum {
+ PT1BitsAv = PointerLikeTypeTraits < PT1 >::NumLowBitsAvailable,
+ PT2BitsAv = PointerLikeTypeTraits < PT2 >::NumLowBitsAvailable,
+ NumLowBitsAvailable = 0 ? PT1BitsAv : PT2BitsAv // { dg-warning "enumeral mismatch" }
+ };
+};
+
+template < typename PT1, typename PT2 > class PointerUnion {
+ typedef PointerIntPair < PointerUnionUIntTraits < PT1, PT2 > > ValTy;
+ ValTy Val;
+};
+
+struct ClassInfo {
+ PointerUnion < CodeGenInstruction *, CodeGenInstAlias * > DefRec;
+};
===================================================================
@@ -0,0 +1,31 @@
+// PR c++/53524
+// { dg-options "-Wall" }
+
+template < typename > struct PointerLikeTypeTraits {
+ enum { NumLowBitsAvailable };
+};
+
+class CodeGenInstruction;
+class CodeGenInstAlias;
+
+template < typename T>
+struct PointerIntPair {
+ enum { IntShift = T::NumLowBitsAvailable };
+};
+
+template < typename PT1, typename PT2 > struct PointerUnionUIntTraits {
+ enum {
+ PT1BitsAv = PointerLikeTypeTraits < PT1 >::NumLowBitsAvailable,
+ PT2BitsAv = PointerLikeTypeTraits < PT2 >::NumLowBitsAvailable,
+ NumLowBitsAvailable = 0 ? PT1BitsAv : PT2BitsAv // { dg-warning "enumeral mismatch" }
+ };
+};
+
+template < typename PT1, typename PT2 > class PointerUnion {
+ typedef PointerIntPair < PointerUnionUIntTraits < PT1, PT2 > > ValTy;
+ ValTy Val;
+};
+
+struct ClassInfo {
+ PointerUnion < CodeGenInstruction *, CodeGenInstAlias * > DefRec;
+};
===================================================================
@@ -4697,7 +4697,7 @@ build_conditional_expr_1 (tree arg1, tree arg2, tr
&& TREE_CODE (arg3_type) == ENUMERAL_TYPE)
{
if (complain & tf_warning)
- warning (0,
+ warning (OPT_Wenum_mismatch,
"enumeral mismatch in conditional expression: %qT vs %qT",
arg2_type, arg3_type);
}