[cfe-commits] r116549 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CXX/over/over.built/p25.cpp
Douglas Gregor
dgregor at apple.com
Thu Oct 14 17:50:56 PDT 2010
Author: dgregor
Date: Thu Oct 14 19:50:56 2010
New Revision: 116549
URL: http://llvm.org/viewvc/llvm-project?rev=116549&view=rev
Log:
Add builtin conditional operator candidates for scoped enumeration
types, from Alp Toker! Fixes PR8344.
Added:
cfe/trunk/test/CXX/over/over.built/p25.cpp (with props)
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=116549&r1=116548&r2=116549&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Oct 14 19:50:56 2010
@@ -5255,9 +5255,9 @@
// contextually converted to bool long ago. The candidates below are
// therefore added as binary.
//
- // C++ [over.built]p24:
- // For every type T, where T is a pointer or pointer-to-member type,
- // there exist candidate operator functions of the form
+ // C++ [over.built]p25:
+ // For every type T, where T is a pointer, pointer-to-member, or scoped
+ // enumeration type, there exist candidate operator functions of the form
//
// T operator?(bool, T, T);
//
@@ -5272,6 +5272,15 @@
QualType ParamTypes[2] = { *Ptr, *Ptr };
AddBuiltinCandidate(*Ptr, ParamTypes, Args, 2, CandidateSet);
}
+ if (getLangOptions().CPlusPlus0x)
+ for (BuiltinCandidateTypeSet::iterator Enum =
+ CandidateTypes.enumeration_begin(),
+ E = CandidateTypes.enumeration_end(); Enum != E; ++Enum) {
+ if (!(*Enum)->getAs<EnumType>()->getDecl()->isScoped())
+ continue;
+ QualType ParamTypes[2] = { *Enum, *Enum };
+ AddBuiltinCandidate(*Enum, ParamTypes, Args, 2, CandidateSet);
+ }
goto Conditional;
}
}
Added: cfe/trunk/test/CXX/over/over.built/p25.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.built/p25.cpp?rev=116549&view=auto
==============================================================================
--- cfe/trunk/test/CXX/over/over.built/p25.cpp (added)
+++ cfe/trunk/test/CXX/over/over.built/p25.cpp Thu Oct 14 19:50:56 2010
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+enum class Color { Red, Green, Blue };
+
+struct ConvertsToColorA {
+ operator Color();
+};
+
+struct ConvertsToColorB {
+ operator Color();
+};
+
+Color foo(bool cond, ConvertsToColorA ca, ConvertsToColorB cb) {
+ return cond? ca : cb;
+}
Propchange: cfe/trunk/test/CXX/over/over.built/p25.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/CXX/over/over.built/p25.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/CXX/over/over.built/p25.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the cfe-commits
mailing list