~ubuntu-branches/ubuntu/wily/aspectc++/wily

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/src/CSemantic.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-06-15 10:17:02 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090615101702-qsr30iptwbxylmo2
Tags: 1.0pre4~svn.20090615-1
* New upstream release.
* don't ignore errors in the postrm script
* avoid spurious creation of empty dir ./usr/sbin/
* improve short descriptions of libpuma-doc and libpuma-dev
* bump Standards-Version to 3.8.1
* bump debhelper compat level to level 7 (latest in stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
#define SEM_MSG(loc__,mesg__) \
61
61
  *_err << loc__->token ()->location () << mesg__ << endMessage
62
 
  
 
62
 
63
63
#define SEM_ERROR(loc__,mesg__) \
64
64
  SEM_MSG (loc__, sev_error << mesg__)
65
65
 
66
66
#define SEM_WARNING(loc__,mesg__) \
67
67
  SEM_MSG (loc__, sev_warning << mesg__)
68
68
 
 
69
#define SEM_WARNING__implicit_fct(loc__,name__) \
 
70
  SEM_MSG (loc__, sev_warning << "implicit declaration of function ‘" \
 
71
    << name__ << "'")
 
72
 
69
73
#define SEM_MSG__prev_loc(info__) \
70
74
  *_err << info__->SourceInfo ()->StartToken ()->token ()->location () \
71
75
        << "previously defined here" << endMessage
72
76
 
 
77
#define SEM_WARNING__redefinition(token__,type__,info__) \
 
78
  SEM_WARNING (token__, "redefinition of " << type__ \
 
79
    << "`" << info__->Name () << "'"); \
 
80
  SEM_MSG__prev_loc(info__)
 
81
 
73
82
#define SEM_ERROR__redefinition(token__,type__,info__) \
74
83
  SEM_ERROR (token__, "redefinition of " << type__ \
75
84
    << "`" << info__->Name () << "'"); \
79
88
  SEM_ERROR (token__, "`" << info__->Name () \
80
89
    << "' already defined"); \
81
90
  SEM_MSG__prev_loc(info__)
82
 
  
 
91
 
83
92
#define SEM_ERROR__conflicting_types(token__,info__) \
84
93
  SEM_ERROR (token__, "conflicting types for `" \
85
94
    << info__->Name () << "'"); \
86
95
  SEM_MSG__prev_loc(info__)
87
 
  
 
96
 
88
97
#define SEM_ERROR__duplicate(token__,type__,name__) \
89
98
  SEM_ERROR (token__, "duplicate " << type__ \
90
99
    << " `" << name__->Text () << "'")
102
111
  }
103
112
}
104
113
 
 
114
 
105
115
void CSemantic::configure (Config &c) {
106
116
  Semantic::configure (c);
107
117
}
334
344
       scope->Parent ()->FunctionInfo ())) && 
335
345
      ! result && scope != scope->Parent ())
336
346
    return lookup (id, scope->Parent ()->Structure (), type, nested);
337
 
  else    
 
347
  else
338
348
    return result;
339
349
}
340
350
 
341
351
 
342
352
 
 
353
CObjectInfo* CSemantic::lookupBuiltin (const char* name) const {
 
354
  CObjectInfo* info = 0;
 
355
  if (strncmp (name, "__builtin_", 10) == 0) {
 
356
    info = lookup (name+10, NON_TAG, true);
 
357
  }
 
358
  return info;
 
359
}
 
360
 
 
361
 
 
362
 
