[cfe-dev] implicit int rule for c89

Rong, Hongbo hongbo.rong at intel.com
Mon Dec 15 10:50:16 PST 2014


I want to do some simple type inference on variables, if their types are missing. For example, if there is a statement like “a=1” or “a=”hello””, identifier a is automatically set to int or char*. Does clang has examples/code for similar situations?
Thanks!
From: James Dennett [mailto:james.dennett at gmail.com]
Sent: Sunday, December 14, 2014 10:32 PM
To: Rong, Hongbo
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] implicit int rule for c89

On Sun, Dec 14, 2014 at 10:21 PM, Rong, Hongbo <hongbo.rong at intel.com<mailto:hongbo.rong at intel.com>> wrote:
b.c:
int main() {
  a = 1;
  return a;
}

clang.exe -std=c89 b.c
b.c:2:3: error: use of undeclared identifier 'a'
  a = 1;
  ^
b.c:3:10: error: use of undeclared identifier 'a'
  return a;
         ^
2 errors generated.

For c89, why variable a is not made as an implicit int?


Because that's not what C89 says.  "implicit int" was for functions, not variables.

-- James



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141215/5709c6a1/attachment.html>


More information about the cfe-dev mailing list