[Clang] Accepts invalid constructor declaration with an asterisk
struct A {
*A();
};
See Compiler Explorer: https://compiler-explorer.com/z/ccf6rqenE
Just FYI, GCC has a similar bug and was filed as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118306 (there was also a recent regression with an ICE when defaulting the constructor which the reporter here reported to GCC as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118304 ).
@llvm/issue-subscribers-clang-frontend
Author: None (MagentaTreehouse)
Fun to note it accepts any number of asterisks: https://compiler-explorer.com/z/naaP75err
struct A {
******************A();
};
we can bring the whole gang along: https://compiler-explorer.com/z/TY8aq8G9W
struct A {
****A();
***~A();
**A(const A&);
*A(A&&);
};
goes back to clang-2.6: https://compiler-explorer.com/z/zWv4b45s7
To generalize further, Clang seems to allow any of the ptr-operators in the ptr-declarator for constructors and destructors.
Consider also these accepts-invalid cases: https://compiler-explorer.com/z/qdbdsjbWh
struct A {
*&A();
};
struct B {
*&&B();
};
struct C {
*const C();
};
struct D {
*const *D();
};
struct E {
*E::*E();
};
struct F {
*F::*const F();
};
Only to fail when there is a & in the front:
struct G {
&G();
};
Output:
<source>:2:5: error: cannot form a reference to 'void'
2 | &G();
| ^