343
363
/*****************************************************************************/
344
364
/*                                                                           */
345
365
/*                  Linkage and storage class determination                  */
392
412
 SemObjType type, CLinkage::Type linkage) const {
393
413
  if (type == ATTRIB) {
394
414
    bool def_static = dss->declared (CT_PrimDeclSpec::PDS_STATIC);
 
415
    bool def_thread = dss->declared (CT_PrimDeclSpec::PDS_THREAD);
395
416
    if (linkage == CLinkage::LINK_EXTERNAL ||
396
417
        linkage == CLinkage::LINK_INTERNAL || def_static) {
397
 
      return CStorage::CLASS_STATIC;
 
418
      return def_thread ? CStorage::CLASS_THREAD : CStorage::CLASS_STATIC;
398
419
    } else if (linkage == CLinkage::LINK_NONE) {
399
420
      if (! def_static) 
400
421
        return CStorage::CLASS_AUTOMATIC;
428
449
 
429
450
 
430
451
CTree *CSemantic::id_expr () {
431
 
  CObjectInfo *info;
432
 
  info = lookup (builder ().get_node ()->token ()->text (), NON_TAG, true);
 
452
  CT_SimpleName *result = 0;
 
453
  const char* name = builder ().get_node ()->token ()->text ();
 
454
  CObjectInfo *info = lookup (name, NON_TAG, true);
 
455
  if (! info)
 
456
    info = lookupBuiltin (name);
433
457
  if (info && ! info->TypedefInfo ()) {
434
 
    CT_SimpleName *result = (CT_SimpleName*)builder ().simple_name ();
 
458
    result = (CT_SimpleName*)builder ().simple_name ();
435
459
    result->Object (info);
436
460
    result->setTypeRef (info->TypeInfo ());
437
 
    return result;
438
 
  } else 
439
 
    return (CTree*)0;
 
461
  } else if (syntax ().look_ahead () == TOK_OPEN_ROUND) {
 
462
    // call to undeclared function
 
463
    result = (CT_SimpleName*)builder ().simple_name ();
 
464
    SEM_WARNING__implicit_fct (result, name);
 
465
  }
 
466
  return result;
440
467
}
441
468
 
442
469
 
474
501
    } else if (! typeMatch (type, prev->TypeInfo ())) {
475
502
      SEM_ERROR__conflicting_types (id, prev);
476
503
    } else if (is_typedef) {
477
 
      SEM_ERROR__redefinition (id, "typedef ", prev);
 
504
      // for compatibility only issue a warning
 
505
      SEM_WARNING__redefinition (id, "typedef ", prev);
 
506
      id->Object (prev);
 
507
      return id;
478
508
    } else if (is_attr && (prev->Linkage () == CLinkage::LINK_NONE ||
479
509
      determine_linkage (dsi, ATTRIB, prev) == CLinkage::LINK_NONE)) {
480
510
      SEM_ERROR__redefinition (id, "", prev);
481
 
    } else 
 
511
    } else
482
512
      error = false;
483
 
      
484
513
    if (error) {
485
514
      delete id;
486
515
      return (CTree*)0;
699
728
  } else if (dsi->declared (CT_PrimDeclSpec::PDS_TYPEDEF) ||
700
729
             dsi->declared (CT_PrimDeclSpec::PDS_AUTO) ||
701
730
             dsi->declared (CT_PrimDeclSpec::PDS_STATIC) ||
 
731
             dsi->declared (CT_PrimDeclSpec::PDS_THREAD) ||
702
732
             dsi->declared (CT_PrimDeclSpec::PDS_EXTERN)) {
703
733
    SEM_ERROR__wrong_storage_class (ad, "function parameter", csd.Name ());
704
734
  } else
807
837
  }
808
838
    
