================
@@ -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:
This actually came up before, see the resolved thread above from Feb 2025.
Tried `<< II` there too and got the same double-quoting issue (`''FOO1'' is
defined as...`), since the diagnostic text already has literal quotes baked in.
Kept it as `II->getName()` to avoid that.
https://github.com/llvm/llvm-project/pull/123495
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits