[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 17:53:44 PDT 2026
================
@@ -2548,6 +2548,28 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
return E;
}
+// Diagnose when a macro cannot be expanded because it's a function-like macro
+// being used as an object-like macro. Returns true if a diagnostic is emitted.
+static bool diagnoseFunctionLikeMacro(Sema &SemaRef, DeclarationName Name,
+ SourceLocation TypoLoc) {
+
+ if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
+ if (II->hasMacroDefinition()) {
+ MacroInfo *MI = SemaRef.PP.getMacroInfo(II);
+ if (MI && MI->isFunctionLike()) {
+ SemaRef.Diag(TypoLoc,
+ diag::err_undeclared_var_use_suggest_func_like_macro)
+ << II->getName();
----------------
StarOne01 wrote:
xD, Let me know if there's anything else you'd like changed.
https://github.com/llvm/llvm-project/pull/123495
More information about the cfe-commits
mailing list