809
839
  if (oi) {
810
 
    if (oi->FunctionInfo ()->isDefined ()) {
 
840
    if (isRedefinedFunction (oi->FunctionInfo ())) {
811
841
      SEM_ERROR__redefinition (d, "function ", oi);
812
842
      return (CTree*)0;
813
843
    } else
830
860
}
831
861
 
832
862
 
 
863
bool CSemantic::isRedefinedFunction (CFunctionInfo* fct) const {
 
864
  return fct->isDefined ();
 
865
}
 
866
 
833
867
 
834
868
CTree *CSemantic::introduce_class () {
835
869
  CObjectInfo *info, *oi;
945
979
      oi = (CObjectInfo*)0; 
946
980
  }
947
981
  if (oi) {
948
 
    if (tag->NodeName () == CT_ClassSpec::NodeId () && ! oi->ClassInfo () ||
949
 
        tag->NodeName () == CT_UnionSpec::NodeId () && ! oi->UnionInfo () ||
950
 
        tag->NodeName () == CT_EnumSpec::NodeId ()  && ! oi->EnumInfo ()) {
 
982
    if ((tag->NodeName () == CT_ClassSpec::NodeId () && ! oi->ClassInfo ()) ||
 
983
        (tag->NodeName () == CT_UnionSpec::NodeId () && ! oi->UnionInfo ()) ||
 
984
        (tag->NodeName () == CT_EnumSpec::NodeId ()  && ! oi->EnumInfo ())) {
951
985
      SEM_ERROR (tag, "wrong use of `" << *tag->Name () << "'");
952
986
      return (CTree*)0;
953
987
    }
1051
1085
  } else if (dsi->declared (CT_PrimDeclSpec::PDS_TYPEDEF) ||
1052
1086
             dsi->declared (CT_PrimDeclSpec::PDS_EXTERN) ||
1053
1087
             dsi->declared (CT_PrimDeclSpec::PDS_STATIC) ||
 
1088
             dsi->declared (CT_PrimDeclSpec::PDS_THREAD) ||
1054
1089
             dsi->declared (CT_PrimDeclSpec::PDS_AUTO)) {
1055
1090
    SEM_ERROR__wrong_storage_class (id, "function parameter", csd.Name ());
1056
1091
  } else 
1137
1172
        if (type == CT_PrimDeclSpec::PDS_CHAR || 
1138
1173
            type == CT_PrimDeclSpec::PDS_WCHAR_T || 
1139
1174
            type == CT_PrimDeclSpec::PDS_BOOL ||
 
1175
            type == CT_PrimDeclSpec::PDS_C_BOOL ||
1140
1176
            type == CT_PrimDeclSpec::PDS_SHORT || 
1141
1177
            type == CT_PrimDeclSpec::PDS_INT || 
1142
1178
            type == CT_PrimDeclSpec::PDS_LONG ||
1434
1470
    
1435
1471
  if (dsi->declared (CT_PrimDeclSpec::PDS_VIRTUAL)) 
1436
1472
    info->isVirtual (true);
1437
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_STATIC)) 
 
1473
  if (dsi->declared (CT_PrimDeclSpec::PDS_STATIC)) 
1438
1474
    info->isStatic (true);
1439
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_EXTERN)) 
 
1475
  if (dsi->declared (CT_PrimDeclSpec::PDS_EXTERN)) 
1440
1476
    info->isExtern (true);
1441
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_MUTABLE)) 
 
1477
  if (dsi->declared (CT_PrimDeclSpec::PDS_MUTABLE)) 
1442
1478
    info->isMutable (true);
1443
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_REGISTER)) 
 
1479
  if (dsi->declared (CT_PrimDeclSpec::PDS_REGISTER)) 
1444
1480
    info->isRegister (true);
1445
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_EXPLICIT)) 
 
1481
  if (dsi->declared (CT_PrimDeclSpec::PDS_EXPLICIT)) 
1446
1482
    info->isExplicit (true);
1447
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_INLINE)) 
 
1483
  if (dsi->declared (CT_PrimDeclSpec::PDS_INLINE)) 
1448
1484
    info->isInline (true);
1449
 
  else if (dsi->declared (CT_PrimDeclSpec::PDS_AUTO)) 
 
1485
  if (dsi->declared (CT_PrimDeclSpec::PDS_AUTO)) 
1450
1486
    info->isAuto (true);
 
1487
  if (dsi->declared (CT_PrimDeclSpec::PDS_THREAD)) 
 
1488
    info->isThreadLocal (true);
1451
1489
}
1452
1490
 
1453
1491