================ @@ -692,6 +692,13 @@ def warn_maybe_falloff_nonvoid_function : Warning< def warn_falloff_nonvoid_function : Warning< "non-void function does not return a value">, InGroup<ReturnType>; +def warn_pure_attr_on_cxx_constructor : Warning< + "constructor cannot be 'pure' (undefined behavior)">, + InGroup<IncorrectAttributeUsage>; ---------------- AaronBallman wrote:
Also, I don't think it's always UB to mark a constructor as being pure, it's just not a sensible operation because a constructor does not produce a value. (For example, this constructor doesn't violate any principles of function purity except that it's not called for its value: `struct S { [[gnu::pure]] S() {} };`) And I think the same logic applies to marking a destructor as pure; it doesn't make sense as an operation. How about: `'%select{pure|const}0' attribute applied to a function which %select{returns 'void'|has no return value}1; attribute ignored`? Then it handles both situations, both attributes, and we don't need to invent a new warning group (it can go under `IgnoredAttributes`). https://github.com/llvm/llvm-project/pull/78200 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits