This is an archive of the discontinued LLVM Phabricator instance.

Implement DR1601 - Promotion of enumeration with fixed underlying type
Needs ReviewPublic

Authored by ismailp on Apr 19 2017, 3:37 PM.

Details

Reviewers
rsmith
Summary

Essentially, clang will accept the following in C++11 and forth:

enum B : bool { b };
enum C : char { c };

int &func(bool);
double &func(char);
void func(unsigned);
void func(long);

void g() {
  int &r = func(b);
  double &d = func(c);
}

Event Timeline

ismailp created this revision.Apr 19 2017, 3:37 PM
rsmith added inline comments.Apr 19 2017, 5:52 PM
lib/Sema/SemaOverload.cpp
3850–3853

This should probably go after all the standard orderings.

3872

I don't think it makes sense to condition this on C++11 mode: we support fixed underlying types for enums in C++98 as an extension, and they should get this behavior too.

3874–3879

This does not check that the "other" conversion converts to the promoted underlying type. It looks like this would (incorrectly) also order a case like:

enum A : char { a };
void f(char);
void f(const char&);
void g() { f(a); }