// 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);
//
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;
}
}
--- /dev/null
+// 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;
+}