diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-15 00:50:56 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-15 00:50:56 +0000 |
commit | 8a8e0313bfb0131de8be93dca4d078a3c4dbafde (patch) | |
tree | a2d3b5dae9f61c131aa929b4d80595f081af8f1d /clang/lib | |
parent | 59ae1373299f20a111861aac360d93d25ce945e8 (diff) | |
download | bcm5719-llvm-8a8e0313bfb0131de8be93dca4d078a3c4dbafde.tar.gz bcm5719-llvm-8a8e0313bfb0131de8be93dca4d078a3c4dbafde.zip |
Add builtin conditional operator candidates for scoped enumeration
types, from Alp Toker! Fixes PR8344.
llvm-svn: 116549
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 4fef397f37a..d2f6ee725d5 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5255,9 +5255,9 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, // 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 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, 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; } } |