aeubanks added a comment.

  $ cat /tmp/a.cc
  typedef struct Test {
  } Test;
  
  void f() {
    const Test constVal;
    _Generic(constVal, const Test : 0);
  }
  $ ./build/rel/bin/clang -fsyntax-only  -x c++ /tmp/a.cc -Wall
  /tmp/a.cc:6:28: warning: due to lvalue conversion of the controlling 
expression, association of type 'const Test' will never be selected because it 
is qualified [-Wunreachable-code-generic-assoc]
    _Generic(constVal, const Test : 0);
                             ^
  /tmp/a.cc:6:35: warning: expression result unused [-Wunused-value]
    _Generic(constVal, const Test : 0);
                                    ^
  2 warnings generated.
  $ ./build/rel/bin/clang -fsyntax-only  -x c /tmp/a.cc -Wall
  /tmp/a.cc:6:28: warning: due to lvalue conversion of the controlling 
expression, association of type 'const Test' (aka 'const struct Test') will 
never be selected because it is qualified [-Wunreachable-code-generic-assoc]
    _Generic(constVal, const Test : 0);
                             ^
  /tmp/a.cc:6:12: error: controlling expression type 'Test' (aka 'struct Test') 
not compatible with any generic association type
    _Generic(constVal, const Test : 0);
             ^~~~~~~~
  1 warning and 1 error generated.

the C++ case looks wrong, it's warning that `const Test` can't be selected then 
selects it


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125259/new/

https://reviews.llvm.org/D125259

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to